Re: [PATCH] D14184: [clang] Add initial support for -meabi flag

2015-11-03 Thread Renato Golin via cfe-commits
rengolin added inline comments.


Comment at: lib/Frontend/CompilerInvocation.cpp:458
@@ +457,3 @@
+StringRef Value = A->getValue();
+bool Valid = llvm::StringSwitch(Value)
+  .Case("default", true)

tinti wrote:
> tinti wrote:
> > compnerd wrote:
> > > If `llvm::EABI::EABIVersionType` had an `Invalid` value in the 
> > > enumeration, you could convert directly to the value here, and report the 
> > > error if the value was `Invalid`.
> > I chose this way because none of the other target options have it [1].
> > 
> > Do you prefer with it?
> > 
> > [1] 
> > https://github.com/llvm-mirror/llvm/blob/master/include/llvm/Target/TargetOptions.h#L27
> Looks like that in LLVM the Invalid is not defined but in Clang there are 
> target specific enums that define them [1].
> 
> [1] https://github.com/llvm-mirror/clang/blob/master/lib/Driver/Tools.h#L263
@compnerd, it seems that this code is already checking for invalid values, I'm 
not sure what you're asking about.

Also, EABI::EABIVersionType has no field Invalid, and I don't think it should, 
either.


http://reviews.llvm.org/D14184



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


[PATCH] D14285: [x86] Additional small fix for MCU psABI support

2015-11-03 Thread Andrey Bokhanko via cfe-commits
andreybokhanko created this revision.
andreybokhanko added reviewers: rnk, DavidKreitzer, mkuper.
andreybokhanko added a subscriber: cfe-commits.

This patch fixes one more thing in MCU psABI support: LongDoubleWidth should be 
set to 64.

http://reviews.llvm.org/D14285

Files:
  lib/Basic/Targets.cpp
  test/CodeGen/x86_32-arguments-iamcu.c

Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -2335,8 +2335,7 @@
 public:
   X86TargetInfo(const llvm::Triple ) : TargetInfo(Triple) {
 BigEndian = false;
-LongDoubleFormat = Triple.isOSIAMCU() ? ::APFloat::IEEEdouble
-  : ::APFloat::x87DoubleExtended;
+LongDoubleFormat = ::APFloat::x87DoubleExtended;
   }
   unsigned getFloatEvalMethod() const override {
 // X87 evaluates with 80 bits "long double" precision.
@@ -3624,6 +3623,11 @@
 IntPtrType = SignedInt;
 RegParmMax = 3;
 
+if (getTriple().isOSIAMCU()) {
+  LongDoubleWidth = 64;
+  LongDoubleFormat = ::APFloat::IEEEdouble;
+}
+
 // Use fpret for all types.
 RealTypeUsesObjCFPRet = ((1 << TargetInfo::Float) |
  (1 << TargetInfo::Double) |
Index: test/CodeGen/x86_32-arguments-iamcu.c
===
--- test/CodeGen/x86_32-arguments-iamcu.c
+++ test/CodeGen/x86_32-arguments-iamcu.c
@@ -57,6 +57,6 @@
 // CHECK-LABEL: define i32 @varArgs(i32 inreg %i1, ...)
 int varArgs(int i1, ...) { return i1; }
 
-// CHECK-LABEL: define double @longDoubleArg(double %ld1)
+// CHECK-LABEL: define double @longDoubleArg(double inreg %ld1)
 long double longDoubleArg(long double ld1) { return ld1; }
 


Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -2335,8 +2335,7 @@
 public:
   X86TargetInfo(const llvm::Triple ) : TargetInfo(Triple) {
 BigEndian = false;
-LongDoubleFormat = Triple.isOSIAMCU() ? ::APFloat::IEEEdouble
-  : ::APFloat::x87DoubleExtended;
+LongDoubleFormat = ::APFloat::x87DoubleExtended;
   }
   unsigned getFloatEvalMethod() const override {
 // X87 evaluates with 80 bits "long double" precision.
@@ -3624,6 +3623,11 @@
 IntPtrType = SignedInt;
 RegParmMax = 3;
 
+if (getTriple().isOSIAMCU()) {
+  LongDoubleWidth = 64;
+  LongDoubleFormat = ::APFloat::IEEEdouble;
+}
+
 // Use fpret for all types.
 RealTypeUsesObjCFPRet = ((1 << TargetInfo::Float) |
  (1 << TargetInfo::Double) |
Index: test/CodeGen/x86_32-arguments-iamcu.c
===
--- test/CodeGen/x86_32-arguments-iamcu.c
+++ test/CodeGen/x86_32-arguments-iamcu.c
@@ -57,6 +57,6 @@
 // CHECK-LABEL: define i32 @varArgs(i32 inreg %i1, ...)
 int varArgs(int i1, ...) { return i1; }
 
-// CHECK-LABEL: define double @longDoubleArg(double %ld1)
+// CHECK-LABEL: define double @longDoubleArg(double inreg %ld1)
 long double longDoubleArg(long double ld1) { return ld1; }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r251949 - Simplify Sema::ProcessPropertyDecl. NFC

2015-11-03 Thread Douglas Gregor via cfe-commits
Author: dgregor
Date: Tue Nov  3 11:02:34 2015
New Revision: 251949

URL: http://llvm.org/viewvc/llvm-project?rev=251949=rev
Log:
Simplify Sema::ProcessPropertyDecl. NFC

Now that the properties created within Objective-C class extensions go
into the extension themselves, we don't need any of the extra
complexity here.

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/lib/Sema/SemaObjCProperty.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=251949=251948=251949=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Nov  3 11:02:34 2015
@@ -7257,14 +7257,7 @@ public:
   /// Process the specified property declaration and create decls for the
   /// setters and getters as needed.
   /// \param property The property declaration being processed
-  /// \param CD The semantic container for the property
-  /// \param redeclaredProperty Declaration for property if redeclared
-  ///in class extension.
-  /// \param lexicalDC Container for redeclaredProperty.
-  void ProcessPropertyDecl(ObjCPropertyDecl *property,
-   ObjCContainerDecl *CD,
-   ObjCPropertyDecl *redeclaredProperty = nullptr,
-   ObjCContainerDecl *lexicalDC = nullptr);
+  void ProcessPropertyDecl(ObjCPropertyDecl *property);
 
 
   void DiagnosePropertyMismatch(ObjCPropertyDecl *Property,

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=251949=251948=251949=diff
==
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Tue Nov  3 11:02:34 2015
@@ -3637,7 +3637,7 @@ Decl *Sema::ActOnAtEnd(Scope *S, SourceR
   // user-defined setter/getter. It also synthesizes setter/getter methods
   // and adds them to the DeclContext and global method pools.
   for (auto *I : CDecl->properties())
-ProcessPropertyDecl(I, CDecl);
+ProcessPropertyDecl(I);
 CDecl->setAtEndRange(AtEnd);
   }
   if (ObjCImplementationDecl *IC=dyn_cast(ClassDecl)) {

Modified: cfe/trunk/lib/Sema/SemaObjCProperty.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaObjCProperty.cpp?rev=251949=251948=251949=diff
==
--- cfe/trunk/lib/Sema/SemaObjCProperty.cpp (original)
+++ cfe/trunk/lib/Sema/SemaObjCProperty.cpp Tue Nov  3 11:02:34 2015
@@ -390,9 +390,7 @@ Sema::HandlePropertyInClassExtension(Sco
   // If there was no declaration of a property with the same name in
   // the primary class, we're done.
   if (!PIDecl) {
-ProcessPropertyDecl(PDecl, CDecl,
-/* redeclaredProperty = */ nullptr,
-/* lexicalDC = */ CDecl);
+ProcessPropertyDecl(PDecl);
 return PDecl;
   }
 
@@ -483,8 +481,8 @@ Sema::HandlePropertyInClassExtension(Sco
 
   *isOverridingProperty = true;
 
-  // Make sure setter decl is synthesized, and added to continuation class's 
list.
-  ProcessPropertyDecl(PDecl, CDecl, PIDecl, CDecl);
+  // Make sure getter/setter are appropriately synthesized.
+  ProcessPropertyDecl(PDecl);
   return PDecl;
 }
 
@@ -1973,15 +1971,10 @@ static void AddPropertyAttrs(Sema , Ob
 /// ProcessPropertyDecl - Make sure that any user-defined setter/getter methods
 /// have the property type and issue diagnostics if they don't.
 /// Also synthesize a getter/setter method if none exist (and update the
-/// appropriate lookup tables. FIXME: Should reconsider if adding synthesized
-/// methods is the "right" thing to do.
-void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property,
-   ObjCContainerDecl *CD,
-   ObjCPropertyDecl *redeclaredProperty,
-   ObjCContainerDecl *lexicalDC) {
-
+/// appropriate lookup tables.
+void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property) {
   ObjCMethodDecl *GetterMethod, *SetterMethod;
-
+  ObjCContainerDecl *CD = cast(property->getDeclContext());
   if (CD->isInvalidDecl())
 return;
 
@@ -2060,10 +2053,6 @@ void Sema::ProcessPropertyDecl(ObjCPrope
 
 AddPropertyAttrs(*this, GetterMethod, property);
 
-// FIXME: Eventually this shouldn't be needed, as the lexical context
-// and the real context should be the same.
-if (lexicalDC)
-  GetterMethod->setLexicalDeclContext(lexicalDC);
 if (property->hasAttr())
   GetterMethod->addAttr(NSReturnsNotRetainedAttr::CreateImplicit(Context,
  Loc));
@@ -2134,10 +2123,6 @@ void Sema::ProcessPropertyDecl(ObjCPrope
   AddPropertyAttrs(*this, 

Re: [PATCH] D14180: enable -fms-extensions by default on the mingw-w64 target

2015-11-03 Thread Martell Malone via cfe-commits
martell added a comment.

> This is what I'm worried about. :) Can you elaborate on what would break?


Essentially mingw-w64 has a few header defines for working around builtings 
such as __rtdsc and the interlocked functions and some other builtins
As soon as one of these headers are included it would result in a compile time 
error as it would collide with what clang now provides.

I have talked to jon_y the 4.x maintainer about this before.
We could port back my patches to next 4.x release which i believe is 4.0.4.
But essentially older versions of mingw-w64 that doesn't respect the compiler 
may have the builtins would not work.

We don't have to make this break now of course but we should do it at some 
point?


http://reviews.llvm.org/D14180



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


r251953 - Revert "Support watchOS and tvOS in compiler-rt builds"

2015-11-03 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Tue Nov  3 12:14:42 2015
New Revision: 251953

URL: http://llvm.org/viewvc/llvm-project?rev=251953=rev
Log:
Revert "Support watchOS and tvOS in compiler-rt builds"

The required compiler-rt changes aren't present yet so attempting to
build with compiler-rt breaks. And since we're trying to deprecate
autotools we actually want to fix this in CMake primarily anyway.

This reverts r251712.

Modified:
cfe/trunk/runtime/compiler-rt/Makefile

Modified: cfe/trunk/runtime/compiler-rt/Makefile
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/runtime/compiler-rt/Makefile?rev=251953=251952=251953=diff
==
--- cfe/trunk/runtime/compiler-rt/Makefile (original)
+++ cfe/trunk/runtime/compiler-rt/Makefile Tue Nov  3 12:14:42 2015
@@ -83,25 +83,6 @@ RuntimeLibrary.darwin.Configs := \
 
 IOS_SDK := $(shell xcrun --show-sdk-path -sdk iphoneos 2> /dev/null)
 IOSSIM_SDK := $(shell xcrun --show-sdk-path -sdk iphonesimulator 2> /dev/null)
-TVOS_SDK := $(shell xcrun --show-sdk-path -sdk appletvos 2> /dev/null)
-TVOSSIM_SDK := $(shell xcrun --show-sdk-path -sdk appletvsimulator 2> 
/dev/null)
-WATCHOS_SDK := $(shell xcrun --show-sdk-path -sdk watchos 2> /dev/null)
-WATCHOSSIM_SDK := $(shell xcrun --show-sdk-path -sdk watchsimulator 2> 
/dev/null)
-
-LinkerSupportedArches = \
-  $(shell \
-result=""; \
-for arch in $1; do \
-  if $(LD) -v 2>&1 | grep "configured to support" | tr ' ' '\n' | grep 
"^$$arch$$" >/dev/null 2>/dev/null; then \
-result="$$result$$arch "; \
-  fi; \
-done; \
-echo $$result)
-
-
-RuntimeLibrary.macho_embedded.Configs := \
-   hard_static.a hard_pic.a
-ifneq (,$(findstring ARM,$(TARGETS_TO_BUILD)))
 
 ifneq ($(IOS_SDK)$(IOSSIM_SDK),)
 RuntimeLibrary.darwin.Configs += ios.a profile_ios.a
@@ -118,23 +99,9 @@ RuntimeLibrary.darwin.Configs += asan_io
  ubsan_iossim_dynamic.dylib
 endif
 
-
-ifneq ($(TVOS_SDK)$(TVOSSIM_SDK),)
-RuntimeLibrary.darwin.Configs += tvos.a profile_tvos.a
-endif
-
-ifneq ($(TVOS_SDK),)
-RuntimeLibrary.darwin.Configs += cc_kext_tvos.a
-endif
-
-ifneq ($(WATCHOS_SDK)$(WATCHOSSIM_SDK),)
-RuntimeLibrary.darwin.Configs += watchos.a profile_watchos.a
-endif
-
-ifneq ($(WATCHOS_SDK),)
-RuntimeLibrary.darwin.Configs += cc_kext_watchos.a
-endif
-
+RuntimeLibrary.macho_embedded.Configs := \
+   hard_static.a hard_pic.a
+ifneq (,$(findstring ARM,$(TARGETS_TO_BUILD)))
 RuntimeLibrary.macho_embedded.Configs += \
soft_static.a soft_pic.a
 endif


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


Re: [PATCH] D13446: [PATCH] Add checker discouraging definition of variadic function definitions in C++

2015-11-03 Thread Daniel Berlin via cfe-commits
Apologies, I will try to take a look today

On Tue, Nov 3, 2015, 10:05 AM Aaron Ballman  wrote:

> On Tue, Nov 3, 2015 at 7:19 AM, Alexander Kornienko 
> wrote:
> > On Fri, Oct 9, 2015 at 12:13 PM, Aaron Ballman 
> > wrote:
> >>
> >> On Fri, Oct 9, 2015 at 3:09 PM, Daniel Berlin 
> wrote:
> >> > dberlin added a subscriber: dberlin.
> >> >
> >> > 
> >> > Comment at: docs/clang-tidy/checks/cert-variadic-function-def.rst:13
> >> > @@ +12,2 @@
> >> > +`DCL50-CPP. Do not define a C-style variadic function
> >> >
> >> > +<
> https://www.securecoding.cert.org/confluence/display/cplusplus/DCL50-CPP.+Do+not+define+a+C-style+variadic+function
> >`_.
> >> > 
> >> > I'm sure this is oversight on CERT's part, but their website actually
> >> > has terms of use (click the terms of use at the bottom of the page)
> that
> >> > says this can't be copied/reused, and here you are, copying it.
> >> > It explicit says: "
> >> > Use of the Service. You may only display the content of the Service
> for
> >> > your own personal use (i.e., non-commercial use) and may not
> otherwise copy,
> >> > reproduce, alter, modify, create derivative works, or publicly
> display any
> >> > content. "
> >> >
> >> > Before this is accepted, someone should email cert and say "hey, uh,
> >> > yeah, this seems bad", and get them to okay you doing this.
> >> > I'm sure they'll go and fix this.
> >>
> >> That's an excellent point, I will bring it up internally (I work for
> >> CERT) and report back.
> >
> >
> > Any news here?
>
> Yes; I have heard back from CERT's legal team, and they have a
> document that I have sent (off-list) to Daniel for review. If it seems
> like it would resolve his concerns, then I think the next step will be
> to bring it to the LLVM foundation more formally to see how they would
> like to handle it.
>
> ~Aaron
>
> >
> >>
> >>
> >> ~Aaron
> >>
> >> >
> >> >
> >> >
> >> > http://reviews.llvm.org/D13446
> >> >
> >> >
> >> >
> >
> >
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13304: Avoid inlining in throw statement

2015-11-03 Thread Jun Bum Lim via cfe-commits
junbuml added a comment.

The basic idea of this change is to avoid inlining callsites invoked in 
exception handling regions (EHR) so that we can reduce code size blow-up in 
very cold regions and indirectly increase inline opportunities for functions 
containing exception handling code.

I think the best way to implement this is influencing to the inline heuristic 
by smoothly decreasing the threshold for the callsites in EHR. From this 
perspective, Attribute::Cold seems to be the right attribute to be added. 
However, the current ColdThreshold is still not tuned yet (r200898) and too 
high to conservatively perform inlining in EHR.

As a work-around, in my current implementation, both Cold and NoInline are 
added to the callsites. I understand that the NoInline is somewhat strong 
attribute to be added, but I don't think there is any negative impact on 
performance unless the execution logic really depends on exception handling 
flows, which is rare. The only downsides I can think of is the case where the 
callee is very small so that inlining it is profitable for size, but the impact 
must be minor.

If using NoInline is too strong to use, another work-around could be 
introducing a new attribute something like "ColdInEHR", and then we decrease 
the inline threshold for the callsites marked with this attribute.  
OptSizeThreshold(75)  could be considered to be a candidate for the default 
threshold.

Unless there is a strong objection about the basic idea, I want to move forward 
and close this issue as soon as possible. Please let me know any opinion.


http://reviews.llvm.org/D13304



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


[PATCH] D14292: [libcxx] Make it possible to build a no-exceptions variant of libcxx.

2015-11-03 Thread Asiri Rathnayake via cfe-commits
rmaprath created this revision.
rmaprath added reviewers: rengolin, mclow.lists.
rmaprath added a subscriber: cfe-commits.

Fixes a small omission in libcxx that prevents libcxx being built when 
-DLIBCXX_ENABLE_EXCEPTIONS=0 is used.

I will do a follow-up patch to introduce the new libc++ build to the buildbot.

http://reviews.llvm.org/D14292

Files:
  src/future.cpp

Index: src/future.cpp
===
--- src/future.cpp
+++ src/future.cpp
@@ -221,10 +221,12 @@
 {
 if (__state_)
 {
+#ifndef _LIBCPP_NO_EXCEPTIONS
 if (!__state_->__has_value() && __state_->use_count() > 1)
 __state_->set_exception(make_exception_ptr(
   
future_error(make_error_code(future_errc::broken_promise))
   ));
+#endif // _LIBCPP_NO_EXCEPTIONS
 __state_->__release_shared();
 }
 }


Index: src/future.cpp
===
--- src/future.cpp
+++ src/future.cpp
@@ -221,10 +221,12 @@
 {
 if (__state_)
 {
+#ifndef _LIBCPP_NO_EXCEPTIONS
 if (!__state_->__has_value() && __state_->use_count() > 1)
 __state_->set_exception(make_exception_ptr(
   future_error(make_error_code(future_errc::broken_promise))
   ));
+#endif // _LIBCPP_NO_EXCEPTIONS
 __state_->__release_shared();
 }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14180: enable -fms-extensions by default on the mingw-w64 target

2015-11-03 Thread Reid Kleckner via cfe-commits
rnk added a comment.

In http://reviews.llvm.org/D14180#279962, @martell wrote:

> In http://reviews.llvm.org/D14180#279651, @rnk wrote:
>
> > Will Clang be able to compile the last few stable mingw-w64 releases with 
> > this change? I'd like that to keep working.
>
>
> Clang has not been able to compile mingw-w64 crt for the last few releases.
>  I have only added support for this on HEAD.


Right, I'm not worried about that.

> There would be a drawback though.

>  Clang would not like older mingw-w64 headers.


This is what I'm worried about. :) Can you elaborate on what would break?


http://reviews.llvm.org/D14180



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


Re: [PATCH] D14180: enable -fms-extensions by default on the mingw-w64 target

2015-11-03 Thread Martell Malone via cfe-commits
martell added a comment.

In http://reviews.llvm.org/D14180#280184, @rnk wrote:

> You're mostly interested in the non-builtin parts of -fms-extensions, like 
> declspec and UUID, right?


Yes that would be one of the main reasons, gcc is very lacking in this 
department :)

> You can then change the mingw headers to use 
> `__has_builtin(_InterlockedCompareExchange)` to provide compatibility with 
> either mode.


Yes I could do this but this still won't work with the the existing mingw 
toolchains that don't have this in their headers right?
I can update head to support both though yes


http://reviews.llvm.org/D14180



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


Re: [PATCH] D14293: [libcxx] Add -fno-exceptions libcxx builders to zorg

2015-11-03 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

PS: I've run a couple of hand-crafted builders on a locally hacked up buildbot 
and made sure the above changes are fine.


http://reviews.llvm.org/D14293



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


Re: [PATCH] D14285: [x86] Additional small fix for MCU psABI support

2015-11-03 Thread Reid Kleckner via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


http://reviews.llvm.org/D14285



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


Re: [PATCH] D12031: Const std::move() argument ClangTidy check

2015-11-03 Thread Vadym Doroshenko via cfe-commits
dvadym added a comment.

Thanks alexfh and sbenza for comments!
I've addressed most of them. Could you please advice how to find that some 
expression has type which is template dependent?

Regards,
Vadym



Comment at: clang-tidy/misc/MoveConstantArgumentCheck.cpp:20
@@ +19,3 @@
+  const auto* CallMove = result.Nodes.getNodeAs("call-move");
+  if (CallMove->getNumArgs() != 1) return;
+  const Expr* Arg = CallMove->getArg(0);

sbenza wrote:
> You can move both checks to the matcher.
> Something like:
> 
> callExpr(callee(functionDecl(hasName("::std::move"))),
>  argumentCountIs(1),
>  hasArgument(0, expr(hasType(isConstQualified()
Thanks, according to alexfh comments I've decided to apply this check not only 
for const but also for trivially copyable types.


Comment at: clang-tidy/misc/MoveConstantArgumentCheck.cpp:31
@@ +30,3 @@
+std::string ArgString(sm->getCharacterData(ArgBegin), length);
+diag(CallMove->getLocStart(), "move of const variable")
+<< FixItHint::CreateReplacement(MoveRange, ArgString);

alexfh wrote:
> The message could be more helpful. For example, "std::move of the const 
> variable '%0' doesn't have effect". We could also add a recommendation on how 
> to fix that (e.g. "remove std::move() or make the variable non-const").
> 
> Also, in case it's not a variable (DeclRefExpr), the warning shouldn't say 
> "variable".
Thanks, I've addressed your comments.


Comment at: test/clang-tidy/move-const-arg.cpp:29
@@ +28,3 @@
+{
+  return std::move(42);
+}

alexfh wrote:
> That also doesn't look like a reasonable use of std::move. We should probably 
> extend this check to flag std::move applied to rvalues (in general, not only 
> usages of const variables), scalar types, pointer types and probably also all 
> other trivially-copyable types (I don't immediately see why moving those 
> could ever be better than copying). These warnings shouldn't trigger for 
> dependent types and in template instantiations.
Thanks, I've implemented for trivially copyable types. But I didn't find how to 
find dependent types: Arg->isTypeDependent(), Arg->isInstantiationDependent(), 
Arg->getType()->isDependentType() doesn't look like solving this problem. Could 
you please advice?


Comment at: test/clang-tidy/move-const-arg.cpp:41
@@ +40,3 @@
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: move of const variable 
[move-const-arg]
+  // CHECK-FIXES: return x;
+}

alexfh wrote:
> Please make the checked code lines unique to avoid matching in a wrong place. 
> FileCheck (the utility that is called by the check_clang_tidy.py script to 
> verify the `// CHECK-...` lines, 
> http://llvm.org/docs/CommandGuide/FileCheck.html) doesn't take the location 
> of the `// CHECK-FIXES:` line in the test file into consideration, it just 
> verifies that the fixed file has a subsequence of lines that matches all `// 
> CHECK-FIXES` lines in that order. Here, for example, `return x;` would 
> equally match, if the check would fix line 34 instead of line 39. We could 
> solve this by numbering lines so that CHECK-FIXES patterns could refer to the 
> line numbers, but until we do that (if we decide so), making the checked 
> lines unique is the way to go (e.g. by using different variable names in each 
> test case instead of just `x`).
Thanks, I've set different names to variables


http://reviews.llvm.org/D12031



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


r251966 - [analyzer] Move the ObjCGenericsChecker out of the alpha package.

2015-11-03 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Tue Nov  3 13:38:03 2015
New Revision: 251966

URL: http://llvm.org/viewvc/llvm-project?rev=251966=rev
Log:
[analyzer] Move the ObjCGenericsChecker out of the alpha package.

It is now in the osx.cocoa package and so will be on by default for Apple
toolchains.

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td
cfe/trunk/test/Analysis/DynamicTypePropagation.m
cfe/trunk/test/Analysis/generics.m

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td?rev=251966=251965=251966=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td Tue Nov  3 13:38:03 2015
@@ -457,6 +457,10 @@ def RetainCountChecker : Checker<"Retain
   HelpText<"Check for leaks and improper reference count management">,
   DescFile<"RetainCountChecker.cpp">;
 
+def ObjCGenericsChecker : Checker<"ObjCGenerics">,
+  HelpText<"Check for type errors when using Objective-C generics">,
+  DescFile<"DynamicTypePropagation.cpp">;
+
 } // end "osx.cocoa"
 
 let ParentPackage = CocoaAlpha in {
@@ -481,10 +485,6 @@ def DirectIvarAssignmentForAnnotatedFunc
   HelpText<"Check for direct assignments to instance variables in the methods 
annotated with objc_no_direct_instance_variable_assignment">,
   DescFile<"DirectIvarAssignment.cpp">;
 
-def ObjCGenericsChecker : Checker<"ObjCGenerics">,
-  HelpText<"Check for type errors when using Objective-C generics">,
-  DescFile<"DynamicTypePropagation.cpp">;
-
 def NonLocalizedStringChecker : Checker<"NonLocalizedStringChecker">,
   HelpText<"Warns about uses of non-localized NSStrings passed to UI methods 
expecting localized NSStrings">,
   DescFile<"LocalizationChecker.cpp">;

Modified: cfe/trunk/test/Analysis/DynamicTypePropagation.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/DynamicTypePropagation.m?rev=251966=251965=251966=diff
==
--- cfe/trunk/test/Analysis/DynamicTypePropagation.m (original)
+++ cfe/trunk/test/Analysis/DynamicTypePropagation.m Tue Nov  3 13:38:03 2015
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze 
-analyzer-checker=core,alpha.osx.cocoa.ObjCGenerics -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.ObjCGenerics 
-verify %s
 
 #if !__has_feature(objc_generics)
 #  error Compiler does not support Objective-C generics?

Modified: cfe/trunk/test/Analysis/generics.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/generics.m?rev=251966=251965=251966=diff
==
--- cfe/trunk/test/Analysis/generics.m (original)
+++ cfe/trunk/test/Analysis/generics.m Tue Nov  3 13:38:03 2015
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -analyze 
-analyzer-checker=core,alpha.osx.cocoa.ObjCGenerics,alpha.core.DynamicTypeChecker
 -verify -Wno-objc-method-access %s
-// RUN: %clang_cc1 -analyze 
-analyzer-checker=core,alpha.osx.cocoa.ObjCGenerics,alpha.core.DynamicTypeChecker
 -verify -Wno-objc-method-access %s -analyzer-output=plist -o %t.plist
+// RUN: %clang_cc1 -analyze 
-analyzer-checker=core,osx.cocoa.ObjCGenerics,alpha.core.DynamicTypeChecker 
-verify -Wno-objc-method-access %s
+// RUN: %clang_cc1 -analyze 
-analyzer-checker=core,osx.cocoa.ObjCGenerics,alpha.core.DynamicTypeChecker 
-verify -Wno-objc-method-access %s -analyzer-output=plist -o %t.plist
 // RUN: FileCheck --input-file %t.plist %s
 
 #if !__has_feature(objc_generics)


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


Re: [PATCH] D12031: Const std::move() argument ClangTidy check

2015-11-03 Thread Vadym Doroshenko via cfe-commits
dvadym updated the summary for this revision.
dvadym updated this revision to Diff 39077.
dvadym marked 6 inline comments as done.
dvadym added a comment.

1.Most comments addressed
2.Taking into consideration applying move to trivially copyable objects
3.Different message if move argument variable or expression.

It's not addressed yet case when move argument is depend in some way on 
template argument. There is comment in code about this.


http://reviews.llvm.org/D12031

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/MoveConstantArgumentCheck.cpp
  clang-tidy/misc/MoveConstantArgumentCheck.h
  test/clang-tidy/move-const-arg.cpp

Index: test/clang-tidy/move-const-arg.cpp
===
--- test/clang-tidy/move-const-arg.cpp
+++ test/clang-tidy/move-const-arg.cpp
@@ -0,0 +1,72 @@
+// RUN: $(dirname %s)/check_clang_tidy.sh %s misc-move-const-arg %t
+// REQUIRES: shell
+
+namespace std {
+// Directly copied from the stl.
+template
+struct remove_reference;
+
+template
+  struct remove_reference
+  { typedef _Tp   type; };
+
+template
+  struct remove_reference<_Tp&>
+  { typedef _Tp   type; };
+
+template
+  struct remove_reference<_Tp&&>
+  { typedef _Tp   type; };
+
+template
+  constexpr typename std::remove_reference<_Tp>::type&&
+  move(_Tp&& __t);
+
+}  // namespace std
+
+class A
+{
+ public:
+  A() {}
+  A(const A& rhs) {}
+  A(A&& rhs) {}
+};
+
+int f1()
+{
+  return std::move(42);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: std::move of the expression of trivially-copyable type doesn't have effect. Remove std::move().
+  // CHECK-FIXES: return 42;
+}
+
+int f2(int x2)
+{
+  return std::move(x2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: std::move of the variable of trivially-copyable type doesn't have effect. Remove std::move().
+  // CHECK-FIXES: return x2;
+}
+
+int* f3(int* x3)
+{
+  return std::move(x3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: std::move of the expression of trivially-copyable type doesn't have effect. Remove std::move().
+  // CHECK-FIXES: return x3;
+}
+
+A f4(A x4)
+{
+  return std::move(x4);
+}
+
+A f5(const A x5)
+{
+  return std::move(x5);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: std::move of the const variable doesn't have effect. Remove std::move() or make the variable non-const.
+  // CHECK-FIXES: return x5;
+}
+
+template
+T f6(const T a)
+{
+  return std::move(a);
+}
Index: clang-tidy/misc/MoveConstantArgumentCheck.h
===
--- clang-tidy/misc/MoveConstantArgumentCheck.h
+++ clang-tidy/misc/MoveConstantArgumentCheck.h
@@ -0,0 +1,17 @@
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+class MoveConstantArgumentCheck : public ClangTidyCheck {
+public:
+  MoveConstantArgumentCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult ) override;
+};
+
+} // namespace misc
+} // namespace tidy
+} // namespace clang
Index: clang-tidy/misc/MoveConstantArgumentCheck.cpp
===
--- clang-tidy/misc/MoveConstantArgumentCheck.cpp
+++ clang-tidy/misc/MoveConstantArgumentCheck.cpp
@@ -0,0 +1,51 @@
+#include "MoveConstantArgumentCheck.h"
+
+#include 
+using namespace std;
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+using namespace ast_matchers;
+
+void MoveConstantArgumentCheck::registerMatchers(MatchFinder* Finder) {
+  Finder->addMatcher(
+  callExpr(callee(functionDecl(hasName("::std::move".bind("call-move"),
+  this);
+}
+
+void MoveConstantArgumentCheck::check(const MatchFinder::MatchResult& Result) {
+  const auto* CallMove = Result.Nodes.getNodeAs("call-move");
+  if (CallMove->getNumArgs() != 1) return;
+  const Expr* Arg = CallMove->getArg(0);
+  auto* Context = Result.Context;
+
+  bool IsTypeDependOnTemplateParameter =
+  false;  // my first guess was type->getTypeClass () == 30 but it doesn't
+  // work in some cases. Could you please advice better solution.
+  if (IsTypeDependOnTemplateParameter) return;
+  bool IsConstArg = Arg->getType().isConstQualified();
+  bool IsTriviallyCopyable = Arg->getType().isTriviallyCopyableType(*Context);
+
+  if (IsConstArg || IsTriviallyCopyable) {
+bool IsVariable = (dyn_cast(Arg) != nullptr);
+string message = "std::move of the ";
+message += IsConstArg ? "const " : "";
+message += IsVariable ? "variable " : "expression ";
+message += IsTriviallyCopyable ? "of trivially-copyable type " : "";
+message += "doesn't have effect. ";
+message += "Remove std::move()";
+message += IsConstArg && IsVariable ? " or make the variable non-const." : ".";
+
+SourceRange RemoveRange1(CallMove->getLocStart(), Arg->getLocStart());
+  

Re: [PATCH] D13446: [PATCH] Add checker discouraging definition of variadic function definitions in C++

2015-11-03 Thread Aaron Ballman via cfe-commits
On Tue, Nov 3, 2015 at 7:19 AM, Alexander Kornienko  wrote:
> On Fri, Oct 9, 2015 at 12:13 PM, Aaron Ballman 
> wrote:
>>
>> On Fri, Oct 9, 2015 at 3:09 PM, Daniel Berlin  wrote:
>> > dberlin added a subscriber: dberlin.
>> >
>> > 
>> > Comment at: docs/clang-tidy/checks/cert-variadic-function-def.rst:13
>> > @@ +12,2 @@
>> > +`DCL50-CPP. Do not define a C-style variadic function
>> >
>> > +`_.
>> > 
>> > I'm sure this is oversight on CERT's part, but their website actually
>> > has terms of use (click the terms of use at the bottom of the page) that
>> > says this can't be copied/reused, and here you are, copying it.
>> > It explicit says: "
>> > Use of the Service. You may only display the content of the Service for
>> > your own personal use (i.e., non-commercial use) and may not otherwise 
>> > copy,
>> > reproduce, alter, modify, create derivative works, or publicly display any
>> > content. "
>> >
>> > Before this is accepted, someone should email cert and say "hey, uh,
>> > yeah, this seems bad", and get them to okay you doing this.
>> > I'm sure they'll go and fix this.
>>
>> That's an excellent point, I will bring it up internally (I work for
>> CERT) and report back.
>
>
> Any news here?

Yes; I have heard back from CERT's legal team, and they have a
document that I have sent (off-list) to Daniel for review. If it seems
like it would resolve his concerns, then I think the next step will be
to bring it to the LLVM foundation more formally to see how they would
like to handle it.

~Aaron

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


[PATCH] D14293: [libcxx] Add -fno-exceptions libcxx builders to zorg

2015-11-03 Thread Asiri Rathnayake via cfe-commits
rmaprath created this revision.
rmaprath added reviewers: rengolin, gribozavr, gkistanova, EricWF.
rmaprath added a subscriber: cfe-commits.

This patch adds the necessary builders to zorg to get the -fno-exceptions 
libcxx library variant building. I've only used those build-slaves which I have 
got explicit permission to use for this purpose.

As discussed on the cfe-dev list, these builders won't run the libcxx test 
suite (they will, in the near future, when we adapt the tests).

These builders will ensure that we don't break the -fno-exceptions library 
build. This patch can only go in once D14292 is sorted.

http://reviews.llvm.org/D14293

Files:
  buildbot/osuosl/master/config/builders.py
  zorg/buildbot/builders/LibcxxAndAbiBuilder.py

Index: zorg/buildbot/builders/LibcxxAndAbiBuilder.py
===
--- zorg/buildbot/builders/LibcxxAndAbiBuilder.py
+++ zorg/buildbot/builders/LibcxxAndAbiBuilder.py
@@ -128,6 +128,10 @@
 descriptionDone = ['test', 'libcxxabi'],
 workdir = build_path))
 
+# Skip libcxx tests if requested
+if 'no-libcxx-tests' in additional_features:
+return f
+
 # Test libc++
 f.addStep(LitTestCommand(
 name= 'test.libcxx',
Index: buildbot/osuosl/master/config/builders.py
===
--- buildbot/osuosl/master/config/builders.py
+++ buildbot/osuosl/master/config/builders.py
@@ -740,6 +759,18 @@
  env={'CC': 'clang', 'CXX': 'clang++'}),
  'category': 'libcxx'},
 
+# x86_64 -fno-exceptions libcxx build (skips libcxx tests)
+{'name': 'libcxx-libcxxabi-x86_64-linux-debian-noexceptions',
+ 'slavenames': ['gribozavr4'],
+ 'builddir': 'libcxx-libcxxabi-x86_64-linux-debian-noexceptions',
+ 'factory': LibcxxAndAbiBuilder.getLibcxxAndAbiBuilder(
+ env={'CC': 'clang', 'CXX': 'clang++'},
+ cmake_extra_opts={'LIBCXX_ENABLE_EXCEPTIONS': 'OFF'},
+ # TODO: Remove this once the libcxx tests are updated to pass on
+ # the -fno-exceptions library build.
+ additional_features={'no-libcxx-tests'}),
+ 'category': 'libcxx'},
+
 {'name': 'libcxx-libcxxabi-singlethreaded-x86_64-linux-debian',
  'slavenames': ['gribozavr4'],
  'builddir': 'libcxx-libcxxabi-singlethreaded-x86_64-linux-debian',
@@ -840,6 +871,24 @@
 cmake_extra_opts={'LIBCXXABI_USE_LLVM_UNWINDER': 'True',
   'CMAKE_C_FLAGS': '-mcpu=cortex-a15',
   'CMAKE_CXX_FLAGS': '-mcpu=cortex-a15'})},
+
+# Cortex-A15 -fno-exceptions libcxx build (skips libcxx tests)
+{'name': 'libcxx-libcxxabi-arm-linux-noexceptions',
+ 'slavenames': ['linaro-chrome-01'],
+ 'builddir': 'libcxx-libcxxabi-arm-linux-noexceptions',
+ 'category': 'libcxx',
+ 'factory': LibcxxAndAbiBuilder.getLibcxxAndAbiBuilder(
+env={'CC': 'clang', 'CXX': 'clang++'},
+# FIXME: there should be a way to merge autodetected with 
user-defined linker flags
+# See: libcxxabi/test/lit.cfg
+lit_extra_opts={'link_flags': '"-lc++abi -lc -lm -lpthread 
-lunwind -ldl -L/opt/llvm/lib/clang/3.6.0/lib/linux -lclang_rt.builtins-arm"'},
+cmake_extra_opts={'LIBCXXABI_USE_LLVM_UNWINDER': 'True',
+  'CMAKE_C_FLAGS': '-mcpu=cortex-a15',
+  'CMAKE_CXX_FLAGS': '-mcpu=cortex-a15',
+  'LIBCXX_ENABLE_EXCEPTIONS': 'OFF'},
+# TODO: Remove this once the libcxx tests are updated to pass on
+# the -fno-exceptions library build.
+additional_features={'no-libcxx-tests'})},
 ]
 
 # Experimental and stopped builders


Index: zorg/buildbot/builders/LibcxxAndAbiBuilder.py
===
--- zorg/buildbot/builders/LibcxxAndAbiBuilder.py
+++ zorg/buildbot/builders/LibcxxAndAbiBuilder.py
@@ -128,6 +128,10 @@
 descriptionDone = ['test', 'libcxxabi'],
 workdir = build_path))
 
+# Skip libcxx tests if requested
+if 'no-libcxx-tests' in additional_features:
+return f
+
 # Test libc++
 f.addStep(LitTestCommand(
 name= 'test.libcxx',
Index: buildbot/osuosl/master/config/builders.py
===
--- buildbot/osuosl/master/config/builders.py
+++ buildbot/osuosl/master/config/builders.py
@@ -740,6 +759,18 @@
  env={'CC': 'clang', 'CXX': 'clang++'}),
  'category': 'libcxx'},
 
+# x86_64 -fno-exceptions libcxx build (skips libcxx tests)
+{'name': 'libcxx-libcxxabi-x86_64-linux-debian-noexceptions',
+ 'slavenames': ['gribozavr4'],
+ 'builddir': 'libcxx-libcxxabi-x86_64-linux-debian-noexceptions',
+ 

Re: [PATCH] D14291: Improve modernize-make-unique matcher.

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

lg


http://reviews.llvm.org/D14291



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


[PATCH] D14291: Improve modernize-make-unique matcher.

2015-11-03 Thread Angel Garcia via cfe-commits
angelgarcia created this revision.
angelgarcia added a reviewer: klimek.
angelgarcia added subscribers: cfe-commits, alexfh.

"std::unique_ptr" is not the same type as "std::unique_ptr", unless we insert a "hasCanonicalType" in the 
middle. Probably it also happens in other cases related to default template 
argument.

http://reviews.llvm.org/D14291

Files:
  clang-tidy/modernize/MakeUniqueCheck.cpp
  test/clang-tidy/modernize-make-unique.cpp

Index: test/clang-tidy/modernize-make-unique.cpp
===
--- test/clang-tidy/modernize-make-unique.cpp
+++ test/clang-tidy/modernize-make-unique.cpp
@@ -195,3 +195,9 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: use std::make_unique instead
   // CHECK-FIXES: auto Spaces = std::make_unique();
 }
+
+void nesting() {
+  auto Nest = std::unique_ptr(new 
std::unique_ptr(new int));
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: use std::make_unique instead
+  // CHECK-FIXES: auto Nest = std::make_unique(new int);
+}
Index: clang-tidy/modernize/MakeUniqueCheck.cpp
===
--- clang-tidy/modernize/MakeUniqueCheck.cpp
+++ clang-tidy/modernize/MakeUniqueCheck.cpp
@@ -42,9 +42,10 @@
   qualType(equalsBoundNode(
   PointerType))),
 argumentCountIs(1),
-hasArgument(0, cxxNewExpr(hasType(pointsTo(qualType(
-  equalsBoundNode(PointerType)
-   .bind(NewExpression)))
+hasArgument(
+0, cxxNewExpr(hasType(pointsTo(qualType(hasCanonicalType(
+  equalsBoundNode(PointerType))
+   .bind(NewExpression)))
 .bind(ConstructorCall))),
 this);
   }


Index: test/clang-tidy/modernize-make-unique.cpp
===
--- test/clang-tidy/modernize-make-unique.cpp
+++ test/clang-tidy/modernize-make-unique.cpp
@@ -195,3 +195,9 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: use std::make_unique instead
   // CHECK-FIXES: auto Spaces = std::make_unique();
 }
+
+void nesting() {
+  auto Nest = std::unique_ptr(new std::unique_ptr(new int));
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: use std::make_unique instead
+  // CHECK-FIXES: auto Nest = std::make_unique(new int);
+}
Index: clang-tidy/modernize/MakeUniqueCheck.cpp
===
--- clang-tidy/modernize/MakeUniqueCheck.cpp
+++ clang-tidy/modernize/MakeUniqueCheck.cpp
@@ -42,9 +42,10 @@
   qualType(equalsBoundNode(
   PointerType))),
 argumentCountIs(1),
-hasArgument(0, cxxNewExpr(hasType(pointsTo(qualType(
-  equalsBoundNode(PointerType)
-   .bind(NewExpression)))
+hasArgument(
+0, cxxNewExpr(hasType(pointsTo(qualType(hasCanonicalType(
+  equalsBoundNode(PointerType))
+   .bind(NewExpression)))
 .bind(ConstructorCall))),
 this);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14180: enable -fms-extensions by default on the mingw-w64 target

2015-11-03 Thread Reid Kleckner via cfe-commits
rnk added a comment.

I'd like clang to work out of the box with mingw-w64 releases from at least the 
past year. You're mostly interested in the non-builtin parts of 
-fms-extensions, like declspec and UUID, right? One way we could do this is to 
enable -fms-extensions in mingw but then suppress the builtins in that 
environment, or have some other flag to enable them.

You can then change the mingw headers to use 
`__has_builtin(_InterlockedCompareExchange)` to provide compatibility with 
either mode.


http://reviews.llvm.org/D14180



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


Re: [PATCH] D12031: Const std::move() argument ClangTidy check

2015-11-03 Thread Vadym Doroshenko via cfe-commits
dvadym updated this revision to Diff 39080.
dvadym marked an inline comment as done.
dvadym added a comment.

Small clean-up


http://reviews.llvm.org/D12031

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/MoveConstantArgumentCheck.cpp
  clang-tidy/misc/MoveConstantArgumentCheck.h
  test/clang-tidy/move-const-arg.cpp

Index: test/clang-tidy/move-const-arg.cpp
===
--- test/clang-tidy/move-const-arg.cpp
+++ test/clang-tidy/move-const-arg.cpp
@@ -0,0 +1,71 @@
+// RUN: $(dirname %s)/check_clang_tidy.sh %s misc-move-const-arg %t
+
+namespace std {
+// Directly copied from the stl.
+template
+struct remove_reference;
+
+template
+  struct remove_reference
+  { typedef _Tp   type; };
+
+template
+  struct remove_reference<_Tp&>
+  { typedef _Tp   type; };
+
+template
+  struct remove_reference<_Tp&&>
+  { typedef _Tp   type; };
+
+template
+  constexpr typename std::remove_reference<_Tp>::type&&
+  move(_Tp&& __t);
+
+}  // namespace std
+
+class A
+{
+ public:
+  A() {}
+  A(const A& rhs) {}
+  A(A&& rhs) {}
+};
+
+int f1()
+{
+  return std::move(42);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: std::move of the expression of trivially-copyable type doesn't have effect. Remove std::move().
+  // CHECK-FIXES: return 42;
+}
+
+int f2(int x2)
+{
+  return std::move(x2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: std::move of the variable of trivially-copyable type doesn't have effect. Remove std::move().
+  // CHECK-FIXES: return x2;
+}
+
+int* f3(int* x3)
+{
+  return std::move(x3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: std::move of the expression of trivially-copyable type doesn't have effect. Remove std::move().
+  // CHECK-FIXES: return x3;
+}
+
+A f4(A x4)
+{
+  return std::move(x4);
+}
+
+A f5(const A x5)
+{
+  return std::move(x5);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: std::move of the const variable doesn't have effect. Remove std::move() or make the variable non-const.
+  // CHECK-FIXES: return x5;
+}
+
+template
+T f6(const T a)
+{
+  return std::move(a);
+}
Index: clang-tidy/misc/MoveConstantArgumentCheck.h
===
--- clang-tidy/misc/MoveConstantArgumentCheck.h
+++ clang-tidy/misc/MoveConstantArgumentCheck.h
@@ -0,0 +1,17 @@
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+class MoveConstantArgumentCheck : public ClangTidyCheck {
+public:
+  MoveConstantArgumentCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult ) override;
+};
+
+} // namespace misc
+} // namespace tidy
+} // namespace clang
Index: clang-tidy/misc/MoveConstantArgumentCheck.cpp
===
--- clang-tidy/misc/MoveConstantArgumentCheck.cpp
+++ clang-tidy/misc/MoveConstantArgumentCheck.cpp
@@ -0,0 +1,49 @@
+#include "MoveConstantArgumentCheck.h"
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+using namespace ast_matchers;
+
+void MoveConstantArgumentCheck::registerMatchers(MatchFinder* Finder) {
+  Finder->addMatcher(
+  callExpr(callee(functionDecl(hasName("::std::move".bind("call-move"),
+  this);
+}
+
+void MoveConstantArgumentCheck::check(const MatchFinder::MatchResult& Result) {
+  const auto* CallMove = Result.Nodes.getNodeAs("call-move");
+  if (CallMove->getNumArgs() != 1) return;
+  const Expr* Arg = CallMove->getArg(0);
+  auto* Context = Result.Context;
+
+  bool IsTypeDependOnTemplateParameter =
+  false;  // my first guess was type->getTypeClass () == 30 but it doesn't
+  // work in some cases. Could you please advice better solution.
+  if (IsTypeDependOnTemplateParameter) return;
+  bool IsConstArg = Arg->getType().isConstQualified();
+  bool IsTriviallyCopyable = Arg->getType().isTriviallyCopyableType(*Context);
+
+  if (IsConstArg || IsTriviallyCopyable) {
+bool IsVariable = dyn_cast(Arg) != nullptr;
+std::string message = "std::move of the ";
+message += IsConstArg ? "const " : "";
+message += IsVariable ? "variable " : "expression ";
+message += IsTriviallyCopyable ? "of trivially-copyable type " : "";
+message += "doesn't have effect. ";
+message += "Remove std::move()";
+message +=
+IsConstArg && IsVariable ? " or make the variable non-const." : ".";
+
+SourceRange RemoveRange1(CallMove->getLocStart(), Arg->getLocStart());
+SourceRange RemoveRange2(CallMove->getLocEnd(), CallMove->getLocEnd());
+diag(CallMove->getLocStart(), message)
+<< FixItHint::CreateRemoval(RemoveRange1)
+<< FixItHint::CreateRemoval(RemoveRange2);
+  }
+}
+
+}  // namespace misc
+}  // namespace tidy
+}  // namespace clang
Index: clang-tidy/misc/MiscTidyModule.cpp

Re: [PATCH] D14172: [libcxx] Make it possible to build a no-exceptions variant of libcxx.

2015-11-03 Thread Asiri Rathnayake via cfe-commits
rmaprath abandoned this revision.
rmaprath added a comment.

Abandoning revision as it seems I cannot add subscribers/reviewers to existing 
phab reviews.


http://reviews.llvm.org/D14172



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


Re: [PATCH] D14266: CodeGen: Update for debug info API change.Depends on D14265.

2015-11-03 Thread Duncan P. N. Exon Smith via cfe-commits
This LGTM (although obviously gated on LLVM changes).

> On 2015-Nov-02, at 16:28, Peter Collingbourne  wrote:
> 
> pcc created this revision.
> pcc added a reviewer: dexonsmith.
> pcc added a subscriber: cfe-commits.
> 
> http://reviews.llvm.org/D14266
> 
> Files:
>  lib/CodeGen/CGDebugInfo.cpp
>  test/CodeGen/debug-info-block-decl.c
>  test/CodeGenCXX/debug-info-static-fns.cpp
>  test/CodeGenCXX/debug-info-windows-dtor.cpp
>  test/CodeGenCXX/globalinit-loc.cpp
>  test/CodeGenCXX/linetable-virtual-variadic.cpp
>  test/CodeGenObjCXX/property-objects.mm
> 
> 

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


Re: [PATCH] D12031: Const std::move() argument ClangTidy check

2015-11-03 Thread Aaron Ballman via cfe-commits
aaron.ballman added a subscriber: aaron.ballman.


Comment at: clang-tidy/misc/MoveConstantArgumentCheck.cpp:1
@@ +1,2 @@
+#include "MoveConstantArgumentCheck.h"
+

Missing new file legal text.


Comment at: clang-tidy/misc/MoveConstantArgumentCheck.cpp:9
@@ +8,3 @@
+
+void MoveConstantArgumentCheck::registerMatchers(MatchFinder* Finder) {
+  Finder->addMatcher(

Formatting -- the * should go with Finder. May want to run clang-format over 
the entire patch; there's a lot of other formatting issues I will refrain from 
commenting on.


Comment at: clang-tidy/misc/MoveConstantArgumentCheck.cpp:10
@@ +9,3 @@
+void MoveConstantArgumentCheck::registerMatchers(MatchFinder* Finder) {
+  Finder->addMatcher(
+  callExpr(callee(functionDecl(hasName("::std::move".bind("call-move"),

Please only register this matcher for C++ code.


Comment at: clang-tidy/misc/MoveConstantArgumentCheck.cpp:22
@@ +21,3 @@
+  bool IsTypeDependOnTemplateParameter =
+  false;  // my first guess was type->getTypeClass () == 30 but it doesn't
+  // work in some cases. Could you please advice better solution.

Arg->getType()->isDependentType() should do what you want, if I understand you 
properly.


Comment at: clang-tidy/misc/MoveConstantArgumentCheck.cpp:29
@@ +28,3 @@
+  if (IsConstArg || IsTriviallyCopyable) {
+bool IsVariable = dyn_cast(Arg) != nullptr;
+std::string message = "std::move of the ";

isa instead of dyn_cast and check against nullptr.


Comment at: clang-tidy/misc/MoveConstantArgumentCheck.cpp:34
@@ +33,3 @@
+message += IsTriviallyCopyable ? "of trivially-copyable type " : "";
+message += "doesn't have effect. ";
+message += "Remove std::move()";

This line reads a bit strangely to me. Perhaps "has no effect" instead? Also, 
our diagnostics are not full sentences, so you should remove the period, and 
instead do: "; remove std::move()"


Comment at: clang-tidy/misc/MoveConstantArgumentCheck.h:1
@@ +1,2 @@
+#include "../ClangTidy.h"
+

Missing header include guards and header legal text.


http://reviews.llvm.org/D12031



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


r251955 - Introduce module file extensions to piggy-back data onto module files.

2015-11-03 Thread Douglas Gregor via cfe-commits
Author: dgregor
Date: Tue Nov  3 12:33:07 2015
New Revision: 251955

URL: http://llvm.org/viewvc/llvm-project?rev=251955=rev
Log:
Introduce module file extensions to piggy-back data onto module files.

Introduce the notion of a module file extension, which introduces
additional information into a module file at the time it is built that
can then be queried when the module file is read. Module file
extensions are identified by a block name (which must be unique to the
extension) and can write any bitstream records into their own
extension block within the module file. When a module file is loaded,
any extension blocks are matched up with module file extension
readers, that are per-module-file and are given access to the input
bitstream.

Note that module file extensions can only be introduced by
programmatic clients that have access to the CompilerInvocation. There
is only one such extension at the moment, which is used for testing
the module file extension harness. As a future direction, one could
imagine allowing the plugin mechanism to introduce new module file
extensions.

Added:
cfe/trunk/include/clang/Serialization/ModuleFileExtension.h
cfe/trunk/lib/Frontend/TestModuleFileExtension.cpp
cfe/trunk/lib/Frontend/TestModuleFileExtension.h
cfe/trunk/lib/Serialization/ModuleFileExtension.cpp
cfe/trunk/test/Modules/Inputs/ExtensionTestA.h
cfe/trunk/test/Modules/extensions.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Frontend/CompilerInstance.h
cfe/trunk/include/clang/Frontend/FrontendOptions.h
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/include/clang/Serialization/ASTWriter.h
cfe/trunk/include/clang/Serialization/Module.h
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/lib/Frontend/CMakeLists.txt
cfe/trunk/lib/Frontend/ChainedIncludesSource.cpp
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/FrontendActions.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/lib/Serialization/CMakeLists.txt
cfe/trunk/lib/Serialization/GeneratePCH.cpp
cfe/trunk/test/Modules/Inputs/module.map

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=251955=251954=251955=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Tue Nov  3 12:33:07 
2015
@@ -193,6 +193,10 @@ def err_drv_modules_validate_once_requir
   "option '-fmodules-validate-once-per-build-session' requires "
   "'-fbuild-session-timestamp=' or 
'-fbuild-session-file='">;
 
+def err_test_module_file_extension_format : Error<
+  "-ftest-module-file-extension argument '%0' is not of the required form "
+  "'blockname:major:minor:hashed:user info'">;
+
 def warn_drv_invoking_fallback : Warning<"falling back to %0">,
   InGroup;
 

Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=251955=251954=251955=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Tue Nov  3 
12:33:07 2015
@@ -204,6 +204,10 @@ def err_modules_embed_file_not_found :
   Error<"file '%0' specified by '-fmodules-embed-file=' not found">,
   DefaultFatal;
 
+def err_test_module_file_extension_version : Error<
+  "test module file extension '%0' has different version (%1.%2) than expected 
"
+  "(%3.%4)">;
+
 def err_conflicting_module_names : Error<
   "conflicting module names specified: '-fmodule-name=%0' and "
   "'-fmodule-implementation-of %1'">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=251955=251954=251955=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Tue Nov  3 12:33:07 2015
@@ -253,6 +253,7 @@ def MismatchedTags : DiagGroup<"mismatch
 def MissingFieldInitializers : DiagGroup<"missing-field-initializers">;
 def ModuleBuild : DiagGroup<"module-build">;
 def ModuleConflict : DiagGroup<"module-conflict">;
+def ModuleFileExtension : 

Re: [PATCH] D14293: [libcxx] Add -fno-exceptions libcxx builders to zorg

2015-11-03 Thread Dmitri Gribenko via cfe-commits
gribozavr added a comment.

The Debian configuration LGTM.


http://reviews.llvm.org/D14293



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


Re: [PATCH] D13304: Avoid inlining in throw statement

2015-11-03 Thread Richard Smith via cfe-commits
rsmith added a comment.

I am not convinced that it's reasonable to put inlining heuristics into clang's 
IR generation. This will cause maintenance problems for the inliner in the 
future (anyone tuning the inlining heuristics and thresholds will need to be 
aware of this, and clang will behave differently from other frontends in this 
regard).

I don't really see a need for clang's IR to change in order to support the 
inliner in this regard -- the inliner can already determine that a call to a 
`noreturn` function can only exit via unwinding, and can already determine 
which code is only reachable via landingpads. That seems like enough 
information for all the cases you're addressing here. (If I remember correctly, 
we already have a heuristic that treats calls followed by `unreachable` as 
being cold; perhaps we could extend that to also look for invokes that branch 
to `unreachable`, if it doesn't already handle that case.) If we handle this at 
that level, we'll also handle cases such as a user-defined function whose 
purpose is to throw an exception, and we'll treat the code leading to the throw 
the same regardless of whether it's within the operand of the 
//throw-expression//.

`noinline` seems like too strong of a constraint for this case. There are calls 
that we really want to inline, even if they occur in cold regions (because 
doing so will reduce code size), and calls that we must inline for correctness 
(calls to `always_inline` functions). If the `cold` attribute isn't working 
properly, that's an inliner bug and should be fixed in the inliner, not worked 
around here.

If you want to change the inlining heuristics to make a different choice here, 
it seems to me that you should make that change in the inliner.


http://reviews.llvm.org/D13304



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


Re: [PATCH] D14164: Driver: fallback to parent directory of clang if no sysroot for mingw-w64 target

2015-11-03 Thread Yaron Keren via cfe-commits
yaron.keren added a subscriber: cfe-commits.
yaron.keren added a comment.

We did  not have cfe-commits as subscriber so I'm adding it now (this is a 
clang commit), see if someone would like to further comment.


http://reviews.llvm.org/D14164



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


[PATCH] D14303: [analyzer] Add 'optin' checker package and move localizability checkers into it.

2015-11-03 Thread Devin Coughlin via cfe-commits
dcoughlin created this revision.
dcoughlin added reviewers: zaks.anna, krememek.
dcoughlin added a subscriber: cfe-commits.

This patch creates a new 'optin' top-level checker package and moves several of 
the localizability checkers into it. 

This package is for checkers that are not alpha and that would normally be on 
by default but where the driver does not have enough information to determine 
when they are applicable. The localizability checkers fit this criterion 
because the driver cannot determine whether a project is localized or not -- 
this is best determined at the IDE or build-system level.

This new package is *not* intended for checkers that are too noisy to be on by 
default.

The hierarchy under 'optin' mirrors that in 'alpha': checkers under 'optin' 
should be organized in the hierarchy they would have had if they were truly top 
level (e.g., optin.osx.cocoa.MyOptInChecker).

We are not attached to the name 'optin'. If you have ideas for a better name, 
we welcome suggestions.

http://reviews.llvm.org/D14303

Files:
  lib/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
  test/Analysis/localization-aggressive.m
  test/Analysis/localization.m

Index: test/Analysis/localization.m
===
--- test/Analysis/localization.m
+++ test/Analysis/localization.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -fblocks -analyzer-store=region -analyzer-checker=alpha.osx.cocoa.NonLocalizedStringChecker -analyzer-checker=alpha.osx.cocoa.PluralMisuseChecker -verify  %s
+// RUN: %clang_cc1 -analyze -fblocks -analyzer-store=region -analyzer-checker=optin.osx.cocoa.localizability.NonLocalizedStringChecker -analyzer-checker=alpha.osx.cocoa.localizability.PluralMisuseChecker -verify  %s
 
 // The larger set of tests in located in localization.m. These are tests
 // specific for non-aggressive reporting.
Index: test/Analysis/localization-aggressive.m
===
--- test/Analysis/localization-aggressive.m
+++ test/Analysis/localization-aggressive.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze -fblocks -analyzer-store=region  -analyzer-checker=alpha.osx.cocoa.NonLocalizedStringChecker -analyzer-checker=alpha.osx.cocoa.EmptyLocalizationContextChecker -verify  -analyzer-config AggressiveReport=true %s
+// RUN: %clang_cc1 -analyze -fblocks -analyzer-store=region  -analyzer-checker=optin.osx.cocoa.localizability.NonLocalizedStringChecker -analyzer-checker=optin.osx.cocoa.localizability.EmptyLocalizationContextChecker -verify  -analyzer-config AggressiveReport=true %s
 
 // These declarations were reduced using Delta-Debugging from Foundation.h
 // on Mac OS X.
Index: lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
+++ lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
@@ -1198,4 +1198,4 @@
 
 void ento::registerPluralMisuseChecker(CheckerManager ) {
   mgr.registerChecker();
-}
\ No newline at end of file
+}
Index: lib/StaticAnalyzer/Checkers/Checkers.td
===
--- lib/StaticAnalyzer/Checkers/Checkers.td
+++ lib/StaticAnalyzer/Checkers/Checkers.td
@@ -19,6 +19,9 @@
 def CoreBuiltin : Package<"builtin">, InPackage;
 def CoreUninitialized  : Package<"uninitialized">, InPackage;
 def CoreAlpha : Package<"core">, InPackage, Hidden;
+
+def OptIn : Package<"optin">;
+
 def Nullability : Package<"nullability">;
 
 def Cplusplus : Package<"cplusplus">;
@@ -39,11 +42,18 @@
 
 def OSX : Package<"osx">;
 def OSXAlpha : Package<"osx">, InPackage, Hidden;
+def OSXOptIn : Package<"osx">, InPackage;
+
 def Cocoa : Package<"cocoa">, InPackage;
 def CocoaAlpha : Package<"cocoa">, InPackage, Hidden;
+def CocoaOptIn : Package<"cocoa">, InPackage;
+
 def CoreFoundation : Package<"coreFoundation">, InPackage;
 def Containers : Package<"containers">, InPackage;
 
+def LocalizabilityAlpha : Package<"localizability">, InPackage;
+def LocalizabilityOptIn : Package<"localizability">, InPackage;
+
 def LLVM : Package<"llvm">;
 def Debug : Package<"debug">;
 
@@ -485,18 +495,6 @@
   HelpText<"Check for direct assignments to instance variables in the methods annotated with objc_no_direct_instance_variable_assignment">,
   DescFile<"DirectIvarAssignment.cpp">;
 
-def NonLocalizedStringChecker : Checker<"NonLocalizedStringChecker">,
-  HelpText<"Warns about uses of non-localized NSStrings passed to UI methods expecting localized NSStrings">,
-  DescFile<"LocalizationChecker.cpp">;
-
-def EmptyLocalizationContextChecker : Checker<"EmptyLocalizationContextChecker">,
-  HelpText<"Check that NSLocalizedString macros include a comment for context">,
-  DescFile<"LocalizationChecker.cpp">;
-
-def PluralMisuseChecker : Checker<"PluralMisuseChecker">,
-  HelpText<"Warns against using one vs. many plural pattern in 

Re: [PATCH] D14179: Remove some legacy mingw-w64 gcc struct info

2015-11-03 Thread NAKAMURA Takumi via cfe-commits
chapuni added a comment.

Sorry, I supposed someone removed it. It was really buggy in past.


Repository:
  rL LLVM

http://reviews.llvm.org/D14179



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


[PATCH] D14307: AMDGPU: Add support for 's' and 'v' asm constraints

2015-11-03 Thread Tom Stellard via cfe-commits
tstellarAMD created this revision.
tstellarAMD added reviewers: echristo, arsenm.
tstellarAMD added a subscriber: cfe-commits.

's' is used to specify sgprs and 'v' is used to specify vgprs.

http://reviews.llvm.org/D14307

Files:
  lib/Basic/Targets.cpp
  test/Sema/inline-asm-validate-amdgpu.cl

Index: test/Sema/inline-asm-validate-amdgpu.cl
===
--- /dev/null
+++ test/Sema/inline-asm-validate-amdgpu.cl
@@ -0,0 +1,14 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -x cl -triple amdgcn -fsyntax-only  %s
+// expected-no-diagnostics
+
+kernel void test () {
+
+  int sgpr = 0, vgpr = 0, imm = 0;
+
+  // sgpr constraints
+  __asm__ ("s_mov_b32 %0, %1" : "=s" (sgpr) : "s" (imm) : );
+
+  // vgpr constraints
+  __asm__ ("v_mov_b32 %0, %1" : "=v" (vgpr) : "v" (imm) : );
+}
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -1826,8 +1826,15 @@
   }
 
   bool validateAsmConstraint(const char *,
- TargetInfo::ConstraintInfo ) const override {
-return true;
+ TargetInfo::ConstraintInfo ) const override {
+switch (*Name) {
+default: break;
+case 'v': // vgpr
+case 's': // sgpr
+  Info.setAllowsRegister();
+  return true;
+}
+return false;
   }
 
   ArrayRef getTargetBuiltins() const override {


Index: test/Sema/inline-asm-validate-amdgpu.cl
===
--- /dev/null
+++ test/Sema/inline-asm-validate-amdgpu.cl
@@ -0,0 +1,14 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -x cl -triple amdgcn -fsyntax-only  %s
+// expected-no-diagnostics
+
+kernel void test () {
+
+  int sgpr = 0, vgpr = 0, imm = 0;
+
+  // sgpr constraints
+  __asm__ ("s_mov_b32 %0, %1" : "=s" (sgpr) : "s" (imm) : );
+
+  // vgpr constraints
+  __asm__ ("v_mov_b32 %0, %1" : "=v" (vgpr) : "v" (imm) : );
+}
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -1826,8 +1826,15 @@
   }
 
   bool validateAsmConstraint(const char *,
- TargetInfo::ConstraintInfo ) const override {
-return true;
+ TargetInfo::ConstraintInfo ) const override {
+switch (*Name) {
+default: break;
+case 'v': // vgpr
+case 's': // sgpr
+  Info.setAllowsRegister();
+  return true;
+}
+return false;
   }
 
   ArrayRef getTargetBuiltins() const override {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13099: [Analyzer] Don’t invalidate CXXThis when conservatively evaluating const methods (PR 21606)

2015-11-03 Thread Devin Coughlin via cfe-commits
dcoughlin added a comment.

This patch seems to have caused a regression. 
https://llvm.org/bugs/show_bug.cgi?id=25392


Repository:
  rL LLVM

http://reviews.llvm.org/D13099



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


Re: [PATCH] D14184: [clang] Add initial support for -meabi flag

2015-11-03 Thread Vinicius Tinti via cfe-commits
tinti set the repository for this revision to rL LLVM.
tinti updated this revision to Diff 39108.
tinti added a comment.

- Clang format code.
- Update eabi names to match new LLVM patch.


Repository:
  rL LLVM

http://reviews.llvm.org/D14184

Files:
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.h
  lib/CodeGen/BackendUtil.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/arm-eabi.c
  test/Driver/eabi.c

Index: test/Driver/eabi.c
===
--- /dev/null
+++ test/Driver/eabi.c
@@ -0,0 +1,15 @@
+// RUN: %clang %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-DEFAULT %s
+// RUN: %clang %s -meabi default -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-DEFAULT %s
+// RUN: %clang %s -meabi 4 -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-EABI4 %s
+// RUN: %clang %s -meabi 5 -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-EABI5 %s
+// RUN: %clang %s -meabi gnu -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-GNUEABI %s
+
+// CHECK-DEFAULT: "-meabi" "default"
+// CHECK-EABI4: "-meabi" "4"
+// CHECK-EABI5: "-meabi" "5"
+// CHECK-GNUEABI: "-meabi" "gnu"
Index: test/CodeGen/arm-eabi.c
===
--- /dev/null
+++ test/CodeGen/arm-eabi.c
@@ -0,0 +1,20 @@
+// REQUIRES: arm-registered-target
+// RUN: %clang -target arm-none-eabi -S -o - %s | FileCheck -check-prefix=CHECK-EABI %s
+// RUN: %clang -target arm-none-eabi -S -meabi gnu -o - %s | FileCheck -check-prefix=CHECK-GNUEABI %s
+// RUN: %clang -target arm-none-eabihf -S -o - %s | FileCheck -check-prefix=CHECK-EABI %s
+// RUN: %clang -target arm-none-eabihf -S -meabi gnu -o - %s | FileCheck -check-prefix=CHECK-GNUEABI %s
+// RUN: %clang -target arm-none-gnueabi -S -o - %s | FileCheck -check-prefix=CHECK-GNUEABI %s
+// RUN: %clang -target arm-none-gnueabi -S -meabi 5 -o - %s | FileCheck -check-prefix=CHECK-EABI %s
+// RUN: %clang -target arm-none-gnueabihf -S -o - %s | FileCheck -check-prefix=CHECK-GNUEABI %s
+// RUN: %clang -target arm-none-gnueabihf -S -meabi 5 -o - %s | FileCheck -check-prefix=CHECK-EABI %s
+
+struct my_s {
+  unsigned long a[18];
+};
+
+// CHECK-LABEL: foo
+// CHECK-EABI: bl __aeabi_memcpy4
+// CHECK-GNUEABI: bl memcpy
+void foo(unsigned long *t) {
+  *(struct my_s *)t = *((struct my_s *)(1UL));
+}
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -454,6 +454,20 @@
   Opts.DisableFree = Args.hasArg(OPT_disable_free);
   Opts.DisableTailCalls = Args.hasArg(OPT_mdisable_tail_calls);
   Opts.FloatABI = Args.getLastArgValue(OPT_mfloat_abi);
+  if (Arg *A = Args.getLastArg(OPT_meabi)) {
+StringRef Value = A->getValue();
+bool Valid = llvm::StringSwitch(Value)
+ .Case("default", true)
+ .Case("4", true)
+ .Case("5", true)
+ .Case("gnu", true)
+ .Default(false);
+if (!Valid)
+  Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args)
+<< Value;
+else
+  Opts.EABIVersion = Value;
+  }
   Opts.LessPreciseFPMAD = Args.hasArg(OPT_cl_mad_enable);
   Opts.LimitFloatPrecision = Args.getLastArgValue(OPT_mlimit_float_precision);
   Opts.NoInfsFPMath = (Args.hasArg(OPT_menable_no_infinities) ||
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -3412,6 +3412,12 @@
 }
   }
 
+  CmdArgs.push_back("-meabi");
+  if (Arg *A = Args.getLastArg(options::OPT_meabi))
+CmdArgs.push_back(A->getValue());
+  else
+CmdArgs.push_back("default");
+
   CmdArgs.push_back("-mthread-model");
   if (Arg *A = Args.getLastArg(options::OPT_mthread_model))
 CmdArgs.push_back(A->getValue());
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -515,6 +515,15 @@
   Options.UseInitArray = CodeGenOpts.UseInitArray;
   Options.DisableIntegratedAS = CodeGenOpts.DisableIntegratedAS;
   Options.CompressDebugSections = CodeGenOpts.CompressDebugSections;
+
+  // Set EABI version.
+  Options.EABIVersion =
+  llvm::StringSwitch(CodeGenOpts.EABIVersion)
+  .Case("4", llvm::EABI::EABI4)
+  .Case("5", llvm::EABI::EABI5)
+  .Case("gnu", llvm::EABI::GNU)
+  .Default(llvm::EABI::Default);
+
   Options.LessPreciseFPMADOption = CodeGenOpts.LessPreciseFPMAD;
   Options.NoInfsFPMath = CodeGenOpts.NoInfsFPMath;
   Options.NoNaNsFPMath = CodeGenOpts.NoNaNsFPMath;
Index: include/clang/Frontend/CodeGenOptions.h
===
--- 

Re: [PATCH] D14293: [libcxx] Add -fno-exceptions libcxx builders to zorg

2015-11-03 Thread Jonathan Roelofs via cfe-commits
jroelofs added a subscriber: jroelofs.


Comment at: buildbot/osuosl/master/config/builders.py:771
@@ +770,3 @@
+ # the -fno-exceptions library build.
+ additional_features={'no-libcxx-tests'}),
+ 'category': 'libcxx'},

How bad is the fallout?


http://reviews.llvm.org/D14293



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


Re: [PATCH] D13304: Avoid inlining in throw statement

2015-11-03 Thread Chad Rosier via cfe-commits
mcrosier added a comment.

@chandlerc: Adding Chandler in case he has an opinion on how to move forward or 
how we could go about tuning the cold threshold.


http://reviews.llvm.org/D13304



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


Re: [PATCH] D14293: [libcxx] Add -fno-exceptions libcxx builders to zorg

2015-11-03 Thread Asiri Rathnayake via cfe-commits
rmaprath added inline comments.


Comment at: buildbot/osuosl/master/config/builders.py:771
@@ +770,3 @@
+ # the -fno-exceptions library build.
+ additional_features={'no-libcxx-tests'}),
+ 'category': 'libcxx'},

jroelofs wrote:
> How bad is the fallout?
I see about 160 test failures. Mostly because those tests have try/catch/throw 
statements that don't compile under -fno-exceptions, but there are other kinds 
of failures as well.

One option is to add xfails for those tests and gradually fix them up, this 
will ensure that we don't regress those tests that are already passing. I've 
taken the slightly more involved approach and started fixing the tests all in 
one go. I plan to send a follow-up patch soon with the general idea of the 
proposed "fix".


http://reviews.llvm.org/D14293



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


Re: [PATCH] D14277: [Analyzer] Make referenced SymbolMetadata live even if its region is dead

2015-11-03 Thread Jordan Rose via cfe-commits
jordan_rose added a comment.

The intent here was that a metadata symbol represents //metadata about a 
region.// That means if the region is dead, and the symbol isn't directly 
referenceable, we won't be able to recreate it. The advantage of `&&` was that 
checkers didn't have to track when regions were no longer live.

Of course, the example shows that a symbol doesn't have to be directly 
referenceable to be used, so it didn't exactly pan out. But making this change 
without a corresponding change to every checker using metadata symbols 
(in-tree, just CStringChecker) means that those checkers will now keep the 
symbols alive forever. (And if we wanted to do that, we wouldn't have to use 
`markInUse`; just `markLive`.)

I think this needs a little more thought.


Repository:
  rL LLVM

http://reviews.llvm.org/D14277



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


Re: [PATCH] D13304: Avoid inlining in throw statement

2015-11-03 Thread Jun Bum Lim via cfe-commits
junbuml added a comment.

Thanks Richard for your comment !

If the frond-end is not a good to place for this, I think there are two places 
we can consider : inliner or prune-eh.

1. In inliner, we can directly check if a CallSite branches an exception 
region, and then make getInlineThreshold() return a lower threshold.
2. If we want to avoid adding the additional check in inliner, we can move back 
to PruneEH.cpp(http://reviews.llvm.org/D12979). If NoInline is too strong to 
use, then I want to suggest to introduce a new attribute and allow ininliner to 
check the new attribute and decide lower inline threshold for callsites in 
exception handling regions.

Please let me know any opinion or any better suggestion.


http://reviews.llvm.org/D13304



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


Re: [PATCH] D14179: Remove some legacy mingw-w64 gcc struct info

2015-11-03 Thread Martell Malone via cfe-commits
martell added a comment.

From what I can gather it made sense at the time of gcc 4.6 so I don't think 
anyone is at fault :)


Repository:
  rL LLVM

http://reviews.llvm.org/D14179



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


Re: [PATCH] D13925: Implement __attribute__((internal_linkage))

2015-11-03 Thread Aaron Ballman via cfe-commits
On Tue, Nov 3, 2015 at 7:23 PM, Richard Smith  wrote:
> rsmith added inline comments.
>
> 
> Comment at: include/clang/Basic/AttrDocs.td:1628
> @@ +1627,3 @@
> +The ``internal_linkage`` attribute changes the linkage type of the 
> declaration to internal.
> +This is similar to C-style ``static``, but can be used on classes and class 
> methods
> +This can be used to contain the ABI of a C++ library by excluding unwanted 
> class methods from the export tables.
> 
> Missing period at end of sentence.
>
> 
> Comment at: include/clang/Basic/AttrDocs.td:1628
> @@ +1627,3 @@
> +The ``internal_linkage`` attribute changes the linkage type of the 
> declaration to internal.
> +This is similar to C-style ``static``, but can be used on classes and class 
> methods
> +This can be used to contain the ABI of a C++ library by excluding unwanted 
> class methods from the export tables.
> 
> rsmith wrote:
>> Missing period at end of sentence.
> Please also say what it means if the attribute is applied to a class.
>
> 
> Comment at: lib/AST/Decl.cpp:635-641
> @@ -634,2 +634,9 @@
>assert(!isa(D) && "Didn't expect a FieldDecl!");
>
> +  for (const DeclContext *DC = D->getDeclContext();
> +   !isa(DC); DC = DC->getParent()) {
> +const NamespaceDecl *ND = dyn_cast(DC);
> +if (ND && ND->getAttr())
> +  return LinkageInfo::internal();
> +  }
> +
> 
> Dead code?
>
> 
> Comment at: lib/AST/Decl.cpp:1362-1367
> @@ -1346,4 +1361,8 @@
>  }
> -assert(!Old || Old->getCachedLinkage() == D->getCachedLinkage());
> +// Linkages may also differ if one of the declarations has
> +// InternalLinkageAttr.
> +assert(!Old || Old->getCachedLinkage() == D->getCachedLinkage() ||
> +   (Old->hasAttr() !=
> +D->hasAttr()));
>  #endif
>
> 
> We should not introduce another case where the linkage of an entity can 
> change after its first declaration. It seems reasonable to require this 
> attribute to be on the first declaration of the function.
>
> 
> Comment at: lib/Sema/SemaDeclAttr.cpp:3391
> @@ +3390,3 @@
> +  unsigned AttrSpellingListIndex) {
> +  if (checkAttrMutualExclusion(*this, D, Range, Ident))
> +return nullptr;
> 
> Aaron, could we move the mutual exclusion functionality to TableGen? 
> (Separately from this patch, of course.) It looks like there are now 6 
> attributes that could use the "simple attribute" codepath if we did so.

Yes, I think that would be a good idea. Ideally, I would like the
tablegen to look like:

class Attr {
  // ...
  list MutuallyExclusive = [];
}

def Hot {
  // ...
  let MutuallyExclusive = [Cold];
}

def Cold {
  // ...
  let MutuallyExclusive = [Hot];
}

I'll put this on my list of refactorings to do.

~Aaron

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


Re: [PATCH] D13925: Implement __attribute__((internal_linkage))

2015-11-03 Thread Evgeniy Stepanov via cfe-commits
eugenis added inline comments.


Comment at: lib/AST/Decl.cpp:635-641
@@ -634,2 +634,9 @@
   assert(!isa(D) && "Didn't expect a FieldDecl!");
 
+  for (const DeclContext *DC = D->getDeclContext();
+   !isa(DC); DC = DC->getParent()) {
+const NamespaceDecl *ND = dyn_cast(DC);
+if (ND && ND->getAttr())
+  return LinkageInfo::internal();
+  }
+

rsmith wrote:
> Dead code?
Right. Removed.


Comment at: lib/AST/Decl.cpp:1362-1367
@@ -1346,4 +1361,8 @@
 }
-assert(!Old || Old->getCachedLinkage() == D->getCachedLinkage());
+// Linkages may also differ if one of the declarations has
+// InternalLinkageAttr.
+assert(!Old || Old->getCachedLinkage() == D->getCachedLinkage() ||
+   (Old->hasAttr() !=
+D->hasAttr()));
 #endif
 

rsmith wrote:
> We should not introduce another case where the linkage of an entity can 
> change after its first declaration. It seems reasonable to require this 
> attribute to be on the first declaration of the function.
This is strange, I can no longer trigger this code path.
I wonder if the change that added an attribute check to isExternallyVisible 
made this special case unnecessary?
Reverting this chunk.


Repository:
  rL LLVM

http://reviews.llvm.org/D13925



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


Re: [PATCH] D13925: Implement __attribute__((internal_linkage))

2015-11-03 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: include/clang/Basic/AttrDocs.td:1628
@@ +1627,3 @@
+The ``internal_linkage`` attribute changes the linkage type of the declaration 
to internal.
+This is similar to C-style ``static``, but can be used on classes and class 
methods
+This can be used to contain the ABI of a C++ library by excluding unwanted 
class methods from the export tables.

Missing period at end of sentence.


Comment at: include/clang/Basic/AttrDocs.td:1628
@@ +1627,3 @@
+The ``internal_linkage`` attribute changes the linkage type of the declaration 
to internal.
+This is similar to C-style ``static``, but can be used on classes and class 
methods
+This can be used to contain the ABI of a C++ library by excluding unwanted 
class methods from the export tables.

rsmith wrote:
> Missing period at end of sentence.
Please also say what it means if the attribute is applied to a class.


Comment at: lib/AST/Decl.cpp:635-641
@@ -634,2 +634,9 @@
   assert(!isa(D) && "Didn't expect a FieldDecl!");
 
+  for (const DeclContext *DC = D->getDeclContext();
+   !isa(DC); DC = DC->getParent()) {
+const NamespaceDecl *ND = dyn_cast(DC);
+if (ND && ND->getAttr())
+  return LinkageInfo::internal();
+  }
+

Dead code?


Comment at: lib/AST/Decl.cpp:1362-1367
@@ -1346,4 +1361,8 @@
 }
-assert(!Old || Old->getCachedLinkage() == D->getCachedLinkage());
+// Linkages may also differ if one of the declarations has
+// InternalLinkageAttr.
+assert(!Old || Old->getCachedLinkage() == D->getCachedLinkage() ||
+   (Old->hasAttr() !=
+D->hasAttr()));
 #endif
 

We should not introduce another case where the linkage of an entity can change 
after its first declaration. It seems reasonable to require this attribute to 
be on the first declaration of the function.


Comment at: lib/Sema/SemaDeclAttr.cpp:3391
@@ +3390,3 @@
+  unsigned AttrSpellingListIndex) {
+  if (checkAttrMutualExclusion(*this, D, Range, Ident))
+return nullptr;

Aaron, could we move the mutual exclusion functionality to TableGen? 
(Separately from this patch, of course.) It looks like there are now 6 
attributes that could use the "simple attribute" codepath if we did so.


Repository:
  rL LLVM

http://reviews.llvm.org/D13925



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


Re: [PATCH] D13925: Implement __attribute__((internal_linkage))

2015-11-03 Thread Aaron Ballman via cfe-commits
On Tue, Nov 3, 2015 at 7:44 PM, Richard Smith  wrote:
> On Tue, Nov 3, 2015 at 4:37 PM, Aaron Ballman via cfe-commits
>  wrote:
>>
>> On Tue, Nov 3, 2015 at 7:23 PM, Richard Smith 
>> wrote:
>> > rsmith added inline comments.
>> >
>> > 
>> > Comment at: include/clang/Basic/AttrDocs.td:1628
>> > @@ +1627,3 @@
>> > +The ``internal_linkage`` attribute changes the linkage type of the
>> > declaration to internal.
>> > +This is similar to C-style ``static``, but can be used on classes and
>> > class methods
>> > +This can be used to contain the ABI of a C++ library by excluding
>> > unwanted class methods from the export tables.
>> > 
>> > Missing period at end of sentence.
>> >
>> > 
>> > Comment at: include/clang/Basic/AttrDocs.td:1628
>> > @@ +1627,3 @@
>> > +The ``internal_linkage`` attribute changes the linkage type of the
>> > declaration to internal.
>> > +This is similar to C-style ``static``, but can be used on classes and
>> > class methods
>> > +This can be used to contain the ABI of a C++ library by excluding
>> > unwanted class methods from the export tables.
>> > 
>> > rsmith wrote:
>> >> Missing period at end of sentence.
>> > Please also say what it means if the attribute is applied to a class.
>> >
>> > 
>> > Comment at: lib/AST/Decl.cpp:635-641
>> > @@ -634,2 +634,9 @@
>> >assert(!isa(D) && "Didn't expect a FieldDecl!");
>> >
>> > +  for (const DeclContext *DC = D->getDeclContext();
>> > +   !isa(DC); DC = DC->getParent()) {
>> > +const NamespaceDecl *ND = dyn_cast(DC);
>> > +if (ND && ND->getAttr())
>> > +  return LinkageInfo::internal();
>> > +  }
>> > +
>> > 
>> > Dead code?
>> >
>> > 
>> > Comment at: lib/AST/Decl.cpp:1362-1367
>> > @@ -1346,4 +1361,8 @@
>> >  }
>> > -assert(!Old || Old->getCachedLinkage() == D->getCachedLinkage());
>> > +// Linkages may also differ if one of the declarations has
>> > +// InternalLinkageAttr.
>> > +assert(!Old || Old->getCachedLinkage() == D->getCachedLinkage() ||
>> > +   (Old->hasAttr() !=
>> > +D->hasAttr()));
>> >  #endif
>> >
>> > 
>> > We should not introduce another case where the linkage of an entity can
>> > change after its first declaration. It seems reasonable to require this
>> > attribute to be on the first declaration of the function.
>> >
>> > 
>> > Comment at: lib/Sema/SemaDeclAttr.cpp:3391
>> > @@ +3390,3 @@
>> > +  unsigned AttrSpellingListIndex) {
>> > +  if (checkAttrMutualExclusion(*this, D, Range,
>> > Ident))
>> > +return nullptr;
>> > 
>> > Aaron, could we move the mutual exclusion functionality to TableGen?
>> > (Separately from this patch, of course.) It looks like there are now 6
>> > attributes that could use the "simple attribute" codepath if we did so.
>>
>> Yes, I think that would be a good idea. Ideally, I would like the
>> tablegen to look like:
>>
>> class Attr {
>>   // ...
>>   list MutuallyExclusive = [];
>> }
>>
>> def Hot {
>>   // ...
>>   let MutuallyExclusive = [Cold];
>> }
>>
>> def Cold {
>>   // ...
>>   let MutuallyExclusive = [Hot];
>> }
>>
>> I'll put this on my list of refactorings to do.
>
>
> It'd be nice if we could also diagnose inconsistencies in this (eg, Hot says
> it's exclusive with Cold and Cold doesn't agree).

Already planned (as a warning, because you can infer the correct
behavior anyway). Also, this can generate some documentation
automatically for those attributes.

~Aaron

>
>>
>> ~Aaron
>>
>> >
>> >
>> > Repository:
>> >   rL LLVM
>> >
>> > http://reviews.llvm.org/D13925
>> >
>> >
>> >
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13925: Implement __attribute__((internal_linkage))

2015-11-03 Thread Evgeniy Stepanov via cfe-commits
eugenis updated this revision to Diff 39135.
eugenis marked 2 inline comments as done.

Repository:
  rL LLVM

http://reviews.llvm.org/D13925

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Sema/Sema.h
  lib/AST/Decl.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGenCXX/attribute_internal_linkage.cpp
  test/Sema/attr-coldhot.c
  test/Sema/internal_linkage.c
  test/SemaCXX/internal_linkage.cpp

Index: test/SemaCXX/internal_linkage.cpp
===
--- /dev/null
+++ test/SemaCXX/internal_linkage.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+int f() __attribute__((internal_linkage));
+class __attribute__((internal_linkage)) A {
+public:
+  int x __attribute__((internal_linkage)); // expected-warning{{'internal_linkage' attribute only applies to variables, functions and classes}}
+  static int y __attribute__((internal_linkage));
+  void f1() __attribute__((internal_linkage));
+  void f2() __attribute__((internal_linkage)) {}
+  static void f3() __attribute__((internal_linkage)) {}
+  A() __attribute__((internal_linkage)) {}
+  ~A() __attribute__((internal_linkage)) {}
+  A& operator=(const A&) __attribute__((internal_linkage)) { return *this; }
+  struct {
+int z  __attribute__((internal_linkage)); // expected-warning{{'internal_linkage' attribute only applies to variables, functions and classes}}
+  };
+};
+
+namespace Z __attribute__((internal_linkage)) { // expected-warning{{'internal_linkage' attribute only applies to variables, functions and classes}}
+}
+
+__attribute__((internal_linkage("foo"))) int g() {} // expected-error{{'internal_linkage' attribute takes no arguments}}
+
+[[clang::internal_linkage]] int h() {}
+
+enum struct __attribute__((internal_linkage)) E { // expected-warning{{'internal_linkage' attribute only applies to variables, functions and classes}}
+  a = 1,
+  b = 2
+};
+
+int A::y;
+
+void A::f1() {
+}
Index: test/Sema/internal_linkage.c
===
--- /dev/null
+++ test/Sema/internal_linkage.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int var __attribute__((internal_linkage));
+int var2 __attribute__((internal_linkage,common)); // expected-error{{'internal_linkage' and 'common' attributes are not compatible}} \
+   // expected-note{{conflicting attribute is here}}
+int var3 __attribute__((common,internal_linkage)); // expected-error{{'common' and 'internal_linkage' attributes are not compatible}} \
+   // expected-note{{conflicting attribute is here}}
+
+int var4 __attribute__((common)); // expected-error{{'common' and 'internal_linkage' attributes are not compatible}}
+int var4 __attribute__((internal_linkage)); // expected-note{{conflicting attribute is here}}
+
+int var5 __attribute__((internal_linkage)); // expected-error{{'internal_linkage' and 'common' attributes are not compatible}}
+int var5 __attribute__((common)); // expected-note{{conflicting attribute is here}}
+
+__attribute__((internal_linkage)) int f() {}
+struct __attribute__((internal_linkage)) S { // expected-warning{{'internal_linkage' attribute only applies to variables and functions}}
+};
+
+__attribute__((internal_linkage("foo"))) int g() {} // expected-error{{'internal_linkage' attribute takes no arguments}}
Index: test/Sema/attr-coldhot.c
===
--- test/Sema/attr-coldhot.c
+++ test/Sema/attr-coldhot.c
@@ -6,5 +6,7 @@
 int var1 __attribute__((__cold__)); // expected-warning{{'__cold__' attribute only applies to functions}}
 int var2 __attribute__((__hot__)); // expected-warning{{'__hot__' attribute only applies to functions}}
 
-int qux() __attribute__((__hot__)) __attribute__((__cold__)); // expected-error{{'__hot__' and 'cold' attributes are not compatible}}
-int baz() __attribute__((__cold__)) __attribute__((__hot__)); // expected-error{{'__cold__' and 'hot' attributes are not compatible}}
+int qux() __attribute__((__hot__)) __attribute__((__cold__)); // expected-error{{'__hot__' and 'cold' attributes are not compatible}} \
+// expected-note{{conflicting attribute is here}}
+int baz() __attribute__((__cold__)) __attribute__((__hot__)); // expected-error{{'__cold__' and 'hot' attributes are not compatible}} \
+// expected-note{{conflicting attribute is here}}
Index: test/CodeGenCXX/attribute_internal_linkage.cpp
===
--- /dev/null
+++ test/CodeGenCXX/attribute_internal_linkage.cpp
@@ -0,0 +1,90 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -std=c++11 -emit-llvm -o - %s | FileCheck %s
+
+__attribute__((internal_linkage)) void f() {}
+// CHECK-DAG: define internal void @_ZL1fv
+
+class A {
+public:
+  static int y __attribute__((internal_linkage));
+  

Re: [PATCH] D13925: Implement __attribute__((internal_linkage))

2015-11-03 Thread Evgeniy Stepanov via cfe-commits
eugenis updated this revision to Diff 39124.
eugenis marked 5 inline comments as done.
eugenis added a comment.

Disabled the new attribute on namespaces.


Repository:
  rL LLVM

http://reviews.llvm.org/D13925

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Sema/Sema.h
  lib/AST/Decl.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGenCXX/attribute_internal_linkage.cpp
  test/Sema/attr-coldhot.c
  test/Sema/internal_linkage.c
  test/SemaCXX/internal_linkage.cpp

Index: test/SemaCXX/internal_linkage.cpp
===
--- /dev/null
+++ test/SemaCXX/internal_linkage.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+int f() __attribute__((internal_linkage));
+class __attribute__((internal_linkage)) A {
+public:
+  int x __attribute__((internal_linkage)); // expected-warning{{'internal_linkage' attribute only applies to variables, functions and classes}}
+  static int y __attribute__((internal_linkage));
+  void f1() __attribute__((internal_linkage));
+  void f2() __attribute__((internal_linkage)) {}
+  static void f3() __attribute__((internal_linkage)) {}
+  A() __attribute__((internal_linkage)) {}
+  ~A() __attribute__((internal_linkage)) {}
+  A& operator=(const A&) __attribute__((internal_linkage)) { return *this; }
+  struct {
+int z  __attribute__((internal_linkage)); // expected-warning{{'internal_linkage' attribute only applies to variables, functions and classes}}
+  };
+};
+
+namespace Z __attribute__((internal_linkage)) { // expected-warning{{'internal_linkage' attribute only applies to variables, functions and classes}}
+}
+
+__attribute__((internal_linkage("foo"))) int g() {} // expected-error{{'internal_linkage' attribute takes no arguments}}
+
+[[clang::internal_linkage]] int h() {}
+
+enum struct __attribute__((internal_linkage)) E { // expected-warning{{'internal_linkage' attribute only applies to variables, functions and classes}}
+  a = 1,
+  b = 2
+};
+
+int A::y;
+
+void A::f1() {
+}
Index: test/Sema/internal_linkage.c
===
--- /dev/null
+++ test/Sema/internal_linkage.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int var __attribute__((internal_linkage));
+int var2 __attribute__((internal_linkage,common)); // expected-error{{'internal_linkage' and 'common' attributes are not compatible}} \
+   // expected-note{{conflicting attribute is here}}
+int var3 __attribute__((common,internal_linkage)); // expected-error{{'common' and 'internal_linkage' attributes are not compatible}} \
+   // expected-note{{conflicting attribute is here}}
+
+int var4 __attribute__((common)); // expected-error{{'common' and 'internal_linkage' attributes are not compatible}}
+int var4 __attribute__((internal_linkage)); // expected-note{{conflicting attribute is here}}
+
+int var5 __attribute__((internal_linkage)); // expected-error{{'internal_linkage' and 'common' attributes are not compatible}}
+int var5 __attribute__((common)); // expected-note{{conflicting attribute is here}}
+
+__attribute__((internal_linkage)) int f() {}
+struct __attribute__((internal_linkage)) S { // expected-warning{{'internal_linkage' attribute only applies to variables and functions}}
+};
+
+__attribute__((internal_linkage("foo"))) int g() {} // expected-error{{'internal_linkage' attribute takes no arguments}}
Index: test/Sema/attr-coldhot.c
===
--- test/Sema/attr-coldhot.c
+++ test/Sema/attr-coldhot.c
@@ -6,5 +6,7 @@
 int var1 __attribute__((__cold__)); // expected-warning{{'__cold__' attribute only applies to functions}}
 int var2 __attribute__((__hot__)); // expected-warning{{'__hot__' attribute only applies to functions}}
 
-int qux() __attribute__((__hot__)) __attribute__((__cold__)); // expected-error{{'__hot__' and 'cold' attributes are not compatible}}
-int baz() __attribute__((__cold__)) __attribute__((__hot__)); // expected-error{{'__cold__' and 'hot' attributes are not compatible}}
+int qux() __attribute__((__hot__)) __attribute__((__cold__)); // expected-error{{'__hot__' and 'cold' attributes are not compatible}} \
+// expected-note{{conflicting attribute is here}}
+int baz() __attribute__((__cold__)) __attribute__((__hot__)); // expected-error{{'__cold__' and 'hot' attributes are not compatible}} \
+// expected-note{{conflicting attribute is here}}
Index: test/CodeGenCXX/attribute_internal_linkage.cpp
===
--- /dev/null
+++ test/CodeGenCXX/attribute_internal_linkage.cpp
@@ -0,0 +1,79 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -std=c++11 -emit-llvm -o - %s | FileCheck %s
+
+__attribute__((internal_linkage)) void f() {}
+// CHECK-DAG: define internal void @_ZL1fv
+
+class A 

Re: [PATCH] D13304: Avoid inlining in throw statement

2015-11-03 Thread Manman Ren via cfe-commits
manmanren added a subscriber: manmanren.
manmanren added a comment.

Inliner currently does not include analysis passes such as BPI and BFI. With 
the new pass manager, we should be able to hook up inliner with BFI (and we can 
handle throw in BFI). Before that, maybe we can add this as part of inlining 
analysis?


http://reviews.llvm.org/D13304



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


Re: [PATCH] D13925: Implement __attribute__((internal_linkage))

2015-11-03 Thread Richard Smith via cfe-commits
On Tue, Nov 3, 2015 at 4:37 PM, Aaron Ballman via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On Tue, Nov 3, 2015 at 7:23 PM, Richard Smith 
> wrote:
> > rsmith added inline comments.
> >
> > 
> > Comment at: include/clang/Basic/AttrDocs.td:1628
> > @@ +1627,3 @@
> > +The ``internal_linkage`` attribute changes the linkage type of the
> declaration to internal.
> > +This is similar to C-style ``static``, but can be used on classes and
> class methods
> > +This can be used to contain the ABI of a C++ library by excluding
> unwanted class methods from the export tables.
> > 
> > Missing period at end of sentence.
> >
> > 
> > Comment at: include/clang/Basic/AttrDocs.td:1628
> > @@ +1627,3 @@
> > +The ``internal_linkage`` attribute changes the linkage type of the
> declaration to internal.
> > +This is similar to C-style ``static``, but can be used on classes and
> class methods
> > +This can be used to contain the ABI of a C++ library by excluding
> unwanted class methods from the export tables.
> > 
> > rsmith wrote:
> >> Missing period at end of sentence.
> > Please also say what it means if the attribute is applied to a class.
> >
> > 
> > Comment at: lib/AST/Decl.cpp:635-641
> > @@ -634,2 +634,9 @@
> >assert(!isa(D) && "Didn't expect a FieldDecl!");
> >
> > +  for (const DeclContext *DC = D->getDeclContext();
> > +   !isa(DC); DC = DC->getParent()) {
> > +const NamespaceDecl *ND = dyn_cast(DC);
> > +if (ND && ND->getAttr())
> > +  return LinkageInfo::internal();
> > +  }
> > +
> > 
> > Dead code?
> >
> > 
> > Comment at: lib/AST/Decl.cpp:1362-1367
> > @@ -1346,4 +1361,8 @@
> >  }
> > -assert(!Old || Old->getCachedLinkage() == D->getCachedLinkage());
> > +// Linkages may also differ if one of the declarations has
> > +// InternalLinkageAttr.
> > +assert(!Old || Old->getCachedLinkage() == D->getCachedLinkage() ||
> > +   (Old->hasAttr() !=
> > +D->hasAttr()));
> >  #endif
> >
> > 
> > We should not introduce another case where the linkage of an entity can
> change after its first declaration. It seems reasonable to require this
> attribute to be on the first declaration of the function.
> >
> > 
> > Comment at: lib/Sema/SemaDeclAttr.cpp:3391
> > @@ +3390,3 @@
> > +  unsigned AttrSpellingListIndex) {
> > +  if (checkAttrMutualExclusion(*this, D, Range,
> Ident))
> > +return nullptr;
> > 
> > Aaron, could we move the mutual exclusion functionality to TableGen?
> (Separately from this patch, of course.) It looks like there are now 6
> attributes that could use the "simple attribute" codepath if we did so.
>
> Yes, I think that would be a good idea. Ideally, I would like the
> tablegen to look like:
>
> class Attr {
>   // ...
>   list MutuallyExclusive = [];
> }
>
> def Hot {
>   // ...
>   let MutuallyExclusive = [Cold];
> }
>
> def Cold {
>   // ...
>   let MutuallyExclusive = [Hot];
> }
>
> I'll put this on my list of refactorings to do.
>

It'd be nice if we could also diagnose inconsistencies in this (eg, Hot
says it's exclusive with Cold and Cold doesn't agree).


> ~Aaron
>
> >
> >
> > Repository:
> >   rL LLVM
> >
> > http://reviews.llvm.org/D13925
> >
> >
> >
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D14311: [Clang] Fix some Clang-tidy modernize warnings, other minor fixes

2015-11-03 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko created this revision.
Eugene.Zelenko added a reviewer: hans.
Eugene.Zelenko added a subscriber: cfe-commits.
Eugene.Zelenko set the repository for this revision to rL LLVM.
Herald added subscribers: dschuff, jfb.

Fixed warnings are: modernize-use-override, modernize-use-nullptr and 
modernize-redundant-void-arg.

I checked this patch on my own build on RHEL 6. Regressions were OK.

Repository:
  rL LLVM

http://reviews.llvm.org/D14311

Files:
  lib/AST/ASTContext.cpp
  lib/Driver/Tools.cpp
  lib/Driver/Tools.h
  lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
  lib/StaticAnalyzer/Core/LoopWidening.cpp

Index: lib/StaticAnalyzer/Core/LoopWidening.cpp
===
--- lib/StaticAnalyzer/Core/LoopWidening.cpp
+++ lib/StaticAnalyzer/Core/LoopWidening.cpp
@@ -23,7 +23,7 @@
 static const Expr *getLoopCondition(const Stmt *LoopStmt) {
   switch (LoopStmt->getStmtClass()) {
   default:
-return NULL;
+return nullptr;
   case Stmt::ForStmtClass:
 return cast(LoopStmt)->getCond();
   case Stmt::WhileStmtClass:
Index: lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
+++ lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
@@ -32,9 +32,9 @@
   LockState(Kind K) : K(K) {}
 
 public:
-  static LockState getLocked(void) { return LockState(Locked); }
-  static LockState getUnlocked(void) { return LockState(Unlocked); }
-  static LockState getDestroyed(void) { return LockState(Destroyed); }
+  static LockState getLocked() { return LockState(Locked); }
+  static LockState getUnlocked() { return LockState(Unlocked); }
+  static LockState getDestroyed() { return LockState(Destroyed); }
 
   bool operator==(const LockState ) const {
 return K == X.K;
Index: lib/Driver/Tools.h
===
--- lib/Driver/Tools.h
+++ lib/Driver/Tools.h
@@ -255,7 +255,7 @@
 
 void appendEBLinkFlags(const llvm::opt::ArgList , ArgStringList ,
const llvm::Triple );
-}
+} // end namespace arm
 
 namespace mips {
 typedef enum { NanLegacy = 1, Nan2008 = 2 } NanEncoding;
@@ -278,11 +278,11 @@
 bool shouldUseFPXX(const llvm::opt::ArgList , const llvm::Triple ,
StringRef CPUName, StringRef ABIName,
mips::FloatABI FloatABI);
-}
+} // end namespace mips
 
 namespace ppc {
 bool hasPPCAbiArg(const llvm::opt::ArgList , const char *Value);
-}
+} // end namespace ppc
 
 /// cloudabi -- Directly call GNU Binutils linker
 namespace cloudabi {
@@ -396,7 +396,7 @@
 const llvm::opt::ArgList ,
 const char *LinkingOutput) const override;
 };
-}
+} // end namespace darwin
 
 /// openbsd -- Directly call GNU Binutils assembler and linker
 namespace openbsd {
@@ -412,6 +412,7 @@
 const llvm::opt::ArgList ,
 const char *LinkingOutput) const override;
 };
+
 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
 public:
   Linker(const ToolChain ) : GnuTool("openbsd::Linker", "linker", TC) {}
@@ -440,6 +441,7 @@
 const llvm::opt::ArgList ,
 const char *LinkingOutput) const override;
 };
+
 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
 public:
   Linker(const ToolChain ) : GnuTool("bitrig::Linker", "linker", TC) {}
@@ -468,6 +470,7 @@
 const llvm::opt::ArgList ,
 const char *LinkingOutput) const override;
 };
+
 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
 public:
   Linker(const ToolChain ) : GnuTool("freebsd::Linker", "linker", TC) {}
@@ -485,7 +488,6 @@
 /// netbsd -- Directly call GNU Binutils assembler and linker
 namespace netbsd {
 class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool {
-
 public:
   Assembler(const ToolChain )
   : GnuTool("netbsd::Assembler", "assembler", TC) {}
@@ -497,8 +499,8 @@
 const llvm::opt::ArgList ,
 const char *LinkingOutput) const override;
 };
+
 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
-
 public:
   Linker(const ToolChain ) : GnuTool("netbsd::Linker", "linker", TC) {}
 
@@ -525,6 +527,7 @@
 const llvm::opt::ArgList ,
 const char *LinkingOutput) const override;
 };
+
 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
 public:
   Linker(const ToolChain ) : GnuTool("GNU::Linker", "linker", TC) {}
@@ -537,7 +540,7 @@
 const llvm::opt::ArgList ,
 const char *LinkingOutput) const override;
 };
-}
+} // end namespace gnutools
 
 namespace nacltools {
 class LLVM_LIBRARY_VISIBILITY AssemblerARM : public gnutools::Assembler {
@@ -549,6 +552,7 @@
 const llvm::opt::ArgList ,
 const char *LinkingOutput) const override;
 };
+
 class 

Re: [PATCH] D13925: Implement __attribute__((internal_linkage))

2015-11-03 Thread Evgeniy Stepanov via cfe-commits
eugenis updated this revision to Diff 39128.
eugenis added a comment.

One more test for forward declarations.


Repository:
  rL LLVM

http://reviews.llvm.org/D13925

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Sema/Sema.h
  lib/AST/Decl.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGenCXX/attribute_internal_linkage.cpp
  test/Sema/attr-coldhot.c
  test/Sema/internal_linkage.c
  test/SemaCXX/internal_linkage.cpp

Index: test/SemaCXX/internal_linkage.cpp
===
--- /dev/null
+++ test/SemaCXX/internal_linkage.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+int f() __attribute__((internal_linkage));
+class __attribute__((internal_linkage)) A {
+public:
+  int x __attribute__((internal_linkage)); // expected-warning{{'internal_linkage' attribute only applies to variables, functions and classes}}
+  static int y __attribute__((internal_linkage));
+  void f1() __attribute__((internal_linkage));
+  void f2() __attribute__((internal_linkage)) {}
+  static void f3() __attribute__((internal_linkage)) {}
+  A() __attribute__((internal_linkage)) {}
+  ~A() __attribute__((internal_linkage)) {}
+  A& operator=(const A&) __attribute__((internal_linkage)) { return *this; }
+  struct {
+int z  __attribute__((internal_linkage)); // expected-warning{{'internal_linkage' attribute only applies to variables, functions and classes}}
+  };
+};
+
+namespace Z __attribute__((internal_linkage)) { // expected-warning{{'internal_linkage' attribute only applies to variables, functions and classes}}
+}
+
+__attribute__((internal_linkage("foo"))) int g() {} // expected-error{{'internal_linkage' attribute takes no arguments}}
+
+[[clang::internal_linkage]] int h() {}
+
+enum struct __attribute__((internal_linkage)) E { // expected-warning{{'internal_linkage' attribute only applies to variables, functions and classes}}
+  a = 1,
+  b = 2
+};
+
+int A::y;
+
+void A::f1() {
+}
Index: test/Sema/internal_linkage.c
===
--- /dev/null
+++ test/Sema/internal_linkage.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int var __attribute__((internal_linkage));
+int var2 __attribute__((internal_linkage,common)); // expected-error{{'internal_linkage' and 'common' attributes are not compatible}} \
+   // expected-note{{conflicting attribute is here}}
+int var3 __attribute__((common,internal_linkage)); // expected-error{{'common' and 'internal_linkage' attributes are not compatible}} \
+   // expected-note{{conflicting attribute is here}}
+
+int var4 __attribute__((common)); // expected-error{{'common' and 'internal_linkage' attributes are not compatible}}
+int var4 __attribute__((internal_linkage)); // expected-note{{conflicting attribute is here}}
+
+int var5 __attribute__((internal_linkage)); // expected-error{{'internal_linkage' and 'common' attributes are not compatible}}
+int var5 __attribute__((common)); // expected-note{{conflicting attribute is here}}
+
+__attribute__((internal_linkage)) int f() {}
+struct __attribute__((internal_linkage)) S { // expected-warning{{'internal_linkage' attribute only applies to variables and functions}}
+};
+
+__attribute__((internal_linkage("foo"))) int g() {} // expected-error{{'internal_linkage' attribute takes no arguments}}
Index: test/Sema/attr-coldhot.c
===
--- test/Sema/attr-coldhot.c
+++ test/Sema/attr-coldhot.c
@@ -6,5 +6,7 @@
 int var1 __attribute__((__cold__)); // expected-warning{{'__cold__' attribute only applies to functions}}
 int var2 __attribute__((__hot__)); // expected-warning{{'__hot__' attribute only applies to functions}}
 
-int qux() __attribute__((__hot__)) __attribute__((__cold__)); // expected-error{{'__hot__' and 'cold' attributes are not compatible}}
-int baz() __attribute__((__cold__)) __attribute__((__hot__)); // expected-error{{'__cold__' and 'hot' attributes are not compatible}}
+int qux() __attribute__((__hot__)) __attribute__((__cold__)); // expected-error{{'__hot__' and 'cold' attributes are not compatible}} \
+// expected-note{{conflicting attribute is here}}
+int baz() __attribute__((__cold__)) __attribute__((__hot__)); // expected-error{{'__cold__' and 'hot' attributes are not compatible}} \
+// expected-note{{conflicting attribute is here}}
Index: test/CodeGenCXX/attribute_internal_linkage.cpp
===
--- /dev/null
+++ test/CodeGenCXX/attribute_internal_linkage.cpp
@@ -0,0 +1,90 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -std=c++11 -emit-llvm -o - %s | FileCheck %s
+
+__attribute__((internal_linkage)) void f() {}
+// CHECK-DAG: define internal void @_ZL1fv
+
+class A {
+public:
+  static int y 

Re: [PATCH] D12473: [clang-tidy] Add old style function check

2015-11-03 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Apparently, I forgot to submit the comments a looong time ago. Sorry for the 
delay.

In http://reviews.llvm.org/D12473#236401, @alexfh wrote:

> A high-level comment:
>
> It seems that the scope of the check is artificially made too narrow. The 
> check could actually look at any POD variables declared unnecessarily far 
> from their initialization and usages. And here the value of the check would 
> also be much higher, if it can automatically fix the code.
>
> I'll review the code more thoroughly later.


It looks like addressing this comment will significantly change the code, so a 
more thorough review should follow that step.

A few initial comments though.



Comment at: clang-tidy/misc/OldStyleFunctionCheck.cpp:29
@@ +28,3 @@
+
+  bool VisitStmt(Stmt* Statement);
+

I think, this class could be replaced with an AST matcher 
(`functionDecl(forEachDescendant(stmt( ... )))`) that you could run using the 
`clang::ast_matchers::match()` function. Where the `...` part would contain the 
matcher-based implementation of the `isInteresting` method.

The result would be a more local and clear code that expresses the constraints 
on the AST nodes you're interested in.


Comment at: clang-tidy/misc/OldStyleFunctionCheck.cpp:76
@@ +75,3 @@
+   "function '%0' seems to be written in legacy C style: "
+   "it has %select{an|%1}2 uninitialized POD type variable%s1 declared far 
from %select{its|their}2 point of use: %3")
+  << FunctionDefinition->getQualifiedNameAsString()

80 column limit is violated here and in a few other places. Consider 
clang-format'ting the code.


Comment at: clang-tidy/misc/OldStyleFunctionCheck.cpp:83
@@ +82,3 @@
+
+
+

This kind of a comment is not common in llvm/clang code.


Comment at: clang-tidy/misc/OldStyleFunctionCheck.cpp:149
@@ +148,3 @@
+bool OldStyleDeclarationFinder::hasImplicitOrDefaultedInitialization(const 
VarDecl* VariableDeclaration) {
+  const auto* InitConstructExpr = llvm::dyn_cast_or_null(VariableDeclaration->getInit());
+  if (InitConstructExpr == nullptr)

I'd use the `if (T* x = ...) ...` style for this and the next condition.


Comment at: clang-tidy/misc/OldStyleFunctionCheck.cpp:171
@@ +170,3 @@
+if (!first)
+  result += ", ";
+else

raw_string_ostream is a more common way to format text, and it should be more 
effective.


Comment at: docs/clang-tidy/checks/misc-old-style-function.rst:25
@@ +24,1 @@
+   parameter `DeclarationAndFirstUseDistanceThreshold` with default vaule of 3
\ No newline at end of file


Please add a newline at the end of file.


http://reviews.llvm.org/D12473



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


Re: [PATCH] D13786: [Sema] Implement __make_integer_seq

2015-11-03 Thread David Majnemer via cfe-commits
majnemer updated this revision to Diff 39153.
majnemer added a comment.

- Address Richard's latest comments


http://reviews.llvm.org/D13786

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/DataRecursiveASTVisitor.h
  include/clang/AST/DeclTemplate.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/Basic/Builtins.h
  include/clang/Basic/DeclNodes.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTContext.cpp
  lib/AST/ASTDumper.cpp
  lib/AST/DeclBase.cpp
  lib/AST/DeclTemplate.cpp
  lib/CodeGen/CGDecl.cpp
  lib/Sema/SemaLookup.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Serialization/ASTCommon.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriter.cpp
  test/PCH/make-integer-seq.cpp
  test/SemaCXX/make_integer_seq.cpp
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -5110,6 +5110,7 @@
   case Decl::Import:
   case Decl::OMPThreadPrivate:
   case Decl::ObjCTypeParam:
+  case Decl::BuiltinTemplate:
 return C;
 
   // Declaration kinds that don't make any sense here, but are
Index: test/SemaCXX/make_integer_seq.cpp
===
--- /dev/null
+++ test/SemaCXX/make_integer_seq.cpp
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+template 
+struct Seq {
+  static constexpr T PackSize = sizeof...(I);
+};
+
+template 
+using MakeSeq = __make_integer_seq;
+
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+
+template 
+using ErrorSeq = __make_integer_seq; // expected-error{{must have non-negative sequence length}} \
+   expected-error{{must have integral element type}}
+
+enum Color : int { Red,
+   Green,
+   Blue };
+using illformed1 = ErrorSeq; // expected-note{{in instantiation}}
+
+using illformed2 = ErrorSeq;
+
+template  void f() {}
+__make_integer_seq x; // expected-error{{template template parameter must be a class template or type alias template}}
Index: test/PCH/make-integer-seq.cpp
===
--- /dev/null
+++ test/PCH/make-integer-seq.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -std=c++14 -x c++-header %s -emit-pch -o %t.pch
+// RUN: %clang_cc1 -std=c++14 -x c++ /dev/null -include-pch %t.pch
+
+template 
+struct Seq {
+static constexpr T PackSize = sizeof...(I);
+};
+
+template 
+using MakeSeq = __make_integer_seq;
+
+void fn1() {
+  MakeSeq x;
+}
Index: lib/Serialization/ASTWriter.cpp
===
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -4136,6 +4136,8 @@
   RegisterPredefDecl(Context.BuiltinMSVaListDecl,
  PREDEF_DECL_BUILTIN_MS_VA_LIST_ID);
   RegisterPredefDecl(Context.ExternCContext, PREDEF_DECL_EXTERN_C_CONTEXT_ID);
+  RegisterPredefDecl(Context.MakeIntegerSeqDecl,
+ PREDEF_DECL_MAKE_INTEGER_SEQ_ID);
 
   // Build a record containing all of the tentative definitions in this file, in
   // TentativeDefinitions order.  Generally, this record will be empty for
Index: lib/Serialization/ASTReaderDecl.cpp
===
--- lib/Serialization/ASTReaderDecl.cpp
+++ lib/Serialization/ASTReaderDecl.cpp
@@ -293,6 +293,7 @@
 DeclID VisitTemplateDecl(TemplateDecl *D);
 RedeclarableResult VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D);
 void VisitClassTemplateDecl(ClassTemplateDecl *D);
+void VisitBuiltinTemplateDecl(BuiltinTemplateDecl *D);
 void VisitVarTemplateDecl(VarTemplateDecl *D);
 void VisitFunctionTemplateDecl(FunctionTemplateDecl *D);
 void 

Re: [PATCH] D13786: [Sema] Implement __make_integer_seq

2015-11-03 Thread Richard Smith via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Please add a test for serialization/deserialization of this declaration. 
Otherwise, this looks fine.



Comment at: include/clang/Serialization/ASTBitCodes.h:994
@@ -990,3 +993,3 @@
 /// \c PredefinedDeclIDs type and the PREDEF_DECL_*_ID constants.
 const unsigned int NUM_PREDEF_DECL_IDS = 13;
 

Increase this by 1, please :)


Comment at: lib/AST/DeclTemplate.cpp:1212
@@ +1211,3 @@
+
+  // 
+  NamedDecl *P[2] = {T, N};

This should say T ...Ints too.


Comment at: lib/AST/DeclTemplate.cpp:1217
@@ +1216,3 @@
+
+  // template  class IntSeq
+  auto *TemplateTemplateParm = TemplateTemplateParmDecl::Create(

And this.


Comment at: lib/AST/DeclTemplate.cpp:1238
@@ +1237,3 @@
+
+  // template  class IntSeq, typename T, 
Ints...>
+  return TemplateParameterList::Create(C, SourceLocation(), SourceLocation(),

This should say T ...Ints and then T N


http://reviews.llvm.org/D13786



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


Re: [PATCH] D10833: Retrieve BinaryOperator::getOpcode and BinaryOperator::getOpcodeStr via libclang and its python interface

2015-11-03 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 updated this revision to Diff 39158.
RedX2501 added a comment.

Added module tests to libclang and python.


http://reviews.llvm.org/D10833

Files:
  bindings/python/clang/cindex.py
  bindings/python/tests/cindex/test_cursor.py
  include/clang-c/Index.h
  include/clang/AST/OperationKinds.h
  test/Index/binop.cpp
  tools/c-index-test/c-index-test.c
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -3725,6 +3725,11 @@
   return cxstring::createDup(OS.str());
 }
 
+if (C.kind == CXCursor_BinaryOperator ||
+C.kind == CXCursor_CompoundAssignOperator) {
+  return clang_Cursor_getBinaryOpCodeStr(C);
+}
+
 const Decl *D = getDeclFromExpr(getCursorExpr(C));
 if (D)
   return getDeclSpelling(D);
@@ -6741,6 +6746,34 @@
   return 0;
 }
 
+enum CX_BinaryOperatorKind clang_Cursor_getBinaryOpCode(CXCursor C) {
+	if (C.kind != CXCursor_BinaryOperator &&
+		C.kind != CXCursor_CompoundAssignOperator) {
+		return CX_BO_Invalid;
+	}
+
+	const Expr *D = getCursorExpr(C);
+	if (const BinaryOperator *BinOp = dyn_cast(D)) {
+		return static_cast(BinOp->getOpcode() + 1);
+	}
+
+	return CX_BO_Invalid;
+}
+
+CXString clang_Cursor_getBinaryOpCodeStr(CXCursor C) {
+	if (C.kind != CXCursor_BinaryOperator &&
+		C.kind != CXCursor_CompoundAssignOperator) {
+		return cxstring::createEmpty();
+	}
+
+	const Expr *D = getCursorExpr(C);
+	if (const BinaryOperator *BinOp = dyn_cast(D)) {
+		return cxstring::createDup(BinOp->getOpcodeStr());
+	}
+
+	return cxstring::createEmpty();
+}
+
 CXSourceRange clang_Cursor_getCommentRange(CXCursor C) {
   if (!clang_isDeclaration(C.kind))
 return clang_getNullRange();
Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -1425,6 +1425,21 @@
   return CXChildVisit_Recurse;
 }
 
+static enum CXChildVisitResult PrintBinOps(CXCursor C, CXCursor p,
+   CXClientData d){
+  enum CXCursorKind ck = clang_getCursorKind(C);
+  if (ck != CXCursor_BinaryOperator && ck != CXCursor_CompoundAssignOperator)
+return CXChildVisit_Recurse;
+
+  PrintCursor(C, NULL);
+  CXString opstr = clang_Cursor_getBinaryOpCodeStr(C);
+  enum CX_BinaryOperatorKind bok = clang_Cursor_getBinaryOpCode(C);
+  printf(" BinOp=%s %d\n", clang_getCString(opstr), bok);
+
+  return CXChildVisit_Recurse;
+}
+
+
 /**/
 /* Mangling testing.  */
 /**/
@@ -4068,6 +4083,7 @@
 "   c-index-test -test-print-type {}*\n"
 "   c-index-test -test-print-type-size {}*\n"
 "   c-index-test -test-print-bitwidth {}*\n"
+"   c-index-test -test-print-binops {}*\n"
 "   c-index-test -print-usr [ {}]*\n"
 "   c-index-test -print-usr-file \n"
 "   c-index-test -write-pch  \n");
@@ -4161,6 +4177,9 @@
   else if (argc > 2 && strcmp(argv[1], "-test-print-bitwidth") == 0)
 return perform_test_load_source(argc - 2, argv + 2, "all",
 PrintBitWidth, 0);
+  else if (argc > 2 && strcmp(argv[1], "-test-print-binops") == 0)
+return perform_test_load_source(argc - 2, argv + 2, "all",
+PrintBinOps, 0);
   else if (argc > 2 && strcmp(argv[1], "-test-print-mangle") == 0)
 return perform_test_load_tu(argv[2], "all", NULL, PrintMangledName, NULL);
   else if (argc > 1 && strcmp(argv[1], "-print-usr") == 0) {
Index: test/Index/binop.cpp
===
--- /dev/null
+++ test/Index/binop.cpp
@@ -0,0 +1,90 @@
+// RUN: c-index-test -test-print-binops %s | FileCheck %s
+
+struct C {
+  int m;
+};
+
+void func(void){
+	int a, b;
+  int C::* p = ::m;
+
+	C c;
+	c.*p;
+
+	C* pc;
+	pc->*p;
+
+	a * b;
+	a / b;
+	a % b;
+	a + b;
+	a - b;
+
+	a << b;
+	a >> b;
+
+	a < b;
+	a > b;
+
+	a <= b;
+	a >= b;
+	a == b;
+	a != b;
+	
+	a & b;
+	a ^ b;
+	a | b;
+
+	a && b;
+	a || b;
+
+	a = b;
+
+	a *= b;
+	a /= b;
+	a %= b;
+	a += b;
+	a -= b;
+	
+	a <<= b;
+	a >>= b;
+
+	a &= b;
+	a ^= b;
+	a |= b;
+	a , b;
+
+}
+
+// CHECK: BinaryOperator=.* BinOp=.* 1
+// CHECK: BinaryOperator=->* BinOp=->* 2
+// CHECK: BinaryOperator=* BinOp=* 3
+// CHECK: BinaryOperator=/ BinOp=/ 4
+// CHECK: BinaryOperator=% BinOp=% 5
+// CHECK: BinaryOperator=+ BinOp=+ 6
+// CHECK: BinaryOperator=- BinOp=- 7
+// CHECK: BinaryOperator=<< BinOp=<< 8
+// CHECK: BinaryOperator=>> BinOp=>> 9
+// CHECK: BinaryOperator=< BinOp=< 10
+// CHECK: BinaryOperator=> BinOp=> 11
+// CHECK: BinaryOperator=<= BinOp=<= 12
+// CHECK: BinaryOperator=>= BinOp=>= 13
+// CHECK: BinaryOperator=== 

Re: [PATCH] D10834: Added functions to retrieve information about whether a vardecl is local in libclang and its python bindings.

2015-11-03 Thread guibufolo+l...@gmail.com via cfe-commits
RedX2501 retitled this revision from "Added functions to retrieve information 
about variable storage in libclang and its python bindings." to "Added 
functions to retrieve information about whether a vardecl is local in libclang 
and its python bindings.".
RedX2501 updated this revision to Diff 39163.
RedX2501 added a comment.

No longer export to functions but only one.
The original functionality can be achieved by using StorageClass coupled with 
the information if the variable is local.

Added python and libclang tests.


http://reviews.llvm.org/D10834

Files:
  bindings/python/clang/cindex.py
  bindings/python/tests/cindex/test_cursor.py
  include/clang-c/Index.h
  test/Index/islocalvardecl.cpp
  tools/c-index-test/c-index-test.c
  tools/libclang/CIndex.cpp
  tools/libclang/libclang.exports

Index: tools/libclang/libclang.exports
===
--- tools/libclang/libclang.exports
+++ tools/libclang/libclang.exports
@@ -32,6 +32,7 @@
 clang_Cursor_isNull
 clang_Cursor_isObjCOptional
 clang_Cursor_isVariadic
+clang_Cursor_isLocalVarDecl
 clang_Cursor_getModule
 clang_Cursor_getStorageClass
 clang_File_isEqual
Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -6741,6 +6741,19 @@
   return 0;
 }
 
+unsigned clang_Cursor_isLocalVarDecl(CXCursor C){
+  if (C.kind != CXCursor_VarDecl) {
+return 0;
+  }
+
+  const Decl *D = getCursorDecl(C);
+  if (const VarDecl *VD = dyn_cast(D)) {
+		return VD->isLocalVarDecl();
+	}
+
+	return 0;
+}
+
 CXSourceRange clang_Cursor_getCommentRange(CXCursor C) {
   if (!clang_isDeclaration(C.kind))
 return clang_getNullRange();
Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -1248,6 +1248,21 @@
 }
 
 /**/
+/* Local VarKind testing. */
+/**/
+
+static enum ChildVisitResult PrintIsLocalVarDecl(CXCursor C, CXClientData CD){
+
+  if (clang_getCursorKind(C) != CXCursor_VarDecl)
+return CXChildVisit_Recurse;
+
+  PrintCursor(C, NULL);
+  printf(" IsLocalVarDecl=%d\n", clang_Cursor_isLocalVarDecl(C));
+
+  return CXChildVisit_Recurse;
+}
+
+/**/
 /* Typekind testing.  */
 /**/
 
@@ -4065,6 +4080,7 @@
 "   c-index-test -test-inclusion-stack-tu \n");
   fprintf(stderr,
 "   c-index-test -test-print-linkage-source {}*\n"
+"   c-index-test -test-print-is-local-var {}*\n"
 "   c-index-test -test-print-type {}*\n"
 "   c-index-test -test-print-type-size {}*\n"
 "   c-index-test -test-print-bitwidth {}*\n"
@@ -4152,6 +4168,9 @@
   else if (argc > 2 && strcmp(argv[1], "-test-print-linkage-source") == 0)
 return perform_test_load_source(argc - 2, argv + 2, "all", PrintLinkage,
 NULL);
+	else if (argc > 2 && strcmp(argv[1], "-test-print-is-local-var") == 0)
+return perform_test_load_source(argc - 2, argv + 2, "all", PrintIsLocalVarDecl,
+NULL);
   else if (argc > 2 && strcmp(argv[1], "-test-print-type") == 0)
 return perform_test_load_source(argc - 2, argv + 2, "all",
 PrintType, 0);
Index: test/Index/islocalvardecl.cpp
===
--- /dev/null
+++ test/Index/islocalvardecl.cpp
@@ -0,0 +1,32 @@
+// RUN: c-index-test -test-print-local-var-kind %s | FileCheck %s
+
+extern "C" {
+  int var0;
+  static int var1;
+
+  void func(void){
+static int var2;
+int var3;
+  }
+};
+
+int var4;
+
+class Classy {
+  static int var5;
+
+  void member(){
+int var6;
+static int var7;
+  }
+};
+
+// CHECK: VarDecl=var0:3:5 (Definition) IsLocalVarDecl=0
+// CHECK: VarDecl=var1:4:12 (Definition) IsLocalVarDecl=0
+// CHECK: VarDecl=var2:7:14 (Definition) IsLocalVarDecl=1
+// CHECK: VarDecl=var3:8:7 (Definition) IsLocalVarDecl=1
+// CHECK: VarDecl=var4:13:5 (Definition) IsLocalVarDecl=0
+// CHECK: VarDecl=var5:17:12 IsLocalVarDecl=0
+// CHECK: VarDecl=var6:20:9 (Definition) IsLocalVarDecl=1
+// CHECK: VarDecl=var7:21:16 (Definition) IsLocalVarDecl=1
+
Index: include/clang-c/Index.h
===
--- include/clang-c/Index.h
+++ include/clang-c/Index.h
@@ -3829,6 +3829,11 @@
 CINDEX_LINKAGE unsigned clang_Cursor_isVariadic(CXCursor C);
 
 /**
+ * \brief Returns non-zero if the Cursor refers to a local VarDecl.
+ 

Re: [PATCH] D13786: [Sema] Implement __make_integer_seq

2015-11-03 Thread David Majnemer via cfe-commits
majnemer updated this revision to Diff 39145.
majnemer added a comment.

- Add an llvm_unreachable to ASTDeclReader::VisitBuiltinTemplateDecl
- Address Richard's review comments.
- Add logic to check [intseq.intseq]p1.
- Remove TemplateName::BuiltinTemplate
- Rename BuiltinTemplateNameKind to BuiltinTemplateKind
- Make __make_integer_seq parameters as implicit
- Remove Sema::Ident___make_integer_seq
- Remove extraneous whitespace change
- Add test for __make_integer_seq
- Address Richard's review feedback


http://reviews.llvm.org/D13786

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/DataRecursiveASTVisitor.h
  include/clang/AST/DeclTemplate.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/Basic/Builtins.h
  include/clang/Basic/DeclNodes.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTContext.cpp
  lib/AST/ASTDumper.cpp
  lib/AST/DeclBase.cpp
  lib/AST/DeclTemplate.cpp
  lib/CodeGen/CGDecl.cpp
  lib/Sema/SemaLookup.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Serialization/ASTCommon.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriter.cpp
  test/SemaCXX/make_integer_seq.cpp
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -5110,6 +5110,7 @@
   case Decl::Import:
   case Decl::OMPThreadPrivate:
   case Decl::ObjCTypeParam:
+  case Decl::BuiltinTemplate:
 return C;
 
   // Declaration kinds that don't make any sense here, but are
Index: test/SemaCXX/make_integer_seq.cpp
===
--- /dev/null
+++ test/SemaCXX/make_integer_seq.cpp
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+template 
+struct Seq {
+  static constexpr T PackSize = sizeof...(I);
+};
+
+template 
+using MakeSeq = __make_integer_seq;
+
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+
+template 
+using ErrorSeq = __make_integer_seq; // expected-error{{must have non-negative sequence length}} \
+   expected-error{{must have integral element type}}
+
+enum Color : int { Red,
+   Green,
+   Blue };
+using illformed1 = ErrorSeq; // expected-note{{in instantiation}}
+
+using illformed2 = ErrorSeq;
+
+template  void f() {}
+__make_integer_seq x; // expected-error{{template template parameter must be a class template or type alias template}}
Index: lib/Serialization/ASTWriter.cpp
===
--- lib/Serialization/ASTWriter.cpp
+++ lib/Serialization/ASTWriter.cpp
@@ -4136,6 +4136,8 @@
   RegisterPredefDecl(Context.BuiltinMSVaListDecl,
  PREDEF_DECL_BUILTIN_MS_VA_LIST_ID);
   RegisterPredefDecl(Context.ExternCContext, PREDEF_DECL_EXTERN_C_CONTEXT_ID);
+  RegisterPredefDecl(Context.MakeIntegerSeqDecl,
+ PREDEF_DECL_MAKE_INTEGER_SEQ_ID);
 
   // Build a record containing all of the tentative definitions in this file, in
   // TentativeDefinitions order.  Generally, this record will be empty for
Index: lib/Serialization/ASTReaderDecl.cpp
===
--- lib/Serialization/ASTReaderDecl.cpp
+++ lib/Serialization/ASTReaderDecl.cpp
@@ -293,6 +293,7 @@
 DeclID VisitTemplateDecl(TemplateDecl *D);
 RedeclarableResult VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D);
 void VisitClassTemplateDecl(ClassTemplateDecl *D);
+void VisitBuiltinTemplateDecl(BuiltinTemplateDecl *D);
 void VisitVarTemplateDecl(VarTemplateDecl *D);
 void VisitFunctionTemplateDecl(FunctionTemplateDecl *D);
 void VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D);
@@ -1856,6 +1857,10 @@
   }
 }
 
+void 

[PATCH] D14316: [Concepts] Add diagnostics which fall under [dcl.spec.concept]p1

2015-11-03 Thread Nathan Wilson via cfe-commits
nwilson created this revision.
nwilson added reviewers: rsmith, hubert.reinterpretcast, aaron.ballman, faisalv.
nwilson added a subscriber: cfe-commits.

Diagnose when the 'concept' specifier is used on a typedef or function 
parameter.

http://reviews.llvm.org/D14316

Files:
  lib/Sema/SemaDecl.cpp
  test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp

Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
===
--- test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
@@ -37,5 +37,7 @@
 template  concept class TCC1 {}; // expected-error {{'concept' can 
only appear on the definition of a function template or variable template}}
 template  concept struct TCS1 {}; // expected-error {{'concept' 
can only appear on the definition of a function template or variable template}}
 template  concept union TCU1 {}; // expected-error {{'concept' can 
only appear on the definition of a function template or variable template}}
+typedef concept int CI; // expected-error {{'concept' can only appear on the 
definition of a function template or variable template}}
+void fpc(concept int i) {} // expected-error {{'concept' can only appear on 
the definition of a function template or variable template}}
 
 concept bool; // expected-error {{'concept' can only appear on the definition 
of a function template or variable template}}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -5119,6 +5119,9 @@
   if (D.getDeclSpec().isConstexprSpecified())
 Diag(D.getDeclSpec().getConstexprSpecLoc(), diag::err_invalid_constexpr)
   << 1;
+  if (D.getDeclSpec().isConceptSpecified())
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_wrong_decl_kind);
 
   if (D.getName().Kind != UnqualifiedId::IK_Identifier) {
 Diag(D.getName().StartLocation, diag::err_typedef_not_identifier)
@@ -10277,6 +10280,8 @@
   if (DS.isConstexprSpecified())
 Diag(DS.getConstexprSpecLoc(), diag::err_invalid_constexpr)
   << 0;
+  if (DS.isConceptSpecified())
+Diag(DS.getConceptSpecLoc(), diag::err_concept_wrong_decl_kind);
 
   DiagnoseFunctionSpecifiers(DS);
 


Index: test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
===
--- test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
+++ test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
@@ -37,5 +37,7 @@
 template  concept class TCC1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
 template  concept struct TCS1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
 template  concept union TCU1 {}; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
+typedef concept int CI; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
+void fpc(concept int i) {} // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
 
 concept bool; // expected-error {{'concept' can only appear on the definition of a function template or variable template}}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -5119,6 +5119,9 @@
   if (D.getDeclSpec().isConstexprSpecified())
 Diag(D.getDeclSpec().getConstexprSpecLoc(), diag::err_invalid_constexpr)
   << 1;
+  if (D.getDeclSpec().isConceptSpecified())
+Diag(D.getDeclSpec().getConceptSpecLoc(),
+ diag::err_concept_wrong_decl_kind);
 
   if (D.getName().Kind != UnqualifiedId::IK_Identifier) {
 Diag(D.getName().StartLocation, diag::err_typedef_not_identifier)
@@ -10277,6 +10280,8 @@
   if (DS.isConstexprSpecified())
 Diag(DS.getConstexprSpecLoc(), diag::err_invalid_constexpr)
   << 0;
+  if (DS.isConceptSpecified())
+Diag(DS.getConceptSpecLoc(), diag::err_concept_wrong_decl_kind);
 
   DiagnoseFunctionSpecifiers(DS);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14316: [Concepts] Add diagnostics which fall under [dcl.spec.concept]p1

2015-11-03 Thread Hubert Tong via cfe-commits
hubert.reinterpretcast accepted this revision.
hubert.reinterpretcast added a comment.
This revision is now accepted and ready to land.

LGTM


http://reviews.llvm.org/D14316



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


Re: [PATCH] D13786: [Sema] Implement __make_integer_seq

2015-11-03 Thread David Majnemer via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL252036: [Sema] Implement __make_integer_seq (authored by 
majnemer).

Changed prior to commit:
  http://reviews.llvm.org/D13786?vs=39153=39154#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13786

Files:
  cfe/trunk/include/clang/AST/ASTContext.h
  cfe/trunk/include/clang/AST/DataRecursiveASTVisitor.h
  cfe/trunk/include/clang/AST/DeclTemplate.h
  cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
  cfe/trunk/include/clang/Basic/Builtins.h
  cfe/trunk/include/clang/Basic/DeclNodes.td
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/include/clang/Serialization/ASTBitCodes.h
  cfe/trunk/lib/AST/ASTContext.cpp
  cfe/trunk/lib/AST/ASTDumper.cpp
  cfe/trunk/lib/AST/DeclBase.cpp
  cfe/trunk/lib/AST/DeclTemplate.cpp
  cfe/trunk/lib/CodeGen/CGDecl.cpp
  cfe/trunk/lib/Sema/SemaLookup.cpp
  cfe/trunk/lib/Sema/SemaTemplate.cpp
  cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
  cfe/trunk/lib/Serialization/ASTCommon.cpp
  cfe/trunk/lib/Serialization/ASTReader.cpp
  cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
  cfe/trunk/lib/Serialization/ASTWriter.cpp
  cfe/trunk/test/PCH/make-integer-seq.cpp
  cfe/trunk/test/SemaCXX/make_integer_seq.cpp
  cfe/trunk/tools/libclang/CIndex.cpp

Index: cfe/trunk/test/PCH/make-integer-seq.cpp
===
--- cfe/trunk/test/PCH/make-integer-seq.cpp
+++ cfe/trunk/test/PCH/make-integer-seq.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -std=c++14 -x c++-header %s -emit-pch -o %t.pch
+// RUN: %clang_cc1 -std=c++14 -x c++ /dev/null -include-pch %t.pch
+
+template 
+struct Seq {
+static constexpr T PackSize = sizeof...(I);
+};
+
+template 
+using MakeSeq = __make_integer_seq;
+
+void fn1() {
+  MakeSeq x;
+}
Index: cfe/trunk/test/SemaCXX/make_integer_seq.cpp
===
--- cfe/trunk/test/SemaCXX/make_integer_seq.cpp
+++ cfe/trunk/test/SemaCXX/make_integer_seq.cpp
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+template 
+struct Seq {
+  static constexpr T PackSize = sizeof...(I);
+};
+
+template 
+using MakeSeq = __make_integer_seq;
+
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+static_assert(__is_same(MakeSeq, Seq), "");
+
+template 
+using ErrorSeq = __make_integer_seq; // expected-error{{must have non-negative sequence length}} \
+   expected-error{{must have integral element type}}
+
+enum Color : int { Red,
+   Green,
+   Blue };
+using illformed1 = ErrorSeq; // expected-note{{in instantiation}}
+
+using illformed2 = ErrorSeq;
+
+template  void f() {}
+__make_integer_seq x; // expected-error{{template template parameter must be a class template or type alias template}}
Index: cfe/trunk/lib/CodeGen/CGDecl.cpp
===
--- cfe/trunk/lib/CodeGen/CGDecl.cpp
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp
@@ -35,6 +35,7 @@
 
 void CodeGenFunction::EmitDecl(const Decl ) {
   switch (D.getKind()) {
+  case Decl::BuiltinTemplate:
   case Decl::TranslationUnit:
   case Decl::ExternCContext:
   case Decl::Namespace:
Index: cfe/trunk/lib/AST/ASTDumper.cpp
===
--- cfe/trunk/lib/AST/ASTDumper.cpp
+++ cfe/trunk/lib/AST/ASTDumper.cpp
@@ -21,6 +21,7 @@
 #include "clang/AST/DeclVisitor.h"
 #include "clang/AST/StmtVisitor.h"
 #include "clang/AST/TypeVisitor.h"
+#include "clang/Basic/Builtins.h"
 #include "clang/Basic/Module.h"
 #include "clang/Basic/SourceManager.h"
 #include "llvm/Support/raw_ostream.h"
@@ -447,6 +448,7 @@
 const ClassTemplatePartialSpecializationDecl *D);
 void VisitClassScopeFunctionSpecializationDecl(
 const ClassScopeFunctionSpecializationDecl *D);
+void VisitBuiltinTemplateDecl(const BuiltinTemplateDecl *D);
 void VisitVarTemplateDecl(const 

Re: [PATCH] D14293: [libcxx] Add -fno-exceptions libcxx builders to zorg

2015-11-03 Thread Asiri Rathnayake via cfe-commits
rmaprath added inline comments.


Comment at: buildbot/osuosl/master/config/builders.py:874
@@ -842,1 +873,3 @@
   'CMAKE_CXX_FLAGS': '-mcpu=cortex-a15'})},
+
+# Cortex-A15 -fno-exceptions libcxx build (skips libcxx tests)

rengolin wrote:
> I'd like to run this internally first, as I'm not sure it will work. I'll use 
> this configuration and will let you know if it's ok.
> 
> We should only put this up if it's totally green.
Thanks! The newly added Debian configuration is quite similar to the 
configuration I ran locally. I have run some ARM configurations but it is best 
to run this particular configuration if possible.

You'd need the patch for D14292 though. I was hoping to get it committed first, 
so that these configs can be verified easily.


http://reviews.llvm.org/D14293



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


Re: [PATCH] D12031: Const std::move() argument ClangTidy check

2015-11-03 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/misc/MoveConstantArgumentCheck.cpp:22
@@ +21,3 @@
+  bool IsTypeDependOnTemplateParameter =
+  false;  // my first guess was type->getTypeClass () == 30 but it doesn't
+  // work in some cases. Could you please advice better solution.

aaron.ballman wrote:
> Arg->getType()->isDependentType() should do what you want, if I understand 
> you properly.
Yep, should be what you need.


Comment at: clang-tidy/misc/MoveConstantArgumentCheck.cpp:30
@@ +29,3 @@
+bool IsVariable = dyn_cast(Arg) != nullptr;
+std::string message = "std::move of the ";
+message += IsConstArg ? "const " : "";

Please don't string += as a way to build messages. This creates a temporary 
each time and reallocates the string buffer. Use one of the these:
  
  std::string message = (llvm::Twine("...") + "..." + "...").str()

(only in a single expression, i.e. don't create variables of the llvm::Twine 
type, as this can lead to dangling string references), or:

  std::string buffer;
  llvm::raw_string_ostream message(buffer);
  message << "...";
  message << "...";
  // then use message.str() where you would use an std::string.

The second alternative would be more suitable for this kind of code.

BUT, even this is not needed in the specific case of producing diagnostics, as 
clang provides a powerful template substitution mechanism, and your code could 
be written more effectively:

  diag("std::move of the %select{const |}0 %select{variable|expression}1 ...") 
<< IsConstArg << IsVariable << ...;


Comment at: clang-tidy/misc/MoveConstantArgumentCheck.cpp:39
@@ +38,3 @@
+
+SourceRange RemoveRange1(CallMove->getLocStart(), Arg->getLocStart());
+SourceRange RemoveRange2(CallMove->getLocEnd(), CallMove->getLocEnd());

The variable names don't add much value here. Either remove the variables and 
use the expressions below or give the variables more useful names. Also note 
that `SourceRange` can be constructed from a single token 
(`SourceRange(CallMove->getLocEnd())`).


Comment at: test/clang-tidy/move-const-arg.cpp:1
@@ +1,2 @@
+// RUN: $(dirname %s)/check_clang_tidy.sh %s misc-move-const-arg %t
+

This has changed once more, now `%check_clang_tidy` should be used instead of 
the script itself. Please also rebase the patch on top of current HEAD.


Comment at: test/clang-tidy/move-const-arg.cpp:4
@@ +3,3 @@
+namespace std {
+// Directly copied from the stl.
+template

The comment is not useful here. This is a mock implementation, and it's not 
important where does this come from. Please also clang-format the test with 
`-style=file` (to pick up formatting options specific to tests, namely 
unlimited columns limit).


Comment at: test/clang-tidy/move-const-arg.cpp:30
@@ +29,3 @@
+  A() {}
+  A(const A& rhs) {}
+  A(A&& rhs) {}

How did you find that `Arg->getType()->isDependentType()` doesn't work?


http://reviews.llvm.org/D12031



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


Re: [PATCH] D13388: Add support for querying the visibility of a cursor

2015-11-03 Thread Sergey Kalinichev via cfe-commits
skalinichev added a comment.

Well, I think it's ok then. Still there is no test for visibility set from 
command line case. 
Also adding comment to clang_getCursorVisibility explaining that it also works 
with visibility set from command line would be very useful.



Comment at: test/Index/symbol-visibility.c:8
@@ +7,3 @@
+// CHECK: FunctionDecl=foo1:3:47visibility=Default
+// CHECK: FunctionDecl=foo2:4:49visibility=Protected
+// CHECK: FunctionDecl=foo3:5:46visibility=Hidden

Are you sure that this is correct?
Looking at r246931, it seems like the protected visibility is not supported on 
all platforms.


http://reviews.llvm.org/D13388



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


Re: [PATCH] D13844: [libclang] Visit TypeAliasTemplateDecl

2015-11-03 Thread Sergey Kalinichev via cfe-commits
skalinichev added a comment.

Yes, I have commit acces now (didn't test it yet though). I'll try to submit 
this patch soon.

Thanks!


http://reviews.llvm.org/D13844



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


r251930 - Remove some legacy mingw-w64 gcc struct info

2015-11-03 Thread Martell Malone via cfe-commits
Author: martell
Date: Tue Nov  3 09:57:45 2015
New Revision: 251930

URL: http://llvm.org/viewvc/llvm-project?rev=251930=rev
Log:
Remove some legacy mingw-w64 gcc struct info

As of gcc 4.7 mingw-w64 no longer emits 128-bit structs as i128

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

Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=251930=251929=251930=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Tue Nov  3 09:57:45 2015
@@ -,10 +,6 @@ ABIArgInfo WinX86_64ABIInfo::classify(Qu
 if (RT->getDecl()->hasFlexibleArrayMember())
   return getNaturalAlignIndirect(Ty, /*ByVal=*/false);
 
-// FIXME: mingw-w64-gcc emits 128-bit struct as i128
-if (Width == 128 && IsMingw64)
-  return ABIArgInfo::getDirect(
-  llvm::IntegerType::get(getVMContext(), Width));
   }
 
   // vectorcall adds the concept of a homogenous vector aggregate, similar to


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


[PATCH] D14289: Handle correctly containers that are data members in modernize-loop-convert.

2015-11-03 Thread Angel Garcia via cfe-commits
angelgarcia created this revision.
angelgarcia added a reviewer: klimek.
angelgarcia added subscribers: alexfh, cfe-commits.

I recently found that the variable naming wasn't working as expected with 
containers that are data members. The new index always received the name "Elem" 
(or equivalent) regardless of the container's name.
The check was assuming that the container's declaration was a VarDecl, which 
cannot be converted to a FieldDecl (a data member), and then it could never 
retrieve its name.

This also fixes some cases where the check failed to find the container at all 
(so it didn't do any fix) because of the same reason.

http://reviews.llvm.org/D14289

Files:
  clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tidy/modernize/LoopConvertCheck.h
  clang-tidy/modernize/LoopConvertUtils.h
  test/clang-tidy/modernize-loop-convert-basic.cpp
  test/clang-tidy/modernize-loop-convert-extra.cpp
  test/clang-tidy/modernize-loop-convert-negative.cpp

Index: test/clang-tidy/modernize-loop-convert-negative.cpp
===
--- test/clang-tidy/modernize-loop-convert-negative.cpp
+++ test/clang-tidy/modernize-loop-convert-negative.cpp
@@ -92,33 +92,6 @@
   }
 }
 
-struct HasArr {
-  int Arr[N];
-  Val ValArr[N];
-};
-
-struct HasIndirectArr {
-  HasArr HA;
-  void implicitThis() {
-for (int I = 0; I < N; ++I) {
-  printf("%d", HA.Arr[I]);
-}
-
-for (int I = 0; I < N; ++I) {
-  printf("%d", HA.ValArr[I].X);
-}
-  }
-
-  void explicitThis() {
-for (int I = 0; I < N; ++I) {
-  printf("%d", this->HA.Arr[I]);
-}
-
-for (int I = 0; I < N; ++I) {
-  printf("%d", this->HA.ValArr[I].X);
-}
-  }
-};
 }
 
 namespace NegativeIterator {
Index: test/clang-tidy/modernize-loop-convert-extra.cpp
===
--- test/clang-tidy/modernize-loop-convert-extra.cpp
+++ test/clang-tidy/modernize-loop-convert-extra.cpp
@@ -237,6 +237,26 @@
   }
 }
 
+struct MemberNaming {
+  const static int N = 10;
+  int Ints[N], Ints_[N];
+  void loops() {
+for (int I = 0; I < N; ++I) {
+  printf("%d\n", Ints[I]);
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:5: warning: use range-based for loop instead
+// CHECK-FIXES: for (int Int : Ints)
+// CHECK-FIXES-NEXT: printf("%d\n", Int);
+
+for (int I = 0; I < N; ++I) {
+  printf("%d\n", Ints_[I]);
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:5: warning: use range-based for loop instead
+// CHECK-FIXES: for (int Int : Ints_)
+// CHECK-FIXES-NEXT: printf("%d\n", Int);
+  }
+};
+
 } // namespace NamingAlias
 
 namespace NamingConlict {
Index: test/clang-tidy/modernize-loop-convert-basic.cpp
===
--- test/clang-tidy/modernize-loop-convert-basic.cpp
+++ test/clang-tidy/modernize-loop-convert-basic.cpp
@@ -168,6 +168,41 @@
   }
 };
 
+struct HasIndirectArr {
+  HasArr HA;
+  void implicitThis() {
+for (int I = 0; I < N; ++I) {
+  printf("%d", HA.Arr[I]);
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:5: warning: use range-based for loop instead
+// CHECK-FIXES: for (int Elem : HA.Arr)
+// CHECK-FIXES-NEXT: printf("%d", Elem);
+
+for (int I = 0; I < N; ++I) {
+  printf("%d", HA.ValArr[I].X);
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:5: warning: use range-based for loop instead
+// CHECK-FIXES: for (auto & Elem : HA.ValArr)
+// CHECK-FIXES-NEXT: printf("%d", Elem.X);
+  }
+
+  void explicitThis() {
+for (int I = 0; I < N; ++I) {
+  printf("%d", this->HA.Arr[I]);
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:5: warning: use range-based for loop instead
+// CHECK-FIXES: for (int Elem : this->HA.Arr)
+// CHECK-FIXES-NEXT: printf("%d", Elem);
+
+for (int I = 0; I < N; ++I) {
+  printf("%d", this->HA.ValArr[I].X);
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:5: warning: use range-based for loop instead
+// CHECK-FIXES: for (auto & Elem : this->HA.ValArr)
+// CHECK-FIXES-NEXT: printf("%d", Elem.X);
+  }
+};
+
 // Loops whose bounds are value-dependent should not be converted.
 template 
 void dependentExprBound() {
Index: clang-tidy/modernize/LoopConvertUtils.h
===
--- clang-tidy/modernize/LoopConvertUtils.h
+++ clang-tidy/modernize/LoopConvertUtils.h
@@ -425,7 +425,7 @@
   VariableNamer(StmtGeneratedVarNameMap *GeneratedDecls,
 const StmtParentMap *ReverseAST, const clang::Stmt *SourceStmt,
 const clang::VarDecl *OldIndex,
-const clang::VarDecl *TheContainer,
+const clang::ValueDecl *TheContainer,
 const clang::ASTContext *Context, NamingStyle Style)
   : GeneratedDecls(GeneratedDecls), ReverseAST(ReverseAST),
 SourceStmt(SourceStmt), OldIndex(OldIndex), TheContainer(TheContainer),
@@ -443,7 +443,7 @@
   const StmtParentMap *ReverseAST;
   const 

Re: [PATCH] D14282: Improve more the const-detection in modernize-loop-convert.

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

lg


http://reviews.llvm.org/D14282



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


Re: [PATCH] D14179: Remove some legacy mingw-w64 gcc struct info

2015-11-03 Thread Martell Malone via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL251930: Remove some legacy mingw-w64 gcc struct info 
(authored by martell).

Changed prior to commit:
  http://reviews.llvm.org/D14179?vs=38744=39067#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14179

Files:
  cfe/trunk/lib/CodeGen/TargetInfo.cpp

Index: cfe/trunk/lib/CodeGen/TargetInfo.cpp
===
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp
@@ -,10 +,6 @@
 if (RT->getDecl()->hasFlexibleArrayMember())
   return getNaturalAlignIndirect(Ty, /*ByVal=*/false);
 
-// FIXME: mingw-w64-gcc emits 128-bit struct as i128
-if (Width == 128 && IsMingw64)
-  return ABIArgInfo::getDirect(
-  llvm::IntegerType::get(getVMContext(), Width));
   }
 
   // vectorcall adds the concept of a homogenous vector aggregate, similar to


Index: cfe/trunk/lib/CodeGen/TargetInfo.cpp
===
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp
@@ -,10 +,6 @@
 if (RT->getDecl()->hasFlexibleArrayMember())
   return getNaturalAlignIndirect(Ty, /*ByVal=*/false);
 
-// FIXME: mingw-w64-gcc emits 128-bit struct as i128
-if (Width == 128 && IsMingw64)
-  return ABIArgInfo::getDirect(
-  llvm::IntegerType::get(getVMContext(), Width));
   }
 
   // vectorcall adds the concept of a homogenous vector aggregate, similar to
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2015-11-03 Thread Aleksei Sidorin via cfe-commits
a.sidorin created this revision.
a.sidorin added a reviewer: sepavloff.
a.sidorin added a subscriber: cfe-commits.
a.sidorin set the repository for this revision to rL LLVM.

This patch implements some expression-related AST node import. This is the 
first patch in a series.

Supported nodes:
GCCAsmStmt
VAArgExpr
GNUNullExpr
PredefinedExpr
InitListExpr
DesignatedInitExpr
CXXNullPtrLiteralExpr
CXXBoolLiteralExpr
CompoundLiteralExpr
AtomicExpr
AddrLabelExpr
ParenListExpr
StmtExpr
ConditionalOperator
BinaryConditionalOperator


Repository:
  rL LLVM

http://reviews.llvm.org/D14286

Files:
  lib/AST/ASTImporter.cpp

Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -29,7 +29,29 @@
   public DeclVisitor,
   public StmtVisitor {
 ASTImporter 
-
+
+template
+void ImportMultipleItems(IIter Ibegin, IIter Iend, OIter Obegin) {
+  ASTImporter &_Importer = Importer;
+  std::transform(Ibegin, Iend, Obegin,
+[&_Importer](ItemT I) -> ItemT {
+  return _Importer.Import(I);
+});
+}
+
+template
+bool checkNull(IIter Ibegin, IIter Iend) {
+  return std::find(Ibegin, Iend, nullptr) == Iend;
+}
+
+template
+bool checkPossibleNull(IIter Ibegin, IIter Iend, OIter Obegin) {
+  for (; Ibegin != Iend; Ibegin++, Obegin++)
+if (*Obegin == nullptr && Ibegin != nullptr)
+  return false;
+  return true;
+}
+
   public:
 explicit ASTNodeImporter(ASTImporter ) : Importer(Importer) { }
 
@@ -86,6 +108,10 @@
 void ImportDeclarationNameLoc(const DeclarationNameInfo ,
   DeclarationNameInfo& To);
 void ImportDeclContext(DeclContext *FromDC, bool ForceImport = false);
+
+typedef DesignatedInitExpr::Designator Designator;
+Designator ImportDesignator(const Designator );
+
 
 /// \brief What we should import from the definition.
 enum ImportDefinitionKind { 
@@ -174,6 +200,7 @@
 DeclGroupRef ImportDeclGroup(DeclGroupRef DG);
 
 Stmt *VisitStmt(Stmt *S);
+Stmt *VisitGCCAsmStmt(GCCAsmStmt *S);
 Stmt *VisitDeclStmt(DeclStmt *S);
 Stmt *VisitNullStmt(NullStmt *S);
 Stmt *VisitCompoundStmt(CompoundStmt *S);
@@ -191,7 +218,6 @@
 Stmt *VisitContinueStmt(ContinueStmt *S);
 Stmt *VisitBreakStmt(BreakStmt *S);
 Stmt *VisitReturnStmt(ReturnStmt *S);
-// FIXME: GCCAsmStmt
 // FIXME: MSAsmStmt
 // FIXME: SEHExceptStmt
 // FIXME: SEHFinallyStmt
@@ -212,13 +238,29 @@
 
 // Importing expressions
 Expr *VisitExpr(Expr *E);
+Expr *VisitVAArgExpr(VAArgExpr *E);
+Expr *VisitGNUNullExpr(GNUNullExpr *E);
+Expr *VisitPredefinedExpr(PredefinedExpr *E);
 Expr *VisitDeclRefExpr(DeclRefExpr *E);
+Expr *VisitInitListExpr(InitListExpr *ILE);
+Expr *VisitDesignatedInitExpr(DesignatedInitExpr *E);
+Expr *VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E);
+Expr *VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E);
 Expr *VisitIntegerLiteral(IntegerLiteral *E);
+Expr *VisitFloatingLiteral(FloatingLiteral *E);
 Expr *VisitCharacterLiteral(CharacterLiteral *E);
+Expr *VisitStringLiteral(StringLiteral *E);
+Expr *VisitCompoundLiteralExpr(CompoundLiteralExpr *E);
+Expr *VisitAtomicExpr(AtomicExpr *E);
+Expr *VisitAddrLabelExpr(AddrLabelExpr *E);
 Expr *VisitParenExpr(ParenExpr *E);
+Expr *VisitParenListExpr(ParenListExpr *E);
+Expr *VisitStmtExpr(StmtExpr *E);
 Expr *VisitUnaryOperator(UnaryOperator *E);
 Expr *VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E);
 Expr *VisitBinaryOperator(BinaryOperator *E);
+Expr *VisitConditionalOperator(ConditionalOperator *E);
+Expr *VisitBinaryConditionalOperator(BinaryConditionalOperator *E);
 Expr *VisitCompoundAssignOperator(CompoundAssignOperator *E);
 Expr *VisitImplicitCastExpr(ImplicitCastExpr *E);
 Expr *VisitCStyleCastExpr(CStyleCastExpr *E);
@@ -4591,7 +4633,84 @@
  << S->getStmtClassName();
return nullptr;
  }
- 
+
+
+Stmt *ASTNodeImporter::VisitGCCAsmStmt(GCCAsmStmt *S) {
+  SmallVector Names;
+  for (unsigned i = 0, e = S->getNumOutputs(); i != e; i++) {
+IdentifierInfo *ToII = Importer.Import(S->getOutputIdentifier(i));
+if (!ToII && S->getOutputIdentifier(i))
+  return nullptr;
+Names.push_back(ToII);
+  }
+  for (unsigned i = 0, e = S->getNumInputs(); i != e; i++) {
+IdentifierInfo *ToII = Importer.Import(S->getInputIdentifier(i));
+if (!ToII && S->getInputIdentifier(i))
+  return nullptr;
+Names.push_back(ToII);
+  }
+
+  SmallVector Clobbers;
+  for (unsigned i = 0, e = S->getNumClobbers(); i != e; i++) {
+StringLiteral *Clobber = cast_or_null(
+  Importer.Import(S->getClobberStringLiteral(i)));
+if (!Clobber)
+  

Re: [PATCH] D14180: enable -fms-extensions by default on the mingw-w64 target

2015-11-03 Thread Martell Malone via cfe-commits
martell added a comment.

In http://reviews.llvm.org/D14180#279651, @rnk wrote:

> Will Clang be able to compile the last few stable mingw-w64 releases with 
> this change? I'd like that to keep working.


Clang has not been able to compile mingw-w64 crt for the last few releases.
I have only added support for this on HEAD.

There would be a drawback though.
Clang would not like older mingw-w64 headers.


http://reviews.llvm.org/D14180



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


[PATCH] D14282: Improve more the const-detection in modernize-loop-convert.

2015-11-03 Thread Angel Garcia via cfe-commits
angelgarcia created this revision.
angelgarcia added a reviewer: klimek.
angelgarcia added subscribers: cfe-commits, alexfh.

The previous change was focused in detecting when a non-const object was used 
in a constant way. Looks like I forgot the most important and trivial case: 
when the object is already constant. Failing to detect this cases results in 
compile errors, due to trying to bind a constant object to a non-const 
reference in the range-for statement. This change should fix that.

http://reviews.llvm.org/D14282

Files:
  clang-tidy/modernize/LoopConvertCheck.cpp
  test/clang-tidy/modernize-loop-convert-const.cpp

Index: test/clang-tidy/modernize-loop-convert-const.cpp
===
--- test/clang-tidy/modernize-loop-convert-const.cpp
+++ test/clang-tidy/modernize-loop-convert-const.cpp
@@ -271,28 +271,91 @@
   // Aliases.
   for (int I = 0; I < N; ++I) {
 const Str  = Array[I];
-(void) J;
+(void)J;
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop
   // CHECK-FIXES: for (auto J : Array)
   for (int I = 0; I < N; ++I) {
 Str  = Array[I];
-(void) J;
+(void)J;
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop
   // CHECK-FIXES: for (auto & J : Array)
 
   for (int I = 0; I < N; ++I) {
 const int  = Ints[I];
-(void) J;
+(void)J;
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop
   // CHECK-FIXES: for (int J : Ints)
 
   for (int I = 0; I < N; ++I) {
 int  = Ints[I];
-(void) J;
+(void)J;
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop
   // CHECK-FIXES: for (int & J : Ints)
 }
+
+template 
+struct vector {
+  unsigned size() const;
+  const T [](int) const;
+  T [](int);
+  T *begin();
+  T *end();
+  const T *begin() const;
+  const T *end() const;
+};
+
+// If the elements are already constant, we won't do any ImplicitCast to const.
+void testContainerOfConstElements() {
+  const int Ints[N]{};
+  for (int I = 0; I < N; ++I) {
+OtherInt -= Ints[I];
+  }
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop
+  // CHECK-FIXES: for (int Int : Ints)
+
+  vector Strs;
+  for (int I = 0; I < Strs.size(); ++I) {
+Strs[I].constMember(0);
+constRefArg(Strs[I]);
+  }
+  // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop
+  // CHECK-FIXES: for (auto Str : Strs)
+}
+
+// When we are inside a const-qualified member functions, all the data members
+// are implicitly set as const. As before, there won't be any ImplicitCast to
+// const in their usages.
+class TestInsideConstFunction {
+  const static int N = 10;
+  int Ints[N];
+  Str Array[N];
+  vector V;
+
+  void foo() const {
+for (int I = 0; I < N; ++I) {
+  if (Ints[I])
+copyArg(Ints[I]);
+}
+// CHECK-MESSAGES: :[[@LINE-4]]:5: warning: use range-based for loop
+// CHECK-FIXES: for (int Elem : Ints)
+
+for (int I = 0; I < N; ++I) {
+  Array[I].constMember(0);
+  constRefArg(Array[I]);
+}
+// CHECK-MESSAGES: :[[@LINE-4]]:5: warning: use range-based for loop
+// CHECK-FIXES: for (auto Elem : Array)
+
+for (int I = 0; I < V.size(); ++I) {
+  if (V[I])
+copyArg(V[I]);
+}
+// CHECK-MESSAGES: :[[@LINE-4]]:5: warning: use range-based for loop
+// CHECK-FIXES: for (int Elem : V)
+
+  }
+};
Index: clang-tidy/modernize/LoopConvertCheck.cpp
===
--- clang-tidy/modernize/LoopConvertCheck.cpp
+++ clang-tidy/modernize/LoopConvertCheck.cpp
@@ -372,6 +372,8 @@
 /// containter that we are iterating over, returns false when it can be
 /// guaranteed this element cannot be modified as a result of this usage.
 static bool canBeModified(ASTContext *Context, const Expr *E) {
+  if (E->getType().isConstQualified())
+return false;
   auto Parents = Context->getParents(*E);
   if (Parents.size() != 1)
 return true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14014: Checker of proper vfork usage

2015-11-03 Thread Yury Gribov via cfe-commits
ygribov updated this revision to Diff 39040.
ygribov added a comment.

Updated warning messages.


http://reviews.llvm.org/D14014

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
  lib/StaticAnalyzer/Checkers/VforkChecker.cpp
  lib/StaticAnalyzer/Core/CheckerHelpers.cpp
  test/Analysis/Inputs/system-header-simulator.h
  test/Analysis/vfork.c

Index: test/Analysis/vfork.c
===
--- /dev/null
+++ test/Analysis/vfork.c
@@ -0,0 +1,114 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.unix.Vfork -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.unix.Vfork -verify -x c++ %s
+
+#include "Inputs/system-header-simulator.h"
+
+void foo();
+
+// Ensure that child process is properly checked.
+int f1(int x) {
+  pid_t pid = vfork();
+  if (pid != 0)
+return 0;
+
+  switch (x) {
+  case 0:
+// Ensure that modifying pid is ok.
+pid = 1; // no-warning
+// Ensure that calling whitelisted routines is ok.
+execl("", "", 0); // no-warning
+_exit(1); // no-warning
+break;
+  case 1:
+// Ensure that writing variables is prohibited.
+x = 0; // expected-warning{{This assignment is prohibited after a successful vfork}}
+break;
+  case 2:
+// Ensure that calling functions is prohibited.
+foo(); // expected-warning{{This function call is prohibited after a successful vfork}}
+break;
+  default:
+// Ensure that returning from function is prohibited.
+return 0; // expected-warning{{Return is prohibited after a successful vfork; call _exit() instead}}
+  }
+
+  while(1);
+}
+
+// Same as previous but without explicit pid variable.
+int f2(int x) {
+  pid_t pid = vfork();
+
+  switch (x) {
+  case 0:
+// Ensure that writing pid is ok.
+pid = 1; // no-warning
+// Ensure that calling whitelisted routines is ok.
+execl("", "", 0); // no-warning
+_exit(1); // no-warning
+break;
+  case 1:
+// Ensure that writing variables is prohibited.
+x = 0; // expected-warning{{This assignment is prohibited after a successful vfork}}
+break;
+  case 2:
+// Ensure that calling functions is prohibited.
+foo(); // expected-warning{{This function call is prohibited after a successful vfork}}
+break;
+  default:
+// Ensure that returning from function is prohibited.
+return 0; // expected-warning{{Return is prohibited after a successful vfork; call _exit() instead}}
+  }
+
+  while(1);
+}
+
+// Ensure that parent process isn't restricted.
+int f3(int x) {
+  if (vfork() == 0)
+_exit(1);
+  x = 0; // no-warning
+  foo(); // no-warning
+  return 0;
+} // no-warning
+
+// Unbound pids are special so test them separately.
+void f4(int x) {
+  switch (x) {
+  case 0:
+vfork();
+x = 0; // expected-warning{{This assignment is prohibited after a successful vfork}}
+break;
+
+  case 1:
+{
+  char args[2];
+  switch (vfork()) {
+  case 0:
+args[0] = 0; // expected-warning{{This assignment is prohibited after a successful vfork}}
+exit(1);
+  }
+  break;
+}
+
+  case 2:
+{
+  pid_t pid;
+  if ((pid = vfork()) == 0)
+while(1); // no-warning
+  break;
+}
+  }
+  while(1);
+} //no-warning
+
+
+void f5() {
+  // See "libxtables: move some code to avoid cautions in vfork man page"
+  // (http://lists.netfilter.org/pipermail/netfilter-buglog/2014-October/003280.html).
+  if (vfork() == 0) {
+execl("prog", "arg1", 0); // no-warning
+exit(1);  // expected-warning{{This function call is prohibited after a successful vfork}}
+  }
+}
+
Index: test/Analysis/Inputs/system-header-simulator.h
===
--- test/Analysis/Inputs/system-header-simulator.h
+++ test/Analysis/Inputs/system-header-simulator.h
@@ -86,3 +86,13 @@
   char * p;
 } SomeStruct;
 void fakeSystemHeaderCall(SomeStruct *);
+
+typedef int pid_t;
+pid_t fork(void);
+pid_t vfork(void);
+int execl(const char *path, const char *arg, ...);
+
+void exit(int status) __attribute__ ((__noreturn__));
+void _exit(int status) __attribute__ ((__noreturn__));
+void _Exit(int status) __attribute__ ((__noreturn__));
+
Index: lib/StaticAnalyzer/Core/CheckerHelpers.cpp
===
--- lib/StaticAnalyzer/Core/CheckerHelpers.cpp
+++ lib/StaticAnalyzer/Core/CheckerHelpers.cpp
@@ -12,6 +12,7 @@
 //===--===//
 
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h"
+#include "clang/AST/Decl.h"
 #include "clang/AST/Expr.h"
 
 // Recursively find any substatements containing macros
@@ -70,3 +71,26 @@
 
   return false;
 }
+
+// Extract lhs and rhs from assignment statement
+std::pair

Re: [PATCH] D14014: Checker of proper vfork usage

2015-11-03 Thread Yury Gribov via cfe-commits
ygribov marked 2 inline comments as done.
ygribov added a comment.

http://reviews.llvm.org/D14014



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


[clang-tools-extra] r251940 - Improve more the const-detection in modernize-loop-convert.

2015-11-03 Thread Angel Garcia Gomez via cfe-commits
Author: angelgarcia
Date: Tue Nov  3 10:31:36 2015
New Revision: 251940

URL: http://llvm.org/viewvc/llvm-project?rev=251940=rev
Log:
Improve more the const-detection in modernize-loop-convert.

Summary: The previous change was focused in detecting when a non-const object 
was used in a constant way. Looks like I forgot the most important and trivial 
case: when the object is already constant. Failing to detect this cases results 
in compile errors, due to trying to bind a constant object to a non-const 
reference in the range-for statement. This change should fix that.

Reviewers: klimek

Subscribers: alexfh, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-const.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp?rev=251940=251939=251940=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp Tue Nov  
3 10:31:36 2015
@@ -372,6 +372,8 @@ static bool isDirectMemberExpr(const Exp
 /// containter that we are iterating over, returns false when it can be
 /// guaranteed this element cannot be modified as a result of this usage.
 static bool canBeModified(ASTContext *Context, const Expr *E) {
+  if (E->getType().isConstQualified())
+return false;
   auto Parents = Context->getParents(*E);
   if (Parents.size() != 1)
 return true;

Modified: 
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-const.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-const.cpp?rev=251940=251939=251940=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-const.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-const.cpp 
Tue Nov  3 10:31:36 2015
@@ -271,28 +271,91 @@ void takingReferences() {
   // Aliases.
   for (int I = 0; I < N; ++I) {
 const Str  = Array[I];
-(void) J;
+(void)J;
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop
   // CHECK-FIXES: for (auto J : Array)
   for (int I = 0; I < N; ++I) {
 Str  = Array[I];
-(void) J;
+(void)J;
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop
   // CHECK-FIXES: for (auto & J : Array)
 
   for (int I = 0; I < N; ++I) {
 const int  = Ints[I];
-(void) J;
+(void)J;
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop
   // CHECK-FIXES: for (int J : Ints)
 
   for (int I = 0; I < N; ++I) {
 int  = Ints[I];
-(void) J;
+(void)J;
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop
   // CHECK-FIXES: for (int & J : Ints)
 }
+
+template 
+struct vector {
+  unsigned size() const;
+  const T [](int) const;
+  T [](int);
+  T *begin();
+  T *end();
+  const T *begin() const;
+  const T *end() const;
+};
+
+// If the elements are already constant, we won't do any ImplicitCast to const.
+void testContainerOfConstElements() {
+  const int Ints[N]{};
+  for (int I = 0; I < N; ++I) {
+OtherInt -= Ints[I];
+  }
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop
+  // CHECK-FIXES: for (int Int : Ints)
+
+  vector Strs;
+  for (int I = 0; I < Strs.size(); ++I) {
+Strs[I].constMember(0);
+constRefArg(Strs[I]);
+  }
+  // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop
+  // CHECK-FIXES: for (auto Str : Strs)
+}
+
+// When we are inside a const-qualified member functions, all the data members
+// are implicitly set as const. As before, there won't be any ImplicitCast to
+// const in their usages.
+class TestInsideConstFunction {
+  const static int N = 10;
+  int Ints[N];
+  Str Array[N];
+  vector V;
+
+  void foo() const {
+for (int I = 0; I < N; ++I) {
+  if (Ints[I])
+copyArg(Ints[I]);
+}
+// CHECK-MESSAGES: :[[@LINE-4]]:5: warning: use range-based for loop
+// CHECK-FIXES: for (int Elem : Ints)
+
+for (int I = 0; I < N; ++I) {
+  Array[I].constMember(0);
+  constRefArg(Array[I]);
+}
+// CHECK-MESSAGES: :[[@LINE-4]]:5: warning: use range-based for loop
+// CHECK-FIXES: for (auto Elem : Array)
+
+for (int I = 0; I < V.size(); ++I) {
+  if (V[I])
+copyArg(V[I]);
+}
+// CHECK-MESSAGES: :[[@LINE-4]]:5: warning: use range-based for loop
+// CHECK-FIXES: for (int Elem : V)
+
+  }
+};


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


Re: [PATCH] D14282: Improve more the const-detection in modernize-loop-convert.

2015-11-03 Thread Angel Garcia via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL251940: Improve more the const-detection in 
modernize-loop-convert. (authored by angelgarcia).

Changed prior to commit:
  http://reviews.llvm.org/D14282?vs=39052=39074#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14282

Files:
  clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-const.cpp

Index: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
@@ -372,6 +372,8 @@
 /// containter that we are iterating over, returns false when it can be
 /// guaranteed this element cannot be modified as a result of this usage.
 static bool canBeModified(ASTContext *Context, const Expr *E) {
+  if (E->getType().isConstQualified())
+return false;
   auto Parents = Context->getParents(*E);
   if (Parents.size() != 1)
 return true;
Index: clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-const.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-const.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-const.cpp
@@ -271,28 +271,91 @@
   // Aliases.
   for (int I = 0; I < N; ++I) {
 const Str  = Array[I];
-(void) J;
+(void)J;
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop
   // CHECK-FIXES: for (auto J : Array)
   for (int I = 0; I < N; ++I) {
 Str  = Array[I];
-(void) J;
+(void)J;
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop
   // CHECK-FIXES: for (auto & J : Array)
 
   for (int I = 0; I < N; ++I) {
 const int  = Ints[I];
-(void) J;
+(void)J;
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop
   // CHECK-FIXES: for (int J : Ints)
 
   for (int I = 0; I < N; ++I) {
 int  = Ints[I];
-(void) J;
+(void)J;
   }
   // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop
   // CHECK-FIXES: for (int & J : Ints)
 }
+
+template 
+struct vector {
+  unsigned size() const;
+  const T [](int) const;
+  T [](int);
+  T *begin();
+  T *end();
+  const T *begin() const;
+  const T *end() const;
+};
+
+// If the elements are already constant, we won't do any ImplicitCast to const.
+void testContainerOfConstElements() {
+  const int Ints[N]{};
+  for (int I = 0; I < N; ++I) {
+OtherInt -= Ints[I];
+  }
+  // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop
+  // CHECK-FIXES: for (int Int : Ints)
+
+  vector Strs;
+  for (int I = 0; I < Strs.size(); ++I) {
+Strs[I].constMember(0);
+constRefArg(Strs[I]);
+  }
+  // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop
+  // CHECK-FIXES: for (auto Str : Strs)
+}
+
+// When we are inside a const-qualified member functions, all the data members
+// are implicitly set as const. As before, there won't be any ImplicitCast to
+// const in their usages.
+class TestInsideConstFunction {
+  const static int N = 10;
+  int Ints[N];
+  Str Array[N];
+  vector V;
+
+  void foo() const {
+for (int I = 0; I < N; ++I) {
+  if (Ints[I])
+copyArg(Ints[I]);
+}
+// CHECK-MESSAGES: :[[@LINE-4]]:5: warning: use range-based for loop
+// CHECK-FIXES: for (int Elem : Ints)
+
+for (int I = 0; I < N; ++I) {
+  Array[I].constMember(0);
+  constRefArg(Array[I]);
+}
+// CHECK-MESSAGES: :[[@LINE-4]]:5: warning: use range-based for loop
+// CHECK-FIXES: for (auto Elem : Array)
+
+for (int I = 0; I < V.size(); ++I) {
+  if (V[I])
+copyArg(V[I]);
+}
+// CHECK-MESSAGES: :[[@LINE-4]]:5: warning: use range-based for loop
+// CHECK-FIXES: for (int Elem : V)
+
+  }
+};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D14289: Handle correctly containers that are data members in modernize-loop-convert.

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

lg


http://reviews.llvm.org/D14289



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


Re: [PATCH] D14289: Handle correctly containers that are data members in modernize-loop-convert.

2015-11-03 Thread Angel Garcia via cfe-commits
angelgarcia updated this revision to Diff 39075.
angelgarcia added a comment.

Merge with the latest revision.


http://reviews.llvm.org/D14289

Files:
  clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tidy/modernize/LoopConvertCheck.h
  clang-tidy/modernize/LoopConvertUtils.h
  test/clang-tidy/modernize-loop-convert-basic.cpp
  test/clang-tidy/modernize-loop-convert-const.cpp
  test/clang-tidy/modernize-loop-convert-extra.cpp
  test/clang-tidy/modernize-loop-convert-negative.cpp

Index: test/clang-tidy/modernize-loop-convert-negative.cpp
===
--- test/clang-tidy/modernize-loop-convert-negative.cpp
+++ test/clang-tidy/modernize-loop-convert-negative.cpp
@@ -92,33 +92,6 @@
   }
 }
 
-struct HasArr {
-  int Arr[N];
-  Val ValArr[N];
-};
-
-struct HasIndirectArr {
-  HasArr HA;
-  void implicitThis() {
-for (int I = 0; I < N; ++I) {
-  printf("%d", HA.Arr[I]);
-}
-
-for (int I = 0; I < N; ++I) {
-  printf("%d", HA.ValArr[I].X);
-}
-  }
-
-  void explicitThis() {
-for (int I = 0; I < N; ++I) {
-  printf("%d", this->HA.Arr[I]);
-}
-
-for (int I = 0; I < N; ++I) {
-  printf("%d", this->HA.ValArr[I].X);
-}
-  }
-};
 }
 
 namespace NegativeIterator {
Index: test/clang-tidy/modernize-loop-convert-extra.cpp
===
--- test/clang-tidy/modernize-loop-convert-extra.cpp
+++ test/clang-tidy/modernize-loop-convert-extra.cpp
@@ -237,6 +237,26 @@
   }
 }
 
+struct MemberNaming {
+  const static int N = 10;
+  int Ints[N], Ints_[N];
+  void loops() {
+for (int I = 0; I < N; ++I) {
+  printf("%d\n", Ints[I]);
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:5: warning: use range-based for loop instead
+// CHECK-FIXES: for (int Int : Ints)
+// CHECK-FIXES-NEXT: printf("%d\n", Int);
+
+for (int I = 0; I < N; ++I) {
+  printf("%d\n", Ints_[I]);
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:5: warning: use range-based for loop instead
+// CHECK-FIXES: for (int Int : Ints_)
+// CHECK-FIXES-NEXT: printf("%d\n", Int);
+  }
+};
+
 } // namespace NamingAlias
 
 namespace NamingConlict {
Index: test/clang-tidy/modernize-loop-convert-const.cpp
===
--- test/clang-tidy/modernize-loop-convert-const.cpp
+++ test/clang-tidy/modernize-loop-convert-const.cpp
@@ -341,7 +341,7 @@
 copyArg(Ints[I]);
 }
 // CHECK-MESSAGES: :[[@LINE-4]]:5: warning: use range-based for loop
-// CHECK-FIXES: for (int Elem : Ints)
+// CHECK-FIXES: for (int Int : Ints)
 
 for (int I = 0; I < N; ++I) {
   Array[I].constMember(0);
Index: test/clang-tidy/modernize-loop-convert-basic.cpp
===
--- test/clang-tidy/modernize-loop-convert-basic.cpp
+++ test/clang-tidy/modernize-loop-convert-basic.cpp
@@ -168,6 +168,41 @@
   }
 };
 
+struct HasIndirectArr {
+  HasArr HA;
+  void implicitThis() {
+for (int I = 0; I < N; ++I) {
+  printf("%d", HA.Arr[I]);
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:5: warning: use range-based for loop instead
+// CHECK-FIXES: for (int Elem : HA.Arr)
+// CHECK-FIXES-NEXT: printf("%d", Elem);
+
+for (int I = 0; I < N; ++I) {
+  printf("%d", HA.ValArr[I].X);
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:5: warning: use range-based for loop instead
+// CHECK-FIXES: for (auto & Elem : HA.ValArr)
+// CHECK-FIXES-NEXT: printf("%d", Elem.X);
+  }
+
+  void explicitThis() {
+for (int I = 0; I < N; ++I) {
+  printf("%d", this->HA.Arr[I]);
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:5: warning: use range-based for loop instead
+// CHECK-FIXES: for (int Elem : this->HA.Arr)
+// CHECK-FIXES-NEXT: printf("%d", Elem);
+
+for (int I = 0; I < N; ++I) {
+  printf("%d", this->HA.ValArr[I].X);
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:5: warning: use range-based for loop instead
+// CHECK-FIXES: for (auto & Elem : this->HA.ValArr)
+// CHECK-FIXES-NEXT: printf("%d", Elem.X);
+  }
+};
+
 // Loops whose bounds are value-dependent should not be converted.
 template 
 void dependentExprBound() {
Index: clang-tidy/modernize/LoopConvertUtils.h
===
--- clang-tidy/modernize/LoopConvertUtils.h
+++ clang-tidy/modernize/LoopConvertUtils.h
@@ -425,7 +425,7 @@
   VariableNamer(StmtGeneratedVarNameMap *GeneratedDecls,
 const StmtParentMap *ReverseAST, const clang::Stmt *SourceStmt,
 const clang::VarDecl *OldIndex,
-const clang::VarDecl *TheContainer,
+const clang::ValueDecl *TheContainer,
 const clang::ASTContext *Context, NamingStyle Style)
   : GeneratedDecls(GeneratedDecls), ReverseAST(ReverseAST),
 SourceStmt(SourceStmt), OldIndex(OldIndex), TheContainer(TheContainer),
@@ -443,7 +443,7 @@
   const 

[clang-tools-extra] r251943 - Handle correctly containers that are data members in modernize-loop-convert.

2015-11-03 Thread Angel Garcia Gomez via cfe-commits
Author: angelgarcia
Date: Tue Nov  3 10:38:31 2015
New Revision: 251943

URL: http://llvm.org/viewvc/llvm-project?rev=251943=rev
Log:
Handle correctly containers that are data members in modernize-loop-convert.

Summary:
I recently found that the variable naming wasn't working as expected with 
containers that are data members. The new index always received the name "Elem" 
(or equivalent) regardless of the container's name.
The check was assuming that the container's declaration was a VarDecl, which 
cannot be converted to a FieldDecl (a data member), and then it could never 
retrieve its name.

This also fixes some cases where the check failed to find the container at all 
(so it didn't do any fix) because of the same reason.

Reviewers: klimek

Subscribers: cfe-commits, alexfh

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.h
clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.h
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-const.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-negative.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp?rev=251943=251942=251943=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.cpp Tue Nov  
3 10:38:31 2015
@@ -353,10 +353,12 @@ static StringRef getStringFromRange(Sour
 }
 
 /// \brief If the given expression is actually a DeclRefExpr, find and return
-/// the underlying VarDecl; otherwise, return NULL.
-static const VarDecl *getReferencedVariable(const Expr *E) {
+/// the underlying ValueDecl; otherwise, return NULL.
+static const ValueDecl *getReferencedVariable(const Expr *E) {
   if (const DeclRefExpr *DRE = getDeclRef(E))
 return dyn_cast(DRE->getDecl());
+  if (const auto *Mem = dyn_cast(E))
+return dyn_cast(Mem->getMemberDecl());
   return nullptr;
 }
 
@@ -500,9 +502,10 @@ void LoopConvertCheck::getAliasRange(Sou
 /// \brief Computes the changes needed to convert a given for loop, and
 /// applies them.
 void LoopConvertCheck::doConversion(
-ASTContext *Context, const VarDecl *IndexVar, const VarDecl 
*MaybeContainer,
-const UsageResult , const DeclStmt *AliasDecl, bool 
AliasUseRequired,
-bool AliasFromForInit, const ForStmt *Loop, RangeDescriptor Descriptor) {
+ASTContext *Context, const VarDecl *IndexVar,
+const ValueDecl *MaybeContainer, const UsageResult ,
+const DeclStmt *AliasDecl, bool AliasUseRequired, bool AliasFromForInit,
+const ForStmt *Loop, RangeDescriptor Descriptor) {
   auto Diag = diag(Loop->getForLoc(), "use range-based for loop instead");
 
   std::string VarName;

Modified: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.h?rev=251943=251942=251943=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertCheck.h Tue Nov  3 
10:38:31 2015
@@ -37,7 +37,7 @@ private:
   void getAliasRange(SourceManager , SourceRange );
 
   void doConversion(ASTContext *Context, const VarDecl *IndexVar,
-const VarDecl *MaybeContainer, const UsageResult ,
+const ValueDecl *MaybeContainer, const UsageResult ,
 const DeclStmt *AliasDecl, bool AliasUseRequired,
 bool AliasFromForInit, const ForStmt *Loop,
 RangeDescriptor Descriptor);

Modified: clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.h?rev=251943=251942=251943=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.h (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/LoopConvertUtils.h Tue Nov  3 
10:38:31 2015
@@ -425,7 +425,7 @@ public:
   VariableNamer(StmtGeneratedVarNameMap *GeneratedDecls,
 const StmtParentMap *ReverseAST, const clang::Stmt *SourceStmt,
 const clang::VarDecl *OldIndex,
-const clang::VarDecl *TheContainer,
+const clang::ValueDecl *TheContainer,
 const clang::ASTContext *Context, NamingStyle Style)