Re: [PATCH] D20352: Add XRay flags to Clang

2016-06-27 Thread Dean Michael Berris via cfe-commits
dberris added inline comments.


Comment at: include/clang/Basic/Attr.td:436
@@ +435,3 @@
+   CXX11<"clang", "xray_never_instrument">];
+  let Subjects = SubjectList<[CXXMethod, ObjCMethod, Function], WarnDiag,
+  "ExpectedFunctionOrMethod">;

aaron.ballman wrote:
> You can drop the WarnDiag and string literal; the defaults already do the 
> right thing.
I tried, but I'm getting this error:

.../Basic/Attr.td:436:18: error: Could not deduce diagnostic argument for Attr 
subjects
  let Subjects = SubjectList<[CXXMethod, ObjCMethod, Function]>;



Comment at: include/clang/Basic/AttrDocs.td:2455
@@ +2454,3 @@
+  let Content = [{
+``__attribute__((xray_always_instrument))`` or 
``[[clang:xray_always_instrument]]`` is used to mark member functions (in C++), 
methods (in Objective C), and free functions (in C, C++, and Objective C) to be 
instrumented with XRay. This will cause the function to always have space at 
the beginning and exit points to allow for runtime patching.
+

aaron.ballman wrote:
> Let's make sure that this patch and D19908 do not conflict, because they seem 
> to be implementing competing semantics.
Good catch. Let me comment on D19908 to see if it competes with how we define 
XRay instrumentation. As far as I can tell from the LLVM side, those should not 
interfere with each other.


Comment at: lib/CodeGen/CodeGenFunction.cpp:381
@@ -380,3 +380,3 @@
 
-  for (SmallVectorImpl::iterator
+  for (SmallVectorImpl::iterator
I = DeferredReplacements.begin(),

aaron.ballman wrote:
> Can't you rangify this loop?
Probably in a different change. :) For now I've reverted the formatting changes.


Comment at: lib/CodeGen/CodeGenFunction.cpp:402
@@ +401,3 @@
+/// instrumented with XRay nop sleds.
+bool CodeGenFunction::ShouldXRayInstrumentFunction() {
+  return CGM.getCodeGenOpts().XRayInstrumentFunctions;

aaron.ballman wrote:
> Any particular reason this isn't a `const` function?
No good reason. :) Good catch, fixed.


Comment at: lib/CodeGen/CodeGenFunction.cpp:691
@@ +690,3 @@
+if (D->hasAttr()) {
+  switch (D->getAttr()->getSpellingListIndex()) {
+case 0:

aaron.ballman wrote:
> This is not the right way to do this. ;-)
> 
> You should check the *semantic* spelling instead. e.g.,
> ```
> if (const auto *A = D->getAttr()) {
>   switch (A->getSemanticSpelling()) {
>   case XRayInstrumentAttr::GNU_blahblah:
>   case XRayInstrumentAttr::CXX11_clang_blahblah:
>   }
> }
> ```
> Alternatively (and I think this may be cleaner), you could add an additional 
> member in Attr.td that exposes this as two Boolean getters `bool 
> alwaysInstrument() const` and `bool neverInstrument() const` that do the 
> semantic spelling switch.
I thought this was a little weird, thanks for pointing this out!

I've used accessors instead, maybe it looks better now?


http://reviews.llvm.org/D20352



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


Re: [PATCH] D20352: Add XRay flags to Clang

2016-06-27 Thread Dean Michael Berris via cfe-commits
dberris updated this revision to Diff 62056.
dberris marked 2 inline comments as done.
dberris added a comment.

- Undo formatting changes
- Re-apply changes post-review
- Address more comments


http://reviews.llvm.org/D20352

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/xray-attributes-supported.cpp
  test/Sema/xray-always-instrument-attr.c
  test/Sema/xray-always-instrument-attr.cpp

Index: test/Sema/xray-always-instrument-attr.cpp
===
--- /dev/null
+++ test/Sema/xray-always-instrument-attr.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -std=c++11 -x c++
+void foo [[clang::xray_always_instrument]] ();
+
+struct [[clang::xray_always_instrument]] a { int x; }; // expected-warning {{'xray_always_instrument' attribute only applies to functions and methods}}
+
+class b {
+ void c [[clang::xray_always_instrument]] ();
+};
+
+void baz [[clang::xray_always_instrument("not-supported")]] (); // expected-error {{'xray_always_instrument' attribute takes no arguments}}
Index: test/Sema/xray-always-instrument-attr.c
===
--- /dev/null
+++ test/Sema/xray-always-instrument-attr.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -std=c11
+void foo() __attribute__((xray_always_instrument));
+
+struct __attribute__((xray_always_instrument)) a { int x; }; // expected-warning {{'xray_always_instrument' attribute only applies to functions and methods}}
+
+void bar() __attribute__((xray_always_instrument("not-supported"))); // expected-error {{'xray_always_instrument' attribute takes no arguments}}
Index: test/CodeGen/xray-attributes-supported.cpp
===
--- /dev/null
+++ test/CodeGen/xray-attributes-supported.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple x86_64-unknown-linux-gnu | FileCheck %s
+
+// Make sure that the LLVM attribute for XRay-annotated functions do show up.
+[[clang::xray_always_instrument]] void foo() {
+// CHECK: define void @_Z3foov() #0
+};
+
+[[clang::xray_never_instrument]] void bar() {
+// CHECK: define void @_Z3barv() #1
+};
+
+// CHECK: #0 = {{.*}}"function-instrument"="xray-always"
+// CHECK: #1 = {{.*}}"function-instrument"="xray-never"
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -5913,10 +5913,13 @@
   case AttributeList::AT_TypeTagForDatatype:
 handleTypeTagForDatatypeAttr(S, D, Attr);
 break;
-
   case AttributeList::AT_RenderScriptKernel:
 handleSimpleAttribute(S, D, Attr);
 break;
+  // XRay attributes.
+  case AttributeList::AT_XRayInstrument:
+handleSimpleAttribute(S, D, Attr);
+break;
   }
 }
 
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -685,6 +685,9 @@
   }
 
   Opts.InstrumentFunctions = Args.hasArg(OPT_finstrument_functions);
+  Opts.XRayInstrumentFunctions = Args.hasArg(OPT_fxray_instrument);
+  Opts.XRayInstructionThreshold =
+  getLastArgIntValue(Args, OPT_fxray_instruction_threshold_, 200, Diags);
   Opts.InstrumentForProfiling = Args.hasArg(OPT_pg);
   Opts.EmitOpenCLArgMetadata = Args.hasArg(OPT_cl_kernel_arg_info);
   Opts.CompressDebugSections = Args.hasArg(OPT_compress_debug_sections);
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3178,6 +3178,28 @@
   return !StaticRuntimes.empty();
 }
 
+static bool addXRayRuntime(const ToolChain , const ArgList ,
+   ArgStringList ) {
+  if (Args.hasArg(options::OPT_fxray_instrument,
+  options::OPT_fnoxray_instrument, false)) {
+CmdArgs.push_back("-whole-archive");
+CmdArgs.push_back(TC.getCompilerRTArgString(Args, "xray", false));
+CmdArgs.push_back("-no-whole-archive");
+return true;
+  }
+  return false;
+}
+
+static void linkXRayRuntimeDeps(const ToolChain , ArgStringList ) {
+  CmdArgs.push_back("--no-as-needed");
+  CmdArgs.push_back("-lpthread");
+  CmdArgs.push_back("-lrt");
+  CmdArgs.push_back("-lm");
+  CmdArgs.push_back("-latomic");
+  if (TC.getTriple().getOS() != llvm::Triple::FreeBSD)
+CmdArgs.push_back("-ldl");
+}
+
 static bool areOptimizationsEnabled(const ArgList ) {
   // Find the last -O arg and see if it is non-zero.
   if (Arg *A = Args.getLastArg(options::OPT_O_Group))
@@ -4579,6 +4601,16 @@
 
   Args.AddAllArgs(CmdArgs, 

r273987 - [clang-cl] Define _MSVC_LANG

2016-06-27 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Mon Jun 27 22:13:16 2016
New Revision: 273987

URL: http://llvm.org/viewvc/llvm-project?rev=273987=rev
Log:
[clang-cl] Define _MSVC_LANG

Recently, Microsoft added support for a flag, /std, which controls which
version of the language rules MSVC should use.
MSVC hasn't updated __cplusplus though.
Instead, they added a new macro, _MSVC_LANG, which is defined in a
similar fashion to __cplusplus.  This is used to indicate which mode the
compiler is in.

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/Preprocessor/predefined-macros.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=273987=273986=273987=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Mon Jun 27 22:13:16 2016
@@ -734,6 +734,13 @@ protected:
 
   if (Opts.CPlusPlus11 && Opts.isCompatibleWithMSVC(LangOptions::MSVC2015))
 Builder.defineMacro("_HAS_CHAR16_T_LANGUAGE_SUPPORT", Twine(1));
+
+  if (Opts.isCompatibleWithMSVC(LangOptions::MSVC2015)) {
+if (Opts.CPlusPlus1z)
+  Builder.defineMacro("_MSVC_LANG", "201403L");
+else if (Opts.CPlusPlus14)
+  Builder.defineMacro("_MSVC_LANG", "201402L");
+  }
 }
 
 if (Opts.MicrosoftExt) {

Modified: cfe/trunk/test/Preprocessor/predefined-macros.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/predefined-macros.c?rev=273987=273986=273987=diff
==
--- cfe/trunk/test/Preprocessor/predefined-macros.c (original)
+++ cfe/trunk/test/Preprocessor/predefined-macros.c Mon Jun 27 22:13:16 2016
@@ -1,10 +1,11 @@
 // This test verifies that the correct macros are predefined.
 //
-// RUN: %clang_cc1 %s -E -dM -triple i686-pc-win32 -fms-extensions 
-fms-compatibility \
-// RUN: -fms-compatibility-version=13.00 -o - | FileCheck 
-match-full-lines %s --check-prefix=CHECK-MS
+// RUN: %clang_cc1 %s -x c++ -E -dM -triple i686-pc-win32 -fms-extensions 
-fms-compatibility \
+// RUN: -fms-compatibility-version=19.00 -std=c++1z -o - | FileCheck 
-match-full-lines %s --check-prefix=CHECK-MS
 // CHECK-MS: #define _INTEGRAL_MAX_BITS 64
 // CHECK-MS: #define _MSC_EXTENSIONS 1
-// CHECK-MS: #define _MSC_VER 1300
+// CHECK-MS: #define _MSC_VER 1900
+// CHECK-MS: #define _MSVC_LANG 201403L
 // CHECK-MS: #define _M_IX86 600
 // CHECK-MS: #define _M_IX86_FP 0
 // CHECK-MS: #define _WIN32 1
@@ -13,11 +14,12 @@
 // CHECK-MS-NOT: GNU
 // CHECK-MS-NOT: GXX
 //
-// RUN: %clang_cc1 %s -E -dM -triple x86_64-pc-win32 -fms-extensions 
-fms-compatibility \
-// RUN: -fms-compatibility-version=13.00 -o - | FileCheck 
-match-full-lines %s --check-prefix=CHECK-MS64
+// RUN: %clang_cc1 %s -x c++ -E -dM -triple x86_64-pc-win32 -fms-extensions 
-fms-compatibility \
+// RUN: -fms-compatibility-version=19.00 -std=c++14 -o - | FileCheck 
-match-full-lines %s --check-prefix=CHECK-MS64
 // CHECK-MS64: #define _INTEGRAL_MAX_BITS 64
 // CHECK-MS64: #define _MSC_EXTENSIONS 1
-// CHECK-MS64: #define _MSC_VER 1300
+// CHECK-MS64: #define _MSC_VER 1900
+// CHECK-MS64: #define _MSVC_LANG 201402L
 // CHECK-MS64: #define _M_AMD64 100
 // CHECK-MS64: #define _M_X64 100
 // CHECK-MS64: #define _WIN64 1


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


r273986 - [intrin.h] Certain _Interlocked intrinsics return the old value

2016-06-27 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Mon Jun 27 21:54:43 2016
New Revision: 273986

URL: http://llvm.org/viewvc/llvm-project?rev=273986=rev
Log:
[intrin.h] Certain _Interlocked intrinsics return the old value

This fixes PR28326.

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

Modified: cfe/trunk/lib/Headers/intrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/intrin.h?rev=273986=273985=273986=diff
==
--- cfe/trunk/lib/Headers/intrin.h (original)
+++ cfe/trunk/lib/Headers/intrin.h Mon Jun 27 21:54:43 2016
@@ -666,20 +666,20 @@ _InterlockedDecrement64(__int64 volatile
 
\**/
 static __inline__ char __DEFAULT_FN_ATTRS
 _InterlockedAnd8(char volatile *_Value, char _Mask) {
-  return __atomic_and_fetch(_Value, _Mask, __ATOMIC_SEQ_CST);
+  return __atomic_fetch_and(_Value, _Mask, __ATOMIC_SEQ_CST);
 }
 static __inline__ short __DEFAULT_FN_ATTRS
 _InterlockedAnd16(short volatile *_Value, short _Mask) {
-  return __atomic_and_fetch(_Value, _Mask, __ATOMIC_SEQ_CST);
+  return __atomic_fetch_and(_Value, _Mask, __ATOMIC_SEQ_CST);
 }
 static __inline__ long __DEFAULT_FN_ATTRS
 _InterlockedAnd(long volatile *_Value, long _Mask) {
-  return __atomic_and_fetch(_Value, _Mask, __ATOMIC_SEQ_CST);
+  return __atomic_fetch_and(_Value, _Mask, __ATOMIC_SEQ_CST);
 }
 #ifdef __x86_64__
 static __inline__ __int64 __DEFAULT_FN_ATTRS
 _InterlockedAnd64(__int64 volatile *_Value, __int64 _Mask) {
-  return __atomic_and_fetch(_Value, _Mask, __ATOMIC_SEQ_CST);
+  return __atomic_fetch_and(_Value, _Mask, __ATOMIC_SEQ_CST);
 }
 #endif
 
/**\
@@ -687,20 +687,20 @@ _InterlockedAnd64(__int64 volatile *_Val
 
\**/
 static __inline__ char __DEFAULT_FN_ATTRS
 _InterlockedOr8(char volatile *_Value, char _Mask) {
-  return __atomic_or_fetch(_Value, _Mask, __ATOMIC_SEQ_CST);
+  return __atomic_fetch_or(_Value, _Mask, __ATOMIC_SEQ_CST);
 }
 static __inline__ short __DEFAULT_FN_ATTRS
 _InterlockedOr16(short volatile *_Value, short _Mask) {
-  return __atomic_or_fetch(_Value, _Mask, __ATOMIC_SEQ_CST);
+  return __atomic_fetch_or(_Value, _Mask, __ATOMIC_SEQ_CST);
 }
 static __inline__ long __DEFAULT_FN_ATTRS
 _InterlockedOr(long volatile *_Value, long _Mask) {
-  return __atomic_or_fetch(_Value, _Mask, __ATOMIC_SEQ_CST);
+  return __atomic_fetch_or(_Value, _Mask, __ATOMIC_SEQ_CST);
 }
 #ifdef __x86_64__
 static __inline__ __int64 __DEFAULT_FN_ATTRS
 _InterlockedOr64(__int64 volatile *_Value, __int64 _Mask) {
-  return __atomic_or_fetch(_Value, _Mask, __ATOMIC_SEQ_CST);
+  return __atomic_fetch_or(_Value, _Mask, __ATOMIC_SEQ_CST);
 }
 #endif
 
/**\
@@ -708,20 +708,20 @@ _InterlockedOr64(__int64 volatile *_Valu
 
\**/
 static __inline__ char __DEFAULT_FN_ATTRS
 _InterlockedXor8(char volatile *_Value, char _Mask) {
-  return __atomic_xor_fetch(_Value, _Mask, __ATOMIC_SEQ_CST);
+  return __atomic_fetch_xor(_Value, _Mask, __ATOMIC_SEQ_CST);
 }
 static __inline__ short __DEFAULT_FN_ATTRS
 _InterlockedXor16(short volatile *_Value, short _Mask) {
-  return __atomic_xor_fetch(_Value, _Mask, __ATOMIC_SEQ_CST);
+  return __atomic_fetch_xor(_Value, _Mask, __ATOMIC_SEQ_CST);
 }
 static __inline__ long __DEFAULT_FN_ATTRS
 _InterlockedXor(long volatile *_Value, long _Mask) {
-  return __atomic_xor_fetch(_Value, _Mask, __ATOMIC_SEQ_CST);
+  return __atomic_fetch_xor(_Value, _Mask, __ATOMIC_SEQ_CST);
 }
 #ifdef __x86_64__
 static __inline__ __int64 __DEFAULT_FN_ATTRS
 _InterlockedXor64(__int64 volatile *_Value, __int64 _Mask) {
-  return __atomic_xor_fetch(_Value, _Mask, __ATOMIC_SEQ_CST);
+  return __atomic_fetch_xor(_Value, _Mask, __ATOMIC_SEQ_CST);
 }
 #endif
 
/**\


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


[PATCH] D21783: [CodeView] Implement support for bitfields in Clang

2016-06-27 Thread David Majnemer via cfe-commits
majnemer created this revision.
majnemer added reviewers: rnk, aaboud.
majnemer added a subscriber: cfe-commits.

Emit the underlying storage offset in addition to the starting bit
position of the field.

http://reviews.llvm.org/D21783

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  test/CodeGen/debug-info-packed-struct.c
  test/CodeGenCXX/debug-info-ms-bitfields.cpp

Index: test/CodeGenCXX/debug-info-ms-bitfields.cpp
===
--- /dev/null
+++ test/CodeGenCXX/debug-info-ms-bitfields.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple x86_64-pc-win32 -debug-info-kind=limited -gcodeview %s -emit-llvm -o - | FileCheck %s
+
+#pragma pack(1)
+struct S {
+  char : 8;
+  short   : 8;
+  short x : 8;
+} s;
+
+// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "x", {{.*}}, size: 8, align: 16, offset: 16, flags: DIFlagBitField, extraData: i64 8)
Index: test/CodeGen/debug-info-packed-struct.c
===
--- test/CodeGen/debug-info-packed-struct.c
+++ test/CodeGen/debug-info-packed-struct.c
@@ -21,7 +21,7 @@
 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "l0_ofs8",
 // CHECK-SAME: {{.*}}size: 64, align: 64, offset: 64)
 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "l0_ofs16",
-// CHECK-SAME: {{.*}}size: 1, align: 32, offset: 128)
+// CHECK-SAME: {{.*}}size: 1, align: 32, offset: 128, flags: DIFlagBitField, extraData: i64 128)
 
 
 // -
@@ -40,7 +40,7 @@
 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "l1_ofs1",
 // CHECK-SAME: {{.*}}size: 64, align: 8, offset: 8)
 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "l1_ofs9",
-// CHECK-SAME: {{.*}}size: 1, align: 32, offset: 72)
+// CHECK-SAME: {{.*}}size: 1, align: 32, offset: 72, flags: DIFlagBitField, extraData: i64 72)
 
 
 // -
@@ -61,7 +61,7 @@
 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "l2_ofs1",
 // CHECK-SAME: {{.*}}size: 64, align: 8, offset: 8)
 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "l2_ofs9",
-// CHECK-SAME: {{.*}}size: 1, align: 32, offset: 72)
+// CHECK-SAME: {{.*}}size: 1, align: 32, offset: 72, flags: DIFlagBitField, extraData: i64 72)
 
 
 
@@ -83,7 +83,7 @@
 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "l3_ofs4",
 // CHECK-SAME: {{.*}}size: 64, align: 32, offset: 32)
 // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "l3_ofs12",
-// CHECK-SAME: {{.*}}size: 1, align: 32, offset: 96)
+// CHECK-SAME: {{.*}}size: 1, align: 32, offset: 96, flags: DIFlagBitField, extraData: i64 96)
 
 struct layout0 l0;
 struct layout1 l1;
Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -232,11 +232,16 @@
llvm::DIFile *F);
 
   llvm::DIType *createFieldType(StringRef name, QualType type,
-uint64_t sizeInBitsOverride, SourceLocation loc,
-AccessSpecifier AS, uint64_t offsetInBits,
-llvm::DIFile *tunit, llvm::DIScope *scope,
+SourceLocation loc, AccessSpecifier AS,
+uint64_t offsetInBits, llvm::DIFile *tunit,
+llvm::DIScope *scope,
 const RecordDecl *RD = nullptr);
 
+  /// Create new bit field member.
+  llvm::DIType *createBitFieldType(const FieldDecl *BitFieldDecl,
+   llvm::DIScope *RecordTy,
+   const RecordDecl *RD, SourceLocation Loc);
+
   /// Helpers for collecting fields of a record.
   /// @{
   void CollectRecordLambdaFields(const CXXRecordDecl *CXXDecl,
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -13,6 +13,7 @@
 
 #include "CGDebugInfo.h"
 #include "CGBlocks.h"
+#include "CGRecordLayout.h"
 #include "CGCXXABI.h"
 #include "CGObjCRuntime.h"
 #include "CodeGenFunction.h"
@@ -905,10 +906,38 @@
   llvm_unreachable("unexpected access enumerator");
 }
 
-llvm::DIType *CGDebugInfo::createFieldType(
-StringRef name, QualType type, uint64_t sizeInBitsOverride,
-SourceLocation loc, AccessSpecifier AS, uint64_t offsetInBits,
-llvm::DIFile *tunit, llvm::DIScope *scope, const RecordDecl *RD) {
+llvm::DIType *CGDebugInfo::createBitFieldType(const FieldDecl *BitFieldDecl,
+  llvm::DIScope *RecordTy,
+  const RecordDecl *RD) {
+  StringRef Name = BitFieldDecl->getName();
+  QualType Ty = BitFieldDecl->getType();
+  SourceLocation Loc = BitFieldDecl->getLocation();
+  

Re: [PATCH] D21659: AMDGPU: Add builtin to read exec mask

2016-06-27 Thread Matt Arsenault via cfe-commits
arsenm closed this revision.
arsenm added a comment.

r273965


http://reviews.llvm.org/D21659



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


r273976 - Avoid accessing an invalid PresumedLoc.

2016-06-27 Thread Jordan Rose via cfe-commits
Author: jrose
Date: Mon Jun 27 20:02:31 2016
New Revision: 273976

URL: http://llvm.org/viewvc/llvm-project?rev=273976=rev
Log:
Avoid accessing an invalid PresumedLoc.

DiagnosticNoteRenderer asserts trying to emit its "while building
module Foo imported from bar.h:5" note when the presumed location
of the import is invalid. This assertion was added in r267914,
where most uses of 'getFilename' were updated to test 'isValid'
instead. This one must have been missed.

I can't come up with a test because this location is always valid
in C-based code, but external clients that manually import modules
(*cough*Swift*cough*) sometimes provide invalid SourceLocations.

rdar://problem/26099576

http://reviews.llvm.org/D2

Modified:
cfe/trunk/lib/Frontend/DiagnosticRenderer.cpp

Modified: cfe/trunk/lib/Frontend/DiagnosticRenderer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/DiagnosticRenderer.cpp?rev=273976=273975=273976=diff
==
--- cfe/trunk/lib/Frontend/DiagnosticRenderer.cpp (original)
+++ cfe/trunk/lib/Frontend/DiagnosticRenderer.cpp Mon Jun 27 20:02:31 2016
@@ -618,7 +618,7 @@ DiagnosticNoteRenderer::emitBuildingModu
   // Generate a note indicating the include location.
   SmallString<200> MessageStorage;
   llvm::raw_svector_ostream Message(MessageStorage);
-  if (PLoc.getFilename())
+  if (PLoc.isValid())
 Message << "while building module '" << ModuleName << "' imported from "
 << PLoc.getFilename() << ':' << PLoc.getLine() << ":";
   else


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


Re: [PATCH] D21111: Avoid accessing an invalid PresumedLoc

2016-06-27 Thread Jordan Rose via cfe-commits
jordan_rose closed this revision.
jordan_rose added a comment.

Committed as r273976.


Repository:
  rL LLVM

http://reviews.llvm.org/D2



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


[PATCH] D21778: [CUDA] Add support for CUDA 8 and sm_60-62.

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

Also add sm_32, which was missing.

http://reviews.llvm.org/D21778

Files:
  lib/Basic/Targets.cpp
  lib/Driver/Action.cpp
  lib/Driver/ToolChains.cpp

Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -1712,6 +1712,7 @@
 Args.getLastArgValue(options::OPT_cuda_path_EQ));
   else {
 CudaPathCandidates.push_back(D.SysRoot + "/usr/local/cuda");
+CudaPathCandidates.push_back(D.SysRoot + "/usr/local/cuda-8.0");
 CudaPathCandidates.push_back(D.SysRoot + "/usr/local/cuda-7.5");
 CudaPathCandidates.push_back(D.SysRoot + "/usr/local/cuda-7.0");
   }
@@ -1758,6 +1759,9 @@
 CudaLibDeviceMap["sm_50"] = FilePath;
 CudaLibDeviceMap["sm_52"] = FilePath;
 CudaLibDeviceMap["sm_53"] = FilePath;
+CudaLibDeviceMap["sm_60"] = FilePath;
+CudaLibDeviceMap["sm_61"] = FilePath;
+CudaLibDeviceMap["sm_62"] = FilePath;
   }
 }
 
Index: lib/Driver/Action.cpp
===
--- lib/Driver/Action.cpp
+++ lib/Driver/Action.cpp
@@ -66,6 +66,9 @@
   .Case("sm_50", "compute_50")
   .Case("sm_52", "compute_52")
   .Case("sm_53", "compute_53")
+  .Case("sm_60", "compute_60")
+  .Case("sm_61", "compute_61")
+  .Case("sm_62", "compute_62")
   .Default(nullptr);
 }
 
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -1694,11 +1694,15 @@
 GK_SM20,
 GK_SM21,
 GK_SM30,
+GK_SM32,
 GK_SM35,
 GK_SM37,
 GK_SM50,
 GK_SM52,
 GK_SM53,
+GK_SM60,
+GK_SM61,
+GK_SM62,
   } GPU;
 
 public:
@@ -1780,35 +1784,37 @@
 Builder.defineMacro("__NVPTX__");
 if (Opts.CUDAIsDevice) {
   // Set __CUDA_ARCH__ for the GPU specified.
-  std::string CUDAArchCode;
-  switch (GPU) {
-  case GK_SM20:
-CUDAArchCode = "200";
-break;
-  case GK_SM21:
-CUDAArchCode = "210";
-break;
-  case GK_SM30:
-CUDAArchCode = "300";
-break;
-  case GK_SM35:
-CUDAArchCode = "350";
-break;
-  case GK_SM37:
-CUDAArchCode = "370";
-break;
-  case GK_SM50:
-CUDAArchCode = "500";
-break;
-  case GK_SM52:
-CUDAArchCode = "520";
-break;
-  case GK_SM53:
-CUDAArchCode = "530";
-break;
-  default:
-llvm_unreachable("Unhandled target CPU");
-  }
+  std::string CUDAArchCode = [this] {
+switch (GPU) {
+case GK_NONE:
+  assert(false && "No GPU arch when compiling CUDA device code.");
+  return "";
+case GK_SM20:
+  return "200";
+case GK_SM21:
+  return "210";
+case GK_SM30:
+  return "300";
+case GK_SM32:
+  return "320";
+case GK_SM35:
+  return "350";
+case GK_SM37:
+  return "370";
+case GK_SM50:
+  return "500";
+case GK_SM52:
+  return "520";
+case GK_SM53:
+  return "530";
+case GK_SM60:
+  return "600";
+case GK_SM61:
+  return "610";
+case GK_SM62:
+  return "620";
+}
+  }();
   Builder.defineMacro("__CUDA_ARCH__", CUDAArchCode);
 }
   }
@@ -1853,11 +1859,15 @@
   .Case("sm_20", GK_SM20)
   .Case("sm_21", GK_SM21)
   .Case("sm_30", GK_SM30)
+  .Case("sm_32", GK_SM32)
   .Case("sm_35", GK_SM35)
   .Case("sm_37", GK_SM37)
   .Case("sm_50", GK_SM50)
   .Case("sm_52", GK_SM52)
   .Case("sm_53", GK_SM53)
+  .Case("sm_60", GK_SM60)
+  .Case("sm_61", GK_SM61)
+  .Case("sm_62", GK_SM62)
   .Default(GK_NONE);
 
 return GPU != GK_NONE;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r273965 - AMDGPU: Add builtin to read exec mask

2016-06-27 Thread Matt Arsenault via cfe-commits
Author: arsenm
Date: Mon Jun 27 19:13:17 2016
New Revision: 273965

URL: http://llvm.org/viewvc/llvm-project?rev=273965=rev
Log:
AMDGPU: Add builtin to read exec mask

Modified:
cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl

Modified: cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def?rev=273965=273964=273965=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def Mon Jun 27 19:13:17 2016
@@ -18,6 +18,9 @@
 #   define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS)
 #endif
 
+//===--===//
+// Instruction builtins.
+//===--===//
 BUILTIN(__builtin_amdgcn_s_barrier, "v", "n")
 BUILTIN(__builtin_amdgcn_div_scale, "dddbb*", "n")
 BUILTIN(__builtin_amdgcn_div_scalef, "fffbb*", "n")
@@ -60,6 +63,11 @@ BUILTIN(__builtin_amdgcn_s_sleep, "vIi",
 TARGET_BUILTIN(__builtin_amdgcn_s_memrealtime, "LUi", "n", "s-memrealtime")
 
 
//===--===//
+// Special builtins.
+//===--===//
+BUILTIN(__builtin_amdgcn_read_exec, "LUi", "nc")
+
+//===--===//
 // Legacy names with amdgpu prefix
 
//===--===//
 

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=273965=273964=273965=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Jun 27 19:13:17 2016
@@ -3650,7 +3650,9 @@ Value *CodeGenFunction::GetValueForARMHi
 static Value *EmitSpecialRegisterBuiltin(CodeGenFunction ,
  const CallExpr *E,
  llvm::Type *RegisterType,
- llvm::Type *ValueType, bool IsRead) {
+ llvm::Type *ValueType,
+ bool IsRead,
+ StringRef SysReg = "") {
   // write and register intrinsics only support 32 and 64 bit operations.
   assert((RegisterType->isIntegerTy(32) || RegisterType->isIntegerTy(64))
   && "Unsupported size for register.");
@@ -3659,8 +3661,10 @@ static Value *EmitSpecialRegisterBuiltin
   CodeGen::CodeGenModule  = CGF.CGM;
   LLVMContext  = CGM.getLLVMContext();
 
-  const Expr *SysRegStrExpr = E->getArg(0)->IgnoreParenCasts();
-  StringRef SysReg = cast(SysRegStrExpr)->getString();
+  if (SysReg.empty()) {
+const Expr *SysRegStrExpr = E->getArg(0)->IgnoreParenCasts();
+SysReg = cast(SysRegStrExpr)->getString();
+  }
 
   llvm::Metadata *Ops[] = { llvm::MDString::get(Context, SysReg) };
   llvm::MDNode *RegName = llvm::MDNode::get(Context, Ops);
@@ -7413,7 +7417,13 @@ Value *CodeGenFunction::EmitAMDGPUBuilti
   case AMDGPU::BI__builtin_amdgcn_classf:
 return emitFPIntBuiltin(*this, E, Intrinsic::amdgcn_class);
 
-// Legacy amdgpu prefix
+  case AMDGPU::BI__builtin_amdgcn_read_exec: {
+CallInst *CI = cast(
+  EmitSpecialRegisterBuiltin(*this, E, Int64Ty, Int64Ty, true, "exec"));
+CI->setConvergent();
+return CI;
+  }
+  // Legacy amdgpu prefix
   case AMDGPU::BI__builtin_amdgpu_rsq:
   case AMDGPU::BI__builtin_amdgpu_rsqf: {
 if (getTarget().getTriple().getArch() == Triple::amdgcn)

Modified: cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl?rev=273965=273964=273965=diff
==
--- cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl Mon Jun 27 19:13:17 2016
@@ -253,6 +253,14 @@ void test_cubema(global float* out, floa
   *out = __builtin_amdgcn_cubema(a, b, c);
 }
 
+// CHECK-LABEL: @test_read_exec(
+// CHECK: call i64 @llvm.read_register.i64(metadata ![[EXEC:[0-9]+]]) 
#[[READ_EXEC_ATTRS:[0-9]+]]
+void test_read_exec(global ulong* out) {
+  *out = __builtin_amdgcn_read_exec();
+}
+
+// CHECK: declare i64 @llvm.read_register.i64(metadata) 
#[[NOUNWIND_READONLY:[0-9]+]]
+
 // Legacy intrinsics with AMDGPU prefix
 
 // CHECK-LABEL: @test_legacy_rsq_f32
@@ -282,3 +290,7 @@ void test_legacy_ldexp_f64(global double
 {
   *out = __builtin_amdgpu_ldexp(a, b);
 }
+
+// CHECK-DAG: attributes 

Re: r273950 -

2016-06-27 Thread David Majnemer via cfe-commits
Any tests?

On Mon, Jun 27, 2016 at 5:12 PM, Nico Weber via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Did you land this intentionally? What was the commit message supposed to
> be?
>
> On Mon, Jun 27, 2016 at 6:11 PM, Chris Dewhurst via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: lerochris
>> Date: Mon Jun 27 17:11:12 2016
>> New Revision: 273950
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=273950=rev
>> Log: (empty)
>>
>> Modified:
>> cfe/trunk/lib/Basic/Targets.cpp
>>
>> Modified: cfe/trunk/lib/Basic/Targets.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=273950=273949=273950=diff
>>
>> ==
>> --- cfe/trunk/lib/Basic/Targets.cpp (original)
>> +++ cfe/trunk/lib/Basic/Targets.cpp Mon Jun 27 17:11:12 2016
>> @@ -6594,6 +6594,8 @@ public:
>>PtrDiffType = SignedLong;
>>break;
>>  }
>> +
>> +MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
>>}
>>
>>void getTargetDefines(const LangOptions ,
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r273950 -

2016-06-27 Thread Nico Weber via cfe-commits
Did you land this intentionally? What was the commit message supposed to be?

On Mon, Jun 27, 2016 at 6:11 PM, Chris Dewhurst via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: lerochris
> Date: Mon Jun 27 17:11:12 2016
> New Revision: 273950
>
> URL: http://llvm.org/viewvc/llvm-project?rev=273950=rev
> Log: (empty)
>
> Modified:
> cfe/trunk/lib/Basic/Targets.cpp
>
> Modified: cfe/trunk/lib/Basic/Targets.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=273950=273949=273950=diff
>
> ==
> --- cfe/trunk/lib/Basic/Targets.cpp (original)
> +++ cfe/trunk/lib/Basic/Targets.cpp Mon Jun 27 17:11:12 2016
> @@ -6594,6 +6594,8 @@ public:
>PtrDiffType = SignedLong;
>break;
>  }
> +
> +MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
>}
>
>void getTargetDefines(const LangOptions ,
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D21773: [clang] Update an optimization remark test for change D18777

2016-06-27 Thread Li Huang via cfe-commits
lihuang created this revision.
lihuang added reviewers: sanjoy, reames.
lihuang added a subscriber: cfe-commits.

Update an optimization remark test for change D18777.

This test checks the loop-vectorization remarks when pointer checking threshold 
is exceeded. The change in D18777 would introduce zexts that cannot be removed 
so that the "loop not vectorized" reason is changed, hence breaking this test. 

Modified the offsets to be 1 and the zexts could be finally removed by indvars 
(this magic fact is attributed to some scev mechanisms). Since the purpose of 
this test is checking the vectorization options, the offset numbers don't 
matter. 

http://reviews.llvm.org/D21773

Files:
  test/Frontend/optimization-remark-options.c

Index: test/Frontend/optimization-remark-options.c
===
--- test/Frontend/optimization-remark-options.c
+++ test/Frontend/optimization-remark-options.c
@@ -16,6 +16,6 @@
 void foo2(int *dw, int *uw, int *A, int *B, int *C, int *D, int N) {
   for (int i = 0; i < N; i++) {
 dw[i] = A[i] + B[i - 1] + C[i - 2] + D[i - 3];
-uw[i] = A[i] + B[i + 1] + C[i + 2] + D[i + 3];
+uw[i] = A[i] + B[i + 1] + C[i + 1] + D[i + 1];
   }
 }


Index: test/Frontend/optimization-remark-options.c
===
--- test/Frontend/optimization-remark-options.c
+++ test/Frontend/optimization-remark-options.c
@@ -16,6 +16,6 @@
 void foo2(int *dw, int *uw, int *A, int *B, int *C, int *D, int N) {
   for (int i = 0; i < N; i++) {
 dw[i] = A[i] + B[i - 1] + C[i - 2] + D[i - 3];
-uw[i] = A[i] + B[i + 1] + C[i + 2] + D[i + 3];
+uw[i] = A[i] + B[i + 1] + C[i + 1] + D[i + 1];
   }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r273950 -

2016-06-27 Thread Chris Dewhurst via cfe-commits
Author: lerochris
Date: Mon Jun 27 17:11:12 2016
New Revision: 273950

URL: http://llvm.org/viewvc/llvm-project?rev=273950=rev
Log: (empty)

Modified:
cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=273950=273949=273950=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Mon Jun 27 17:11:12 2016
@@ -6594,6 +6594,8 @@ public:
   PtrDiffType = SignedLong;
   break;
 }
+
+MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
   }
 
   void getTargetDefines(const LangOptions ,


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


Re: [PATCH] D15225: [Driver] Sanitizer support based on runtime library presence

2016-06-27 Thread Chris Bieneman via cfe-commits
beanz requested changes to this revision.
beanz added a comment.
This revision now requires changes to proceed.

It looks like @samsonov had quite a few valid review comments that are still 
unresolved. I know he hasn't been active lately, but I think those points 
deserve discussion.

-Chris


http://reviews.llvm.org/D15225



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


Re: [PATCH] D15225: [Driver] Sanitizer support based on runtime library presence

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

LGTM.

Any other comments to this?


http://reviews.llvm.org/D15225



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


r273948 - Attempting to fix lit test test/Headers/opencl-c-header.cl on cygwin.

2016-06-27 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Mon Jun 27 16:43:00 2016
New Revision: 273948

URL: http://llvm.org/viewvc/llvm-project?rev=273948=rev
Log:
Attempting to fix lit test test/Headers/opencl-c-header.cl on cygwin.

"chmod u-x *" does not work for lit on cygwin.

Modified:
cfe/trunk/test/Headers/opencl-c-header.cl

Modified: cfe/trunk/test/Headers/opencl-c-header.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/opencl-c-header.cl?rev=273948=273947=273948=diff
==
--- cfe/trunk/test/Headers/opencl-c-header.cl (original)
+++ cfe/trunk/test/Headers/opencl-c-header.cl Mon Jun 27 16:43:00 2016
@@ -71,11 +71,11 @@
 // RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm -o - 
-finclude-default-header -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t -ftime-report %s 2>&1 | FileCheck --check-prefix=CHECK 
--check-prefix=CHECK-MOD %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm -o - -cl-std=CL2.0 
-finclude-default-header -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t -ftime-report %s 2>&1 | FileCheck 
--check-prefix=CHECK20 --check-prefix=CHECK-MOD %s
 // RUN: %clang_cc1 -triple amdgcn--amdhsa -emit-llvm -o - -cl-std=CL2.0  
-finclude-default-header -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t -ftime-report %s 2>&1 | FileCheck 
--check-prefix=CHECK20 --check-prefix=CHECK-MOD %s
-// RUN: chmod u-w %t/* 
+// RUN: chmod u-w %t 
 // RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm -o - 
-finclude-default-header -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t -ftime-report %s 2>&1 | FileCheck --check-prefix=CHECK 
--check-prefix=CHECK-MOD %s
 // RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm -o - -cl-std=CL2.0 
-finclude-default-header -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t -ftime-report %s 2>&1 | FileCheck 
--check-prefix=CHECK20 --check-prefix=CHECK-MOD %s
 // RUN: %clang_cc1 -triple amdgcn--amdhsa -emit-llvm -o - -cl-std=CL2.0 
-finclude-default-header -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t -ftime-report %s 2>&1 | FileCheck 
--check-prefix=CHECK20 --check-prefix=CHECK-MOD %s
-// RUN: chmod u+w %t/*
+// RUN: chmod u+w %t
 
 char f(char x) {
 #if __OPENCL_C_VERSION__ != CL_VERSION_2_0


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


Re: [PATCH] D18919: [Clang-tidy] Add check "modernize use using"

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

Please see PR28334.

I'm not sure if Krystyna has Bugzilla account, so I report problem here.


Repository:
  rL LLVM

http://reviews.llvm.org/D18919



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


[clang-tools-extra] r273941 - clang-rename: try to make ClassTestReplacements more reliable

2016-06-27 Thread Miklos Vajna via cfe-commits
Author: vmiklos
Date: Mon Jun 27 16:04:53 2016
New Revision: 273941

URL: http://llvm.org/viewvc/llvm-project?rev=273941=rev
Log:
clang-rename: try to make ClassTestReplacements more reliable

As it failed on e.g.

 with:

Trouble iterating over directory 
'/home/buildbots/ppc64be-clang-test/clang-ppc64be/stage1/tools/clang/tools/extra/test/clang-rename/Output':
 No such file or directory

A reliable way to trigger the problem locally is to run all clang-rename
tests in parallel in a loop:

for i in $(seq 1 100); do ~/git/llvm/workdir/bin/llvm-lit -v -j15 . || break; 
done

Change the test script to be more similar to test/Tooling/clang-check.cpp, that
way the above command doesn't fail for me anymore.

Modified:
clang-tools-extra/trunk/test/clang-rename/ClassTestReplacements.cpp

Modified: clang-tools-extra/trunk/test/clang-rename/ClassTestReplacements.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/ClassTestReplacements.cpp?rev=273941=273940=273941=diff
==
--- clang-tools-extra/trunk/test/clang-rename/ClassTestReplacements.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-rename/ClassTestReplacements.cpp Mon Jun 
27 16:04:53 2016
@@ -1,7 +1,8 @@
-// RUN: mkdir -p %T/fixes
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/fixes
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=225 -new-name=Hector -export-fixes=%T/fixes.yaml 
%t.cpp --
-// RUN: clang-apply-replacements %T
+// RUN: clang-rename -offset=256 -new-name=Hector 
-export-fixes=%t/fixes/clang-rename.yaml %t.cpp --
+// RUN: clang-apply-replacements %t
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 class Cla  // CHECK: class Hector
 {


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


Re: [PATCH] D20382: Add postorder support to RecursiveASTVisitor

2016-06-27 Thread Raphael Isemann via cfe-commits
teemperor updated this revision to Diff 62015.
teemperor added a comment.

- Stmt traversal is now always postorder, even if child statements don't 
support iterative traversal (thanks Richard).


http://reviews.llvm.org/D20382

Files:
  include/clang/AST/RecursiveASTVisitor.h
  unittests/AST/CMakeLists.txt
  unittests/AST/PostOrderASTVisitor.cpp

Index: unittests/AST/PostOrderASTVisitor.cpp
===
--- /dev/null
+++ unittests/AST/PostOrderASTVisitor.cpp
@@ -0,0 +1,123 @@
+//===- unittests/AST/PostOrderASTVisitor.cpp - Declaration printer tests --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file contains tests for the post-order traversing functionality
+// of RecursiveASTVisitor.
+//
+//===--===//
+
+#include "gtest/gtest.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/Tooling/Tooling.h"
+
+using namespace clang;
+
+namespace {
+
+  class RecordingVisitor
+: public RecursiveASTVisitor {
+
+bool VisitPostOrder;
+  public:
+explicit RecordingVisitor(bool VisitPostOrder)
+  : VisitPostOrder(VisitPostOrder) {
+}
+
+// List of visited nodes during traversal.
+std::vector VisitedNodes;
+
+bool shouldTraversePostOrder() const { return VisitPostOrder; }
+
+bool VisitBinaryOperator(BinaryOperator *Op) {
+  VisitedNodes.push_back(Op->getOpcodeStr());
+  return true;
+}
+
+bool VisitIntegerLiteral(IntegerLiteral *Lit) {
+  VisitedNodes.push_back(Lit->getValue().toString(10, false));
+  return true;
+}
+
+bool VisitVarDecl(VarDecl* D) {
+  VisitedNodes.push_back(D->getNameAsString());
+  return true;
+}
+
+bool VisitCXXMethodDecl(CXXMethodDecl *D) {
+  VisitedNodes.push_back(D->getQualifiedNameAsString());
+  return true;
+}
+
+bool VisitReturnStmt(Stmt *S) {
+  VisitedNodes.push_back("return");
+  return true;
+}
+
+bool VisitCXXRecordDecl(CXXRecordDecl *Declaration) {
+  VisitedNodes.push_back(Declaration->getQualifiedNameAsString());
+  return true;
+}
+
+bool VisitTemplateTypeParmType(TemplateTypeParmType *T) {
+  VisitedNodes.push_back(T->getDecl()->getQualifiedNameAsString());
+  return true;
+}
+  };
+
+}
+
+TEST(RecursiveASTVisitor, PostOrderTraversal) {
+  auto ASTUnit = tooling::buildASTFromCode(
+"template  class A {"
+"  class B {"
+"int foo() { while(4) { int i = 9; } return (1 + 3) + 2; }"
+"  };"
+"};"
+  );
+  auto TU = ASTUnit->getASTContext().getTranslationUnitDecl();
+  // We traverse the translation unit and store all
+  // visited nodes.
+  RecordingVisitor Visitor(true);
+  Visitor.TraverseTranslationUnitDecl(TU);
+
+  std::vector expected = {
+"4", "9", "i", "1", "3", "+", "2", "+", "return", "A::B::foo", "A::B", "A", "A::T"
+  };
+  // Compare the list of actually visited nodes
+  // with the expected list of visited nodes.
+  ASSERT_EQ(expected.size(), Visitor.VisitedNodes.size());
+  for (std::size_t I = 0; I < expected.size(); I++) {
+ASSERT_EQ(expected[I], Visitor.VisitedNodes[I]);
+  }
+}
+
+TEST(RecursiveASTVisitor, NoPostOrderTraversal) {
+  auto ASTUnit = tooling::buildASTFromCode(
+"template  class A {"
+"  class B {"
+"int foo() { return 1 + 2; }"
+"  };"
+"};"
+  );
+  auto TU = ASTUnit->getASTContext().getTranslationUnitDecl();
+  // We traverse the translation unit and store all
+  // visited nodes.
+  RecordingVisitor Visitor(false);
+  Visitor.TraverseTranslationUnitDecl(TU);
+
+  std::vector expected = {
+"A", "A::B", "A::B::foo", "return", "+", "1", "2", "A::T"
+  };
+  // Compare the list of actually visited nodes
+  // with the expected list of visited nodes.
+  ASSERT_EQ(expected.size(), Visitor.VisitedNodes.size());
+  for (std::size_t I = 0; I < expected.size(); I++) {
+ASSERT_EQ(expected[I], Visitor.VisitedNodes[I]);
+  }
+}
Index: unittests/AST/CMakeLists.txt
===
--- unittests/AST/CMakeLists.txt
+++ unittests/AST/CMakeLists.txt
@@ -14,6 +14,7 @@
   EvaluateAsRValueTest.cpp
   ExternalASTSourceTest.cpp
   NamedDeclPrinterTest.cpp
+  PostOrderASTVisitor.cpp
   SourceLocationTest.cpp
   StmtPrinterTest.cpp
   )
Index: include/clang/AST/RecursiveASTVisitor.h
===
--- include/clang/AST/RecursiveASTVisitor.h
+++ include/clang/AST/RecursiveASTVisitor.h
@@ -72,8 +72,8 @@
   return false;\
   } while (0)
 
-/// \brief A class that does preorder depth-first traversal on the
-/// entire Clang AST and visits 

[PATCH] D21767: Fix instantiation of friend function templates

2016-06-27 Thread Serge Pavlov via cfe-commits
sepavloff created this revision.
sepavloff added a reviewer: rsmith.
sepavloff added a subscriber: cfe-commits.

If a function template was defined in a friend declaration in a
template class, it was not instantiated because template definition
was not found.

http://reviews.llvm.org/D21767

Files:
  lib/AST/Decl.cpp
  lib/Sema/SemaTemplateInstantiate.cpp
  test/SemaTemplate/instantiate-friend-function.cpp

Index: test/SemaTemplate/instantiate-friend-function.cpp
===
--- /dev/null
+++ test/SemaTemplate/instantiate-friend-function.cpp
@@ -0,0 +1,63 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -S -triple i686-pc-linux-gnu -std=c++11 %s -o - | FileCheck %s
+// expected-no-diagnostics
+
+template void func_01(T *x);
+template
+struct C1 {
+  template friend void func_01(T *x) {}
+};
+
+C1 v1a;
+
+void use_01(int *x) {
+  func_01(x);
+}
+// CHECK: _Z7func_01IiEvPT_:
+
+
+template
+struct C2 {
+  template friend void func_02(T *x) {}
+};
+
+C2 v2a;
+template void func_02(T *x);
+
+void use_02(int *x) {
+  func_02(x);
+}
+// CHECK: _Z7func_02IiEvPT_:
+
+
+template
+struct C3a {
+  template friend void func_03(T *x) {}
+};
+template
+struct C3b {
+  template friend void func_03(T *x) {}
+};
+
+template void func_03(T *x) {}
+
+void use_03(int *x) {
+  func_03(x);
+}
+// CHECK: _Z7func_03IiEvPT_:
+
+
+template constexpr int func_04(const T x);
+template
+struct C4 {
+  template friend constexpr int func_04(const T x) { return sizeof(T); }
+};
+
+C4 v4;
+
+void use_04(int *x) {
+  static_assert(func_04(short(122)) == sizeof(short), "Invalid calculation");
+  static_assert(func_04(122) == sizeof(int), "Invalid calculation");
+  static_assert(func_04(122L) == sizeof(long), "Invalid calculation");
+  static_assert(func_04(122LL) == sizeof(long long), "Invalid calculation");
+}
Index: lib/Sema/SemaTemplateInstantiate.cpp
===
--- lib/Sema/SemaTemplateInstantiate.cpp
+++ lib/Sema/SemaTemplateInstantiate.cpp
@@ -164,6 +164,13 @@
 RelativeToPrimary = false;
 continue;
   }
+
+  if (Pattern && Pattern->getFriendObjectKind() &&
+  Function->getDeclContext()->isFileContext()) {
+Ctx = const_cast(Pattern->getLexicalDeclContext());
+RelativeToPrimary = false;
+continue;
+  }
 } else if (CXXRecordDecl *Rec = dyn_cast(Ctx)) {
   if (ClassTemplateDecl *ClassTemplate = Rec->getDescribedClassTemplate()) {
 QualType T = ClassTemplate->getInjectedClassNameSpecialization();
Index: lib/AST/Decl.cpp
===
--- lib/AST/Decl.cpp
+++ lib/AST/Decl.cpp
@@ -3152,19 +3152,13 @@
"template");
 return getPrimaryTemplate()->getTemplatedDecl();
   }
-  
+
   if (FunctionTemplateDecl *Primary = getPrimaryTemplate()) {
-while (Primary->getInstantiatedFromMemberTemplate()) {
-  // If we have hit a point where the user provided a specialization of
-  // this template, we're done looking.
-  if (Primary->isMemberSpecialization())
-break;
-  Primary = Primary->getInstantiatedFromMemberTemplate();
-}
-
+if (FunctionTemplateDecl *Def = Primary->getDefinition())
+  Primary = Def;
 return Primary->getTemplatedDecl();
-  } 
-
+  }
+
   return getInstantiatedFromMemberFunction();
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21453: Add support for attribute "overallocated"

2016-06-27 Thread Richard Smith via cfe-commits
rsmith requested changes to this revision.


Comment at: include/clang/Basic/AttrDocs.td:2073-2079
@@ +2072,9 @@
+  let Content = [{
+Use ``overallocated`` to indicate a class or union can have extra memory
+allocated at its end. This attribute is primarily used when we want
+__builtin_object_size to return a conservative value for the distance between
+the pointer and the end of the subobject the pointer points to.
+
+For example:
+
+.. code-block:: c++

No, this approach is not reasonable. Just changing what `__builtin_object_size` 
returns does not change the fact that code that tries to use bytes off the end 
of the struct would have undefined behavior. Lying in the result of 
`__builtin_object_size` is actively harmful.

Note that in your example below, you cannot access more than four `char`s 
through `((struct S*)p)->b`, despite the attribute, because the attribute does 
not affect the behaviour of the array member of `S`.

The right thing to do here would presumably be to have an attribute that makes 
an array be treated as a flexible array member, *even if* its bound is 
specified (and greater than 0). This would affect `__builtin_object_size`, 
sanitizers, alias analysis, diagnostics for flexible array members in the 
middle of a type, and so on.


http://reviews.llvm.org/D21453



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


Re: [PATCH] D14471: [AArch64] Fix a crash in driver

2016-06-27 Thread Akira Hatanaka via cfe-commits
ahatanak added a comment.

Sorry for not replying for a long time. I'll get back to this soon.


http://reviews.llvm.org/D14471



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


Re: [PATCH] D21111: Avoid accessing an invalid PresumedLoc

2016-06-27 Thread Ben Langmuir via cfe-commits
benlangmuir added a subscriber: benlangmuir.
benlangmuir added a comment.

LGTM


Repository:
  rL LLVM

http://reviews.llvm.org/D2



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


r273913 - Add simple, stupid, pattern-based fuzzer / reducer for modules bugs. I've

2016-06-27 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Jun 27 14:43:46 2016
New Revision: 273913

URL: http://llvm.org/viewvc/llvm-project?rev=273913=rev
Log:
Add simple, stupid, pattern-based fuzzer / reducer for modules bugs. I've
already used this to find and reduce quite a few bugs, and it works pretty well
if you can find the right patterns.

Added:
cfe/trunk/utils/modfuzz.py

Added: cfe/trunk/utils/modfuzz.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/modfuzz.py?rev=273913=auto
==
--- cfe/trunk/utils/modfuzz.py (added)
+++ cfe/trunk/utils/modfuzz.py Mon Jun 27 14:43:46 2016
@@ -0,0 +1,166 @@
+#! /usr/bin/env python
+
+# To use:
+#  1) Update the 'decls' list below with your fuzzing configuration.
+#  2) Run with the clang binary as the command-line argument.
+
+import random
+import subprocess
+import sys
+import os
+
+clang = sys.argv[1]
+none_opts = 0.3
+
+class Decl:
+  def __init__(self, text, depends=[], provides=[], conflicts=[]):
+self.text = text
+self.depends = depends
+self.provides = provides
+self.conflicts = conflicts
+
+  def valid(self, model):
+for i in self.depends:
+  if i not in model.decls:
+return False
+for i in self.conflicts:
+  if i in model.decls:
+return False
+return True
+
+  def apply(self, model, name):
+for i in self.provides:
+  model.decls[i] = True
+model.source += self.text % {'name': name}
+
+decls = [
+  Decl('struct X { int n; };\n', provides=['X'], conflicts=['X']),
+  Decl('static_assert(X{.n=1}.n == 1, "");\n', depends=['X']),
+  Decl('X %(name)s;\n', depends=['X']),
+]
+
+class FS:
+  def __init__(self):
+self.fs = {}
+self.prevfs = {}
+
+  def write(self, path, contents):
+self.fs[path] = contents
+
+  def done(self):
+for f, s in self.fs.items():
+  if self.prevfs.get(f) != s:
+f = file(f, 'w')
+f.write(s)
+f.close()
+
+for f in self.prevfs:
+  if f not in self.fs:
+os.remove(f)
+
+self.prevfs, self.fs = self.fs, {}
+
+fs = FS()
+
+class CodeModel:
+  def __init__(self):
+self.source = ''
+self.modules = {}
+self.decls = {}
+self.i = 0
+
+  def make_name(self):
+self.i += 1
+return 'n' + str(self.i)
+
+  def fails(self):
+fs.write('module.modulemap',
+  ''.join('module %s { header "%s.h" export * }\n' % (m, m)
+  for m in self.modules.keys()))
+
+for m, (s, _) in self.modules.items():
+  fs.write('%s.h' % m, s)
+
+fs.write('main.cc', self.source)
+fs.done()
+
+return subprocess.call([clang, '-std=c++11', '-c', '-fmodules', 'main.cc', 
'-o', '/dev/null']) != 0
+
+def generate():
+  model = CodeModel()
+  m = []
+
+  try:
+for d in mutations(model):
+  d(model)
+  m.append(d)
+if not model.fails():
+  return
+  except KeyboardInterrupt:
+print
+return True
+
+  sys.stdout.write('\nReducing:\n')
+  sys.stdout.flush()
+
+  try:
+while True:
+  assert m, 'got a failure with no steps; broken clang binary?'
+  i = random.choice(range(len(m)))
+  x = m[0:i] + m[i+1:]
+  m2 = CodeModel()
+  for d in x:
+d(m2)
+  if m2.fails():
+m = x
+model = m2
+  else:
+sys.stdout.write('.')
+sys.stdout.flush()
+  except KeyboardInterrupt:
+# FIXME: Clean out output directory first.
+model.fails()
+return model
+
+def choose(options):
+  while True:
+i = int(random.uniform(0, len(options) + none_opts))
+if i >= len(options):
+  break
+yield options[i]
+
+def mutations(model):
+  options = [create_module, add_top_level_decl]
+  for opt in choose(options):
+yield opt(model, options)
+
+def create_module(model, options):
+  n = model.make_name()
+  def go(model):
+model.modules[n] = (model.source, model.decls)
+(model.source, model.decls) = ('', {})
+  options += [lambda model, options: add_import(model, options, n)]
+  return go
+
+def add_top_level_decl(model, options):
+  n = model.make_name()
+  d = random.choice([decl for decl in decls if decl.valid(model)])
+  def go(model):
+if not d.valid(model):
+  return
+d.apply(model, n)
+  return go
+
+def add_import(model, options, module_name):
+  def go(model):
+if module_name in model.modules:
+  model.source += '#include "%s.h"\n' % module_name
+  model.decls.update(model.modules[module_name][1])
+  return go
+
+sys.stdout.write('Finding bug: ')
+while True:
+  if generate():
+break
+  sys.stdout.write('.')
+  sys.stdout.flush()


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


r273911 - [ExprConstant] Fix PR28314 - crash while evluating objectsize.

2016-06-27 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Mon Jun 27 14:40:41 2016
New Revision: 273911

URL: http://llvm.org/viewvc/llvm-project?rev=273911=rev
Log:
[ExprConstant] Fix PR28314 - crash while evluating objectsize.

This fixes a crash in code like:
```
struct A {
  struct B b;
  char c[1];
}

int foo(struct A* a) { return __builtin_object_size(a->c, 0); }
```

We wouldn't check whether the structs we were examining were invalid,
and getting the layout of an invalid struct is (unsurprisingly) A Bad
Thing. With this patch, we'll always return conservatively if we see an
invalid struct, since I'm assuming the presence of an invalid struct
means that our compilation failed (so having a conservative result isn't
such a big deal).

Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/Sema/builtin-object-size.c

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=273911=273910=273911=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Mon Jun 27 14:40:41 2016
@@ -6540,25 +6540,32 @@ static const Expr *ignorePointerCastsAnd
 ///
 /// Please note: this function is specialized for how __builtin_object_size
 /// views "objects".
+///
+/// If this encounters an invalid RecordDecl, it will always return true.
 static bool isDesignatorAtObjectEnd(const ASTContext , const LValue ) 
{
   assert(!LVal.Designator.Invalid);
 
-  auto IsLastFieldDecl = [](const FieldDecl *FD) {
-if (FD->getParent()->isUnion())
+  auto IsLastOrInvalidFieldDecl = [](const FieldDecl *FD, bool ) {
+const RecordDecl *Parent = FD->getParent();
+Invalid = Parent->isInvalidDecl();
+if (Invalid || Parent->isUnion())
   return true;
-const ASTRecordLayout  = Ctx.getASTRecordLayout(FD->getParent());
+const ASTRecordLayout  = Ctx.getASTRecordLayout(Parent);
 return FD->getFieldIndex() + 1 == Layout.getFieldCount();
   };
 
   auto  = LVal.getLValueBase();
   if (auto *ME = dyn_cast_or_null(Base.dyn_cast())) {
 if (auto *FD = dyn_cast(ME->getMemberDecl())) {
-  if (!IsLastFieldDecl(FD))
-return false;
+  bool Invalid;
+  if (!IsLastOrInvalidFieldDecl(FD, Invalid))
+return Invalid;
 } else if (auto *IFD = dyn_cast(ME->getMemberDecl())) {
-  for (auto *FD : IFD->chain())
-if (!IsLastFieldDecl(cast(FD)))
-  return false;
+  for (auto *FD : IFD->chain()) {
+bool Invalid;
+if (!IsLastOrInvalidFieldDecl(cast(FD), Invalid))
+  return Invalid;
+  }
 }
   }
 
@@ -6581,8 +6588,9 @@ static bool isDesignatorAtObjectEnd(cons
 return false;
   BaseType = CT->getElementType();
 } else if (auto *FD = getAsField(LVal.Designator.Entries[I])) {
-  if (!IsLastFieldDecl(FD))
-return false;
+  bool Invalid;
+  if (!IsLastOrInvalidFieldDecl(FD, Invalid))
+return Invalid;
   BaseType = FD->getType();
 } else {
   assert(getAsBaseClass(LVal.Designator.Entries[I]) != nullptr &&

Modified: cfe/trunk/test/Sema/builtin-object-size.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/builtin-object-size.c?rev=273911=273910=273911=diff
==
--- cfe/trunk/test/Sema/builtin-object-size.c (original)
+++ cfe/trunk/test/Sema/builtin-object-size.c Mon Jun 27 14:40:41 2016
@@ -52,3 +52,27 @@ void f6(void)
   __builtin___memccpy_chk (buf, b, '\0', sizeof(b), __builtin_object_size 
(buf, 0));
   __builtin___memccpy_chk (b, buf, '\0', sizeof(buf), __builtin_object_size 
(b, 0));  // expected-warning {{'__builtin___memccpy_chk' will always overflow 
destination buffer}}
 }
+
+int pr28314(void) {
+  struct {
+struct InvalidField a; // expected-error{{has incomplete type}} 
expected-note 3{{forward declaration of 'struct InvalidField'}}
+char b[0];
+  } *p;
+
+  struct {
+struct InvalidField a; // expected-error{{has incomplete type}}
+char b[1];
+  } *p2;
+
+  struct {
+struct InvalidField a; // expected-error{{has incomplete type}}
+char b[2];
+  } *p3;
+
+  int a = 0;
+  a += __builtin_object_size(>a, 0);
+  a += __builtin_object_size(p->b, 0);
+  a += __builtin_object_size(p2->b, 0);
+  a += __builtin_object_size(p3->b, 0);
+  return a;
+}


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


Re: [PATCH] D21676: clang-rename: add a -export-fixes option

2016-06-27 Thread Miklos Vajna via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL273910: clang-rename: add a -export-fixes option (authored 
by vmiklos).

Changed prior to commit:
  http://reviews.llvm.org/D21676?vs=61833=62004#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D21676

Files:
  clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp
  clang-tools-extra/trunk/test/clang-rename/ClassTestReplacements.cpp

Index: clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp
===
--- clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp
+++ clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp
@@ -32,6 +32,7 @@
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Refactoring.h"
+#include "clang/Tooling/ReplacementsYaml.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/Support/Host.h"
@@ -72,6 +73,12 @@
 "pl",
 cl::desc("Print the locations affected by renaming to stderr."),
 cl::cat(ClangRenameCategory));
+static cl::opt
+ExportFixes(
+"export-fixes",
+cl::desc("YAML file to store suggested fixes in."),
+cl::value_desc("filename"),
+cl::cat(ClangRenameCategory));
 
 #define CLANG_RENAME_VERSION "0.0.1"
 
@@ -126,6 +133,26 @@
   } else {
 res = Tool.run(Factory.get());
 
+if (!ExportFixes.empty()) {
+  std::error_code EC;
+  llvm::raw_fd_ostream OS(ExportFixes, EC, llvm::sys::fs::F_None);
+  if (EC) {
+llvm::errs() << "Error opening output file: " << EC.message() << '\n';
+exit(1);
+  }
+
+  // Export replacements.
+  tooling::TranslationUnitReplacements TUR;
+  const tooling::Replacements  = Tool.getReplacements();
+  TUR.Replacements.insert(TUR.Replacements.end(), Replacements.begin(),
+  Replacements.end());
+
+  yaml::Output YAML(OS);
+  YAML << TUR;
+  OS.close();
+  exit(0);
+}
+
 // Write every file to stdout. Right now we just barf the files without any
 // indication of which files start where, other than that we print the 
files
 // in the same order we see them.
Index: clang-tools-extra/trunk/test/clang-rename/ClassTestReplacements.cpp
===
--- clang-tools-extra/trunk/test/clang-rename/ClassTestReplacements.cpp
+++ clang-tools-extra/trunk/test/clang-rename/ClassTestReplacements.cpp
@@ -0,0 +1,11 @@
+// RUN: mkdir -p %T/fixes
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=225 -new-name=Hector -export-fixes=%T/fixes.yaml 
%t.cpp --
+// RUN: clang-apply-replacements %T
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+class Cla  // CHECK: class Hector
+{
+};
+
+// Use grep -FUbo 'Cla'  to get the correct offset of Cla when changing
+// this file.


Index: clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp
===
--- clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp
+++ clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp
@@ -32,6 +32,7 @@
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Refactoring.h"
+#include "clang/Tooling/ReplacementsYaml.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/Support/Host.h"
@@ -72,6 +73,12 @@
 "pl",
 cl::desc("Print the locations affected by renaming to stderr."),
 cl::cat(ClangRenameCategory));
+static cl::opt
+ExportFixes(
+"export-fixes",
+cl::desc("YAML file to store suggested fixes in."),
+cl::value_desc("filename"),
+cl::cat(ClangRenameCategory));
 
 #define CLANG_RENAME_VERSION "0.0.1"
 
@@ -126,6 +133,26 @@
   } else {
 res = Tool.run(Factory.get());
 
+if (!ExportFixes.empty()) {
+  std::error_code EC;
+  llvm::raw_fd_ostream OS(ExportFixes, EC, llvm::sys::fs::F_None);
+  if (EC) {
+llvm::errs() << "Error opening output file: " << EC.message() << '\n';
+exit(1);
+  }
+
+  // Export replacements.
+  tooling::TranslationUnitReplacements TUR;
+  const tooling::Replacements  = Tool.getReplacements();
+  TUR.Replacements.insert(TUR.Replacements.end(), Replacements.begin(),
+  Replacements.end());
+
+  yaml::Output YAML(OS);
+  YAML << TUR;
+  OS.close();
+  exit(0);
+}
+
 // Write every file to stdout. Right now we just barf the files without any
 // indication of which files start where, other than that we print the files
 // in the same order we see them.
Index: clang-tools-extra/trunk/test/clang-rename/ClassTestReplacements.cpp
===
--- clang-tools-extra/trunk/test/clang-rename/ClassTestReplacements.cpp
+++ 

[clang-tools-extra] r273910 - clang-rename: add a -export-fixes option

2016-06-27 Thread Miklos Vajna via cfe-commits
Author: vmiklos
Date: Mon Jun 27 14:34:47 2016
New Revision: 273910

URL: http://llvm.org/viewvc/llvm-project?rev=273910=rev
Log:
clang-rename: add a -export-fixes option

Use case: a class is declared in a header, and defined in two
translation units. clang-rename is asked to rename a class member that's
referenced in both translation units.

Using -i is not possible, as in case the first clang-rename invocation
touches the header, the second invocation will result in compilation
errors. Using -export-fixes handles this situation, each invocation can
work on the original source, and at the end the user can apply the
replacements with clang-apply-replacements.

Reviewers: klimek

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

Added:
clang-tools-extra/trunk/test/clang-rename/ClassTestReplacements.cpp
Modified:
clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp

Modified: clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp?rev=273910=273909=273910=diff
==
--- clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp Mon Jun 27 
14:34:47 2016
@@ -32,6 +32,7 @@
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Refactoring.h"
+#include "clang/Tooling/ReplacementsYaml.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/Support/Host.h"
@@ -72,6 +73,12 @@ PrintLocations(
 "pl",
 cl::desc("Print the locations affected by renaming to stderr."),
 cl::cat(ClangRenameCategory));
+static cl::opt
+ExportFixes(
+"export-fixes",
+cl::desc("YAML file to store suggested fixes in."),
+cl::value_desc("filename"),
+cl::cat(ClangRenameCategory));
 
 #define CLANG_RENAME_VERSION "0.0.1"
 
@@ -126,6 +133,26 @@ int main(int argc, const char **argv) {
   } else {
 res = Tool.run(Factory.get());
 
+if (!ExportFixes.empty()) {
+  std::error_code EC;
+  llvm::raw_fd_ostream OS(ExportFixes, EC, llvm::sys::fs::F_None);
+  if (EC) {
+llvm::errs() << "Error opening output file: " << EC.message() << '\n';
+exit(1);
+  }
+
+  // Export replacements.
+  tooling::TranslationUnitReplacements TUR;
+  const tooling::Replacements  = Tool.getReplacements();
+  TUR.Replacements.insert(TUR.Replacements.end(), Replacements.begin(),
+  Replacements.end());
+
+  yaml::Output YAML(OS);
+  YAML << TUR;
+  OS.close();
+  exit(0);
+}
+
 // Write every file to stdout. Right now we just barf the files without any
 // indication of which files start where, other than that we print the 
files
 // in the same order we see them.

Added: clang-tools-extra/trunk/test/clang-rename/ClassTestReplacements.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/ClassTestReplacements.cpp?rev=273910=auto
==
--- clang-tools-extra/trunk/test/clang-rename/ClassTestReplacements.cpp (added)
+++ clang-tools-extra/trunk/test/clang-rename/ClassTestReplacements.cpp Mon Jun 
27 14:34:47 2016
@@ -0,0 +1,11 @@
+// RUN: mkdir -p %T/fixes
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=225 -new-name=Hector -export-fixes=%T/fixes.yaml 
%t.cpp --
+// RUN: clang-apply-replacements %T
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+class Cla  // CHECK: class Hector
+{
+};
+
+// Use grep -FUbo 'Cla'  to get the correct offset of Cla when changing
+// this file.


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


Re: [PATCH] D21617: [OpenMP] Diagnose missing cases of statements between target and teams directives

2016-06-27 Thread Kelvin Li via cfe-commits
kkwli0 closed this revision.
kkwli0 added a comment.

At revision: 273908


http://reviews.llvm.org/D21617



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


r273908 - [OpenMP] Diagnose missing cases of statements between target and teams directives

2016-06-27 Thread Kelvin Li via cfe-commits
Author: kli
Date: Mon Jun 27 14:15:43 2016
New Revision: 273908

URL: http://llvm.org/viewvc/llvm-project?rev=273908=rev
Log:
[OpenMP] Diagnose missing cases of statements between target and teams 
directives

Clang fails to diagnose cases such as
#pragma omp target
  while(0) {
#pragma omp teams
{}
  }

A patch by David Sheinkman.


Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/nesting_of_regions.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=273908=273907=273908=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Mon Jun 27 14:15:43 2016
@@ -6537,6 +6537,9 @@ StmtResult Sema::ActOnOpenMPTargetDirect
   }
   assert(I != CS->body_end() && "Not found statement");
   S = *I;
+} else {
+  auto *OED = dyn_cast(S);
+  OMPTeamsFound = OED && isOpenMPTeamsDirective(OED->getDirectiveKind());
 }
 if (!OMPTeamsFound) {
   Diag(StartLoc, diag::err_omp_target_contains_not_only_teams);

Modified: cfe/trunk/test/OpenMP/nesting_of_regions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nesting_of_regions.cpp?rev=273908=273907=273908=diff
==
--- cfe/trunk/test/OpenMP/nesting_of_regions.cpp (original)
+++ cfe/trunk/test/OpenMP/nesting_of_regions.cpp Mon Jun 27 14:15:43 2016
@@ -2960,6 +2960,12 @@ void foo() {
 #pragma omp teams  // expected-note {{nested teams construct here}}
 ++a;
   }
+#pragma omp target // expected-error {{target construct with nested teams 
region contains statements outside of the teams construct}}
+  {
+while (0)  // expected-note {{statement outside teams construct here}}
+#pragma omp teams  // expected-note {{nested teams construct here}}
+++a;
+  }
 #pragma omp target
   {
 #pragma omp taskloop


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


Re: [PATCH] D20382: Add postorder support to RecursiveASTVisitor

2016-06-27 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: include/clang/AST/RecursiveASTVisitor.h:630-635
@@ -593,1 +629,8 @@
 
+  if (getDerived().shouldTraversePostOrder()) {
+for (auto Iter = ReverseLocalQueue.rbegin();
+ Iter != ReverseLocalQueue.rend(); ++Iter) {
+  TRY_TO(PostVisitStmt(*Iter));
+}
+  }
+

Does this really give a postorder traversal rather than some kind of postorder 
/ reverse preorder hybrid (based on whether we use data recursion or regular 
recursion for different parts of the graph)?

I would expect the right way to handle this would be to call `PostVisitStmt` 
from the `if (Visited)` branch above, where we call `dataTraverseStmtPost`.


http://reviews.llvm.org/D20382



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


Re: [PATCH] D21718: [libcxx] [test] Make move_assign_noexcept.pass.cpp tests more portable.

2016-06-27 Thread Stephan T. Lavavej via cfe-commits
STL_MSFT updated this revision to Diff 62003.
STL_MSFT added a comment.

Population, 9 billion. All test macros.


http://reviews.llvm.org/D21718

Files:
  test/std/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp
  
test/std/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp
  
test/std/containers/associative/multiset/multiset.cons/move_assign_noexcept.pass.cpp
  test/std/containers/associative/set/set.cons/move_assign_noexcept.pass.cpp
  test/std/containers/sequences/deque/deque.cons/move_assign_noexcept.pass.cpp
  
test/std/containers/sequences/forwardlist/forwardlist.cons/move_assign_noexcept.pass.cpp
  test/std/containers/sequences/list/list.cons/move_assign_noexcept.pass.cpp
  test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp
  
test/std/containers/unord/unord.map/unord.map.cnstr/move_assign_noexcept.pass.cpp
  
test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_assign_noexcept.pass.cpp
  
test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_assign_noexcept.pass.cpp
  
test/std/containers/unord/unord.set/unord.set.cnstr/move_assign_noexcept.pass.cpp

Index: test/std/containers/unord/unord.set/unord.set.cnstr/move_assign_noexcept.pass.cpp
===
--- test/std/containers/unord/unord.set/unord.set.cnstr/move_assign_noexcept.pass.cpp
+++ test/std/containers/unord/unord.set/unord.set.cnstr/move_assign_noexcept.pass.cpp
@@ -22,6 +22,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "MoveOnly.h"
 #include "test_allocator.h"
 
@@ -56,7 +57,7 @@
 {
 typedef std::unordered_set C;
-static_assert(std::is_nothrow_move_assignable::value, "");
+LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable::value, "");
 }
 {
 typedef std::unordered_set C;
Index: test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_assign_noexcept.pass.cpp
===
--- test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_assign_noexcept.pass.cpp
+++ test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_assign_noexcept.pass.cpp
@@ -22,6 +22,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "MoveOnly.h"
 #include "test_allocator.h"
 
@@ -56,7 +57,7 @@
 {
 typedef std::unordered_multiset C;
-static_assert(std::is_nothrow_move_assignable::value, "");
+LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable::value, "");
 }
 {
 typedef std::unordered_multiset C;
Index: test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_assign_noexcept.pass.cpp
===
--- test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_assign_noexcept.pass.cpp
+++ test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_assign_noexcept.pass.cpp
@@ -22,6 +22,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "MoveOnly.h"
 #include "test_allocator.h"
 
@@ -56,7 +57,7 @@
 {
 typedef std::unordered_multimap> C;
-static_assert(std::is_nothrow_move_assignable::value, "");
+LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable::value, "");
 }
 {
 typedef std::unordered_multimap C;
Index: test/std/containers/unord/unord.map/unord.map.cnstr/move_assign_noexcept.pass.cpp
===
--- test/std/containers/unord/unord.map/unord.map.cnstr/move_assign_noexcept.pass.cpp
+++ test/std/containers/unord/unord.map/unord.map.cnstr/move_assign_noexcept.pass.cpp
@@ -22,6 +22,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "MoveOnly.h"
 #include "test_allocator.h"
 
@@ -56,7 +57,7 @@
 {
 typedef std::unordered_map> C;
-static_assert(std::is_nothrow_move_assignable::value, "");
+LIBCPP_STATIC_ASSERT(std::is_nothrow_move_assignable::value, "");
 }
 {
 typedef std::unordered_map C;
Index: test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp
===
--- test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp
+++ test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp
@@ -21,6 +21,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "test_allocator.h"
 
 template 
@@ -60,28 +61,28 @@
 {
 {
   

Re: [PATCH] D21716: [libcxx] [test] Make move_noexcept.pass.cpp tests more portable.

2016-06-27 Thread Stephan T. Lavavej via cfe-commits
STL_MSFT updated this revision to Diff 62002.
STL_MSFT added a comment.

Test macros for the test macro throne!


http://reviews.llvm.org/D21716

Files:
  test/std/containers/associative/map/map.cons/move_noexcept.pass.cpp
  test/std/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp
  test/std/containers/associative/multiset/multiset.cons/move_noexcept.pass.cpp
  test/std/containers/associative/set/set.cons/move_noexcept.pass.cpp
  test/std/containers/container.adaptors/queue/queue.cons/move_noexcept.pass.cpp
  test/std/containers/container.adaptors/stack/stack.cons/move_noexcept.pass.cpp
  test/std/containers/sequences/deque/deque.cons/move_noexcept.pass.cpp
  
test/std/containers/sequences/forwardlist/forwardlist.cons/move_noexcept.pass.cpp
  test/std/containers/sequences/list/list.cons/move_noexcept.pass.cpp
  test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp
  test/std/containers/unord/unord.map/unord.map.cnstr/move_noexcept.pass.cpp
  
test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_noexcept.pass.cpp
  
test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_noexcept.pass.cpp
  test/std/containers/unord/unord.set/unord.set.cnstr/move_noexcept.pass.cpp

Index: test/std/containers/unord/unord.set/unord.set.cnstr/move_noexcept.pass.cpp
===
--- test/std/containers/unord/unord.set/unord.set.cnstr/move_noexcept.pass.cpp
+++ test/std/containers/unord/unord.set/unord.set.cnstr/move_noexcept.pass.cpp
@@ -20,6 +20,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "MoveOnly.h"
 #include "test_allocator.h"
 
@@ -43,17 +44,17 @@
 {
 {
 typedef std::unordered_set C;
-static_assert(std::is_nothrow_move_constructible::value, "");
+LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible::value, "");
 }
 {
 typedef std::unordered_set C;
-static_assert(std::is_nothrow_move_constructible::value, "");
+LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible::value, "");
 }
 {
 typedef std::unordered_set C;
-static_assert(std::is_nothrow_move_constructible::value, "");
+LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible::value, "");
 }
 {
 typedef std::unordered_set C;
Index: test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_noexcept.pass.cpp
===
--- test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_noexcept.pass.cpp
+++ test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_noexcept.pass.cpp
@@ -20,6 +20,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "MoveOnly.h"
 #include "test_allocator.h"
 
@@ -43,17 +44,17 @@
 {
 {
 typedef std::unordered_multiset C;
-static_assert(std::is_nothrow_move_constructible::value, "");
+LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible::value, "");
 }
 {
 typedef std::unordered_multiset C;
-static_assert(std::is_nothrow_move_constructible::value, "");
+LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible::value, "");
 }
 {
 typedef std::unordered_multiset C;
-static_assert(std::is_nothrow_move_constructible::value, "");
+LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible::value, "");
 }
 {
 typedef std::unordered_multiset C;
Index: test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_noexcept.pass.cpp
===
--- test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_noexcept.pass.cpp
+++ test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_noexcept.pass.cpp
@@ -20,6 +20,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "MoveOnly.h"
 #include "test_allocator.h"
 
@@ -43,17 +44,17 @@
 {
 {
 typedef std::unordered_multimap C;
-static_assert(std::is_nothrow_move_constructible::value, "");
+LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible::value, "");
 }
 {
 typedef std::unordered_multimap> C;
-static_assert(std::is_nothrow_move_constructible::value, "");
+LIBCPP_STATIC_ASSERT(std::is_nothrow_move_constructible::value, "");
 }
 {
 typedef std::unordered_multimap

Re: [PATCH] D21717: [libcxx] [test] Make dtor_noexcept.pass.cpp tests more portable.

2016-06-27 Thread Stephan T. Lavavej via cfe-commits
STL_MSFT updated this revision to Diff 62001.
STL_MSFT added a comment.

Adding test_macros.h as requested.


http://reviews.llvm.org/D21717

Files:
  test/std/containers/associative/map/map.cons/dtor_noexcept.pass.cpp
  test/std/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp
  test/std/containers/associative/multiset/multiset.cons/dtor_noexcept.pass.cpp
  test/std/containers/associative/set/set.cons/dtor_noexcept.pass.cpp
  test/std/containers/sequences/deque/deque.cons/dtor_noexcept.pass.cpp
  
test/std/containers/sequences/forwardlist/forwardlist.cons/dtor_noexcept.pass.cpp
  test/std/containers/sequences/list/list.cons/dtor_noexcept.pass.cpp
  test/std/containers/sequences/vector.bool/dtor_noexcept.pass.cpp
  test/std/containers/sequences/vector/vector.cons/dtor_noexcept.pass.cpp
  test/std/containers/unord/unord.map/unord.map.cnstr/dtor_noexcept.pass.cpp
  
test/std/containers/unord/unord.multimap/unord.multimap.cnstr/dtor_noexcept.pass.cpp
  
test/std/containers/unord/unord.multiset/unord.multiset.cnstr/dtor_noexcept.pass.cpp
  test/std/containers/unord/unord.set/unord.set.cnstr/dtor_noexcept.pass.cpp
  test/std/strings/basic.string/string.cons/dtor_noexcept.pass.cpp

Index: test/std/strings/basic.string/string.cons/dtor_noexcept.pass.cpp
===
--- test/std/strings/basic.string/string.cons/dtor_noexcept.pass.cpp
+++ test/std/strings/basic.string/string.cons/dtor_noexcept.pass.cpp
@@ -16,6 +16,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "test_allocator.h"
 
 template 
@@ -38,6 +39,6 @@
 }
 {
 typedef std::basic_string C;
-static_assert(!std::is_nothrow_destructible::value, "");
+LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible::value, "");
 }
 }
Index: test/std/containers/unord/unord.set/unord.set.cnstr/dtor_noexcept.pass.cpp
===
--- test/std/containers/unord/unord.set/unord.set.cnstr/dtor_noexcept.pass.cpp
+++ test/std/containers/unord/unord.set/unord.set.cnstr/dtor_noexcept.pass.cpp
@@ -16,6 +16,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "MoveOnly.h"
 #include "test_allocator.h"
 
@@ -54,11 +55,11 @@
 }
 {
 typedef std::unordered_set C;
-static_assert(!std::is_nothrow_destructible::value, "");
+LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible::value, "");
 }
 {
 typedef std::unordered_set C;
-static_assert(!std::is_nothrow_destructible::value, "");
+LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible::value, "");
 }
 }
Index: test/std/containers/unord/unord.multiset/unord.multiset.cnstr/dtor_noexcept.pass.cpp
===
--- test/std/containers/unord/unord.multiset/unord.multiset.cnstr/dtor_noexcept.pass.cpp
+++ test/std/containers/unord/unord.multiset/unord.multiset.cnstr/dtor_noexcept.pass.cpp
@@ -16,6 +16,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "MoveOnly.h"
 #include "test_allocator.h"
 
@@ -54,11 +55,11 @@
 }
 {
 typedef std::unordered_multiset C;
-static_assert(!std::is_nothrow_destructible::value, "");
+LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible::value, "");
 }
 {
 typedef std::unordered_multiset C;
-static_assert(!std::is_nothrow_destructible::value, "");
+LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible::value, "");
 }
 }
Index: test/std/containers/unord/unord.multimap/unord.multimap.cnstr/dtor_noexcept.pass.cpp
===
--- test/std/containers/unord/unord.multimap/unord.multimap.cnstr/dtor_noexcept.pass.cpp
+++ test/std/containers/unord/unord.multimap/unord.multimap.cnstr/dtor_noexcept.pass.cpp
@@ -16,6 +16,7 @@
 #include 
 #include 
 
+#include "test_macros.h"
 #include "MoveOnly.h"
 #include "test_allocator.h"
 
@@ -54,11 +55,11 @@
 }
 {
 typedef std::unordered_multimap C;
-static_assert(!std::is_nothrow_destructible::value, "");
+LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible::value, "");
 }
 {
 typedef std::unordered_multimap C;
-static_assert(!std::is_nothrow_destructible::value, "");
+LIBCPP_STATIC_ASSERT(!std::is_nothrow_destructible::value, "");
 }
 }
Index: test/std/containers/unord/unord.map/unord.map.cnstr/dtor_noexcept.pass.cpp
===
--- 

Re: [PATCH] D21766: [codeview][clang] Added support for unnamed bitfield type.

2016-06-27 Thread David Majnemer via cfe-commits
majnemer added a comment.

As I said in the other differential, I do not think this is the right approach.
We should use the extraData for the bitfield member to indicate the offset of 
the storage unit.


http://reviews.llvm.org/D21766



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


[PATCH] D21766: [codeview][clang] Added support for unnamed bitfield type.

2016-06-27 Thread Amjad Aboud via cfe-commits
aaboud created this revision.
aaboud added reviewers: rnk, majnemer.
aaboud added subscribers: cfe-commits, bwyma.

Allow creating DI metadata for non-zero width unnamed bitfield members when 
emitting CodeView.
This is needed for patch D21489.

http://reviews.llvm.org/D21766

Files:
  lib/CodeGen/CGDebugInfo.cpp

Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -1010,14 +1010,20 @@
 const RecordDecl *RD) {
   StringRef name = field->getName();
   QualType type = field->getType();
+  bool EmitCodeView = CGM.getCodeGenOpts().EmitCodeView;
 
   // Ignore unnamed fields unless they're anonymous structs/unions.
   if (name.empty() && !type->isRecordType())
-return;
+// Do not ignore anonymous bitfield when emitting CodeView.
+if(!EmitCodeView || !field->isBitField())
+  return;
 
   uint64_t SizeInBitsOverride = 0;
   if (field->isBitField()) {
 SizeInBitsOverride = field->getBitWidthValue(CGM.getContext());
+if (!SizeInBitsOverride && name.empty())
+  // Ignore unnamed 0-width bitfield.
+  return;
 assert(SizeInBitsOverride && "found named 0-width bitfield");
   }
 


Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -1010,14 +1010,20 @@
 const RecordDecl *RD) {
   StringRef name = field->getName();
   QualType type = field->getType();
+  bool EmitCodeView = CGM.getCodeGenOpts().EmitCodeView;
 
   // Ignore unnamed fields unless they're anonymous structs/unions.
   if (name.empty() && !type->isRecordType())
-return;
+// Do not ignore anonymous bitfield when emitting CodeView.
+if(!EmitCodeView || !field->isBitField())
+  return;
 
   uint64_t SizeInBitsOverride = 0;
   if (field->isBitField()) {
 SizeInBitsOverride = field->getBitWidthValue(CGM.getContext());
+if (!SizeInBitsOverride && name.empty())
+  // Ignore unnamed 0-width bitfield.
+  return;
 assert(SizeInBitsOverride && "found named 0-width bitfield");
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D5896: Emit more intrinsics for builtin functions

2016-06-27 Thread Matt Arsenault via cfe-commits
arsenm added a comment.

ping


http://reviews.llvm.org/D5896



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


Re: [PATCH] D11360: Proposed patch to prevent the creation of empty (forwarding) blocks resulting from nested ifs.

2016-06-27 Thread Wolfgang Pieb via cfe-commits
wolfgangp updated this revision to Diff 61987.
wolfgangp added a comment.
Herald added a subscriber: mehdi_amini.

Updating this patch against a recent revision.


http://reviews.llvm.org/D11360

Files:
  lib/CodeGen/CGStmt.cpp
  test/CodeGen/forwarding-blocks-if.c

Index: test/CodeGen/forwarding-blocks-if.c
===
--- test/CodeGen/forwarding-blocks-if.c
+++ test/CodeGen/forwarding-blocks-if.c
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+// Check that no empty blocks are generated for nested ifs.
+
+extern void func();
+
+int f0(int val)
+{
+if (val == 0)
+{
+func();
+}
+else if (val == 1)
+{
+func();
+}
+return 0;
+}
+
+// CHECK-LABEL: define i32 @f0
+// CHECK: call void {{.*}} @func
+// CHECK: call void {{.*}} @func
+// CHECK: br label %[[RETBLOCK1:[^ ]*]]
+// CHECK: [[RETBLOCK1]]:
+// CHECK-NOT: br label
+// CHECK: ret i32
+
+
+int f1(int val, int g)
+{
+if (val == 0)
+if (g == 1)
+{
+func();
+}
+return 0;
+}
+
+// CHECK-LABEL: define i32 @f1
+// CHECK: call void {{.*}} @func
+// CHECK: br label %[[RETBLOCK2:[^ ]*]]
+// CHECK: [[RETBLOCK2]]:
+// CHECK-NOT: br label
+// CHECK: ret i32
Index: lib/CodeGen/CGStmt.cpp
===
--- lib/CodeGen/CGStmt.cpp
+++ lib/CodeGen/CGStmt.cpp
@@ -606,7 +606,12 @@
 RunCleanupsScope ThenScope(*this);
 EmitStmt(S.getThen());
   }
-  EmitBranch(ContBlock);
+  {
+auto CurBlock = Builder.GetInsertBlock();
+EmitBranch(ContBlock);
+if (CurBlock)
+  SimplifyForwardingBlocks(CurBlock); 
+  }
 
   // Emit the 'else' code if present.
   if (const Stmt *Else = S.getElse()) {
@@ -622,7 +627,10 @@
 {
   // There is no need to emit line number for an unconditional branch.
   auto NL = ApplyDebugLocation::CreateEmpty(*this);
+  auto CurBlock = Builder.GetInsertBlock();
   EmitBranch(ContBlock);
+  if (CurBlock)
+SimplifyForwardingBlocks(CurBlock); 
 }
   }
 


Index: test/CodeGen/forwarding-blocks-if.c
===
--- test/CodeGen/forwarding-blocks-if.c
+++ test/CodeGen/forwarding-blocks-if.c
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+// Check that no empty blocks are generated for nested ifs.
+
+extern void func();
+
+int f0(int val)
+{
+if (val == 0)
+{
+func();
+}
+else if (val == 1)
+{
+func();
+}
+return 0;
+}
+
+// CHECK-LABEL: define i32 @f0
+// CHECK: call void {{.*}} @func
+// CHECK: call void {{.*}} @func
+// CHECK: br label %[[RETBLOCK1:[^ ]*]]
+// CHECK: [[RETBLOCK1]]:
+// CHECK-NOT: br label
+// CHECK: ret i32
+
+
+int f1(int val, int g)
+{
+if (val == 0)
+if (g == 1)
+{
+func();
+}
+return 0;
+}
+
+// CHECK-LABEL: define i32 @f1
+// CHECK: call void {{.*}} @func
+// CHECK: br label %[[RETBLOCK2:[^ ]*]]
+// CHECK: [[RETBLOCK2]]:
+// CHECK-NOT: br label
+// CHECK: ret i32
Index: lib/CodeGen/CGStmt.cpp
===
--- lib/CodeGen/CGStmt.cpp
+++ lib/CodeGen/CGStmt.cpp
@@ -606,7 +606,12 @@
 RunCleanupsScope ThenScope(*this);
 EmitStmt(S.getThen());
   }
-  EmitBranch(ContBlock);
+  {
+auto CurBlock = Builder.GetInsertBlock();
+EmitBranch(ContBlock);
+if (CurBlock)
+  SimplifyForwardingBlocks(CurBlock); 
+  }
 
   // Emit the 'else' code if present.
   if (const Stmt *Else = S.getElse()) {
@@ -622,7 +627,10 @@
 {
   // There is no need to emit line number for an unconditional branch.
   auto NL = ApplyDebugLocation::CreateEmpty(*this);
+  auto CurBlock = Builder.GetInsertBlock();
   EmitBranch(ContBlock);
+  if (CurBlock)
+SimplifyForwardingBlocks(CurBlock); 
 }
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21508: Make friend function template definition available if class is instantiated.

2016-06-27 Thread Serge Pavlov via cfe-commits
sepavloff updated this revision to Diff 61989.
sepavloff added a comment.

Make more correct template function definition lookup

Lookup is made recursive to cover more cases.


http://reviews.llvm.org/D21508

Files:
  include/clang/AST/DeclTemplate.h
  lib/AST/DeclTemplate.cpp
  lib/Sema/SemaDecl.cpp
  test/SemaCXX/friend2.cpp

Index: test/SemaCXX/friend2.cpp
===
--- test/SemaCXX/friend2.cpp
+++ test/SemaCXX/friend2.cpp
@@ -91,6 +91,73 @@
   friend int func10(int);  // expected-error{{functions that differ only in their return type cannot be overloaded}}
 };
 
+// Case of template friend functions.
+
+template void func_11(T *x);
+template
+struct C11a {
+  template friend void func_11(T *x) {}
+};
+template
+struct C11b {
+  template friend void func_11(T *x) {}
+};
+
+
+template inline void func_12(T *x) {}
+template
+struct C12a {
+  template friend void func_12(T *x) {}
+};
+template
+struct C12b {
+  template friend void func_12(T *x) {}
+};
+
+
+template
+struct C13a {
+  template friend void func_13(T *x) {}
+};
+template
+struct C13b {
+  template friend void func_13(T *x) {}
+};
+
+
+template inline void func_14(T *x) {}  // expected-note{{previous definition is here}}
+template
+struct C14 {
+  template friend void func_14(T *x) {} // expected-error{{redefinition of 'func_14'}}
+};
+
+C14 v14;  // expected-note{{in instantiation of template class 'C14' requested here}}
+
+
+template inline void func_15(T *x);
+template
+struct C15a {
+  template friend void func_15(T *x) {} // expected-note{{previous definition is here}}
+};
+template
+struct C15b {
+  template friend void func_15(T *x) {} // expected-error{{redefinition of 'func_15'}}
+};
+
+C15a v15a;
+C15b v15b;  // expected-note{{in instantiation of template class 'C15b' requested here}}
+
+
+template void func_16(T *x);
+template
+struct C16 {
+  template friend void func_16(T *x) {}  // expected-error{{redefinition of 'func_16'}}
+ // expected-note@-1{{previous definition is here}}
+};
+
+C16 v16a;
+C16 v16b;  //expected-note{{in instantiation of template class 'C16' requested here}}
+
 
 namespace pr22307 {
 
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -8807,10 +8807,23 @@
 
 if (FunctionTemplateDecl *OldTemplateDecl
   = dyn_cast(OldDecl)) {
-  NewFD->setPreviousDeclaration(OldTemplateDecl->getTemplatedDecl());
   FunctionTemplateDecl *NewTemplateDecl
 = NewFD->getDescribedFunctionTemplate();
   assert(NewTemplateDecl && "Template/non-template mismatch");
+  Redeclaration = shouldLinkDependentDeclWithPrevious(NewTemplateDecl,
+  OldTemplateDecl);
+  if (Redeclaration &&
+  (NewTemplateDecl->getFriendObjectKind() != Decl::FOK_None ||
+   OldTemplateDecl->getFriendObjectKind() != Decl::FOK_None))
+if (FunctionTemplateDecl *NewDef = NewTemplateDecl->getDefinition())
+  if (FunctionTemplateDecl *OldDef = OldTemplateDecl->getDefinition()) {
+Diag(NewDef->getLocation(), diag::err_redefinition)
+<< NewDef->getDeclName();
+Diag(OldDef->getLocation(), diag::note_previous_definition);
+Redeclaration = false;
+  }
+  if (Redeclaration)
+NewFD->setPreviousDeclaration(OldTemplateDecl->getTemplatedDecl());
   if (CXXMethodDecl *Method
 = dyn_cast(NewTemplateDecl->getTemplatedDecl())) {
 Method->setAccess(OldTemplateDecl->getAccess());
Index: lib/AST/DeclTemplate.cpp
===
--- lib/AST/DeclTemplate.cpp
+++ lib/AST/DeclTemplate.cpp
@@ -289,6 +289,34 @@
   }
 }
 
+/// \brief Returns definition for this function template of null if no
+/// definition found.
+///
+/// This function scans not only redeclarations but also templates from which
+/// these declarations are instantiated, if the function template was
+/// instantiated from another template.
+///
+FunctionTemplateDecl *FunctionTemplateDecl::getDefinition() const {
+  for (auto *R : redecls()) {
+FunctionTemplateDecl *F = cast(R);
+if (F->isThisDeclarationADefinition())
+  return F;
+
+// If template does not have a body, probably it is instantiated from
+// another template, which is not used yet.
+if (FunctionTemplateDecl *P = F->getInstantiatedFromMemberTemplate()) {
+  // If we have hit a point where the user provided a specialization of
+  // this template, we're done looking.
+  if (F->isMemberSpecialization())
+return F;
+  if (FunctionTemplateDecl *Def = P->getDefinition())
+return Def;
+}
+  }
+
+  return nullptr;
+}
+
 llvm::FoldingSetVector &
 FunctionTemplateDecl::getSpecializations() const {
   

Re: [PATCH] D21392: [clang-tidy] Enhance redundant-expression check

2016-06-27 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 61984.
etienneb marked 12 inline comments as done.
etienneb added a comment.

address comments


http://reviews.llvm.org/D21392

Files:
  clang-tidy/misc/RedundantExpressionCheck.cpp
  clang-tidy/misc/RedundantExpressionCheck.h
  test/clang-tidy/misc-redundant-expression.cpp

Index: test/clang-tidy/misc-redundant-expression.cpp
===
--- test/clang-tidy/misc-redundant-expression.cpp
+++ test/clang-tidy/misc-redundant-expression.cpp
@@ -1,4 +1,6 @@
-// RUN: %check_clang_tidy %s misc-redundant-expression %t
+// RUN: %check_clang_tidy %s misc-redundant-expression %t -- -- -std=c++11
+
+typedef __INT64_TYPE__ I64;
 
 struct Point {
   int x;
@@ -64,7 +66,7 @@
 
   if ( + "dummy" == + "dummy") return 1;
   // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: both side of operator are equivalent
-  if (L"abc" == L"abc") return 1; 
+  if (L"abc" == L"abc") return 1;
   // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: both side of operator are equivalent
 
   if (foo(0) - 2 < foo(0) - 2) return 1;
@@ -82,7 +84,7 @@
 
 int Valid(int X, int Y) {
   if (X != Y) return 1;
-  if (X == X + 0) return 1;
+  if (X == Y + 0) return 1;
   if (P.x == P.y) return 1;
   if (P.a[P.x] < P.a[P.y]) return 1;
   if (P.a[0] < P.a[1]) return 1;
@@ -160,3 +162,324 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: both side of overloaded operator are equivalent
 }
 void TestTemplate() { TemplateCheck(); }
+
+int TestArithmetic(int X, int Y) {
+  if (X + 1 == X) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always false
+  if (X + 1 != X) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always true
+  if (X - 1 == X) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always false
+  if (X - 1 != X) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always true
+
+  if (X + 1LL == X) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: logical expression is always false
+  if (X + 1ULL == X) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: logical expression is always false
+
+  if (X == X + 1) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: logical expression is always false
+  if (X != X + 1) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: logical expression is always true
+  if (X == X - 1) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: logical expression is always false
+  if (X != X - 1) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: logical expression is always true
+
+  if (X != X - 1U) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: logical expression is always true
+  if (X != X - 1LL) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: logical expression is always true
+
+  if ((X+X) != (X+X) - 1) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always true
+
+  if (X + 1 == X + 2) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always false
+  if (X + 1 != X + 2) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always true
+
+  if (X - 1 == X - 2) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always false
+  if (X - 1 != X - 2) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always true
+
+  if (X + 1 == X - -1) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always true
+  if (X + 1 != X - -1) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always false
+  if (X + 1 == X - -2) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always false
+  if (X + 1 != X - -2) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always true
+
+  if (X + 1 == X - (~0)) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always true
+  if (X + 1 == X - (~0U)) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always true
+  if (X + 1 == X - (~0ULL)) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always true
+
+  // Should not match.
+  if (X + 0.5 == X) return 1;
+  if (X + 1 == Y) return 1;
+  if (X + 1 == Y + 1) return 1;
+  if (X + 1 == Y + 2) return 1;
+
+  return 0;
+}
+
+int TestBitwise(int X) {
+  if ((X & 0xFF) == 0xF00) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: logical expression is always false
+  if ((X & 0xFF) != 0xF00) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: logical expression is always true
+  if ((X | 0xFF) == 0xF00) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: logical expression is always false
+  if ((X | 0xFF) != 0xF00) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: logical expression is always true
+
+  if 

Re: [PATCH] D21367: AMDGPU: Set amdgpu_kernel calling convention for OpenCL kernels.

2016-06-27 Thread Nikolay Haustov via cfe-commits
nhaustov added a comment.

In http://reviews.llvm.org/D21367#467894, @yaxunl wrote:

> I am wondering what's the difference between this calling convention and 
> spir_kernel.


spir_kernel has only effect and was created only for SPIR target. In theory it 
could perhaps be reused for AMDGPU target, however it seems not very clear to 
me.

In http://reviews.llvm.org/D21367#468057, @yaxunl wrote:

> In http://reviews.llvm.org/D21367#467982, @nhaustov wrote:
>
> > In http://reviews.llvm.org/D21367#467894, @yaxunl wrote:
> >
> > > I am wondering what's the difference between this calling convention and 
> > > spir_kernel.
> >
> >
> > spir_kernel has only effect and was created only for SPIR target. In theory 
> > it could perhaps be reused for AMDGPU target, however it seems not very 
> > clear to me.
>
>
> If the new calling convention is to indicate a function is an OpenCL kernel, 
> then it has exactly the same meaning as spir_kernel. Can we just use it in 
> AMDGPU target?


This looks like a hack to me. Calling conventions in LLVM IR are really target 
specific. spir_kernel really doesn't make sense for anything other than SPIR.

Maybe we can use the fact that calling conventions are separate in AST and in 
LLVM IR. So in AST maybe we can have opencl_kernel and in LLVM it can map to 
spir_kernel for SPIR and amdgpu_kernel for AMDGPU.


http://reviews.llvm.org/D21367



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


Re: [PATCH] D21453: Add support for attribute "overallocated"

2016-06-27 Thread Aaron Ballman via cfe-commits
On Mon, Jun 27, 2016 at 2:07 PM, Duncan P. N. Exon Smith
 wrote:
>
>> On 2016-Jun-27, at 11:02, Aaron Ballman  wrote:
>>
>> aaron.ballman requested changes to this revision.
>> aaron.ballman added a comment.
>> This revision now requires changes to proceed.
>>
>> Missing Sema tests for the attribute.
>>
>>
>> 
>> Comment at: include/clang/Basic/AttrDocs.td:2082
>> @@ +2081,3 @@
>> +
>> +struct S {
>> +  char a[4], char b[4];
>> 
>> I *think* this code example will give doxygen fits because it's not 
>> indented; have you tried generating the docs locally? You can test this by 
>> running: `clang-tblgen -gen-attr-docs -I E:\llvm\llvm\tools\clang\include 
>> E:\llvm\llvm\tools\clang\include\clang\Basic\Attr.td -o 
>> E:\llvm\llvm\tools\clang\docs\AttributeReference.rst` and then building the 
>> docs as normal. Note, you will have to revert AttributeReference.rst when 
>> you are done.
>>
>> 
>> Comment at: lib/AST/ExprConstant.cpp:1051-1057
>> @@ -1050,4 +1050,9 @@
>> CharUnits Offset;
>> bool InvalidBase : 1;
>> -unsigned CallIndex : 31;
>> +
>> +// Indicates the enclosing struct is marked overallocated. This is used 
>> in
>> +// computation of __builtin_object_size.
>> +bool OverAllocated : 1;
>> +
>> +unsigned CallIndex : 30;
>> SubobjectDesignator Designator;
>> 
>> All three of these should be using `unsigned`, otherwise you do not get the 
>> behavior you expect in MSVC (it allocates bit-fields of different types on 
>> their own boundaries).
>
> It looks like it's already bloated for MSVC because of `InvalidBase`.  I
> think that should be cleaned up in a prep commit.

Agreed.

~Aaron

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


Re: [PATCH] D21453: Add support for attribute "overallocated"

2016-06-27 Thread Duncan P. N. Exon Smith via cfe-commits

> On 2016-Jun-27, at 11:02, Aaron Ballman  wrote:
> 
> aaron.ballman requested changes to this revision.
> aaron.ballman added a comment.
> This revision now requires changes to proceed.
> 
> Missing Sema tests for the attribute.
> 
> 
> 
> Comment at: include/clang/Basic/AttrDocs.td:2082
> @@ +2081,3 @@
> +
> +struct S {
> +  char a[4], char b[4];
> 
> I *think* this code example will give doxygen fits because it's not indented; 
> have you tried generating the docs locally? You can test this by running: 
> `clang-tblgen -gen-attr-docs -I E:\llvm\llvm\tools\clang\include 
> E:\llvm\llvm\tools\clang\include\clang\Basic\Attr.td -o 
> E:\llvm\llvm\tools\clang\docs\AttributeReference.rst` and then building the 
> docs as normal. Note, you will have to revert AttributeReference.rst when you 
> are done.
> 
> 
> Comment at: lib/AST/ExprConstant.cpp:1051-1057
> @@ -1050,4 +1050,9 @@
> CharUnits Offset;
> bool InvalidBase : 1;
> -unsigned CallIndex : 31;
> +
> +// Indicates the enclosing struct is marked overallocated. This is used 
> in
> +// computation of __builtin_object_size.
> +bool OverAllocated : 1;
> +
> +unsigned CallIndex : 30;
> SubobjectDesignator Designator;
> 
> All three of these should be using `unsigned`, otherwise you do not get the 
> behavior you expect in MSVC (it allocates bit-fields of different types on 
> their own boundaries).

It looks like it's already bloated for MSVC because of `InvalidBase`.  I
think that should be cleaned up in a prep commit.

> 
> 
> http://reviews.llvm.org/D21453
> 
> 
> 

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


Re: [PATCH] D21453: Add support for attribute "overallocated"

2016-06-27 Thread Aaron Ballman via cfe-commits
aaron.ballman requested changes to this revision.
aaron.ballman added a comment.
This revision now requires changes to proceed.

Missing Sema tests for the attribute.



Comment at: include/clang/Basic/AttrDocs.td:2082
@@ +2081,3 @@
+
+struct S {
+  char a[4], char b[4];

I *think* this code example will give doxygen fits because it's not indented; 
have you tried generating the docs locally? You can test this by running: 
`clang-tblgen -gen-attr-docs -I E:\llvm\llvm\tools\clang\include 
E:\llvm\llvm\tools\clang\include\clang\Basic\Attr.td -o 
E:\llvm\llvm\tools\clang\docs\AttributeReference.rst` and then building the 
docs as normal. Note, you will have to revert AttributeReference.rst when you 
are done.


Comment at: lib/AST/ExprConstant.cpp:1051-1057
@@ -1050,4 +1050,9 @@
 CharUnits Offset;
 bool InvalidBase : 1;
-unsigned CallIndex : 31;
+
+// Indicates the enclosing struct is marked overallocated. This is used in
+// computation of __builtin_object_size.
+bool OverAllocated : 1;
+
+unsigned CallIndex : 30;
 SubobjectDesignator Designator;

All three of these should be using `unsigned`, otherwise you do not get the 
behavior you expect in MSVC (it allocates bit-fields of different types on 
their own boundaries).


http://reviews.llvm.org/D21453



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


Re: [PATCH] D21367: AMDGPU: Set amdgpu_kernel calling convention for OpenCL kernels.

2016-06-27 Thread Yaxun Liu via cfe-commits
yaxunl added a comment.

In http://reviews.llvm.org/D21367#467982, @nhaustov wrote:

> In http://reviews.llvm.org/D21367#467894, @yaxunl wrote:
>
> > I am wondering what's the difference between this calling convention and 
> > spir_kernel.
>
>
> spir_kernel has only effect and was created only for SPIR target. In theory 
> it could perhaps be reused for AMDGPU target, however it seems not very clear 
> to me.


If the new calling convention is to indicate a function is an OpenCL kernel, 
then it has exactly the same meaning as spir_kernel. Can we just use it in 
AMDGPU target?


http://reviews.llvm.org/D21367



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


Re: [PATCH] D21367: AMDGPU: Set amdgpu_kernel calling convention for OpenCL kernels.

2016-06-27 Thread Nikolay Haustov via cfe-commits
nhaustov added a comment.

In http://reviews.llvm.org/D21367#467894, @yaxunl wrote:

> I am wondering what's the difference between this calling convention and 
> spir_kernel.


spir_kernel has only effect and was created only for SPIR target. In theory it 
could perhaps be reused for AMDGPU target, however it seems not very clear to 
me.


http://reviews.llvm.org/D21367



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


Re: [PATCH] D21741: Add test for D21736 and D21737.

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

Is the plan to commit this along with http://reviews.llvm.org/D21737?



Comment at: test/Profile/cxx-indirect-call.cpp:3
@@ -2,3 +2,3 @@
 
-// RUN: %clang_cc1 %s -o - -emit-llvm -fprofile-instrument=clang -mllvm 
-enable-value-profiling -fexceptions -fcxx-exceptions -triple 
%itanium_abi_triple | FileCheck %s
+// RUN: %clang_cc1 %s -o - -emit-llvm -fprofile-instrument=clang -mllvm 
-enable-value-profiling -fexceptions -fcxx-exceptions -triple 
x86_64-apple-macosx10.9 | FileCheck %s
 

koriakin wrote:
> vsk wrote:
> > I don't really understand the significance of `makeItaniumABITriple`. Could 
> > you explain why this change is necessary? If it's not, please drop it.
> %itanium_abi_tuple may give any target triple that's not win32 - which 
> includes s390x and other platforms that need zeroext.  Since this test 
> assumes __llvm_profile_instrument_target has last parameter without zeroext, 
> it'd break when run on s390x.  Hardwiring the target to x86_64 ensures we'll 
> never emit zeroext here.
Ok! Thanks for explaining.


Repository:
  rL LLVM

http://reviews.llvm.org/D21741



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


[PATCH] D21753: Comprehensive Static Instrumentation (2/2): Clang flag

2016-06-27 Thread Tyler Denniston via cfe-commits
tdenniston created this revision.
tdenniston added reviewers: kcc, zhaoqin, bruening, mehdi_amini.
tdenniston added subscribers: cfe-commits, eugenis, pcc, vitalybuka, aizatsky, 
neboat.
tdenniston set the repository for this revision to rL LLVM.
tdenniston added a project: Comprehensive Static Instrumentation.

This diff implements a Clang `-fcsi` flag to support CSI. We will be submitting 
further diffs that incrementally add functionality to CSI.

Repository:
  rL LLVM

http://reviews.llvm.org/D21753

Files:
  docs/CSI.rst
  include/clang/Basic/LangOptions.def
  include/clang/Driver/Options.td
  lib/CodeGen/BackendUtil.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Lex/PPMacroExpansion.cpp
  test/Lexer/has_feature_comprehensive_static_instrumentation.cpp

Index: test/Lexer/has_feature_comprehensive_static_instrumentation.cpp
===
--- /dev/null
+++ test/Lexer/has_feature_comprehensive_static_instrumentation.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -E -fcsi %s -o - | FileCheck --check-prefix=CHECK-CSI %s
+// RUN: %clang_cc1 -E  %s -o - | FileCheck --check-prefix=CHECK-NO-CSI %s
+
+#if __has_feature(comprehensive_static_instrumentation)
+int CsiEnabled();
+#else
+int CsiDisabled();
+#endif
+
+// CHECK-CSI: CsiEnabled
+// CHECK-NO-CSI: CsiDisabled
Index: lib/Lex/PPMacroExpansion.cpp
===
--- lib/Lex/PPMacroExpansion.cpp
+++ lib/Lex/PPMacroExpansion.cpp
@@ -1095,6 +1095,8 @@
   .Case("dataflow_sanitizer", LangOpts.Sanitize.has(SanitizerKind::DataFlow))
   .Case("efficiency_sanitizer",
 LangOpts.Sanitize.hasOneOf(SanitizerKind::Efficiency))
+  .Case("comprehensive_static_instrumentation",
+LangOpts.ComprehensiveStaticInstrumentation)
   // Objective-C features
   .Case("objc_arr", LangOpts.ObjCAutoRefCount) // FIXME: REMOVE?
   .Case("objc_arc", LangOpts.ObjCAutoRefCount)
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2130,6 +2130,8 @@
   Opts.SanitizeAddressFieldPadding =
   getLastArgIntValue(Args, OPT_fsanitize_address_field_padding, 0, Diags);
   Opts.SanitizerBlacklistFiles = Args.getAllArgValues(OPT_fsanitize_blacklist);
+
+  Opts.ComprehensiveStaticInstrumentation = Args.hasArg(OPT_fcsi);
 }
 
 static void ParsePreprocessorArgs(PreprocessorOptions , ArgList ,
@@ -2342,6 +2344,8 @@
 LangOpts.PIE = Args.hasArg(OPT_pic_is_pie);
 parseSanitizerKinds("-fsanitize=", Args.getAllArgValues(OPT_fsanitize_EQ),
 Diags, LangOpts.Sanitize);
+Res.getLangOpts()->ComprehensiveStaticInstrumentation =
+Args.hasArg(OPT_fcsi);
   } else {
 // Other LangOpts are only initialzed when the input is not AST or LLVM IR.
 ParseLangArgs(LangOpts, Args, DashX, Res.getTargetOpts(),
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -4963,6 +4963,10 @@
   const SanitizerArgs  = getToolChain().getSanitizerArgs();
   Sanitize.addArgs(getToolChain(), Args, CmdArgs, InputType);
 
+  if (Args.hasArg(options::OPT_fcsi)) {
+Args.AddLastArg(CmdArgs, options::OPT_fcsi);
+  }
+
   // Report an error for -faltivec on anything other than PowerPC.
   if (const Arg *A = Args.getLastArg(options::OPT_faltivec)) {
 const llvm::Triple::ArchType Arch = getToolChain().getArch();
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -277,6 +277,12 @@
   PM.add(createEfficiencySanitizerPass(Opts));
 }
 
+static void
+addComprehensiveStaticInstrumentationPass(const PassManagerBuilder ,
+  PassManagerBase ) {
+  PM.add(createComprehensiveStaticInstrumentationPass());
+}
+
 static TargetLibraryInfoImpl *createTLII(llvm::Triple ,
  const CodeGenOptions ) {
   TargetLibraryInfoImpl *TLII = new TargetLibraryInfoImpl(TargetTriple);
@@ -452,6 +458,13 @@
addEfficiencySanitizerPass);
   }
 
+  if (LangOpts.ComprehensiveStaticInstrumentation) {
+PMBuilder.addExtension(PassManagerBuilder::EP_OptimizerLast,
+   addComprehensiveStaticInstrumentationPass);
+PMBuilder.addExtension(PassManagerBuilder::EP_EnabledOnOptLevel0,
+   addComprehensiveStaticInstrumentationPass);
+  }
+
   // Set up the per-function pass manager.
   legacy::FunctionPassManager *FPM = getPerFunctionPasses();
   if (CodeGenOpts.VerifyModule)
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ 

Re: [PATCH] D21446: Comprehensive static instrumentation (2/3): Clang support

2016-06-27 Thread Tyler Denniston via cfe-commits
tdenniston abandoned this revision.
tdenniston added a comment.

Abandoning. We are resubmitting the CSI patches in smaller increments.


Repository:
  rL LLVM

http://reviews.llvm.org/D21446



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


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

2016-06-27 Thread Erik Pilkington via cfe-commits
erik.pilkington added a comment.

Ping!


http://reviews.llvm.org/D21030



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


Re: [PATCH] D20382: Add postorder support to RecursiveASTVisitor

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

If there's no more executable size bloat this seems fine to me.


http://reviews.llvm.org/D20382



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


Re: [PATCH] D21741: Add test for D21736 and D21737.

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

LGTM, with one nit.



Comment at: test/Profile/cxx-indirect-call.cpp:3
@@ -2,3 +2,3 @@
 
-// RUN: %clang_cc1 %s -o - -emit-llvm -fprofile-instrument=clang -mllvm 
-enable-value-profiling -fexceptions -fcxx-exceptions -triple 
%itanium_abi_triple | FileCheck %s
+// RUN: %clang_cc1 %s -o - -emit-llvm -fprofile-instrument=clang -mllvm 
-enable-value-profiling -fexceptions -fcxx-exceptions -triple 
x86_64-apple-macosx10.9 | FileCheck %s
 

I don't really understand the significance of `makeItaniumABITriple`. Could you 
explain why this change is necessary? If it's not, please drop it.


Repository:
  rL LLVM

http://reviews.llvm.org/D21741



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


Re: [PATCH] D20382: Add postorder support to RecursiveASTVisitor

2016-06-27 Thread Vassil Vassilev via cfe-commits
v.g.vassilev added a comment.

@bkramer are those modifications enough to accept this patch? It is holding 
back quite a lot of ongoing development from @teemperor as part of his GSoC 
project.


http://reviews.llvm.org/D20382



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


Re: [PATCH] D21564: [OpenMP] Initial implementation of parse and sema for composite pragma 'distribute parallel for'

2016-06-27 Thread Carlo Bertolli via cfe-commits
carlo.bertolli added a comment.

Resubmitted at revision 273884 after fixes.


Repository:
  rL LLVM

http://reviews.llvm.org/D21564



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


Re: [PATCH] D21747: [clang-tidy] Warning enum unused using declarations.

2016-06-27 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL273882: [clang-tidy] Warning enum unused using declarations. 
(authored by hokein).

Changed prior to commit:
  http://reviews.llvm.org/D21747?vs=61955=61966#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D21747

Files:
  clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp

Index: clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -19,12 +19,13 @@
 namespace misc {
 
 // A function that helps to tell whether a TargetDecl in a UsingDecl will be
-// checked. Only variable, function, function template, class template and 
class
-// are considered.
+// checked. Only variable, function, function template, class template, class,
+// enum declaration and enum constant declaration are considered.
 static bool ShouldCheckDecl(const Decl *TargetDecl) {
   return isa(TargetDecl) || isa(TargetDecl) ||
  isa(TargetDecl) || isa(TargetDecl) ||
- isa(TargetDecl);
+ isa(TargetDecl) || isa(TargetDecl) ||
+ isa(TargetDecl);
 }
 
 void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
@@ -91,6 +92,8 @@
 removeFromFoundDecls(FD);
 } else if (const auto *VD = dyn_cast(DRE->getDecl())) {
   removeFromFoundDecls(VD);
+} else if (const auto *ECD = dyn_cast(DRE->getDecl())) {
+  removeFromFoundDecls(ECD);
 }
   }
   // Check the uninstantiated template function usage.
Index: clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp
@@ -43,7 +43,14 @@
 };
 extern ostream cout;
 ostream (ostream );
-}
+
+enum Color {
+  Green,
+  Red,
+  Yellow
+};
+
+}  // namespace n
 
 // - Using declarations -
 // eol-comments aren't removed (yet)
@@ -119,6 +126,12 @@
 using n::H;
 }
 
+using n::Color;
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'Color' is unused
+using n::Green;
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'Green' is unused
+using n::Red;
+
 // - Usages -
 void f(B b);
 void g() {
@@ -131,4 +144,5 @@
   UsedFunc();
   UsedTemplateFunc();
   cout << endl;
+  int t = Red;
 }


Index: clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -19,12 +19,13 @@
 namespace misc {
 
 // A function that helps to tell whether a TargetDecl in a UsingDecl will be
-// checked. Only variable, function, function template, class template and class
-// are considered.
+// checked. Only variable, function, function template, class template, class,
+// enum declaration and enum constant declaration are considered.
 static bool ShouldCheckDecl(const Decl *TargetDecl) {
   return isa(TargetDecl) || isa(TargetDecl) ||
  isa(TargetDecl) || isa(TargetDecl) ||
- isa(TargetDecl);
+ isa(TargetDecl) || isa(TargetDecl) ||
+ isa(TargetDecl);
 }
 
 void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
@@ -91,6 +92,8 @@
 removeFromFoundDecls(FD);
 } else if (const auto *VD = dyn_cast(DRE->getDecl())) {
   removeFromFoundDecls(VD);
+} else if (const auto *ECD = dyn_cast(DRE->getDecl())) {
+  removeFromFoundDecls(ECD);
 }
   }
   // Check the uninstantiated template function usage.
Index: clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp
@@ -43,7 +43,14 @@
 };
 extern ostream cout;
 ostream (ostream );
-}
+
+enum Color {
+  Green,
+  Red,
+  Yellow
+};
+
+}  // namespace n
 
 // - Using declarations -
 // eol-comments aren't removed (yet)
@@ -119,6 +126,12 @@
 using n::H;
 }
 
+using n::Color;
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'Color' is unused
+using n::Green;
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'Green' is unused
+using n::Red;
+
 // - Usages -
 void f(B b);
 void g() {
@@ -131,4 +144,5 @@
   UsedFunc();
   UsedTemplateFunc();
   cout << endl;
+  int t = Red;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r273882 - [clang-tidy] Warning enum unused using declarations.

2016-06-27 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Mon Jun 27 09:47:39 2016
New Revision: 273882

URL: http://llvm.org/viewvc/llvm-project?rev=273882=rev
Log:
[clang-tidy] Warning enum unused using declarations.

Reviewers: alexfh, aaron.ballman

Subscribers: aaron.ballman, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp?rev=273882=273881=273882=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp Mon Jun 
27 09:47:39 2016
@@ -19,12 +19,13 @@ namespace tidy {
 namespace misc {
 
 // A function that helps to tell whether a TargetDecl in a UsingDecl will be
-// checked. Only variable, function, function template, class template and 
class
-// are considered.
+// checked. Only variable, function, function template, class template, class,
+// enum declaration and enum constant declaration are considered.
 static bool ShouldCheckDecl(const Decl *TargetDecl) {
   return isa(TargetDecl) || isa(TargetDecl) ||
  isa(TargetDecl) || isa(TargetDecl) ||
- isa(TargetDecl);
+ isa(TargetDecl) || isa(TargetDecl) ||
+ isa(TargetDecl);
 }
 
 void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
@@ -91,6 +92,8 @@ void UnusedUsingDeclsCheck::check(const
 removeFromFoundDecls(FD);
 } else if (const auto *VD = dyn_cast(DRE->getDecl())) {
   removeFromFoundDecls(VD);
+} else if (const auto *ECD = dyn_cast(DRE->getDecl())) {
+  removeFromFoundDecls(ECD);
 }
   }
   // Check the uninstantiated template function usage.

Modified: clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp?rev=273882=273881=273882=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp Mon Jun 
27 09:47:39 2016
@@ -43,7 +43,14 @@ public:
 };
 extern ostream cout;
 ostream (ostream );
-}
+
+enum Color {
+  Green,
+  Red,
+  Yellow
+};
+
+}  // namespace n
 
 // - Using declarations -
 // eol-comments aren't removed (yet)
@@ -119,6 +126,12 @@ void IgnoreFunctionScope() {
 using n::H;
 }
 
+using n::Color;
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'Color' is unused
+using n::Green;
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'Green' is unused
+using n::Red;
+
 // - Usages -
 void f(B b);
 void g() {
@@ -131,4 +144,5 @@ void g() {
   UsedFunc();
   UsedTemplateFunc();
   cout << endl;
+  int t = Red;
 }


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


Re: [PATCH] D21367: AMDGPU: Set amdgpu_kernel calling convention for OpenCL kernels.

2016-06-27 Thread Yaxun Liu via cfe-commits
yaxunl added a comment.

I am wondering what's the difference between this calling convention and 
spir_kernel.


http://reviews.llvm.org/D21367



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


Re: [PATCH] D21747: [clang-tidy] Warning enum unused using declarations.

2016-06-27 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.

LG


http://reviews.llvm.org/D21747



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


Re: [PATCH] D20352: Add XRay flags to Clang

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

It looks like you ran clang-format over the entire file in some instances, 
causing a lot of unrelated changes to creep in. Can you back those changes out 
and only run clang-format over just your patch instead 
(http://clang.llvm.org/docs/ClangFormat.html#script-for-patch-reformatting)?



Comment at: include/clang/Basic/Attr.td:436
@@ +435,3 @@
+   CXX11<"clang", "xray_never_instrument">];
+  let Subjects = SubjectList<[CXXMethod, ObjCMethod, Function], WarnDiag,
+  "ExpectedFunctionOrMethod">;

You can drop the WarnDiag and string literal; the defaults already do the right 
thing.


Comment at: include/clang/Basic/AttrDocs.td:2455
@@ +2454,3 @@
+  let Content = [{
+``__attribute__((xray_always_instrument))`` or 
``[[clang:xray_always_instrument]]`` is used to mark member functions (in C++), 
methods (in Objective C), and free functions (in C, C++, and Objective C) to be 
instrumented with XRay. This will cause the function to always have space at 
the beginning and exit points to allow for runtime patching.
+

Let's make sure that this patch and D19908 do not conflict, because they seem 
to be implementing competing semantics.


Comment at: lib/CodeGen/CodeGenFunction.cpp:381
@@ -380,3 +380,3 @@
 
-  for (SmallVectorImpl::iterator
+  for (SmallVectorImpl::iterator
I = DeferredReplacements.begin(),

Can't you rangify this loop?


Comment at: lib/CodeGen/CodeGenFunction.cpp:402
@@ +401,3 @@
+/// instrumented with XRay nop sleds.
+bool CodeGenFunction::ShouldXRayInstrumentFunction() {
+  return CGM.getCodeGenOpts().XRayInstrumentFunctions;

Any particular reason this isn't a `const` function?


Comment at: lib/CodeGen/CodeGenFunction.cpp:691
@@ +690,3 @@
+if (D->hasAttr()) {
+  switch (D->getAttr()->getSpellingListIndex()) {
+case 0:

This is not the right way to do this. ;-)

You should check the *semantic* spelling instead. e.g.,
```
if (const auto *A = D->getAttr()) {
  switch (A->getSemanticSpelling()) {
  case XRayInstrumentAttr::GNU_blahblah:
  case XRayInstrumentAttr::CXX11_clang_blahblah:
  }
}
```
Alternatively (and I think this may be cleaner), you could add an additional 
member in Attr.td that exposes this as two Boolean getters `bool 
alwaysInstrument() const` and `bool neverInstrument() const` that do the 
semantic spelling switch.


http://reviews.llvm.org/D20352



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


Re: [PATCH] D21747: [clang-tidy] Warning enum unused using declarations.

2016-06-27 Thread Aaron Ballman via cfe-commits
aaron.ballman added a subscriber: aaron.ballman.
aaron.ballman accepted this revision.
aaron.ballman added a reviewer: aaron.ballman.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!


http://reviews.llvm.org/D21747



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


Re: [PATCH] D14471: [AArch64] Fix a crash in driver

2016-06-27 Thread Renato Golin via cfe-commits
rengolin added a comment.

If this patch was abandoned, please "Abandon" it. If not, please implement it 
using the AArch64 TargetParser.


http://reviews.llvm.org/D14471



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


Re: [PATCH] D21737: [PATCH] [CodeGen] Insert TargetLibraryInfoWrapperPass before anything else.

2016-06-27 Thread Diego Novillo via cfe-commits
dnovillo accepted this revision.
dnovillo added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rL LLVM

http://reviews.llvm.org/D21737



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


[PATCH] D21747: [clang-tidy] Warning enum unused using declarations.

2016-06-27 Thread Haojian Wu via cfe-commits
hokein created this revision.
hokein added a reviewer: alexfh.
hokein added a subscriber: cfe-commits.

http://reviews.llvm.org/D21747

Files:
  clang-tidy/misc/UnusedUsingDeclsCheck.cpp
  test/clang-tidy/misc-unused-using-decls.cpp

Index: test/clang-tidy/misc-unused-using-decls.cpp
===
--- test/clang-tidy/misc-unused-using-decls.cpp
+++ test/clang-tidy/misc-unused-using-decls.cpp
@@ -43,7 +43,14 @@
 };
 extern ostream cout;
 ostream (ostream );
-}
+
+enum Color {
+  Green,
+  Red,
+  Yellow
+};
+
+}  // namespace n
 
 // - Using declarations -
 // eol-comments aren't removed (yet)
@@ -119,6 +126,12 @@
 using n::H;
 }
 
+using n::Color;
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'Color' is unused
+using n::Green;
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'Green' is unused
+using n::Red;
+
 // - Usages -
 void f(B b);
 void g() {
@@ -131,4 +144,5 @@
   UsedFunc();
   UsedTemplateFunc();
   cout << endl;
+  int t = Red;
 }
Index: clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===
--- clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -19,12 +19,13 @@
 namespace misc {
 
 // A function that helps to tell whether a TargetDecl in a UsingDecl will be
-// checked. Only variable, function, function template, class template and 
class
-// are considered.
+// checked. Only variable, function, function template, class template, class,
+// enum declaration and enum constant declaration are considered.
 static bool ShouldCheckDecl(const Decl *TargetDecl) {
   return isa(TargetDecl) || isa(TargetDecl) ||
  isa(TargetDecl) || isa(TargetDecl) ||
- isa(TargetDecl);
+ isa(TargetDecl) || isa(TargetDecl) ||
+ isa(TargetDecl);
 }
 
 void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
@@ -91,6 +92,8 @@
 removeFromFoundDecls(FD);
 } else if (const auto *VD = dyn_cast(DRE->getDecl())) {
   removeFromFoundDecls(VD);
+} else if (const auto *ECD = dyn_cast(DRE->getDecl())) {
+  removeFromFoundDecls(ECD);
 }
   }
   // Check the uninstantiated template function usage.


Index: test/clang-tidy/misc-unused-using-decls.cpp
===
--- test/clang-tidy/misc-unused-using-decls.cpp
+++ test/clang-tidy/misc-unused-using-decls.cpp
@@ -43,7 +43,14 @@
 };
 extern ostream cout;
 ostream (ostream );
-}
+
+enum Color {
+  Green,
+  Red,
+  Yellow
+};
+
+}  // namespace n
 
 // - Using declarations -
 // eol-comments aren't removed (yet)
@@ -119,6 +126,12 @@
 using n::H;
 }
 
+using n::Color;
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'Color' is unused
+using n::Green;
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'Green' is unused
+using n::Red;
+
 // - Usages -
 void f(B b);
 void g() {
@@ -131,4 +144,5 @@
   UsedFunc();
   UsedTemplateFunc();
   cout << endl;
+  int t = Red;
 }
Index: clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===
--- clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -19,12 +19,13 @@
 namespace misc {
 
 // A function that helps to tell whether a TargetDecl in a UsingDecl will be
-// checked. Only variable, function, function template, class template and class
-// are considered.
+// checked. Only variable, function, function template, class template, class,
+// enum declaration and enum constant declaration are considered.
 static bool ShouldCheckDecl(const Decl *TargetDecl) {
   return isa(TargetDecl) || isa(TargetDecl) ||
  isa(TargetDecl) || isa(TargetDecl) ||
- isa(TargetDecl);
+ isa(TargetDecl) || isa(TargetDecl) ||
+ isa(TargetDecl);
 }
 
 void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
@@ -91,6 +92,8 @@
 removeFromFoundDecls(FD);
 } else if (const auto *VD = dyn_cast(DRE->getDecl())) {
   removeFromFoundDecls(VD);
+} else if (const auto *ECD = dyn_cast(DRE->getDecl())) {
+  removeFromFoundDecls(ECD);
 }
   }
   // Check the uninstantiated template function usage.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r273861 - Fix bad link for P0006

2016-06-27 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon Jun 27 06:14:34 2016
New Revision: 273861

URL: http://llvm.org/viewvc/llvm-project?rev=273861=rev
Log:
Fix bad link for P0006

Modified:
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/www/cxx1z_status.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=273861=273860=273861=diff
==
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Mon Jun 27 06:14:34 2016
@@ -71,7 +71,7 @@
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4510;>N4510LWGMinimal
 incomplete type support for standard containers, revision 
4LenexaComplete3.6

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/P0004R1.html;>P0004R1LWGRemove
 Deprecated iostreams 
aliases.KonaComplete3.8
-   http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/P0006R0.html;>P0006R0LWGAdopt
 Type Traits Variable Templates for 
C++17.KonaComplete3.8
+   http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0006r0.html;>P0006R0LWGAdopt
 Type Traits Variable Templates for 
C++17.KonaComplete3.8
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/P0092R1.html;>P0092R1LWGPolishing
 chronoKonaComplete3.8
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/P0007R1.html;>P0007R1LWGConstant
 View: A proposal for a std::as_const helper function 
template.KonaComplete3.8
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0156r0.html; 
>P0156R0LWGVariadic lock_guard(rev 
3).KonaComplete (ABI V2 Only)3.9


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


[PATCH] D21746: [AVX512] Zero extend cmp intrinsic return value.

2016-06-27 Thread Igor Breger via cfe-commits
igorb created this revision.
igorb added reviewers: delena, craig.topper.
igorb added a subscriber: cfe-commits.
igorb set the repository for this revision to rL LLVM.

[AVX512] Zero extend cmp intrinsic return value.

Repository:
  rL LLVM

http://reviews.llvm.org/D21746

Files:
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/avx512vl-builtins.c

Index: test/CodeGen/avx512vl-builtins.c
===
--- test/CodeGen/avx512vl-builtins.c
+++ test/CodeGen/avx512vl-builtins.c
@@ -8,6 +8,7 @@
 __mmask8 test_mm_cmpeq_epu32_mask(__m128i __a, __m128i __b) {
   // CHECK-LABEL: @test_mm_cmpeq_epu32_mask
   // CHECK: icmp eq <4 x i32> %{{.*}}, %{{.*}}
+  // CHECK: shufflevector <4 x i1> %{{.*}}, <4 x i1> zeroinitializer, <8 x 
i32> 
   return (__mmask8)_mm_cmpeq_epu32_mask(__a, __b);
 }
 
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -6456,8 +6456,10 @@
   Indices[i] = i;
 for (unsigned i = NumElts; i != 8; ++i)
   Indices[i] = NumElts;
-Cmp = CGF.Builder.CreateShuffleVector(Cmp, UndefValue::get(Cmp->getType()),
-  Indices);
+Cmp = CGF.Builder.CreateShuffleVector(
+Cmp,
+llvm::Constant::getNullValue(Cmp->getType()),
+Indices);
   }
   return CGF.Builder.CreateBitCast(Cmp,
IntegerType::get(CGF.getLLVMContext(),


Index: test/CodeGen/avx512vl-builtins.c
===
--- test/CodeGen/avx512vl-builtins.c
+++ test/CodeGen/avx512vl-builtins.c
@@ -8,6 +8,7 @@
 __mmask8 test_mm_cmpeq_epu32_mask(__m128i __a, __m128i __b) {
   // CHECK-LABEL: @test_mm_cmpeq_epu32_mask
   // CHECK: icmp eq <4 x i32> %{{.*}}, %{{.*}}
+  // CHECK: shufflevector <4 x i1> %{{.*}}, <4 x i1> zeroinitializer, <8 x i32> 
   return (__mmask8)_mm_cmpeq_epu32_mask(__a, __b);
 }
 
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -6456,8 +6456,10 @@
   Indices[i] = i;
 for (unsigned i = NumElts; i != 8; ++i)
   Indices[i] = NumElts;
-Cmp = CGF.Builder.CreateShuffleVector(Cmp, UndefValue::get(Cmp->getType()),
-  Indices);
+Cmp = CGF.Builder.CreateShuffleVector(
+Cmp,
+llvm::Constant::getNullValue(Cmp->getType()),
+Indices);
   }
   return CGF.Builder.CreateBitCast(Cmp,
IntegerType::get(CGF.getLLVMContext(),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21676: clang-rename: add a -export-fixes option

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

lg


http://reviews.llvm.org/D21676



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


Re: [PATCH] D21228: Deprecated (legacy) string literal conversion to 'char *' causes strange overloading resolution

2016-06-27 Thread Alexander Makarov via cfe-commits
a.makarov added a reviewer: rnk.
a.makarov added a comment.

Reid, please, take a look.


http://reviews.llvm.org/D21228



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


Re: [PATCH] D20249: [OpenCL] Hierarchical/dynamic parallelism - enqueue kernel in OpenCL 2.0

2016-06-27 Thread Alexey Bader via cfe-commits
bader accepted this revision.
bader added a comment.

LGTM.
A few style nitpicks.



Comment at: lib/CodeGen/CGBuiltin.cpp:2180-2181
@@ +2179,4 @@
+}
+// Could have events and/or vaargs.
+if (NumArgs >= 5) {
+  if (E->getArg(3)->getType()->isBlockPointerType()) {

[Style] Minor suggestion to consider.
To avoid indentation of almost 100 lines of code inside if statement this can 
be implemented as:
if (NumArgs < 5) llvm_unreachable("Unhandled enqueue_kernel signature");

There is no else branch for that condition anyway.


Comment at: lib/CodeGen/CGBuiltin.cpp:2189-2190
@@ +2188,4 @@
+// express to the runtime the number of variadic arguments.
+std::vector Args{Queue, Flags, Range, Block,
+ConstantInt::get(IntTy, NumArgs - 4)};
+std::vector ArgTys = {QueueTy, IntTy, RangeTy, Int8PtrTy,

[Style] Use an equals before the open curly brace.
http://llvm.org/docs/CodingStandards.html#do-not-use-braced-initializer-lists-to-call-a-constructor


Comment at: lib/CodeGen/CGBuiltin.cpp:2195
@@ +2194,3 @@
+// Add the variadics.
+for (unsigned i = 4; i < NumArgs; ++i) {
+  llvm::Value *ArgSize = EmitScalarExpr(E->getArg(i));

[Style] CamelCase: i -> I
http://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly



Comment at: lib/CodeGen/CGBuiltin.cpp:2238-2239
@@ +2237,4 @@
+EventPtrAS4Ty, EventPtrAS5Ty, Int8PtrTy};
+std::vector Args{Queue, Flags,Range, NumEvents,
+EventList, ClkEvent, Block};
+

[Style] Use an equals before the open curly brace.
http://llvm.org/docs/CodingStandards.html#do-not-use-braced-initializer-lists-to-call-a-constructor


Comment at: lib/CodeGen/CGBuiltin.cpp:2249
@@ +2248,3 @@
+ llvm::ArrayRef(Args)));
+} else {
+  // Has event info and variadics

[Style] 'else' here is unnecessary:
http://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return



Comment at: lib/CodeGen/CGBuiltin.cpp:2257
@@ +2256,3 @@
+  // Add the variadics.
+  for (unsigned i = 7; i < NumArgs; ++i) {
+llvm::Value *ArgSize = EmitScalarExpr(E->getArg(i));

[Style] CamelCase: i -> I
http://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly


Comment at: lib/Sema/SemaChecking.cpp:124-126
@@ +123,5 @@
+   diag::err_opencl_enqueue_kernel_expected_type) << "block";
+return true;
+  } else
+return checkBlockArgs(S, BlockArg);
+}

[Style] 'else' here is unnecessary:
http://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return


Comment at: lib/Sema/SemaChecking.cpp:132
@@ +131,3 @@
+  bool IllegalParams = false;
+  for (unsigned i = Start; i <= End; ++i) {
+QualType Ty = TheCall->getArg(i)->getType();

[Style] CamelCase: i -> I
http://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly


Comment at: lib/Sema/SemaChecking.cpp:145
@@ +144,3 @@
+}
+
+/// OpenCL v2.0, s6.13.17.1 - Check that sizes are provided for all

Anastasia wrote:
> I think the problem is that in C99 there are implicit casts among integer 
> types, therefore making this check more restrictive would imply the cast has 
> to be done explicitly instead.
> 
> Thus, this would have to be modified as follows:
> 
>   enqueue_kernel(...,  64); -> enqueue_kernel(...,  (uint)64); or 
> enqueue_kernel(...,  64U);
> 
> which in my opinion is undesirable and also a bit unexpected because by 
> analogy to C99 you can compile the following successfully:
>   
>   void g(unsigned);
> 
>   void f() {
> char i;
> g(i);
>   }
> 
> I have added a check for a size however not to be larger than 32 bits and 
> handled type cast in CodeGen. The test cases are added too.
> 
> What's your opinion about it?
I'm OK with allowing implicit conversions as long as there is a way to enforce 
strict check for unsigned 32-bit integer here (e.g. with -Wconversion or in 
pedatic mode).
Can we check that mode?


Comment at: lib/Sema/SemaChecking.cpp:238-239
@@ +237,4 @@
+  << "block";
+  return true;
+} else { // we have a block type, check the prototype
+  const BlockPointerType *BPT =

[Style] 'else' here is unnecessary:
http://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return


Comment at: lib/Sema/SemaChecking.cpp:250
@@ +249,3 @@
+return false;
+  } else {
+// we can have block + varargs.

[Style] 'else' here is unnecessary:
http://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return


Re: [PATCH] D21470: [clang-tidy] Don't run misc-definitions-in-headers check in failing TUs.

2016-06-27 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL273849: [clang-tidy] Don't run misc-definitions-in-headers 
check in failing TUs. (authored by hokein).

Changed prior to commit:
  http://reviews.llvm.org/D21470?vs=61092=61938#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D21470

Files:
  clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp

Index: clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
@@ -72,6 +72,10 @@
 }
 
 void DefinitionsInHeadersCheck::check(const MatchFinder::MatchResult ) {
+  // Don't run the check in failing TUs.
+  if (Result.Context->getDiagnostics().hasErrorOccurred())
+return;
+
   // C++ [basic.def.odr] p6:
   // There can be more than one definition of a class type, enumeration type,
   // inline function with external linkage, class template, non-static function


Index: clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
@@ -72,6 +72,10 @@
 }
 
 void DefinitionsInHeadersCheck::check(const MatchFinder::MatchResult ) {
+  // Don't run the check in failing TUs.
+  if (Result.Context->getDiagnostics().hasErrorOccurred())
+return;
+
   // C++ [basic.def.odr] p6:
   // There can be more than one definition of a class type, enumeration type,
   // inline function with external linkage, class template, non-static function
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r273849 - [clang-tidy] Don't run misc-definitions-in-headers check in failing TUs.

2016-06-27 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Mon Jun 27 03:04:01 2016
New Revision: 273849

URL: http://llvm.org/viewvc/llvm-project?rev=273849=rev
Log:
[clang-tidy] Don't run misc-definitions-in-headers check in failing TUs.

Reviewers: alexfh

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp?rev=273849=273848=273849=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp Mon 
Jun 27 03:04:01 2016
@@ -72,6 +72,10 @@ void DefinitionsInHeadersCheck::register
 }
 
 void DefinitionsInHeadersCheck::check(const MatchFinder::MatchResult ) {
+  // Don't run the check in failing TUs.
+  if (Result.Context->getDiagnostics().hasErrorOccurred())
+return;
+
   // C++ [basic.def.odr] p6:
   // There can be more than one definition of a class type, enumeration type,
   // inline function with external linkage, class template, non-static function


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


Re: [PATCH] D20352: Add XRay flags to Clang

2016-06-27 Thread Dean Michael Berris via cfe-commits
dberris marked an inline comment as done.


Comment at: include/clang/Basic/Attr.td:432
@@ +431,3 @@
+   CXX11<"clang", "xray_always_instrument">];
+  let Subjects = SubjectList<[CXXMethod, Function], WarnDiag,
+  "ExpectedFunctionOrMethod">;

Yes it does, done.


Comment at: include/clang/Basic/Attr.td:433
@@ +432,3 @@
+  let Subjects = SubjectList<[CXXMethod, Function], WarnDiag,
+  "ExpectedFunctionOrMethod">;
+  let Documentation = [Undocumented];  // TODO(dberris): Document this!

Done the latter to include ObjC methods.


Comment at: include/clang/Basic/Attr.td:437
@@ +436,3 @@
+
+def XRayNeverInstrument : InheritableAttr {
+  let Spellings = [GNU<"xray_never_instrument">,

This actually makes a lot of sense. I've done some of the consolidation to make 
it a lot easier to check in the code and to expand later on too. I suppose 
other attributes that are XRay-specific with additional values/arguments would 
make a better candidate for additional attributes. Will cross that bridge when 
we get to that part of the implementation. :)


Comment at: include/clang/Frontend/CodeGenOptions.def:75
@@ -74,3 +74,3 @@
 CODEGENOPT(FunctionSections  , 1, 0) ///< Set when -ffunction-sections is 
enabled.
 CODEGENOPT(InstrumentFunctions , 1, 0) ///< Set when -finstrument-functions is
///< enabled.

I'm open to this idea, except this might break compatibility with GCC (as this 
seems to be a gcc-inspired flag).

I'm happy to explore consolidating the different instrumentation flags under 
`-finstrument=` which then has namespace values internally (profile-..., 
xray-...) for different modes, etc. For now the simplest thing to do might be 
to have XRay do this independently first, then have a cleanup later to 
consolidate flags on the driver and deprecate the flags.


http://reviews.llvm.org/D20352



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


Re: [PATCH] D20352: Add XRay flags to Clang

2016-06-27 Thread Dean Michael Berris via cfe-commits
dberris updated this revision to Diff 61932.
dberris marked 2 inline comments as done.
dberris added a comment.

- Address review comments; see details.


http://reviews.llvm.org/D20352

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/xray-attributes-supported.cpp
  test/Sema/xray-always-instrument-attr.c
  test/Sema/xray-always-instrument-attr.cpp

Index: test/Sema/xray-always-instrument-attr.cpp
===
--- /dev/null
+++ test/Sema/xray-always-instrument-attr.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -std=c++11 -x c++
+void foo [[clang::xray_always_instrument]] ();
+
+struct [[clang::xray_always_instrument]] a { int x; }; // expected-warning {{'xray_always_instrument' attribute only applies to functions and methods}}
+
+class b {
+ void c [[clang::xray_always_instrument]] ();
+};
+
+void baz [[clang::xray_always_instrument("not-supported")]] (); // expected-error {{'xray_always_instrument' attribute takes no arguments}}
Index: test/Sema/xray-always-instrument-attr.c
===
--- /dev/null
+++ test/Sema/xray-always-instrument-attr.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only -std=c11
+void foo() __attribute__((xray_always_instrument));
+
+struct __attribute__((xray_always_instrument)) a { int x; }; // expected-warning {{'xray_always_instrument' attribute only applies to functions and methods}}
+
+void bar() __attribute__((xray_always_instrument("not-supported"))); // expected-error {{'xray_always_instrument' attribute takes no arguments}}
Index: test/CodeGen/xray-attributes-supported.cpp
===
--- /dev/null
+++ test/CodeGen/xray-attributes-supported.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 %s -fxray-instrument -std=c++11 -x c++ -emit-llvm -o - -triple x86_64-unknown-linux-gnu | FileCheck %s
+
+// Make sure that the LLVM attribute for XRay-annotated functions do show up.
+[[clang::xray_always_instrument]] void foo() {
+// CHECK: define void @_Z3foov() #0
+};
+
+[[clang::xray_never_instrument]] void bar() {
+// CHECK: define void @_Z3barv() #1
+};
+
+// CHECK: #0 = {{.*}}"function-instrument"="xray-always"
+// CHECK: #1 = {{.*}}"function-instrument"="xray-never"
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -5913,10 +5913,13 @@
   case AttributeList::AT_TypeTagForDatatype:
 handleTypeTagForDatatypeAttr(S, D, Attr);
 break;
-
   case AttributeList::AT_RenderScriptKernel:
 handleSimpleAttribute(S, D, Attr);
 break;
+  // XRay attributes.
+  case AttributeList::AT_XRayInstrument:
+handleSimpleAttribute(S, D, Attr);
+break;
   }
 }
 
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -685,6 +685,9 @@
   }
 
   Opts.InstrumentFunctions = Args.hasArg(OPT_finstrument_functions);
+  Opts.XRayInstrumentFunctions = Args.hasArg(OPT_fxray_instrument);
+  Opts.XRayInstructionThreshold =
+  getLastArgIntValue(Args, OPT_fxray_instruction_threshold_, 200, Diags);
   Opts.InstrumentForProfiling = Args.hasArg(OPT_pg);
   Opts.EmitOpenCLArgMetadata = Args.hasArg(OPT_cl_kernel_arg_info);
   Opts.CompressDebugSections = Args.hasArg(OPT_compress_debug_sections);
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3178,6 +3178,28 @@
   return !StaticRuntimes.empty();
 }
 
+static bool addXRayRuntime(const ToolChain , const ArgList ,
+   ArgStringList ) {
+  if (Args.hasArg(options::OPT_fxray_instrument,
+  options::OPT_fnoxray_instrument, false)) {
+CmdArgs.push_back("-whole-archive");
+CmdArgs.push_back(TC.getCompilerRTArgString(Args, "xray", false));
+CmdArgs.push_back("-no-whole-archive");
+return true;
+  }
+  return false;
+}
+
+static void linkXRayRuntimeDeps(const ToolChain , ArgStringList ) {
+  CmdArgs.push_back("--no-as-needed");
+  CmdArgs.push_back("-lpthread");
+  CmdArgs.push_back("-lrt");
+  CmdArgs.push_back("-lm");
+  CmdArgs.push_back("-latomic");
+  if (TC.getTriple().getOS() != llvm::Triple::FreeBSD)
+CmdArgs.push_back("-ldl");
+}
+
 static bool areOptimizationsEnabled(const ArgList ) {
   // Find the last -O arg and see if it is non-zero.
   if (Arg *A = Args.getLastArg(options::OPT_O_Group))
@@ -4579,6 +4601,16 @@
 
   Args.AddAllArgs(CmdArgs, options::OPT_finstrument_functions);
 
+