r261467 - Added SKL and CNL processors and features to Clang

2016-02-20 Thread Elena Demikhovsky via cfe-commits
Author: delena
Date: Sun Feb 21 01:41:23 2016
New Revision: 261467

URL: http://llvm.org/viewvc/llvm-project?rev=261467=rev
Log:
Added SKL and CNL processors and features to Clang

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


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

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=261467=261466=261467=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Sun Feb 21 01:41:23 2016
@@ -2117,7 +2117,11 @@ class X86TargetInfo : public TargetInfo
   bool HasAVX512DQ = false;
   bool HasAVX512BW = false;
   bool HasAVX512VL = false;
+  bool HasAVX512VBMI = false;
+  bool HasAVX512IFMA = false;
   bool HasSHA = false;
+  bool HasMPX = false;
+  bool HasSGX = false;
   bool HasCX16 = false;
   bool HasFXSR = false;
   bool HasXSAVE = false;
@@ -2125,6 +2129,12 @@ class X86TargetInfo : public TargetInfo
   bool HasXSAVEC = false;
   bool HasXSAVES = false;
   bool HasPKU = false;
+  bool HasCLFLUSHOPT = false;
+  bool HasPCOMMIT = false;
+  bool HasCLWB = false;
+  bool HasUMIP = false;
+  bool HasMOVBE = false;
+  bool HasPREFETCHWT1 = false;
 
   /// \brief Enumeration of all of the X86 CPUs supported by Clang.
   ///
@@ -2225,9 +2235,17 @@ class X86TargetInfo : public TargetInfo
 /// Broadwell microarchitecture based processors.
 CK_Broadwell,
 
-/// \name Skylake
-/// Skylake microarchitecture based processors.
-CK_Skylake,
+/// \name Skylake Client
+/// Skylake client microarchitecture based processors.
+CK_SkylakeClient,
+
+/// \name Skylake Server
+/// Skylake server microarchitecture based processors.
+CK_SkylakeServer,
+
+/// \name Cannonlake Client
+/// Cannonlake client microarchitecture based processors.
+CK_Cannonlake,
 
 /// \name Knights Landing
 /// Knights Landing processor.
@@ -2332,8 +2350,10 @@ class X86TargetInfo : public TargetInfo
 .Case("haswell", CK_Haswell)
 .Case("core-avx2", CK_Haswell) // Legacy name.
 .Case("broadwell", CK_Broadwell)
-.Case("skylake", CK_Skylake)
-.Case("skx", CK_Skylake) // Legacy name.
+.Case("skylake", CK_SkylakeClient)
+.Case("skylake-avx512", CK_SkylakeServer)
+.Case("skx", CK_SkylakeServer) // Legacy name.
+.Case("cannonlake", CK_Cannonlake)
 .Case("knl", CK_KNL)
 .Case("k6", CK_K6)
 .Case("k6-2", CK_K6_2)
@@ -2508,7 +2528,9 @@ public:
 case CK_IvyBridge:
 case CK_Haswell:
 case CK_Broadwell:
-case CK_Skylake:
+case CK_SkylakeClient:
+case CK_SkylakeServer:
+case CK_Cannonlake:
 case CK_KNL:
 case CK_Athlon64:
 case CK_Athlon64SSE3:
@@ -2618,15 +2640,28 @@ bool X86TargetInfo::initFeatureMap(
 setFeatureEnabledImpl(Features, "fxsr", true);
 setFeatureEnabledImpl(Features, "cx16", true);
 break;
-  case CK_Skylake:
+  case CK_Cannonlake:
+setFeatureEnabledImpl(Features, "avx512ifma", true);
+setFeatureEnabledImpl(Features, "avx512vbmi", true);
+setFeatureEnabledImpl(Features, "sha", true);
+setFeatureEnabledImpl(Features, "umip", true);
+// FALLTHROUGH
+  case CK_SkylakeServer:
 setFeatureEnabledImpl(Features, "avx512f", true);
 setFeatureEnabledImpl(Features, "avx512cd", true);
 setFeatureEnabledImpl(Features, "avx512dq", true);
 setFeatureEnabledImpl(Features, "avx512bw", true);
 setFeatureEnabledImpl(Features, "avx512vl", true);
+setFeatureEnabledImpl(Features, "pku", true);
+setFeatureEnabledImpl(Features, "pcommit", true);
+setFeatureEnabledImpl(Features, "clwb", true);
+// FALLTHROUGH
+  case CK_SkylakeClient:
 setFeatureEnabledImpl(Features, "xsavec", true);
 setFeatureEnabledImpl(Features, "xsaves", true);
-setFeatureEnabledImpl(Features, "pku", true);
+setFeatureEnabledImpl(Features, "mpx", true);
+setFeatureEnabledImpl(Features, "sgx", true);
+setFeatureEnabledImpl(Features, "clflushopt", true);
 // FALLTHROUGH
   case CK_Broadwell:
 setFeatureEnabledImpl(Features, "rdseed", true);
@@ -2639,6 +2674,7 @@ bool X86TargetInfo::initFeatureMap(
 setFeatureEnabledImpl(Features, "bmi2", true);
 setFeatureEnabledImpl(Features, "rtm", true);
 setFeatureEnabledImpl(Features, "fma", true);
+setFeatureEnabledImpl(Features, "movbe", true);
 // FALLTHROUGH
   case CK_IvyBridge:
 setFeatureEnabledImpl(Features, "rdrnd", true);
@@ -2665,6 +2701,7 @@ bool X86TargetInfo::initFeatureMap(
 setFeatureEnabledImpl(Features, "avx512cd", true);
 setFeatureEnabledImpl(Features, "avx512er", true);
 setFeatureEnabledImpl(Features, "avx512pf", true);
+setFeatureEnabledImpl(Features, "prefetchwt1", true);
 setFeatureEnabledImpl(Features, "fxsr", true);
 

Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct

2016-02-20 Thread Richard Smith via cfe-commits
On 20 Feb 2016 10:01 p.m., "H.J. Lu"  wrote:
>
> On Sat, Feb 20, 2016 at 9:47 PM, Richard Smith 
wrote:
> > On 20 Feb 2016 6:54 p.m., "H.J. Lu"  wrote:
> >>
> >> On Sat, Feb 20, 2016 at 4:57 PM, Matthijs van Duin
> >>  wrote:
> >> > On 20 February 2016 at 23:35, H.J. Lu  wrote:
> >> >> Can a compiler tell if a copy constructor or destructor is trivial
> >> >> from the class declaration without function body?
> >> >
> >> > Yes, the mere presence of the declaration suffices to render it
> >> > non-trivial (unless explicitly declared "= default" like I did with
> >> > the default constructor, in which case there's no function body).
> >>
> >> How about this?
> >>
> >> An empty type is a type where it and all of its subobjects
(recursively)
> >> are of class, structure, union, or array type.  An empty type may only
> >> have static member functions, default  constructor, default copy
> >> constructor, default copy assignment operator or default destructor.
> >
> > No, that's the wrong rule still. Please leave the C++ rule here to the
C++
> > ABI rather than trying to reinvent it. Whether a type is empty is
completely
> > orthogonal to whether it must be passed through memory for C++ ABI /
> > semantics reasons.
>
> What is the correct wording?  The last one:
>
> An empty type is a type where it and all of its subobjects (recursively)
> are of class, structure, union, or array type.
>
> doesn't cover "trivially-copyable".

That's correct. Whether a type is trivially copyable is unrelated to
whether it is empty.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct

2016-02-20 Thread H.J. Lu via cfe-commits
On Sat, Feb 20, 2016 at 9:47 PM, Richard Smith  wrote:
> On 20 Feb 2016 6:54 p.m., "H.J. Lu"  wrote:
>>
>> On Sat, Feb 20, 2016 at 4:57 PM, Matthijs van Duin
>>  wrote:
>> > On 20 February 2016 at 23:35, H.J. Lu  wrote:
>> >> Can a compiler tell if a copy constructor or destructor is trivial
>> >> from the class declaration without function body?
>> >
>> > Yes, the mere presence of the declaration suffices to render it
>> > non-trivial (unless explicitly declared "= default" like I did with
>> > the default constructor, in which case there's no function body).
>>
>> How about this?
>>
>> An empty type is a type where it and all of its subobjects (recursively)
>> are of class, structure, union, or array type.  An empty type may only
>> have static member functions, default  constructor, default copy
>> constructor, default copy assignment operator or default destructor.
>
> No, that's the wrong rule still. Please leave the C++ rule here to the C++
> ABI rather than trying to reinvent it. Whether a type is empty is completely
> orthogonal to whether it must be passed through memory for C++ ABI /
> semantics reasons.

What is the correct wording?  The last one:

An empty type is a type where it and all of its subobjects (recursively)
are of class, structure, union, or array type.

doesn't cover "trivially-copyable".

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


Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct

2016-02-20 Thread Richard Smith via cfe-commits
On 20 Feb 2016 6:54 p.m., "H.J. Lu"  wrote:
>
> On Sat, Feb 20, 2016 at 4:57 PM, Matthijs van Duin
>  wrote:
> > On 20 February 2016 at 23:35, H.J. Lu  wrote:
> >> Can a compiler tell if a copy constructor or destructor is trivial
> >> from the class declaration without function body?
> >
> > Yes, the mere presence of the declaration suffices to render it
> > non-trivial (unless explicitly declared "= default" like I did with
> > the default constructor, in which case there's no function body).
>
> How about this?
>
> An empty type is a type where it and all of its subobjects (recursively)
> are of class, structure, union, or array type.  An empty type may only
> have static member functions, default  constructor, default copy
> constructor, default copy assignment operator or default destructor.

No, that's the wrong rule still. Please leave the C++ rule here to the C++
ABI rather than trying to reinvent it. Whether a type is empty is
completely orthogonal to whether it must be passed through memory for C++
ABI / semantics reasons.

> No memory slot nor register should be used to pass or return an
> object of empty type.
>
> --
> H.J.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r261466 - Class Property: Fix a crash with old ABI when generating metadata in classes.

2016-02-20 Thread Manman Ren via cfe-commits
Author: mren
Date: Sat Feb 20 23:31:05 2016
New Revision: 261466

URL: http://llvm.org/viewvc/llvm-project?rev=261466=rev
Log:
Class Property: Fix a crash with old ABI when generating metadata in classes.

rdar://23891898

Modified:
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/test/CodeGenObjC/metadata-class-properties.m

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=261466=261465=261466=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Sat Feb 20 23:31:05 2016
@@ -3446,8 +3446,10 @@ CGObjCMac::EmitClassExtension(const ObjC
 
   llvm::Constant *Values[3];
   Values[0] = llvm::ConstantInt::get(ObjCTypes.IntTy, Size);
-  Values[1] = nullptr;
-  if (!isClassProperty)
+  if (isClassProperty) {
+llvm::Type *PtrTy = CGM.Int8PtrTy;
+Values[1] = llvm::Constant::getNullValue(PtrTy);
+  } else
 Values[1] = BuildWeakIvarLayout(ID, CharUnits::Zero(), InstanceSize,
 hasMRCWeakIvars);
   if (isClassProperty)

Modified: cfe/trunk/test/CodeGenObjC/metadata-class-properties.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/metadata-class-properties.m?rev=261466=261465=261466=diff
==
--- cfe/trunk/test/CodeGenObjC/metadata-class-properties.m (original)
+++ cfe/trunk/test/CodeGenObjC/metadata-class-properties.m Sat Feb 20 23:31:05 
2016
@@ -6,6 +6,9 @@
 // CHECK: @"\01l_OBJC_$_CLASS_PROP_LIST_Foo_$_Category" = private global 
{{.*}} section "__DATA, __objc_const", align 8
 // CHECK: @"\01l_OBJC_$_CATEGORY_Foo_$_Category" = private global 
%struct._category_t { {{.*}} @"\01l_OBJC_$_CLASS_PROP_LIST_Foo_$_Category" 
{{.*}} }, section "__DATA, __objc_const", align 8
 
+// CHECK: @"\01l_OBJC_$_CLASS_PROP_LIST_C" = private global {{.*}} section 
"__DATA, __objc_const", align 8
+// CHECK: @"\01l_OBJC_METACLASS_RO_$_C" = private global %struct._class_ro_t { 
{{.*}} @"\01l_OBJC_$_CLASS_PROP_LIST_C" {{.*}} }, section "__DATA, 
__objc_const", align 8
+
 // CHECK: !{i32 1, !"Objective-C Class Properties", i32 64}
 
 // CHECK-FRAGILE: @"OBJC_$_CLASS_PROP_PROTO_LIST_Proto" = private global 
{{.*}} section "__OBJC,__property,regular,no_dead_strip", align 8
@@ -13,6 +16,9 @@
 // CHECK-FRAGILE: @"\01l_OBJC_$_CLASS_PROP_LIST_Foo_Category" = private global 
{{.*}} section "__OBJC,__property,regular,no_dead_strip", align 8
 // CHECK-FRAGILE: @OBJC_CATEGORY_Foo_Category = private global 
%struct._objc_category { {{.*}}, i32 64, {{.*}} 
@"\01l_OBJC_$_CLASS_PROP_LIST_Foo_Category" {{.*}} }, section 
"__OBJC,__category,regular,no_dead_strip", align 8
 
+// CHECK-FRAGILE: @"\01l_OBJC_$_CLASS_PROP_LIST_C" = private global {{.*}} 
section "__OBJC,__property,regular,no_dead_strip", align 8
+// CHECK-FRAGILE: @OBJC_CLASSEXT_C = private global 
%struct._objc_class_extension { {{.*}} @"\01l_OBJC_$_CLASS_PROP_LIST_C" {{.*}} 
}, section "__OBJC,__class_ext,regular,no_dead_strip", align 8
+
 // CHECK-FRAGILE: !{i32 1, !"Objective-C Class Properties", i32 64}
 
 @interface Foo @end
@@ -26,3 +32,11 @@
 @implementation Foo (Category)
 +(int)proto_property { return 0; }
 @end
+
+__attribute__((objc_root_class))
+@interface C
+@property(class, readonly) int p;
+@end
+@implementation C
++(int)p { return 1; }
+@end


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


[PATCH] D17488: Extend UnnecessaryCopyInitialization check to trigger on non-const copies that can be safely converted to const references.

2016-02-20 Thread Felix Berger via cfe-commits
flx created this revision.
flx added a reviewer: alexfh.
flx added a subscriber: cfe-commits.
flx set the repository for this revision to rL LLVM.

Move code shared between UnnecessaryCopyInitialization and ForRangeCopyCheck 
into utilities files.
Add more test cases for UnnecessaryCopyInitialization and disable fixes inside 
of macros.

Repository:
  rL LLVM

http://reviews.llvm.org/D17488

Files:
  clang-tidy/performance/ForRangeCopyCheck.cpp
  clang-tidy/performance/UnnecessaryCopyInitialization.cpp
  clang-tidy/performance/UnnecessaryCopyInitialization.h
  clang-tidy/utils/CMakeLists.txt
  clang-tidy/utils/DeclRefExprUtils.cpp
  clang-tidy/utils/DeclRefExprUtils.h
  clang-tidy/utils/FixItHintUtils.cpp
  clang-tidy/utils/FixItHintUtils.h
  test/clang-tidy/performance-unnecessary-copy-initialization.cpp

Index: test/clang-tidy/performance-unnecessary-copy-initialization.cpp
===
--- test/clang-tidy/performance-unnecessary-copy-initialization.cpp
+++ test/clang-tidy/performance-unnecessary-copy-initialization.cpp
@@ -4,6 +4,7 @@
   ExpensiveToCopyType() {}
   virtual ~ExpensiveToCopyType() {}
   const ExpensiveToCopyType () const { return *this; }
+  void nonConstMethod() {}
 };
 
 struct TrivialToCopyType {
@@ -20,6 +21,11 @@
   return *Type;
 }
 
+void mutate(ExpensiveToCopyType &);
+void mutate(ExpensiveToCopyType *);
+void useAsConstReference(const ExpensiveToCopyType &);
+void useByValue(ExpensiveToCopyType);
+
 void PositiveFunctionCall() {
   const auto AutoAssigned = ExpensiveTypeReference();
   // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 'AutoAssigned' is copy-constructed from a const reference; consider making it a const reference [performance-unnecessary-copy-initialization]
@@ -114,11 +120,53 @@
   static const auto StaticVar = Obj.reference();
 }
 
-void NegativeFunctionCallExpensiveTypeNonConstVariable() {
+void PositiveFunctionCallExpensiveTypeNonConstVariable() {
   auto AutoAssigned = ExpensiveTypeReference();
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: the variable 'AutoAssigned' is copy-constructed from a const reference but is only used as const reference; consider making it a const reference [performance-unnecessary-copy-initialization]
+  // CHECK-FIXES: const auto& AutoAssigned = ExpensiveTypeReference();
   auto AutoCopyConstructed(ExpensiveTypeReference());
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: the variable
+  // CHECK-FIXES: const auto& AutoCopyConstructed(ExpensiveTypeReference());
   ExpensiveToCopyType VarAssigned = ExpensiveTypeReference();
+  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: the variable
+  // CHECK-FIXES: const ExpensiveToCopyType& VarAssigned = ExpensiveTypeReference();
   ExpensiveToCopyType VarCopyConstructed(ExpensiveTypeReference());
+  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: the variable
+  // CHECK-FIXES: const ExpensiveToCopyType& VarCopyConstructed(ExpensiveTypeReference());
+}
+
+void positiveNonConstVarInCodeBlock(const ExpensiveToCopyType ) {
+  {
+auto Assigned = Obj.reference();
+// CHECK-MESSAGES: [[@LINE-1]]:10: warning: the variable
+// CHECK-FIXES: const auto& Assigned = Obj.reference();
+Assigned.reference();
+useAsConstReference(Assigned);
+useByValue(Assigned);
+  }
+}
+
+void negativeNonConstVarWithNonConstUse(const ExpensiveToCopyType ) {
+  {
+auto NonConstInvoked = Obj.reference();
+// CHECK-FIXES: auto NonConstInvoked = Obj.reference();
+NonConstInvoked.nonConstMethod();
+  }
+  {
+auto Reassigned = Obj.reference();
+// CHECK-FIXES: auto Reassigned = Obj.reference();
+Reassigned = ExpensiveToCopyType();
+  }
+  {
+auto MutatedByReference = Obj.reference();
+// CHECK-FIXES: auto MutatedByReference = Obj.reference();
+mutate(MutatedByReference);
+  }
+  {
+auto MutatedByPointer = Obj.reference();
+// CHECK-FIXES: auto MutatedByPointer = Obj.reference();
+mutate();
+  }
 }
 
 void NegativeMethodCallNonConstRef(ExpensiveToCopyType ) {
@@ -146,11 +194,32 @@
   ExpensiveToCopyType Obj;
   const auto AutoAssigned = Obj.reference();
   const auto AutoCopyConstructed(Obj.reference());
-  const ExpensiveToCopyType VarAssigned = Obj.reference();
-  const ExpensiveToCopyType VarCopyConstructed(Obj.reference());
+  ExpensiveToCopyType VarAssigned = Obj.reference();
+  ExpensiveToCopyType VarCopyConstructed(Obj.reference());
 }
 
 struct NegativeConstructor {
   NegativeConstructor(const ExpensiveToCopyType ) : Obj(Obj) {}
   ExpensiveToCopyType Obj;
 };
+
+#define UNNECESSARY_COPY_INIT_IN_MACRO_BODY(TYPE)	\
+  void functionWith##TYPE(const TYPE& T) {		\
+auto AssignedInMacro = T.reference();		\
+  }			\
+// Ensure fix is not applied.
+// CHECK-FIXES: auto AssignedInMacro = T.reference();
+
+
+UNNECESSARY_COPY_INIT_IN_MACRO_BODY(ExpensiveToCopyType)
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: the variable 'AssignedInMacro' is copy-constructed
+
+#define 

Re: [PATCH] D16928: [OpenCL] Apply missing restrictions for Blocks in OpenCL v2.0

2016-02-20 Thread Xiuli PAN via cfe-commits
pxli168 accepted this revision.
pxli168 added a comment.
This revision is now accepted and ready to land.

LGTM!
Thanks


http://reviews.llvm.org/D16928



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


Re: [PATCH] D16928: [OpenCL] Apply missing restrictions for Blocks in OpenCL v2.0

2016-02-20 Thread Xiuli PAN via cfe-commits
pxli168 added a comment.

LGTM!
Thanks.


http://reviews.llvm.org/D16928



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


Re: [PATCH] D17484: [clang-tidy] introduce modernize-deprecated-headers check

2016-02-20 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a comment.

Another idea: to replace limits.h with limits and also replace its defines with 
their C++ counterparts. For example, INT_MIN with numeric_limits::min().

Will be definitely useful for LLDB code modernization.


http://reviews.llvm.org/D17484



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


Re: [PATCH] D17091: [analyzer][scan-build-py] Non-existing directory for scan-build output.

2016-02-20 Thread Laszlo Nagy via cfe-commits
rizsotto.mailinglist added a comment.

the semicolon at the end of line 39 is an issue for PEP8. please remove it.


http://reviews.llvm.org/D17091



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


Re: [PATCH] D17091: [analyzer][scan-build-py] Non-existing directory for scan-build output.

2016-02-20 Thread Laszlo Nagy via cfe-commits
rizsotto.mailinglist accepted this revision.
rizsotto.mailinglist added a comment.
This revision is now accepted and ready to land.

thanks Anton, LGTM!


http://reviews.llvm.org/D17091



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


Re: [PATCH] D17484: [clang-tidy] introduce modernize-deprecated-headers check

2016-02-20 Thread Richard via cfe-commits
LegalizeAdulthood added a comment.

Other than a few nits, LGTM.



Comment at: clang-tidy/modernize/DeprecatedHeadersCheck.cpp:54
@@ +53,3 @@
+: Check(Check), LangOpts(LangOpts) {
+  CStyledHeaderToCxx["assert.h"] = "cassert";
+  CStyledHeaderToCxx["float.h"] = "cfloat";

Can't we use C++11 brace initialization here instead of repeated assignments?


Comment at: docs/clang-tidy/checks/modernize-deprecated-headers.rst:33
@@ +32,3 @@
+
+The following headers were deprecated before C++ 11:
+

Can we sort these lists of includes?  Otherwise it's hard to find a specific 
include in the list.


Comment at: test/clang-tidy/modernize-deprecated-headers-cxx11.cpp:3
@@ +2,3 @@
+
+#include "assert.h"
+#include "float.h"

Can we sort the includes in the test files too please?


http://reviews.llvm.org/D17484



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


Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct

2016-02-20 Thread Marc Glisse via cfe-commits

On Sat, 20 Feb 2016, H.J. Lu wrote:


On Fri, Feb 19, 2016 at 1:07 PM, Richard Smith  wrote:

On Fri, Feb 19, 2016 at 5:35 AM, Michael Matz  wrote:

Hi,

On Thu, 18 Feb 2016, Richard Smith wrote:


An empty type is a type where it and all of its subobjects
(recursively) are of class, structure, union, or array type.  No
memory slot nor register should be used to pass or return an object
of empty type.


The trivially copyable is gone again.  Why is it not necessary?


The C++ ABI doesn't defer to the C psABI for types that aren't
trivially-copyable. See
http://mentorembedded.github.io/cxx-abi/abi.html#normal-call


Hmm, yes, but we don't want to define something for only C and C++, but
language independend (so far as possible).  And given only the above
language I think this type:

struct S {
  S() {something();}
};

would be an empty type, and that's not what we want.


Yes it is. Did you mean to give S a copy constructor, copy assignment
operator, or destructor instead?


"Trivially copyable"
is a reasonably common abstraction (if in doubt we could even define it in
the ABI), and captures the idea that we need well (namely that a bit-copy
is enough).


In this case:

struct dummy0
{
};

struct dummy
{
 dummy0 d[20];

 dummy0 * foo (int i);
};

dummy0 *
dummy::foo (int i)
{
 return [i];
}

dummy0 *
bar (dummy d, int i)
{
 return d.foo (i);
}

dummy shouldn't be passed as empty type.


Why not?

We need to have a clear definition for what kinds of member functions 
are allowed in an empty type.


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


Re: r260872 - Add isAnyPointer() matchers. Register missing matchers.

2016-02-20 Thread Aaron Ballman via cfe-commits
On Sat, Feb 20, 2016 at 7:48 PM, Felix Berger  wrote:
>
>
> On Mon, Feb 15, 2016 at 8:05 AM, Aaron Ballman 
> wrote:
>>
>> On Sun, Feb 14, 2016 at 11:00 PM, Felix Berger via cfe-commits
>>  wrote:
>> > Author: flx
>> > Date: Sun Feb 14 22:00:39 2016
>> > New Revision: 260872
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=260872=rev
>> > Log:
>> > Add isAnyPointer() matchers. Register missing matchers.
>> >
>> > Summary:
>> > The isAnyPointer() matcher is useful for http://reviews.llvm.org/D15623.
>> >
>> > Reviewers: alexfh, klimek
>> >
>> > Subscribers: cfe-commits
>> >
>> > Differential Revision: http://reviews.llvm.org/D15819
>> >
>> > Modified:
>> > cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
>> > cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
>> > cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
>> >
>> > Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=260872=260871=260872=diff
>> >
>> > ==
>> > --- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
>> > +++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Sun Feb 14
>> > 22:00:39 2016
>> > @@ -3673,6 +3673,19 @@ AST_MATCHER(QualType, isAnyCharacter) {
>> >  return Node->isAnyCharacterType();
>> >  }
>> >
>> > + \brief Matches QualType nodes that are of any pointer type.
>> > +///
>> > +/// Given
>> > +/// \code
>> > +///   int *i = nullptr;
>> > +///   int j;
>> > +/// \endcode
>> > +/// varDecl(hasType(isAnyPointer()))
>> > +///   matches "int *i", but not "int j".
>> > +AST_MATCHER(QualType, isAnyPointer) {
>> > +  return Node->isAnyPointerType();
>> > +}
>>
>> The whole point to isAnyPointer() is for objective C types, where
>> pointers are modeled differently. Can you add documentation, an
>> example, and tests for that fact?
>>
>
> Thanks for making me look into this further. After looking through the
> existing test cases and matchers I found there is already a pointerType()
> matcher which is the matcher I originally wanted to expose.
>
> I can do one of two things now:
>
> Keep the new isAnyPointer() matcher if we think it's useful and add an objc
> pointer test for it which is already in the works.
> Remove the matcher again since there is no real need for it and users could
> get the same by writing anyOf(pointerType(), objcObjectPointerType())
>
> What do you think?

We try to avoid adding matchers for the sake of having them, but I
know I've been bitten a few times by forgetting that an Objective-C
pointer type is not actually a pointer type, so I think that keeping
isAnyPointer() would be generally useful.

~Aaron

>
>>
>> ~Aaron
>>
>> > +
>> >  /// \brief Matches QualType nodes that are const-qualified, i.e., that
>> >  /// include "top-level" const.
>> >  ///
>> >
>> > Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp?rev=260872=260871=260872=diff
>> >
>> > ==
>> > --- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp (original)
>> > +++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp Sun Feb 14 22:00:39
>> > 2016
>> > @@ -264,6 +264,8 @@ RegistryMaps::RegistryMaps() {
>> >REGISTER_MATCHER(innerType);
>> >REGISTER_MATCHER(integerLiteral);
>> >REGISTER_MATCHER(isAnonymous);
>> > +  REGISTER_MATCHER(isAnyCharacter);
>> > +  REGISTER_MATCHER(isAnyPointer);
>> >REGISTER_MATCHER(isArrow);
>> >REGISTER_MATCHER(isBaseInitializer);
>> >REGISTER_MATCHER(isCatchAll);
>> >
>> > Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp?rev=260872=260871=260872=diff
>> >
>> > ==
>> > --- cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp (original)
>> > +++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp Sun Feb 14
>> > 22:00:39 2016
>> > @@ -1479,6 +1479,14 @@ TEST(IsInteger, ReportsNoFalsePositives)
>> >to(varDecl(hasType(isInteger();
>> >  }
>> >
>> > +TEST(IsAnyPointer, MatchesPointers) {
>> > +  EXPECT_TRUE(matches("int* i = nullptr;",
>> > varDecl(hasType(isAnyPointer();
>> > +}
>> > +
>> > +TEST(IsAnyPointer, ReportsNoFalsePositives) {
>> > +  EXPECT_TRUE(notMatches("int i = 0;",
>> > varDecl(hasType(isAnyPointer();
>> > +}
>> > +
>> >  TEST(IsAnyCharacter, MatchesCharacters) {
>> >EXPECT_TRUE(matches("char i = 0;",
>> > varDecl(hasType(isAnyCharacter();
>> >  }
>> >
>> >
>> > ___
>> > cfe-commits mailing list
>> > cfe-commits@lists.llvm.org
>> > 

Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct

2016-02-20 Thread Matthijs van Duin via cfe-commits
On 20 February 2016 at 23:35, H.J. Lu  wrote:
> Can a compiler tell if a copy constructor or destructor is trivial
> from the class declaration without function body?

Yes, the mere presence of the declaration suffices to render it
non-trivial (unless explicitly declared "= default" like I did with
the default constructor, in which case there's no function body).
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r260872 - Add isAnyPointer() matchers. Register missing matchers.

2016-02-20 Thread Felix Berger via cfe-commits
On Mon, Feb 15, 2016 at 8:05 AM, Aaron Ballman 
wrote:

> On Sun, Feb 14, 2016 at 11:00 PM, Felix Berger via cfe-commits
>  wrote:
> > Author: flx
> > Date: Sun Feb 14 22:00:39 2016
> > New Revision: 260872
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=260872=rev
> > Log:
> > Add isAnyPointer() matchers. Register missing matchers.
> >
> > Summary:
> > The isAnyPointer() matcher is useful for http://reviews.llvm.org/D15623.
> >
> > Reviewers: alexfh, klimek
> >
> > Subscribers: cfe-commits
> >
> > Differential Revision: http://reviews.llvm.org/D15819
> >
> > Modified:
> > cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
> > cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
> > cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
> >
> > Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=260872=260871=260872=diff
> >
> ==
> > --- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
> > +++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Sun Feb 14
> 22:00:39 2016
> > @@ -3673,6 +3673,19 @@ AST_MATCHER(QualType, isAnyCharacter) {
> >  return Node->isAnyCharacterType();
> >  }
> >
> > + \brief Matches QualType nodes that are of any pointer type.
> > +///
> > +/// Given
> > +/// \code
> > +///   int *i = nullptr;
> > +///   int j;
> > +/// \endcode
> > +/// varDecl(hasType(isAnyPointer()))
> > +///   matches "int *i", but not "int j".
> > +AST_MATCHER(QualType, isAnyPointer) {
> > +  return Node->isAnyPointerType();
> > +}
>
> The whole point to isAnyPointer() is for objective C types, where
> pointers are modeled differently. Can you add documentation, an
> example, and tests for that fact?
>
>
Thanks for making me look into this further. After looking through the
existing test cases and matchers I found there is already a pointerType()
matcher which is the matcher I originally wanted to expose.

I can do one of two things now:

   1. Keep the new isAnyPointer() matcher if we think it's useful and add
   an objc pointer test for it which is already in the works.
   2. Remove the matcher again since there is no real need for it and users
   could get the same by writing anyOf(pointerType(), objcObjectPointerType())

What do you think?


> ~Aaron
>
> > +
> >  /// \brief Matches QualType nodes that are const-qualified, i.e., that
> >  /// include "top-level" const.
> >  ///
> >
> > Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp?rev=260872=260871=260872=diff
> >
> ==
> > --- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp (original)
> > +++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp Sun Feb 14 22:00:39
> 2016
> > @@ -264,6 +264,8 @@ RegistryMaps::RegistryMaps() {
> >REGISTER_MATCHER(innerType);
> >REGISTER_MATCHER(integerLiteral);
> >REGISTER_MATCHER(isAnonymous);
> > +  REGISTER_MATCHER(isAnyCharacter);
> > +  REGISTER_MATCHER(isAnyPointer);
> >REGISTER_MATCHER(isArrow);
> >REGISTER_MATCHER(isBaseInitializer);
> >REGISTER_MATCHER(isCatchAll);
> >
> > Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp?rev=260872=260871=260872=diff
> >
> ==
> > --- cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp (original)
> > +++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp Sun Feb 14
> 22:00:39 2016
> > @@ -1479,6 +1479,14 @@ TEST(IsInteger, ReportsNoFalsePositives)
> >to(varDecl(hasType(isInteger();
> >  }
> >
> > +TEST(IsAnyPointer, MatchesPointers) {
> > +  EXPECT_TRUE(matches("int* i = nullptr;",
> varDecl(hasType(isAnyPointer();
> > +}
> > +
> > +TEST(IsAnyPointer, ReportsNoFalsePositives) {
> > +  EXPECT_TRUE(notMatches("int i = 0;",
> varDecl(hasType(isAnyPointer();
> > +}
> > +
> >  TEST(IsAnyCharacter, MatchesCharacters) {
> >EXPECT_TRUE(matches("char i = 0;",
> varDecl(hasType(isAnyCharacter();
> >  }
> >
> >
> > ___
> > 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


r261461 - Lex: Never overflow the file in HeaderMap::lookupFilename()

2016-02-20 Thread Duncan P. N. Exon Smith via cfe-commits
Author: dexonsmith
Date: Sat Feb 20 18:14:36 2016
New Revision: 261461

URL: http://llvm.org/viewvc/llvm-project?rev=261461=rev
Log:
Lex: Never overflow the file in HeaderMap::lookupFilename()

If a header map file is corrupt, the strings in the string table may not
be null-terminated.  The logic here previously relied on `MemoryBuffer`
always being null-terminated, but this isn't actually guaranteed by the
class AFAICT.  Moreover, we're seeing a lot of crash traces at calls to
`strlen()` inside of `lookupFilename()`, so something is going wrong
there.

Instead, use `strnlen()` to get the length, and check for corruption.

Also remove code paths that could call `StringRef(nullptr)`.  r261459
made these rather obvious (although they'd been there all along).

Modified:
cfe/trunk/lib/Lex/HeaderMap.cpp
cfe/trunk/unittests/Lex/HeaderMapTest.cpp

Modified: cfe/trunk/lib/Lex/HeaderMap.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderMap.cpp?rev=261461=261460=261461=diff
==
--- cfe/trunk/lib/Lex/HeaderMap.cpp (original)
+++ cfe/trunk/lib/Lex/HeaderMap.cpp Sat Feb 20 18:14:36 2016
@@ -21,6 +21,7 @@
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/SwapByteOrder.h"
 #include "llvm/Support/Debug.h"
+#include 
 #include 
 using namespace clang;
 
@@ -151,12 +152,17 @@ StringRef HeaderMapImpl::getString(unsig
 
   // Check for invalid index.
   if (StrTabIdx >= FileBuffer->getBufferSize())
-return nullptr;
+return "";
+
+  const char *Data = FileBuffer->getBufferStart() + StrTabIdx;
+  unsigned MaxLen = FileBuffer->getBufferSize() - StrTabIdx;
+  unsigned Len = strnlen(Data, MaxLen);
+
+  // Check whether the buffer is null-terminated.
+  if (Len == MaxLen && Data[Len - 1])
+return "";
 
-  // Otherwise, we have a valid pointer into the file.  Just return it.  We 
know
-  // that the "string" can not overrun the end of the file, because the buffer
-  // is nul terminated by virtue of being a MemoryBuffer.
-  return FileBuffer->getBufferStart()+StrTabIdx;
+  return StringRef(Data, Len);
 }
 
 
//===--===//

Modified: cfe/trunk/unittests/Lex/HeaderMapTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Lex/HeaderMapTest.cpp?rev=261461=261460=261461=diff
==
--- cfe/trunk/unittests/Lex/HeaderMapTest.cpp (original)
+++ cfe/trunk/unittests/Lex/HeaderMapTest.cpp Sat Feb 20 18:14:36 2016
@@ -14,6 +14,7 @@
 #include "llvm/Support/SwapByteOrder.h"
 #include "gtest/gtest.h"
 #include 
+#include 
 
 using namespace clang;
 using namespace llvm;
@@ -170,4 +171,45 @@ TEST(HeaderMapTest, lookupFilename) {
   ASSERT_EQ("bc", Map.lookupFilename("a", DestPath));
 }
 
+template  struct PaddedFile {
+  FileTy File;
+  PaddingTy Padding;
+};
+
+TEST(HeaderMapTest, lookupFilenameTruncated) {
+  typedef MapFile<2, 64 - sizeof(HMapHeader) - 2 * sizeof(HMapBucket)> FileTy;
+  static_assert(std::is_standard_layout::value,
+"Expected standard layout");
+  static_assert(sizeof(FileTy) == 64, "check the math");
+  PaddedFile P;
+  auto  = P.File;
+  auto  = P.Padding;
+  File.init();
+
+  FileMaker Maker(File);
+  auto a = Maker.addString("a");
+  auto b = Maker.addString("b");
+  auto c = Maker.addString("c");
+  Maker.addBucket(getHash("a"), a, b, c);
+
+  // Add 'x' characters to cause an overflow into Padding.
+  ASSERT_EQ('c', File.Bytes[5]);
+  for (unsigned I = 6; I < sizeof(File.Bytes); ++I) {
+ASSERT_EQ(0, File.Bytes[I]);
+File.Bytes[I] = 'x';
+  }
+  Padding = 0x; // Padding won't stop it either.
+
+  bool NeedsSwap;
+  ASSERT_TRUE(HeaderMapImpl::checkHeader(*File.getBuffer(), NeedsSwap));
+  ASSERT_FALSE(NeedsSwap);
+  HeaderMapImpl Map(File.getBuffer(), NeedsSwap);
+
+  // The string for "c" runs to the end of File.  Check that the suffix
+  // ("c...") is ignored.  Another option would be to return an empty
+  // filename altogether.
+  SmallString<24> DestPath;
+  ASSERT_EQ("b", Map.lookupFilename("a", DestPath));
+}
+
 } // end namespace


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


r261459 - Lex: Change HeaderMapImpl::getString() to return StringRef, NFC

2016-02-20 Thread Duncan P. N. Exon Smith via cfe-commits
Author: dexonsmith
Date: Sat Feb 20 17:12:51 2016
New Revision: 261459

URL: http://llvm.org/viewvc/llvm-project?rev=261459=rev
Log:
Lex: Change HeaderMapImpl::getString() to return StringRef, NFC

Modified:
cfe/trunk/include/clang/Lex/HeaderMap.h
cfe/trunk/lib/Lex/HeaderMap.cpp

Modified: cfe/trunk/include/clang/Lex/HeaderMap.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderMap.h?rev=261459=261458=261459=diff
==
--- cfe/trunk/include/clang/Lex/HeaderMap.h (original)
+++ cfe/trunk/include/clang/Lex/HeaderMap.h Sat Feb 20 17:12:51 2016
@@ -53,7 +53,7 @@ private:
   unsigned getEndianAdjustedWord(unsigned X) const;
   const HMapHeader () const;
   HMapBucket getBucket(unsigned BucketNo) const;
-  const char *getString(unsigned StrTabIdx) const;
+  StringRef getString(unsigned StrTabIdx) const;
 };
 
 /// This class represents an Apple concept known as a 'header map'.  To the

Modified: cfe/trunk/lib/Lex/HeaderMap.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderMap.cpp?rev=261459=261458=261459=diff
==
--- cfe/trunk/lib/Lex/HeaderMap.cpp (original)
+++ cfe/trunk/lib/Lex/HeaderMap.cpp Sat Feb 20 17:12:51 2016
@@ -145,7 +145,7 @@ HMapBucket HeaderMapImpl::getBucket(unsi
 
 /// getString - Look up the specified string in the string table.  If the 
string
 /// index is not valid, it returns an empty string.
-const char *HeaderMapImpl::getString(unsigned StrTabIdx) const {
+StringRef HeaderMapImpl::getString(unsigned StrTabIdx) const {
   // Add the start of the string table to the idx.
   StrTabIdx += getEndianAdjustedWord(getHeader().StringsOffset);
 
@@ -175,9 +175,9 @@ LLVM_DUMP_METHOD void HeaderMapImpl::dum
 HMapBucket B = getBucket(i);
 if (B.Key == HMAP_EmptyBucketKey) continue;
 
-const char *Key= getString(B.Key);
-const char *Prefix = getString(B.Prefix);
-const char *Suffix = getString(B.Suffix);
+StringRef Key= getString(B.Key);
+StringRef Prefix = getString(B.Prefix);
+StringRef Suffix = getString(B.Suffix);
 llvm::dbgs() << "  " << i << ". " << Key << " -> '" << Prefix << "' '"
  << Suffix << "'\n";
   }


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


r261456 - Lex: Use dbgs() instead of fprintf() in HeaderMap::dump()

2016-02-20 Thread Duncan P. N. Exon Smith via cfe-commits
Author: dexonsmith
Date: Sat Feb 20 17:09:14 2016
New Revision: 261456

URL: http://llvm.org/viewvc/llvm-project?rev=261456=rev
Log:
Lex: Use dbgs() instead of fprintf() in HeaderMap::dump()

This way it's easy to change HeaderMapImpl::getString() to return a
StringRef.

There's a slight change here, because I used `errs()` instead of
`dbgs()`.  But `dbgs()` is more appropriate for a dump method.

Modified:
cfe/trunk/lib/Lex/HeaderMap.cpp

Modified: cfe/trunk/lib/Lex/HeaderMap.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderMap.cpp?rev=261456=261455=261456=diff
==
--- cfe/trunk/lib/Lex/HeaderMap.cpp (original)
+++ cfe/trunk/lib/Lex/HeaderMap.cpp Sat Feb 20 17:09:14 2016
@@ -20,7 +20,7 @@
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/SwapByteOrder.h"
-#include 
+#include "llvm/Support/Debug.h"
 #include 
 using namespace clang;
 
@@ -168,9 +168,8 @@ LLVM_DUMP_METHOD void HeaderMapImpl::dum
   const HMapHeader  = getHeader();
   unsigned NumBuckets = getEndianAdjustedWord(Hdr.NumBuckets);
 
-  fprintf(stderr, "Header Map %s:\n  %d buckets, %d entries\n",
-  getFileName(), NumBuckets,
-  getEndianAdjustedWord(Hdr.NumEntries));
+  llvm::dbgs() << "Header Map " << getFileName() << ":\n  " << NumBuckets
+   << ", " << getEndianAdjustedWord(Hdr.NumEntries) << "\n";
 
   for (unsigned i = 0; i != NumBuckets; ++i) {
 HMapBucket B = getBucket(i);
@@ -179,7 +178,8 @@ LLVM_DUMP_METHOD void HeaderMapImpl::dum
 const char *Key= getString(B.Key);
 const char *Prefix = getString(B.Prefix);
 const char *Suffix = getString(B.Suffix);
-fprintf(stderr, "  %d. %s -> '%s' '%s'\n", i, Key, Prefix, Suffix);
+llvm::dbgs() << "  " << i << ". " << Key << " -> '" << Prefix << "' '"
+ << Suffix << "'\n";
   }
 }
 


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


r261455 - Lex: Add a test for HeaderMap::lookupFileName()

2016-02-20 Thread Duncan P. N. Exon Smith via cfe-commits
Author: dexonsmith
Date: Sat Feb 20 16:53:22 2016
New Revision: 261455

URL: http://llvm.org/viewvc/llvm-project?rev=261455=rev
Log:
Lex: Add a test for HeaderMap::lookupFileName()

Add a simple test for `HeaderMap::lookupFileName()`.  I'm planning to
add better error checking in a moment, and I'll add more tests like this
then.

Modified:
cfe/trunk/unittests/Lex/HeaderMapTest.cpp

Modified: cfe/trunk/unittests/Lex/HeaderMapTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Lex/HeaderMapTest.cpp?rev=261455=261454=261455=diff
==
--- cfe/trunk/unittests/Lex/HeaderMapTest.cpp (original)
+++ cfe/trunk/unittests/Lex/HeaderMapTest.cpp Sat Feb 20 16:53:22 2016
@@ -7,10 +7,13 @@
 //
 //===--===//
 
+#include "clang/Basic/CharInfo.h"
 #include "clang/Lex/HeaderMap.h"
 #include "clang/Lex/HeaderMapTypes.h"
+#include "llvm/ADT/SmallString.h"
 #include "llvm/Support/SwapByteOrder.h"
 #include "gtest/gtest.h"
+#include 
 
 using namespace clang;
 using namespace llvm;
@@ -47,6 +50,45 @@ template  struct FileMaker {
+  FileTy 
+  unsigned SI = 1;
+  unsigned BI = 0;
+  FileMaker(FileTy ) : File(File) {}
+
+  unsigned addString(StringRef S) {
+assert(SI + S.size() + 1 <= sizeof(File.Bytes));
+std::copy(S.begin(), S.end(), File.Bytes + SI);
+auto OldSI = SI;
+SI += S.size() + 1;
+return OldSI;
+  }
+  void addBucket(unsigned Hash, unsigned Key, unsigned Prefix, unsigned 
Suffix) {
+assert(!(File.Header.NumBuckets & (File.Header.NumBuckets - 1)));
+unsigned I = Hash & (File.Header.NumBuckets - 1);
+do {
+  if (!File.Buckets[I].Key) {
+File.Buckets[I].Key = Key;
+File.Buckets[I].Prefix = Prefix;
+File.Buckets[I].Suffix = Suffix;
+++File.Header.NumEntries;
+return;
+  }
+  ++I;
+  I &= File.Header.NumBuckets - 1;
+} while (I != (Hash & (File.Header.NumBuckets - 1)));
+llvm_unreachable("no empty buckets");
+  }
+};
+
 TEST(HeaderMapTest, checkHeaderEmpty) {
   bool NeedsSwap;
   ASSERT_FALSE(HeaderMapImpl::checkHeader(
@@ -108,4 +150,24 @@ TEST(HeaderMapTest, checkHeaderNotEnough
   ASSERT_FALSE(HeaderMapImpl::checkHeader(*File.getBuffer(), NeedsSwap));
 }
 
+TEST(HeaderMapTest, lookupFilename) {
+  typedef MapFile<2, 7> FileTy;
+  FileTy File;
+  File.init();
+
+  FileMaker Maker(File);
+  auto a = Maker.addString("a");
+  auto b = Maker.addString("b");
+  auto c = Maker.addString("c");
+  Maker.addBucket(getHash("a"), a, b, c);
+
+  bool NeedsSwap;
+  ASSERT_TRUE(HeaderMapImpl::checkHeader(*File.getBuffer(), NeedsSwap));
+  ASSERT_FALSE(NeedsSwap);
+  HeaderMapImpl Map(File.getBuffer(), NeedsSwap);
+
+  SmallString<8> DestPath;
+  ASSERT_EQ("bc", Map.lookupFilename("a", DestPath));
+}
+
 } // end namespace


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


Re: [PATCH] D17362: [Sema] PR23090 Crash when return type or parameter types for extern "C" functions don't have external linkage

2016-02-20 Thread don hinton via cfe-commits
hintonda updated this revision to Diff 48601.
hintonda added a comment.

Fixed additional tests.


http://reviews.llvm.org/D17362

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  test/CXX/drs/dr3xx.cpp
  test/Sema/pr23090-crash-on-invalid.cpp
  test/SemaCXX/warn-unused-filescoped.cpp

Index: test/SemaCXX/warn-unused-filescoped.cpp
===
--- test/SemaCXX/warn-unused-filescoped.cpp
+++ test/SemaCXX/warn-unused-filescoped.cpp
@@ -121,7 +121,7 @@
   namespace { struct A {}; }
 
   void test(A a); // expected-warning {{unused function}}
-  extern "C" void test4(A a);
+  extern "C" void test4(A a); // expected-error {{'test4' has C-linkage 
specified, but parameter type 'test4::(anonymous namespace)::A' has internal 
linkage}}
 }
 
 namespace rdar8733476 {
Index: test/Sema/pr23090-crash-on-invalid.cpp
===
--- /dev/null
+++ test/Sema/pr23090-crash-on-invalid.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// Don't crash (PR23090).
+
+namespace {
+
+// check return type
+struct A;
+extern "C" A *foo(); // expected-error {{'foo' has C-linkage specified, but 
return type '(anonymous namespace)::A *' has internal linkage}}
+A *foo();
+
+// check parameter
+struct B;
+extern "C" void bar(B*); // expected-error {{'bar' has C-linkage specified, 
but parameter type '(anonymous namespace)::B *' has internal linkage}}
+void bar(B*);
+
+}
Index: test/CXX/drs/dr3xx.cpp
===
--- test/CXX/drs/dr3xx.cpp
+++ test/CXX/drs/dr3xx.cpp
@@ -232,8 +232,8 @@
   typedef struct {
 int i;
   } *ps;
-  extern "C" void f(ps);
-  void g(ps); // FIXME: ill-formed, type 'ps' has no linkage
+  extern "C" void f(ps); // expected-error-re {{'f' has C-linkage specified, 
but parameter type 'ps' (aka 'dr319::(anonymous struct {{.*}} *') has internal 
linkage}}
+  void g(ps);
 
   static enum { e } a1;
   enum { e2 } a2; // FIXME: ill-formed, enum type has no linkage
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -8218,6 +8218,25 @@
   Diag(NewFD->getLocation(), diag::ext_out_of_line_declaration)
 << D.getCXXScopeSpec().getRange();
 }
+
+if (NewFD->isExternC()) {
+  // Check return type linkage
+  QualType R = NewFD->getReturnType();
+  if (R.getTypePtr()->getLinkage() != Linkage::ExternalLinkage) {
+Diag(NewFD->getLocation(), diag::err_return_value_linkage)
+  << NewFD << R;
+NewFD->setInvalidDecl();
+  }
+  // Check parameter type linkage
+  for (auto param : NewFD->parameters()) {
+QualType P = param->getOriginalType();
+if (P.getTypePtr()->getLinkage() != Linkage::ExternalLinkage) {
+  Diag(NewFD->getLocation(), diag::err_parameter_value_linkage)
+<< NewFD << P;
+  NewFD->setInvalidDecl();
+}
+  }
+}
   }
 
   ProcessPragmaWeak(S, NewFD);
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -325,6 +325,11 @@
 def warn_unused_private_field: Warning<"private field %0 is not used">,
   InGroup, DefaultIgnore;
 
+def err_return_value_linkage: Error<
+  "%0 has C-linkage specified, but return type %1 has internal linkage">;
+def err_parameter_value_linkage: Error<
+  "%0 has C-linkage specified, but parameter type %1 has internal linkage">;
+
 def warn_parameter_size: Warning<
   "%0 is a large (%1 bytes) pass-by-value argument; "
   "pass it by reference instead ?">, InGroup;


Index: test/SemaCXX/warn-unused-filescoped.cpp
===
--- test/SemaCXX/warn-unused-filescoped.cpp
+++ test/SemaCXX/warn-unused-filescoped.cpp
@@ -121,7 +121,7 @@
   namespace { struct A {}; }
 
   void test(A a); // expected-warning {{unused function}}
-  extern "C" void test4(A a);
+  extern "C" void test4(A a); // expected-error {{'test4' has C-linkage specified, but parameter type 'test4::(anonymous namespace)::A' has internal linkage}}
 }
 
 namespace rdar8733476 {
Index: test/Sema/pr23090-crash-on-invalid.cpp
===
--- /dev/null
+++ test/Sema/pr23090-crash-on-invalid.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// Don't crash (PR23090).
+
+namespace {
+
+// check return type
+struct A;
+extern "C" A *foo(); // expected-error {{'foo' has C-linkage specified, but return type '(anonymous namespace)::A *' has internal linkage}}
+A *foo();
+
+// check parameter
+struct B;
+extern "C" void bar(B*); // expected-error {{'bar' has C-linkage specified, but parameter type '(anonymous namespace)::B *' has internal 

Re: [PATCH] D17484: [clang-tidy] introduce modernize-deprecated-headers check

2016-02-20 Thread Kirill Bobyrev via cfe-commits
omtcyf0 updated this revision to Diff 48600.
omtcyf0 added a comment.

Thanks for a review, Eugene!

The FixItHint and warning now comes with the "angled" version of header 
wrapping.


http://reviews.llvm.org/D17484

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/DeprecatedHeadersCheck.cpp
  clang-tidy/modernize/DeprecatedHeadersCheck.h
  clang-tidy/modernize/ModernizeTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-deprecated-headers.rst
  test/clang-tidy/modernize-deprecated-headers-cxx03.cpp
  test/clang-tidy/modernize-deprecated-headers-cxx11.cpp

Index: test/clang-tidy/modernize-deprecated-headers-cxx11.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-deprecated-headers-cxx11.cpp
@@ -0,0 +1,117 @@
+// RUN: %check_clang_tidy %s modernize-deprecated-headers %t -- -- -std=c++11 -isystem %S/Inputs/Headers
+
+#include "assert.h"
+#include "float.h"
+#include "math.h"
+#include "stddef.h"
+#include "setjmp.h"
+#include "stdio.h"
+#include "time.h"
+#include "ctype.h"
+#include "iso646.h"
+#include "signal.h"
+#include "errno.h"
+#include "limits.h"
+#include "stdarg.h"
+#include "stdlib.h"
+#include "wchar.h"
+#include "locale.h"
+#include "string.h"
+#include "wctype.h"
+#include "complex.h"
+#include "stdint.h"
+#include "inttypes.h"
+
+// C++11 deprecated headers
+#include "stdalign.h"
+#include "stdbool.h"
+#include "fenv.h"
+#include "tgmath.h"
+#include "uchar.h"
+
+// CHECK-FIXES: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+
+// C++11 headers
+// CHECK-FIXES: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+// C++11 deprecated headers
+#include 
+#include 
+#include 
+#include 
+#include 
+
+// CHECK-FIXES: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+
+// C++11 headers
+// CHECK-FIXES: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
Index: test/clang-tidy/modernize-deprecated-headers-cxx03.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-deprecated-headers-cxx03.cpp
@@ -0,0 +1,103 @@
+// RUN: %check_clang_tidy %s modernize-deprecated-headers %t -- -- -std=c++03 -isystem %S/Inputs/Headers
+
+#include "assert.h"
+#include "float.h"
+#include "math.h"
+#include "stddef.h"
+#include "setjmp.h"
+#include "stdio.h"
+#include "time.h"
+#include "ctype.h"
+#include "iso646.h"
+#include "signal.h"
+#include "errno.h"
+#include "limits.h"
+#include "stdarg.h"
+#include "stdlib.h"
+#include "wchar.h"
+#include "locale.h"
+#include "string.h"
+#include "wctype.h"
+#include "complex.h"
+#include "stdint.h"
+#include "inttypes.h"
+
+// C++11 deprecated headers
+#include "stdalign.h"
+#include "stdbool.h"
+#include "fenv.h"
+#include "tgmath.h"
+#include "uchar.h"
+
+// CHECK-FIXES: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// 

Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct

2016-02-20 Thread H.J. Lu via cfe-commits
On Sat, Feb 20, 2016 at 11:40 AM, Matthijs van Duin
 wrote:
> On 20 February 2016 at 20:34, H.J. Lu  wrote:
>> Is there a class, which meets the above definition,  with a member function
>> which can't be passed without a memory slot or a register?
>
> The EmptyInt class in my first post in this thread. It has no
> non-static data members, has standard layout, and has a trivial
> default constructor, but it has a non-trivial copy constructor and
> non-trivial destructor.
>

Can a compiler tell if a copy constructor or destructor is trivial
from the class declaration without function body?

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


Re: [PATCH] D17362: [Sema] PR23090 Crash when return type or parameter types for extern "C" functions don't have external linkage

2016-02-20 Thread don hinton via cfe-commits
hintonda added a comment.

This change breaks a couple tests in test/SemaCXX/linkage.cpp where we no 
longer allow mixing internal and external linkage, i.e., extern "C" functions 
have external linkage no matter where they are declared, but return types and 
parameters declared in anonymous namespaces have internal linkage.

Not yet sure how to go about fixing those, but one was based on PR9316, 
however, the test is more complicated and  is invalid -- so we don't generate 
code.


http://reviews.llvm.org/D17362



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


Re: [PATCH] D17484: [clang-tidy] introduce modernize-deprecated-headers check

2016-02-20 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a comment.

Thank you for implementing this check!

However, I think will be good idea to always wrap header name in <> for warning 
and FixIt.


http://reviews.llvm.org/D17484



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


r261449 - Lex: Check whether the header map buffer has space for the buckets

2016-02-20 Thread Duncan P. N. Exon Smith via cfe-commits
Author: dexonsmith
Date: Sat Feb 20 15:24:31 2016
New Revision: 261449

URL: http://llvm.org/viewvc/llvm-project?rev=261449=rev
Log:
Lex: Check whether the header map buffer has space for the buckets

Check up front whether the header map buffer has space for all of its
declared buckets.

There was already a check in `getBucket()`, but it had UB (comparing
pointers that were outside of objects in the error path) and was
insufficient (only checking for a single byte of the relevant bucket).
I fixed the check, moved it to `checkHeader()`, and left a fixed version
behind as an assertion.

Modified:
cfe/trunk/lib/Lex/HeaderMap.cpp
cfe/trunk/unittests/Lex/HeaderMapTest.cpp

Modified: cfe/trunk/lib/Lex/HeaderMap.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderMap.cpp?rev=261449=261448=261449=diff
==
--- cfe/trunk/lib/Lex/HeaderMap.cpp (original)
+++ cfe/trunk/lib/Lex/HeaderMap.cpp Sat Feb 20 15:24:31 2016
@@ -83,14 +83,16 @@ bool HeaderMapImpl::checkHeader(const ll
   if (Header->Reserved != 0)
 return false;
 
-  // Check the number of buckets.
+  // Check the number of buckets.  It should be a power of two, and there
+  // should be enough space in the file for all of them.
   auto NumBuckets = NeedsByteSwap
 ? llvm::sys::getSwappedBytes(Header->NumBuckets)
 : Header->NumBuckets;
-
-  // If the number of buckets is not a power of two, the headermap is corrupt.
   if (NumBuckets & (NumBuckets - 1))
 return false;
+  if (File.getBufferSize() <
+  sizeof(HMapHeader) + sizeof(HMapBucket) * NumBuckets)
+return false;
 
   // Okay, everything looks good.
   return true;
@@ -122,21 +124,19 @@ const HMapHeader ::getHead
 /// bswap'ing its fields as appropriate.  If the bucket number is not valid,
 /// this return a bucket with an empty key (0).
 HMapBucket HeaderMapImpl::getBucket(unsigned BucketNo) const {
+  assert(FileBuffer->getBufferSize() >=
+ sizeof(HMapHeader) + sizeof(HMapBucket) * BucketNo &&
+ "Expected bucket to be in range");
+
   HMapBucket Result;
   Result.Key = HMAP_EmptyBucketKey;
 
   const HMapBucket *BucketArray =
 reinterpret_cast(FileBuffer->getBufferStart() +
 sizeof(HMapHeader));
-
   const HMapBucket *BucketPtr = BucketArray+BucketNo;
-  if ((const char*)(BucketPtr+1) > FileBuffer->getBufferEnd()) {
-Result.Prefix = 0;
-Result.Suffix = 0;
-return Result;  // Invalid buffer, corrupt hmap.
-  }
 
-  // Otherwise, the bucket is valid.  Load the values, bswapping as needed.
+  // Load the values, bswapping as needed.
   Result.Key= getEndianAdjustedWord(BucketPtr->Key);
   Result.Prefix = getEndianAdjustedWord(BucketPtr->Prefix);
   Result.Suffix = getEndianAdjustedWord(BucketPtr->Suffix);

Modified: cfe/trunk/unittests/Lex/HeaderMapTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Lex/HeaderMapTest.cpp?rev=261449=261448=261449=diff
==
--- cfe/trunk/unittests/Lex/HeaderMapTest.cpp (original)
+++ cfe/trunk/unittests/Lex/HeaderMapTest.cpp Sat Feb 20 15:24:31 2016
@@ -100,4 +100,12 @@ TEST(HeaderMapTest, checkHeader3Buckets)
   ASSERT_FALSE(HeaderMapImpl::checkHeader(*File.getBuffer(), NeedsSwap));
 }
 
+TEST(HeaderMapTest, checkHeaderNotEnoughBuckets) {
+  MapFile<1, 1> File;
+  File.init();
+  File.Header.NumBuckets = 8;
+  bool NeedsSwap;
+  ASSERT_FALSE(HeaderMapImpl::checkHeader(*File.getBuffer(), NeedsSwap));
+}
+
 } // end namespace


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


Re: r259975 - Fix a crash when emitting dbeug info for forward-declared scoped enums.

2016-02-20 Thread Adrian Prantl via cfe-commits
This had me puzzled for a second, but then I figured out what happened :-)
The “crash” I quoted in the commit message really was an assertion failure, to 
be precise, the very assertion I relaxed in LLVM r259973 in order to be able to 
defer the building of the DeclContext implemented by this commit. Even with the 
assertion removed, I still believe that implementing it this way preferable, as 
it avoids creating the enum a second time.

> On Feb 19, 2016, at 7:05 PM, Eric Christopher  wrote:
> 
> Hi Adrian,
> 
> I'm taking a look at this and can't duplicate using the testcase you gave 
> without your patch(es) applied. It's also causing asserts in other code as 
> you can have the forward decl left around and the CU isn't a valid context.

Do you happen to have an example handy? I don’t quite understand the problem 
from the description — shouldn’t the temporary fwddecl be RAUWed 
unconditionally after the DeclContext is created?

If you’re blocked on this we can definitely revert the change in CGDebugInfo 
(but not the testcase), I just would like to understand what’s going on.

-- adrian

> Can you take a look/revert until you've got a different testcase? There's not 
> enough information in the commit to construct one up for you.
> 
> Thanks!
> 
> -eric
> 
> On Fri, Feb 5, 2016 at 6:03 PM Adrian Prantl via cfe-commits 
>  wrote:
> Author: adrian
> Date: Fri Feb  5 19:59:09 2016
> New Revision: 259975
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=259975=rev
> Log:
> Fix a crash when emitting dbeug info for forward-declared scoped enums.
> It is possible for enums to be created as part of their own
> declcontext. We need to cache a placeholder to avoid the type being
> created twice before hitting the cache.
> 
> 
> 
> Added:
> cfe/trunk/test/CodeGenCXX/debug-info-scoped-class.cpp
> Modified:
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> 
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=259975=259974=259975=diff
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Feb  5 19:59:09 2016
> @@ -2051,13 +2051,25 @@ llvm::DIType *CGDebugInfo::CreateEnumTyp
>// If this is just a forward declaration, construct an appropriately
>// marked node and just return it.
>if (isImportedFromModule || !ED->getDefinition()) {
> -llvm::DIScope *EDContext = getDeclContextDescriptor(ED);
>  llvm::DIFile *DefUnit = getOrCreateFile(ED->getLocation());
> +
> +// It is possible for enums to be created as part of their own
> +// declcontext. We need to cache a placeholder to avoid the type being
> +// created twice before hitting the cache.
> +llvm::DIScope *EDContext = DBuilder.createReplaceableCompositeType(
> +  llvm::dwarf::DW_TAG_enumeration_type, "", TheCU, DefUnit, 0);
> +
>  unsigned Line = getLineNumber(ED->getLocation());
>  StringRef EDName = ED->getName();
>  llvm::DIType *RetTy = DBuilder.createReplaceableCompositeType(
>  llvm::dwarf::DW_TAG_enumeration_type, EDName, EDContext, DefUnit, 
> Line,
>  0, Size, Align, llvm::DINode::FlagFwdDecl, FullName);
> +
> +// Cache the enum type so it is available when building the declcontext
> +// and replace the declcontect with the real thing.
> +TypeCache[Ty].reset(RetTy);
> +EDContext->replaceAllUsesWith(getDeclContextDescriptor(ED));
> +
>  ReplaceMap.emplace_back(
>  std::piecewise_construct, std::make_tuple(Ty),
>  std::make_tuple(static_cast(RetTy)));
> 
> Added: cfe/trunk/test/CodeGenCXX/debug-info-scoped-class.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-scoped-class.cpp?rev=259975=auto
> ==
> --- cfe/trunk/test/CodeGenCXX/debug-info-scoped-class.cpp (added)
> +++ cfe/trunk/test/CodeGenCXX/debug-info-scoped-class.cpp Fri Feb  5 19:59:09 
> 2016
> @@ -0,0 +1,15 @@
> +// RUN: %clang_cc1 -emit-llvm -debug-info-kind=standalone -std=c++11 \
> +// RUN:   -triple thumbv7-apple-ios %s -o - | FileCheck %s
> +
> +// This forward-declared scoped enum will be created while building its own
> +// declcontext. Make sure it is only emitted once.
> +
> +struct A {
> +  enum class Return;
> +  Return f1();
> +};
> +A::Return* f2() {}
> +
> +// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "Return",
> +// CHECK-SAME: flags: DIFlagFwdDecl,
> +// CHECK-NOT:  tag: DW_TAG_enumeration_type, name: "Return"
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

___
cfe-commits mailing list

r261448 - Lex: Check buckets on header map construction

2016-02-20 Thread Duncan P. N. Exon Smith via cfe-commits
Author: dexonsmith
Date: Sat Feb 20 15:00:58 2016
New Revision: 261448

URL: http://llvm.org/viewvc/llvm-project?rev=261448=rev
Log:
Lex: Check buckets on header map construction

If the number of buckets is not a power of two, immediately recognize
the header map as corrupt, rather than waiting for the first lookup.  I
converted the later check to an assert.

Modified:
cfe/trunk/lib/Lex/HeaderMap.cpp
cfe/trunk/unittests/Lex/HeaderMapTest.cpp

Modified: cfe/trunk/lib/Lex/HeaderMap.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderMap.cpp?rev=261448=261447=261448=diff
==
--- cfe/trunk/lib/Lex/HeaderMap.cpp (original)
+++ cfe/trunk/lib/Lex/HeaderMap.cpp Sat Feb 20 15:00:58 2016
@@ -19,6 +19,7 @@
 #include "llvm/Support/DataTypes.h"
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/SwapByteOrder.h"
 #include 
 #include 
 using namespace clang;
@@ -82,6 +83,15 @@ bool HeaderMapImpl::checkHeader(const ll
   if (Header->Reserved != 0)
 return false;
 
+  // Check the number of buckets.
+  auto NumBuckets = NeedsByteSwap
+? llvm::sys::getSwappedBytes(Header->NumBuckets)
+: Header->NumBuckets;
+
+  // If the number of buckets is not a power of two, the headermap is corrupt.
+  if (NumBuckets & (NumBuckets - 1))
+return false;
+
   // Okay, everything looks good.
   return true;
 }
@@ -191,10 +201,8 @@ StringRef HeaderMapImpl::lookupFilename(
   const HMapHeader  = getHeader();
   unsigned NumBuckets = getEndianAdjustedWord(Hdr.NumBuckets);
 
-  // If the number of buckets is not a power of two, the headermap is corrupt.
-  // Don't probe infinitely.
-  if (NumBuckets & (NumBuckets-1))
-return StringRef();
+  // Don't probe infinitely.  This should be checked before constructing.
+  assert(!(NumBuckets & (NumBuckets - 1)) && "Expected power of 2");
 
   // Linearly probe the hash table.
   for (unsigned Bucket = HashHMapKey(Filename);; ++Bucket) {

Modified: cfe/trunk/unittests/Lex/HeaderMapTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Lex/HeaderMapTest.cpp?rev=261448=261447=261448=diff
==
--- cfe/trunk/unittests/Lex/HeaderMapTest.cpp (original)
+++ cfe/trunk/unittests/Lex/HeaderMapTest.cpp Sat Feb 20 15:00:58 2016
@@ -91,4 +91,13 @@ TEST(HeaderMapTest, checkHeaderValidButE
   ASSERT_TRUE(NeedsSwap);
 }
 
+TEST(HeaderMapTest, checkHeader3Buckets) {
+  MapFile<3, 1> File;
+  ASSERT_EQ(3 * sizeof(HMapBucket), sizeof(File.Buckets));
+
+  File.init();
+  bool NeedsSwap;
+  ASSERT_FALSE(HeaderMapImpl::checkHeader(*File.getBuffer(), NeedsSwap));
+}
+
 } // end namespace


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


r261446 - Lex: Add some unit tests for corrupt header maps

2016-02-20 Thread Duncan P. N. Exon Smith via cfe-commits
Author: dexonsmith
Date: Sat Feb 20 14:39:51 2016
New Revision: 261446

URL: http://llvm.org/viewvc/llvm-project?rev=261446=rev
Log:
Lex: Add some unit tests for corrupt header maps

Split the implementation of `HeaderMap` into `HeaderMapImpl` so that we
can write unit tests that don't depend on the `FileManager`, and then
write a few tests that cover the types of corrupt header maps already
detected.

This also moves type and constant definitions from HeaderMap.cpp to
HeaderMapTypes.h so that the test can access them.

Added:
cfe/trunk/include/clang/Lex/HeaderMapTypes.h
cfe/trunk/unittests/Lex/HeaderMapTest.cpp
Modified:
cfe/trunk/include/clang/Lex/HeaderMap.h
cfe/trunk/lib/Lex/HeaderMap.cpp
cfe/trunk/unittests/Lex/CMakeLists.txt

Modified: cfe/trunk/include/clang/Lex/HeaderMap.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderMap.h?rev=261446=261445=261446=diff
==
--- cfe/trunk/include/clang/Lex/HeaderMap.h (original)
+++ cfe/trunk/include/clang/Lex/HeaderMap.h Sat Feb 20 14:39:51 2016
@@ -26,39 +26,27 @@ class FileManager;
 struct HMapBucket;
 struct HMapHeader;
 
-/// This class represents an Apple concept known as a 'header map'.  To the
-/// \#include file resolution process, it basically acts like a directory of
-/// symlinks to files.  Its advantages are that it is dense and more efficient
-/// to create and process than a directory of symlinks.
-class HeaderMap {
+/// Implementation for \a HeaderMap that doesn't depend on \a FileManager.
+class HeaderMapImpl {
   std::unique_ptr FileBuffer;
   bool NeedsBSwap;
 
-  HeaderMap(std::unique_ptr File, bool BSwap)
-  : FileBuffer(std::move(File)), NeedsBSwap(BSwap) {}
-
 public:
-  /// HeaderMap::Create - This attempts to load the specified file as a header
-  /// map.  If it doesn't look like a HeaderMap, it gives up and returns null.
-  static const HeaderMap *Create(const FileEntry *FE, FileManager );
+  HeaderMapImpl(std::unique_ptr File, bool 
NeedsBSwap)
+  : FileBuffer(std::move(File)), NeedsBSwap(NeedsBSwap) {}
 
-  /// LookupFile - Check to see if the specified relative filename is located 
in
-  /// this HeaderMap.  If so, open it and return its FileEntry.
-  /// If RawPath is not NULL and the file is found, RawPath will be set to the
-  /// raw path at which the file was found in the file system. For example,
-  /// for a search path ".." and a filename "../file.h" this would be
-  /// "../../file.h".
-  const FileEntry *LookupFile(StringRef Filename, FileManager ) const;
+  // Check for a valid header and extract the byte swap.
+  static bool checkHeader(const llvm::MemoryBuffer , bool );
 
   /// If the specified relative filename is located in this HeaderMap return
   /// the filename it is mapped to, otherwise return an empty StringRef.
   StringRef lookupFilename(StringRef Filename,
SmallVectorImpl ) const;
 
-  /// getFileName - Return the filename of the headermap.
+  /// Return the filename of the headermap.
   const char *getFileName() const;
 
-  /// dump - Print the contents of this headermap to stderr.
+  /// Print the contents of this headermap to stderr.
   void dump() const;
 
 private:
@@ -68,6 +56,31 @@ private:
   const char *getString(unsigned StrTabIdx) const;
 };
 
+/// This class represents an Apple concept known as a 'header map'.  To the
+/// \#include file resolution process, it basically acts like a directory of
+/// symlinks to files.  Its advantages are that it is dense and more efficient
+/// to create and process than a directory of symlinks.
+class HeaderMap : private HeaderMapImpl {
+  HeaderMap(std::unique_ptr File, bool BSwap)
+  : HeaderMapImpl(std::move(File), BSwap) {}
+
+public:
+  /// This attempts to load the specified file as a header map.  If it doesn't
+  /// look like a HeaderMap, it gives up and returns null.
+  static const HeaderMap *Create(const FileEntry *FE, FileManager );
+
+  /// Check to see if the specified relative filename is located in this
+  /// HeaderMap.  If so, open it and return its FileEntry.  If RawPath is not
+  /// NULL and the file is found, RawPath will be set to the raw path at which
+  /// the file was found in the file system. For example, for a search path
+  /// ".." and a filename "../file.h" this would be "../../file.h".
+  const FileEntry *LookupFile(StringRef Filename, FileManager ) const;
+
+  using HeaderMapImpl::lookupFilename;
+  using HeaderMapImpl::getFileName;
+  using HeaderMapImpl::dump;
+};
+
 } // end namespace clang.
 
 #endif

Added: cfe/trunk/include/clang/Lex/HeaderMapTypes.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderMapTypes.h?rev=261446=auto
==
--- cfe/trunk/include/clang/Lex/HeaderMapTypes.h (added)
+++ cfe/trunk/include/clang/Lex/HeaderMapTypes.h Sat Feb 20 14:39:51 2016
@@ 

r261445 - [c-index-test] CMake: When installing c-index-test to a different prefix directory, add an rpath so that

2016-02-20 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Sat Feb 20 14:34:55 2016
New Revision: 261445

URL: http://llvm.org/viewvc/llvm-project?rev=261445=rev
Log:
[c-index-test] CMake: When installing c-index-test to a different prefix 
directory, add an rpath so that
it can find libclang.

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

Modified: cfe/trunk/tools/c-index-test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/CMakeLists.txt?rev=261445=261444=261445=diff
==
--- cfe/trunk/tools/c-index-test/CMakeLists.txt (original)
+++ cfe/trunk/tools/c-index-test/CMakeLists.txt Sat Feb 20 14:34:55 2016
@@ -42,6 +42,8 @@ endif()
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
   if(INTERNAL_INSTALL_PREFIX)
 set(INSTALL_DESTINATION "${INTERNAL_INSTALL_PREFIX}/bin")
+set_property(TARGET c-index-test APPEND PROPERTY INSTALL_RPATH
+   "@executable_path/../../lib")
   else()
 set(INSTALL_DESTINATION bin)
   endif()


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


Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct

2016-02-20 Thread Matthijs van Duin via cfe-commits
On 20 February 2016 at 20:34, H.J. Lu  wrote:
> Is there a class, which meets the above definition,  with a member function
> which can't be passed without a memory slot or a register?

The EmptyInt class in my first post in this thread. It has no
non-static data members, has standard layout, and has a trivial
default constructor, but it has a non-trivial copy constructor and
non-trivial destructor.

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


Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct

2016-02-20 Thread H.J. Lu via cfe-commits
On Sat, Feb 20, 2016 at 10:50 AM, Matthijs van Duin
 wrote:
> On 20 February 2016 at 18:55, H.J. Lu  wrote:
>> struct dummy0
>> {
>> };
>>
>> struct dummy
>> {
>>   dummy0 d[20];
>>
>>   dummy0 * foo (int i);
>> };
>>
>> dummy0 *
>> dummy::foo (int i)
>> {
>>   return [i];
>> }
>>
>> dummy0 *
>> bar (dummy d, int i)
>> {
>>   return d.foo (i);
>> }
>
> 1. This has undefined behaviour due to returning a pointer to a local variable
> 2. There's still no need for the reference to the original argument
> since copying it is a nop.

Given:

An empty type is a type where it and all of its subobjects (recursively)
are of class, structure, union, or array type.  No memory slot nor register
should be used to pass or return an object of empty type.

Footnote: Array of empty type can only passed by reference in C and C++.

Is there a class, which meets the above definition,  with a member function
which can't be passed without a memory slot or a register?

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


Re: [PATCH] D17484: [clang-tidy] introduce modernize-deprecated-headers check

2016-02-20 Thread Kirill Bobyrev via cfe-commits
omtcyf0 updated this revision to Diff 48598.
omtcyf0 added a comment.

fixed clang-tidy/modernize/DeprecatedHeaders.h head typo caused by the check 
rename


http://reviews.llvm.org/D17484

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/DeprecatedHeadersCheck.cpp
  clang-tidy/modernize/DeprecatedHeadersCheck.h
  clang-tidy/modernize/ModernizeTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-deprecated-headers.rst
  test/clang-tidy/modernize-deprecated-headers-cxx03.cpp
  test/clang-tidy/modernize-deprecated-headers-cxx11.cpp

Index: test/clang-tidy/modernize-deprecated-headers-cxx11.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-deprecated-headers-cxx11.cpp
@@ -0,0 +1,117 @@
+// RUN: %check_clang_tidy %s modernize-deprecated-headers %t -- -- -std=c++11 -isystem %S/Inputs/Headers
+
+#include "assert.h"
+#include "float.h"
+#include "math.h"
+#include "stddef.h"
+#include "setjmp.h"
+#include "stdio.h"
+#include "time.h"
+#include "ctype.h"
+#include "iso646.h"
+#include "signal.h"
+#include "errno.h"
+#include "limits.h"
+#include "stdarg.h"
+#include "stdlib.h"
+#include "wchar.h"
+#include "locale.h"
+#include "string.h"
+#include "wctype.h"
+#include "complex.h"
+#include "stdint.h"
+#include "inttypes.h"
+
+// C++11 deprecated headers
+#include "stdalign.h"
+#include "stdbool.h"
+#include "fenv.h"
+#include "tgmath.h"
+#include "uchar.h"
+
+// CHECK-FIXES: #include "cassert"
+// CHECK-FIXES-NEXT: #include "cfloat"
+// CHECK-FIXES-NEXT: #include "cmath"
+// CHECK-FIXES-NEXT: #include "cstddef"
+// CHECK-FIXES-NEXT: #include "csetjmp"
+// CHECK-FIXES-NEXT: #include "cstdio"
+// CHECK-FIXES-NEXT: #include "ctime"
+// CHECK-FIXES-NEXT: #include "cctype"
+// CHECK-FIXES-NEXT: #include "ciso646"
+// CHECK-FIXES-NEXT: #include "csignal"
+// CHECK-FIXES-NEXT: #include "cerrno"
+// CHECK-FIXES-NEXT: #include "climits"
+// CHECK-FIXES-NEXT: #include "cstdarg"
+// CHECK-FIXES-NEXT: #include "cstdlib"
+// CHECK-FIXES-NEXT: #include "cwchar"
+// CHECK-FIXES-NEXT: #include "clocale"
+// CHECK-FIXES-NEXT: #include "cstring"
+// CHECK-FIXES-NEXT: #include "cwctype"
+// CHECK-FIXES-NEXT: #include "ccomplex"
+// CHECK-FIXES-NEXT: #include "cstdint"
+// CHECK-FIXES-NEXT: #include "cinttypes"
+
+// C++11 headers
+// CHECK-FIXES: #include "cstdalign"
+// CHECK-FIXES-NEXT: #include "cstdbool"
+// CHECK-FIXES-NEXT: #include "cfenv"
+// CHECK-FIXES-NEXT: #include "ctgmath"
+// CHECK-FIXES-NEXT: #include "cuchar"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+// C++11 deprecated headers
+#include 
+#include 
+#include 
+#include 
+#include 
+
+// CHECK-FIXES: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+
+// C++11 headers
+// CHECK-FIXES: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
Index: test/clang-tidy/modernize-deprecated-headers-cxx03.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-deprecated-headers-cxx03.cpp
@@ -0,0 +1,103 @@
+// RUN: %check_clang_tidy %s modernize-deprecated-headers %t -- -- -std=c++03 -isystem %S/Inputs/Headers
+
+#include "assert.h"
+#include "float.h"
+#include "math.h"
+#include "stddef.h"
+#include "setjmp.h"
+#include "stdio.h"
+#include "time.h"
+#include "ctype.h"
+#include "iso646.h"
+#include "signal.h"
+#include "errno.h"
+#include "limits.h"
+#include "stdarg.h"
+#include "stdlib.h"
+#include "wchar.h"
+#include "locale.h"
+#include "string.h"
+#include "wctype.h"
+#include "complex.h"
+#include "stdint.h"
+#include "inttypes.h"
+
+// C++11 deprecated headers
+#include "stdalign.h"
+#include "stdbool.h"
+#include "fenv.h"
+#include "tgmath.h"
+#include "uchar.h"
+
+// CHECK-FIXES: #include "cassert"
+// CHECK-FIXES-NEXT: #include "cfloat"
+// CHECK-FIXES-NEXT: #include "cmath"
+// CHECK-FIXES-NEXT: #include "cstddef"
+// CHECK-FIXES-NEXT: #include "csetjmp"
+// CHECK-FIXES-NEXT: #include "cstdio"
+// CHECK-FIXES-NEXT: #include "ctime"
+// CHECK-FIXES-NEXT: #include "cctype"
+// CHECK-FIXES-NEXT: #include "ciso646"
+// 

[PATCH] D17484: [clang-tidy] introduce modernize-deprecated-headers check

2016-02-20 Thread Kirill Bobyrev via cfe-commits
omtcyf0 created this revision.
omtcyf0 added reviewers: alexfh, LegalizeAdulthood, Eugene.Zelenko.
omtcyf0 added a subscriber: cfe-commits.

This patch introduces the modernize-deprecated-headers check, which is supposed 
to replace deprecated C library headers with the C++ STL-ones.

For information see documentation; for exmaples see the test cases.

http://reviews.llvm.org/D17484

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/DeprecatedHeadersCheck.cpp
  clang-tidy/modernize/DeprecatedHeadersCheck.h
  clang-tidy/modernize/ModernizeTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-deprecated-headers.rst
  test/clang-tidy/modernize-deprecated-headers-cxx03.cpp
  test/clang-tidy/modernize-deprecated-headers-cxx11.cpp

Index: test/clang-tidy/modernize-deprecated-headers-cxx11.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-deprecated-headers-cxx11.cpp
@@ -0,0 +1,117 @@
+// RUN: %check_clang_tidy %s modernize-deprecated-headers %t -- -- -std=c++11 -isystem %S/Inputs/Headers
+
+#include "assert.h"
+#include "float.h"
+#include "math.h"
+#include "stddef.h"
+#include "setjmp.h"
+#include "stdio.h"
+#include "time.h"
+#include "ctype.h"
+#include "iso646.h"
+#include "signal.h"
+#include "errno.h"
+#include "limits.h"
+#include "stdarg.h"
+#include "stdlib.h"
+#include "wchar.h"
+#include "locale.h"
+#include "string.h"
+#include "wctype.h"
+#include "complex.h"
+#include "stdint.h"
+#include "inttypes.h"
+
+// C++11 deprecated headers
+#include "stdalign.h"
+#include "stdbool.h"
+#include "fenv.h"
+#include "tgmath.h"
+#include "uchar.h"
+
+// CHECK-FIXES: #include "cassert"
+// CHECK-FIXES-NEXT: #include "cfloat"
+// CHECK-FIXES-NEXT: #include "cmath"
+// CHECK-FIXES-NEXT: #include "cstddef"
+// CHECK-FIXES-NEXT: #include "csetjmp"
+// CHECK-FIXES-NEXT: #include "cstdio"
+// CHECK-FIXES-NEXT: #include "ctime"
+// CHECK-FIXES-NEXT: #include "cctype"
+// CHECK-FIXES-NEXT: #include "ciso646"
+// CHECK-FIXES-NEXT: #include "csignal"
+// CHECK-FIXES-NEXT: #include "cerrno"
+// CHECK-FIXES-NEXT: #include "climits"
+// CHECK-FIXES-NEXT: #include "cstdarg"
+// CHECK-FIXES-NEXT: #include "cstdlib"
+// CHECK-FIXES-NEXT: #include "cwchar"
+// CHECK-FIXES-NEXT: #include "clocale"
+// CHECK-FIXES-NEXT: #include "cstring"
+// CHECK-FIXES-NEXT: #include "cwctype"
+// CHECK-FIXES-NEXT: #include "ccomplex"
+// CHECK-FIXES-NEXT: #include "cstdint"
+// CHECK-FIXES-NEXT: #include "cinttypes"
+
+// C++11 headers
+// CHECK-FIXES: #include "cstdalign"
+// CHECK-FIXES-NEXT: #include "cstdbool"
+// CHECK-FIXES-NEXT: #include "cfenv"
+// CHECK-FIXES-NEXT: #include "ctgmath"
+// CHECK-FIXES-NEXT: #include "cuchar"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+// C++11 deprecated headers
+#include 
+#include 
+#include 
+#include 
+#include 
+
+// CHECK-FIXES: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+
+// C++11 headers
+// CHECK-FIXES: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
+// CHECK-FIXES-NEXT: #include 
Index: test/clang-tidy/modernize-deprecated-headers-cxx03.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-deprecated-headers-cxx03.cpp
@@ -0,0 +1,103 @@
+// RUN: %check_clang_tidy %s modernize-deprecated-headers %t -- -- -std=c++03 -isystem %S/Inputs/Headers
+
+#include "assert.h"
+#include "float.h"
+#include "math.h"
+#include "stddef.h"
+#include "setjmp.h"
+#include "stdio.h"
+#include "time.h"
+#include "ctype.h"
+#include "iso646.h"
+#include "signal.h"
+#include "errno.h"
+#include "limits.h"
+#include "stdarg.h"
+#include "stdlib.h"
+#include "wchar.h"
+#include "locale.h"
+#include "string.h"
+#include "wctype.h"
+#include "complex.h"
+#include "stdint.h"
+#include "inttypes.h"
+
+// C++11 deprecated headers
+#include "stdalign.h"
+#include "stdbool.h"
+#include "fenv.h"
+#include "tgmath.h"
+#include "uchar.h"
+
+// CHECK-FIXES: #include "cassert"
+// CHECK-FIXES-NEXT: #include "cfloat"
+// CHECK-FIXES-NEXT: #include "cmath"
+// CHECK-FIXES-NEXT: #include "cstddef"
+// CHECK-FIXES-NEXT: 

Re: [PATCH] D17026: Changed ASTImporter DiagnosticsEngine from FromDiag to ToDiag for unsupported ASTNodes Import.

2016-02-20 Thread Argyrios Kyrtzidis via cfe-commits
akyrtzi added a comment.

Could you check if you can decouple VerifyDiagnosticConsumer from depending on 
a particular DiagnosticsEngine ?


http://reviews.llvm.org/D17026



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


Re: [PATCH] D17026: Changed ASTImporter DiagnosticsEngine from FromDiag to ToDiag for unsupported ASTNodes Import.

2016-02-20 Thread Argyrios Kyrtzidis via cfe-commits
akyrtzi added a comment.

I'm not sure removing all the Importer.FromDiag() calls is the right thing. You 
are changing

Importer.FromDiag(D->getLocation(), diag::err_unsupported_ast_node)

to

Importer.ToDiag(SourceLocation(), diag::err_unsupported_ast_node)

and you lose the source location information.


http://reviews.llvm.org/D17026



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


r261443 - Lex: clang-format HeaderMap.h, NFC

2016-02-20 Thread Duncan P. N. Exon Smith via cfe-commits
Author: dexonsmith
Date: Sat Feb 20 12:55:08 2016
New Revision: 261443

URL: http://llvm.org/viewvc/llvm-project?rev=261443=rev
Log:
Lex: clang-format HeaderMap.h, NFC

Modified:
cfe/trunk/include/clang/Lex/HeaderMap.h

Modified: cfe/trunk/include/clang/Lex/HeaderMap.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderMap.h?rev=261443=261442=261443=diff
==
--- cfe/trunk/include/clang/Lex/HeaderMap.h (original)
+++ cfe/trunk/include/clang/Lex/HeaderMap.h Sat Feb 20 12:55:08 2016
@@ -20,10 +20,11 @@
 #include 
 
 namespace clang {
-  class FileEntry;
-  class FileManager;
-  struct HMapBucket;
-  struct HMapHeader;
+
+class FileEntry;
+class FileManager;
+struct HMapBucket;
+struct HMapHeader;
 
 /// This class represents an Apple concept known as a 'header map'.  To the
 /// \#include file resolution process, it basically acts like a directory of
@@ -35,6 +36,7 @@ class HeaderMap {
 
   HeaderMap(std::unique_ptr File, bool BSwap)
   : FileBuffer(std::move(File)), NeedsBSwap(BSwap) {}
+
 public:
   /// HeaderMap::Create - This attempts to load the specified file as a header
   /// map.  If it doesn't look like a HeaderMap, it gives up and returns null.


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


r261442 - Lex: Remove explicitly deleted copy constructor, NFC

2016-02-20 Thread Duncan P. N. Exon Smith via cfe-commits
Author: dexonsmith
Date: Sat Feb 20 12:53:45 2016
New Revision: 261442

URL: http://llvm.org/viewvc/llvm-project?rev=261442=rev
Log:
Lex: Remove explicitly deleted copy constructor, NFC

`std::unique_ptr` already deletes these, so there's no
reason for the boiler-plate in HeaderMap.

Modified:
cfe/trunk/include/clang/Lex/HeaderMap.h

Modified: cfe/trunk/include/clang/Lex/HeaderMap.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderMap.h?rev=261442=261441=261442=diff
==
--- cfe/trunk/include/clang/Lex/HeaderMap.h (original)
+++ cfe/trunk/include/clang/Lex/HeaderMap.h Sat Feb 20 12:53:45 2016
@@ -30,9 +30,6 @@ namespace clang {
 /// symlinks to files.  Its advantages are that it is dense and more efficient
 /// to create and process than a directory of symlinks.
 class HeaderMap {
-  HeaderMap(const HeaderMap &) = delete;
-  void operator=(const HeaderMap &) = delete;
-
   std::unique_ptr FileBuffer;
   bool NeedsBSwap;
 


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


Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct

2016-02-20 Thread Matthijs van Duin via cfe-commits
On 20 February 2016 at 18:55, H.J. Lu  wrote:
> struct dummy0
> {
> };
>
> struct dummy
> {
>   dummy0 d[20];
>
>   dummy0 * foo (int i);
> };
>
> dummy0 *
> dummy::foo (int i)
> {
>   return [i];
> }
>
> dummy0 *
> bar (dummy d, int i)
> {
>   return d.foo (i);
> }

1. This has undefined behaviour due to returning a pointer to a local variable
2. There's still no need for the reference to the original argument
since copying it is a nop.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct

2016-02-20 Thread H.J. Lu via cfe-commits
On Fri, Feb 19, 2016 at 1:07 PM, Richard Smith  wrote:
> On Fri, Feb 19, 2016 at 5:35 AM, Michael Matz  wrote:
>> Hi,
>>
>> On Thu, 18 Feb 2016, Richard Smith wrote:
>>
>>> >> An empty type is a type where it and all of its subobjects
>>> >> (recursively) are of class, structure, union, or array type.  No
>>> >> memory slot nor register should be used to pass or return an object
>>> >> of empty type.
>>> >
>>> > The trivially copyable is gone again.  Why is it not necessary?
>>>
>>> The C++ ABI doesn't defer to the C psABI for types that aren't
>>> trivially-copyable. See
>>> http://mentorembedded.github.io/cxx-abi/abi.html#normal-call
>>
>> Hmm, yes, but we don't want to define something for only C and C++, but
>> language independend (so far as possible).  And given only the above
>> language I think this type:
>>
>> struct S {
>>   S() {something();}
>> };
>>
>> would be an empty type, and that's not what we want.
>
> Yes it is. Did you mean to give S a copy constructor, copy assignment
> operator, or destructor instead?
>
>> "Trivially copyable"
>> is a reasonably common abstraction (if in doubt we could even define it in
>> the ABI), and captures the idea that we need well (namely that a bit-copy
>> is enough).

In this case:

struct dummy0
{
};

struct dummy
{
  dummy0 d[20];

  dummy0 * foo (int i);
};

dummy0 *
dummy::foo (int i)
{
  return [i];
}

dummy0 *
bar (dummy d, int i)
{
  return d.foo (i);
}

dummy shouldn't be passed as empty type.  We need to have a clear
definition for what kinds of member functions are allowed in an empty
type.

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


Re: [PATCH] D17019: [OpenMP] Code generation for teams - kernel launching

2016-02-20 Thread Samuel Antao via cfe-commits
sfantao added inline comments.


Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:3799-3806
@@ -3780,4 +3798,10 @@
   OffloadEntriesInfoManager.registerTargetRegionEntryInfo(
   DeviceID, FileID, ParentName, Line, OutlinedFn, OutlinedFnID);
 }
 
+/// \brief Emit the num_teams clause of an enclosed teams directive at the
+/// target region scope. If there is no teams directive associated with the
+/// target directive, or if there is no num_teams clause associated with the
+/// enclosed teams directive, return nullptr.
+static llvm::Value *
+emitNumTeamsClauseForTargetDirective(CodeGenFunction ,

ABataev wrote:
> sfantao wrote:
> > ABataev wrote:
> > > sfantao wrote:
> > > > ABataev wrote:
> > > > > I don't understand why global var is not captured in target region. 
> > > > > If it is not implemented yet, it must be implemented. If it is not 
> > > > > captured, it must be captured in Sema. We should not introduce some 
> > > > > function/other objects to find a workaround for 'not implemented' 
> > > > > features.
> > > > Sorry, I was not clear in my comment. It is not that globals are not 
> > > > captured in target regions - they are, we already have Sema doing that. 
> > > > 
> > > > My point is that exactly because we capture globals in target regions 
> > > > the magic that `OMPCapturedExprDecl` introduces does not work for that 
> > > > specific case. So, if we have something like:
> > > > 
> > > > ```
> > > > int Gbl;
> > > > 
> > > > foo() {
> > > >   #pragma omp target
> > > >   #pragma omp teams num_teams(Gbl)
> > > >   {}
> > > > }
> > > > ```
> > > > when the DeclRefExpr for Gbl used in num_teams is emitted in the scope 
> > > > that encloses '#pragma omp target', it will crash because Gbl is not a 
> > > > local and is marked as refer to enclosing capture. 
> > > > 
> > > > If I got it right, a solution based on `OMPCapturedExprDecl` basically 
> > > > makes local declarations whose initializers are the expression we are 
> > > > interested in. In the cases that  `OMPCapturedExprDecl` is currently 
> > > > employed we don't have globals being captured and that is why it works 
> > > > fine.
> > > > 
> > > > It is likely I am missing something here. Let me know if you need me to 
> > > > provide more details.
> > > > 
> > > > Thanks!
> > > It should not crash, because if it is captured, we must use captured 
> > > version of this variable, passed in arguments to outlined function
> > I am afraid I may not be understanding what you want me to do. Going back 
> > to my example:
> > 
> > ```
> > int Gbl;
> > 
> > foo() {
> >   // a) I need to emit num_teams(Gbl) here. DeclRefExpr(Gbl) emission won't 
> > work because it is marked "refer to enclosing capture". 
> >   #pragma omp target
> >   // b) If I emit it here, that's fine because I already have the arguments 
> > of the outlined function, but that is not what I need.
> >   #pragma omp teams num_teams(Gbl)
> >   {}
> > }
> > ```
> > Can you please elaborate on how `OMPCapturedExprDecl` would help me 
> > implement a). Sorry for the trouble.
> > 
> > Thanks!
> Ok, why you don't want to emit it in b), but in a)?
The reason is that the runtime library requires the number of teams and thread 
limit to be passed. So, if we have a target region with an enclosed teams 
region, we have to use `tgt_target_teams` instead of `tgt_target`. 
`tgt_target_teams` takes thread_limit and num_teams as arguments. Therefore, we 
need to get that information from the teams directive given that that 
information is captured in its clauses.

Thanks!


http://reviews.llvm.org/D17019



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


[PATCH] D17482: [clang-tidy] Allow tests to verify changes made to header files

2016-02-20 Thread Richard via cfe-commits
LegalizeAdulthood created this revision.
LegalizeAdulthood added a reviewer: alexfh.
LegalizeAdulthood added a subscriber: cfe-commits.

This changeset improves check_clang_tidy.py to allow chnages made by a check to 
a header to be verified.

A new argument `--header-filter` allows the test file to specify the header 
that will be modified by the check.

`check_clang_tidy.py` will then:

- Copy the named header to the same temporary directory containing the source 
file
- Scrub `CHECK-FIXES` and `CHECK-FIXES` text from the copied header
- Run the `clang-tidy`  on the scrubbed source files with:
  - `-header-filter` and the name of the copied header file.
  -  `-I .` to specify the temporary directory in the include search path
- Verify messages and fixes on the source file.
- Verify messages and fixes on the header file.
- In the case of failure, report differences on the header and the source file.

http://reviews.llvm.org/D17482

Files:
  test/clang-tidy/check_clang_tidy.py
  test/clang-tidy/modernize-redundant-void-arg.cpp
  test/clang-tidy/modernize-redundant-void-arg.h

Index: test/clang-tidy/modernize-redundant-void-arg.h
===
--- /dev/null
+++ test/clang-tidy/modernize-redundant-void-arg.h
@@ -0,0 +1,8 @@
+#ifndef LLVM_CLANG_TOOLS_EXTRA_TEST_CLANG_TIDY_MODERNIZE_REDUNDANT_VOID_ARG_H
+#define LLVM_CLANG_TOOLS_EXTRA_TEST_CLANG_TIDY_MODERNIZE_REDUNDANT_VOID_ARG_H
+
+extern int foo(void);
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: redundant void argument list in function declaration [modernize-redundant-void-arg]
+// CHECK-FIXES: {{^}}extern int foo();{{$}}
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_TEST_CLANG_TIDY_MODERNIZE_REDUNDANT_VOID_ARG_H
Index: test/clang-tidy/modernize-redundant-void-arg.cpp
===
--- test/clang-tidy/modernize-redundant-void-arg.cpp
+++ test/clang-tidy/modernize-redundant-void-arg.cpp
@@ -1,4 +1,6 @@
-// RUN: %check_clang_tidy %s modernize-redundant-void-arg %t
+// RUN: %check_clang_tidy --header-filter=modernize-redundant-void-arg.h %s modernize-redundant-void-arg %t
+
+#include "modernize-redundant-void-arg.h"
 
 #define NULL 0
 
Index: test/clang-tidy/check_clang_tidy.py
===
--- test/clang-tidy/check_clang_tidy.py
+++ test/clang-tidy/check_clang_tidy.py
@@ -25,6 +25,7 @@
 """
 
 import argparse
+import os
 import re
 import subprocess
 import sys
@@ -35,16 +36,98 @@
 f.write(text)
 f.truncate()
 
+
+# Remove the contents of the CHECK lines to avoid CHECKs matching on
+# themselves.  We need to keep the comments to preserve line numbers while
+# avoiding empty lines which could potentially trigger formatting-related
+# checks.
+def clean_text(input_text):
+  return re.sub('// *CHECK-[A-Z-]*:[^\r\n]*', '//', input_text)
+
+
+def write_cleaned_header(input_file_path, temp_file_name, header_file_name):
+  src_path = os.path.join(os.path.dirname(input_file_path), header_file_name)
+  fixed_path = os.path.join(os.path.dirname(temp_file_name), header_file_name)
+  with open(src_path, 'r') as input_file:
+cleaned_text = clean_text(input_file.read())
+  cleaned_path = fixed_path + '.orig'
+  write_file(cleaned_path, cleaned_text)
+  write_file(fixed_path, cleaned_text)
+  return cleaned_path, fixed_path, src_path
+
+
+def separate_output(clang_tidy_output, header_file_name, input_file_name):
+  input_file_name = os.path.basename(input_file_name)
+  input_file_output = ''
+  header_file_output = ''
+  input_messages = True
+  for line in clang_tidy_output.splitlines(True):
+if input_messages:
+  if header_file_name in line:
+input_messages = False
+header_file_output += line
+  else:
+input_file_output += line
+else:
+  if input_file_name in line:
+input_messages = True
+input_file_output += line
+  else:
+header_file_output += line
+  return header_file_output, input_file_output
+
+
+def try_run(args):
+  try:
+process_output = \
+  subprocess.check_output(args, stderr=subprocess.STDOUT).decode()
+  except subprocess.CalledProcessError as e:
+print('%s failed:\n%s' % (' '.join(args), e.output.decode()))
+raise
+  return process_output
+
+
+def check_output_for_messages(messages_file, input_file_name):
+  try_run(
+['FileCheck', '-input-file=' + messages_file, input_file_name,
+   '-check-prefix=CHECK-MESSAGES',
+   '-implicit-check-not={{warning|error}}:'])
+
+
+def check_output_for_fixes(temp_file_name, input_file_name):
+  try_run(
+  ['FileCheck', '-input-file=' + temp_file_name, input_file_name,
+   '-check-prefix=CHECK-FIXES', '-strict-whitespace'])
+
+
+def has_checks(input_text):
+  has_check_fixes = input_text.find('CHECK-FIXES') >= 0
+  has_check_messages = input_text.find('CHECK-MESSAGES') >= 0
+  return has_check_fixes, has_check_messages
+
+
+def 

Re: [PATCH] D17026: Changed ASTImporter DiagnosticsEngine from FromDiag to ToDiag for unsupported ASTNodes Import.

2016-02-20 Thread Elisavet Sakellari via cfe-commits
esakella added a comment.

In http://reviews.llvm.org/D17026#356418, @akyrtzi wrote:

> Doesn't this mean that _all_ of the Importer.FromDiag() calls will be ignored 
> by VerifyDiagnosticConsumer ? Why specifically change only this two and what 
> are we going to do with the others ?
>  This seems more like needing a fix higher up in the stack, not at the 
> ASTImporter level.


Yes I think also that the right thing would be to change it in all the places, 
but for now we decided to make this change only in these two places which are 
relevant to the other things I implemented, to see first if this change would 
be acceptable.


http://reviews.llvm.org/D17026



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


Re: [PATCH] D17029: [AST] Implemented missing import for the Template type parameter and Injected Class Name in ASTImporter class.

2016-02-20 Thread Elisavet Sakellari via cfe-commits
esakella added a comment.

In http://reviews.llvm.org/D17029#356428, @akyrtzi wrote:

> If I apply just the test changes without the rest of the changes, I don't see 
> any failures, so I'm not sure these are effective tests.


This happens because also one of the changes is the new line 4304 which 
triggers the import of the template class definition , which in turn triggers 
the import of the other two elements.

If you only apply this change and the run the tests, then you see the 
respective error messages 'error: cannot import unsupported AST node 
InjectedClassName' and 'error: cannot import unsupported AST node 
TemplateTypeParm'.

I thought it would be better not to split and add this small change by itself, 
so I put them all together.


http://reviews.llvm.org/D17029



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


Re: r261297 - Implement the likely resolution of core issue 253.

2016-02-20 Thread Nico Weber via cfe-commits
On Fri, Feb 19, 2016 at 10:32 PM, Nico Weber  wrote:

> On Fri, Feb 19, 2016 at 10:02 PM, Nico Weber  wrote:
>
>> On Fri, Feb 19, 2016 at 8:01 PM, Richard Smith 
>> wrote:
>>
>>> On Fri, Feb 19, 2016 at 4:41 PM, Nico Weber  wrote:
>>> > On Fri, Feb 19, 2016 at 4:29 PM, Richard Smith via cfe-commits
>>> >  wrote:
>>> >>
>>> >> On Thu, Feb 18, 2016 at 5:52 PM, Nico Weber via cfe-commits
>>> >>  wrote:
>>> >> > Author: nico
>>> >> > Date: Thu Feb 18 19:52:46 2016
>>> >> > New Revision: 261297
>>> >> >
>>> >> > URL: http://llvm.org/viewvc/llvm-project?rev=261297=rev
>>> >> > Log:
>>> >> > Implement the likely resolution of core issue 253.
>>> >> >
>>> >> > C++11 requires const objects to have a user-provided constructor,
>>> even
>>> >> > for
>>> >> > classes without any fields. DR 253 relaxes this to say "If the
>>> implicit
>>> >> > default
>>> >> > constructor initializes all subobjects, no initializer should be
>>> >> > required."
>>> >> >
>>> >> > clang is currently the only compiler that implements this C++11
>>> rule,
>>> >> > and e.g.
>>> >> > libstdc++ relies on something like DR 253 to compile in newer
>>> versions.
>>> >> > This
>>> >> > change  makes it possible to build code that says `const
>>> vector v;'
>>> >> > again
>>> >> > when using libstdc++5.2 and _GLIBCXX_DEBUG
>>> >> > (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60284).
>>> >> >
>>> >> > Fixes PR23381.
>>> >> >
>>> >> > http://reviews.llvm.org/D16552
>>> >> >
>>> >> > Modified:
>>> >> > cfe/trunk/include/clang/AST/DeclCXX.h
>>> >> > cfe/trunk/lib/AST/ASTImporter.cpp
>>> >> > cfe/trunk/lib/AST/DeclCXX.cpp
>>> >> > cfe/trunk/lib/Sema/SemaInit.cpp
>>> >> > cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
>>> >> > cfe/trunk/lib/Serialization/ASTWriter.cpp
>>> >> >
>>>  cfe/trunk/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp
>>> >> > cfe/trunk/test/CXX/dcl.decl/dcl.init/p6.cpp
>>> >> > cfe/trunk/test/CXX/drs/dr4xx.cpp
>>> >> > cfe/trunk/test/SemaCXX/attr-selectany.cpp
>>> >> > cfe/trunk/test/SemaCXX/constexpr-value-init.cpp
>>> >> > cfe/trunk/test/SemaCXX/cxx0x-cursory-default-delete.cpp
>>> >> > cfe/trunk/test/SemaCXX/illegal-member-initialization.cpp
>>> >> > cfe/trunk/www/cxx_dr_status.html
>>> >> >
>>> >> > Modified: cfe/trunk/include/clang/AST/DeclCXX.h
>>> >> > URL:
>>> >> >
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=261297=261296=261297=diff
>>> >> >
>>> >> >
>>> ==
>>> >> > --- cfe/trunk/include/clang/AST/DeclCXX.h (original)
>>> >> > +++ cfe/trunk/include/clang/AST/DeclCXX.h Thu Feb 18 19:52:46 2016
>>> >> > @@ -378,6 +378,10 @@ class CXXRecordDecl : public RecordDecl
>>> >> >  /// even if the class has a trivial default constructor.
>>> >> >  bool HasUninitializedReferenceMember : 1;
>>> >> >
>>> >> > +/// \brief True if any non-mutable field whose type doesn't
>>> have a
>>> >> > user-
>>> >> > +/// provided default ctor also doesn't have an in-class
>>> >> > initializer.
>>> >> > +bool HasUninitializedFields : 1;
>>> >> > +
>>> >> >  /// \brief These flags are \c true if a defaulted corresponding
>>> >> > special
>>> >> >  /// member can't be fully analyzed without performing overload
>>> >> > resolution.
>>> >> >  /// @{
>>> >> > @@ -1270,6 +1274,13 @@ public:
>>> >> >  return !(data().HasTrivialSpecialMembers & SMF_Destructor);
>>> >> >}
>>> >> >
>>> >> > +  /// \brief Determine whether declaring a const variable with this
>>> >> > type is ok
>>> >> > +  /// per core issue 253.
>>> >> > +  bool allowConstDefaultInit() const {
>>> >> > +return !data().HasUninitializedFields ||
>>> >> > +   hasUserProvidedDefaultConstructor();
>>> >>
>>> >> hasUserProvidedDefaultConstructor() here is subtly incorrect. We
>>> >> shouldn't care whether there's a user-provided default constructor, we
>>> >> instead care whether the constructor that would have been chosen for
>>> >> initialization is defaulted (or equivalently, whether there *is* a
>>> >> defaulted default constructor, since if there is one, then either the
>>> >> initialization is ambiguous or it is chosen).
>>> >>
>>> >> This causes a regression for a testcase such as:
>>> >>
>>> >> struct X { template X(T...); int n; };
>>> >> const X x; // formerly OK, now bogus error
>>> >
>>> >
>>> > Hm, great point. For a single hop, this fixes it:
>>> >
>>> > Index: lib/Sema/SemaInit.cpp
>>> > ===
>>> > --- lib/Sema/SemaInit.cpp (revision 261298)
>>> > +++ lib/Sema/SemaInit.cpp (working copy)
>>> > @@ -3521,7 +3521,7 @@
>>> >// The 253 proposal is for example needed to process libstdc++
>>> headers in
>>> > 5.x.
>>> >CXXConstructorDecl *CtorDecl =
>>> 

Re: r261422 - Fix handling of vaargs on PPC32 when going from regsave to overflow.

2016-02-20 Thread Hal Finkel via cfe-commits


- Original Message -
> From: "Dimitry Andric via cfe-commits" 
> To: "Hans Wennborg" 
> Cc: "Roman Divacky" , "cfe-commits" 
> 
> Sent: Saturday, February 20, 2016 8:24:36 AM
> Subject: Re: r261422 - Fix handling of vaargs on PPC32 when going from 
> regsave to overflow.
> 
> On 20 Feb 2016, at 09:31, Roman Divacky via cfe-commits
>  wrote:
> > 
> > Author: rdivacky
> > Date: Sat Feb 20 02:31:24 2016
> > New Revision: 261422
> > 
> > URL: http://llvm.org/viewvc/llvm-project?rev=261422=rev
> > Log:
> > Fix handling of vaargs on PPC32 when going from regsave to
> > overflow.
> > 
> > It can happen that when we only have 1 more register left in the
> > regsave
> > area we need to store a value bigger than 1 register and therefore
> > we
> > go to the overflow area. In this case we have to leave the last
> > slot
> > in the regsave area unused and keep using overflow area. Do this
> > by storing a limit value to the used register counter in the
> > overflow block.
> > 
> > Issue diagnosed by and solution tested by Mark Millard!
> 
> Hans, this looks like a nice minor fix to have in 3.8.0.  Can we
> merge it, please?

Fine by me.

 -Hal

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

-- 
Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r261422 - Fix handling of vaargs on PPC32 when going from regsave to overflow.

2016-02-20 Thread Dimitry Andric via cfe-commits
On 20 Feb 2016, at 09:31, Roman Divacky via cfe-commits 
 wrote:
> 
> Author: rdivacky
> Date: Sat Feb 20 02:31:24 2016
> New Revision: 261422
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=261422=rev
> Log:
> Fix handling of vaargs on PPC32 when going from regsave to overflow.
> 
> It can happen that when we only have 1 more register left in the regsave
> area we need to store a value bigger than 1 register and therefore we
> go to the overflow area. In this case we have to leave the last slot
> in the regsave area unused and keep using overflow area. Do this
> by storing a limit value to the used register counter in the overflow block.
> 
> Issue diagnosed by and solution tested by Mark Millard!

Hans, this looks like a nice minor fix to have in 3.8.0.  Can we merge it, 
please?

-Dimitry



signature.asc
Description: Message signed with OpenPGP using GPGMail
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17444: PR26672: [MSVC] Clang does not recognize "static_assert" keyword in C mode

2016-02-20 Thread Andrey Bokhanko via cfe-commits
andreybokhanko updated this revision to Diff 48591.
andreybokhanko added a comment.

Patch updated in response to Reid's proposal (to introduce KEYMSCOMPAT).

(To clarify, I agree with Aaron that we should wait for MS' response first. 
Though I frankly don't expect them to accept recognition of "static_assert" as 
a bug, so wanted to have a patch ready.)

Yours,

Andrey
==

Software Engineer
Intel Compiler Team


http://reviews.llvm.org/D17444

Files:
  include/clang/Basic/TokenKinds.def
  lib/Basic/IdentifierTable.cpp
  test/Lexer/keywords_test.cpp

Index: lib/Basic/IdentifierTable.cpp
===
--- lib/Basic/IdentifierTable.cpp
+++ lib/Basic/IdentifierTable.cpp
@@ -113,6 +113,7 @@
 KEYOBJC2= 0x2,
 KEYZVECTOR  = 0x4,
 KEYCOROUTINES = 0x8,
+KEYMSCOMPAT = 0x10,
 KEYALL = (0xf & ~KEYNOMS18 &
   ~KEYNOOPENCL) // KEYNOMS18 and KEYNOOPENCL are used to exclude.
   };
@@ -136,6 +137,7 @@
   if (LangOpts.C99 && (Flags & KEYC99)) return KS_Enabled;
   if (LangOpts.GNUKeywords && (Flags & KEYGNU)) return KS_Extension;
   if (LangOpts.MicrosoftExt && (Flags & KEYMS)) return KS_Extension;
+  if (LangOpts.MSVCCompat && (Flags & KEYMSCOMPAT)) return KS_Enabled;
   if (LangOpts.Borland && (Flags & KEYBORLAND)) return KS_Extension;
   if (LangOpts.Bool && (Flags & BOOLSUPPORT)) return KS_Enabled;
   if (LangOpts.Half && (Flags & HALFSUPPORT)) return KS_Enabled;
Index: include/clang/Basic/TokenKinds.def
===
--- include/clang/Basic/TokenKinds.def
+++ include/clang/Basic/TokenKinds.def
@@ -237,6 +237,7 @@
 // are enabled.
 //   KEYGNU   - This is a keyword if GNU extensions are enabled
 //   KEYMS- This is a keyword if Microsoft extensions are enabled
+//   KEYMSCOMPAT - This is a keyword if Microsoft compatibility mode is enabled
 //   KEYNOMS18 - This is a keyword that must never be enabled under
 //   MSVC <= v18.
 //   KEYOPENCL  - This is a keyword in OpenCL
@@ -354,7 +355,7 @@
 CXX11_KEYWORD(decltype  , 0)
 CXX11_KEYWORD(noexcept  , 0)
 CXX11_KEYWORD(nullptr   , 0)
-CXX11_KEYWORD(static_assert , 0)
+CXX11_KEYWORD(static_assert , KEYMSCOMPAT)
 CXX11_KEYWORD(thread_local  , 0)
 
 // C++ concepts TS keywords
Index: test/Lexer/keywords_test.cpp
===
--- test/Lexer/keywords_test.cpp
+++ test/Lexer/keywords_test.cpp
@@ -10,9 +10,9 @@
 // RUN: %clang_cc1 -std=c++03 -fdeclspec -fno-declspec -fsyntax-only %s
 // RUN: %clang_cc1 -std=c++03 -fms-extensions -fno-declspec -fdeclspec 
-DDECLSPEC -fsyntax-only %s
 // RUN: %clang_cc1 -std=c++03 -fms-extensions -fdeclspec -fno-declspec 
-fsyntax-only %s
-// RUN: %clang -std=c++03 -target i686-windows-msvc -DDECLSPEC -fsyntax-only %s
+// RUN: %clang -std=c++03 -target i686-windows-msvc -DMS -DDECLSPEC 
-fsyntax-only %s
 // RUN: %clang -std=c++03 -target x86_64-scei-ps4 -DDECLSPEC -fsyntax-only %s
-// RUN: %clang -std=c++03 -target i686-windows-msvc -fno-declspec 
-fsyntax-only %s
+// RUN: %clang -std=c++03 -target i686-windows-msvc -DMS -fno-declspec 
-fsyntax-only %s
 // RUN: %clang -std=c++03 -target x86_64-scei-ps4 -fno-declspec -fsyntax-only 
%s
 
 #define IS_KEYWORD(NAME) _Static_assert(!__is_identifier(NAME), #NAME)
@@ -50,7 +50,12 @@
 CXX11_TYPE(char32_t);
 CXX11_KEYWORD(constexpr);
 CXX11_KEYWORD(noexcept);
+#ifndef MS
 CXX11_KEYWORD(static_assert);
+#else
+// MS compiler recognizes static_assert in all modes. So should we.
+IS_KEYWORD(static_assert);
+#endif
 CXX11_KEYWORD(thread_local);
 
 // Concepts TS keywords


Index: lib/Basic/IdentifierTable.cpp
===
--- lib/Basic/IdentifierTable.cpp
+++ lib/Basic/IdentifierTable.cpp
@@ -113,6 +113,7 @@
 KEYOBJC2= 0x2,
 KEYZVECTOR  = 0x4,
 KEYCOROUTINES = 0x8,
+KEYMSCOMPAT = 0x10,
 KEYALL = (0xf & ~KEYNOMS18 &
   ~KEYNOOPENCL) // KEYNOMS18 and KEYNOOPENCL are used to exclude.
   };
@@ -136,6 +137,7 @@
   if (LangOpts.C99 && (Flags & KEYC99)) return KS_Enabled;
   if (LangOpts.GNUKeywords && (Flags & KEYGNU)) return KS_Extension;
   if (LangOpts.MicrosoftExt && (Flags & KEYMS)) return KS_Extension;
+  if (LangOpts.MSVCCompat && (Flags & KEYMSCOMPAT)) return KS_Enabled;
   if (LangOpts.Borland && (Flags & KEYBORLAND)) return KS_Extension;
   if (LangOpts.Bool && (Flags & BOOLSUPPORT)) return KS_Enabled;
   if (LangOpts.Half && (Flags & HALFSUPPORT)) return KS_Enabled;
Index: include/clang/Basic/TokenKinds.def
===
--- include/clang/Basic/TokenKinds.def
+++ include/clang/Basic/TokenKinds.def
@@ -237,6 +237,7 @@
 // are enabled.
 //   KEYGNU   - This is a keyword if GNU extensions are enabled
 //   KEYMS- This 

[clang-tools-extra] r261431 - [clang-tidy] Describe modules, link to LLVM development docs, other minor updates

2016-02-20 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Sat Feb 20 05:42:13 2016
New Revision: 261431

URL: http://llvm.org/viewvc/llvm-project?rev=261431=rev
Log:
[clang-tidy] Describe modules, link to LLVM development docs, other minor 
updates

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

Modified: clang-tools-extra/trunk/docs/clang-tidy/index.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/index.rst?rev=261431=261430=261431=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/index.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/index.rst Sat Feb 20 05:42:13 2016
@@ -328,10 +328,38 @@ Writing a clang-tidy Check
 
 So you have an idea of a useful check for :program:`clang-tidy`.
 
-You need to decide which module the check belongs to. If the check verifies
-conformance of the code to a certain coding style, it probably deserves a
-separate module and a directory in ``clang-tidy/`` (there are LLVM and Google
-modules already).
+First, if you're not familiar with LLVM development, read through the `Getting
+Started with LLVM`_ document for instructions on setting up your workflow and
+the `LLVM Coding Standards`_ document to familiarize yourself with the coding
+style used in the project. For code reviews we mostly use `LLVM Phabricator`_.
+
+.. _Getting Started with LLVM: http://llvm.org/docs/GettingStarted.html
+.. _LLVM Coding Standards: http://llvm.org/docs/CodingStandards.html
+.. _LLVM Phabricator: http://llvm.org/docs/Phabricator.html
+
+
+Next, you need to decide which module the check belongs to. If the check
+verifies conformance of the code to a certain coding style, it probably 
deserves
+a separate module and a directory in ``clang-tidy/``. There are already modules
+implementing checks related to:
+
+* `C++ Core Guidelines
+  
`_
+* `CERT Secure Coding Standards
+  
`_
+* `Google Style Guide
+  
`_
+* `LLVM Style
+  
`_
+* `modernizing C/C++ code
+  
`_
+* potential `performance problems
+  
`_
+* various `readability issues
+  
`_
+* and `miscellaneous checks
+  
`_
+  that we couldn't find a better category for.
 
 After choosing the module, you need to create a class for your check:
 
@@ -341,13 +369,21 @@ After choosing the module, you need to c
 
   namespace clang {
   namespace tidy {
+  namespace some_module {
 
   class MyCheck : public ClangTidyCheck {
+  public:
+MyCheck(StringRef Name, ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context) {}
   };
 
+  } // namespace some_module
   } // namespace tidy
   } // namespace clang
 
+Constructor of the check receives the ``Name`` and ``Context`` parameters, and
+must forward them to the ``ClangTidyCheck`` constructor.
+
 Next, you need to decide whether it should operate on the preprocessor level or
 on the AST level. Let's imagine that we need to work with the AST in our check.
 In this case we need to override two methods:
@@ -363,9 +399,6 @@ In this case we need to override two met
 void check(ast_matchers::MatchFinder::MatchResult ) override;
   };
 
-Constructor of the check receives the ``Name`` and ``Context`` parameters, and
-must forward them to the ``ClangTidyCheck`` constructor.
-
 In the ``registerMatchers`` method we create an AST Matcher (see `AST 
Matchers`_
 for more information) that will find the pattern in the AST that we want to
 inspect. The results of the matching are passed to the ``check`` method, which
@@ -380,8 +413,7 @@ can further inspect them and report diag
   }
 
   void ExplicitConstructorCheck::check(const MatchFinder::MatchResult ) 
{
-const CXXConstructorDecl *Ctor =
-Result.Nodes.getNodeAs("ctor");
+const auto *Ctor = Result.Nodes.getNodeAs("ctor");
 // Do not be confused: isExplicit means 'explicit' keyword is present,
 // isImplicit means that it's a compiler-generated constructor.
 if (Ctor->isOutOfLine() || Ctor->isExplicit() || Ctor->isImplicit())
@@ -394,7 +426,10 @@ can further inspect them and report diag
   }
 
 (The full code for this check resides in
-``clang-tidy/google/ExplicitConstructorCheck.{h,cpp}``).
+`clang-tidy/google/ExplicitConstructorCheck.h

r261425 - [MSVC Compat] Implement -EHc semantics

2016-02-20 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Sat Feb 20 03:23:47 2016
New Revision: 261425

URL: http://llvm.org/viewvc/llvm-project?rev=261425=rev
Log:
[MSVC Compat] Implement -EHc semantics

The -EHc flag implicitly adds a nothrow attribute to any extern "C"
function when exceptions are enabled.

Modified:
cfe/trunk/include/clang/Basic/LangOptions.def
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp

Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=261425=261424=261425=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Sat Feb 20 03:23:47 2016
@@ -110,6 +110,7 @@ LANGOPT(Exceptions, 1, 0, "excep
 LANGOPT(ObjCExceptions, 1, 0, "Objective-C exceptions")
 LANGOPT(CXXExceptions , 1, 0, "C++ exceptions")
 LANGOPT(SjLjExceptions, 1, 0, "setjmp-longjump exception handling")
+LANGOPT(ExternCNoUnwind   , 1, 0, "Assume extern C functions don't unwind")
 LANGOPT(TraditionalCPP, 1, 0, "traditional CPP emulation")
 LANGOPT(RTTI  , 1, 1, "run-time type information")
 LANGOPT(RTTIData  , 1, 1, "emit run-time type information data")

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=261425=261424=261425=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Sat Feb 20 03:23:47 2016
@@ -511,6 +511,8 @@ def main_file_name : Separate<["-"], "ma
 
 def fblocks_runtime_optional : Flag<["-"], "fblocks-runtime-optional">,
   HelpText<"Weakly link in the blocks runtime">;
+def fexternc_nounwind : Flag<["-"], "fexternc-nounwind">,
+  HelpText<"Assume all functions with C linkage do not unwind">;
 def fsjlj_exceptions : Flag<["-"], "fsjlj-exceptions">,
   HelpText<"Use SjLj style exceptions">;
 def split_dwarf_file : Separate<["-"], "split-dwarf-file">,

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=261425=261424=261425=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Sat Feb 20 03:23:47 2016
@@ -5786,8 +5786,7 @@ struct EHFlags {
 /// - s: Cleanup after "synchronous" exceptions, aka C++ exceptions.
 /// - a: Cleanup after "asynchronous" exceptions, aka structured exceptions.
 ///  The 'a' modifier is unimplemented and fundamentally hard in LLVM IR.
-/// - c: Assume that extern "C" functions are implicitly noexcept.  This
-///  modifier is an optimization, so we ignore it for now.
+/// - c: Assume that extern "C" functions are implicitly nounwind.
 /// The default is /EHs-c-, meaning cleanups are disabled.
 static EHFlags parseClangCLEHFlags(const Driver , const ArgList ) {
   EHFlags EH;
@@ -5897,10 +5896,11 @@ void Clang::AddClangCLArgs(const ArgList
 
   const Driver  = getToolChain().getDriver();
   EHFlags EH = parseClangCLEHFlags(D, Args);
-  // FIXME: Do something with NoExceptC.
   if (EH.Synch || EH.Asynch) {
 CmdArgs.push_back("-fcxx-exceptions");
 CmdArgs.push_back("-fexceptions");
+if (EH.NoUnwindC)
+  CmdArgs.push_back("-fexternc-nounwind");
   }
 
   // /EP should expand to -E -P.

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=261425=261424=261425=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Sat Feb 20 03:23:47 2016
@@ -1688,6 +1688,7 @@ static void ParseLangArgs(LangOptions 
   Opts.ObjCExceptions = Args.hasArg(OPT_fobjc_exceptions);
   Opts.CXXExceptions = Args.hasArg(OPT_fcxx_exceptions);
   Opts.SjLjExceptions = Args.hasArg(OPT_fsjlj_exceptions);
+  Opts.ExternCNoUnwind = Args.hasArg(OPT_fexternc_nounwind);
   Opts.TraditionalCPP = Args.hasArg(OPT_traditional_cpp);
 
   Opts.RTTI = Opts.CPlusPlus && !Args.hasArg(OPT_fno_rtti);

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=261425=261424=261425=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Sat Feb 20 03:23:47 2016
@@ -11582,6 +11582,13 @@ void Sema::AddKnownFunctionAttributes(Fu
 }
   }
 
+  // If C++ exceptions are enabled but we are told extern "C" functions cannot
+  // throw, add an implicit 

r261422 - Fix handling of vaargs on PPC32 when going from regsave to overflow.

2016-02-20 Thread Roman Divacky via cfe-commits
Author: rdivacky
Date: Sat Feb 20 02:31:24 2016
New Revision: 261422

URL: http://llvm.org/viewvc/llvm-project?rev=261422=rev
Log:
Fix handling of vaargs on PPC32 when going from regsave to overflow.

It can happen that when we only have 1 more register left in the regsave
area we need to store a value bigger than 1 register and therefore we
go to the overflow area. In this case we have to leave the last slot
in the regsave area unused and keep using overflow area. Do this
by storing a limit value to the used register counter in the overflow block.

Issue diagnosed by and solution tested by Mark Millard!

Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/test/CodeGen/ppc-varargs-struct.c

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=261422=261421=261422=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Sat Feb 20 02:31:24 2016
@@ -3505,6 +3505,7 @@ public:
 
 Address PPC32_SVR4_ABIInfo::EmitVAArg(CodeGenFunction , Address VAList,
   QualType Ty) const {
+  const unsigned OverflowLimit = 8;
   if (const ComplexType *CTy = Ty->getAs()) {
 // TODO: Implement this. For now ignore.
 (void)CTy;
@@ -3547,7 +3548,7 @@ Address PPC32_SVR4_ABIInfo::EmitVAArg(Co
   }
 
   llvm::Value *CC =
-  Builder.CreateICmpULT(NumRegs, Builder.getInt8(8), "cond");
+  Builder.CreateICmpULT(NumRegs, Builder.getInt8(OverflowLimit), "cond");
 
   llvm::BasicBlock *UsingRegs = CGF.createBasicBlock("using_regs");
   llvm::BasicBlock *UsingOverflow = CGF.createBasicBlock("using_overflow");
@@ -3599,6 +3600,8 @@ Address PPC32_SVR4_ABIInfo::EmitVAArg(Co
   {
 CGF.EmitBlock(UsingOverflow);
 
+Builder.CreateStore(Builder.getInt8(OverflowLimit), NumRegsAddr);
+
 // Everything in the overflow area is rounded up to a size of at least 4.
 CharUnits OverflowAreaAlign = CharUnits::fromQuantity(4);
 

Modified: cfe/trunk/test/CodeGen/ppc-varargs-struct.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ppc-varargs-struct.c?rev=261422=261421=261422=diff
==
--- cfe/trunk/test/CodeGen/ppc-varargs-struct.c (original)
+++ cfe/trunk/test/CodeGen/ppc-varargs-struct.c Sat Feb 20 02:31:24 2016
@@ -37,6 +37,7 @@ void testva (int n, ...)
 // CHECK-PPC-NEXT:  br label %[[CONT:[a-z0-9]+]]
 //
 // CHECK-PPC:[[USING_OVERFLOW]]
+// CHECK-PPC-NEXT:  store i8 8, i8* [[GPRPTR]], align 4
 // CHECK-PPC-NEXT:  [[OVERFLOW_AREA_P:%[0-9]+]] = getelementptr inbounds 
%struct.__va_list_tag, %struct.__va_list_tag* [[ARRAYDECAY]], i32 0, i32 3
 // CHECK-PPC-NEXT:  [[OVERFLOW_AREA:%.+]] = load i8*, i8** 
[[OVERFLOW_AREA_P]], align 4
 // CHECK-PPC-NEXT:  %{{[0-9]+}} =  ptrtoint i8* %argp.cur to i32
@@ -76,6 +77,7 @@ void testva (int n, ...)
 // CHECK-PPC-NEXT:  br label %[[CONT:[a-z0-9]+]]
 //
 // CHECK-PPC:[[USING_OVERFLOW]]
+// CHECK-PPC-NEXT:  store i8 8, i8* [[GPRPTR]], align 4
 // CHECK-PPC-NEXT:  [[OVERFLOW_AREA_P:%[0-9]+]] = getelementptr inbounds 
%struct.__va_list_tag, %struct.__va_list_tag* [[ARRAYDECAY]], i32 0, i32 3
 // CHECK-PPC-NEXT:  [[OVERFLOW_AREA:%.+]] = load i8*, i8** 
[[OVERFLOW_AREA_P]], align 4
 // CHECK-PPC-NEXT:  [[MEMADDR:%.+]] = bitcast i8* [[OVERFLOW_AREA]] to i32*


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


[libcxx] r261421 - Rename <__hash_table> traits so they don't conflict with similar traits.

2016-02-20 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sat Feb 20 01:59:16 2016
New Revision: 261421

URL: http://llvm.org/viewvc/llvm-project?rev=261421=rev
Log:
Rename <__hash_table> traits so they don't conflict with similar traits.

In particular <__tree> defines many of the same types of traits classes.

Modified:
libcxx/trunk/include/__hash_table
libcxx/trunk/test/libcxx/containers/unord/key_value_traits.pass.cpp

Modified: libcxx/trunk/include/__hash_table
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__hash_table?rev=261421=261420=261421=diff
==
--- libcxx/trunk/include/__hash_table (original)
+++ libcxx/trunk/include/__hash_table Sat Feb 20 01:59:16 2016
@@ -110,7 +110,7 @@ template  class _LI
 template  class _LIBCPP_TYPE_VIS_ONLY 
__hash_map_const_iterator;
 
 template 
-struct __key_value_types {
+struct __hash_key_value_types {
   static_assert(!is_reference<_Tp>::value && !is_const<_Tp>::value, "");
   typedef _Tp key_type;
   typedef _Tp __node_value_type;
@@ -138,7 +138,7 @@ struct __key_value_types {
 };
 
 template 
-struct __key_value_types<__hash_value_type<_Key, _Tp> > {
+struct __hash_key_value_types<__hash_value_type<_Key, _Tp> > {
   typedef _Key key_type;
   typedef _Tp  mapped_type;
   typedef __hash_value_type<_Key, _Tp> __node_value_type;
@@ -181,12 +181,12 @@ struct __key_value_types<__hash_value_ty
 
 };
 
-template ,
+template ,
   bool = _KVTypes::__is_map>
-struct __map_pointer_types {};
+struct __hash_map_pointer_types {};
 
 template 
-struct __map_pointer_types<_Tp, _AllocPtr, _KVTypes, true> {
+struct __hash_map_pointer_types<_Tp, _AllocPtr, _KVTypes, true> {
   typedef typename _KVTypes::__map_value_type   _Mv;
   typedef typename __rebind_pointer<_AllocPtr, _Mv>::type

__map_value_type_pointer;
@@ -199,10 +199,10 @@ struct __hash_node_types;
 
 template 
 struct __hash_node_types<_NodePtr, __hash_node<_Tp, _VoidPtr> >
-: public __key_value_types<_Tp>, __map_pointer_types<_Tp, _VoidPtr>
+: public __hash_key_value_types<_Tp>, __hash_map_pointer_types<_Tp, 
_VoidPtr>
 
 {
-  typedef __key_value_types<_Tp>   __base;
+  typedef __hash_key_value_types<_Tp>   __base;
 
 public:
   typedef ptrdiff_t difference_type;

Modified: libcxx/trunk/test/libcxx/containers/unord/key_value_traits.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/containers/unord/key_value_traits.pass.cpp?rev=261421=261420=261421=diff
==
--- libcxx/trunk/test/libcxx/containers/unord/key_value_traits.pass.cpp 
(original)
+++ libcxx/trunk/test/libcxx/containers/unord/key_value_traits.pass.cpp Sat Feb 
20 01:59:16 2016
@@ -18,7 +18,7 @@
 void testKeyValueTrait() {
   {
 typedef int Tp;
-typedef std::__key_value_types Traits;
+typedef std::__hash_key_value_types Traits;
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), 
"");
@@ -26,7 +26,7 @@ void testKeyValueTrait() {
   }
   {
 typedef std::pair Tp;
-typedef std::__key_value_types Traits;
+typedef std::__hash_key_value_types Traits;
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), 
"");
@@ -34,7 +34,7 @@ void testKeyValueTrait() {
   }
   {
 typedef std::pair Tp;
-typedef std::__key_value_types Traits;
+typedef std::__hash_key_value_types Traits;
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), 
"");
@@ -42,7 +42,7 @@ void testKeyValueTrait() {
   }
   {
 typedef std::__hash_value_type Tp;
-typedef std::__key_value_types Traits;
+typedef std::__hash_key_value_types Traits;
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");


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