[PATCH] D24693: [CodeGen] Don't emit lifetime intrinsics for some local variables

2016-10-25 Thread Vitaly Buka via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285176: [CodeGen] Don't emit lifetime intrinsics for some 
local variables (authored by vitalybuka).

Changed prior to commit:
  https://reviews.llvm.org/D24693?vs=74814=75832#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24693

Files:
  cfe/trunk/lib/CodeGen/CGDecl.cpp
  cfe/trunk/lib/CodeGen/CMakeLists.txt
  cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.h
  cfe/trunk/lib/CodeGen/VarBypassDetector.cpp
  cfe/trunk/lib/CodeGen/VarBypassDetector.h
  cfe/trunk/test/CodeGen/lifetime2.c

Index: cfe/trunk/lib/CodeGen/VarBypassDetector.h
===
--- cfe/trunk/lib/CodeGen/VarBypassDetector.h
+++ cfe/trunk/lib/CodeGen/VarBypassDetector.h
@@ -0,0 +1,70 @@
+//===--- VarBypassDetector.cpp - Bypass jumps detector *- C++ -*-=//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file contains VarBypassDetector class, which is used to detect
+// local variable declarations which can be bypassed by jumps.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_CODEGEN_VARBYPASSDETECTOR_H
+#define LLVM_CLANG_LIB_CODEGEN_VARBYPASSDETECTOR_H
+
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/SmallVector.h"
+
+namespace clang {
+
+class Decl;
+class Stmt;
+class VarDecl;
+
+namespace CodeGen {
+
+/// The class detects jumps which bypass local variables declaration:
+///goto L;
+///int a;
+///  L:
+///
+/// This is simplified version of JumpScopeChecker. Primary differences:
+///  * Detects only jumps into the scope local variables.
+///  * Does not detect jumps out of the scope of local variables.
+///  * Not limited to variables with initializers, JumpScopeChecker is limited.
+class VarBypassDetector {
+  // Scope information. Contains a parent scope and related variable
+  // declaration.
+  llvm::SmallVector, 48> Scopes;
+  // List of jumps with scopes.
+  llvm::SmallVector FromScopes;
+  // Lookup map to find scope for destinations.
+  llvm::DenseMap ToScopes;
+  // Set of variables which were bypassed by some jump.
+  llvm::DenseSet Bypasses;
+  // If true assume that all variables are being bypassed.
+  bool AlwaysBypassed = false;
+
+public:
+  void Init(const Stmt *Body);
+
+  /// Returns true if the variable declaration was by bypassed by any goto or
+  /// switch statement.
+  bool IsBypassed(const VarDecl *D) const {
+return AlwaysBypassed || Bypasses.find(D) != Bypasses.end();
+  }
+
+private:
+  bool BuildScopeInformation(const Decl *D, unsigned );
+  bool BuildScopeInformation(const Stmt *S, unsigned );
+  void Detect();
+  void Detect(unsigned From, unsigned To);
+};
+}
+}
+
+#endif
Index: cfe/trunk/lib/CodeGen/VarBypassDetector.cpp
===
--- cfe/trunk/lib/CodeGen/VarBypassDetector.cpp
+++ cfe/trunk/lib/CodeGen/VarBypassDetector.cpp
@@ -0,0 +1,168 @@
+//===--- VarBypassDetector.h - Bypass jumps detector --*- C++ -*-=//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "VarBypassDetector.h"
+
+#include "clang/AST/Decl.h"
+#include "clang/AST/Expr.h"
+#include "clang/AST/Stmt.h"
+
+using namespace clang;
+using namespace CodeGen;
+
+/// Clear the object and pre-process for the given statement, usually function
+/// body statement.
+void VarBypassDetector::Init(const Stmt *Body) {
+  FromScopes.clear();
+  ToScopes.clear();
+  Bypasses.clear();
+  Scopes = {{~0U, nullptr}};
+  unsigned ParentScope = 0;
+  AlwaysBypassed = !BuildScopeInformation(Body, ParentScope);
+  if (!AlwaysBypassed)
+Detect();
+}
+
+/// Build scope information for a declaration that is part of a DeclStmt.
+/// Returns false if we failed to build scope information and can't tell for
+/// which vars are being bypassed.
+bool VarBypassDetector::BuildScopeInformation(const Decl *D,
+  unsigned ) {
+  const VarDecl *VD = dyn_cast(D);
+  if (VD && VD->hasLocalStorage()) {
+Scopes.push_back({ParentScope, VD});
+ParentScope = Scopes.size() - 1;
+  }
+
+  if (const VarDecl *VD = dyn_cast(D))
+if (const Expr *Init = VD->getInit())
+  return BuildScopeInformation(Init, ParentScope);
+
+  return true;
+}
+
+/// Walk through the statements, adding any labels or gotos to
+/// LabelAndGotoScopes and recursively 

r285176 - [CodeGen] Don't emit lifetime intrinsics for some local variables

2016-10-25 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Wed Oct 26 00:42:30 2016
New Revision: 285176

URL: http://llvm.org/viewvc/llvm-project?rev=285176=rev
Log:
[CodeGen] Don't emit lifetime intrinsics for some local variables

Summary:
Current generation of lifetime intrinsics does not handle cases like:

```
  {
char x;
  l1:
bar(, 1);
  }
  goto l1;

```
We will get code like this:

```
  %x = alloca i8, align 1
  call void @llvm.lifetime.start(i64 1, i8* nonnull %x)
  br label %l1
l1:
  %call = call i32 @bar(i8* nonnull %x, i32 1)
  call void @llvm.lifetime.end(i64 1, i8* nonnull %x)
  br label %l1
```

So the second time bar was called for x which is marked as dead.
Lifetime markers here are misleading so it's better to remove them at all.
This type of bypasses are rare, e.g. code detects just 8 functions building
clang (2329 targets).

PR28267

Reviewers: eugenis

Subscribers: beanz, mgorny, cfe-commits

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

Added:
cfe/trunk/lib/CodeGen/VarBypassDetector.cpp
cfe/trunk/lib/CodeGen/VarBypassDetector.h
Modified:
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CMakeLists.txt
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/test/CodeGen/lifetime2.c

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=285176=285175=285176=diff
==
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Wed Oct 26 00:42:30 2016
@@ -1010,12 +1010,18 @@ CodeGenFunction::EmitAutoVarAlloca(const
   bool IsMSCatchParam =
   D.isExceptionVariable() && getTarget().getCXXABI().isMicrosoft();
 
-  // Emit a lifetime intrinsic if meaningful.  There's no point
-  // in doing this if we don't have a valid insertion point (?).
+  // Emit a lifetime intrinsic if meaningful. There's no point in doing 
this
+  // if we don't have a valid insertion point (?).
   if (HaveInsertPoint() && !IsMSCatchParam) {
-uint64_t size = CGM.getDataLayout().getTypeAllocSize(allocaTy);
-emission.SizeForLifetimeMarkers =
-  EmitLifetimeStart(size, address.getPointer());
+// goto or switch-case statements can break lifetime into several
+// regions which need more efforts to handle them correctly. PR28267
+// This is rare case, but it's better just omit intrinsics than have
+// them incorrectly placed.
+if (!Bypasses.IsBypassed()) {
+  uint64_t size = CGM.getDataLayout().getTypeAllocSize(allocaTy);
+  emission.SizeForLifetimeMarkers =
+  EmitLifetimeStart(size, address.getPointer());
+}
   } else {
 assert(!emission.useLifetimeMarkers());
   }

Modified: cfe/trunk/lib/CodeGen/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CMakeLists.txt?rev=285176=285175=285176=diff
==
--- cfe/trunk/lib/CodeGen/CMakeLists.txt (original)
+++ cfe/trunk/lib/CodeGen/CMakeLists.txt Wed Oct 26 00:42:30 2016
@@ -82,6 +82,7 @@ add_clang_library(clangCodeGen
   SanitizerMetadata.cpp
   SwiftCallingConv.cpp
   TargetInfo.cpp
+  VarBypassDetector.cpp
 
   DEPENDS
   ${codegen_deps}

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=285176=285175=285176=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Wed Oct 26 00:42:30 2016
@@ -1066,6 +1066,13 @@ void CodeGenFunction::GenerateCode(Globa
 if (SpecDecl->hasBody(SpecDecl))
   Loc = SpecDecl->getLocation();
 
+  Stmt *Body = FD->getBody();
+
+  // Initialize helper which will detect jumps which can cause invalid lifetime
+  // markers.
+  if (Body && ShouldEmitLifetimeMarkers)
+Bypasses.Init(Body);
+
   // Emit the standard function prologue.
   StartFunction(GD, ResTy, Fn, FnInfo, Args, Loc, BodyRange.getBegin());
 
@@ -1095,7 +1102,7 @@ void CodeGenFunction::GenerateCode(Globa
 // Implicit copy-assignment gets the same special treatment as implicit
 // copy-constructors.
 emitImplicitAssignmentOperatorBody(Args);
-  } else if (Stmt *Body = FD->getBody()) {
+  } else if (Body) {
 EmitFunctionBody(Args, Body);
   } else
 llvm_unreachable("no definition for emitted function");

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=285176=285175=285176=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Wed Oct 26 00:42:30 2016
@@ -21,6 +21,7 @@
 

[PATCH] D25902: [AVX-512] Fix the operand order for all calls to __builtin_ia32_vfmaddss3_mask.

2016-10-25 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285175: [AVX-512] Fix the operand order for all calls to 
__builtin_ia32_vfmaddss3_mask. (authored by ctopper).

Changed prior to commit:
  https://reviews.llvm.org/D25902?vs=75557=75830#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25902

Files:
  cfe/trunk/lib/Headers/avx512fintrin.h

Index: cfe/trunk/lib/Headers/avx512fintrin.h
===
--- cfe/trunk/lib/Headers/avx512fintrin.h
+++ cfe/trunk/lib/Headers/avx512fintrin.h
@@ -8338,17 +8338,17 @@
 static __inline__ __m128 __DEFAULT_FN_ATTRS
 _mm_mask_fmadd_ss (__m128 __W, __mmask8 __U, __m128 __A, __m128 __B)
 {
- return (__m128) __builtin_ia32_vfmaddss3_mask ((__v4sf) __A,
+ return (__m128) __builtin_ia32_vfmaddss3_mask ((__v4sf) __W,
+  (__v4sf) __A,
   (__v4sf) __B,
-  (__v4sf) __W,
   (__mmask8) __U,
   _MM_FROUND_CUR_DIRECTION);
 }
 
 #define _mm_mask_fmadd_round_ss(W, U, A, B, R) __extension__({\
-  (__m128)__builtin_ia32_vfmaddss3_mask((__v4sf)(__m128)(A), \
-(__v4sf)(__m128)(B), \
-(__v4sf)(__m128)(W), (__mmask8)(U), \
+  (__m128)__builtin_ia32_vfmaddss3_mask((__v4sf)(__m128)(W), \
+(__v4sf)(__m128)(A), \
+(__v4sf)(__m128)(B), (__mmask8)(U), \
 (int)(R)); })
 
 static __inline__ __m128 __DEFAULT_FN_ATTRS
@@ -8386,17 +8386,17 @@
 static __inline__ __m128 __DEFAULT_FN_ATTRS
 _mm_mask_fmsub_ss (__m128 __W, __mmask8 __U, __m128 __A, __m128 __B)
 {
- return (__m128) __builtin_ia32_vfmaddss3_mask ((__v4sf) __A,
+ return (__m128) __builtin_ia32_vfmaddss3_mask ((__v4sf) __W,
+  (__v4sf) __A,
   -(__v4sf) __B,
-  (__v4sf) __W,
   (__mmask8) __U,
   _MM_FROUND_CUR_DIRECTION);
 }
 
 #define _mm_mask_fmsub_round_ss(W, U, A, B, R) __extension__ ({\
-  (__m128)__builtin_ia32_vfmaddss3_mask((__v4sf)(__m128)(A), \
--(__v4sf)(__m128)(B), \
-(__v4sf)(__m128)(W), (__mmask8)(U), \
+  (__m128)__builtin_ia32_vfmaddss3_mask((__v4sf)(__m128)(W), \
+(__v4sf)(__m128)(A), \
+(__v4sf)(__m128)(B), (__mmask8)(U), \
 (int)(R)); })
 
 static __inline__ __m128 __DEFAULT_FN_ATTRS
@@ -8434,17 +8434,17 @@
 static __inline__ __m128 __DEFAULT_FN_ATTRS
 _mm_mask_fnmadd_ss (__m128 __W, __mmask8 __U, __m128 __A, __m128 __B)
 {
- return (__m128) __builtin_ia32_vfmaddss3_mask (-(__v4sf) __A,
+ return (__m128) __builtin_ia32_vfmaddss3_mask ((__v4sf) __W,
+  -(__v4sf) __A,
   (__v4sf) __B,
-  (__v4sf) __W,
   (__mmask8) __U,
   _MM_FROUND_CUR_DIRECTION);
 }
 
 #define _mm_mask_fnmadd_round_ss(W, U, A, B, R) __extension__ ({\
-  (__m128)__builtin_ia32_vfmaddss3_mask(-(__v4sf)(__m128)(A), \
-(__v4sf)(__m128)(B), \
-(__v4sf)(__m128)(W), (__mmask8)(U), \
+  (__m128)__builtin_ia32_vfmaddss3_mask((__v4sf)(__m128)(W), \
+-(__v4sf)(__m128)(A), \
+(__v4sf)(__m128)(B), (__mmask8)(U), \
 (int)(R)); })
 
 static __inline__ __m128 __DEFAULT_FN_ATTRS
@@ -8482,17 +8482,17 @@
 static __inline__ __m128 __DEFAULT_FN_ATTRS
 _mm_mask_fnmsub_ss (__m128 __W, __mmask8 __U, __m128 __A, __m128 __B)
 {
- return (__m128) __builtin_ia32_vfmaddss3_mask (-(__v4sf) __A,
+ return (__m128) __builtin_ia32_vfmaddss3_mask ((__v4sf) __W,
+  -(__v4sf) __A,
   -(__v4sf) __B,
-  (__v4sf) __W,
   (__mmask8) __U,
   _MM_FROUND_CUR_DIRECTION);
 }
 
 #define _mm_mask_fnmsub_round_ss(W, U, A, B, R) __extension__ ({\
-  (__m128)__builtin_ia32_vfmaddss3_mask(-(__v4sf)(__m128)(A), \
--(__v4sf)(__m128)(B), \
-(__v4sf)(__m128)(W), (__mmask8)(U), \
+  (__m128)__builtin_ia32_vfmaddss3_mask((__v4sf)(__m128)(W), \
+-(__v4sf)(__m128)(A), \
+-(__v4sf)(__m128)(B), (__mmask8)(U), \
 (int)(R)); })
 
 static __inline__ __m128 __DEFAULT_FN_ATTRS
@@ -8530,17 +8530,17 @@
 static __inline__ __m128d __DEFAULT_FN_ATTRS
 _mm_mask_fmadd_sd (__m128d __W, __mmask8 __U, __m128d __A, __m128d __B)
 {
- return (__m128d) __builtin_ia32_vfmaddsd3_mask ( (__v2df) __A,
+ return (__m128d) __builtin_ia32_vfmaddsd3_mask ( (__v2df) __W,
+  (__v2df) __A,
   (__v2df) __B,
-  (__v2df) __W,
   (__mmask8) __U,
   _MM_FROUND_CUR_DIRECTION);
 

r285175 - [AVX-512] Fix the operand order for all calls to __builtin_ia32_vfmaddss3_mask.

2016-10-25 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Wed Oct 26 00:35:38 2016
New Revision: 285175

URL: http://llvm.org/viewvc/llvm-project?rev=285175=rev
Log:
[AVX-512] Fix the operand order for all calls to __builtin_ia32_vfmaddss3_mask.

Summary: The preserved input should be the first argument and the vector inputs 
should be in the same order as the intrinsics it is used to implement.

Reviewers: igorb, delena

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/Headers/avx512fintrin.h

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=285175=285174=285175=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Wed Oct 26 00:35:38 2016
@@ -8338,17 +8338,17 @@ __builtin_ia32_gatherdiv16sf ((__v8sf) _
 static __inline__ __m128 __DEFAULT_FN_ATTRS
 _mm_mask_fmadd_ss (__m128 __W, __mmask8 __U, __m128 __A, __m128 __B)
 {
- return (__m128) __builtin_ia32_vfmaddss3_mask ((__v4sf) __A,
+ return (__m128) __builtin_ia32_vfmaddss3_mask ((__v4sf) __W,
+  (__v4sf) __A,
   (__v4sf) __B,
-  (__v4sf) __W,
   (__mmask8) __U,
   _MM_FROUND_CUR_DIRECTION);
 }
 
 #define _mm_mask_fmadd_round_ss(W, U, A, B, R) __extension__({\
-  (__m128)__builtin_ia32_vfmaddss3_mask((__v4sf)(__m128)(A), \
-(__v4sf)(__m128)(B), \
-(__v4sf)(__m128)(W), (__mmask8)(U), \
+  (__m128)__builtin_ia32_vfmaddss3_mask((__v4sf)(__m128)(W), \
+(__v4sf)(__m128)(A), \
+(__v4sf)(__m128)(B), (__mmask8)(U), \
 (int)(R)); })
 
 static __inline__ __m128 __DEFAULT_FN_ATTRS
@@ -8386,17 +8386,17 @@ _mm_mask3_fmadd_ss (__m128 __W, __m128 _
 static __inline__ __m128 __DEFAULT_FN_ATTRS
 _mm_mask_fmsub_ss (__m128 __W, __mmask8 __U, __m128 __A, __m128 __B)
 {
- return (__m128) __builtin_ia32_vfmaddss3_mask ((__v4sf) __A,
+ return (__m128) __builtin_ia32_vfmaddss3_mask ((__v4sf) __W,
+  (__v4sf) __A,
   -(__v4sf) __B,
-  (__v4sf) __W,
   (__mmask8) __U,
   _MM_FROUND_CUR_DIRECTION);
 }
 
 #define _mm_mask_fmsub_round_ss(W, U, A, B, R) __extension__ ({\
-  (__m128)__builtin_ia32_vfmaddss3_mask((__v4sf)(__m128)(A), \
--(__v4sf)(__m128)(B), \
-(__v4sf)(__m128)(W), (__mmask8)(U), \
+  (__m128)__builtin_ia32_vfmaddss3_mask((__v4sf)(__m128)(W), \
+(__v4sf)(__m128)(A), \
+(__v4sf)(__m128)(B), (__mmask8)(U), \
 (int)(R)); })
 
 static __inline__ __m128 __DEFAULT_FN_ATTRS
@@ -8434,17 +8434,17 @@ _mm_mask3_fmsub_ss (__m128 __W, __m128 _
 static __inline__ __m128 __DEFAULT_FN_ATTRS
 _mm_mask_fnmadd_ss (__m128 __W, __mmask8 __U, __m128 __A, __m128 __B)
 {
- return (__m128) __builtin_ia32_vfmaddss3_mask (-(__v4sf) __A,
+ return (__m128) __builtin_ia32_vfmaddss3_mask ((__v4sf) __W,
+  -(__v4sf) __A,
   (__v4sf) __B,
-  (__v4sf) __W,
   (__mmask8) __U,
   _MM_FROUND_CUR_DIRECTION);
 }
 
 #define _mm_mask_fnmadd_round_ss(W, U, A, B, R) __extension__ ({\
-  (__m128)__builtin_ia32_vfmaddss3_mask(-(__v4sf)(__m128)(A), \
-(__v4sf)(__m128)(B), \
-(__v4sf)(__m128)(W), (__mmask8)(U), \
+  (__m128)__builtin_ia32_vfmaddss3_mask((__v4sf)(__m128)(W), \
+-(__v4sf)(__m128)(A), \
+(__v4sf)(__m128)(B), (__mmask8)(U), \
 (int)(R)); })
 
 static __inline__ __m128 __DEFAULT_FN_ATTRS
@@ -8482,17 +8482,17 @@ _mm_mask3_fnmadd_ss (__m128 __W, __m128
 static __inline__ __m128 __DEFAULT_FN_ATTRS
 _mm_mask_fnmsub_ss (__m128 __W, __mmask8 __U, __m128 __A, __m128 __B)
 {
- return (__m128) __builtin_ia32_vfmaddss3_mask (-(__v4sf) __A,
+ return (__m128) __builtin_ia32_vfmaddss3_mask ((__v4sf) __W,
+  -(__v4sf) __A,
   -(__v4sf) __B,
-  (__v4sf) __W,
   (__mmask8) __U,
   _MM_FROUND_CUR_DIRECTION);
 }
 
 #define _mm_mask_fnmsub_round_ss(W, U, A, B, R) __extension__ ({\
-  (__m128)__builtin_ia32_vfmaddss3_mask(-(__v4sf)(__m128)(A), \
--(__v4sf)(__m128)(B), \
-(__v4sf)(__m128)(W), (__mmask8)(U), \
+  (__m128)__builtin_ia32_vfmaddss3_mask((__v4sf)(__m128)(W), \
+-(__v4sf)(__m128)(A), \
+-(__v4sf)(__m128)(B), (__mmask8)(U), \
 (int)(R)); })
 
 

[PATCH] D25845: [CUDA] Ignore implicit target attributes during function template instantiation.

2016-10-25 Thread Justin Lebar via cfe-commits
jlebar added a comment.

Doesn't look like we changed any testcases when we changed this behavior?  The 
change in behavior may be unobservable, but even still it seems worthwhile to 
have tests that check that we're not doing any of the alternatives we 
considered.




Comment at: lib/Sema/SemaCUDA.cpp:99
+  if (!D->hasAttrs())
+return false;
+  for (Attr *Attribute : D->getAttrs()) {

Is this early return necessary?



Comment at: lib/Sema/SemaCUDA.cpp:107
+  }
+  return false;
+}

Could we write this function as

  return llvm::any_of(D->getAttrs(), [&](Attr *Attribute) {
return isa(Attribute) && (!IgnoreImplicitAttr || 
!Attribute->isImplicit()) });



Comment at: lib/Sema/SemaCUDA.cpp:893
+
+void Sema::inheritCUDATargetAttrs(FunctionDecl *NewFD, FunctionDecl *OldFD) {
+  // Propagate CUDA target attributes from template to FD. This is

Perhaps `ToFD`, `FromFD` would be better names than "new" and "old".



Comment at: lib/Sema/SemaCUDA.cpp:896
+  // needed to ensure that FD and its template have the same
+  // effective target.
+  if (CUDAGlobalAttr *Attr = OldFD->getAttr()) {

This comment is confusing because this function's implementation doesn't have 
anything to do with templates, but the first sentence says we're copying from a 
template to "FD".

In addition to cleaning this up, maybe we should move the comment into Sema.h?



Comment at: lib/Sema/SemaCUDA.cpp:912
+}
+  }
+}

Could this be written as

  template
  static void copyAttrIfPresent(FunctionDecl *NewFD, FunctionDecl *OldFD) {
if (A *Attribute = OldFD->getAttr()) {
  ...
}
  }

  void Sema::inheritCUDATargetAttrs(...) {
copyAttrIfPresent(NewFD, OldFD);
...
  }

?  In particular I am not sure why we need this particular control flow in this 
function.



Comment at: lib/Sema/SemaDecl.cpp:8372
+// may end up with different effective targets. Instead,
+// specializations inherit target attributes from template in
+// CheckFunctionTemplateSpecialization() call below.

"from their templates" "in *the* foo() call below".

Although because "from their template__s__" is kind of confusing, I might 
rewrite to be singular:

  Instead, a specialization inherits its target attributes from its template ...



Comment at: lib/Sema/SemaTemplate.cpp:7048
   // target attributes into account, we perform target match check
   // here and reject candidates that have different target.
   if (LangOpts.CUDA &&

Missing some articles:

  Target attributes are part of the cuda function signature, so the deduced 
template's cuda target must match XXX [1].  Given that regular template 
deduction [2] does not take target attributes into account, we reject 
candidates here that have a different target.

[1] I am not sure what XXX should be.  The deduced template's cuda target must 
match what, exactly?

[2] What is "regular template deduction"?



Comment at: lib/Sema/SemaTemplate.cpp:7171
+  // must inherit in order to have the same effective target as its
+  // template.
+  if (LangOpts.CUDA)

Suggest

  A function template specialization inherits the target attributes of its 
template.  (We require the attributes explicitly in the code to match, but a 
template may have implicit attributes by virtue e.g. of being constexpr, and it 
passes these implicit attributes on to its specializations.)



Comment at: lib/Sema/SemaTemplate.cpp:7173
+  if (LangOpts.CUDA)
+inheritCUDATargetAttrs(FD, Specialization);
+

Isn't this backwards?  The function is `to, from`?  If this is a bug, can we 
add a test to catch this?


https://reviews.llvm.org/D25845



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


[PATCH] D25809: [CUDA] Improved target attribute-based overloading.

2016-10-25 Thread Justin Lebar via cfe-commits
jlebar added a comment.

Is it possible to write a testcase for the using-declaration change?


https://reviews.llvm.org/D25809



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


r285162 - Use printf instead of "echo -ne".

2016-10-25 Thread Rui Ueyama via cfe-commits
Author: ruiu
Date: Tue Oct 25 22:38:48 2016
New Revision: 285162

URL: http://llvm.org/viewvc/llvm-project?rev=285162=rev
Log:
Use printf instead of "echo -ne".

Not all echo commands support "-e".

Modified:
cfe/trunk/test/Driver/response-file-extra-whitespace.c

Modified: cfe/trunk/test/Driver/response-file-extra-whitespace.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/response-file-extra-whitespace.c?rev=285162=285161=285162=diff
==
--- cfe/trunk/test/Driver/response-file-extra-whitespace.c (original)
+++ cfe/trunk/test/Driver/response-file-extra-whitespace.c Tue Oct 25 22:38:48 
2016
@@ -3,7 +3,7 @@
 // some joined arguments (like "-x c") across lines to ensure that regular
 // clang (not clang-cl) can process it correctly.
 //
-// RUN: echo -en "-x\r\nc\r\n-DTEST\r\n" > %t.0.txt
+// RUN: printf " -x\r\nc\r\n-DTEST\r\n" > %t.0.txt
 // RUN: %clang -E @%t.0.txt %s -v 2>&1 | FileCheck %s -check-prefix=SHORT
 // SHORT: extern int it_works;
 


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


[PATCH] D19853: [safestack] Add -fruntime-init to support invoking functions during runtime init

2016-10-25 Thread Michael LeMay via cfe-commits
mlemay-intel abandoned this revision.
mlemay-intel added a comment.

I was able to setup a temporary thread control block early enough in musl libc 
initialization to obviate the need for an attribute like runtime_init.


https://reviews.llvm.org/D19853



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


r285160 - [modules] Fix assert if multiple update records provide a definition for a

2016-10-25 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Oct 25 21:31:56 2016
New Revision: 285160

URL: http://llvm.org/viewvc/llvm-project?rev=285160=rev
Log:
[modules] Fix assert if multiple update records provide a definition for a
class template specialization and that specialization has attributes.

Modified:
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/test/Modules/Inputs/templates-left.h
cfe/trunk/test/Modules/Inputs/templates-right.h
cfe/trunk/test/Modules/Inputs/templates-top.h
cfe/trunk/test/Modules/templates.mm

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=285160=285159=285160=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Tue Oct 25 21:31:56 2016
@@ -3930,7 +3930,10 @@ void ASTDeclReader::UpdateDecl(Decl *D,
   if (Record[Idx++]) {
 AttrVec Attrs;
 Reader.ReadAttributes(F, Attrs, Record, Idx);
-D->setAttrsImpl(Attrs, Reader.getContext());
+// If the declaration already has attributes, we assume that some other
+// AST file already loaded them.
+if (!D->hasAttrs())
+  D->setAttrsImpl(Attrs, Reader.getContext());
   }
   break;
 }

Modified: cfe/trunk/test/Modules/Inputs/templates-left.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/templates-left.h?rev=285160=285159=285160=diff
==
--- cfe/trunk/test/Modules/Inputs/templates-left.h (original)
+++ cfe/trunk/test/Modules/Inputs/templates-left.h Tue Oct 25 21:31:56 2016
@@ -70,3 +70,5 @@ namespace EmitDefaultedSpecialMembers {
 inline int *getStaticDataMemberLeft() {
   return WithUndefinedStaticDataMember::undefined;
 }
+
+inline WithAttributes make_with_attributes_left() { return 
WithAttributes(); }

Modified: cfe/trunk/test/Modules/Inputs/templates-right.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/templates-right.h?rev=285160=285159=285160=diff
==
--- cfe/trunk/test/Modules/Inputs/templates-right.h (original)
+++ cfe/trunk/test/Modules/Inputs/templates-right.h Tue Oct 25 21:31:56 2016
@@ -51,3 +51,5 @@ void outOfLineInlineUseRightH(void (OutO
 inline int *getStaticDataMemberRight() {
   return WithUndefinedStaticDataMember::undefined;
 }
+
+inline WithAttributes make_with_attributes_right() { return 
WithAttributes(); }

Modified: cfe/trunk/test/Modules/Inputs/templates-top.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/templates-top.h?rev=285160=285159=285160=diff
==
--- cfe/trunk/test/Modules/Inputs/templates-top.h (original)
+++ cfe/trunk/test/Modules/Inputs/templates-top.h Tue Oct 25 21:31:56 2016
@@ -58,3 +58,8 @@ namespace EmitDefaultedSpecialMembers {
 template struct WithUndefinedStaticDataMember {
   static T undefined;
 };
+
+template struct __attribute__((packed, aligned(2))) WithAttributes 
{
+  T value;
+};
+WithAttributes *get_with_attributes();

Modified: cfe/trunk/test/Modules/templates.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/templates.mm?rev=285160=285159=285160=diff
==
--- cfe/trunk/test/Modules/templates.mm (original)
+++ cfe/trunk/test/Modules/templates.mm Tue Oct 25 21:31:56 2016
@@ -116,4 +116,9 @@ void testStaticDataMember() {
   (void) getStaticDataMemberRight();
 }
 
-
+void testWithAttributes() {
+  auto a = make_with_attributes_left();
+  auto b = make_with_attributes_right();
+  static_assert(alignof(decltype(a)) == 2, "");
+  static_assert(alignof(decltype(b)) == 2, "");
+}


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


r285132 - [codeview] emit debug info for indirect virtual base classes

2016-10-25 Thread Bob Haarman via cfe-commits
Author: inglorion
Date: Tue Oct 25 17:19:32 2016
New Revision: 285132

URL: http://llvm.org/viewvc/llvm-project?rev=285132=rev
Log:
[codeview] emit debug info for indirect virtual base classes

Summary:
Fixes PR28281.

MSVC lists indirect virtual base classes in the field list of a class.
This change makes Clang emit the information necessary for LLVM to
emit such records.

Reviewers: rnk, ruiu, zturner

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

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/test/CodeGenCXX/debug-info-ms-vbase.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=285132=285131=285132=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Oct 25 17:19:32 2016
@@ -13,9 +13,9 @@
 
 #include "CGDebugInfo.h"
 #include "CGBlocks.h"
-#include "CGRecordLayout.h"
 #include "CGCXXABI.h"
 #include "CGObjCRuntime.h"
+#include "CGRecordLayout.h"
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "clang/AST/ASTContext.h"
@@ -31,6 +31,7 @@
 #include "clang/Lex/HeaderSearchOptions.h"
 #include "clang/Lex/ModuleMap.h"
 #include "clang/Lex/PreprocessorOptions.h"
+#include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/IR/Constants.h"
@@ -1380,13 +1381,33 @@ void CGDebugInfo::CollectCXXMemberFuncti
 void CGDebugInfo::CollectCXXBases(const CXXRecordDecl *RD, llvm::DIFile *Unit,
   SmallVectorImpl ,
   llvm::DIType *RecordTy) {
-  const ASTRecordLayout  = CGM.getContext().getASTRecordLayout(RD);
-  for (const auto  : RD->bases()) {
-llvm::DINode::DIFlags BFlags = llvm::DINode::FlagZero;
-uint64_t BaseOffset;
+  llvm::DenseSet SeenTypes;
+  CollectCXXBasesAux(RD, Unit, EltTys, RecordTy, RD->bases(), SeenTypes,
+ llvm::DINode::FlagZero);
+
+  // If we are generating CodeView debug info, we also need to emit records for
+  // indirect virtual base classes.
+  if (CGM.getCodeGenOpts().EmitCodeView) {
+CollectCXXBasesAux(RD, Unit, EltTys, RecordTy, RD->vbases(), SeenTypes,
+   llvm::DINode::FlagIndirectVirtualBase);
+  }
+}
 
+void CGDebugInfo::CollectCXXBasesAux(
+const CXXRecordDecl *RD, llvm::DIFile *Unit,
+SmallVectorImpl , llvm::DIType *RecordTy,
+const CXXRecordDecl::base_class_const_range ,
+llvm::DenseSet ,
+llvm::DINode::DIFlags StartingFlags) {
+  const ASTRecordLayout  = CGM.getContext().getASTRecordLayout(RD);
+  for (const auto  : Bases) {
 const auto *Base =
 cast(BI.getType()->getAs()->getDecl());
+if (!SeenTypes.insert(Base).second)
+  continue;
+auto *BaseTy = getOrCreateType(BI.getType(), Unit);
+llvm::DINode::DIFlags BFlags = StartingFlags;
+uint64_t BaseOffset;
 
 if (BI.isVirtual()) {
   if (CGM.getTarget().getCXXABI().isItaniumFamily()) {
@@ -1401,15 +1422,15 @@ void CGDebugInfo::CollectCXXBases(const
 BaseOffset =
 4 * CGM.getMicrosoftVTableContext().getVBTableIndex(RD, Base);
   }
-  BFlags = llvm::DINode::FlagVirtual;
+  BFlags |= llvm::DINode::FlagVirtual;
 } else
   BaseOffset = CGM.getContext().toBits(RL.getBaseClassOffset(Base));
 // FIXME: Inconsistent units for BaseOffset. It is in bytes when
 // BI->isVirtual() and bits when not.
 
 BFlags |= getAccessFlag(BI.getAccessSpecifier(), RD);
-llvm::DIType *DTy = DBuilder.createInheritance(
-RecordTy, getOrCreateType(BI.getType(), Unit), BaseOffset, BFlags);
+llvm::DIType *DTy =
+DBuilder.createInheritance(RecordTy, BaseTy, BaseOffset, BFlags);
 EltTys.push_back(DTy);
   }
 }

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=285132=285131=285132=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Tue Oct 25 17:19:32 2016
@@ -15,12 +15,14 @@
 #define LLVM_CLANG_LIB_CODEGEN_CGDEBUGINFO_H
 
 #include "CGBuilder.h"
+#include "clang/AST/DeclCXX.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/ExternalASTSource.h"
 #include "clang/AST/Type.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Frontend/CodeGenOptions.h"
 #include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/IR/DIBuilder.h"
 #include "llvm/IR/DebugInfo.h"
@@ -32,7 +34,6 @@ class MDNode;
 }
 
 namespace clang {
-class CXXMethodDecl;
 class ClassTemplateSpecializationDecl;
 class GlobalDecl;
 class ModuleMap;
@@ -218,6 +219,15 @@ class CGDebugInfo {

[PATCH] D25974: Fix implementation of the likely resolution of core issue 253 to support class based arrays.

2016-10-25 Thread Ian Tessier via cfe-commits
itessier created this revision.
itessier added a subscriber: cfe-commits.

https://reviews.llvm.org/D16552 implemented the likely resolution of core issue 
253, but didn't include support for class based array fields. E.g.:

struct A {
}

struct B {

  A a[2];

}

const B b;  // Fails, but should pass.


https://reviews.llvm.org/D25974

Files:
  lib/AST/DeclCXX.cpp
  test/SemaCXX/constexpr-value-init.cpp


Index: test/SemaCXX/constexpr-value-init.cpp
===
--- test/SemaCXX/constexpr-value-init.cpp
+++ test/SemaCXX/constexpr-value-init.cpp
@@ -35,3 +35,12 @@
   constexpr Z() : V() {}
 };
 constexpr int n = Z().c; // expected-error {{constant expression}} 
expected-note {{virtual base class}}
+
+struct E {
+  A a[2];
+};
+constexpr E e; // ok
+static_assert(e.a[0].a == 1, "");
+static_assert(e.a[0].b == 2, "");
+static_assert(e.a[1].a == 1, "");
+static_assert(e.a[1].b == 2, "");
Index: lib/AST/DeclCXX.cpp
===
--- lib/AST/DeclCXX.cpp
+++ lib/AST/DeclCXX.cpp
@@ -739,7 +739,7 @@
 }
 
 if (!Field->hasInClassInitializer() && !Field->isMutable()) {
-  if (CXXRecordDecl *FieldType = Field->getType()->getAsCXXRecordDecl()) {
+  if (CXXRecordDecl *FieldType = T->getAsCXXRecordDecl()) {
 if (FieldType->hasDefinition() && !FieldType->allowConstDefaultInit())
   data().HasUninitializedFields = true;
   } else {


Index: test/SemaCXX/constexpr-value-init.cpp
===
--- test/SemaCXX/constexpr-value-init.cpp
+++ test/SemaCXX/constexpr-value-init.cpp
@@ -35,3 +35,12 @@
   constexpr Z() : V() {}
 };
 constexpr int n = Z().c; // expected-error {{constant expression}} expected-note {{virtual base class}}
+
+struct E {
+  A a[2];
+};
+constexpr E e; // ok
+static_assert(e.a[0].a == 1, "");
+static_assert(e.a[0].b == 2, "");
+static_assert(e.a[1].a == 1, "");
+static_assert(e.a[1].b == 2, "");
Index: lib/AST/DeclCXX.cpp
===
--- lib/AST/DeclCXX.cpp
+++ lib/AST/DeclCXX.cpp
@@ -739,7 +739,7 @@
 }
 
 if (!Field->hasInClassInitializer() && !Field->isMutable()) {
-  if (CXXRecordDecl *FieldType = Field->getType()->getAsCXXRecordDecl()) {
+  if (CXXRecordDecl *FieldType = T->getAsCXXRecordDecl()) {
 if (FieldType->hasDefinition() && !FieldType->allowConstDefaultInit())
   data().HasUninitializedFields = true;
   } else {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25579: [codeview] emit debug info for indirect virtual base classes

2016-10-25 Thread Bob Haarman via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285132: [codeview] emit debug info for indirect virtual base 
classes (authored by inglorion).

Changed prior to commit:
  https://reviews.llvm.org/D25579?vs=75381=75804#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25579

Files:
  cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
  cfe/trunk/lib/CodeGen/CGDebugInfo.h
  cfe/trunk/test/CodeGenCXX/debug-info-ms-vbase.cpp

Index: cfe/trunk/test/CodeGenCXX/debug-info-ms-vbase.cpp
===
--- cfe/trunk/test/CodeGenCXX/debug-info-ms-vbase.cpp
+++ cfe/trunk/test/CodeGenCXX/debug-info-ms-vbase.cpp
@@ -24,6 +24,17 @@
 
 // CHECK: ![[HasVirtualMethod_base]] = !DIDerivedType(tag: DW_TAG_inheritance, scope: ![[HasPrimaryBase]], baseType: ![[HasVirtualMethod]])
 
+// CHECK: ![[HasIndirectVirtualBase:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "HasIndirectVirtualBase"
+// CHECK-SAME: elements: ![[elements:[0-9]+]]
+
+// CHECK: !DIDerivedType(tag: DW_TAG_inheritance, scope: ![[HasIndirectVirtualBase]], baseType: ![[HasPrimaryBase]]
+// CHECK-NOT: DIFlagIndirectVirtualBase
+// CHECK-SAME: )
+
+// CHECK: !DIDerivedType(tag: DW_TAG_inheritance, scope: ![[HasIndirectVirtualBase]], baseType: ![[SecondaryVTable]]
+// CHECK-SAME: flags:
+// CHECK-SAME: DIFlagIndirectVirtualBase
+
 // CHECK: ![[DynamicNoVFPtr:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "DynamicNoVFPtr",
 // CHECK-SAME: elements: ![[elements:[0-9]+]]
 
@@ -52,3 +63,6 @@
 
 HasPrimaryBase has_primary_base;
 
+struct HasIndirectVirtualBase : public HasPrimaryBase {};
+
+HasIndirectVirtualBase has_indirect_virtual_base;
Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
@@ -13,9 +13,9 @@
 
 #include "CGDebugInfo.h"
 #include "CGBlocks.h"
-#include "CGRecordLayout.h"
 #include "CGCXXABI.h"
 #include "CGObjCRuntime.h"
+#include "CGRecordLayout.h"
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "clang/AST/ASTContext.h"
@@ -31,6 +31,7 @@
 #include "clang/Lex/HeaderSearchOptions.h"
 #include "clang/Lex/ModuleMap.h"
 #include "clang/Lex/PreprocessorOptions.h"
+#include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/IR/Constants.h"
@@ -1380,13 +1381,33 @@
 void CGDebugInfo::CollectCXXBases(const CXXRecordDecl *RD, llvm::DIFile *Unit,
   SmallVectorImpl ,
   llvm::DIType *RecordTy) {
-  const ASTRecordLayout  = CGM.getContext().getASTRecordLayout(RD);
-  for (const auto  : RD->bases()) {
-llvm::DINode::DIFlags BFlags = llvm::DINode::FlagZero;
-uint64_t BaseOffset;
+  llvm::DenseSet SeenTypes;
+  CollectCXXBasesAux(RD, Unit, EltTys, RecordTy, RD->bases(), SeenTypes,
+ llvm::DINode::FlagZero);
+
+  // If we are generating CodeView debug info, we also need to emit records for
+  // indirect virtual base classes.
+  if (CGM.getCodeGenOpts().EmitCodeView) {
+CollectCXXBasesAux(RD, Unit, EltTys, RecordTy, RD->vbases(), SeenTypes,
+   llvm::DINode::FlagIndirectVirtualBase);
+  }
+}
 
+void CGDebugInfo::CollectCXXBasesAux(
+const CXXRecordDecl *RD, llvm::DIFile *Unit,
+SmallVectorImpl , llvm::DIType *RecordTy,
+const CXXRecordDecl::base_class_const_range ,
+llvm::DenseSet ,
+llvm::DINode::DIFlags StartingFlags) {
+  const ASTRecordLayout  = CGM.getContext().getASTRecordLayout(RD);
+  for (const auto  : Bases) {
 const auto *Base =
 cast(BI.getType()->getAs()->getDecl());
+if (!SeenTypes.insert(Base).second)
+  continue;
+auto *BaseTy = getOrCreateType(BI.getType(), Unit);
+llvm::DINode::DIFlags BFlags = StartingFlags;
+uint64_t BaseOffset;
 
 if (BI.isVirtual()) {
   if (CGM.getTarget().getCXXABI().isItaniumFamily()) {
@@ -1401,15 +1422,15 @@
 BaseOffset =
 4 * CGM.getMicrosoftVTableContext().getVBTableIndex(RD, Base);
   }
-  BFlags = llvm::DINode::FlagVirtual;
+  BFlags |= llvm::DINode::FlagVirtual;
 } else
   BaseOffset = CGM.getContext().toBits(RL.getBaseClassOffset(Base));
 // FIXME: Inconsistent units for BaseOffset. It is in bytes when
 // BI->isVirtual() and bits when not.
 
 BFlags |= getAccessFlag(BI.getAccessSpecifier(), RD);
-llvm::DIType *DTy = DBuilder.createInheritance(
-RecordTy, getOrCreateType(BI.getType(), Unit), BaseOffset, BFlags);
+llvm::DIType *DTy =
+DBuilder.createInheritance(RecordTy, BaseTy, BaseOffset, BFlags);
 EltTys.push_back(DTy);
   }
 }
Index: cfe/trunk/lib/CodeGen/CGDebugInfo.h
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h
+++ 

[PATCH] D25640: [CUDA] [AST] Allow isInlineDefinitionExternallyVisible to be called on functions without bodies.

2016-10-25 Thread Justin Lebar via cfe-commits
jlebar added a comment.

In https://reviews.llvm.org/D25640#579238, @tra wrote:

> I'm OK with the change, but the comments suggest that things may be more 
> complicated.
>  How about disabling assert for CUDA only?


I don't think that is the right approach.  This function has nothing to do with 
CUDA, so either the assertion is valid and we shouldn't be calling it this way, 
or it's not valid and we should remove the assertion.

Richard, would appreciate some help with this one.


https://reviews.llvm.org/D25640



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


[PATCH] D24695: [CodeGen] Move shouldEmitLifetimeMarkers into more convenient place

2016-10-25 Thread Vitaly Buka via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285158: [CodeGen] Move shouldEmitLifetimeMarkers into more 
convenient place (authored by vitalybuka).

Changed prior to commit:
  https://reviews.llvm.org/D24695?vs=72908=75827#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24695

Files:
  cfe/trunk/lib/CodeGen/CGDecl.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.h

Index: cfe/trunk/lib/CodeGen/CodeGenFunction.h
===
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h
@@ -1186,6 +1186,9 @@
   llvm::BasicBlock *TerminateHandler;
   llvm::BasicBlock *TrapBB;
 
+  /// True if we need emit the life-time markers.
+  const bool ShouldEmitLifetimeMarkers;
+
   /// Add a kernel metadata node to the named metadata node 'opencl.kernels'.
   /// In the kernel metadata node, reference the kernel function and metadata 
   /// nodes for its optional attribute qualifiers (OpenCL 1.1 6.7.2):
Index: cfe/trunk/lib/CodeGen/CGDecl.cpp
===
--- cfe/trunk/lib/CodeGen/CGDecl.cpp
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp
@@ -885,29 +885,12 @@
   EmitAutoVarCleanups(emission);
 }
 
-/// shouldEmitLifetimeMarkers - Decide whether we need emit the life-time
-/// markers.
-static bool shouldEmitLifetimeMarkers(const CodeGenOptions ,
-  const LangOptions ) {
-  // Asan uses markers for use-after-scope checks.
-  if (CGOpts.SanitizeAddressUseAfterScope)
-return true;
-
-  // Disable lifetime markers in msan builds.
-  // FIXME: Remove this when msan works with lifetime markers.
-  if (LangOpts.Sanitize.has(SanitizerKind::Memory))
-return false;
-
-  // For now, only in optimized builds.
-  return CGOpts.OptimizationLevel != 0;
-}
-
 /// Emit a lifetime.begin marker if some criteria are satisfied.
 /// \return a pointer to the temporary size Value if a marker was emitted, null
 /// otherwise
 llvm::Value *CodeGenFunction::EmitLifetimeStart(uint64_t Size,
 llvm::Value *Addr) {
-  if (!shouldEmitLifetimeMarkers(CGM.getCodeGenOpts(), getLangOpts()))
+  if (!ShouldEmitLifetimeMarkers)
 return nullptr;
 
   llvm::Value *SizeV = llvm::ConstantInt::get(Int64Ty, Size);
Index: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
@@ -38,29 +38,46 @@
 using namespace clang;
 using namespace CodeGen;
 
+/// shouldEmitLifetimeMarkers - Decide whether we need emit the life-time
+/// markers.
+static bool shouldEmitLifetimeMarkers(const CodeGenOptions ,
+  const LangOptions ) {
+  // Asan uses markers for use-after-scope checks.
+  if (CGOpts.SanitizeAddressUseAfterScope)
+return true;
+
+  // Disable lifetime markers in msan builds.
+  // FIXME: Remove this when msan works with lifetime markers.
+  if (LangOpts.Sanitize.has(SanitizerKind::Memory))
+return false;
+
+  // For now, only in optimized builds.
+  return CGOpts.OptimizationLevel != 0;
+}
+
 CodeGenFunction::CodeGenFunction(CodeGenModule , bool suppressNewContext)
 : CodeGenTypeCache(cgm), CGM(cgm), Target(cgm.getTarget()),
   Builder(cgm, cgm.getModule().getContext(), llvm::ConstantFolder(),
   CGBuilderInserterTy(this)),
   CurFn(nullptr), ReturnValue(Address::invalid()),
-  CapturedStmtInfo(nullptr),
-  SanOpts(CGM.getLangOpts().Sanitize), IsSanitizerScope(false),
-  CurFuncIsThunk(false), AutoreleaseResult(false), SawAsmBlock(false),
-  IsOutlinedSEHHelper(false),
-  BlockInfo(nullptr), BlockPointer(nullptr),
-  LambdaThisCaptureField(nullptr), NormalCleanupDest(nullptr),
-  NextCleanupDestIndex(1), FirstBlockInfo(nullptr), EHResumeBlock(nullptr),
-  ExceptionSlot(nullptr), EHSelectorSlot(nullptr),
-  DebugInfo(CGM.getModuleDebugInfo()),
+  CapturedStmtInfo(nullptr), SanOpts(CGM.getLangOpts().Sanitize),
+  IsSanitizerScope(false), CurFuncIsThunk(false), AutoreleaseResult(false),
+  SawAsmBlock(false), IsOutlinedSEHHelper(false), BlockInfo(nullptr),
+  BlockPointer(nullptr), LambdaThisCaptureField(nullptr),
+  NormalCleanupDest(nullptr), NextCleanupDestIndex(1),
+  FirstBlockInfo(nullptr), EHResumeBlock(nullptr), ExceptionSlot(nullptr),
+  EHSelectorSlot(nullptr), DebugInfo(CGM.getModuleDebugInfo()),
   DisableDebugInfo(false), DidCallStackSave(false), IndirectBranch(nullptr),
   PGO(cgm), SwitchInsn(nullptr), SwitchWeights(nullptr),
   CaseRangeBlock(nullptr), UnreachableBlock(nullptr), NumReturnExprs(0),
   NumSimpleReturnExprs(0), CXXABIThisDecl(nullptr),
   CXXABIThisValue(nullptr), CXXThisValue(nullptr),
   CXXStructorImplicitParamDecl(nullptr),

r285159 - [Sema] Handle CaseStmt and DefaultStmt as SwitchCase

2016-10-25 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Tue Oct 25 21:00:00 2016
New Revision: 285159

URL: http://llvm.org/viewvc/llvm-project?rev=285159=rev
Log:
[Sema] Handle CaseStmt and DefaultStmt as SwitchCase

Summary: rsmith

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

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

Modified: cfe/trunk/lib/Sema/JumpDiagnostics.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/JumpDiagnostics.cpp?rev=285159=285158=285159=diff
==
--- cfe/trunk/lib/Sema/JumpDiagnostics.cpp (original)
+++ cfe/trunk/lib/Sema/JumpDiagnostics.cpp Tue Oct 25 21:00:00 2016
@@ -550,10 +550,8 @@ void JumpScopeChecker::BuildScopeInforma
 // order to avoid blowing out the stack.
 while (true) {
   Stmt *Next;
-  if (CaseStmt *CS = dyn_cast(SubStmt))
-Next = CS->getSubStmt();
-  else if (DefaultStmt *DS = dyn_cast(SubStmt))
-Next = DS->getSubStmt();
+  if (SwitchCase *SC = dyn_cast(SubStmt))
+Next = SC->getSubStmt();
   else if (LabelStmt *LS = dyn_cast(SubStmt))
 Next = LS->getSubStmt();
   else


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


r285158 - [CodeGen] Move shouldEmitLifetimeMarkers into more convenient place

2016-10-25 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Tue Oct 25 20:59:57 2016
New Revision: 285158

URL: http://llvm.org/viewvc/llvm-project?rev=285158=rev
Log:
[CodeGen] Move shouldEmitLifetimeMarkers into more convenient place

Summary: D24693 will need access to it from other places

Reviewers: eugenis

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=285158=285157=285158=diff
==
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Tue Oct 25 20:59:57 2016
@@ -885,29 +885,12 @@ void CodeGenFunction::EmitAutoVarDecl(co
   EmitAutoVarCleanups(emission);
 }
 
-/// shouldEmitLifetimeMarkers - Decide whether we need emit the life-time
-/// markers.
-static bool shouldEmitLifetimeMarkers(const CodeGenOptions ,
-  const LangOptions ) {
-  // Asan uses markers for use-after-scope checks.
-  if (CGOpts.SanitizeAddressUseAfterScope)
-return true;
-
-  // Disable lifetime markers in msan builds.
-  // FIXME: Remove this when msan works with lifetime markers.
-  if (LangOpts.Sanitize.has(SanitizerKind::Memory))
-return false;
-
-  // For now, only in optimized builds.
-  return CGOpts.OptimizationLevel != 0;
-}
-
 /// Emit a lifetime.begin marker if some criteria are satisfied.
 /// \return a pointer to the temporary size Value if a marker was emitted, null
 /// otherwise
 llvm::Value *CodeGenFunction::EmitLifetimeStart(uint64_t Size,
 llvm::Value *Addr) {
-  if (!shouldEmitLifetimeMarkers(CGM.getCodeGenOpts(), getLangOpts()))
+  if (!ShouldEmitLifetimeMarkers)
 return nullptr;
 
   llvm::Value *SizeV = llvm::ConstantInt::get(Int64Ty, Size);

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=285158=285157=285158=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Tue Oct 25 20:59:57 2016
@@ -38,20 +38,35 @@
 using namespace clang;
 using namespace CodeGen;
 
+/// shouldEmitLifetimeMarkers - Decide whether we need emit the life-time
+/// markers.
+static bool shouldEmitLifetimeMarkers(const CodeGenOptions ,
+  const LangOptions ) {
+  // Asan uses markers for use-after-scope checks.
+  if (CGOpts.SanitizeAddressUseAfterScope)
+return true;
+
+  // Disable lifetime markers in msan builds.
+  // FIXME: Remove this when msan works with lifetime markers.
+  if (LangOpts.Sanitize.has(SanitizerKind::Memory))
+return false;
+
+  // For now, only in optimized builds.
+  return CGOpts.OptimizationLevel != 0;
+}
+
 CodeGenFunction::CodeGenFunction(CodeGenModule , bool suppressNewContext)
 : CodeGenTypeCache(cgm), CGM(cgm), Target(cgm.getTarget()),
   Builder(cgm, cgm.getModule().getContext(), llvm::ConstantFolder(),
   CGBuilderInserterTy(this)),
   CurFn(nullptr), ReturnValue(Address::invalid()),
-  CapturedStmtInfo(nullptr),
-  SanOpts(CGM.getLangOpts().Sanitize), IsSanitizerScope(false),
-  CurFuncIsThunk(false), AutoreleaseResult(false), SawAsmBlock(false),
-  IsOutlinedSEHHelper(false),
-  BlockInfo(nullptr), BlockPointer(nullptr),
-  LambdaThisCaptureField(nullptr), NormalCleanupDest(nullptr),
-  NextCleanupDestIndex(1), FirstBlockInfo(nullptr), EHResumeBlock(nullptr),
-  ExceptionSlot(nullptr), EHSelectorSlot(nullptr),
-  DebugInfo(CGM.getModuleDebugInfo()),
+  CapturedStmtInfo(nullptr), SanOpts(CGM.getLangOpts().Sanitize),
+  IsSanitizerScope(false), CurFuncIsThunk(false), AutoreleaseResult(false),
+  SawAsmBlock(false), IsOutlinedSEHHelper(false), BlockInfo(nullptr),
+  BlockPointer(nullptr), LambdaThisCaptureField(nullptr),
+  NormalCleanupDest(nullptr), NextCleanupDestIndex(1),
+  FirstBlockInfo(nullptr), EHResumeBlock(nullptr), ExceptionSlot(nullptr),
+  EHSelectorSlot(nullptr), DebugInfo(CGM.getModuleDebugInfo()),
   DisableDebugInfo(false), DidCallStackSave(false), 
IndirectBranch(nullptr),
   PGO(cgm), SwitchInsn(nullptr), SwitchWeights(nullptr),
   CaseRangeBlock(nullptr), UnreachableBlock(nullptr), NumReturnExprs(0),
@@ -60,7 +75,9 @@ CodeGenFunction::CodeGenFunction(CodeGen
   CXXStructorImplicitParamDecl(nullptr),
   CXXStructorImplicitParamValue(nullptr), OutermostConditional(nullptr),
   CurLexicalScope(nullptr), TerminateLandingPad(nullptr),
-  TerminateHandler(nullptr), TrapBB(nullptr) {
+  TerminateHandler(nullptr), TrapBB(nullptr),
+  

r285154 - [cxx_status] update comment

2016-10-25 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Oct 25 20:37:36 2016
New Revision: 285154

URL: http://llvm.org/viewvc/llvm-project?rev=285154=rev
Log:
[cxx_status] update comment

Modified:
cfe/trunk/www/cxx_status.html

Modified: cfe/trunk/www/cxx_status.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_status.html?rev=285154=285153=285154=diff
==
--- cfe/trunk/www/cxx_status.html (original)
+++ cfe/trunk/www/cxx_status.html Tue Oct 25 20:37:36 2016
@@ -614,7 +614,7 @@ as the draft C++1z standard evolves.
   http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0012r1.html;>P0012R1
   Partial
   
+   catching as non-noexcept yet. -->
 
 
   __has_include in preprocessor conditionals


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


Re: [libcxx] r249738 - Split out of .

2016-10-25 Thread Richard Smith via cfe-commits
Committed as r285152.

On Tue, Oct 25, 2016 at 3:09 PM, Richard Smith 
wrote:

> Missed one change from the test suite:
>
> Index: test/Modules/cstd.m
> ===
> --- test/Modules/cstd.m (revision 285117)
> +++ test/Modules/cstd.m (working copy)
> @@ -1,5 +1,5 @@
>  // RUN: rm -rf %t
> -// RUN: %clang_cc1 -fsyntax-only -isystem %S/Inputs/System/usr/include
> -ffreestanding -fmodules -fimplicit-module-maps -fmodules-cache-path=%t
> -D__need_wint_t -Werror=implicit-function-declaration %s
> +// RUN: %clang_cc1 -fsyntax-only -internal-isystem
> %S/Inputs/System/usr/include -fmodules -fimplicit-module-maps
> -fmodules-cache-path=%t -D__need_wint_t -Werror=implicit-function-declaration
> %s
>
>  @import uses_other_constants;
>  const double other_value = DBL_MAX;
>
>
> On Tue, Oct 25, 2016 at 2:56 PM, Richard Smith 
> wrote:
>
>> This was a thinko on my part: clang's builtin headers include_next the
>> system headers, not the other way around, so the system headers should be
>> implicitly textual, not clang's headers. This patch fixes the problem for
>> me with glibc. Does this help for Darwin too?
>>
>> On Tue, Oct 25, 2016 at 2:01 PM, Richard Smith 
>> wrote:
>>
>>> On Mon, Oct 24, 2016 at 4:58 PM, Bruno Cardoso Lopes via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 On Mon, Oct 24, 2016 at 4:17 PM, Richard Smith 
 wrote:
 > On Mon, Oct 24, 2016 at 3:30 PM, Bruno Cardoso Lopes
 >  wrote:
 >>
 >> > Sure, go ahead.
 >>
 >> I committed in r284797 and r284801 (libcxx). There's one minor issue
 >> I've found: the changes for the builtins affecting non submodule
 local
 >> visibility broke current users of plain "-fmodules" against our
 >> frameworks in public SDKs, in 10.11 & 10.12. I've attached a patch to
 >> work around that for the time being: make the new behavior dependent
 >> on local vis. Can you take a look?
 >
 >
 > What's the nature of the breakage? Generally I'd be fine with your
 patch,
 > but I wonder if there's something better we could do here.

 I haven't entirely isolated the problem, but they are all related to
 definitions from stdint.h. In one example below, uint32_t doesn't
 leak, requiring an explicit "#include " to make it work.

 -- example.m
 #import 
 --
 $ clang -arch x86_64 -isysroot
 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.
 platform/Developer/SDKs/MacOSX10.12.sdk
 -fmodules-cache-path=tmpcache example.m -E -o /dev/null  -fmodules

 While building module 'IOKit' imported from example.m:1:
 In file included from :2:
 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.
 platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frame
 works/IOKit.framework/Headers/IODataQueueClient.h:62:71:
 error: de
   'Darwin.POSIX._types._uint32_t' before it is required
 IOReturn IODataQueueDequeue(IODataQueueMemory *dataQueue, void *data,
 uint32_t *dataSize);
   ^
 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.
 platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/_types/_
 uint32_t.h:31:22:
 note: previous declaration is here
 typedef unsigned int uint32_t;
  ^
 bot.m:1:9: fatal error: could not build module 'IOKit'
 #import 
  ~~~^
>>>
>>>
>>> This change also broke local submodule visibility builds with modular
>>> glibc (see PR30778 for details). I have an idea for how to fix this;
>>> running it through bootstrap now.
>>>
>>> >> > Hmm. Ideally, we should try to pick something that captures the
 spirit
 >> > of
 >> > "only non-modular headers and headers from used modules".
 Something like
 >> > "ignore_modules_not_declared_used", but less wordy?
 >>
 >> Right. It's gonna be hard to shrink this to a meaningful short name.
 >> What about a more generic "no_escape"?  "no_undeclared_headers"?
 >
 >
 > Hmm. Maybe we could allow the existing [exhaustive] attribute to be
 > specified on a use-declaration:
 >
 >   use [exhaustive] a, b, c

 I don't understand, the 'Darwin' module map doesn't use the 'use'
 keyword in any of its modules, how do you suggest we would use that to
 express the 'ignore_modules_not_declared_used' idea?
>>>
>>>
>>> Hah, right, this would only work if your module has dependencies. Maybe
>>> an [exhaustive_uses] attribute on the module itself then?
>>>
>>
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r285152 - Treat module headers wrapped by our builtin headers as implicitly being textual

2016-10-25 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Oct 25 20:08:55 2016
New Revision: 285152

URL: http://llvm.org/viewvc/llvm-project?rev=285152=rev
Log:
Treat module headers wrapped by our builtin headers as implicitly being textual
headers. We previously got this check backwards and treated the wrapper header
as being textual.

This is important because our wrapper headers sometimes inject macros into the
system headers that they #include_next, and sometimes replace them entirely.

Modified:
cfe/trunk/lib/Lex/ModuleMap.cpp
cfe/trunk/test/Modules/Inputs/System/usr/include/stdbool.h
cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/stddef.h
cfe/trunk/test/Modules/cstd.m

Modified: cfe/trunk/lib/Lex/ModuleMap.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=285152=285151=285152=diff
==
--- cfe/trunk/lib/Lex/ModuleMap.cpp (original)
+++ cfe/trunk/lib/Lex/ModuleMap.cpp Tue Oct 25 20:08:55 2016
@@ -1881,16 +1881,20 @@ void ModuleMapParser::parseHeaderDecl(MM
   Module::Header H = {RelativePathName.str(), File};
   Map.excludeHeader(ActiveModule, H);
 } else {
-  // If there is a builtin counterpart to this file, add it now as a 
textual
-  // header, so it can be #include_next'd by the wrapper header, and can
-  // receive macros from the wrapper header.
+  // If there is a builtin counterpart to this file, add it now so it can
+  // wrap the system header.
   if (BuiltinFile) {
 // FIXME: Taking the name from the FileEntry is unstable and can give
 // different results depending on how we've previously named that file
 // in this build.
 Module::Header H = { BuiltinFile->getName(), BuiltinFile };
-Map.addHeader(ActiveModule, H, ModuleMap::ModuleHeaderRole(
-   Role | ModuleMap::TextualHeader));
+Map.addHeader(ActiveModule, H, Role);
+
+// If we have both a builtin and system version of the file, the
+// builtin version may want to inject macros into the system header, so
+// force the system header to be treated as a textual header in this
+// case.
+Role = ModuleMap::ModuleHeaderRole(Role | ModuleMap::TextualHeader);
   }
 
   // Record this header.

Modified: cfe/trunk/test/Modules/Inputs/System/usr/include/stdbool.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/System/usr/include/stdbool.h?rev=285152=285151=285152=diff
==
--- cfe/trunk/test/Modules/Inputs/System/usr/include/stdbool.h (original)
+++ cfe/trunk/test/Modules/Inputs/System/usr/include/stdbool.h Tue Oct 25 
20:08:55 2016
@@ -1 +1 @@
-#include_next 
+// Testing hack: does not define bool/true/false.

Modified: cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/stddef.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/stddef.h?rev=285152=285151=285152=diff
==
--- cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/stddef.h 
(original)
+++ cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/stddef.h Tue 
Oct 25 20:08:55 2016
@@ -1,2 +1 @@
 // stddef.h
-#include_next "stddef.h"

Modified: cfe/trunk/test/Modules/cstd.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/cstd.m?rev=285152=285151=285152=diff
==
--- cfe/trunk/test/Modules/cstd.m (original)
+++ cfe/trunk/test/Modules/cstd.m Tue Oct 25 20:08:55 2016
@@ -1,5 +1,5 @@
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -fsyntax-only -isystem %S/Inputs/System/usr/include 
-ffreestanding -fmodules -fimplicit-module-maps -fmodules-cache-path=%t 
-D__need_wint_t -Werror=implicit-function-declaration %s
+// RUN: %clang_cc1 -fsyntax-only -internal-isystem 
%S/Inputs/System/usr/include -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t -D__need_wint_t -Werror=implicit-function-declaration %s
 
 @import uses_other_constants;
 const double other_value = DBL_MAX;


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


[PATCH] D24372: [libcxx] Sprinkle constexpr over compressed_pair

2016-10-25 Thread Marshall Clow via cfe-commits
mclow.lists added a comment.

Looks better than before.


Repository:
  rL LLVM

https://reviews.llvm.org/D24372



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


r285150 - Implement name mangling proposal for exception specifications from cxx-abi-dev 2016-10-11.

2016-10-25 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Oct 25 20:05:54 2016
New Revision: 285150

URL: http://llvm.org/viewvc/llvm-project?rev=285150=rev
Log:
Implement name mangling proposal for exception specifications from cxx-abi-dev 
2016-10-11.

This has the following ABI impact:

 1) Functions whose parameter or return types are non-throwing function pointer
types have different manglings in c++1z mode from prior modes. This is
necessary because c++1z permits overloading on the noexceptness of function
pointer parameter types. A warning is issued for cases that will change
manglings in c++1z mode.

 2) Functions whose parameter or return types contain instantiation-dependent
exception specifications change manglings in all modes. This is necessary
to support overloading on / SFINAE in these exception specifications, which
a careful reading of the standard indicates has essentially always been
permitted.

Note that, in order to be affected by these changes, the code in question must
specify an exception specification on a function pointer/reference type that is
written syntactically within the declaration of another function. Such
declarations are very rare, and I have so far been unable to find any code
that would be affected by this. (Note that such things will probably become
more common in C++17, since it's a lot easier to get a noexcept function type
as a function parameter / return type there.)

This change does not affect the set of symbols produced by a build of clang,
libc++, or libc++abi.

Added:
cfe/trunk/test/CodeGenCXX/mangle-exception-spec.cpp
Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/test/CXX/drs/dr0xx.cpp
cfe/trunk/test/SemaCXX/cxx1z-noexcept-function-type.cpp

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=285150=285149=285150=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Tue Oct 25 20:05:54 2016
@@ -3323,6 +3323,9 @@ public:
   }
   /// Return whether this function has a dependent exception spec.
   bool hasDependentExceptionSpec() const;
+  /// Return whether this function has an instantiation-dependent exception
+  /// spec.
+  bool hasInstantiationDependentExceptionSpec() const;
   /// Result type of getNoexceptSpec().
   enum NoexceptResult {
 NR_NoNoexcept,  ///< There is no noexcept specifier.

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=285150=285149=285150=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Oct 25 20:05:54 
2016
@@ -481,6 +481,9 @@ def warn_deprecated_copy_operation : War
   "for %0 is deprecated because it has a user-declared "
   "%select{copy %select{assignment operator|constructor}1|destructor}2">,
   InGroup, DefaultIgnore;
+def warn_cxx1z_compat_exception_spec_in_signature : Warning<
+  "mangled name of %0 will change in C++17 due to non-throwing exception "
+  "specification in function signature">, InGroup;
 
 def warn_global_constructor : Warning<
   "declaration requires a global constructor">,

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=285150=285149=285150=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Tue Oct 25 20:05:54 2016
@@ -3153,10 +3153,14 @@ static bool isCanonicalExceptionSpecific
   // expansions (so we can't tell whether it's non-throwing) and all its
   // contained types are canonical.
   if (ESI.Type == EST_Dynamic) {
-for (QualType ET : ESI.Exceptions)
-  if (!ET.isCanonical() || !ET->getAs())
+bool AnyPackExpansions = false;
+for (QualType ET : ESI.Exceptions) {
+  if (!ET.isCanonical())
 return false;
-return true;
+  if (ET->getAs())
+AnyPackExpansions = true;
+}
+return AnyPackExpansions;
   }
 
   // A noexcept(expr) specification is (possibly) canonical if expr is

Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=285150=285149=285150=diff
==
--- cfe/trunk/lib/AST/ItaniumMangle.cpp (original)
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp Tue Oct 25 20:05:54 2016
@@ -2245,6 +2245,22 @@ 

[PATCH] D25241: [libcxx] Improve code generation for vector::clear().

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

LGTM


https://reviews.llvm.org/D25241



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


[PATCH] D25958: [libc++] Silence "unused parameter" warnings in test/support/archetypes.hpp

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

LGTM


https://reviews.llvm.org/D25958



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


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

2016-10-25 Thread Jordan Rose via cfe-commits
jordan_rose marked an inline comment as done.
jordan_rose added a comment.

Oops. Ignore the API notes file, which is only in Swift's branch of Clang right 
now.


Repository:
  rL LLVM

https://reviews.llvm.org/D25850



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


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

2016-10-25 Thread Jordan Rose via cfe-commits
jordan_rose retitled this revision from "[WIP] Accept nullability annotations 
(_Nullable) on array parameters" to "Accept nullability annotations (_Nullable) 
on array parameters".
jordan_rose updated the summary for this revision.
jordan_rose updated this revision to Diff 75820.
jordan_rose added a comment.

Updated based on feedback from Richard, fixed typedef support, added tests.

Are there additional tests I should add?


Repository:
  rL LLVM

https://reviews.llvm.org/D25850

Files:
  include/clang/AST/Type.h
  include/clang/Sema/Sema.h
  lib/AST/ASTContext.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/Lex/PPMacroExpansion.cpp
  lib/Parse/ParseDecl.cpp
  lib/Sema/SemaAPINotes.cpp
  lib/Sema/SemaType.cpp
  test/Parser/nullability.c
  test/Sema/nullability.c
  test/SemaCXX/nullability.cpp
  test/SemaObjC/nullability.m

Index: test/SemaObjC/nullability.m
===
--- test/SemaObjC/nullability.m
+++ test/SemaObjC/nullability.m
@@ -256,3 +256,26 @@
   p = c ? noneP : unspecifiedP;
   p = c ? noneP : noneP;
 }
+
+typedef int INTS[4];
+@interface ArraysInMethods
+- (void)simple:(int [_Nonnull 2])x;
+- (void)nested:(void *_Nullable [_Nonnull 2])x;
+- (void)nestedBad:(int [2][_Nonnull 2])x; // expected-error {{nullability specifier '_Nonnull' cannot be applied to non-pointer type 'int [2]'}}
+
+- (void)withTypedef:(INTS _Nonnull)x;
+- (void)withTypedefBad:(INTS _Nonnull[2])x; // expected-error{{nullability specifier '_Nonnull' cannot be applied to non-pointer type 'INTS' (aka 'int [4]')}}
+
+- (void)simpleSugar:(nonnull int [2])x;
+- (void)nestedSugar:(nonnull void *_Nullable [2])x; // expected-error {{nullability keyword 'nonnull' cannot be applied to multi-level pointer type 'void * _Nullable [2]'}} expected-note {{use nullability type specifier '_Nonnull' to affect the innermost pointer type of 'void * _Nullable [2]'}}
+- (void)sugarWithTypedef:(nonnull INTS)x;
+@end
+
+void test(ArraysInMethods *obj) {
+  [obj simple:0]; // expected-warning {{null passed to a callee that requires a non-null argument}}
+  [obj nested:0]; // expected-warning {{null passed to a callee that requires a non-null argument}}
+  [obj withTypedef:0]; // expected-warning {{null passed to a callee that requires a non-null argument}}
+
+  [obj simpleSugar:0]; // expected-warning {{null passed to a callee that requires a non-null argument}}
+  [obj sugarWithTypedef:0]; // expected-warning {{null passed to a callee that requires a non-null argument}}
+}
Index: test/SemaCXX/nullability.cpp
===
--- test/SemaCXX/nullability.cpp
+++ test/SemaCXX/nullability.cpp
@@ -117,3 +117,16 @@
   p = c ? nullableD : nonnullB; // expected-warning{{implicit conversion from nullable pointer 'Base * _Nullable' to non-nullable pointer type 'Base * _Nonnull}}
   p = c ? nullableD : nullableB; // expected-warning{{implicit conversion from nullable pointer 'Base * _Nullable' to non-nullable pointer type 'Base * _Nonnull}}
 }
+
+void arraysInLambdas() {
+  typedef int INTS[4];
+  auto simple = [](int [_Nonnull 2]) {};
+  simple(nullptr); // expected-warning {{null passed to a callee that requires a non-null argument}}
+  auto nested = [](void *_Nullable [_Nonnull 2]) {};
+  nested(nullptr); // expected-warning {{null passed to a callee that requires a non-null argument}}
+  auto nestedBad = [](int [2][_Nonnull 2]) {}; // expected-error {{nullability specifier '_Nonnull' cannot be applied to non-pointer type 'int [2]'}}
+
+  auto withTypedef = [](INTS _Nonnull) {};
+  withTypedef(nullptr); // expected-warning {{null passed to a callee that requires a non-null argument}}
+  auto withTypedefBad = [](INTS _Nonnull[2]) {}; // expected-error {{nullability specifier '_Nonnull' cannot be applied to non-pointer type 'INTS' (aka 'int [4]')}}
+}
Index: test/Sema/nullability.c
===
--- test/Sema/nullability.c
+++ test/Sema/nullability.c
@@ -195,3 +195,55 @@
   p = noneP ?: unspecifiedP;
   p = noneP ?: noneP;
 }
+
+extern int GLOBAL_LENGTH;
+
+// Nullability can appear on arrays when the arrays are in parameter lists.
+void arrays(int ints[_Nonnull],
+void *ptrs[_Nullable],
+void **nestedPtrs[_Nullable],
+void * _Null_unspecified * _Nonnull nestedPtrs2[_Nullable],
+int fixedSize[_Nonnull 2],
+int staticSize[_Nonnull static 2],
+int staticSize2[static _Nonnull 2],
+int starSize[_Nonnull *],
+int vla[_Nonnull GLOBAL_LENGTH],
+void ** _Nullable reference);
+void testDecayedType() {
+  int produceAnErrorMessage = arrays; // expected-warning {{incompatible pointer to integer conversion initializing 'int' with an expression of type 'void (int * _Nonnull, void ** _Nullable, void *** _Nullable, void * _Null_unspecified * _Nonnull * _Nullable, int * _Nonnull, int * _Nonnull, int * _Nonnull, int * 

[PATCH] D25206: [Parser] Correct typo after lambda capture initializer is parsed

2016-10-25 Thread Akira Hatanaka via cfe-commits
ahatanak updated this revision to Diff 75819.
ahatanak marked 2 inline comments as done.
ahatanak added a comment.

Skip the step to correct typo if ParseInitializer returns ExprError(). Add a 
test case that exercises the change.


https://reviews.llvm.org/D25206

Files:
  lib/Parse/ParseExprCXX.cpp
  test/SemaCXX/lambda-expressions.cpp


Index: test/SemaCXX/lambda-expressions.cpp
===
--- test/SemaCXX/lambda-expressions.cpp
+++ test/SemaCXX/lambda-expressions.cpp
@@ -525,3 +525,18 @@
   decltype(a)::D b;
 }
 }
+
+namespace PR30566 {
+int name1; // expected-note {{'name1' declared here}}
+
+struct S1 {
+  template
+  S1(T t) { s = sizeof(t); }
+  int s;
+};
+
+void foo1() {
+  auto s0 = S1{[name=]() {}}; // expected-error 2 {{expected expression}}
+  auto s1 = S1{[name=name]() {}}; // expected-error {{use of undeclared 
identifier 'name'; did you mean 'name1'?}}
+}
+}
Index: lib/Parse/ParseExprCXX.cpp
===
--- lib/Parse/ParseExprCXX.cpp
+++ lib/Parse/ParseExprCXX.cpp
@@ -948,6 +948,8 @@
   SourceLocation StartLoc = Tok.getLocation();
   InMessageExpressionRAIIObject MaybeInMessageExpression(*this, true);
   Init = ParseInitializer();
+  if (!Init.isInvalid())
+Init = Actions.CorrectDelayedTyposInExpr(Init.get());
 
   if (Tok.getLocation() != StartLoc) {
 // Back out the lexing of the token after the initializer.


Index: test/SemaCXX/lambda-expressions.cpp
===
--- test/SemaCXX/lambda-expressions.cpp
+++ test/SemaCXX/lambda-expressions.cpp
@@ -525,3 +525,18 @@
   decltype(a)::D b;
 }
 }
+
+namespace PR30566 {
+int name1; // expected-note {{'name1' declared here}}
+
+struct S1 {
+  template
+  S1(T t) { s = sizeof(t); }
+  int s;
+};
+
+void foo1() {
+  auto s0 = S1{[name=]() {}}; // expected-error 2 {{expected expression}}
+  auto s1 = S1{[name=name]() {}}; // expected-error {{use of undeclared identifier 'name'; did you mean 'name1'?}}
+}
+}
Index: lib/Parse/ParseExprCXX.cpp
===
--- lib/Parse/ParseExprCXX.cpp
+++ lib/Parse/ParseExprCXX.cpp
@@ -948,6 +948,8 @@
   SourceLocation StartLoc = Tok.getLocation();
   InMessageExpressionRAIIObject MaybeInMessageExpression(*this, true);
   Init = ParseInitializer();
+  if (!Init.isInvalid())
+Init = Actions.CorrectDelayedTyposInExpr(Init.get());
 
   if (Tok.getLocation() != StartLoc) {
 // Back out the lexing of the token after the initializer.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25640: [CUDA] [AST] Allow isInlineDefinitionExternallyVisible to be called on functions without bodies.

2016-10-25 Thread Artem Belevich via cfe-commits
tra added a comment.

I'm OK with the change, but the comments suggest that things may be more 
complicated.
How about disabling assert for CUDA only?


https://reviews.llvm.org/D25640



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


[PATCH] D25940: [analyzer] LibraryFunctions: Fix errors due to different integral types and typedefs on different architectures.

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

Are the parameter types actually needed? I think in general the rest of the 
analyzer uses arity alone.

Is the idea to allow for overloads in C++? If so, then I think this 
equivalent-up-to-size-and-sign approach will disallow those overloads.




Comment at: lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:393
 
+bool StdLibraryFunctionsChecker::FunctionSummaryTy::typesAreEqual(
+QualType Lhs, QualType Rhs, ASTContext ) {

Maybe this should be named something like "typesMatch" since it is not actually 
return whether the types are equal?



Comment at: lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:418
+
+  return ACtx.getTypeSize(Lhs) == ACtx.getTypeSize(Rhs);
+}

If the problem is only for ssize_t, would it make sense to only do this if both 
the lhs and rhs are signed?

Another possibility is to have an lhs of what we think is the ssize_t type 
match any signed type.


https://reviews.llvm.org/D25940



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


[PATCH] D25809: [CUDA] Improved target attribute-based overloading.

2016-10-25 Thread Artem Belevich via cfe-commits
tra updated this revision to Diff 75816.
tra added a comment.

- handle using declarations found in the overload set we check.


https://reviews.llvm.org/D25809

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Sema/SemaCUDA.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaTemplate.cpp
  test/CodeGenCUDA/launch-bounds.cu
  test/SemaCUDA/function-overload.cu
  test/SemaCUDA/function-template-overload.cu
  test/SemaCUDA/target_attr_inheritance.cu

Index: test/SemaCUDA/target_attr_inheritance.cu
===
--- test/SemaCUDA/target_attr_inheritance.cu
+++ /dev/null
@@ -1,29 +0,0 @@
-// Verifies correct inheritance of target attributes during template
-// instantiation and specialization.
-
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify %s
-// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fsyntax-only -fcuda-is-device -verify %s
-
-#include "Inputs/cuda.h"
-
-// Function must inherit target attributes during instantiation, but not during
-// specialization.
-template  __host__ __device__ T function_template(const T );
-
-// Specialized functions have their own attributes.
-// expected-note@+1 {{candidate function not viable: call to __host__ function from __device__ function}}
-template <> __host__ float function_template(const float );
-
-// expected-note@+1 {{candidate function not viable: call to __device__ function from __host__ function}}
-template <> __device__ double function_template(const double );
-
-__host__ void hf() {
-  function_template(1.0f); // OK. Specialization is __host__.
-  function_template(2.0); // expected-error {{no matching function for call to 'function_template'}}
-  function_template(1);   // OK. Instantiated function template is HD.
-}
-__device__ void df() {
-  function_template(3.0f); // expected-error {{no matching function for call to 'function_template'}}
-  function_template(4.0); // OK. Specialization is __device__.
-  function_template(1);   // OK. Instantiated function template is HD.
-}
Index: test/SemaCUDA/function-template-overload.cu
===
--- /dev/null
+++ test/SemaCUDA/function-template-overload.cu
@@ -0,0 +1,82 @@
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++11 -triple nvptx64-nvidia-cuda -fsyntax-only -fcuda-is-device -verify %s
+
+#include "Inputs/cuda.h"
+
+struct HType {}; // expected-note-re 6 {{candidate constructor {{.*}} not viable: no known conversion from 'DType'}}
+struct DType {}; // expected-note-re 6 {{candidate constructor {{.*}} not viable: no known conversion from 'HType'}}
+struct HDType {};
+
+template  __host__ HType overload_h_d(T a) { return HType(); }
+// expected-note@-1 2 {{candidate template ignored: could not match 'HType' against 'DType'}}
+// expected-note@-2 2 {{candidate template ignored: target attributes do not match}}
+template  __device__ DType overload_h_d(T a) { return DType(); }
+// expected-note@-1 2 {{candidate template ignored: could not match 'DType' against 'HType'}}
+// expected-note@-2 2 {{candidate template ignored: target attributes do not match}}
+
+// Check explicit instantiation.
+template  __device__ __host__ DType overload_h_d(int a); // There's no HD template...
+// expected-error@-1 {{explicit instantiation of 'overload_h_d' does not refer to a function template, variable template, member function, member class, or static data member}}
+template  __device__ __host__ HType overload_h_d(int a); // There's no HD template...
+// expected-error@-1 {{explicit instantiation of 'overload_h_d' does not refer to a function template, variable template, member function, member class, or static data member}}
+template  __device__ DType overload_h_d(int a); // OK. instantiates D
+template  __host__ HType overload_h_d(int a); // OK. instantiates H
+
+// Check explicit specialization.
+template  <> __device__ __host__ DType overload_h_d(long a); // There's no HD template...
+// expected-error@-1 {{no function template matches function template specialization 'overload_h_d'}}
+template  <> __device__ __host__ HType overload_h_d(long a); // There's no HD template...
+// expected-error@-1 {{no function template matches function template specialization 'overload_h_d'}}
+template  <> __device__ DType overload_h_d(long a); // OK. instantiates D
+template  <> __host__ HType overload_h_d(long a); // OK. instantiates H
+
+
+// Can't overload HD template with H or D template, though functions are OK.
+template  __host__ __device__ HDType overload_hd(T a) { return HDType(); }
+// expected-note@-1 {{previous declaration is here}}
+// expected-note@-2 2 {{candidate template ignored: could not match 'HDType' against 'HType'}}
+template  __device__ HDType overload_hd(T a);
+// expected-error@-1 {{__device__ function 'overload_hd' cannot overload __host__ 

[PATCH] D25845: [CUDA] Ignore implicit target attributes during function template instantiation.

2016-10-25 Thread Artem Belevich via cfe-commits
tra updated this revision to Diff 75812.
tra added a comment.

- Instead of relying on the first attribute we find, check all matching ones.
- Specializations inherit their target attributes from their base template 
only. Their effective target always matches that of the template and is no 
longer affected by whether specialization differens from template in its 
constexpr-ness.


https://reviews.llvm.org/D25845

Files:
  include/clang/Sema/Sema.h
  lib/Sema/SemaCUDA.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaTemplate.cpp
  test/SemaCUDA/function-template-overload.cu

Index: test/SemaCUDA/function-template-overload.cu
===
--- test/SemaCUDA/function-template-overload.cu
+++ test/SemaCUDA/function-template-overload.cu
@@ -31,7 +31,8 @@
 template  <> __host__ HType overload_h_d(long a); // OK. instantiates H
 
 
-// Can't overload HD template with H or D template, though functions are OK.
+// Can't overload HD template with H or D template, though
+// non-template functions are OK.
 template  __host__ __device__ HDType overload_hd(T a) { return HDType(); }
 // expected-note@-1 {{previous declaration is here}}
 // expected-note@-2 2 {{candidate template ignored: could not match 'HDType' against 'HType'}}
@@ -56,24 +57,54 @@
 template  __host__ __device__ HDType overload_h_d2(T a) { return HDType(); }
 template  __device__ DType overload_h_d2(T1 a) { T1 x; T2 y; return DType(); }
 
+// constexpr functions are implicitly HD, but explicit
+// instantiation/specialization must use target attributes as written.
+template  constexpr T overload_ce_implicit_hd(T a) { return a+1; }
+// expected-note@-1 3 {{candidate template ignored: target attributes do not match}}
+
+// These will not match the template.
+template __host__ __device__ int overload_ce_implicit_hd(int a);
+// expected-error@-1 {{explicit instantiation of 'overload_ce_implicit_hd' does not refer to a function template, variable template, member function, member class, or static data member}}
+template <> __host__ __device__ long overload_ce_implicit_hd(long a);
+// expected-error@-1 {{no function template matches function template specialization 'overload_ce_implicit_hd'}}
+template <> __host__ __device__ constexpr long overload_ce_implicit_hd(long a);
+// expected-error@-1 {{no function template matches function template specialization 'overload_ce_implicit_hd'}}
+
+// These should work, because template matching ignores implicit HD
+// attributes compiler gives to constexpr functions/templates so
+// 'overload_ce_implicit_hd' template will match __host__ functions
+// only.
+template __host__ int overload_ce_implicit_hd(int a);
+template <> __host__ long overload_ce_implicit_hd(long a);
+
+template float overload_ce_implicit_hd(float a);
+template <> float* overload_ce_implicit_hd(float *a);
+template <> constexpr double overload_ce_implicit_hd(double a) { return a + 3.0; };
+
 __host__ void hf() {
   overload_hd(13);
+  overload_ce_implicit_hd('h');// Implicitly instantiated
+  overload_ce_implicit_hd(1.0f);   // Explicitly instantiated
+  overload_ce_implicit_hd(2.0);// Explicitly specialized
 
   HType h = overload_h_d(10);
   HType h2i = overload_h_d2(11);
   HType h2ii = overload_h_d2(12);
 
   // These should be implicitly instantiated from __host__ template returning HType.
-  DType d = overload_h_d(20); // expected-error {{no viable conversion from 'HType' to 'DType'}}
-  DType d2i = overload_h_d2(21); // expected-error {{no viable conversion from 'HType' to 'DType'}}
+  DType d = overload_h_d(20);  // expected-error {{no viable conversion from 'HType' to 'DType'}}
+  DType d2i = overload_h_d2(21);  // expected-error {{no viable conversion from 'HType' to 'DType'}}
   DType d2ii = overload_h_d2(22); // expected-error {{no viable conversion from 'HType' to 'DType'}}
 }
 __device__ void df() {
   overload_hd(23);
+  overload_ce_implicit_hd('d');// Implicitly instantiated
+  overload_ce_implicit_hd(1.0f);   // Explicitly instantiated
+  overload_ce_implicit_hd(2.0);// Explicitly specialized
 
   // These should be implicitly instantiated from __device__ template returning DType.
-  HType h = overload_h_d(10); // expected-error {{no viable conversion from 'DType' to 'HType'}}
-  HType h2i = overload_h_d2(11); // expected-error {{no viable conversion from 'DType' to 'HType'}}
+  HType h = overload_h_d(10);  // expected-error {{no viable conversion from 'DType' to 'HType'}}
+  HType h2i = overload_h_d2(11);  // expected-error {{no viable conversion from 'DType' to 'HType'}}
   HType h2ii = overload_h_d2(12); // expected-error {{no viable conversion from 'DType' to 'HType'}}
 
   DType d = overload_h_d(20);
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -7047,7 +7047,9 @@
   // target attributes into account, we 

Re: r284256 - Link static PIE programs against rcrt0.o on OpenBSD

2016-10-25 Thread Brad Smith via cfe-commits

On 10/18/16 22:13, Brad Smith via cfe-commits wrote:

On Fri, Oct 14, 2016 at 09:47:17PM -0400, Brad Smith via cfe-commits wrote:

On Fri, Oct 14, 2016 at 05:59:54PM -, Ed Maste via cfe-commits wrote:

Author: emaste
Date: Fri Oct 14 12:59:53 2016
New Revision: 284256

URL: http://llvm.org/viewvc/llvm-project?rev=284256=rev
Log:
Link static PIE programs against rcrt0.o on OpenBSD

Patch by Stefan Kempf.

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

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/openbsd.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=284256=284255=284256=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Oct 14 12:59:53 2016
@@ -8519,6 +8519,10 @@ void openbsd::Linker::ConstructJob(Compi
   if (Args.hasArg(options::OPT_pg))
 CmdArgs.push_back(
 Args.MakeArgString(getToolChain().GetFilePath("gcrt0.o")));
+  else if (Args.hasArg(options::OPT_static) &&
+   !Args.hasArg(options::OPT_nopie))
+CmdArgs.push_back(
+Args.MakeArgString(getToolChain().GetFilePath("rcrt0.o")));
   else
 CmdArgs.push_back(
 Args.MakeArgString(getToolChain().GetFilePath("crt0.o")));

Modified: cfe/trunk/test/Driver/openbsd.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/openbsd.c?rev=284256=284255=284256=diff
==
--- cfe/trunk/test/Driver/openbsd.c (original)
+++ cfe/trunk/test/Driver/openbsd.c Fri Oct 14 12:59:53 2016
@@ -67,3 +67,26 @@
 // CHECK-MIPS64-PIC: as{{.*}}" "-mabi" "64" "-EB" "-KPIC"
 // CHECK-MIPS64EL: as{{.*}}" "-mabi" "64" "-EL"
 // CHECK-MIPS64EL-PIC: as{{.*}}" "-mabi" "64" "-EL" "-KPIC"
+
+// Check linking against correct startup code when (not) using PIE
+// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd %s -### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-PIE %s
+// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd %s -fno-pie %s -### 
2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-PIE %s
+// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -static %s -### 
2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-STATIC-PIE %s
+// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -static -fno-pie %s 
-### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-STATIC-PIE %s
+// RUN: %clang -no-canonical-prefix -target i868-pc-openbsd -nopie %s -### 
2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-NOPIE %s
+// RUN: %clang -no-canonical-prefix -target i868-pc-openbsd -fno-pie -nopie %s -### 
2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-NOPIE %s
+// RUN: %clang -no-canonical-prefix -target i868-pc-openbsd -static -nopie %s -### 
2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-NOPIE %s
+// RUN: %clang -no-canonical-prefix -target i868-pc-openbsd -fno-pie -static -nopie 
%s -### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-NOPIE %s
+// CHECK-PIE: "/usr/lib/crt0.o"
+// CHECK-PIE-NOT: "-nopie"
+// CHECK-STATIC-PIE: "/usr/lib/rcrt0.o"
+// CHECK-STATIC-PIE-NOT: "-nopie"
+// CHECK-NOPIE: "-nopie" {{.*}}"/usr/lib/crt0.o"


Ok, I see the obvious issue with -no-canonical-prefix vs -no-canonical-prefixes
and fix the typo with the target triples.


After seeing what the test failure was I have adjusted the tests as appropriate.


ping.


Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp(revision 283697)
+++ lib/Driver/Tools.cpp(working copy)
@@ -8469,6 +8469,10 @@
   if (Args.hasArg(options::OPT_pg))
 CmdArgs.push_back(
 Args.MakeArgString(getToolChain().GetFilePath("gcrt0.o")));
+  else if (Args.hasArg(options::OPT_static) &&
+   !Args.hasArg(options::OPT_nopie))
+CmdArgs.push_back(
+Args.MakeArgString(getToolChain().GetFilePath("rcrt0.o")));
   else
 CmdArgs.push_back(
 Args.MakeArgString(getToolChain().GetFilePath("crt0.o")));
Index: test/Driver/openbsd.c
===
--- test/Driver/openbsd.c   (revision 283697)
+++ test/Driver/openbsd.c   (working copy)
@@ -67,3 +67,26 @@
 // CHECK-MIPS64-PIC: as{{.*}}" "-mabi" "64" "-EB" "-KPIC"
 // CHECK-MIPS64EL: as{{.*}}" "-mabi" "64" "-EL"
 // CHECK-MIPS64EL-PIC: as{{.*}}" "-mabi" "64" "-EL" "-KPIC"
+
+// Check linking against correct startup code when (not) using PIE
+// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd %s -### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-PIE %s
+// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd %s -fno-pie %s -### 
2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-PIE %s
+// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd 

Re: r284272 - Implement no_sanitize_address for global vars

2016-10-25 Thread Kostya Serebryany via cfe-commits
ping

On Mon, Oct 17, 2016 at 5:57 PM, Kostya Serebryany  wrote:

> Did you code-review this?
> (sorry if I missed it)
>
> On Fri, Oct 14, 2016 at 12:55 PM, Douglas Katzman via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: dougk
>> Date: Fri Oct 14 14:55:09 2016
>> New Revision: 284272
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=284272=rev
>> Log:
>> Implement no_sanitize_address for global vars
>>
>> Modified:
>> cfe/trunk/include/clang/Basic/Attr.td
>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> cfe/trunk/include/clang/Sema/AttributeList.h
>> cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp
>> cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>> cfe/trunk/test/CodeGen/asan-globals.cpp
>> cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp
>> cfe/trunk/test/SemaCXX/attr-no-sanitize.cpp
>>
>> Modified: cfe/trunk/include/clang/Basic/Attr.td
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>> Basic/Attr.td?rev=284272=284271=284272=diff
>> 
>> ==
>> --- cfe/trunk/include/clang/Basic/Attr.td (original)
>> +++ cfe/trunk/include/clang/Basic/Attr.td Fri Oct 14 14:55:09 2016
>> @@ -1705,7 +1705,8 @@ def X86ForceAlignArgPointer : Inheritabl
>>  def NoSanitize : InheritableAttr {
>>let Spellings = [GNU<"no_sanitize">, CXX11<"clang", "no_sanitize">];
>>let Args = [VariadicStringArgument<"Sanitizers">];
>> -  let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;
>> +  let Subjects = SubjectList<[Function, ObjCMethod, GlobalVar],
>> ErrorDiag,
>> +"ExpectedFunctionMethodOrGlobalVar">;
>>let Documentation = [NoSanitizeDocs];
>>let AdditionalMembers = [{
>>  SanitizerMask getMask() const {
>> @@ -1727,7 +1728,8 @@ def NoSanitizeSpecific : InheritableAttr
>> GCC<"no_sanitize_address">,
>> GCC<"no_sanitize_thread">,
>> GNU<"no_sanitize_memory">];
>> -  let Subjects = SubjectList<[Function], ErrorDiag>;
>> +  let Subjects = SubjectList<[Function, GlobalVar], ErrorDiag,
>> +"ExpectedFunctionGlobalVarMethodOrProperty">;
>>let Documentation = [NoSanitizeAddressDocs, NoSanitizeThreadDocs,
>> NoSanitizeMemoryDocs];
>>let ASTNode = 0;
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>> Basic/DiagnosticSemaKinds.td?rev=284272=284271=284272=diff
>> 
>> ==
>> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Oct 14
>> 14:55:09 2016
>> @@ -2577,6 +2577,7 @@ def warn_attribute_wrong_decl_type : War
>>"|functions, methods and blocks"
>>"|functions, methods, and classes"
>>"|functions, methods, and parameters"
>> +  "|functions, methods, and global variables"
>>"|classes"
>>"|enums"
>>"|variables"
>>
>> Modified: cfe/trunk/include/clang/Sema/AttributeList.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>> Sema/AttributeList.h?rev=284272=284271=284272=diff
>> 
>> ==
>> --- cfe/trunk/include/clang/Sema/AttributeList.h (original)
>> +++ cfe/trunk/include/clang/Sema/AttributeList.h Fri Oct 14 14:55:09 2016
>> @@ -891,6 +891,7 @@ enum AttributeDeclKind {
>>ExpectedFunctionMethodOrBlock,
>>ExpectedFunctionMethodOrClass,
>>ExpectedFunctionMethodOrParameter,
>> +  ExpectedFunctionMethodOrGlobalVar,
>>ExpectedClass,
>>ExpectedEnum,
>>ExpectedVariable,
>>
>> Modified: cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/Sa
>> nitizerMetadata.cpp?rev=284272=284271=284272=diff
>> 
>> ==
>> --- cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp Fri Oct 14 14:55:09 2016
>> @@ -63,7 +63,13 @@ void SanitizerMetadata::reportGlobalToAS
>>std::string QualName;
>>llvm::raw_string_ostream OS(QualName);
>>D.printQualifiedName(OS);
>> -  reportGlobalToASan(GV, D.getLocation(), OS.str(), D.getType(),
>> IsDynInit);
>> +
>> +  bool IsBlacklisted = false;
>> +  for (auto Attr : D.specific_attrs())
>> +if (Attr->getMask() & SanitizerKind::Address)
>> +  IsBlacklisted = true;
>> +  reportGlobalToASan(GV, D.getLocation(), OS.str(), D.getType(),
>> IsDynInit,
>> + IsBlacklisted);
>>  }
>>
>>  void SanitizerMetadata::disableSanitizerForGlobal(llvm::GlobalVariable
>> *GV) {
>>
>> Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaD
>> eclAttr.cpp?rev=284272=284271=284272=diff
>> 

r285140 - [Myriad] Find libc++ adjacent to libstdc++

2016-10-25 Thread Douglas Katzman via cfe-commits
Author: dougk
Date: Tue Oct 25 18:02:30 2016
New Revision: 285140

URL: http://llvm.org/viewvc/llvm-project?rev=285140=rev
Log:
[Myriad] Find libc++ adjacent to libstdc++

Modified:
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/myriad-toolchain.c

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=285140=285139=285140=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Tue Oct 25 18:02:30 2016
@@ -5169,18 +5169,13 @@ MyriadToolChain::MyriadToolChain(const D
   }
 
   if (GCCInstallation.isValid()) {
-// The contents of LibDir are independent of the version of gcc.
-// This contains libc, libg, libm, libstdc++, libssp.
-// The 'ma1x00' and 'nofpu' variants are irrelevant.
-SmallString<128> LibDir(GCCInstallation.getParentLibPath());
-llvm::sys::path::append(LibDir, "../sparc-myriad-elf/lib");
-addPathIfExists(D, LibDir, getFilePaths());
-
 // This directory contains crt{i,n,begin,end}.o as well as libgcc.
 // These files are tied to a particular version of gcc.
 SmallString<128> CompilerSupportDir(GCCInstallation.getInstallPath());
 addPathIfExists(D, CompilerSupportDir, getFilePaths());
   }
+  // libstd++ and libc++ must both be found in this one place.
+  addPathIfExists(D, D.Dir + "/../sparc-myriad-elf/lib", getFilePaths());
 }
 
 MyriadToolChain::~MyriadToolChain() {}

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=285140=285139=285140=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Oct 25 18:02:30 2016
@@ -11313,6 +11313,8 @@ void tools::Myriad::Linker::ConstructJob
   !Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles);
   bool UseDefaultLibs =
   !Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs);
+  // Silence warning if the args contain both -nostdlib and -stdlib=.
+  Args.getLastArg(options::OPT_stdlib_EQ);
 
   if (T.getArch() == llvm::Triple::sparc)
 CmdArgs.push_back("-EB");
@@ -11353,19 +11355,25 @@ void tools::Myriad::Linker::ConstructJob
   if (UseDefaultLibs) {
 if (NeedsSanitizerDeps)
   linkSanitizerRuntimeDeps(TC, CmdArgs);
-if (C.getDriver().CCCIsCXX())
-  CmdArgs.push_back("-lstdc++");
+if (C.getDriver().CCCIsCXX()) {
+  if (TC.GetCXXStdlibType(Args) == ToolChain::CST_Libcxx) {
+CmdArgs.push_back("-lc++");
+CmdArgs.push_back("-lc++abi");
+  } else
+CmdArgs.push_back("-lstdc++");
+}
 if (T.getOS() == llvm::Triple::RTEMS) {
   CmdArgs.push_back("--start-group");
   CmdArgs.push_back("-lc");
+  CmdArgs.push_back("-lgcc"); // circularly dependent on rtems
   // You must provide your own "-L" option to enable finding these.
   CmdArgs.push_back("-lrtemscpu");
   CmdArgs.push_back("-lrtemsbsp");
   CmdArgs.push_back("--end-group");
 } else {
   CmdArgs.push_back("-lc");
+  CmdArgs.push_back("-lgcc");
 }
-CmdArgs.push_back("-lgcc");
   }
   if (UseStartfiles) {
 CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crtend.o")));

Modified: cfe/trunk/test/Driver/myriad-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/myriad-toolchain.c?rev=285140=285139=285140=diff
==
--- cfe/trunk/test/Driver/myriad-toolchain.c (original)
+++ cfe/trunk/test/Driver/myriad-toolchain.c Tue Oct 25 18:02:30 2016
@@ -1,10 +1,11 @@
 // RUN: %clang -no-canonical-prefixes -### -target sparc-myriad-rtems-elf %s \
+// RUN: -ccc-install-dir %S/Inputs/basic_myriad_tree/bin \
 // RUN: --gcc-toolchain=%S/Inputs/basic_myriad_tree 2>&1 | FileCheck %s 
-check-prefix=LINK_WITH_RTEMS
 // LINK_WITH_RTEMS: Inputs{{.*}}crti.o
 // LINK_WITH_RTEMS: Inputs{{.*}}crtbegin.o
-// LINK_WITH_RTEMS: 
"-L{{.*}}Inputs/basic_myriad_tree/lib/gcc/sparc-myriad-elf/4.8.2/../../..{{/|}}../sparc-myriad-elf/lib"
 // LINK_WITH_RTEMS: 
"-L{{.*}}Inputs/basic_myriad_tree/lib/gcc/sparc-myriad-elf/4.8.2"
-// LINK_WITH_RTEMS: "--start-group" "-lc" "-lrtemscpu" "-lrtemsbsp" 
"--end-group" "-lgcc"
+// LINK_WITH_RTEMS: 
"-L{{.*}}Inputs/basic_myriad_tree/bin/../sparc-myriad-elf/lib"
+// LINK_WITH_RTEMS: "--start-group" "-lc" "-lgcc" "-lrtemscpu" "-lrtemsbsp" 
"--end-group"
 // LINK_WITH_RTEMS: Inputs{{.*}}crtend.o
 // LINK_WITH_RTEMS: Inputs{{.*}}crtn.o
 


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


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

2016-10-25 Thread Jordan Rose via cfe-commits
jordan_rose added a comment.

> `_Nonnull` in this position seems very similar to `static` (which typically 
> also implies non-nullness).

I wasn't actually sure if it was okay to assume this, but the standard does 
seem pretty clear:

> If the keyword `static` also appears within the `[` and `]` of the array type 
> derivation, then for each call to the function, the value of the 
> corresponding actual argument shall provide access to the first element of an 
> array with at least as many elements as specified by the size expression. 
> (C11 6.7.6.3p7)

We can pick this up on the Swift side.


Repository:
  rL LLVM

https://reviews.llvm.org/D25850



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


[PATCH] D25876: [analyzer] Report CFNumberGetValue API misuse

2016-10-25 Thread Anna Zaks via cfe-commits
zaks.anna added inline comments.



Comment at: test/Analysis/CFNumber.c:39
+  unsigned char scalar = 0;
+  CFNumberGetValue(x, kCFNumberSInt16Type, );  // expected-warning{{A 
CFNumber object that represents a 16-bit integer is used to initialize an 8-bit 
integer; 8 bits of the CFNumber value will overwrite adjacent storage}}
+  return scalar;

NoQ wrote:
> We're not sure from this code if the `CFNumber` object `x` actually 
> represents a 16-bit integer, or somebody just misplaced the 
> `kCFNumberSInt16Type` thing. I think the warning message could be made more 
> precise in this sence, but i'm not good at coming up with warning messages.
> 
> Hmm, there could actually be a separate check for detecting inconsistent type 
> specifiers used for accessing the same CFNumber object.
I see your point. Looks like we'd need to modify both first part of the 
sentence and the second to address this concern. We could do something like "A 
CFNumber object treated as if it represents a 16-bit integer is used to 
initialize an 8-bit integer; 8 bits of the CFNumber value or the adjacent 
storage will overwrite adjacent storage of the integer".

Though this is more correct, I do not think it's worth the new language 
complexity. Also, the warning message is already quite long.


https://reviews.llvm.org/D25876



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


[PATCH] D25206: [Parser] Correct typo after lambda capture initializer is parsed

2016-10-25 Thread Mehdi AMINI via cfe-commits
mehdi_amini added inline comments.



Comment at: lib/Parse/ParseExprCXX.cpp:951
   Init = ParseInitializer();
+  Init = Actions.CorrectDelayedTyposInExpr(Init.get());
 

rsmith wrote:
> ahatanak wrote:
> > mehdi_amini wrote:
> > > What happens when there is no typo correction to apply?
> > If there are no typos, it just returns the same Expr. If there are typos 
> > but no corrections can be applied, it returns ExprError.
> If `ParseInitializer` returned `ExprError()`, this will incorrectly convert 
> it into `ExprResult()` (that is, it'll clear the 'invalid' flag). You should 
> skip this step if the initializer expression is not valid.
I suggest having a test that exercise this code path.


https://reviews.llvm.org/D25206



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


[PATCH] D25206: [Parser] Correct typo after lambda capture initializer is parsed

2016-10-25 Thread Richard Smith via cfe-commits
rsmith added inline comments.



Comment at: lib/Parse/ParseExprCXX.cpp:951
   Init = ParseInitializer();
+  Init = Actions.CorrectDelayedTyposInExpr(Init.get());
 

ahatanak wrote:
> mehdi_amini wrote:
> > What happens when there is no typo correction to apply?
> If there are no typos, it just returns the same Expr. If there are typos but 
> no corrections can be applied, it returns ExprError.
If `ParseInitializer` returned `ExprError()`, this will incorrectly convert it 
into `ExprResult()` (that is, it'll clear the 'invalid' flag). You should skip 
this step if the initializer expression is not valid.


https://reviews.llvm.org/D25206



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


[PATCH] D25206: [Parser] Correct typo after lambda capture initializer is parsed

2016-10-25 Thread Akira Hatanaka via cfe-commits
ahatanak added reviewers: bruno, erik.pilkington, majnemer.
ahatanak added a comment.

Add more reviewers.


https://reviews.llvm.org/D25206



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


Re: [PATCH] D25343: [OpenCL] Mark group functions as convergent in opencl-c.h

2016-10-25 Thread Ettore Speziale via cfe-commits
Hello,

> As far as I understand the whole problem is that the optimized functions are 
> marked by __attribute__((pure)). If the attribute is removed from your 
> example, we get LLVM dump preserving correctness:
> 
> define i32 @bar(i32 %x) local_unnamed_addr #0 {
> entry:
>  %call = tail call i32 @foo() #2
>  %tobool = icmp eq i32 %x, 0
>  %.call = select i1 %tobool, i32 0, i32 %call
>  ret i32 %.call
> }

I’ve used __attribute__((pure)) only to force LLVM applying the transformation 
and show you an example of incorrect behavior.

This is another example:

void foo();
int baz();

int bar(int x) {
  int y;
  if (x) 
y = baz();
  foo();
  if (x) 
y = baz();
  return y;
} 

Which gets lowered into:

define i32 @bar(i32) #0 {
  %2 = icmp eq i32 %0, 0
  br i1 %2, label %3, label %4

; :3   ; preds = %1
  tail call void (...) @foo() #2
  br label %7

; :4   ; preds = %1
  %5 = tail call i32 (...) @baz() #2
  tail call void (...) @foo() #2
  %6 = tail call i32 (...) @baz() #2
  br label %7

; :7   ; preds = %3, %4
  %8 = phi i32 [ %6, %4 ], [ undef, %3 ]
  ret i32 %8
}

As you can see the call sites of foo in the optimized IR are not 
control-equivalent to the only call site of foo in the unoptimized IR. Now 
imaging foo is implemented in another module and contains a call to a 
convergent function — e.f. barrier(). You are going to generate incorrect code.

Bye

--
Ettore Speziale — Compiler Engineer
speziale.ett...@gmail.com
espezi...@apple.com
--

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


Re: [libcxx] r249738 - Split out of .

2016-10-25 Thread Richard Smith via cfe-commits
Missed one change from the test suite:

Index: test/Modules/cstd.m
===
--- test/Modules/cstd.m (revision 285117)
+++ test/Modules/cstd.m (working copy)
@@ -1,5 +1,5 @@
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -fsyntax-only -isystem %S/Inputs/System/usr/include
-ffreestanding -fmodules -fimplicit-module-maps -fmodules-cache-path=%t
-D__need_wint_t -Werror=implicit-function-declaration %s
+// RUN: %clang_cc1 -fsyntax-only -internal-isystem
%S/Inputs/System/usr/include -fmodules -fimplicit-module-maps
-fmodules-cache-path=%t -D__need_wint_t
-Werror=implicit-function-declaration %s

 @import uses_other_constants;
 const double other_value = DBL_MAX;


On Tue, Oct 25, 2016 at 2:56 PM, Richard Smith 
wrote:

> This was a thinko on my part: clang's builtin headers include_next the
> system headers, not the other way around, so the system headers should be
> implicitly textual, not clang's headers. This patch fixes the problem for
> me with glibc. Does this help for Darwin too?
>
> On Tue, Oct 25, 2016 at 2:01 PM, Richard Smith 
> wrote:
>
>> On Mon, Oct 24, 2016 at 4:58 PM, Bruno Cardoso Lopes via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> On Mon, Oct 24, 2016 at 4:17 PM, Richard Smith 
>>> wrote:
>>> > On Mon, Oct 24, 2016 at 3:30 PM, Bruno Cardoso Lopes
>>> >  wrote:
>>> >>
>>> >> > Sure, go ahead.
>>> >>
>>> >> I committed in r284797 and r284801 (libcxx). There's one minor issue
>>> >> I've found: the changes for the builtins affecting non submodule local
>>> >> visibility broke current users of plain "-fmodules" against our
>>> >> frameworks in public SDKs, in 10.11 & 10.12. I've attached a patch to
>>> >> work around that for the time being: make the new behavior dependent
>>> >> on local vis. Can you take a look?
>>> >
>>> >
>>> > What's the nature of the breakage? Generally I'd be fine with your
>>> patch,
>>> > but I wonder if there's something better we could do here.
>>>
>>> I haven't entirely isolated the problem, but they are all related to
>>> definitions from stdint.h. In one example below, uint32_t doesn't
>>> leak, requiring an explicit "#include " to make it work.
>>>
>>> -- example.m
>>> #import 
>>> --
>>> $ clang -arch x86_64 -isysroot
>>> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.
>>> platform/Developer/SDKs/MacOSX10.12.sdk
>>> -fmodules-cache-path=tmpcache example.m -E -o /dev/null  -fmodules
>>>
>>> While building module 'IOKit' imported from example.m:1:
>>> In file included from :2:
>>> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.
>>> platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/
>>> Frameworks/IOKit.framework/Headers/IODataQueueClient.h:62:71:
>>> error: de
>>>   'Darwin.POSIX._types._uint32_t' before it is required
>>> IOReturn IODataQueueDequeue(IODataQueueMemory *dataQueue, void *data,
>>> uint32_t *dataSize);
>>>   ^
>>> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.
>>> platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/_types/_
>>> uint32_t.h:31:22:
>>> note: previous declaration is here
>>> typedef unsigned int uint32_t;
>>>  ^
>>> bot.m:1:9: fatal error: could not build module 'IOKit'
>>> #import 
>>>  ~~~^
>>
>>
>> This change also broke local submodule visibility builds with modular
>> glibc (see PR30778 for details). I have an idea for how to fix this;
>> running it through bootstrap now.
>>
>> >> > Hmm. Ideally, we should try to pick something that captures the
>>> spirit
>>> >> > of
>>> >> > "only non-modular headers and headers from used modules". Something
>>> like
>>> >> > "ignore_modules_not_declared_used", but less wordy?
>>> >>
>>> >> Right. It's gonna be hard to shrink this to a meaningful short name.
>>> >> What about a more generic "no_escape"?  "no_undeclared_headers"?
>>> >
>>> >
>>> > Hmm. Maybe we could allow the existing [exhaustive] attribute to be
>>> > specified on a use-declaration:
>>> >
>>> >   use [exhaustive] a, b, c
>>>
>>> I don't understand, the 'Darwin' module map doesn't use the 'use'
>>> keyword in any of its modules, how do you suggest we would use that to
>>> express the 'ignore_modules_not_declared_used' idea?
>>
>>
>> Hah, right, this would only work if your module has dependencies. Maybe
>> an [exhaustive_uses] attribute on the module itself then?
>>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r249738 - Split out of .

2016-10-25 Thread Richard Smith via cfe-commits
This was a thinko on my part: clang's builtin headers include_next the
system headers, not the other way around, so the system headers should be
implicitly textual, not clang's headers. This patch fixes the problem for
me with glibc. Does this help for Darwin too?

On Tue, Oct 25, 2016 at 2:01 PM, Richard Smith 
wrote:

> On Mon, Oct 24, 2016 at 4:58 PM, Bruno Cardoso Lopes via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> On Mon, Oct 24, 2016 at 4:17 PM, Richard Smith 
>> wrote:
>> > On Mon, Oct 24, 2016 at 3:30 PM, Bruno Cardoso Lopes
>> >  wrote:
>> >>
>> >> > Sure, go ahead.
>> >>
>> >> I committed in r284797 and r284801 (libcxx). There's one minor issue
>> >> I've found: the changes for the builtins affecting non submodule local
>> >> visibility broke current users of plain "-fmodules" against our
>> >> frameworks in public SDKs, in 10.11 & 10.12. I've attached a patch to
>> >> work around that for the time being: make the new behavior dependent
>> >> on local vis. Can you take a look?
>> >
>> >
>> > What's the nature of the breakage? Generally I'd be fine with your
>> patch,
>> > but I wonder if there's something better we could do here.
>>
>> I haven't entirely isolated the problem, but they are all related to
>> definitions from stdint.h. In one example below, uint32_t doesn't
>> leak, requiring an explicit "#include " to make it work.
>>
>> -- example.m
>> #import 
>> --
>> $ clang -arch x86_64 -isysroot
>> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.
>> platform/Developer/SDKs/MacOSX10.12.sdk
>> -fmodules-cache-path=tmpcache example.m -E -o /dev/null  -fmodules
>>
>> While building module 'IOKit' imported from example.m:1:
>> In file included from :2:
>> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.
>> platform/Developer/SDKs/MacOSX10.12.sdk/System/Library
>> /Frameworks/IOKit.framework/Headers/IODataQueueClient.h:62:71:
>> error: de
>>   'Darwin.POSIX._types._uint32_t' before it is required
>> IOReturn IODataQueueDequeue(IODataQueueMemory *dataQueue, void *data,
>> uint32_t *dataSize);
>>   ^
>> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.
>> platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/_
>> types/_uint32_t.h:31:22:
>> note: previous declaration is here
>> typedef unsigned int uint32_t;
>>  ^
>> bot.m:1:9: fatal error: could not build module 'IOKit'
>> #import 
>>  ~~~^
>
>
> This change also broke local submodule visibility builds with modular
> glibc (see PR30778 for details). I have an idea for how to fix this;
> running it through bootstrap now.
>
> >> > Hmm. Ideally, we should try to pick something that captures the spirit
>> >> > of
>> >> > "only non-modular headers and headers from used modules". Something
>> like
>> >> > "ignore_modules_not_declared_used", but less wordy?
>> >>
>> >> Right. It's gonna be hard to shrink this to a meaningful short name.
>> >> What about a more generic "no_escape"?  "no_undeclared_headers"?
>> >
>> >
>> > Hmm. Maybe we could allow the existing [exhaustive] attribute to be
>> > specified on a use-declaration:
>> >
>> >   use [exhaustive] a, b, c
>>
>> I don't understand, the 'Darwin' module map doesn't use the 'use'
>> keyword in any of its modules, how do you suggest we would use that to
>> express the 'ignore_modules_not_declared_used' idea?
>
>
> Hah, right, this would only work if your module has dependencies. Maybe an
> [exhaustive_uses] attribute on the module itself then?
>
Index: lib/Lex/ModuleMap.cpp
===
--- lib/Lex/ModuleMap.cpp   (revision 285117)
+++ lib/Lex/ModuleMap.cpp   (working copy)
@@ -1881,16 +1881,20 @@
   Module::Header H = {RelativePathName.str(), File};
   Map.excludeHeader(ActiveModule, H);
 } else {
-  // If there is a builtin counterpart to this file, add it now as a 
textual
-  // header, so it can be #include_next'd by the wrapper header, and can
-  // receive macros from the wrapper header.
+  // If there is a builtin counterpart to this file, add it now so it can
+  // wrap the system header.
   if (BuiltinFile) {
 // FIXME: Taking the name from the FileEntry is unstable and can give
 // different results depending on how we've previously named that file
 // in this build.
 Module::Header H = { BuiltinFile->getName(), BuiltinFile };
-Map.addHeader(ActiveModule, H, ModuleMap::ModuleHeaderRole(
-   Role | ModuleMap::TextualHeader));
+Map.addHeader(ActiveModule, H, Role);
+
+// If we have both a builtin and system version of the file, the
+// builtin version may want to inject macros into the system header, so
+// force the system header to be treated as a textual header in this
+

[PATCH] D25761: Use linker flag --fix-cortex-a53-843419 on Android ARM64 compilation.

2016-10-25 Thread Stephen Hines via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285127: Use linker flag --fix-cortex-a53-843419 on Android 
ARM64 compilation. (authored by srhines).

Changed prior to commit:
  https://reviews.llvm.org/D25761?vs=75174=75801#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25761

Files:
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/test/Driver/android-aarch64-link.cpp


Index: cfe/trunk/test/Driver/android-aarch64-link.cpp
===
--- cfe/trunk/test/Driver/android-aarch64-link.cpp
+++ cfe/trunk/test/Driver/android-aarch64-link.cpp
@@ -0,0 +1,17 @@
+// Check that we automatically add relevant linker flags for Android aarch64.
+
+// RUN: %clang -target aarch64-none-linux-android \
+// RUN:   -### -v %s 2> %t
+// RUN: FileCheck -check-prefix=GENERIC-ARM < %t %s
+//
+// RUN: %clang -target aarch64-none-linux-android \
+// RUN:   -mcpu=cortex-a53 -### -v %s 2> %t
+// RUN: FileCheck -check-prefix=CORTEX-A53 < %t %s
+//
+// RUN: %clang -target aarch64-none-linux-android \
+// RUN:   -mcpu=cortex-a57 -### -v %s 2> %t
+// RUN: FileCheck -check-prefix=CORTEX-A57 < %t %s
+//
+// GENERIC-ARM: --fix-cortex-a53-843419
+// CORTEX-A53: --fix-cortex-a53-843419
+// CORTEX-A57-NOT: --fix-cortex-a53-843419
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -9712,6 +9712,14 @@
   if (Arch == llvm::Triple::armeb || Arch == llvm::Triple::thumbeb)
 arm::appendEBLinkFlags(Args, CmdArgs, Triple);
 
+  // Most Android ARM64 targets should enable the linker fix for erratum
+  // 843419. Only non-Cortex-A53 devices are allowed to skip this flag.
+  if (Arch == llvm::Triple::aarch64 && isAndroid) {
+std::string CPU = getCPUName(Args, Triple);
+if (CPU.empty() || CPU == "generic" || CPU == "cortex-a53")
+  CmdArgs.push_back("--fix-cortex-a53-843419");
+  }
+
   for (const auto  : ToolChain.ExtraOpts)
 CmdArgs.push_back(Opt.c_str());
 


Index: cfe/trunk/test/Driver/android-aarch64-link.cpp
===
--- cfe/trunk/test/Driver/android-aarch64-link.cpp
+++ cfe/trunk/test/Driver/android-aarch64-link.cpp
@@ -0,0 +1,17 @@
+// Check that we automatically add relevant linker flags for Android aarch64.
+
+// RUN: %clang -target aarch64-none-linux-android \
+// RUN:   -### -v %s 2> %t
+// RUN: FileCheck -check-prefix=GENERIC-ARM < %t %s
+//
+// RUN: %clang -target aarch64-none-linux-android \
+// RUN:   -mcpu=cortex-a53 -### -v %s 2> %t
+// RUN: FileCheck -check-prefix=CORTEX-A53 < %t %s
+//
+// RUN: %clang -target aarch64-none-linux-android \
+// RUN:   -mcpu=cortex-a57 -### -v %s 2> %t
+// RUN: FileCheck -check-prefix=CORTEX-A57 < %t %s
+//
+// GENERIC-ARM: --fix-cortex-a53-843419
+// CORTEX-A53: --fix-cortex-a53-843419
+// CORTEX-A57-NOT: --fix-cortex-a53-843419
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -9712,6 +9712,14 @@
   if (Arch == llvm::Triple::armeb || Arch == llvm::Triple::thumbeb)
 arm::appendEBLinkFlags(Args, CmdArgs, Triple);
 
+  // Most Android ARM64 targets should enable the linker fix for erratum
+  // 843419. Only non-Cortex-A53 devices are allowed to skip this flag.
+  if (Arch == llvm::Triple::aarch64 && isAndroid) {
+std::string CPU = getCPUName(Args, Triple);
+if (CPU.empty() || CPU == "generic" || CPU == "cortex-a53")
+  CmdArgs.push_back("--fix-cortex-a53-843419");
+  }
+
   for (const auto  : ToolChain.ExtraOpts)
 CmdArgs.push_back(Opt.c_str());
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r285127 - Use linker flag --fix-cortex-a53-843419 on Android ARM64 compilation.

2016-10-25 Thread Stephen Hines via cfe-commits
Author: srhines
Date: Tue Oct 25 16:44:35 2016
New Revision: 285127

URL: http://llvm.org/viewvc/llvm-project?rev=285127=rev
Log:
Use linker flag --fix-cortex-a53-843419 on Android ARM64 compilation.

Summary:
This is only forced on if there is no non-Cortex-A53 CPU specified as
well. Android's platform and NDK builds need to assume that the code can
be run on Cortex-A53 devices, so we always enable the fix unless we know
specifically that the code is only running on a different kind of CPU.

Reviewers: cfe-commits

Subscribers: aemerson, rengolin, tberghammer, pirama, danalbert

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

Added:
cfe/trunk/test/Driver/android-aarch64-link.cpp
Modified:
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=285127=285126=285127=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Oct 25 16:44:35 2016
@@ -9712,6 +9712,14 @@ void gnutools::Linker::ConstructJob(Comp
   if (Arch == llvm::Triple::armeb || Arch == llvm::Triple::thumbeb)
 arm::appendEBLinkFlags(Args, CmdArgs, Triple);
 
+  // Most Android ARM64 targets should enable the linker fix for erratum
+  // 843419. Only non-Cortex-A53 devices are allowed to skip this flag.
+  if (Arch == llvm::Triple::aarch64 && isAndroid) {
+std::string CPU = getCPUName(Args, Triple);
+if (CPU.empty() || CPU == "generic" || CPU == "cortex-a53")
+  CmdArgs.push_back("--fix-cortex-a53-843419");
+  }
+
   for (const auto  : ToolChain.ExtraOpts)
 CmdArgs.push_back(Opt.c_str());
 

Added: cfe/trunk/test/Driver/android-aarch64-link.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/android-aarch64-link.cpp?rev=285127=auto
==
--- cfe/trunk/test/Driver/android-aarch64-link.cpp (added)
+++ cfe/trunk/test/Driver/android-aarch64-link.cpp Tue Oct 25 16:44:35 2016
@@ -0,0 +1,17 @@
+// Check that we automatically add relevant linker flags for Android aarch64.
+
+// RUN: %clang -target aarch64-none-linux-android \
+// RUN:   -### -v %s 2> %t
+// RUN: FileCheck -check-prefix=GENERIC-ARM < %t %s
+//
+// RUN: %clang -target aarch64-none-linux-android \
+// RUN:   -mcpu=cortex-a53 -### -v %s 2> %t
+// RUN: FileCheck -check-prefix=CORTEX-A53 < %t %s
+//
+// RUN: %clang -target aarch64-none-linux-android \
+// RUN:   -mcpu=cortex-a57 -### -v %s 2> %t
+// RUN: FileCheck -check-prefix=CORTEX-A57 < %t %s
+//
+// GENERIC-ARM: --fix-cortex-a53-843419
+// CORTEX-A53: --fix-cortex-a53-843419
+// CORTEX-A57-NOT: --fix-cortex-a53-843419


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


r285126 - CodeGen: be more conservative about setting section

2016-10-25 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Tue Oct 25 16:43:28 2016
New Revision: 285126

URL: http://llvm.org/viewvc/llvm-project?rev=285126=rev
Log:
CodeGen: be more conservative about setting section

The section names currently are MachO specific.  Only set the section on the
variables if the file format is MachO.

Added:
cfe/trunk/test/CodeGenObjC/section-name.m
Modified:
cfe/trunk/lib/CodeGen/CGObjCMac.cpp

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=285126=285125=285126=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Tue Oct 25 16:43:28 2016
@@ -2919,10 +2919,13 @@ CGObjCMac::EmitProtocolList(Twine Name,
   ProtocolRefs.size()),
  ProtocolRefs);
 
+  StringRef Section;
+  if (CGM.getTriple().isOSBinFormatMachO())
+Section = "__OBJC,__cat_cls_meth,regular,no_dead_strip";
+
   llvm::Constant *Init = llvm::ConstantStruct::getAnon(Values);
   llvm::GlobalVariable *GV =
-CreateMetadataVar(Name, Init, 
"__OBJC,__cat_cls_meth,regular,no_dead_strip",
-  CGM.getPointerAlign(), false);
+  CreateMetadataVar(Name, Init, Section, CGM.getPointerAlign(), false);
   return llvm::ConstantExpr::getBitCast(GV, ObjCTypes.ProtocolListPtrTy);
 }
 
@@ -3028,12 +3031,13 @@ llvm::Constant *CGObjCCommonMac::EmitPro
   Values[2] = llvm::ConstantArray::get(AT, Properties);
   llvm::Constant *Init = llvm::ConstantStruct::getAnon(Values);
 
+  StringRef Section;
+  if (CGM.getTriple().isOSBinFormatMachO())
+Section = (ObjCABI == 2) ? "__DATA, __objc_const"
+ : "__OBJC,__property,regular,no_dead_strip";
+
   llvm::GlobalVariable *GV =
-CreateMetadataVar(Name, Init,
-  (ObjCABI == 2) ? "__DATA, __objc_const" :
-  "__OBJC,__property,regular,no_dead_strip",
-  CGM.getPointerAlign(),
-  true);
+  CreateMetadataVar(Name, Init, Section, CGM.getPointerAlign(), true);
   return llvm::ConstantExpr::getBitCast(GV, ObjCTypes.PropertyListPtrTy);
 }
 
@@ -3049,9 +3053,12 @@ CGObjCCommonMac::EmitProtocolMethodTypes
  MethodTypes.size());
   llvm::Constant *Init = llvm::ConstantArray::get(AT, MethodTypes);
 
-  llvm::GlobalVariable *GV = CreateMetadataVar(
-  Name, Init, (ObjCABI == 2) ? "__DATA, __objc_const" : StringRef(),
-  CGM.getPointerAlign(), true);
+  StringRef Section;
+  if (CGM.getTriple().isOSBinFormatMachO() && ObjCABI == 2)
+Section = "__DATA, __objc_const";
+
+  llvm::GlobalVariable *GV =
+  CreateMetadataVar(Name, Init, Section, CGM.getPointerAlign(), true);
   return llvm::ConstantExpr::getBitCast(GV, ObjCTypes.Int8PtrPtrTy);
 }
 
@@ -5959,18 +5966,21 @@ llvm::GlobalVariable * CGObjCNonFragileA
   }
   llvm::Constant *Init = llvm::ConstantStruct::get(ObjCTypes.ClassRonfABITy,
Values);
+
+  llvm::SmallString<64> ROLabel;
+  llvm::raw_svector_ostream(ROLabel)
+  << ((flags & NonFragileABI_Class_Meta) ? "\01l_OBJC_METACLASS_RO_$_"
+ : "\01l_OBJC_CLASS_RO_$_")
+  << ClassName;
+
   llvm::GlobalVariable *CLASS_RO_GV =
-new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.ClassRonfABITy, false,
- llvm::GlobalValue::PrivateLinkage,
- Init,
- (flags & NonFragileABI_Class_Meta) ?
- 
std::string("\01l_OBJC_METACLASS_RO_$_")+ClassName :
- std::string("\01l_OBJC_CLASS_RO_$_")+ClassName);
+  new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.ClassRonfABITy, 
false,
+   llvm::GlobalValue::PrivateLinkage, Init, 
ROLabel);
   CLASS_RO_GV->setAlignment(
 CGM.getDataLayout().getABITypeAlignment(ObjCTypes.ClassRonfABITy));
-  CLASS_RO_GV->setSection("__DATA, __objc_const");
+  if (CGM.getTriple().isOSBinFormatMachO())
+CLASS_RO_GV->setSection("__DATA, __objc_const");
   return CLASS_RO_GV;
-
 }
 
 /// BuildClassMetaData - This routine defines that to-level meta-data
@@ -6002,9 +6012,10 @@ llvm::GlobalVariable *CGObjCNonFragileAB
Values);
   llvm::GlobalVariable *GV = GetClassGlobal(ClassName, Weak);
   GV->setInitializer(Init);
-  GV->setSection("__DATA, __objc_data");
+  if (CGM.getTriple().isOSBinFormatMachO())
+GV->setSection("__DATA, __objc_data");
   GV->setAlignment(
-CGM.getDataLayout().getABITypeAlignment(ObjCTypes.ClassnfABITy));
+  CGM.getDataLayout().getABITypeAlignment(ObjCTypes.ClassnfABITy));
   if (!CGM.getTriple().isOSBinFormatCOFF())
 if (HiddenVisibility)
   

[PATCH] D25954: [OpenCL] Add missing atom_xor for 64 bit to opencl-c.h

2016-10-25 Thread Yaxun Liu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285125: [OpenCL] Add missing atom_xor for 64 bit to 
opencl-c.h (authored by yaxunl).

Changed prior to commit:
  https://reviews.llvm.org/D25954?vs=75740=75797#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25954

Files:
  cfe/trunk/lib/Headers/opencl-c.h


Index: cfe/trunk/lib/Headers/opencl-c.h
===
--- cfe/trunk/lib/Headers/opencl-c.h
+++ cfe/trunk/lib/Headers/opencl-c.h
@@ -14616,6 +14616,13 @@
 unsigned int __ovld atom_xor(volatile __local unsigned int *p, unsigned int 
val);
 #endif
 
+#if defined(cl_khr_int64_extended_atomics)
+long __ovld atom_xor(volatile __global long *p, long val);
+unsigned long __ovld atom_xor(volatile __global unsigned long *p, unsigned 
long val);
+long __ovld atom_xor(volatile __local long *p, long val);
+unsigned long __ovld atom_xor(volatile __local unsigned long *p, unsigned long 
val);
+#endif
+
 #if defined(cl_khr_int64_base_atomics) && 
defined(cl_khr_int64_extended_atomics)
 #pragma OPENCL EXTENSION cl_khr_int64_base_atomics : disable
 #pragma OPENCL EXTENSION cl_khr_int64_extended_atomics : disable


Index: cfe/trunk/lib/Headers/opencl-c.h
===
--- cfe/trunk/lib/Headers/opencl-c.h
+++ cfe/trunk/lib/Headers/opencl-c.h
@@ -14616,6 +14616,13 @@
 unsigned int __ovld atom_xor(volatile __local unsigned int *p, unsigned int val);
 #endif
 
+#if defined(cl_khr_int64_extended_atomics)
+long __ovld atom_xor(volatile __global long *p, long val);
+unsigned long __ovld atom_xor(volatile __global unsigned long *p, unsigned long val);
+long __ovld atom_xor(volatile __local long *p, long val);
+unsigned long __ovld atom_xor(volatile __local unsigned long *p, unsigned long val);
+#endif
+
 #if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
 #pragma OPENCL EXTENSION cl_khr_int64_base_atomics : disable
 #pragma OPENCL EXTENSION cl_khr_int64_extended_atomics : disable
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r285125 - [OpenCL] Add missing atom_xor for 64 bit to opencl-c.h

2016-10-25 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Tue Oct 25 16:37:05 2016
New Revision: 285125

URL: http://llvm.org/viewvc/llvm-project?rev=285125=rev
Log:
[OpenCL] Add missing atom_xor for 64 bit to opencl-c.h

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

Modified:
cfe/trunk/lib/Headers/opencl-c.h

Modified: cfe/trunk/lib/Headers/opencl-c.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/opencl-c.h?rev=285125=285124=285125=diff
==
--- cfe/trunk/lib/Headers/opencl-c.h (original)
+++ cfe/trunk/lib/Headers/opencl-c.h Tue Oct 25 16:37:05 2016
@@ -14616,6 +14616,13 @@ int __ovld atom_xor(volatile __local int
 unsigned int __ovld atom_xor(volatile __local unsigned int *p, unsigned int 
val);
 #endif
 
+#if defined(cl_khr_int64_extended_atomics)
+long __ovld atom_xor(volatile __global long *p, long val);
+unsigned long __ovld atom_xor(volatile __global unsigned long *p, unsigned 
long val);
+long __ovld atom_xor(volatile __local long *p, long val);
+unsigned long __ovld atom_xor(volatile __local unsigned long *p, unsigned long 
val);
+#endif
+
 #if defined(cl_khr_int64_base_atomics) && 
defined(cl_khr_int64_extended_atomics)
 #pragma OPENCL EXTENSION cl_khr_int64_base_atomics : disable
 #pragma OPENCL EXTENSION cl_khr_int64_extended_atomics : disable


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


[PATCH] D25909: [analyzer] MacOSXApiChecker: Disallow dispatch_once predicates on heap and in ivars.

2016-10-25 Thread Devin Coughlin via cfe-commits
dcoughlin added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp:94
+  else if (isa(RS)) {
+// FIXME: Presence of an IVar region has priority over this branch, because
+// ObjC objects are on the heap even if the core doesn't realize this.

NoQ wrote:
> dcoughlin wrote:
> > It is not clear to me that this FIXME is a good idea. I would remove it so 
> > someone doesn't spend a lot of time trying to address it.
> > 
> > Objective-C objects don't have the strong dis-aliasing guarantee that the 
> > analyzer assumes for heap base regions. In other words, two calls to [[Foo 
> > alloc] init] may yield exactly the same instance.  This is because, unlike 
> > malloc() and C++ global new, ObjC initializers can (and frequently do) 
> > return instances other than the passed-in, freshly-allocated self.
> Hmm, that seems to be exactly the thing i'm looking for: heap-based regions 
> that may alias.
> 
> The property of a region's staying on the heap has little to do with the 
> property of being able to alias.
> 
> I've a feeling that we should have avoided using C++ inheritance in the 
> memregion hierarchy, and instead went for a bunch of constraints. Eg., memory 
> space is essentially a constraint (it may be unknown or get known later 
> through exploring aliasing), region's value type is essentially a constraint 
> (as seen during dynamic type propagation, it may be unknown, it may be 
> partially known, we may get to know it better during the analysis by 
> observing successful dynamic casts), extent is essentially a constraint (that 
> we currently impose on SymbolExtent), offset of a symbolic region inside its 
> true parent region is a constraint, and so on.
> 
> But that's too vague. I've no well-defined idea how to make this better at 
> the moment.
If you feel strongly about this, I would suggest putting the FIXME in the core, 
perhaps in SimpleSValBuilder where the dis-aliasing assumption is introduced or 
perhaps in the declaration of HeapSpaceRegion. This will make it clear to 
future maintainers that it is not a defect in the checker.



Comment at: lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp:70
 
   // Check if the first argument is stack allocated.  If so, issue a warning
   // because that's likely to be bad news.

I guess this comment needs to be updated.



Comment at: test/Analysis/dispatch-once.m:26
+  // Use regexps to check that we're NOT suggesting to make this static.
+  dispatch_once(once, ^{}); // expected-warning-re^Call to 'dispatch_once' 
uses heap-allocated memory for the predicate value.  Using such transient 
memory for the predicate is potentially dangerous$
+}

Clever.



Comment at: test/Analysis/dispatch-once.m:62
+- (void)test_ivar_struct_from_inside {
+  dispatch_once(, ^{}); // expected-warning{{Call to 'dispatch_once' 
uses the instance variable 's' for the predicate value.}}
+}

Interesting. Have you seen this pattern in the wild?

I think this diagnostic is a little bit confusing since the ivar itself isn't 
being used for the predicate value.

Maybe "... uses a subfield of the instance variable 's' for the predicate 
value"? 






https://reviews.llvm.org/D25909



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


[PATCH] D25954: [OpenCL] Add missing atom_xor for 64 bit to opencl-c.h

2016-10-25 Thread Anastasia Stulova via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM!


https://reviews.llvm.org/D25954



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


r285120 - [index] Fixes for locations and relations in Objective C categories and getters/setters

2016-10-25 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Tue Oct 25 16:11:22 2016
New Revision: 285120

URL: http://llvm.org/viewvc/llvm-project?rev=285120=rev
Log:
[index] Fixes for locations and relations in Objective C categories and 
getters/setters

- Add entries for protocols on categories
- Add relation between categories and class they extend
- Add relation between getters/setters and their corresponding property
- Use category name location as the location of category decls/defs if it has 
one

Modified:
cfe/trunk/include/clang/Index/IndexSymbol.h
cfe/trunk/lib/Index/IndexDecl.cpp
cfe/trunk/lib/Index/IndexSymbol.cpp
cfe/trunk/test/Index/Core/index-source.m
cfe/trunk/test/Index/Core/index-subkinds.m

Modified: cfe/trunk/include/clang/Index/IndexSymbol.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Index/IndexSymbol.h?rev=285120=285119=285120=diff
==
--- cfe/trunk/include/clang/Index/IndexSymbol.h (original)
+++ cfe/trunk/include/clang/Index/IndexSymbol.h Tue Oct 25 16:11:22 2016
@@ -88,8 +88,10 @@ enum class SymbolRole : uint16_t {
   RelationOverrideOf  = 1 << 11,
   RelationReceivedBy  = 1 << 12,
   RelationCalledBy= 1 << 13,
+  RelationExtendedBy  = 1 << 14,
+  RelationAccessorOf  = 1 << 15,
 };
-static const unsigned SymbolRoleBitNum = 14;
+static const unsigned SymbolRoleBitNum = 16;
 typedef unsigned SymbolRoleSet;
 
 /// Represents a relation to another symbol for a symbol occurrence.

Modified: cfe/trunk/lib/Index/IndexDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexDecl.cpp?rev=285120=285119=285120=diff
==
--- cfe/trunk/lib/Index/IndexDecl.cpp (original)
+++ cfe/trunk/lib/Index/IndexDecl.cpp Tue Oct 25 16:11:22 2016
@@ -75,8 +75,21 @@ public:
 }
   }
 
-  bool handleObjCMethod(const ObjCMethodDecl *D) {
-if (!IndexCtx.handleDecl(D, (unsigned)SymbolRole::Dynamic))
+  bool handleObjCMethod(const ObjCMethodDecl *D,
+const ObjCPropertyDecl *AssociatedProp = nullptr) {
+SmallVector Relations;
+SmallVector Overriden;
+
+D->getOverriddenMethods(Overriden);
+for(auto overridden: Overriden) {
+  Relations.emplace_back((unsigned) SymbolRole::RelationOverrideOf,
+ overridden);
+}
+if (AssociatedProp)
+  Relations.emplace_back((unsigned)SymbolRole::RelationAccessorOf,
+ AssociatedProp);
+
+if (!IndexCtx.handleDecl(D, (unsigned)SymbolRole::Dynamic, Relations))
   return false;
 IndexCtx.indexTypeSourceInfo(D->getReturnTypeSourceInfo(), D);
 for (const auto *I : D->parameters())
@@ -269,9 +282,18 @@ public:
   }
 
   bool VisitObjCCategoryDecl(const ObjCCategoryDecl *D) {
-if (!IndexCtx.handleDecl(D))
-  return false;
-IndexCtx.indexDeclContext(D);
+const ObjCInterfaceDecl *C = D->getClassInterface();
+if (C)
+  TRY_TO(IndexCtx.handleReference(C, D->getLocation(), D, D,
+  SymbolRoleSet(), SymbolRelation{
+(unsigned)SymbolRole::RelationExtendedBy, D
+  }));
+SourceLocation CategoryLoc = D->getCategoryNameLoc();
+if (!CategoryLoc.isValid())
+  CategoryLoc = D->getLocation();
+TRY_TO(IndexCtx.handleDecl(D, CategoryLoc));
+TRY_TO(handleReferencedProtocols(D->getReferencedProtocols(), D));
+TRY_TO(IndexCtx.indexDeclContext(D));
 return true;
   }
 
@@ -279,8 +301,14 @@ public:
 const ObjCCategoryDecl *Cat = D->getCategoryDecl();
 if (!Cat)
   return true;
-
-if (!IndexCtx.handleDecl(D))
+const ObjCInterfaceDecl *C = D->getClassInterface();
+if (C)
+  TRY_TO(IndexCtx.handleReference(C, D->getLocation(), D, D,
+  SymbolRoleSet()));
+SourceLocation CategoryLoc = D->getCategoryNameLoc();
+if (!CategoryLoc.isValid())
+  CategoryLoc = D->getLocation();
+if (!IndexCtx.handleDecl(D, CategoryLoc))
   return false;
 IndexCtx.indexDeclContext(D);
 return true;
@@ -299,10 +327,10 @@ public:
   bool VisitObjCPropertyDecl(const ObjCPropertyDecl *D) {
 if (ObjCMethodDecl *MD = D->getGetterMethodDecl())
   if (MD->getLexicalDeclContext() == D->getLexicalDeclContext())
-handleObjCMethod(MD);
+handleObjCMethod(MD, D);
 if (ObjCMethodDecl *MD = D->getSetterMethodDecl())
   if (MD->getLexicalDeclContext() == D->getLexicalDeclContext())
-handleObjCMethod(MD);
+handleObjCMethod(MD, D);
 if (!IndexCtx.handleDecl(D))
   return false;
 IndexCtx.indexTypeSourceInfo(D->getTypeSourceInfo(), D);

Modified: cfe/trunk/lib/Index/IndexSymbol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexSymbol.cpp?rev=285120=285119=285120=diff

Re: [libcxx] r249738 - Split out of .

2016-10-25 Thread Richard Smith via cfe-commits
On Mon, Oct 24, 2016 at 4:58 PM, Bruno Cardoso Lopes via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On Mon, Oct 24, 2016 at 4:17 PM, Richard Smith 
> wrote:
> > On Mon, Oct 24, 2016 at 3:30 PM, Bruno Cardoso Lopes
> >  wrote:
> >>
> >> > Sure, go ahead.
> >>
> >> I committed in r284797 and r284801 (libcxx). There's one minor issue
> >> I've found: the changes for the builtins affecting non submodule local
> >> visibility broke current users of plain "-fmodules" against our
> >> frameworks in public SDKs, in 10.11 & 10.12. I've attached a patch to
> >> work around that for the time being: make the new behavior dependent
> >> on local vis. Can you take a look?
> >
> >
> > What's the nature of the breakage? Generally I'd be fine with your patch,
> > but I wonder if there's something better we could do here.
>
> I haven't entirely isolated the problem, but they are all related to
> definitions from stdint.h. In one example below, uint32_t doesn't
> leak, requiring an explicit "#include " to make it work.
>
> -- example.m
> #import 
> --
> $ clang -arch x86_64 -isysroot
> /Applications/Xcode.app/Contents/Developer/Platforms/
> MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk
> -fmodules-cache-path=tmpcache example.m -E -o /dev/null  -fmodules
>
> While building module 'IOKit' imported from example.m:1:
> In file included from :2:
> /Applications/Xcode.app/Contents/Developer/Platforms/
> MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/
> Library/Frameworks/IOKit.framework/Headers/IODataQueueClient.h:62:71:
> error: de
>   'Darwin.POSIX._types._uint32_t' before it is required
> IOReturn IODataQueueDequeue(IODataQueueMemory *dataQueue, void *data,
> uint32_t *dataSize);
>   ^
> /Applications/Xcode.app/Contents/Developer/Platforms/
> MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/
> include/_types/_uint32_t.h:31:22:
> note: previous declaration is here
> typedef unsigned int uint32_t;
>  ^
> bot.m:1:9: fatal error: could not build module 'IOKit'
> #import 
>  ~~~^


This change also broke local submodule visibility builds with modular glibc
(see PR30778 for details). I have an idea for how to fix this; running it
through bootstrap now.

>> > Hmm. Ideally, we should try to pick something that captures the spirit
> >> > of
> >> > "only non-modular headers and headers from used modules". Something
> like
> >> > "ignore_modules_not_declared_used", but less wordy?
> >>
> >> Right. It's gonna be hard to shrink this to a meaningful short name.
> >> What about a more generic "no_escape"?  "no_undeclared_headers"?
> >
> >
> > Hmm. Maybe we could allow the existing [exhaustive] attribute to be
> > specified on a use-declaration:
> >
> >   use [exhaustive] a, b, c
>
> I don't understand, the 'Darwin' module map doesn't use the 'use'
> keyword in any of its modules, how do you suggest we would use that to
> express the 'ignore_modules_not_declared_used' idea?


Hah, right, this would only work if your module has dependencies. Maybe an
[exhaustive_uses] attribute on the module itself then?
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r285117 - Fix nullptr tests

2016-10-25 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Oct 25 15:45:17 2016
New Revision: 285117

URL: http://llvm.org/viewvc/llvm-project?rev=285117=rev
Log:
Fix nullptr tests

Modified:
libcxx/trunk/include/__nullptr
libcxx/trunk/test/std/language.support/support.types/nullptr_t.pass.cpp

Modified: libcxx/trunk/include/__nullptr
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__nullptr?rev=285117=285116=285117=diff
==
--- libcxx/trunk/include/__nullptr (original)
+++ libcxx/trunk/include/__nullptr Tue Oct 25 15:45:17 2016
@@ -42,10 +42,6 @@ struct _LIBCPP_TYPE_VIS_ONLY nullptr_t
 
 friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator==(nullptr_t, 
nullptr_t) {return true;}
 friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator!=(nullptr_t, 
nullptr_t) {return false;}
-friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator<(nullptr_t, 
nullptr_t) {return false;}
-friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator<=(nullptr_t, 
nullptr_t) {return true;}
-friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator>(nullptr_t, 
nullptr_t) {return false;}
-friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator>=(nullptr_t, 
nullptr_t) {return true;}
 };
 
 inline _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t __get_nullptr_t() 
{return nullptr_t(0);}

Modified: 
libcxx/trunk/test/std/language.support/support.types/nullptr_t.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.types/nullptr_t.pass.cpp?rev=285117=285116=285117=diff
==
--- libcxx/trunk/test/std/language.support/support.types/nullptr_t.pass.cpp 
(original)
+++ libcxx/trunk/test/std/language.support/support.types/nullptr_t.pass.cpp Tue 
Oct 25 15:45:17 2016
@@ -11,6 +11,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 // typedef decltype(nullptr) nullptr_t;
 
 struct A
@@ -34,22 +36,20 @@ void test_conversions()
 }
 }
 
+template  struct Voider { typedef void type; };
+template  struct has_less : std::false_type {};
+
+template  struct has_less::type> : 
std::true_type {};
+
 template 
 void test_comparisons()
 {
 T p = nullptr;
 assert(p == nullptr);
-assert(p <= nullptr);
-assert(p >= nullptr);
 assert(!(p != nullptr));
-assert(!(p < nullptr));
-assert(!(p > nullptr));
 assert(nullptr == p);
-assert(nullptr <= p);
-assert(nullptr >= p);
 assert(!(nullptr != p));
-assert(!(nullptr < p));
-assert(!(nullptr > p));
 }
 
 #if defined(__clang__)
@@ -89,6 +89,15 @@ int main()
 test_conversions();
 }
 {
+#ifdef _LIBCPP_HAS_NO_NULLPTR
+static_assert(!has_less::value, "");
+// FIXME: our c++03 nullptr emulation still allows for comparisons
+// with other pointer types by way of the conversion operator.
+//static_assert(!has_less::value, "");
+#else
+// TODO Enable this assertion when all compilers implement core DR 583.
+// static_assert(!has_less::value, "");
+#endif
 test_comparisons();
 test_comparisons();
 test_comparisons();


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


[PATCH] D23754: cmake: Add CLANG_GOLD_LIBDIR_SUFFIX to specify loc of LLVMgold.so

2016-10-25 Thread Michał Górny via cfe-commits
mgorny added a reviewer: beanz.
mgorny added a subscriber: beanz.
mgorny added a comment.

@beanz, could you also look at this one? I'd like to replace 
CLANG_LIBDIR_SUFFIX with the runtimes suffix, and for this I'd have to get rid 
of this CLANG_LIBDIR_SUFFIX occurrence as well. However, I don't think 
LLVMgold.so really counts as a 'runtime', so I guess a default of 
LLVM_LIBDIR_SUFFIX with possible explicit override would work here.


https://reviews.llvm.org/D23754



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


[libcxxabi] r285107 - Get libc++abi building with LLVM_ENABLE_MODULES

2016-10-25 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Oct 25 15:07:49 2016
New Revision: 285107

URL: http://llvm.org/viewvc/llvm-project?rev=285107=rev
Log:
Get libc++abi building with LLVM_ENABLE_MODULES

Modified:
libcxxabi/trunk/src/CMakeLists.txt

Modified: libcxxabi/trunk/src/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/CMakeLists.txt?rev=285107=285106=285107=diff
==
--- libcxxabi/trunk/src/CMakeLists.txt (original)
+++ libcxxabi/trunk/src/CMakeLists.txt Tue Oct 25 15:07:49 2016
@@ -95,6 +95,12 @@ string(REPLACE ";" " " LIBCXXABI_COMPILE
 string(REPLACE ";" " " LIBCXXABI_LINK_FLAGS "${LIBCXXABI_LINK_FLAGS}")
 string(REPLACE ";" " " LIBCXXABI_SHARED_LINK_FLAGS 
"${LIBCXXABI_SHARED_LINK_FLAGS}")
 
+# FIXME: libc++abi.so will not link when modules are enabled because it depends
+# on symbols defined in libc++.so which has not yet been built.
+if (LLVM_ENABLE_MODULES)
+  string(REPLACE "-Wl,-z,defs" "" CMAKE_SHARED_LINKER_FLAGS 
"${CMAKE_SHARED_LINKER_FLAGS}")
+endif()
+
 # Add a object library that contains the compiled source files.
 add_library(cxxabi_objects OBJECT ${LIBCXXABI_SOURCES} ${LIBCXXABI_HEADERS})
 


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


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

2016-10-25 Thread Adrian Prantl via cfe-commits
aprantl added inline comments.



Comment at: lib/CodeGen/CGDebugInfo.cpp:2493-2499
   case Type::Adjusted:
-  case Type::Decayed:
+  case Type::Decayed: {
 // Decayed and adjusted types use the adjusted type in LLVM and DWARF.
-return CreateType(
-cast(cast(Ty)->getAdjustedType()), Unit);
+QualType Adjusted = cast(Ty)->getAdjustedType();
+(void)AttributedType::stripOuterNullability(Adjusted);
+return CreateType(cast(Adjusted), Unit);
+  }

jordan_rose wrote:
> rsmith wrote:
> > I think this should be handled by `UnwrapTypeForDebugInfo` instead of here; 
> > this is after all just a type sugar node.
> Getting back to this today. I'm inclined to say we should just drop the 
> AdjustedType node altogether in UnwrapTypeForDebugInfo. What do you think? 
> (also for @aprantl)
Assuming that we don't want to support nullability attributes in the debug info 
that seems fine. At least at this point I don;t think there is a need to encode 
this in DWARF.


Repository:
  rL LLVM

https://reviews.llvm.org/D25850



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


[libcxx] r285102 - Update revision number in CHANGELOG.TXT

2016-10-25 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Oct 25 14:44:38 2016
New Revision: 285102

URL: http://llvm.org/viewvc/llvm-project?rev=285102=rev
Log:
Update revision number in CHANGELOG.TXT

Modified:
libcxx/trunk/lib/abi/CHANGELOG.TXT

Modified: libcxx/trunk/lib/abi/CHANGELOG.TXT
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/abi/CHANGELOG.TXT?rev=285102=285101=285102=diff
==
--- libcxx/trunk/lib/abi/CHANGELOG.TXT (original)
+++ libcxx/trunk/lib/abi/CHANGELOG.TXT Tue Oct 25 14:44:38 2016
@@ -17,7 +17,7 @@ Version 4.0
 ---
 
 
-* rTBD - Add -fvisibility-inlines-hidden when building libc++.
+* r285101 - Add -fvisibility-inlines-hidden when building libc++.
 
   Although this change removes symbols, it should still be non-ABI breaking
   since all of the definitions removed are inline functions. For this reason


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


[libcxx] r285101 - [libcxx] Build with -fvisibility-inlines-hidden -- Remove 20 inline definitions from the dylib

2016-10-25 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Oct 25 14:43:44 2016
New Revision: 285101

URL: http://llvm.org/viewvc/llvm-project?rev=285101=rev
Log:
[libcxx] Build with -fvisibility-inlines-hidden -- Remove 20 inline definitions 
from the dylib

Summary:
This patch turns on `-fvisibility-inlines-hidden` when building  the dylib. 
This is important so that libc++.dylib doesn't accidentally export 
inline-functions which are ODR used somewhere in the dylib.

On OS X this change has no effect on the current ABI of the dylib. 
Unfortunately on Linux there are already ~20 inline functions which are 
unintentionally exported by the dylib. Almost all of these are implicitly 
generated destructors. I believe removing these function definitions is safe 
because every "linkage unit" which uses these functions has its own definition, 
and therefore shouldn't be dependent on libc++.dylib to provide them.

Also could a FreeBSD maintainer comment on the ABI compatibility of this patch?



Reviewers: mclow.lists, emaste, dexonsmith, joker-eph-DISABLED, jroelofs, 
danalbert, mehdi_amini, compnerd, dim

Subscribers: beanz, mgorny, cfe-commits, modocache

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

Modified:
libcxx/trunk/CMakeLists.txt
libcxx/trunk/lib/abi/CHANGELOG.TXT
libcxx/trunk/lib/abi/x86_64-linux-gnu.abilist

Modified: libcxx/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=285101=285100=285101=diff
==
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Tue Oct 25 14:43:44 2016
@@ -342,6 +342,11 @@ endif()
 # headers
 add_compile_flags_if_supported(-nostdinc++)
 
+# Hide all inline function definitions which have not explicitly been marked
+# visible. This prevents new definitions for inline functions from appearing in
+# the dylib when get ODR used by another function.
+add_compile_flags_if_supported(-fvisibility-inlines-hidden)
+
 # Let the library headers know they are currently being used to build the
 # library.
 add_definitions(-D_LIBCPP_BUILDING_LIBRARY)

Modified: libcxx/trunk/lib/abi/CHANGELOG.TXT
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/abi/CHANGELOG.TXT?rev=285101=285100=285101=diff
==
--- libcxx/trunk/lib/abi/CHANGELOG.TXT (original)
+++ libcxx/trunk/lib/abi/CHANGELOG.TXT Tue Oct 25 14:43:44 2016
@@ -16,6 +16,41 @@ New entries should be added directly bel
 Version 4.0
 ---
 
+
+* rTBD - Add -fvisibility-inlines-hidden when building libc++.
+
+  Although this change removes symbols, it should still be non-ABI breaking
+  since all of the definitions removed are inline functions. For this reason
+  removing these symbols is safe because every "linkage unit" which uses these
+  functions will contain their own definition.
+
+  x86_64-linux-gnu
+  
+  SYMBOL REMOVED: _ZNSt12bad_any_castD0Ev
+  SYMBOL REMOVED: _ZNSt12experimental15fundamentals_v112bad_any_castD0Ev
+  SYMBOL REMOVED: _ZNSt3__114__codecvt_utf8IDiED0Ev
+  SYMBOL REMOVED: _ZNSt3__114__codecvt_utf8IDsED0Ev
+  SYMBOL REMOVED: _ZNSt3__114__codecvt_utf8IwED0Ev
+  SYMBOL REMOVED: _ZNSt3__115__codecvt_utf16IDiLb0EED0Ev
+  SYMBOL REMOVED: _ZNSt3__115__codecvt_utf16IDiLb1EED0Ev
+  SYMBOL REMOVED: _ZNSt3__115__codecvt_utf16IDsLb0EED0Ev
+  SYMBOL REMOVED: _ZNSt3__115__codecvt_utf16IDsLb1EED0Ev
+  SYMBOL REMOVED: _ZNSt3__115__codecvt_utf16IwLb0EED0Ev
+  SYMBOL REMOVED: _ZNSt3__115__codecvt_utf16IwLb1EED0Ev
+  SYMBOL REMOVED: _ZNSt3__117__assoc_sub_stateD0Ev
+  SYMBOL REMOVED: _ZNSt3__117__assoc_sub_stateD2Ev
+  SYMBOL REMOVED: _ZNSt3__117__libcpp_sscanf_lEPKcP15__locale_structS1_z
+  SYMBOL REMOVED: _ZNSt3__119__libcpp_asprintf_lEPPcP15__locale_structPKcz
+  SYMBOL REMOVED: _ZNSt3__119__libcpp_snprintf_lEPcmP15__locale_structPKcz
+  SYMBOL REMOVED: _ZNSt3__120__codecvt_utf8_utf16IDiED0Ev
+  SYMBOL REMOVED: _ZNSt3__120__codecvt_utf8_utf16IDsED0Ev
+  SYMBOL REMOVED: _ZNSt3__120__codecvt_utf8_utf16IwED0Ev
+
+  x86_64-apple-darwin16.0
+  ---
+  No Changes - inline symbols are already hidden
+
+
 * r284206 - Implement C++17 aligned allocation in 
 
   x86_64-linux-gnu

Modified: libcxx/trunk/lib/abi/x86_64-linux-gnu.abilist
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/abi/x86_64-linux-gnu.abilist?rev=285101=285100=285101=diff
==
--- libcxx/trunk/lib/abi/x86_64-linux-gnu.abilist (original)
+++ libcxx/trunk/lib/abi/x86_64-linux-gnu.abilist Tue Oct 25 14:43:44 2016
@@ -449,8 +449,6 @@
 {'type': 'FUNC', 'name': '_ZNSt11logic_errorC2ERKS_'}
 {'type': 'FUNC', 'name': '_ZNSt11logic_errorD2Ev'}
 {'type': 'FUNC', 'name': '_ZNSt11logic_erroraSERKS_'}
-{'type': 'FUNC', 'name': '_ZNSt12bad_any_castD0Ev'}
-{'type': 'FUNC', 'name': 
'_ZNSt12experimental15fundamentals_v112bad_any_castD0Ev'}
 {'type': 

[PATCH] D25593: [libcxx] Build with -fvisibility-inlines-hidden -- Remove 20 inline definitions from the dylib

2016-10-25 Thread Eric Fiselier via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285101: [libcxx] Build with -fvisibility-inlines-hidden -- 
Remove 20 inline definitions… (authored by EricWF).

Changed prior to commit:
  https://reviews.llvm.org/D25593?vs=75770=75772#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25593

Files:
  libcxx/trunk/CMakeLists.txt
  libcxx/trunk/lib/abi/CHANGELOG.TXT
  libcxx/trunk/lib/abi/x86_64-linux-gnu.abilist

Index: libcxx/trunk/lib/abi/CHANGELOG.TXT
===
--- libcxx/trunk/lib/abi/CHANGELOG.TXT
+++ libcxx/trunk/lib/abi/CHANGELOG.TXT
@@ -16,6 +16,41 @@
 Version 4.0
 ---
 
+
+* rTBD - Add -fvisibility-inlines-hidden when building libc++.
+
+  Although this change removes symbols, it should still be non-ABI breaking
+  since all of the definitions removed are inline functions. For this reason
+  removing these symbols is safe because every "linkage unit" which uses these
+  functions will contain their own definition.
+
+  x86_64-linux-gnu
+  
+  SYMBOL REMOVED: _ZNSt12bad_any_castD0Ev
+  SYMBOL REMOVED: _ZNSt12experimental15fundamentals_v112bad_any_castD0Ev
+  SYMBOL REMOVED: _ZNSt3__114__codecvt_utf8IDiED0Ev
+  SYMBOL REMOVED: _ZNSt3__114__codecvt_utf8IDsED0Ev
+  SYMBOL REMOVED: _ZNSt3__114__codecvt_utf8IwED0Ev
+  SYMBOL REMOVED: _ZNSt3__115__codecvt_utf16IDiLb0EED0Ev
+  SYMBOL REMOVED: _ZNSt3__115__codecvt_utf16IDiLb1EED0Ev
+  SYMBOL REMOVED: _ZNSt3__115__codecvt_utf16IDsLb0EED0Ev
+  SYMBOL REMOVED: _ZNSt3__115__codecvt_utf16IDsLb1EED0Ev
+  SYMBOL REMOVED: _ZNSt3__115__codecvt_utf16IwLb0EED0Ev
+  SYMBOL REMOVED: _ZNSt3__115__codecvt_utf16IwLb1EED0Ev
+  SYMBOL REMOVED: _ZNSt3__117__assoc_sub_stateD0Ev
+  SYMBOL REMOVED: _ZNSt3__117__assoc_sub_stateD2Ev
+  SYMBOL REMOVED: _ZNSt3__117__libcpp_sscanf_lEPKcP15__locale_structS1_z
+  SYMBOL REMOVED: _ZNSt3__119__libcpp_asprintf_lEPPcP15__locale_structPKcz
+  SYMBOL REMOVED: _ZNSt3__119__libcpp_snprintf_lEPcmP15__locale_structPKcz
+  SYMBOL REMOVED: _ZNSt3__120__codecvt_utf8_utf16IDiED0Ev
+  SYMBOL REMOVED: _ZNSt3__120__codecvt_utf8_utf16IDsED0Ev
+  SYMBOL REMOVED: _ZNSt3__120__codecvt_utf8_utf16IwED0Ev
+
+  x86_64-apple-darwin16.0
+  ---
+  No Changes - inline symbols are already hidden
+
+
 * r284206 - Implement C++17 aligned allocation in 
 
   x86_64-linux-gnu
Index: libcxx/trunk/lib/abi/x86_64-linux-gnu.abilist
===
--- libcxx/trunk/lib/abi/x86_64-linux-gnu.abilist
+++ libcxx/trunk/lib/abi/x86_64-linux-gnu.abilist
@@ -449,8 +449,6 @@
 {'type': 'FUNC', 'name': '_ZNSt11logic_errorC2ERKS_'}
 {'type': 'FUNC', 'name': '_ZNSt11logic_errorD2Ev'}
 {'type': 'FUNC', 'name': '_ZNSt11logic_erroraSERKS_'}
-{'type': 'FUNC', 'name': '_ZNSt12bad_any_castD0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt12experimental15fundamentals_v112bad_any_castD0Ev'}
 {'type': 'FUNC', 'name': '_ZNSt12experimental19bad_optional_accessD0Ev'}
 {'type': 'FUNC', 'name': '_ZNSt12experimental19bad_optional_accessD1Ev'}
 {'type': 'FUNC', 'name': '_ZNSt12experimental19bad_optional_accessD2Ev'}
@@ -893,9 +891,6 @@
 {'type': 'FUNC', 'name': '_ZNSt3__113shared_futureIvED1Ev'}
 {'type': 'FUNC', 'name': '_ZNSt3__113shared_futureIvED2Ev'}
 {'type': 'FUNC', 'name': '_ZNSt3__113shared_futureIvEaSERKS1_'}
-{'type': 'FUNC', 'name': '_ZNSt3__114__codecvt_utf8IDiED0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__114__codecvt_utf8IDsED0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__114__codecvt_utf8IwED0Ev'}
 {'type': 'FUNC', 'name': '_ZNSt3__114__get_const_dbEv'}
 {'type': 'FUNC', 'name': '_ZNSt3__114__num_get_base10__get_baseERNS_8ios_baseE'}
 {'type': 'OBJECT', 'name': '_ZNSt3__114__num_get_base5__srcE', 'size': 33}
@@ -943,12 +938,6 @@
 {'type': 'FUNC', 'name': '_ZNSt3__114error_categoryD0Ev'}
 {'type': 'FUNC', 'name': '_ZNSt3__114error_categoryD1Ev'}
 {'type': 'FUNC', 'name': '_ZNSt3__114error_categoryD2Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__115__codecvt_utf16IDiLb0EED0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__115__codecvt_utf16IDiLb1EED0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__115__codecvt_utf16IDsLb0EED0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__115__codecvt_utf16IDsLb1EED0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__115__codecvt_utf16IwLb0EED0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__115__codecvt_utf16IwLb1EED0Ev'}
 {'type': 'FUNC', 'name': '_ZNSt3__115__get_classnameEPKcb'}
 {'type': 'FUNC', 'name': '_ZNSt3__115__num_get_floatIdEET_PKcS3_Rj'}
 {'type': 'FUNC', 'name': '_ZNSt3__115__num_get_floatIeEET_PKcS3_Rj'}
@@ -1080,9 +1069,6 @@
 {'type': 'FUNC', 'name': '_ZNSt3__117__assoc_sub_state4waitEv'}
 {'type': 'FUNC', 'name': '_ZNSt3__117__assoc_sub_state9__executeEv'}
 {'type': 'FUNC', 'name': '_ZNSt3__117__assoc_sub_state9set_valueEv'}
-{'type': 'FUNC', 'name': '_ZNSt3__117__assoc_sub_stateD0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__117__assoc_sub_stateD2Ev'}
-{'type': 'FUNC', 'name': 

[PATCH] D25593: [libcxx] Build with -fvisibility-inlines-hidden -- Remove 20 inline definitions from the dylib

2016-10-25 Thread Eric Fiselier via cfe-commits
EricWF updated this revision to Diff 75770.
EricWF added a comment.

- Address review comments by adding better documentation in the CHANGELOG.TXT.


https://reviews.llvm.org/D25593

Files:
  CMakeLists.txt
  lib/abi/CHANGELOG.TXT
  lib/abi/x86_64-linux-gnu.abilist

Index: lib/abi/x86_64-linux-gnu.abilist
===
--- lib/abi/x86_64-linux-gnu.abilist
+++ lib/abi/x86_64-linux-gnu.abilist
@@ -449,8 +449,6 @@
 {'type': 'FUNC', 'name': '_ZNSt11logic_errorC2ERKS_'}
 {'type': 'FUNC', 'name': '_ZNSt11logic_errorD2Ev'}
 {'type': 'FUNC', 'name': '_ZNSt11logic_erroraSERKS_'}
-{'type': 'FUNC', 'name': '_ZNSt12bad_any_castD0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt12experimental15fundamentals_v112bad_any_castD0Ev'}
 {'type': 'FUNC', 'name': '_ZNSt12experimental19bad_optional_accessD0Ev'}
 {'type': 'FUNC', 'name': '_ZNSt12experimental19bad_optional_accessD1Ev'}
 {'type': 'FUNC', 'name': '_ZNSt12experimental19bad_optional_accessD2Ev'}
@@ -893,9 +891,6 @@
 {'type': 'FUNC', 'name': '_ZNSt3__113shared_futureIvED1Ev'}
 {'type': 'FUNC', 'name': '_ZNSt3__113shared_futureIvED2Ev'}
 {'type': 'FUNC', 'name': '_ZNSt3__113shared_futureIvEaSERKS1_'}
-{'type': 'FUNC', 'name': '_ZNSt3__114__codecvt_utf8IDiED0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__114__codecvt_utf8IDsED0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__114__codecvt_utf8IwED0Ev'}
 {'type': 'FUNC', 'name': '_ZNSt3__114__get_const_dbEv'}
 {'type': 'FUNC', 'name': '_ZNSt3__114__num_get_base10__get_baseERNS_8ios_baseE'}
 {'type': 'OBJECT', 'name': '_ZNSt3__114__num_get_base5__srcE', 'size': 33}
@@ -943,12 +938,6 @@
 {'type': 'FUNC', 'name': '_ZNSt3__114error_categoryD0Ev'}
 {'type': 'FUNC', 'name': '_ZNSt3__114error_categoryD1Ev'}
 {'type': 'FUNC', 'name': '_ZNSt3__114error_categoryD2Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__115__codecvt_utf16IDiLb0EED0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__115__codecvt_utf16IDiLb1EED0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__115__codecvt_utf16IDsLb0EED0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__115__codecvt_utf16IDsLb1EED0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__115__codecvt_utf16IwLb0EED0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__115__codecvt_utf16IwLb1EED0Ev'}
 {'type': 'FUNC', 'name': '_ZNSt3__115__get_classnameEPKcb'}
 {'type': 'FUNC', 'name': '_ZNSt3__115__num_get_floatIdEET_PKcS3_Rj'}
 {'type': 'FUNC', 'name': '_ZNSt3__115__num_get_floatIeEET_PKcS3_Rj'}
@@ -1080,9 +1069,6 @@
 {'type': 'FUNC', 'name': '_ZNSt3__117__assoc_sub_state4waitEv'}
 {'type': 'FUNC', 'name': '_ZNSt3__117__assoc_sub_state9__executeEv'}
 {'type': 'FUNC', 'name': '_ZNSt3__117__assoc_sub_state9set_valueEv'}
-{'type': 'FUNC', 'name': '_ZNSt3__117__assoc_sub_stateD0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__117__assoc_sub_stateD2Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__117__libcpp_sscanf_lEPKcP15__locale_structS1_z'}
 {'type': 'FUNC', 'name': '_ZNSt3__117__widen_from_utf8ILm16EED0Ev'}
 {'type': 'FUNC', 'name': '_ZNSt3__117__widen_from_utf8ILm16EED1Ev'}
 {'type': 'FUNC', 'name': '_ZNSt3__117__widen_from_utf8ILm16EED2Ev'}
@@ -1122,8 +1108,6 @@
 {'type': 'FUNC', 'name': '_ZNSt3__118shared_timed_mutex8try_lockEv'}
 {'type': 'FUNC', 'name': '_ZNSt3__118shared_timed_mutexC1Ev'}
 {'type': 'FUNC', 'name': '_ZNSt3__118shared_timed_mutexC2Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__119__libcpp_asprintf_lEPPcP15__locale_structPKcz'}
-{'type': 'FUNC', 'name': '_ZNSt3__119__libcpp_snprintf_lEPcmP15__locale_structPKcz'}
 {'type': 'FUNC', 'name': '_ZNSt3__119__shared_mutex_base11lock_sharedEv'}
 {'type': 'FUNC', 'name': '_ZNSt3__119__shared_mutex_base13unlock_sharedEv'}
 {'type': 'FUNC', 'name': '_ZNSt3__119__shared_mutex_base15try_lock_sharedEv'}
@@ -1144,9 +1128,6 @@
 {'type': 'FUNC', 'name': '_ZNSt3__119__thread_local_dataEv'}
 {'type': 'FUNC', 'name': '_ZNSt3__119declare_no_pointersEPcm'}
 {'type': 'OBJECT', 'name': '_ZNSt3__119piecewise_constructE', 'size': 1}
-{'type': 'FUNC', 'name': '_ZNSt3__120__codecvt_utf8_utf16IDiED0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__120__codecvt_utf8_utf16IDsED0Ev'}
-{'type': 'FUNC', 'name': '_ZNSt3__120__codecvt_utf8_utf16IwED0Ev'}
 {'type': 'FUNC', 'name': '_ZNSt3__120__get_collation_nameEPKc'}
 {'type': 'FUNC', 'name': '_ZNSt3__120__throw_system_errorEiPKc'}
 {'type': 'FUNC', 'name': '_ZNSt3__121__thread_specific_ptrINS_15__thread_structEE16__at_thread_exitEPv'}
Index: lib/abi/CHANGELOG.TXT
===
--- lib/abi/CHANGELOG.TXT
+++ lib/abi/CHANGELOG.TXT
@@ -16,6 +16,41 @@
 Version 4.0
 ---
 
+
+* rTBD - Add -fvisibility-inlines-hidden when building libc++.
+
+  Although this change removes symbols, it should still be non-ABI breaking
+  since all of the definitions removed are inline functions. For this reason
+  removing these symbols is safe because every "linkage unit" which uses these
+  functions will contain their own definition.
+
+  x86_64-linux-gnu
+  
+  SYMBOL REMOVED: _ZNSt12bad_any_castD0Ev
+  SYMBOL REMOVED: 

[libcxx] r285100 - [libc++] Fix modules build - Rework __refstring definition

2016-10-25 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Oct 25 14:33:14 2016
New Revision: 285100

URL: http://llvm.org/viewvc/llvm-project?rev=285100=rev
Log:
[libc++] Fix modules build - Rework __refstring definition 

Summary:
`__libcpp_refstring` currently has two different definitions. First there is 
the complete definition in `<__refstring>` but there is also a second in  
``.  The historical reason for this split is because both libc++ and 
libc++abi need to see the inline definitions of __libcpp_refstrings methods, 
but the `` header doesn't.  However this is an ODR violation and 
breaks the modules build.

This patch fixes the issue by creating a single class definition in 
`` and changing `<__refstring>` to contain only the inline method 
definitions. This way both `libcxx/src/stdexcept.cpp` and 
`libcxxabi/src/stdexcept.cpp` see the same declaration in `` and 
definitions in `<__refstring>`

Reviewers: mclow.lists, EricWF

Subscribers: cfe-commits

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

Modified:
libcxx/trunk/include/__refstring
libcxx/trunk/include/stdexcept
libcxx/trunk/src/stdexcept.cpp

Modified: libcxx/trunk/include/__refstring
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__refstring?rev=285100=285099=285100=diff
==
--- libcxx/trunk/include/__refstring (original)
+++ libcxx/trunk/include/__refstring Tue Oct 25 14:33:14 2016
@@ -11,6 +11,7 @@
 #define _LIBCPP___REFSTRING
 
 #include <__config>
+#include 
 #include 
 #include 
 #ifdef __APPLE__
@@ -20,119 +21,106 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-class _LIBCPP_HIDDEN __libcpp_refstring
-{
-private:
-const char* str_;
-
-typedef int count_t;
-
-struct _Rep_base
-{
-std::size_t len;
-std::size_t cap;
-count_t count;
-};
-
-static
-_Rep_base*
-rep_from_data(const char *data_) _NOEXCEPT
-{
-char *data = const_cast(data_);
-return reinterpret_cast<_Rep_base *>(data - sizeof(_Rep_base));
-}
-static
-char *
-data_from_rep(_Rep_base *rep) _NOEXCEPT
-{
-char *data = reinterpret_cast(rep);
-return data + sizeof(*rep);
-}
+namespace __refstring_imp { namespace {
+typedef int count_t;
 
-#ifdef __APPLE__
-static
-const char*
-compute_gcc_empty_string_storage() _NOEXCEPT
-{
-void* handle = dlopen("/usr/lib/libstdc++.6.dylib", RTLD_NOLOAD);
-if (handle == nullptr)
-return nullptr;
-void* sym = dlsym(handle, "_ZNSs4_Rep20_S_empty_rep_storageE");
-if (sym == nullptr)
-return nullptr;
-return data_from_rep(reinterpret_cast<_Rep_base *>(sym));
-}
-
-static
-const char*
-get_gcc_empty_string_storage() _NOEXCEPT
-{
-static const char* p = compute_gcc_empty_string_storage();
-return p;
-}
+struct _Rep_base {
+std::size_t len;
+std::size_t cap;
+count_t count;
+};
 
-bool
-uses_refcount() const
-{
-return str_ != get_gcc_empty_string_storage();
-}
-#else
-bool
-uses_refcount() const
-{
-return true;
-}
+inline _Rep_base* rep_from_data(const char *data_) noexcept {
+char *data = const_cast(data_);
+return reinterpret_cast<_Rep_base *>(data - sizeof(_Rep_base));
+}
+
+inline char * data_from_rep(_Rep_base *rep) noexcept {
+char *data = reinterpret_cast(rep);
+return data + sizeof(*rep);
+}
+
+#if defined(__APPLE__)
+inline
+const char* compute_gcc_empty_string_storage() _NOEXCEPT
+{
+void* handle = dlopen("/usr/lib/libstdc++.6.dylib", RTLD_NOLOAD);
+if (handle == nullptr)
+return nullptr;
+void* sym = dlsym(handle, "_ZNSs4_Rep20_S_empty_rep_storageE");
+if (sym == nullptr)
+return nullptr;
+return data_from_rep(reinterpret_cast<_Rep_base *>(sym));
+}
+
+inline
+const char*
+get_gcc_empty_string_storage() _NOEXCEPT
+{
+static const char* p = compute_gcc_empty_string_storage();
+return p;
+}
 #endif
 
-public:
-explicit __libcpp_refstring(const char* msg) {
-std::size_t len = strlen(msg);
-_Rep_base* rep = static_cast<_Rep_base *>(::operator new(sizeof(*rep) 
+ len + 1));
-rep->len = len;
-rep->cap = len;
-rep->count = 0;
-char *data = data_from_rep(rep);
-std::memcpy(data, msg, len + 1);
-str_ = data;
-}
+}} // namespace __refstring_imp
 
-__libcpp_refstring(const __libcpp_refstring& s) _NOEXCEPT : str_(s.str_)
-{
-if (uses_refcount())
-__sync_add_and_fetch(_from_data(str_)->count, 1);
-}
+using namespace __refstring_imp;
 
-__libcpp_refstring& operator=(const __libcpp_refstring& s) _NOEXCEPT
+inline
+__libcpp_refstring::__libcpp_refstring(const char* msg) {
+std::size_t len = strlen(msg);
+_Rep_base* rep = static_cast<_Rep_base *>(::operator new(sizeof(*rep) + 
len + 1));
+rep->len = len;
+

[PATCH] D25958: [libc++] Silence "unused parameter" warnings in test/support/archetypes.hpp

2016-10-25 Thread Casey Carter via cfe-commits
CaseyCarter created this revision.
CaseyCarter added reviewers: EricWF, mclow.lists.
CaseyCarter added a subscriber: cfe-commits.

Fairly straightforward: simply removes the parameter names from the unused 
parameters.


https://reviews.llvm.org/D25958

Files:
  test/support/archetypes.hpp


Index: test/support/archetypes.hpp
===
--- test/support/archetypes.hpp
+++ test/support/archetypes.hpp
@@ -68,12 +68,12 @@
 ++alive; ++constructed; ++value_constructed;
 }
 template ::type = true>
-explicit TestBase(std::initializer_list& il, int y = 0) noexcept
+explicit TestBase(std::initializer_list& il, int = 0) noexcept
   : value(il.size()) {
 ++alive; ++constructed; ++value_constructed;
 }
 template ::type = true>
-explicit TestBase(std::initializer_list& il, int y = 0) noexcept : 
value(il.size()) {
+explicit TestBase(std::initializer_list& il, int = 0) noexcept : 
value(il.size()) {
 ++alive; ++constructed; ++value_constructed;
 }
 TestBase& operator=(int xvalue) noexcept {
@@ -135,9 +135,9 @@
 template ::type = true>
 constexpr ValueBase(int, int y) : value(y) {}
 template ::type = true>
-explicit constexpr ValueBase(std::initializer_list& il, int y = 0) : 
value(il.size()) {}
+explicit constexpr ValueBase(std::initializer_list& il, int = 0) : 
value(il.size()) {}
 template ::type = true>
-constexpr ValueBase(std::initializer_list& il, int y = 0) : 
value(il.size()) {}
+constexpr ValueBase(std::initializer_list& il, int = 0) : 
value(il.size()) {}
 TEST_CONSTEXPR_CXX14 ValueBase& operator=(int xvalue) noexcept {
 value = xvalue;
 return *this;
@@ -193,9 +193,9 @@
 template ::type = true>
 constexpr TrivialValueBase(int, int y) : value(y) {}
 template ::type = true>
-explicit constexpr TrivialValueBase(std::initializer_list& il, int y 
= 0) : value(il.size()) {}
+explicit constexpr TrivialValueBase(std::initializer_list& il, int = 
0) : value(il.size()) {}
 template ::type = true>
-constexpr TrivialValueBase(std::initializer_list& il, int y = 0) : 
value(il.size()) {};
+constexpr TrivialValueBase(std::initializer_list& il, int = 0) : 
value(il.size()) {};
 int value;
 protected:
 constexpr TrivialValueBase() noexcept : value(0) {}


Index: test/support/archetypes.hpp
===
--- test/support/archetypes.hpp
+++ test/support/archetypes.hpp
@@ -68,12 +68,12 @@
 ++alive; ++constructed; ++value_constructed;
 }
 template ::type = true>
-explicit TestBase(std::initializer_list& il, int y = 0) noexcept
+explicit TestBase(std::initializer_list& il, int = 0) noexcept
   : value(il.size()) {
 ++alive; ++constructed; ++value_constructed;
 }
 template ::type = true>
-explicit TestBase(std::initializer_list& il, int y = 0) noexcept : value(il.size()) {
+explicit TestBase(std::initializer_list& il, int = 0) noexcept : value(il.size()) {
 ++alive; ++constructed; ++value_constructed;
 }
 TestBase& operator=(int xvalue) noexcept {
@@ -135,9 +135,9 @@
 template ::type = true>
 constexpr ValueBase(int, int y) : value(y) {}
 template ::type = true>
-explicit constexpr ValueBase(std::initializer_list& il, int y = 0) : value(il.size()) {}
+explicit constexpr ValueBase(std::initializer_list& il, int = 0) : value(il.size()) {}
 template ::type = true>
-constexpr ValueBase(std::initializer_list& il, int y = 0) : value(il.size()) {}
+constexpr ValueBase(std::initializer_list& il, int = 0) : value(il.size()) {}
 TEST_CONSTEXPR_CXX14 ValueBase& operator=(int xvalue) noexcept {
 value = xvalue;
 return *this;
@@ -193,9 +193,9 @@
 template ::type = true>
 constexpr TrivialValueBase(int, int y) : value(y) {}
 template ::type = true>
-explicit constexpr TrivialValueBase(std::initializer_list& il, int y = 0) : value(il.size()) {}
+explicit constexpr TrivialValueBase(std::initializer_list& il, int = 0) : value(il.size()) {}
 template ::type = true>
-constexpr TrivialValueBase(std::initializer_list& il, int y = 0) : value(il.size()) {};
+constexpr TrivialValueBase(std::initializer_list& il, int = 0) : value(il.size()) {};
 int value;
 protected:
 constexpr TrivialValueBase() noexcept : value(0) {}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r285098 - Reapply r284265: "[Sema] Refactor context checking for availability diagnostics"

2016-10-25 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Tue Oct 25 14:05:50 2016
New Revision: 285098

URL: http://llvm.org/viewvc/llvm-project?rev=285098=rev
Log:
Reapply r284265: "[Sema] Refactor context checking for availability diagnostics"

The problem with the original commit was that some of Apple's headers depended
on an incorrect behaviour, this commit adds a temporary workaround until those
headers are fixed.

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaObjC/class-unavail-warning.m

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=285098=285097=285098=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Oct 25 14:05:50 2016
@@ -9909,23 +9909,16 @@ public:
 return OriginalLexicalContext ? OriginalLexicalContext : CurContext;
   }
 
-  AvailabilityResult getCurContextAvailability() const;
-
-  /// \brief Get the verison that this context implies.
-  /// For instance, a method in an interface that is annotated with an
-  /// availability attribuite effectively has the availability of the 
interface.
-  VersionTuple getVersionForDecl(const Decl *Ctx) const;
-
   /// \brief The diagnostic we should emit for \c D, or \c AR_Available.
   ///
   /// \param D The declaration to check. Note that this may be altered to point
   /// to another declaration that \c D gets it's availability from. i.e., we
   /// walk the list of typedefs to find an availability attribute.
   ///
-  /// \param ContextVersion The version to compare availability against.
-  AvailabilityResult
-  ShouldDiagnoseAvailabilityOfDecl(NamedDecl *, VersionTuple ContextVersion,
-   std::string *Message);
+  /// \param Message If non-null, this will be populated with the message from
+  /// the availability attribute that is selected.
+  AvailabilityResult ShouldDiagnoseAvailabilityOfDecl(NamedDecl *,
+  std::string *Message);
 
   const DeclContext *getCurObjCLexicalContext() const {
 const DeclContext *DC = getCurLexicalContext();

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=285098=285097=285098=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Oct 25 14:05:50 2016
@@ -15627,29 +15627,3 @@ void Sema::ActOnPragmaWeakAlias(Identifi
 Decl *Sema::getObjCDeclContext() const {
   return (dyn_cast_or_null(CurContext));
 }
-
-AvailabilityResult Sema::getCurContextAvailability() const {
-  const Decl *D = cast_or_null(getCurObjCLexicalContext());
-  if (!D)
-return AR_Available;
-
-  // If we are within an Objective-C method, we should consult
-  // both the availability of the method as well as the
-  // enclosing class.  If the class is (say) deprecated,
-  // the entire method is considered deprecated from the
-  // purpose of checking if the current context is deprecated.
-  if (const ObjCMethodDecl *MD = dyn_cast(D)) {
-AvailabilityResult R = MD->getAvailability();
-if (R != AR_Available)
-  return R;
-D = MD->getClassInterface();
-  }
-  // If we are within an Objective-c @implementation, it
-  // gets the same availability context as the @interface.
-  else if (const ObjCImplementationDecl *ID =
-dyn_cast(D)) {
-D = ID->getClassInterface();
-  }
-  // Recover from user error.
-  return D ? D->getAvailability() : AR_Available;
-}

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=285098=285097=285098=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Tue Oct 25 14:05:50 2016
@@ -6328,30 +6328,6 @@ static void handleDelayedForbiddenType(S
   diag.Triggered = true;
 }
 
-static bool isDeclDeprecated(Decl *D) {
-  do {
-if (D->isDeprecated())
-  return true;
-// A category implicitly has the availability of the interface.
-if (const ObjCCategoryDecl *CatD = dyn_cast(D))
-  if (const ObjCInterfaceDecl *Interface = CatD->getClassInterface())
-return Interface->isDeprecated();
-  } while ((D = cast_or_null(D->getDeclContext(;
-  return false;
-}
-
-static bool isDeclUnavailable(Decl *D) {
-  do {
-if (D->isUnavailable())
-  return true;
-// A category implicitly has the availability of the interface.
-if (const ObjCCategoryDecl *CatD = dyn_cast(D))
-  if (const ObjCInterfaceDecl *Interface = CatD->getClassInterface())
-return Interface->isUnavailable();
-  } while 

[PATCH] D25876: [analyzer] Report CFNumberGetValue API misuse

2016-10-25 Thread Artem Dergachev via cfe-commits
NoQ added inline comments.



Comment at: test/Analysis/CFNumber.c:39
+  unsigned char scalar = 0;
+  CFNumberGetValue(x, kCFNumberSInt16Type, );  // expected-warning{{A 
CFNumber object that represents a 16-bit integer is used to initialize an 8-bit 
integer; 8 bits of the CFNumber value will overwrite adjacent storage}}
+  return scalar;

We're not sure from this code if the `CFNumber` object `x` actually represents 
a 16-bit integer, or somebody just misplaced the `kCFNumberSInt16Type` thing. I 
think the warning message could be made more precise in this sence, but i'm not 
good at coming up with warning messages.

Hmm, there could actually be a separate check for detecting inconsistent type 
specifiers used for accessing the same CFNumber object.


https://reviews.llvm.org/D25876



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


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

2016-10-25 Thread Jordan Rose via cfe-commits
jordan_rose added inline comments.



Comment at: lib/CodeGen/CGDebugInfo.cpp:2493-2499
   case Type::Adjusted:
-  case Type::Decayed:
+  case Type::Decayed: {
 // Decayed and adjusted types use the adjusted type in LLVM and DWARF.
-return CreateType(
-cast(cast(Ty)->getAdjustedType()), Unit);
+QualType Adjusted = cast(Ty)->getAdjustedType();
+(void)AttributedType::stripOuterNullability(Adjusted);
+return CreateType(cast(Adjusted), Unit);
+  }

rsmith wrote:
> I think this should be handled by `UnwrapTypeForDebugInfo` instead of here; 
> this is after all just a type sugar node.
Getting back to this today. I'm inclined to say we should just drop the 
AdjustedType node altogether in UnwrapTypeForDebugInfo. What do you think? 
(also for @aprantl)


Repository:
  rL LLVM

https://reviews.llvm.org/D25850



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


[PATCH] D21853: [Driver][OpenMP] Update actions builder to create unbundling action when necessary.

2016-10-25 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 75741.
sfantao marked 3 inline comments as done.
sfantao added a comment.

- Fix typos and use StringRef() instead of const char * to follow what the 
Driver does today when it comes to specify the bound architectures.


https://reviews.llvm.org/D21853

Files:
  include/clang/Driver/Action.h
  include/clang/Driver/Types.h
  lib/Driver/Action.cpp
  lib/Driver/Driver.cpp
  lib/Driver/ToolChain.cpp
  lib/Driver/Types.cpp
  test/Driver/openmp-offload.c

Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -302,3 +302,56 @@
 // CHK-BUACTIONS: 17: backend, {2}, assembler, (host-openmp)
 // CHK-BUACTIONS: 18: assembler, {17}, object, (host-openmp)
 // CHK-BUACTIONS: 19: clang-offload-bundler, {9, 16, 18}, object, (host-openmp)
+
+/// ###
+
+/// Check separate compilation with offloading - unbundling actions
+// RUN:   touch %t.i
+// RUN:   %clang -### -ccc-print-phases -fopenmp -o %t.out -lsomelib -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %t.i 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-UBACTIONS %s
+
+// CHK-UBACTIONS: 0: input, "somelib", object, (host-openmp)
+// CHK-UBACTIONS: 1: input, "[[INPUT:.+\.i]]", cpp-output, (host-openmp)
+// CHK-UBACTIONS: 2: clang-offload-unbundler, {1}, cpp-output, (host-openmp)
+// CHK-UBACTIONS: 3: compiler, {2}, ir, (host-openmp)
+// CHK-UBACTIONS: 4: backend, {3}, assembler, (host-openmp)
+// CHK-UBACTIONS: 5: assembler, {4}, object, (host-openmp)
+// CHK-UBACTIONS: 6: linker, {0, 5}, image, (host-openmp)
+// CHK-UBACTIONS: 7: input, "somelib", object, (device-openmp)
+// CHK-UBACTIONS: 8: compiler, {2}, ir, (device-openmp)
+// CHK-UBACTIONS: 9: offload, "host-openmp (powerpc64le--linux)" {3}, "device-openmp (powerpc64le-ibm-linux-gnu)" {8}, ir
+// CHK-UBACTIONS: 10: backend, {9}, assembler, (device-openmp)
+// CHK-UBACTIONS: 11: assembler, {10}, object, (device-openmp)
+// CHK-UBACTIONS: 12: linker, {7, 11}, image, (device-openmp)
+// CHK-UBACTIONS: 13: input, "somelib", object, (device-openmp)
+// CHK-UBACTIONS: 14: compiler, {2}, ir, (device-openmp)
+// CHK-UBACTIONS: 15: offload, "host-openmp (powerpc64le--linux)" {3}, "device-openmp (x86_64-pc-linux-gnu)" {14}, ir
+// CHK-UBACTIONS: 16: backend, {15}, assembler, (device-openmp)
+// CHK-UBACTIONS: 17: assembler, {16}, object, (device-openmp)
+// CHK-UBACTIONS: 18: linker, {13, 17}, image, (device-openmp)
+// CHK-UBACTIONS: 19: offload, "host-openmp (powerpc64le--linux)" {6}, "device-openmp (powerpc64le-ibm-linux-gnu)" {12}, "device-openmp (x86_64-pc-linux-gnu)" {18}, image
+
+/// ###
+
+/// Check separate compilation with offloading - unbundling/bundling actions
+// RUN:   touch %t.i
+// RUN:   %clang -### -ccc-print-phases -fopenmp -c -o %t.o -lsomelib -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %t.i 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-UBUACTIONS %s
+
+// CHK-UBUACTIONS: 0: input, "[[INPUT:.+\.i]]", cpp-output, (host-openmp)
+// CHK-UBUACTIONS: 1: clang-offload-unbundler, {0}, cpp-output, (host-openmp)
+// CHK-UBUACTIONS: 2: compiler, {1}, ir, (host-openmp)
+// CHK-UBUACTIONS: 3: compiler, {1}, ir, (device-openmp)
+// CHK-UBUACTIONS: 4: offload, "host-openmp (powerpc64le--linux)" {2}, "device-openmp (powerpc64le-ibm-linux-gnu)" {3}, ir
+// CHK-UBUACTIONS: 5: backend, {4}, assembler, (device-openmp)
+// CHK-UBUACTIONS: 6: assembler, {5}, object, (device-openmp)
+// CHK-UBUACTIONS: 7: offload, "device-openmp (powerpc64le-ibm-linux-gnu)" {6}, object
+// CHK-UBUACTIONS: 8: compiler, {1}, ir, (device-openmp)
+// CHK-UBUACTIONS: 9: offload, "host-openmp (powerpc64le--linux)" {2}, "device-openmp (x86_64-pc-linux-gnu)" {8}, ir
+// CHK-UBUACTIONS: 10: backend, {9}, assembler, (device-openmp)
+// CHK-UBUACTIONS: 11: assembler, {10}, object, (device-openmp)
+// CHK-UBUACTIONS: 12: offload, "device-openmp (x86_64-pc-linux-gnu)" {11}, object
+// CHK-UBUACTIONS: 13: backend, {2}, assembler, (host-openmp)
+// CHK-UBUACTIONS: 14: assembler, {13}, object, (host-openmp)
+// CHK-UBUACTIONS: 15: clang-offload-bundler, {7, 12, 14}, object, (host-openmp)
+
Index: lib/Driver/Types.cpp
===
--- lib/Driver/Types.cpp
+++ lib/Driver/Types.cpp
@@ -170,6 +170,10 @@
   }
 }
 
+bool types::isSrcFile(ID Id) {
+  return Id != TY_Object && getPreprocessedType(Id) != TY_INVALID;
+}
+
 types::ID types::lookupTypeForExtension(llvm::StringRef Ext) {
   return llvm::StringSwitch(Ext)
.Case("c", TY_C)
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -265,6 +265,7 @@
 

[PATCH] D25954: [OpenCL] Add missing atom_xor for 64 bit to opencl-c.h

2016-10-25 Thread Yaxun Liu via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: Anastasia.
yaxunl added subscribers: cfe-commits, b-sumner.

https://reviews.llvm.org/D25954

Files:
  lib/Headers/opencl-c.h


Index: lib/Headers/opencl-c.h
===
--- lib/Headers/opencl-c.h
+++ lib/Headers/opencl-c.h
@@ -14616,6 +14616,13 @@
 unsigned int __ovld atom_xor(volatile __local unsigned int *p, unsigned int 
val);
 #endif
 
+#if defined(cl_khr_int64_extended_atomics)
+long __ovld atom_xor(volatile __global long *p, long val);
+unsigned long __ovld atom_xor(volatile __global unsigned long *p, unsigned 
long val);
+long __ovld atom_xor(volatile __local long *p, long val);
+unsigned long __ovld atom_xor(volatile __local unsigned long *p, unsigned long 
val);
+#endif
+
 #if defined(cl_khr_int64_base_atomics) && 
defined(cl_khr_int64_extended_atomics)
 #pragma OPENCL EXTENSION cl_khr_int64_base_atomics : disable
 #pragma OPENCL EXTENSION cl_khr_int64_extended_atomics : disable


Index: lib/Headers/opencl-c.h
===
--- lib/Headers/opencl-c.h
+++ lib/Headers/opencl-c.h
@@ -14616,6 +14616,13 @@
 unsigned int __ovld atom_xor(volatile __local unsigned int *p, unsigned int val);
 #endif
 
+#if defined(cl_khr_int64_extended_atomics)
+long __ovld atom_xor(volatile __global long *p, long val);
+unsigned long __ovld atom_xor(volatile __global unsigned long *p, unsigned long val);
+long __ovld atom_xor(volatile __local long *p, long val);
+unsigned long __ovld atom_xor(volatile __local unsigned long *p, unsigned long val);
+#endif
+
 #if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
 #pragma OPENCL EXTENSION cl_khr_int64_base_atomics : disable
 #pragma OPENCL EXTENSION cl_khr_int64_extended_atomics : disable
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25909: [analyzer] MacOSXApiChecker: Disallow dispatch_once predicates on heap and in ivars.

2016-10-25 Thread Artem Dergachev via cfe-commits
NoQ updated this revision to Diff 75739.
NoQ marked 2 inline comments as done.
NoQ added a comment.

Consider a lot more dispatch_once_t regions: improve diagnostics for local 
structs containing predicates, find ivar structs with predicates.

Address a couple of review comments, discuss the rest.


https://reviews.llvm.org/D25909

Files:
  lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
  test/Analysis/dispatch-once.m

Index: test/Analysis/dispatch-once.m
===
--- /dev/null
+++ test/Analysis/dispatch-once.m
@@ -0,0 +1,82 @@
+// RUN: %clang_cc1 -w -fblocks -analyze -analyzer-checker=core,osx.API,unix.Malloc -verify %s
+// RUN: %clang_cc1 -w -fblocks -fobjc-arc -analyze -analyzer-checker=core,osx.API,unix.Malloc -verify %s
+
+#include "Inputs/system-header-simulator-objc.h"
+
+typedef unsigned long size_t;
+void *calloc(size_t nmemb, size_t size);
+
+typedef void (^dispatch_block_t)(void);
+typedef long dispatch_once_t;
+void dispatch_once(dispatch_once_t *predicate, dispatch_block_t block);
+
+void test_stack() {
+  dispatch_once_t once;
+  dispatch_once(, ^{}); // expected-warning{{Call to 'dispatch_once' uses the local variable 'once' for the predicate value.  Using such transient memory for the predicate is potentially dangerous.  Perhaps you intended to declare the variable as 'static'?}}
+}
+
+void test_static_local() {
+  static dispatch_once_t once;
+  dispatch_once(, ^{}); // no-warning
+}
+
+void test_heap_var() {
+  dispatch_once_t *once = calloc(1, sizeof(dispatch_once_t));
+  // Use regexps to check that we're NOT suggesting to make this static.
+  dispatch_once(once, ^{}); // expected-warning-re^Call to 'dispatch_once' uses heap-allocated memory for the predicate value.  Using such transient memory for the predicate is potentially dangerous$
+}
+
+void test_external_pointer(dispatch_once_t *once) {
+  // External pointer does not necessarily point to the heap.
+  dispatch_once(once, ^{}); // no-warning
+}
+
+typedef struct {
+  dispatch_once_t once;
+} Struct;
+
+void test_local_struct() {
+  Struct s;
+  dispatch_once(, ^{}); // expected-warning{{Call to 'dispatch_once' uses the local variable 's' for the predicate value.  Using such transient memory for the predicate is potentially dangerous.  Perhaps you intended to declare the variable as 'static'?}}
+}
+
+void test_heap_struct() {
+  Struct *s = calloc(1, sizeof(Struct));
+  dispatch_once(>once, ^{}); // expected-warning{{Call to 'dispatch_once' uses heap-allocated memory for the predicate value.}}
+}
+
+@interface Object : NSObject {
+@public
+  dispatch_once_t once;
+  Struct s;
+}
+- (void)test_ivar_from_inside;
+- (void)test_ivar_struct_from_inside;
+@end
+
+@implementation Object
+- (void)test_ivar_from_inside {
+  dispatch_once(, ^{}); // expected-warning{{Call to 'dispatch_once' uses the instance variable 'once' for the predicate value.}}
+}
+- (void)test_ivar_struct_from_inside {
+  dispatch_once(, ^{}); // expected-warning{{Call to 'dispatch_once' uses the instance variable 's' for the predicate value.}}
+}
+@end
+
+void test_ivar_from_alloc_init() {
+  Object *o = [[Object alloc] init];
+  dispatch_once(>once, ^{}); // expected-warning{{Call to 'dispatch_once' uses the instance variable 'once' for the predicate value.}}
+}
+void test_ivar_struct_from_alloc_init() {
+  Object *o = [[Object alloc] init];
+  dispatch_once(>s.once, ^{}); // expected-warning{{Call to 'dispatch_once' uses the instance variable 's' for the predicate value.}}
+}
+
+void test_ivar_from_external_obj(Object *o) {
+  // ObjC object pointer always points to the heap.
+  dispatch_once(>once, ^{}); // expected-warning{{Call to 'dispatch_once' uses the instance variable 'once' for the predicate value.}}
+}
+
+void test_ivar_struct_from_external_obj(Object *o) {
+  dispatch_once(>s.once, ^{}); // expected-warning{{Call to 'dispatch_once' uses the instance variable 's' for the predicate value.}}
+}
Index: lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
+++ lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
@@ -33,6 +33,8 @@
 class MacOSXAPIChecker : public Checker< check::PreStmt > {
   mutable std::unique_ptr BT_dispatchOnce;
 
+  static const ObjCIvarRegion *getParentIvarRegion(const MemRegion *R);
+
 public:
   void checkPreStmt(const CallExpr *CE, CheckerContext ) const;
 
@@ -49,20 +51,35 @@
 // dispatch_once and dispatch_once_f
 //===--===//
 
+const ObjCIvarRegion *
+MacOSXAPIChecker::getParentIvarRegion(const MemRegion *R) {
+  const SubRegion *SR = dyn_cast(R);
+  while (SR) {
+if (const ObjCIvarRegion *IR = dyn_cast(SR))
+  return IR;
+SR = dyn_cast(SR->getSuperRegion());
+  }
+  return nullptr;
+}
+
 void MacOSXAPIChecker::CheckDispatchOnce(CheckerContext , const CallExpr *CE,

[PATCH] D25909: [analyzer] MacOSXApiChecker: Disallow dispatch_once predicates on heap and in ivars.

2016-10-25 Thread Artem Dergachev via cfe-commits
NoQ added inline comments.



Comment at: test/Analysis/dispatch-once.m:13
+
+void test_stack() {
+  dispatch_once_t once;

dcoughlin wrote:
> Should the tests for dispatch_once in unix-fns.c be moved here?
In fact we need to de-duplicate code with unix.API's pthread_once check, which 
is an exact copy-paste for this checker. Not sure how to achieve that, maybe 
split both into a single *-once checker (and remove this checker because it 
becomes empty). Maybe then we'd deal with tests as well.


https://reviews.llvm.org/D25909



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


[PATCH] D21853: [Driver][OpenMP] Update actions builder to create unbundling action when necessary.

2016-10-25 Thread Samuel Antao via cfe-commits
sfantao marked 7 inline comments as done.
sfantao added a comment.

Hi Hal,

Thanks for the review! Comments inlined.




Comment at: include/clang/Driver/Action.h:504
+  /// unbundling action.
+  struct DependingActionInfoTy final {
+/// \brief The tool chain of the depending action.

hfinkel wrote:
> Don't need 'Ty' in the name of this struct.
Ok, using `DependentActionInfo` now.



Comment at: lib/Driver/Driver.cpp:2091
+InputArg->getOption().getKind() == llvm::opt::Option::InputClass &&
+!types::isSrcFile(HostAction->getType())) {
+  auto UnbundlingHostAction =

hfinkel wrote:
> hfinkel wrote:
> > This checks that the file needs to be preprocessed. What does preprocessing 
> > have to do with this? I don't imagine that providing a preprocessed source 
> > file as input should invoke the unbundler   .
> On second thought, this is okay. It does not make sense to have a non-bundled 
> preprocessed source for the input there, as the host and device compilation 
> don't share a common preprocessor state.
> 
> We do need to be careful, perhaps, about .s files (which don't need 
> preprocessing as .S files do) -- we should probably assume that all 
> non-bundled .s files are host assembly code.
Yes, that is what we do. If the bundler tool detects that the input is not a 
bundle, it assumes it is host code/bits. In either case, we still generate the 
unbundling tool as the driver doesn't check the contents of the files.



Comment at: test/Driver/openmp-offload.c:274
+/// Check separate compilation with offloading - unbundling actions
+// RUN:   touch %t.i
+// RUN:   %clang -### -ccc-print-phases -fopenmp -o %t.out -lsomelib -target 
powerpc64le-linux 
-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %t.i 2>&1 \

hfinkel wrote:
> hfinkel wrote:
> > Oh, are you using .i to indicate a bundle instead of a preprocessed file? 
> > Don't do that. Please use a different suffix -- the bundler has its own 
> > file format.
> Never mind; this is okay too.
Ok, there is no particular suffix to indicate a file is a bundle. The 
(un)bundler, however, has the machinery to detect if a given file is a bundle, 
it just uses the extension to understand if it is a human readable file, 
bitcode file, or object file, because the bundle format is different in those 
three cases.


https://reviews.llvm.org/D21853



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


[PATCH] D21848: [Driver][OpenMP] Add logic for offloading-specific argument translation.

2016-10-25 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Hi Hal,

Thanks for the review!




Comment at: lib/Driver/ToolChains.cpp:2854
+  case options::OPT_shared:
+  case options::OPT_static:
+  case options::OPT_fPIC:

hfinkel wrote:
> And also?
> 
>   case options::OPT_dynamic:
Oh, yes, that one too! Thanks!


https://reviews.llvm.org/D21848



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


[PATCH] D21847: [Driver][OpenMP] Build jobs for OpenMP offloading actions for targets using gcc tool chains.

2016-10-25 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Hi Hal,

Thanks for the review! Comments inlined.




Comment at: lib/Driver/Tools.cpp:334
+  LksStream << "  OpenMP Offload Linker Script.\n";
+  LksStream << "*/\n";
+  LksStream << "TARGET(binary)\n";

hfinkel wrote:
> We should also say 'autogenerated' somewhere in this comment.
Ok, makes sense. The comment is now:
```
   OpenMP Offload Linker Script.
 *** Automatically generated by clang ***
```



Comment at: lib/Driver/Tools.cpp:386
+  // Dump the contents of the linker script if the user requested that.
+  if (C.getArgs().hasArg(options::OPT_fopenmp_dump_offload_linker_script))
+llvm::errs() << LksBuffer;

hfinkel wrote:
> I don't see why this is needed if we have -save-temps - I think we should 
> remove this option entirely.
The reason for adding this option is that the test is done when the driver is 
in dry-run mode (`-###`) so I'm not supposed to generate any files. If we don't 
run in dry-run mode, we need to allow linking to actually happen, therefore the 
machine where the tests runs needs to have a gcc-based toolchain and ld. 

Is there a way to request that in the required features set in llvm-lit config 
file? Should I add a new feature?


https://reviews.llvm.org/D21847



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


[PATCH] D21847: [Driver][OpenMP] Build jobs for OpenMP offloading actions for targets using gcc tool chains.

2016-10-25 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 75730.
sfantao marked 3 inline comments as done.
sfantao added a comment.

- Address Hal Finkel comments - fix comments/fix linker script comment.


https://reviews.llvm.org/D21847

Files:
  include/clang/Driver/Options.td
  lib/Driver/Driver.cpp
  lib/Driver/Tools.cpp
  test/Driver/openmp-offload.c

Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -173,3 +173,104 @@
 // CHK-PHASES-WITH-CUDA: 20: assembler, {19}, object, (device-openmp)
 // CHK-PHASES-WITH-CUDA: 21: linker, {20}, image, (device-openmp)
 // CHK-PHASES-WITH-CUDA: 22: offload, "host-cuda-openmp (powerpc64le-ibm-linux-gnu)" {14}, "device-openmp (nvptx64-nvidia-cuda)" {21}, image
+
+/// ###
+
+/// Check of the commands passed to each tool when using valid OpenMP targets.
+/// Here we also check that offloading does not break the use of integrated
+/// assembler. It does however preclude the merge of the host compile and
+/// backend phases. There are also two offloading specific options:
+/// -fopenmp-is-device: will tell the frontend that it will generate code for a
+/// target.
+/// -fopenmp-host-ir-file-path: specifies the host IR file that can be loaded by
+/// the target code generation to gather information about which declaration
+/// really need to be emitted.
+/// We use -fopenmp-dump-offload-linker-script to dump the linker script and
+/// check its contents.
+///
+// RUN:   %clang -### -fopenmp -o %t.out -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %s -fopenmp-dump-offload-linker-script 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-COMMANDS -check-prefix=CHK-LKS -check-prefix=CHK-LKS-REG %s
+// RUN:   %clang -### -fopenmp -o %t.out -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %s -save-temps -fopenmp-dump-offload-linker-script 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-COMMANDS-ST -check-prefix=CHK-LKS -check-prefix=CHK-LKS-ST %s
+
+// Make sure we are not dumping the script unless the user requested it.
+// RUN:   %clang -### -fopenmp -o %t.out -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-LKS-NODUMP %s
+// RUN:   %clang -### -fopenmp -o %t.out -target powerpc64le-linux -fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu %s -save-temps 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-LKS-NODUMP %s
+
+//
+// Check the linker script contains what we expect.
+//
+// CHK-LKS: /*
+// CHK-LKS:   OpenMP Offload Linker Script
+// CHK-LKS: *** Automatically generated by clang ***
+// CHK-LKS-NODUMP-NOT:  OpenMP Offload Linker Script.
+// CHK-LKS: */
+// CHK-LKS: TARGET(binary)
+// CHK-LKS-REG: INPUT([[T1BIN:.+\.out]])
+// CHK-LKS-REG: INPUT([[T2BIN:.+\.out]])
+// CHK-LKS-ST: INPUT([[T1BIN:.+\.out-device-openmp-powerpc64le-ibm-linux-gnu]])
+// CHK-LKS-ST: INPUT([[T2BIN:.+\.out-device-openmp-x86_64-pc-linux-gnu]])
+// CHK-LKS: SECTIONS
+// CHK-LKS: {
+// CHK-LKS:   .omp_offloading :
+// CHK-LKS:   ALIGN(0x10)
+// CHK-LKS:   {
+// CHK-LKS: . = ALIGN(0x10);
+// CHK-LKS: PROVIDE_HIDDEN(.omp_offloading.img_start.powerpc64le-ibm-linux-gnu = .);
+// CHK-LKS: [[T1BIN]]
+// CHK-LKS: PROVIDE_HIDDEN(.omp_offloading.img_end.powerpc64le-ibm-linux-gnu = .);
+// CHK-LKS: . = ALIGN(0x10);
+// CHK-LKS: PROVIDE_HIDDEN(.omp_offloading.img_start.x86_64-pc-linux-gnu = .);
+// CHK-LKS: [[T2BIN]]
+// CHK-LKS: PROVIDE_HIDDEN(.omp_offloading.img_end.x86_64-pc-linux-gnu = .);
+// CHK-LKS:   }
+// CHK-LKS:   .omp_offloading.entries :
+// CHK-LKS:   ALIGN(0x10)
+// CHK-LKS:   SUBALIGN(0x01)
+// CHK-LKS:   {
+// CHK-LKS: PROVIDE_HIDDEN(.omp_offloading.entries_begin = .);
+// CHK-LKS: *(.omp_offloading.entries)
+// CHK-LKS: PROVIDE_HIDDEN(.omp_offloading.entries_end = .);
+// CHK-LKS:   }
+// CHK-LKS: }
+// CHK-LKS: INSERT BEFORE .data
+
+//
+// Generate host BC file.
+//
+// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-emit-llvm-bc" {{.*}}"-o" "[[HOSTBC:.+\.bc]]" "-x" "c" "[[INPUT:.+\.c]]" "-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu"
+// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-E" {{.*}}"-fopenmp" {{.*}}"-o" "[[HOSTPP:.+\.i]]" "-x" "c" "[[INPUT:.+\.c]]"
+// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le--linux" "-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-o" "[[HOSTBC:.+\.bc]]" "-x" "cpp-output" "[[HOSTPP]]" "-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu"
+
+//
+// Compile for the powerpc device.
+//
+// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-ibm-linux-gnu" "-emit-obj" {{.*}}"-fopenmp" {{.*}}"-o" "[[T1OBJ:.+\.o]]" "-x" "c" "[[INPUT]]" "-fopenmp-is-device" 

[PATCH] D25305: [OpenCL] Setting constant address space for array initializers

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



Comment at: lib/CodeGen/CGDecl.cpp:1272
+if (getLangOpts().OpenCL) {
+  UA = llvm::GlobalValue::UnnamedAddr::None;
+  AS = CGM.getContext().getTargetAddressSpace(LangAS::opencl_constant);

AlexeySotkin wrote:
> bader wrote:
> > Anastasia wrote:
> > > bader wrote:
> > > > AlexeySotkin wrote:
> > > > > Anastasia wrote:
> > > > > > Why this change?
> > > > > Without this change, global variables with unnamed address space are 
> > > > > translated to SPIR-V as variables with "Function" storage class, 
> > > > > which is wrong.
> > > > > This should fix this issue: 
> > > > > https://github.com/KhronosGroup/SPIRV-LLVM/issues/50
> > > > There is inconsistency with how Clang maps initializers to OpenCL 
> > > > memory model.
> > > > Consider example from the test case:
> > > > ```
> > > > __private int arr[] = {1, 2, 3};
> > > > ```
> > > > This code allocates a global constant for initializer {1, 2, 3} and 
> > > > later copies values from this global constant to the private array 
> > > > using memcpy intrinsic. The global constant must be allocated in 
> > > > constant address space, but old code do assign any address space, which 
> > > > is considered to be a private memory region.
> > > > This patch puts global constant objects to constant address space.
> > > Yes, this is perfectly fine. I was specifically asking about setting 
> > > llvm::GlobalValue::UnnamedAddr::None attribute. I can't see why this has 
> > > to be done or is it because we now assign concrete address space and 
> > > private was treated as no address space at all?
> > This attribute has nothing to do with address spaces.
> > See http://llvm.org/docs/LangRef.html#global-variables for 
> > local_unnamed_addr and unnamed_addr attributes description.
> > My understanding is that llvm::GlobalValue::UnnamedAddr::Global should be 
> > fine here.
> llvm::GlobalValue::UnnamedAddr::None is default value of UnnamedAddr for 
> GlobalValue. This line can be removed, but extra "if" statement must be added 
> before GV->setUnnamedAddr(UA);
Yes, I also think that leaving global should be fine here. So could we just 
undo the change to line 1274?


https://reviews.llvm.org/D25305



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


[PATCH] D25949: [Driver] Refactor distro detection & classification as a separate API

2016-10-25 Thread Michał Górny via cfe-commits
mgorny created this revision.
mgorny added reviewers: bruno, bkramer.
mgorny added a subscriber: cfe-commits.
Herald added subscribers: modocache, beanz.

Refactor the Distro enum along with helper functions into a full-fledged
Distro class, inspired by llvm::Triple, and make it a public API.
The new class wraps the enum with necessary comparison operators, adding
the convenience Is*() methods and a constructor performing
the detection. The public API is needed to run the unit tests 
(https://reviews.llvm.org/D25869).


https://reviews.llvm.org/D25949

Files:
  include/clang/Driver/Distro.h
  lib/Driver/CMakeLists.txt
  lib/Driver/Distro.cpp
  lib/Driver/ToolChains.cpp

Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -14,6 +14,7 @@
 #include "clang/Basic/VirtualFileSystem.h"
 #include "clang/Config/config.h" // for GCC_INSTALL_PREFIX
 #include "clang/Driver/Compilation.h"
+#include "clang/Driver/Distro.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
@@ -3834,169 +3835,6 @@
   }
 }
 
-/// Distribution (very bare-bones at the moment).
-
-enum Distro {
-  // NB: Releases of a particular Linux distro should be kept together
-  // in this enum, because some tests are done by integer comparison against
-  // the first and last known member in the family, e.g. IsRedHat().
-  ArchLinux,
-  DebianLenny,
-  DebianSqueeze,
-  DebianWheezy,
-  DebianJessie,
-  DebianStretch,
-  Exherbo,
-  RHEL5,
-  RHEL6,
-  RHEL7,
-  Fedora,
-  OpenSUSE,
-  UbuntuHardy,
-  UbuntuIntrepid,
-  UbuntuJaunty,
-  UbuntuKarmic,
-  UbuntuLucid,
-  UbuntuMaverick,
-  UbuntuNatty,
-  UbuntuOneiric,
-  UbuntuPrecise,
-  UbuntuQuantal,
-  UbuntuRaring,
-  UbuntuSaucy,
-  UbuntuTrusty,
-  UbuntuUtopic,
-  UbuntuVivid,
-  UbuntuWily,
-  UbuntuXenial,
-  UbuntuYakkety,
-  UnknownDistro
-};
-
-static bool IsRedhat(enum Distro Distro) {
-  return Distro == Fedora || (Distro >= RHEL5 && Distro <= RHEL7);
-}
-
-static bool IsOpenSUSE(enum Distro Distro) { return Distro == OpenSUSE; }
-
-static bool IsDebian(enum Distro Distro) {
-  return Distro >= DebianLenny && Distro <= DebianStretch;
-}
-
-static bool IsUbuntu(enum Distro Distro) {
-  return Distro >= UbuntuHardy && Distro <= UbuntuYakkety;
-}
-
-static Distro DetectDistro(vfs::FileSystem ) {
-  llvm::ErrorOr File =
-  VFS.getBufferForFile("/etc/lsb-release");
-  if (File) {
-StringRef Data = File.get()->getBuffer();
-SmallVector Lines;
-Data.split(Lines, "\n");
-Distro Version = UnknownDistro;
-for (StringRef Line : Lines)
-  if (Version == UnknownDistro && Line.startswith("DISTRIB_CODENAME="))
-Version = llvm::StringSwitch(Line.substr(17))
-  .Case("hardy", UbuntuHardy)
-  .Case("intrepid", UbuntuIntrepid)
-  .Case("jaunty", UbuntuJaunty)
-  .Case("karmic", UbuntuKarmic)
-  .Case("lucid", UbuntuLucid)
-  .Case("maverick", UbuntuMaverick)
-  .Case("natty", UbuntuNatty)
-  .Case("oneiric", UbuntuOneiric)
-  .Case("precise", UbuntuPrecise)
-  .Case("quantal", UbuntuQuantal)
-  .Case("raring", UbuntuRaring)
-  .Case("saucy", UbuntuSaucy)
-  .Case("trusty", UbuntuTrusty)
-  .Case("utopic", UbuntuUtopic)
-  .Case("vivid", UbuntuVivid)
-  .Case("wily", UbuntuWily)
-  .Case("xenial", UbuntuXenial)
-  .Case("yakkety", UbuntuYakkety)
-  .Default(UnknownDistro);
-if (Version != UnknownDistro)
-  return Version;
-  }
-
-  File = VFS.getBufferForFile("/etc/redhat-release");
-  if (File) {
-StringRef Data = File.get()->getBuffer();
-if (Data.startswith("Fedora release"))
-  return Fedora;
-if (Data.startswith("Red Hat Enterprise Linux") ||
-Data.startswith("CentOS") ||
-Data.startswith("Scientific Linux")) {
-  if (Data.find("release 7") != StringRef::npos)
-return RHEL7;
-  else if (Data.find("release 6") != StringRef::npos)
-return RHEL6;
-  else if (Data.find("release 5") != StringRef::npos)
-return RHEL5;
-}
-return UnknownDistro;
-  }
-
-  File = VFS.getBufferForFile("/etc/debian_version");
-  if (File) {
-StringRef Data = File.get()->getBuffer();
-// Contents: < major.minor > or < codename/sid >
-int MajorVersion;
-if (!Data.split('.').first.getAsInteger(10, MajorVersion)) {
-  switch (MajorVersion) {
-  case 5:
-return DebianLenny;
-  case 6:
-return DebianSqueeze;
-  case 7:
-return DebianWheezy;
-  case 8:
-return DebianJessie;
- 

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

2016-10-25 Thread Pavel Labath via cfe-commits
labath created this revision.
labath added reviewers: benlangmuir, zturner.
labath added a subscriber: cfe-commits.

NFCI


https://reviews.llvm.org/D25948

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

Index: unittests/Basic/VirtualFileSystemTest.cpp
===
--- unittests/Basic/VirtualFileSystemTest.cpp
+++ unittests/Basic/VirtualFileSystemTest.cpp
@@ -115,20 +115,23 @@
   }
 
   void addRegularFile(StringRef Path, sys::fs::perms Perms = sys::fs::all_all) {
-vfs::Status S(Path, UniqueID(FSID, FileID++), sys::TimeValue::now(), 0, 0,
-  1024, sys::fs::file_type::regular_file, Perms);
+vfs::Status S(Path, UniqueID(FSID, FileID++),
+  std::chrono::system_clock::now(), 0, 0, 1024,
+  sys::fs::file_type::regular_file, Perms);
 addEntry(Path, S);
   }
 
   void addDirectory(StringRef Path, sys::fs::perms Perms = sys::fs::all_all) {
-vfs::Status S(Path, UniqueID(FSID, FileID++), sys::TimeValue::now(), 0, 0,
-  0, sys::fs::file_type::directory_file, Perms);
+vfs::Status S(Path, UniqueID(FSID, FileID++),
+  std::chrono::system_clock::now(), 0, 0, 0,
+  sys::fs::file_type::directory_file, Perms);
 addEntry(Path, S);
   }
 
   void addSymlink(StringRef Path) {
-vfs::Status S(Path, UniqueID(FSID, FileID++), sys::TimeValue::now(), 0, 0,
-  0, sys::fs::file_type::symlink_file, sys::fs::all_all);
+vfs::Status S(Path, UniqueID(FSID, FileID++),
+  std::chrono::system_clock::now(), 0, 0, 0,
+  sys::fs::file_type::symlink_file, sys::fs::all_all);
 addEntry(Path, S);
   }
 };
Index: lib/Serialization/ModuleManager.cpp
===
--- lib/Serialization/ModuleManager.cpp
+++ lib/Serialization/ModuleManager.cpp
@@ -102,7 +102,7 @@
   // A cached stat value would be fine as well.
   if (!FileMgr.getNoncachedStatValue(TimestampFilename, Status))
 ModuleEntry->InputFilesValidationTimestamp =
-Status.getLastModificationTime().toEpochTime();
+llvm::sys::toTimeT(Status.getLastModificationTime());
 }
 
 // Load the contents of the module
Index: lib/Frontend/ASTUnit.cpp
===
--- lib/Frontend/ASTUnit.cpp
+++ lib/Frontend/ASTUnit.cpp
@@ -1392,7 +1392,8 @@
 }
 
 OverriddenFiles[Status.getUniqueID()] = PreambleFileHash::createForFile(
-Status.getSize(), Status.getLastModificationTime().toEpochTime());
+Status.getSize(),
+llvm::sys::toTimeT(Status.getLastModificationTime()));
   }
 
   for (const auto  : PreprocessorOpts.RemappedFileBuffers) {
@@ -1433,8 +1434,8 @@
 
 // The file was not remapped; check whether it has changed on disk.
 if (Status.getSize() != uint64_t(F->second.Size) ||
-Status.getLastModificationTime().toEpochTime() !=
-uint64_t(F->second.ModTime))
+llvm::sys::toTimeT(Status.getLastModificationTime()) !=
+F->second.ModTime)
   AnyFileChanged = true;
   }
   
Index: lib/Basic/VirtualFileSystem.cpp
===
--- lib/Basic/VirtualFileSystem.cpp
+++ lib/Basic/VirtualFileSystem.cpp
@@ -47,7 +47,7 @@
   User(Status.getUser()), Group(Status.getGroup()), Size(Status.getSize()),
   Type(Status.type()), Perms(Status.permissions()), IsVFSMapped(false)  {}
 
-Status::Status(StringRef Name, UniqueID UID, sys::TimeValue MTime,
+Status::Status(StringRef Name, UniqueID UID, sys::TimePoint<> MTime,
uint32_t User, uint32_t Group, uint64_t Size, file_type Type,
perms Perms)
 : Name(Name), UID(UID), MTime(MTime), User(User), Group(Group), Size(Size),
@@ -494,8 +494,8 @@
 
 InMemoryFileSystem::InMemoryFileSystem(bool UseNormalizedPaths)
 : Root(new detail::InMemoryDirectory(
-  Status("", getNextVirtualUniqueID(), llvm::sys::TimeValue::MinTime(),
- 0, 0, 0, llvm::sys::fs::file_type::directory_file,
+  Status("", getNextVirtualUniqueID(), llvm::sys::TimePoint<>(), 0, 0,
+ 0, llvm::sys::fs::file_type::directory_file,
  llvm::sys::fs::perms::all_all))),
   UseNormalizedPaths(UseNormalizedPaths) {}
 
@@ -532,7 +532,7 @@
 // End of the path, create a new file.
 // FIXME: expose the status details in the interface.
 Status Stat(P.str(), getNextVirtualUniqueID(),
-llvm::sys::TimeValue(ModificationTime, 0), 0, 0,
+llvm::sys::toTimePoint(ModificationTime), 0, 0,
 

[PATCH] D21845: [Driver][OpenMP] Add specialized action builder for OpenMP offloading actions.

2016-10-25 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 75722.
sfantao marked 7 inline comments as done.
sfantao added a comment.

- Fix typos and add test tht checks phases when OpenMP and CUDA are used 
simultaneously.


https://reviews.llvm.org/D21845

Files:
  lib/Driver/Driver.cpp
  test/Driver/openmp-offload.c

Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -2,6 +2,11 @@
 /// Perform several driver tests for OpenMP offloading
 ///
 
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: powerpc-registered-target
+// REQUIRES: nvptx-registered-target
+
 /// ###
 
 /// Check whether an invalid OpenMP target is specified:
@@ -35,3 +40,136 @@
 // RUN:   %clang -### -ccc-print-phases -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu,powerpc64le-ibm-linux-gnu  %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-DUPLICATES %s
 // CHK-DUPLICATES: warning: The OpenMP offloading target 'powerpc64le-ibm-linux-gnu' is similar to target 'powerpc64le-ibm-linux-gnu' already specified - will be ignored.
+
+/// ###
+
+/// Check the phases graph when using a single target, different from the host.
+/// We should have an offload action joining the host compile and device
+/// preprocessor and another one joining the device linking outputs to the host
+/// action.
+// RUN:   %clang -ccc-print-phases -fopenmp -target powerpc64le-ibm-linux-gnu -fopenmp-targets=x86_64-pc-linux-gnu %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PHASES %s
+// CHK-PHASES: 0: input, "[[INPUT:.+\.c]]", c, (host-openmp)
+// CHK-PHASES: 1: preprocessor, {0}, cpp-output, (host-openmp)
+// CHK-PHASES: 2: compiler, {1}, ir, (host-openmp)
+// CHK-PHASES: 3: backend, {2}, assembler, (host-openmp)
+// CHK-PHASES: 4: assembler, {3}, object, (host-openmp)
+// CHK-PHASES: 5: linker, {4}, image, (host-openmp)
+// CHK-PHASES: 6: input, "[[INPUT]]", c, (device-openmp)
+// CHK-PHASES: 7: preprocessor, {6}, cpp-output, (device-openmp)
+// CHK-PHASES: 8: compiler, {7}, ir, (device-openmp)
+// CHK-PHASES: 9: offload, "host-openmp (powerpc64le-ibm-linux-gnu)" {2}, "device-openmp (x86_64-pc-linux-gnu)" {8}, ir
+// CHK-PHASES: 10: backend, {9}, assembler, (device-openmp)
+// CHK-PHASES: 11: assembler, {10}, object, (device-openmp)
+// CHK-PHASES: 12: linker, {11}, image, (device-openmp)
+// CHK-PHASES: 13: offload, "host-openmp (powerpc64le-ibm-linux-gnu)" {5}, "device-openmp (x86_64-pc-linux-gnu)" {12}, image
+
+/// ###
+
+/// Check the phases when using multiple targets. Here we also add a library to
+/// make sure it is treated as input by the device.
+// RUN:   %clang -ccc-print-phases -lsomelib -fopenmp -target powerpc64-ibm-linux-gnu -fopenmp-targets=x86_64-pc-linux-gnu,powerpc64-ibm-linux-gnu %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PHASES-LIB %s
+// CHK-PHASES-LIB: 0: input, "somelib", object, (host-openmp)
+// CHK-PHASES-LIB: 1: input, "[[INPUT:.+\.c]]", c, (host-openmp)
+// CHK-PHASES-LIB: 2: preprocessor, {1}, cpp-output, (host-openmp)
+// CHK-PHASES-LIB: 3: compiler, {2}, ir, (host-openmp)
+// CHK-PHASES-LIB: 4: backend, {3}, assembler, (host-openmp)
+// CHK-PHASES-LIB: 5: assembler, {4}, object, (host-openmp)
+// CHK-PHASES-LIB: 6: linker, {0, 5}, image, (host-openmp)
+// CHK-PHASES-LIB: 7: input, "somelib", object, (device-openmp)
+// CHK-PHASES-LIB: 8: input, "[[INPUT]]", c, (device-openmp)
+// CHK-PHASES-LIB: 9: preprocessor, {8}, cpp-output, (device-openmp)
+// CHK-PHASES-LIB: 10: compiler, {9}, ir, (device-openmp)
+// CHK-PHASES-LIB: 11: offload, "host-openmp (powerpc64-ibm-linux-gnu)" {3}, "device-openmp (x86_64-pc-linux-gnu)" {10}, ir
+// CHK-PHASES-LIB: 12: backend, {11}, assembler, (device-openmp)
+// CHK-PHASES-LIB: 13: assembler, {12}, object, (device-openmp)
+// CHK-PHASES-LIB: 14: linker, {7, 13}, image, (device-openmp)
+// CHK-PHASES-LIB: 15: input, "somelib", object, (device-openmp)
+// CHK-PHASES-LIB: 16: input, "[[INPUT]]", c, (device-openmp)
+// CHK-PHASES-LIB: 17: preprocessor, {16}, cpp-output, (device-openmp)
+// CHK-PHASES-LIB: 18: compiler, {17}, ir, (device-openmp)
+// CHK-PHASES-LIB: 19: offload, "host-openmp (powerpc64-ibm-linux-gnu)" {3}, "device-openmp (powerpc64-ibm-linux-gnu)" {18}, ir
+// CHK-PHASES-LIB: 20: backend, {19}, assembler, (device-openmp)
+// CHK-PHASES-LIB: 21: assembler, {20}, object, (device-openmp)
+// CHK-PHASES-LIB: 22: linker, {15, 21}, image, (device-openmp)
+// CHK-PHASES-LIB: 23: offload, "host-openmp (powerpc64-ibm-linux-gnu)" {6}, "device-openmp (x86_64-pc-linux-gnu)" {14}, "device-openmp (powerpc64-ibm-linux-gnu)" {22}, image
+
+
+/// ###
+
+/// Check the phases when using 

[PATCH] D21845: [Driver][OpenMP] Add specialized action builder for OpenMP offloading actions.

2016-10-25 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Hi Hal,

Thanks for the review! Fixed the typos in the new diff.




Comment at: lib/Driver/Driver.cpp:1949
+SpecializedBuilders.push_back(new OpenMPActionBuilder(C, Args, Inputs));
+
 //

hfinkel wrote:
> Since we can have both OpenMP offloading and CUDA, please add a test that the 
> phases work correctly for that case (or that we produce an error if that 
> can't currently work correctly).
Added new test for that. The phases generation should work well if CUDA and 
OpenMP offloading are used on the same file. 

However, the bindings for these phases cannot be generated given that the NVPTX 
toolchain support for OpenMP is not implemented yet and the CUDA implementation 
interprets actions differently, e.g. in CUDA linking is the combination of 
binaries of different devices (GPUs) whereas for OpenMP actual linking takes 
place, i.e. symbols are resolved by looking into other compilation units.



https://reviews.llvm.org/D21845



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


[PATCH] D25937: [Sema] -Wunused-variable warning for variables with array types should behave similarly to variables with scalar types

2016-10-25 Thread John McCall via cfe-commits
rjmccall requested changes to this revision.
rjmccall added a comment.
This revision now requires changes to proceed.

There's no reason for this to only consider constant-sized arrays, and you 
should use getBaseElementTypeUnsafe() so you look through nested array types.  
That method is a no-op on non-array types, so you can just call it 
unconditionally here.


Repository:
  rL LLVM

https://reviews.llvm.org/D25937



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


[PATCH] D25866: [Sema] Support implicit scalar to vector conversions

2016-10-25 Thread Bruno Cardoso Lopes via cfe-commits
bruno added a comment.

Hi,

Nice, thanks for working on this!




Comment at: lib/Sema/SemaExpr.cpp:8051
+  if (!LHSVecType) {
+assert(RHSVecType && "RHSVecType is not a vector!");
 if (!tryVectorConvertAndSplat(*this, (IsCompAssign ? nullptr : ),

`tryVectorConvertAndSplat` does more than plain scalar splat; it supports a 
more general type of CK_IntegralCast, see the comment on one of your changes to 
the tests below.

I suggest that instead of reusing this function, you should create another one 
that only handles the cases we actually want to support for non-ext vectors 
(i.e. for GCC compat). 



Comment at: test/Sema/vector-cast.c:57
+  // FIXME: This lacks a diagnostic: should complain that 'double' to vector 
'float2' involves truncation
+  f2 += d;
+  d += f2; // expected-error {{assigning to 'double' from incompatible type 
'float2' (vector of 2 'float' values)}}

This is not right. The fact that we don't have the appropriate diagnostics here 
doesn't mean we should accept this. For instance, this is what we get with GCC:

error: conversion of scalar 'double' to vector 'float2 {aka __vector(2) float}' 
involves truncation



Comment at: test/Sema/vector-scalar-implict-conv.c:2
+// RUN: %clang_cc1 %s -verify -fsyntax-only -Weverything
+
+typedef long long v2i64 __attribute__((vector_size(16)));

Can you rename this to vector-gcc-compat.c? It would also be nice to split 
functionality being tested within their own function, e.g.: arithmetic, logic, 
vector comparisons.


https://reviews.llvm.org/D25866



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


[PATCH] D25869: [Driver] Add unit tests for DetectDistro()

2016-10-25 Thread Michał Górny via cfe-commits
mgorny added inline comments.



Comment at: unittests/Driver/ToolChainsTest.cpp:154
+   
"BUG_REPORT_URL=\"https://bugs.debian.org/\"\n;));
+  ASSERT_EQ(DebianStretch, DetectDistro(DebianStretchSidFileSystem));
+}

bruno wrote:
> Can you add the tests for /etc/SuSE-release here as well? 
Yes, that is a goal. I didn't add all distros yet because I wanted to see if 
I'm doing it right first ;-).


https://reviews.llvm.org/D25869



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


[PATCH] D25817: [Sema] Improve the error diagnostic for dot destructor calls on pointer objects

2016-10-25 Thread Alex Lorenz via cfe-commits
arphaman updated this revision to Diff 75712.
arphaman added a comment.

The updated patch addresses Richard's comment by making sure the fixit isn't 
emitted when the destructor call is invalid.


Repository:
  rL LLVM

https://reviews.llvm.org/D25817

Files:
  lib/Sema/SemaExprCXX.cpp
  test/CXX/special/class.dtor/p10-0x.cpp
  test/FixIt/fixit.cpp
  test/FixIt/no-fixit.cpp
  test/SemaCXX/pseudo-destructors.cpp

Index: test/SemaCXX/pseudo-destructors.cpp
===
--- test/SemaCXX/pseudo-destructors.cpp
+++ test/SemaCXX/pseudo-destructors.cpp
@@ -89,3 +89,26 @@
 void AliasTemplate(int *p) {
   p->~Id();
 }
+
+namespace dotPointerAccess {
+struct Base {
+  virtual ~Base() {}
+};
+
+struct Derived : Base {
+  ~Derived() {}
+};
+
+void test() {
+  Derived d;
+  static_cast().~Base(); // expected-error {{member reference type 'dotPointerAccess::Base *' is a pointer; did you mean to use '->'}}
+  d->~Derived(); // expected-error {{member reference type 'dotPointerAccess::Derived' is not a pointer; did you mean to use '.'}}
+}
+
+typedef Derived *Foo;
+
+void test2(Foo d) {
+  d.~Foo(); // This is ok
+  d.~Derived(); // expected-error {{member reference type 'Foo' (aka 'dotPointerAccess::Derived *') is a pointer; did you mean to use '->'}}
+}
+}
Index: test/FixIt/no-fixit.cpp
===
--- test/FixIt/no-fixit.cpp
+++ test/FixIt/no-fixit.cpp
@@ -11,3 +11,15 @@
 (void)
   }
 } x;
+
+namespace dotPointerDestructor {
+
+struct Bar {
+  ~Bar() = delete;
+};
+
+void bar(Bar *o) {
+  o.~Bar(); // no fixit
+}
+
+}
Index: test/FixIt/fixit.cpp
===
--- test/FixIt/fixit.cpp
+++ test/FixIt/fixit.cpp
@@ -395,3 +395,14 @@
 // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:26-[[@LINE-1]]:26}:"{}"
 int use_czi = czi.a;
 
+namespace dotPointerDestructor {
+
+struct Bar {
+  ~Bar();
+};
+
+void bar(Bar *o) {
+  o.~Bar(); // expected-error {{member reference type 'dotPointerDestructor::Bar *' is a pointer; did you mean to use '->'}}
+}  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:4-[[@LINE-1]]:5}:"->"
+
+}
Index: test/CXX/special/class.dtor/p10-0x.cpp
===
--- test/CXX/special/class.dtor/p10-0x.cpp
+++ test/CXX/special/class.dtor/p10-0x.cpp
@@ -33,7 +33,7 @@
  expected-error{{the type of object expression ('int') does not match the type being destroyed ('decltype(intp())' (aka 'int *')) in pseudo-destructor expression}}
   i.~decltype(intp())(); // expected-error{{the type of object expression ('int') does not match the type being destroyed ('decltype(intp())' (aka 'int *')) in pseudo-destructor expression}}
   pi->~decltype(int())();
-  pi.~decltype(int())(); // expected-error{{the type of object expression ('int *') does not match the type being destroyed ('decltype(int())' (aka 'int')) in pseudo-destructor expression}}
+  pi.~decltype(int())(); // expected-error{{member reference type 'int *' is a pointer; did you mean to use '->'?}}
   pi.~decltype(intp())();
   pi->~decltype(intp())(); // expected-error{{the type of object expression ('int') does not match the type being destroyed ('decltype(intp())' (aka 'int *')) in pseudo-destructor expression}}
 }
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -6375,6 +6375,23 @@
   return false;
 }
 
+/// \brief Check if it's ok to try and recover dot pseudo destructor calls on
+/// pointer objects.
+static bool
+canRecoverDotPseudoDestructorCallsOnPointerObjects(Sema ,
+   QualType DestructedType) {
+  // If this is a record type, check if its destructor is callable.
+  if (auto *RD = DestructedType->getAsCXXRecordDecl()) {
+if (CXXDestructorDecl *D = SemaRef.LookupDestructor(RD))
+  return SemaRef.CanUseDecl(D, /*TreatUnavailableAsInvalid=*/false);
+return false;
+  }
+
+  // Otherwise, check if it's a type for which it's valid to use a pseudo-dtor.
+  return DestructedType->isDependentType() || DestructedType->isScalarType() ||
+ DestructedType->isVectorType();
+}
+
 ExprResult Sema::BuildPseudoDestructorExpr(Expr *Base,
SourceLocation OpLoc,
tok::TokenKind OpKind,
@@ -6409,15 +6426,36 @@
   = DestructedTypeInfo->getTypeLoc().getLocalSourceRange().getBegin();
 if (!DestructedType->isDependentType() && !ObjectType->isDependentType()) {
   if (!Context.hasSameUnqualifiedType(DestructedType, ObjectType)) {
-Diag(DestructedTypeStart, diag::err_pseudo_dtor_type_mismatch)
-  << ObjectType << DestructedType << Base->getSourceRange()
-  << DestructedTypeInfo->getTypeLoc().getLocalSourceRange();
-
-// Recover by setting the 

r285076 - [Driver] Disable OpenSUSE rules for OpenSUSE/SLES 10 and older

2016-10-25 Thread Michal Gorny via cfe-commits
Author: mgorny
Date: Tue Oct 25 10:33:32 2016
New Revision: 285076

URL: http://llvm.org/viewvc/llvm-project?rev=285076=rev
Log:
[Driver] Disable OpenSUSE rules for OpenSUSE/SLES 10 and older

Disable the OpenSUSE rules for OpenSUSE versions older than 11 as they
are incompatible with the old binutils on that distribution.

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

Modified:
cfe/trunk/lib/Driver/ToolChains.cpp

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=285076=285075=285076=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Tue Oct 25 10:33:32 2016
@@ -3968,8 +3968,25 @@ static Distro DetectDistro(vfs::FileSyst
 .Default(UnknownDistro);
   }
 
-  if (VFS.exists("/etc/SuSE-release"))
-return OpenSUSE;
+  File = VFS.getBufferForFile("/etc/SuSE-release");
+  if (File) {
+StringRef Data = File.get()->getBuffer();
+SmallVector Lines;
+Data.split(Lines, "\n");
+for (const StringRef& Line : Lines) {
+  if (!Line.trim().startswith("VERSION"))
+continue;
+  std::pair SplitLine = Line.split('=');
+  int Version;
+  // OpenSUSE/SLES 10 and older are not supported and not compatible
+  // with our rules, so just treat them as UnknownDistro.
+  if (!SplitLine.second.trim().getAsInteger(10, Version) &&
+  Version > 10)
+return OpenSUSE;
+  return UnknownDistro;
+}
+return UnknownDistro;
+  }
 
   if (VFS.exists("/etc/exherbo-release"))
 return Exherbo;


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


[PATCH] D24954: [Driver] Disable OpenSUSE rules for OpenSUSE/SLES 10 and older

2016-10-25 Thread Michał Górny via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285076: [Driver] Disable OpenSUSE rules for OpenSUSE/SLES 10 
and older (authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D24954?vs=75704=75713#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24954

Files:
  cfe/trunk/lib/Driver/ToolChains.cpp


Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -3968,8 +3968,25 @@
 .Default(UnknownDistro);
   }
 
-  if (VFS.exists("/etc/SuSE-release"))
-return OpenSUSE;
+  File = VFS.getBufferForFile("/etc/SuSE-release");
+  if (File) {
+StringRef Data = File.get()->getBuffer();
+SmallVector Lines;
+Data.split(Lines, "\n");
+for (const StringRef& Line : Lines) {
+  if (!Line.trim().startswith("VERSION"))
+continue;
+  std::pair SplitLine = Line.split('=');
+  int Version;
+  // OpenSUSE/SLES 10 and older are not supported and not compatible
+  // with our rules, so just treat them as UnknownDistro.
+  if (!SplitLine.second.trim().getAsInteger(10, Version) &&
+  Version > 10)
+return OpenSUSE;
+  return UnknownDistro;
+}
+return UnknownDistro;
+  }
 
   if (VFS.exists("/etc/exherbo-release"))
 return Exherbo;


Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -3968,8 +3968,25 @@
 .Default(UnknownDistro);
   }
 
-  if (VFS.exists("/etc/SuSE-release"))
-return OpenSUSE;
+  File = VFS.getBufferForFile("/etc/SuSE-release");
+  if (File) {
+StringRef Data = File.get()->getBuffer();
+SmallVector Lines;
+Data.split(Lines, "\n");
+for (const StringRef& Line : Lines) {
+  if (!Line.trim().startswith("VERSION"))
+continue;
+  std::pair SplitLine = Line.split('=');
+  int Version;
+  // OpenSUSE/SLES 10 and older are not supported and not compatible
+  // with our rules, so just treat them as UnknownDistro.
+  if (!SplitLine.second.trim().getAsInteger(10, Version) &&
+  Version > 10)
+return OpenSUSE;
+  return UnknownDistro;
+}
+return UnknownDistro;
+  }
 
   if (VFS.exists("/etc/exherbo-release"))
 return Exherbo;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r285074 - [Driver] Support obtaining active toolchain from gcc-config on Gentoo

2016-10-25 Thread Michal Gorny via cfe-commits
Author: mgorny
Date: Tue Oct 25 10:07:41 2016
New Revision: 285074

URL: http://llvm.org/viewvc/llvm-project?rev=285074=rev
Log:
[Driver] Support obtaining active toolchain from gcc-config on Gentoo

Support using gcc-config to determine the correct GCC toolchain location
on Gentoo. In order to do that, attempt to read gcc-config configuration
form [[sysroot]]/etc/env.d/gcc, if no custom toolchain location is
provided.

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

Added:
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/config-x86_64-pc-linux-gnu

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/x86_64-pc-linux-gnu-4.9.3

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/gentoo-release
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/include/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/include/.keep
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/crtbegin.o

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3/.keep

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/crtbegin.o

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/include/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/include/g++-v5.4.0/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/include/g++-v5.4.0/.keep

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/x86_64-pc-linux-gnu/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/x86_64-pc-linux-gnu/lib/

cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/x86_64-pc-linux-gnu/lib/.keep
Modified:
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/test/Driver/linux-header-search.cpp

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=285074=285073=285074=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Tue Oct 25 10:07:41 2016
@@ -1438,6 +1438,43 @@ void Generic_GCC::GCCInstallationDetecto
 }
   }
 
+  // Try to respect gcc-config on Gentoo. However, do that only
+  // if --gcc-toolchain is not provided or equal to the Gentoo install
+  // in /usr. This avoids accidentally enforcing the system GCC version
+  // when using a custom toolchain.
+  if (GCCToolchainDir == "" || GCCToolchainDir == D.SysRoot + "/usr") {
+for (StringRef CandidateTriple : CandidateTripleAliases) {
+  llvm::ErrorOr File =
+  D.getVFS().getBufferForFile(D.SysRoot + "/etc/env.d/gcc/config-" +
+  CandidateTriple.str());
+  if (File) {
+SmallVector Lines;
+File.get()->getBuffer().split(Lines, "\n");
+for (StringRef Line : Lines) {
+  // CURRENT=triple-version
+  if (Line.consume_front("CURRENT=")) {
+const std::pair ActiveVersion =
+  Line.rsplit('-');
+// Note: Strictly speaking, we should be reading
+// /etc/env.d/gcc/${CURRENT} now. However, the file doesn't
+// contain anything new or especially useful to us.
+const std::string GentooPath = D.SysRoot + "/usr/lib/gcc/" +
+   ActiveVersion.first.str() + "/" +
+   ActiveVersion.second.str();
+   

Re: [PATCH] D25932: Unconditionally pass `-lto_library` to the linker on Darwin

2016-10-25 Thread Duncan P. N. Exon Smith via cfe-commits
> On 2016-Oct-24, at 21:43, Mehdi AMINI  wrote:
> 
> mehdi_amini created this revision.
> mehdi_amini added a reviewer: dexonsmith.
> mehdi_amini added a subscriber: cfe-commits.
> 
> We're only doing it with -flto currently, however it never "hurt"
> to pass it, and users that are linking without -flto can get in
> trouble if one of the dependency (a static library for instance)
> contains bitcode.

Seems reasonable.  LGTM.

> 
> 
> https://reviews.llvm.org/D25932
> 
> Files:
>  clang/lib/Driver/Tools.cpp
>  clang/test/Driver/darwin-ld-lto.c
> 
> 
> Index: clang/test/Driver/darwin-ld-lto.c
> ===
> --- clang/test/Driver/darwin-ld-lto.c
> +++ clang/test/Driver/darwin-ld-lto.c
> @@ -6,20 +6,20 @@
> // RUN: mkdir -p %T/lib
> // RUN: touch %T/lib/libLTO.dylib
> // RUN: %clang -target x86_64-apple-darwin10 -### %s \
> -// RUN:   -ccc-install-dir %T/bin -mlinker-version=133 -flto 2> %t.log
> +// RUN:   -ccc-install-dir %T/bin -mlinker-version=133 2> %t.log
> // RUN: FileCheck -check-prefix=LINK_LTOLIB_PATH %s -input-file %t.log
> //
> // LINK_LTOLIB_PATH: {{ld(.exe)?"}}
> // LINK_LTOLIB_PATH: "-lto_library"
> 
> // RUN: %clang -target x86_64-apple-darwin10 -### %s \
> -// RUN:   -ccc-install-dir %S/dummytestdir -mlinker-version=133 -flto 2> 
> %t.log
> +// RUN:   -ccc-install-dir %S/dummytestdir -mlinker-version=133 2> %t.log
> // RUN: FileCheck -check-prefix=LINK_LTOLIB_PATH_WRN %s -input-file %t.log
> //
> // LINK_LTOLIB_PATH_WRN: warning: libLTO.dylib relative to clang installed 
> dir not found; using 'ld' default search path instead
> 
> // RUN: %clang -target x86_64-apple-darwin10 -### %s \
> -// RUN:   -ccc-install-dir %S/dummytestdir -mlinker-version=133 -Wno-liblto 
> -flto 2> %t.log
> +// RUN:   -ccc-install-dir %S/dummytestdir -mlinker-version=133 -Wno-liblto 
> 2> %t.log
> // RUN: FileCheck -check-prefix=LINK_LTOLIB_PATH_NOWRN %s -input-file %t.log
> //
> // LINK_LTOLIB_PATH_NOWRN-NOT: warning: libLTO.dylib relative to clang 
> installed dir not found; using 'ld' default search path instead
> Index: clang/lib/Driver/Tools.cpp
> ===
> --- clang/lib/Driver/Tools.cpp
> +++ clang/lib/Driver/Tools.cpp
> @@ -7944,22 +7944,22 @@
>   CmdArgs.push_back("-object_path_lto");
>   CmdArgs.push_back(TmpPath);
> }
> +  }
> 
> -// Use -lto_library option to specify the libLTO.dylib path. Try to find
> -// it in clang installed libraries. If not found, the option is not used
> -// and 'ld' will use its default mechanism to search for libLTO.dylib.
> -if (Version[0] >= 133) {
> -  // Search for libLTO in /../lib/libLTO.dylib
> -  StringRef P = llvm::sys::path::parent_path(D.getInstalledDir());
> -  SmallString<128> LibLTOPath(P);
> -  llvm::sys::path::append(LibLTOPath, "lib");
> -  llvm::sys::path::append(LibLTOPath, "libLTO.dylib");
> -  if (llvm::sys::fs::exists(LibLTOPath)) {
> -CmdArgs.push_back("-lto_library");
> -CmdArgs.push_back(C.getArgs().MakeArgString(LibLTOPath));
> -  } else {
> -D.Diag(diag::warn_drv_lto_libpath);
> -  }
> +  // Use -lto_library option to specify the libLTO.dylib path. Try to find
> +  // it in clang installed libraries. If not found, the option is not used
> +  // and 'ld' will use its default mechanism to search for libLTO.dylib.
> +  if (Version[0] >= 133) {
> +// Search for libLTO in /../lib/libLTO.dylib
> +StringRef P = llvm::sys::path::parent_path(D.getInstalledDir());
> +SmallString<128> LibLTOPath(P);
> +llvm::sys::path::append(LibLTOPath, "lib");
> +llvm::sys::path::append(LibLTOPath, "libLTO.dylib");
> +if (llvm::sys::fs::exists(LibLTOPath)) {
> +  CmdArgs.push_back("-lto_library");
> +  CmdArgs.push_back(C.getArgs().MakeArgString(LibLTOPath));
> +} else {
> +  D.Diag(diag::warn_drv_lto_libpath);
> }
>   }
> 
> 
> 
> 

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


[PATCH] D25869: [Driver] Add unit tests for DetectDistro()

2016-10-25 Thread Bruno Cardoso Lopes via cfe-commits
bruno added a comment.

This is great!




Comment at: unittests/Driver/ToolChainsTest.cpp:154
+   
"BUG_REPORT_URL=\"https://bugs.debian.org/\"\n;));
+  ASSERT_EQ(DebianStretch, DetectDistro(DebianStretchSidFileSystem));
+}

Can you add the tests for /etc/SuSE-release here as well? 


https://reviews.llvm.org/D25869



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


[PATCH] D24954: [Driver] Disable OpenSUSE rules for OpenSUSE/SLES 10 and older

2016-10-25 Thread Bruno Cardoso Lopes via cfe-commits
bruno accepted this revision.
bruno added a comment.
This revision is now accepted and ready to land.

LGTM!


https://reviews.llvm.org/D24954



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


[PATCH] D25661: [Driver] Support obtaining active toolchain from gcc-config on Gentoo

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

ship it.


https://reviews.llvm.org/D25661



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


[PATCH] D25866: [Sema] Support implicit scalar to vector conversions

2016-10-25 Thread Simon Dardis via cfe-commits
sdardis updated this revision to Diff 75708.
sdardis marked an inline comment as done.
sdardis added a comment.

Extra testing for cases where the operand on the left of an operation is a 
vector.
Removed two spurious checks for vector types.


https://reviews.llvm.org/D25866

Files:
  lib/Sema/SemaExpr.cpp
  test/Sema/vector-cast.c
  test/Sema/vector-scalar-implict-conv.c
  test/Sema/zvector.c

Index: test/Sema/zvector.c
===
--- test/Sema/zvector.c
+++ test/Sema/zvector.c
@@ -326,14 +326,14 @@
   bc = bc + sc2; // expected-error {{incompatible type}}
   bc = sc + bc2; // expected-error {{incompatible type}}
 
-  sc = sc + sc_scalar; // expected-error {{cannot convert}}
-  sc = sc + uc_scalar; // expected-error {{cannot convert}}
-  sc = sc_scalar + sc; // expected-error {{cannot convert}}
-  sc = uc_scalar + sc; // expected-error {{cannot convert}}
-  uc = uc + sc_scalar; // expected-error {{cannot convert}}
-  uc = uc + uc_scalar; // expected-error {{cannot convert}}
-  uc = sc_scalar + uc; // expected-error {{cannot convert}}
-  uc = uc_scalar + uc; // expected-error {{cannot convert}}
+  sc = sc + sc_scalar;
+  sc = sc + uc_scalar; // expected-error {{implicit conversion changes signedness: 'unsigned char' to '__vector signed char' (vector of 16 'signed char' values)}}
+  sc = sc_scalar + sc;
+  sc = uc_scalar + sc; // expected-error {{implicit conversion changes signedness: 'unsigned char' to '__vector signed char' (vector of 16 'signed char' values)}}
+  uc = uc + sc_scalar; // expected-error {{implicit conversion changes signedness: 'signed char' to '__vector unsigned char' (vector of 16 'unsigned char' values)}}
+  uc = uc + uc_scalar;
+  uc = sc_scalar + uc; // expected-error {{implicit conversion changes signedness: 'signed char' to '__vector unsigned char' (vector of 16 'unsigned char' values)}}
+  uc = uc_scalar + uc;
 
   ss = ss + ss2;
   us = us + us2;
@@ -368,10 +368,10 @@
   sc += sl2; // expected-error {{cannot convert}}
   sc += fd2; // expected-error {{cannot convert}}
 
-  sc += sc_scalar; // expected-error {{cannot convert}}
-  sc += uc_scalar; // expected-error {{cannot convert}}
-  uc += sc_scalar; // expected-error {{cannot convert}}
-  uc += uc_scalar; // expected-error {{cannot convert}}
+  sc += sc_scalar;
+  sc += uc_scalar; // expected-error {{implicit conversion changes signedness: 'unsigned char' to '__vector signed char' (vector of 16 'signed char' values)}}
+  uc += sc_scalar; // expected-error {{implicit conversion changes signedness: 'signed char' to '__vector unsigned char' (vector of 16 'unsigned char' values)}}
+  uc += uc_scalar;
 
   ss += ss2;
   us += us2;
Index: test/Sema/vector-scalar-implict-conv.c
===
--- /dev/null
+++ test/Sema/vector-scalar-implict-conv.c
@@ -0,0 +1,97 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -Weverything
+
+typedef long long v2i64 __attribute__((vector_size(16)));
+typedef long long v2i64 __attribute__((vector_size(16)));
+
+typedef int v2i32 __attribute__((vector_size(8)));
+typedef int v2i32 __attribute__((vector_size(8)));
+
+typedef unsigned long long v2u64 __attribute__((vector_size(16)));
+typedef unsigned long long v2u64 __attribute__((vector_size(16)));
+
+typedef float v4f32 __attribute__((vector_size(16)));
+typedef double v4f64 __attribute__((vector_size(32)));
+
+void test (void);
+
+void test (void){
+
+  v2i64 v2i64_a = (v2i64) {0, 1};
+  v2i64 v2i64_r;
+
+  v2i32 v2i32_a = (v2i32) {0 , 1};
+
+  v2u64 v2u64_a = (v2u64) {0, 1};
+
+  v4f32 v4f32_a = (v4f32) {0.1f, 0.2f, 0.3f, 0.4f};
+
+  v4f64 v4f64_r = v4f32_a; // expected-error {{initializing 'v4f64' (vector of 4 'double' values) with an expression of incompatible type 'v4f32' (vector of 4 'float' values)}}
+
+  v4f64_r = v4f32_a;
+
+  // FIXME: this should warn about truncation.
+  v4f32_a = v4f64_r;
+
+  v2i64_r = v2i32_a; // expected-error {{assigning to 'v2i64' (vector of 2 'long long' values) from incompatible type 'v2i32' (vector of 2 'int' values)}}
+
+  v2i64_r = v2u64_a; // expected-warning {{incompatible vector types assigning to 'v2i64' (vector of 2 'long long' values) from 'v2u64' (vector of 2 'unsigned long long' values)}}
+
+  v2i64_r = v2i64_a + 1;
+  v2i64_r = v2i64_a - 1;
+  v2i64_r = v2i64_a * 1;
+  v2i64_r = v2i64_a / 1;
+  v2i64_r = v2i64_a % 1;
+
+  v2i64_r = 1 + v2i64_a;
+  v2i64_r = 1 - v2i64_a;
+  v2i64_r = 1 * v2i64_a;
+  v2i64_r = 1 / v2i64_a;
+  v2i64_r = 1 % v2i64_a;
+
+
+  v2i64_a += 1;
+  v2i64_a -= 1;
+  v2i64_a *= 1;
+  v2i64_a /= 1;
+  v2i64_a %= 1;
+
+  v2i64_r = v2i64_a == 1; // expected-warning {{incompatible vector types assigning to 'v2i64' (vector of 2 'long long' values) from 'long __attribute__((ext_vector_type(2)))' (vector of 2 'long' values)}}
+  v2i64_r = v2i64_a != 1; // expected-warning {{incompatible vector types assigning to 'v2i64' (vector of 2 'long long' values) from 'long 

[PATCH] D25661: [Driver] Support obtaining active toolchain from gcc-config on Gentoo

2016-10-25 Thread Michał Górny via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285074: [Driver] Support obtaining active toolchain from 
gcc-config on Gentoo (authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D25661?vs=75707=75710#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25661

Files:
  cfe/trunk/lib/Driver/ToolChains.cpp
  
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/config-x86_64-pc-linux-gnu
  
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/x86_64-pc-linux-gnu-4.9.3
  
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/gentoo-release
  
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/include/.keep
  
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/crtbegin.o
  
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3/.keep
  
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/crtbegin.o
  
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/include/g++-v5.4.0/.keep
  
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/x86_64-pc-linux-gnu/lib/.keep
  cfe/trunk/test/Driver/linux-header-search.cpp


Index: cfe/trunk/test/Driver/linux-header-search.cpp
===
--- cfe/trunk/test/Driver/linux-header-search.cpp
+++ cfe/trunk/test/Driver/linux-header-search.cpp
@@ -301,6 +301,15 @@
 // CHECK-GENTOO-4-9-3: "-internal-externc-isystem" "[[SYSROOT]]/include"
 // CHECK-GENTOO-4-9-3: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
 //
+// Test support for Gentoo's gcc-config -- clang should prefer the older
+// (4.9.3) version over the newer (5.4.0) due to preference specified
+// in /etc/env.d/gcc/x86_64-pc-linux-gnu.
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target x86_64-unknown-linux-gnu -stdlib=libstdc++ \
+// RUN: --sysroot=%S/Inputs/gentoo_linux_gcc_multi_version_tree \
+// RUN: --gcc-toolchain="" \
+// RUN:   | FileCheck --check-prefix=CHECK-GENTOO-4-9-3 %s
+//
 // Check header search on Debian 6 / MIPS64
 // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
 // RUN: -target mips64-unknown-linux-gnuabi64 -stdlib=libstdc++ \
Index: 
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/x86_64-pc-linux-gnu-4.9.3
===
--- 
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/x86_64-pc-linux-gnu-4.9.3
+++ 
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/x86_64-pc-linux-gnu-4.9.3
@@ -0,0 +1,10 @@
+PATH="/usr/x86_64-pc-linux-gnu/gcc-bin/4.9.3"
+ROOTPATH="/usr/x86_64-pc-linux-gnu/gcc-bin/4.9.3"
+GCC_PATH="/usr/x86_64-pc-linux-gnu/gcc-bin/4.9.3"
+LDPATH="/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3:/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/32"
+MANPATH="/usr/share/gcc-data/x86_64-pc-linux-gnu/4.9.3/man"
+INFOPATH="/usr/share/gcc-data/x86_64-pc-linux-gnu/4.9.3/info"
+STDCXX_INCDIR="g++-v4"
+CTARGET="x86_64-pc-linux-gnu"
+GCC_SPECS=""
+MULTIOSDIRS="../lib64:../lib32"
Index: 
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/config-x86_64-pc-linux-gnu
===
--- 
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/config-x86_64-pc-linux-gnu
+++ 
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/config-x86_64-pc-linux-gnu
@@ -0,0 +1 @@
+CURRENT=x86_64-pc-linux-gnu-4.9.3
Index: 
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/gentoo-release
===
--- 
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/gentoo-release
+++ 
cfe/trunk/test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/gentoo-release
@@ -0,0 +1 @@
+Gentoo Base System release 2.3
Index: cfe/trunk/lib/Driver/ToolChains.cpp
===
--- cfe/trunk/lib/Driver/ToolChains.cpp
+++ cfe/trunk/lib/Driver/ToolChains.cpp
@@ -1438,6 +1438,43 @@
 }
   }
 
+  // Try to respect gcc-config on Gentoo. However, do that only
+  // if --gcc-toolchain is not provided or equal to the Gentoo install
+  // in /usr. This avoids accidentally enforcing the system GCC version
+  // when using a custom toolchain.
+  if (GCCToolchainDir == "" || GCCToolchainDir == D.SysRoot + "/usr") {
+for (StringRef CandidateTriple : CandidateTripleAliases) {
+  llvm::ErrorOr File =
+  D.getVFS().getBufferForFile(D.SysRoot + "/etc/env.d/gcc/config-" +
+  

[PATCH] D25661: [Driver] Support obtaining active toolchain from gcc-config on Gentoo

2016-10-25 Thread Michał Górny via cfe-commits
mgorny updated this revision to Diff 75707.
mgorny marked 3 inline comments as done.
mgorny added a comment.

Thanks for the review. Implemented all three suggestions.


https://reviews.llvm.org/D25661

Files:
  lib/Driver/ToolChains.cpp
  
test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/config-x86_64-pc-linux-gnu
  
test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/x86_64-pc-linux-gnu-4.9.3
  test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/gentoo-release
  test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/include/.keep
  
test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/crtbegin.o
  
test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4.9.3/.keep
  
test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/crtbegin.o
  
test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/include/g++-v5.4.0/.keep
  
test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/usr/x86_64-pc-linux-gnu/lib/.keep
  test/Driver/linux-header-search.cpp


Index: test/Driver/linux-header-search.cpp
===
--- test/Driver/linux-header-search.cpp
+++ test/Driver/linux-header-search.cpp
@@ -301,6 +301,15 @@
 // CHECK-GENTOO-4-9-3: "-internal-externc-isystem" "[[SYSROOT]]/include"
 // CHECK-GENTOO-4-9-3: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
 //
+// Test support for Gentoo's gcc-config -- clang should prefer the older
+// (4.9.3) version over the newer (5.4.0) due to preference specified
+// in /etc/env.d/gcc/x86_64-pc-linux-gnu.
+// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
+// RUN: -target x86_64-unknown-linux-gnu -stdlib=libstdc++ \
+// RUN: --sysroot=%S/Inputs/gentoo_linux_gcc_multi_version_tree \
+// RUN: --gcc-toolchain="" \
+// RUN:   | FileCheck --check-prefix=CHECK-GENTOO-4-9-3 %s
+//
 // Check header search on Debian 6 / MIPS64
 // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
 // RUN: -target mips64-unknown-linux-gnuabi64 -stdlib=libstdc++ \
Index: test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/gentoo-release
===
--- /dev/null
+++ test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/gentoo-release
@@ -0,0 +1 @@
+Gentoo Base System release 2.3
Index: 
test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/x86_64-pc-linux-gnu-4.9.3
===
--- /dev/null
+++ 
test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/x86_64-pc-linux-gnu-4.9.3
@@ -0,0 +1,10 @@
+PATH="/usr/x86_64-pc-linux-gnu/gcc-bin/4.9.3"
+ROOTPATH="/usr/x86_64-pc-linux-gnu/gcc-bin/4.9.3"
+GCC_PATH="/usr/x86_64-pc-linux-gnu/gcc-bin/4.9.3"
+LDPATH="/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3:/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/32"
+MANPATH="/usr/share/gcc-data/x86_64-pc-linux-gnu/4.9.3/man"
+INFOPATH="/usr/share/gcc-data/x86_64-pc-linux-gnu/4.9.3/info"
+STDCXX_INCDIR="g++-v4"
+CTARGET="x86_64-pc-linux-gnu"
+GCC_SPECS=""
+MULTIOSDIRS="../lib64:../lib32"
Index: 
test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/config-x86_64-pc-linux-gnu
===
--- /dev/null
+++ 
test/Driver/Inputs/gentoo_linux_gcc_multi_version_tree/etc/env.d/gcc/config-x86_64-pc-linux-gnu
@@ -0,0 +1 @@
+CURRENT=x86_64-pc-linux-gnu-4.9.3
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -1430,6 +1430,43 @@
 }
   }
 
+  // Try to respect gcc-config on Gentoo. However, do that only
+  // if --gcc-toolchain is not provided or equal to the Gentoo install
+  // in /usr. This avoids accidentally enforcing the system GCC version
+  // when using a custom toolchain.
+  if (GCCToolchainDir == "" || GCCToolchainDir == D.SysRoot + "/usr") {
+for (StringRef CandidateTriple : CandidateTripleAliases) {
+  llvm::ErrorOr File =
+  D.getVFS().getBufferForFile(D.SysRoot + "/etc/env.d/gcc/config-" +
+  CandidateTriple.str());
+  if (File) {
+SmallVector Lines;
+File.get()->getBuffer().split(Lines, "\n");
+for (StringRef Line : Lines) {
+  // CURRENT=triple-version
+  if (Line.consume_front("CURRENT=")) {
+const std::pair ActiveVersion =
+  Line.rsplit('-');
+// Note: Strictly speaking, we should be reading
+// /etc/env.d/gcc/${CURRENT} now. However, the file doesn't
+// contain anything new or especially useful to us.
+const std::string GentooPath = D.SysRoot + "/usr/lib/gcc/" +
+

[PATCH] D21843: [Driver][OpenMP] Create tool chains for OpenMP offloading kind.

2016-10-25 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Hi Hal,

Thanks for the review!




Comment at: include/clang/Basic/DiagnosticDriverKinds.td:163
+def err_drv_expecting_fopenmp_with_fopenmp_targets : Error<
+  "The option -fopenmp-targets must be used in conjunction with a -fopenmp 
option compatible with offloading.">;
+def warn_drv_omp_offload_target_duplicate : Warning<

hfinkel wrote:
> This message does not tell the user how they might make their -fopenmp option 
> "compatible with offloading." Please make sure the message does, or is has an 
> associated hint message which does.
> 
Ok, the message is now: `The option -fopenmp-targets must be used in 
conjunction with a -fopenmp option compatible with offloading, please use 
-fopenmp=libomp or -fopenmp=libiomp5.`


https://reviews.llvm.org/D21843



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


r285073 - CodeGen: mark protocols as common data

2016-10-25 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Tue Oct 25 09:50:44 2016
New Revision: 285073

URL: http://llvm.org/viewvc/llvm-project?rev=285073=rev
Log:
CodeGen: mark protocols as common data

This allows for the coalescing of the protocol declarations.  When the protocols
are declared in headers, multiple definitions of the protocol would be emitted.
Marking them as common data indicates that any one can be selected.

Added:
cfe/trunk/test/CodeGenObjC/protocol-comdat.m
Modified:
cfe/trunk/lib/CodeGen/CGObjCMac.cpp

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=285073=285072=285073=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Tue Oct 25 09:50:44 2016
@@ -6562,15 +6562,20 @@ llvm::Constant *CGObjCNonFragileABIMac::
   const ObjCProtocolDecl *PD) {
   llvm::GlobalVariable * = Protocols[PD->getIdentifier()];
 
-  if (!Entry)
+  if (!Entry) {
 // We use the initializer as a marker of whether this is a forward
 // reference or not. At module finalization we add the empty
 // contents for protocols which were referenced but never defined.
-Entry =
-new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.ProtocolnfABITy,
- false, llvm::GlobalValue::ExternalLinkage,
- nullptr,
- "\01l_OBJC_PROTOCOL_$_" + 
PD->getObjCRuntimeNameAsString());
+llvm::SmallString<64> Protocol;
+llvm::raw_svector_ostream(Protocol) << "\01l_OBJC_PROTOCOL_$_"
+<< PD->getObjCRuntimeNameAsString();
+
+Entry = new llvm::GlobalVariable(CGM.getModule(), 
ObjCTypes.ProtocolnfABITy,
+ false, llvm::GlobalValue::ExternalLinkage,
+ nullptr, Protocol);
+if (!CGM.getTriple().isOSBinFormatMachO())
+  Entry->setComdat(CGM.getModule().getOrInsertComdat(Protocol));
+  }
 
   return Entry;
 }
@@ -6688,10 +6693,16 @@ llvm::Constant *CGObjCNonFragileABIMac::
 Entry->setLinkage(llvm::GlobalValue::WeakAnyLinkage);
 Entry->setInitializer(Init);
   } else {
-Entry =
-  new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.ProtocolnfABITy,
-   false, llvm::GlobalValue::WeakAnyLinkage, Init,
-   "\01l_OBJC_PROTOCOL_$_" + 
PD->getObjCRuntimeNameAsString());
+llvm::SmallString<64> Protocol;
+llvm::raw_svector_ostream(Protocol) << "\01l_OBJC_PROTOCOL_$_"
+<< PD->getObjCRuntimeNameAsString();
+
+Entry = new llvm::GlobalVariable(CGM.getModule(), 
ObjCTypes.ProtocolnfABITy,
+ false, llvm::GlobalValue::WeakAnyLinkage,
+ Init, Protocol);
+if (!CGM.getTriple().isOSBinFormatMachO())
+  Entry->setComdat(CGM.getModule().getOrInsertComdat(Protocol));
+
 Entry->setAlignment(
   CGM.getDataLayout().getABITypeAlignment(ObjCTypes.ProtocolnfABITy));
 
@@ -6702,13 +6713,20 @@ llvm::Constant *CGObjCNonFragileABIMac::
 
   // Use this protocol meta-data to build protocol list table in section
   // __DATA, __objc_protolist
+  llvm::SmallString<64> ProtocolRef;
+  llvm::raw_svector_ostream(ProtocolRef) << "\01l_OBJC_LABEL_PROTOCOL_$_"
+ << PD->getObjCRuntimeNameAsString();
+
   llvm::GlobalVariable *PTGV =
 new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.ProtocolnfABIPtrTy,
  false, llvm::GlobalValue::WeakAnyLinkage, Entry,
- "\01l_OBJC_LABEL_PROTOCOL_$_" + 
PD->getObjCRuntimeNameAsString());
+ ProtocolRef);
+  if (!CGM.getTriple().isOSBinFormatMachO())
+PTGV->setComdat(CGM.getModule().getOrInsertComdat(ProtocolRef));
   PTGV->setAlignment(
 CGM.getDataLayout().getABITypeAlignment(ObjCTypes.ProtocolnfABIPtrTy));
-  PTGV->setSection("__DATA, __objc_protolist, coalesced, no_dead_strip");
+  if (CGM.getTriple().isOSBinFormatMachO())
+PTGV->setSection("__DATA, __objc_protolist, coalesced, no_dead_strip");
   PTGV->setVisibility(llvm::GlobalValue::HiddenVisibility);
   CGM.addCompilerUsedGlobal(PTGV);
   return Entry;

Added: cfe/trunk/test/CodeGenObjC/protocol-comdat.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/protocol-comdat.m?rev=285073=auto
==
--- cfe/trunk/test/CodeGenObjC/protocol-comdat.m (added)
+++ cfe/trunk/test/CodeGenObjC/protocol-comdat.m Tue Oct 25 09:50:44 2016
@@ -0,0 +1,20 @@
+// RUN: %clang -cc1 -triple thumbv7--windows-itanium -fobjc-runtime=ios 
-emit-llvm -o - %s -Wno-objc-root-class | FileCheck %s
+
+@protocol P
+- (void) method;
+@end
+
+@interface I
+@end
+
+@implementation I
+- 

[PATCH] D25869: [Driver] Add unit tests for DetectDistro()

2016-10-25 Thread Michał Górny via cfe-commits
mgorny planned changes to this revision.
mgorny added inline comments.



Comment at: unittests/Driver/ToolChainsTest.cpp:15
+// FIXME: I presume this is not the correct way of doing this
+#include "../lib/Driver/ToolChains.h"
+#include "clang/Basic/VirtualFileSystem.h"

bkramer wrote:
> Yeah. It's better to hoist the enum + the decl for detectDistro into a public 
> header under include/clang/Driver and include it from here.
Ok. Then I'll probably refactor the whole thing into a nicer API anyway ;-).


https://reviews.llvm.org/D25869



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


[PATCH] D21843: [Driver][OpenMP] Create tool chains for OpenMP offloading kind.

2016-10-25 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 75705.
sfantao marked an inline comment as done.
sfantao added a comment.

- Address Hal Finkel comments - make diagnostic message more informative.


https://reviews.llvm.org/D21843

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Driver/Action.h
  include/clang/Driver/Driver.h
  lib/Driver/Action.cpp
  lib/Driver/Driver.cpp
  lib/Driver/Tools.cpp
  test/Driver/openmp-offload.c

Index: test/Driver/openmp-offload.c
===
--- /dev/null
+++ test/Driver/openmp-offload.c
@@ -0,0 +1,37 @@
+///
+/// Perform several driver tests for OpenMP offloading
+///
+
+/// ###
+
+/// Check whether an invalid OpenMP target is specified:
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=aaa-bbb-ccc-ddd %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-INVALID-TARGET %s
+// RUN:   %clang -### -fopenmp -fopenmp-targets=aaa-bbb-ccc-ddd %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-INVALID-TARGET %s
+// CHK-INVALID-TARGET: error: OpenMP target is invalid: 'aaa-bbb-ccc-ddd'
+
+/// ###
+
+/// Check warning for empty -fopenmp-targets
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=  %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-EMPTY-OMPTARGETS %s
+// RUN:   %clang -### -fopenmp -fopenmp-targets=  %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-EMPTY-OMPTARGETS %s
+// CHK-EMPTY-OMPTARGETS: warning: joined argument expects additional value: '-fopenmp-targets='
+
+/// ###
+
+/// Check error for no -fopenmp option
+// RUN:   %clang -### -fopenmp-targets=powerpc64le-ibm-linux-gnu  %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-NO-FOPENMP %s
+// RUN:   %clang -### -fopenmp=libgomp -fopenmp-targets=powerpc64le-ibm-linux-gnu  %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-NO-FOPENMP %s
+// CHK-NO-FOPENMP: error: The option -fopenmp-targets must be used in conjunction with a -fopenmp option compatible with offloading, please use -fopenmp=libomp or -fopenmp=libiomp5.
+
+/// ###
+
+/// Check warning for duplicate offloading targets.
+// RUN:   %clang -### -ccc-print-phases -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu,powerpc64le-ibm-linux-gnu  %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-DUPLICATES %s
+// CHK-DUPLICATES: warning: The OpenMP offloading target 'powerpc64le-ibm-linux-gnu' is similar to target 'powerpc64le-ibm-linux-gnu' already specified - will be ignored.
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3009,72 +3009,23 @@
   CmdArgs.push_back(TC.getCompilerRTArgString(Args, "builtins"));
 }
 
-namespace {
-enum OpenMPRuntimeKind {
-  /// An unknown OpenMP runtime. We can't generate effective OpenMP code
-  /// without knowing what runtime to target.
-  OMPRT_Unknown,
-
-  /// The LLVM OpenMP runtime. When completed and integrated, this will become
-  /// the default for Clang.
-  OMPRT_OMP,
-
-  /// The GNU OpenMP runtime. Clang doesn't support generating OpenMP code for
-  /// this runtime but can swallow the pragmas, and find and link against the
-  /// runtime library itself.
-  OMPRT_GOMP,
-
-  /// The legacy name for the LLVM OpenMP runtime from when it was the Intel
-  /// OpenMP runtime. We support this mode for users with existing dependencies
-  /// on this runtime library name.
-  OMPRT_IOMP5
-};
-}
-
-/// Compute the desired OpenMP runtime from the flag provided.
-static OpenMPRuntimeKind getOpenMPRuntime(const ToolChain ,
-  const ArgList ) {
-  StringRef RuntimeName(CLANG_DEFAULT_OPENMP_RUNTIME);
-
-  const Arg *A = Args.getLastArg(options::OPT_fopenmp_EQ);
-  if (A)
-RuntimeName = A->getValue();
-
-  auto RT = llvm::StringSwitch(RuntimeName)
-.Case("libomp", OMPRT_OMP)
-.Case("libgomp", OMPRT_GOMP)
-.Case("libiomp5", OMPRT_IOMP5)
-.Default(OMPRT_Unknown);
-
-  if (RT == OMPRT_Unknown) {
-if (A)
-  TC.getDriver().Diag(diag::err_drv_unsupported_option_argument)
-  << A->getOption().getName() << A->getValue();
-else
-  // FIXME: We could use a nicer diagnostic here.
-  TC.getDriver().Diag(diag::err_drv_unsupported_opt) << "-fopenmp";
-  }
-
-  return RT;
-}
-
 static void addOpenMPRuntime(ArgStringList , const ToolChain ,
   const ArgList ) {
   if (!Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
 options::OPT_fno_openmp, false))
 return;
 
-  switch (getOpenMPRuntime(TC, Args)) {
-  case OMPRT_OMP:
+  switch (TC.getDriver().getOpenMPRuntime(Args)) {
+  case 

[PATCH] D24954: [Driver] Disable OpenSUSE rules for OpenSUSE/SLES 10 and older

2016-10-25 Thread Michał Górny via cfe-commits
mgorny updated this revision to Diff 75704.
mgorny added a comment.

Updated to perform `.startswith()` check before splitting.


https://reviews.llvm.org/D24954

Files:
  lib/Driver/ToolChains.cpp


Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -3931,8 +3931,25 @@
 .Default(UnknownDistro);
   }
 
-  if (VFS.exists("/etc/SuSE-release"))
-return OpenSUSE;
+  File = VFS.getBufferForFile("/etc/SuSE-release");
+  if (File) {
+StringRef Data = File.get()->getBuffer();
+SmallVector Lines;
+Data.split(Lines, "\n");
+for (const StringRef& Line : Lines) {
+  if (!Line.trim().startswith("VERSION"))
+continue;
+  std::pair SplitLine = Line.split('=');
+  int Version;
+  // OpenSUSE/SLES 10 and older are not supported and not compatible
+  // with our rules, so just treat them as UnknownDistro.
+  if (!SplitLine.second.trim().getAsInteger(10, Version) &&
+  Version > 10)
+return OpenSUSE;
+  return UnknownDistro;
+}
+return UnknownDistro;
+  }
 
   if (VFS.exists("/etc/exherbo-release"))
 return Exherbo;


Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -3931,8 +3931,25 @@
 .Default(UnknownDistro);
   }
 
-  if (VFS.exists("/etc/SuSE-release"))
-return OpenSUSE;
+  File = VFS.getBufferForFile("/etc/SuSE-release");
+  if (File) {
+StringRef Data = File.get()->getBuffer();
+SmallVector Lines;
+Data.split(Lines, "\n");
+for (const StringRef& Line : Lines) {
+  if (!Line.trim().startswith("VERSION"))
+continue;
+  std::pair SplitLine = Line.split('=');
+  int Version;
+  // OpenSUSE/SLES 10 and older are not supported and not compatible
+  // with our rules, so just treat them as UnknownDistro.
+  if (!SplitLine.second.trim().getAsInteger(10, Version) &&
+  Version > 10)
+return OpenSUSE;
+  return UnknownDistro;
+}
+return UnknownDistro;
+  }
 
   if (VFS.exists("/etc/exherbo-release"))
 return Exherbo;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25935: [OpenCL] Diagnose variadic arguments

2016-10-25 Thread Yaxun Liu via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks.


https://reviews.llvm.org/D25935



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


[PATCH] D25942: Fix crash in implicit default constructor creation for a template record specialization that has a field declaration with an initializer expression

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

This patch fixes a NULL pointer crash that happens when clang is trying to 
create an implicit default constructor for a specialization of a record 
template which is defined in a specialization of a parent record template and 
has a field declaration with an initializer expression.

The following piece of code reproduces this problem:

  template
  class A {
  public:
template 
struct Inner;
  };
  
  template<>
  template
  struct A::Inner {
int member = 42;
  };
  
  int main(void) {
return A::Inner<0>().member;
  }

The crash happens because `CXXRecordDecl::getTemplateInstantiationPattern` 
returns nil when instantiating `A::Inner<0>`, because it tries to get the 
instantiation pattern from the declaration of `Inner` (which has no definition 
and thus no instantiation pattern), rather than the specialized definition of 
`Inner`. This patch fixes this by making sure that the instantiation pattern 
comes from the definition rather than the declaration of the record template.


Repository:
  rL LLVM

https://reviews.llvm.org/D25942

Files:
  lib/AST/DeclCXX.cpp
  test/CodeGenCXX/cxx11-crashes.cpp


Index: test/CodeGenCXX/cxx11-crashes.cpp
===
--- /dev/null
+++ test/CodeGenCXX/cxx11-crashes.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple -std=c++11 %s -o - | 
FileCheck %s
+
+namespace rd28886662 {
+
+template
+class A {
+public:
+  template
+  struct Inner;
+};
+
+template<>
+template
+struct A::Inner {
+  int member = 42; // should be ok
+};
+
+int foo(void) {
+  return A::Inner<0>().member;
+}
+
+// CHECK: _ZN10rd288866621AIiE5InnerILi0EEC2Ev
+// CHECK: store i32 42, i32* %member
+
+}
Index: lib/AST/DeclCXX.cpp
===
--- lib/AST/DeclCXX.cpp
+++ lib/AST/DeclCXX.cpp
@@ -1347,7 +1347,8 @@
 auto From = TD->getInstantiatedFrom();
 if (auto *CTD = From.dyn_cast()) {
   while (auto *NewCTD = CTD->getInstantiatedFromMemberTemplate()) {
-if (NewCTD->isMemberSpecialization())
+if (NewCTD->isMemberSpecialization() ||
+!NewCTD->isThisDeclarationADefinition())
   break;
 CTD = NewCTD;
   }


Index: test/CodeGenCXX/cxx11-crashes.cpp
===
--- /dev/null
+++ test/CodeGenCXX/cxx11-crashes.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple -std=c++11 %s -o - | FileCheck %s
+
+namespace rd28886662 {
+
+template
+class A {
+public:
+  template
+  struct Inner;
+};
+
+template<>
+template
+struct A::Inner {
+  int member = 42; // should be ok
+};
+
+int foo(void) {
+  return A::Inner<0>().member;
+}
+
+// CHECK: _ZN10rd288866621AIiE5InnerILi0EEC2Ev
+// CHECK: store i32 42, i32* %member
+
+}
Index: lib/AST/DeclCXX.cpp
===
--- lib/AST/DeclCXX.cpp
+++ lib/AST/DeclCXX.cpp
@@ -1347,7 +1347,8 @@
 auto From = TD->getInstantiatedFrom();
 if (auto *CTD = From.dyn_cast()) {
   while (auto *NewCTD = CTD->getInstantiatedFromMemberTemplate()) {
-if (NewCTD->isMemberSpecialization())
+if (NewCTD->isMemberSpecialization() ||
+!NewCTD->isThisDeclarationADefinition())
   break;
 CTD = NewCTD;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D21840: [Driver][CUDA][OpenMP] Reimplement tool selection in the driver.

2016-10-25 Thread Samuel Antao via cfe-commits
sfantao updated this revision to Diff 75698.
sfantao marked 10 inline comments as done.
sfantao added a comment.

- Address Hal Finkel suggestions - rename functions/reorder code/fix comments.


https://reviews.llvm.org/D21840

Files:
  include/clang/Driver/Action.h
  lib/Driver/Driver.cpp

Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1930,7 +1930,7 @@
 
 // Create the offload action with all dependences. When an offload action
 // is created the kinds are propagated to the host action, so we don't have
-// to do that explicitely here.
+// to do that explicitly here.
 OffloadAction::HostDependence HDep(
 *HostAction, *C.getSingleOffloadToolChain(),
 /*BoundArch*/ nullptr, ActiveOffloadKinds);
@@ -2368,142 +2368,288 @@
 }
   }
 }
-/// Collapse an offloading action looking for a job of the given type. The input
-/// action is changed to the input of the collapsed sequence. If we effectively
-/// had a collapse return the corresponding offloading action, otherwise return
-/// null.
-template 
-static OffloadAction *collapseOffloadingAction(Action *) {
-  if (!CurAction)
-return nullptr;
-  if (auto *OA = dyn_cast(CurAction)) {
-if (OA->hasHostDependence())
-  if (auto *HDep = dyn_cast(OA->getHostDependence())) {
-CurAction = HDep;
-return OA;
-  }
-if (OA->hasSingleDeviceDependence())
-  if (auto *DDep = dyn_cast(OA->getSingleDeviceDependence())) {
-CurAction = DDep;
-return OA;
+
+namespace {
+/// Utility class to control the collapse of dependent actions and select the
+/// tools accordingly.
+class ToolSelector final {
+  /// The tool chain this selector refers to.
+  const ToolChain 
+
+  /// The compilation this selector refers to.
+  const Compilation 
+
+  /// The base action this selector refers to.
+  const JobAction *BaseAction;
+
+  /// Set to true if the current toolchain refers to host actions.
+  bool IsHostSelector;
+
+  /// Set to true if save-temps and embed-bitcode functionalities are active.
+  bool SaveTemps;
+  bool EmbedBitcode;
+
+  /// Get previous dependent action or null if that does not exist. If
+  /// \a CanBeCollapsed is false, that action must be legal to collapse or
+  /// null will be returned.
+  const JobAction *getPrevDependentAction(const ActionList ,
+  ActionList ,
+  bool CanBeCollapsed = true) {
+// An option can be collapsed only if it has a single input.
+if (Inputs.size() != 1)
+  return nullptr;
+
+Action *CurAction = *Inputs.begin();
+if (CanBeCollapsed &&
+!CurAction->isCollapsingWithNextDependentActionLegal())
+  return nullptr;
+
+// If the input action is an offload action. Look through it and save any
+// offload action that can be dropped in the event of a collapse.
+if (auto *OA = dyn_cast(CurAction)) {
+  // If the dependent action is a device action, we will attempt to collapse
+  // only with other device actions. Otherwise, we would do the same but
+  // with host actions only.
+  if (!IsHostSelector) {
+if (OA->hasSingleDeviceDependence(/*DoNotConsiderHostActions=*/true)) {
+  CurAction =
+  OA->getSingleDeviceDependence(/*DoNotConsiderHostActions=*/true);
+  if (CanBeCollapsed &&
+  !CurAction->isCollapsingWithNextDependentActionLegal())
+return nullptr;
+  SavedOffloadAction.push_back(OA);
+  return dyn_cast(CurAction);
+}
+  } else if (OA->hasHostDependence()) {
+CurAction = OA->getHostDependence();
+if (CanBeCollapsed &&
+!CurAction->isCollapsingWithNextDependentActionLegal())
+  return nullptr;
+SavedOffloadAction.push_back(OA);
+return dyn_cast(CurAction);
   }
+  return nullptr;
+}
+
+return dyn_cast(CurAction);
   }
-  return nullptr;
-}
-// Returns a Tool for a given JobAction.  In case the action and its
-// predecessors can be combined, updates Inputs with the inputs of the
-// first combined action. If one of the collapsed actions is a
-// CudaHostAction, updates CollapsedCHA with the pointer to it so the
-// caller can deal with extra handling such action requires.
-static const Tool *selectToolForJob(Compilation , bool SaveTemps,
-bool EmbedBitcode, const ToolChain *TC,
-const JobAction *JA,
-const ActionList *,
-ActionList ) {
-  const Tool *ToolForJob = nullptr;
-  CollapsedOffloadAction.clear();
-
-  // See if we should look for a compiler with an integrated assembler. We match
-  // bottom up, so what we are actually looking for is an assembler job with a
-  // compiler input.
-
-  // Look through 

[PATCH] D21840: [Driver][CUDA][OpenMP] Reimplement tool selection in the driver.

2016-10-25 Thread Samuel Antao via cfe-commits
sfantao added a comment.

Hi Hal,

Thanks for the review!

In https://reviews.llvm.org/D21840#555719, @hfinkel wrote:

> The naming here is a bit hard to follow, we have 'dependent action', 
> 'dependency action', 'depending action', and I think they're all supposed to 
> mean the same thing. Only 'dependent action' sounds right to me, can we use 
> that universally (i.e. in all comments and names of functions and variables)?


I agree the Depending/Dependence stuff can be confusing. However, I tried to 
use Depending and Dependence to indicate different things:

- Depending action -> an action that depends on the current one
- Dependence action ->  an action that is a dependence to the current one

Of course they all are dependent actions, so your suggestion definitely makes 
sense. So, in the last diff I indicate:

- Depending action -> Next Dependent action
- Dependence action -> Prev(ious) Dependent action

I hope this helps clarifying things. Let me know you thoughts.

Thanks again!
Samuel




Comment at: lib/Driver/Driver.cpp:2394
+Action *CurAction = *Inputs.begin();
+if (!CurAction->isCollapsingWithDependingActionLegal() && CanBeCollapsed)
+  return nullptr;

hfinkel wrote:
> As a micro-optimization, check CanBeCollapsed first, then call the function:
> 
>   if (CanBeCollapsed && !CurAction->isCollapsingWithDependingActionLegal())
> 
Ok, makes sense. Fixed this in the last diff.



Comment at: lib/Driver/Driver.cpp:2444
+  /// collapsed with it.
+  struct JobActionInfoTy final {
+/// The action this info refers to.

hfinkel wrote:
> Putting "Ty" on the end of a type name seems unusual for our code base (we 
> generally use that for typedefs or for variables that represent types of 
> other entities). Just JobActionInfo should be fine.
Ok, fixed that in the last diff.



Comment at: lib/Driver/Driver.cpp:2474
+  const Tool *
+  attemptCombineAssembleBackendCompile(ArrayRef ActionInfo,
+   const ActionList *,

hfinkel wrote:
> I don't think we need 'attempt' in the name here, just make this:
> 
>   combineAssembleBackendCompile
Ok, fixed in last diff.



Comment at: lib/Driver/Driver.cpp:2632
+
+if (!T)
+  T = attemptCombineAssembleBackendCompile(ActionChain, Inputs,

hfinkel wrote:
> I don't think the syntactic regularity here is helpful enough to justify this 
> extra if. Just do:
> 
>   const Tool *T = combineAssembleBackendCompile(ActionChain, Inputs,
> CollapsedOffloadAction);
> 
Ok, fixed in last diff.


https://reviews.llvm.org/D21840



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


[PATCH] D25936: Fix format string for err_os_log_argument_to_big (currently unused)

2016-10-25 Thread Sam McCall via cfe-commits
sammccall added a comment.

In https://reviews.llvm.org/D25936#578341, @mehdi_amini wrote:

> Good catch! How did you find this?


We've got a library that parses diagnostics that consumes 
DiagnosticSemaKinds.inc, and it failed to parse this message format.

> We need a test though.
>  (I can take over if you want, as I introduced the issue in the first place)

Thanks! I'm pretty new to llvm and wasn't sure how to test this.
Looks like bkramer came up with one though.


Repository:
  rL LLVM

https://reviews.llvm.org/D25936



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


  1   2   >