Re: [PATCH] D21968: [libcxx] Externally threaded libc++ variant - Take 2

2016-09-06 Thread Marshall Clow via cfe-commits
mclow.lists added a comment.

The patch (again) doesn't apply cleanly (test/CMakeLists.txt), so I applied it 
manually.
After that, it builds w/o errors, and passes all the tests.

After addressing @EricWF's concerns, I think this is ready to land.


https://reviews.llvm.org/D21968



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


Re: [PATCH] D24113: Allow implicit conversions between incompatible pointer types in overload resolution in C.

2016-09-06 Thread Jan Vesely via cfe-commits
jvesely added a comment.

In https://reviews.llvm.org/D24113#535255, @george.burgess.iv wrote:

> Thanks for the heads-up!
>
> I'm assuming that below is an example of code that this patch broke?
>
>   void foo(int *a, int) __attribute__((overloadable));
>   void foo(unsigned int *a, unsigned int) __attribute__((overloadable));
>  
>   void callFoo() {
> unsigned int i;
> foo(, 0u); // fine.
> foo(, 0); // now-ambiguous overload.
>   }
>


yes, you're correct. (I'm pretty sure I tried this before posting, I must have 
done something wrong...) I'll send libclc patch. The specs don't really talk 
about overloads so I think the behaviour is OK. Although I think that users 
will expect atomic_add(unsigned int *, 5) to work.without error.

thanks


Repository:
  rL LLVM

https://reviews.llvm.org/D24113



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


[libcxx] r280777 - Improve constexpr tests for std::any

2016-09-06 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Sep  6 21:38:48 2016
New Revision: 280777

URL: http://llvm.org/viewvc/llvm-project?rev=280777=rev
Log:
Improve constexpr tests for std::any

Modified:
libcxx/trunk/test/std/utilities/any/any.class/any.cons/default.pass.cpp

Modified: 
libcxx/trunk/test/std/utilities/any/any.class/any.cons/default.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/any/any.class/any.cons/default.pass.cpp?rev=280777=280776=280777=diff
==
--- libcxx/trunk/test/std/utilities/any/any.class/any.cons/default.pass.cpp 
(original)
+++ libcxx/trunk/test/std/utilities/any/any.class/any.cons/default.pass.cpp Tue 
Sep  6 21:38:48 2016
@@ -21,15 +21,6 @@
 #include "any_helpers.h"
 #include "count_new.hpp"
 
-#if TEST_HAS_BUILTIN_IDENTIFIER(__has_constant_initializer)
-// std::any must have a constexpr default constructor, but it's a non-literal
-// type so we can't create a constexpr variable. This tests that we actually
-// get 'constant initialization'.
-std::any a;
-static_assert(__has_constant_initializer(a),
-  "any must be constant initializable");
-#endif
-
 int main()
 {
 using std::any;
@@ -40,6 +31,15 @@ int main()
   );
 }
 {
+struct TestConstexpr : public std::any {
+  constexpr TestConstexpr() : std::any() {}
+};
+#ifdef _LIBCPP_SAFE_STATIC
+_LIBCPP_SAFE_STATIC static std::any a;
+((void)a);
+#endif
+}
+{
 DisableAllocationGuard g; ((void)g);
 any const a;
 assertEmpty(a);


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


r280776 - Fix clang's handling of the copy performed in the second phase of class

2016-09-06 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Sep  6 21:14:33 2016
New Revision: 280776

URL: http://llvm.org/viewvc/llvm-project?rev=280776=rev
Log:
Fix clang's handling of the copy performed in the second phase of class
copy-initialization. We previously got this wrong in a couple of ways:
 - we only looked for copy / move constructors and constructor templates for
   this copy, and thus would fail to copy in cases where doing so should use
   some other constructor (but see core issue 670),
 - we mishandled the special case for disabling user-defined conversions that
   blocks infinite recursion through repeated application of a copy constructor
   (applying it in slightly too many cases) -- though as far as I can tell,
   this does not ever actually affect the result of overload resolution, and
 - we misapplied the special-case rules for constructors taking a parameter
   whose type is a (reference to) the same class type by incorrectly assuming
   that only happens for copy/move constructors (it also happens for
   constructors instantiated from templates and those inherited from base
   classes).

These changes should only affect strange corner cases (for instance, where the
copy constructor exists but has a non-const-qualified parameter type), so for
the most part it only causes us to produce more 'candidate' notes, but see the
test changes for other cases whose behavior is affected.

Modified:
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp
cfe/trunk/test/CXX/drs/dr0xx.cpp
cfe/trunk/test/CXX/drs/dr1xx.cpp
cfe/trunk/test/CodeGenCXX/copy-constructor-elim-2.cpp
cfe/trunk/test/SemaCXX/conditional-expr.cpp
cfe/trunk/test/SemaCXX/copy-initialization.cpp
cfe/trunk/test/SemaCXX/cxx0x-initializer-constructor.cpp
cfe/trunk/test/SemaCXX/cxx11-inheriting-ctors.cpp
cfe/trunk/test/SemaCXX/cxx98-compat-flags.cpp
cfe/trunk/test/SemaCXX/cxx98-compat-pedantic.cpp

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=280776=280775=280776=diff
==
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Tue Sep  6 21:14:33 2016
@@ -3438,6 +3438,23 @@ static bool TryInitializerListConstructi
   return true;
 }
 
+/// Determine if the constructor has the signature of a copy or move
+/// constructor for the type T of the class in which it was found. That is,
+/// determine if its first parameter is of type T or reference to (possibly
+/// cv-qualified) T.
+static bool hasCopyOrMoveCtorParam(ASTContext ,
+   const ConstructorInfo ) {
+  if (Info.Constructor->getNumParams() == 0)
+return false;
+
+  QualType ParmT =
+  Info.Constructor->getParamDecl(0)->getType().getNonReferenceType();
+  QualType ClassT =
+  Ctx.getRecordType(cast(Info.FoundDecl->getDeclContext()));
+
+  return Ctx.hasSameUnqualifiedType(ParmT, ClassT);
+}
+
 static OverloadingResult
 ResolveConstructorOverload(Sema , SourceLocation DeclLoc,
MultiExprArg Args,
@@ -3445,59 +3462,56 @@ ResolveConstructorOverload(Sema , Sour
DeclContext::lookup_result Ctors,
OverloadCandidateSet::iterator ,
bool CopyInitializing, bool AllowExplicit,
-   bool OnlyListConstructors, bool IsListInit) {
+   bool OnlyListConstructors, bool IsListInit,
+   bool SecondStepOfCopyInit = false) {
   CandidateSet.clear();
 
   for (NamedDecl *D : Ctors) {
 auto Info = getConstructorInfo(D);
-if (!Info.Constructor)
+if (!Info.Constructor || Info.Constructor->isInvalidDecl())
   continue;
 
-bool SuppressUserConversions = false;
+if (!AllowExplicit && Info.Constructor->isExplicit())
+  continue;
 
-if (!Info.ConstructorTmpl) {
-  // C++11 [over.best.ics]p4:
-  //   ... and the constructor or user-defined conversion function is a
-  //   candidate by
-  //   - 13.3.1.3, when the argument is the temporary in the second step
-  // of a class copy-initialization, or
-  //   - 13.3.1.4, 13.3.1.5, or 13.3.1.6 (in all cases),
-  //   user-defined conversion sequences are not considered.
-  // FIXME: This breaks backward compatibility, e.g. PR12117. As a
-  //temporary fix, let's re-instate the third bullet above until
-  //there is a resolution in the standard, i.e.,
-  //   - 13.3.1.7 when the initializer list has exactly one element that is
-  // itself an initializer list and a conversion to some class X or
-  // reference to (possibly cv-qualified) X is considered for the first
-  // parameter of a constructor of X.
-  if ((CopyInitializing ||
-   (IsListInit && Args.size() == 1 && 

Re: [PATCH] D24158: Try contextually converting condition of constexpr if to Boolean value

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


Comment at: test/CodeGenCXX/cxx1z-constexpr-if.cpp:26-29
@@ -17,2 +25,6 @@
   }
+  if constexpr (A())
+should_be_used_3();
+  else
+should_not_be_used();
 }

Please also add a test that we reject expressions that are contextually 
convertible to a `bool` constant expression but are not contextually converted 
constant expressions of type `bool`. Example:

  if constexpr (4.3) // ill-formed, boolean conversion not permitted

... and sadly ...

  constexpr void *p = nullptr;
  if constexpr (p) // ill-formed, boolean conversion not permitted


https://reviews.llvm.org/D24158



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


Re: [PATCH] D24158: Try contextually converting condition of constexpr if to Boolean value

2016-09-06 Thread Richard Smith via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Thanks, LGTM.

If you're looking for more issues in this area -- in passing I noticed that we 
fail to apply the "contextually converted constant expression of type bool" 
rules properly in the other cases where they apply, either (the operand of 
`static_assert` and `noexcept`).


https://reviews.llvm.org/D24158



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


[libcxx] r280775 - Fix PR30260 - optional not working.

2016-09-06 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Sep  6 20:56:07 2016
New Revision: 280775

URL: http://llvm.org/viewvc/llvm-project?rev=280775=rev
Log:
Fix PR30260 - optional not working.

This patch fixes PR30260 by using a (void*) cast on the placement argument
to placement new to casts away the const. See also http://llvm.org/PR30260.

As a drive by change this patch also changes the header guard for
 to _LIBCPP_EXPERIMENTAL_OPTIONAL from _LIBCPP_OPTIONAL.

Modified:
libcxx/trunk/include/experimental/optional

libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/assign_value.pass.cpp

libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/copy.pass.cpp

libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/emplace.pass.cpp

libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp

libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/move.pass.cpp

libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/copy.pass.cpp

libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/move.pass.cpp

libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.swap/swap.pass.cpp

Modified: libcxx/trunk/include/experimental/optional
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/optional?rev=280775=280774=280775=diff
==
--- libcxx/trunk/include/experimental/optional (original)
+++ libcxx/trunk/include/experimental/optional Tue Sep  6 20:56:07 2016
@@ -8,8 +8,8 @@
 //
 
//===--===//
 
-#ifndef _LIBCPP_OPTIONAL
-#define _LIBCPP_OPTIONAL
+#ifndef _LIBCPP_EXPERIMENTAL_OPTIONAL
+#define _LIBCPP_EXPERIMENTAL_OPTIONAL
 
 /*
 optional synopsis
@@ -211,7 +211,7 @@ protected:
 :  __engaged_(__x.__engaged_)
 {
 if (__engaged_)
-::new(_VSTD::addressof(__val_)) value_type(__x.__val_);
+::new((void*)_VSTD::addressof(__val_)) value_type(__x.__val_);
 }
 
 _LIBCPP_INLINE_VISIBILITY
@@ -220,7 +220,7 @@ protected:
 :  __engaged_(__x.__engaged_)
 {
 if (__engaged_)
-::new(_VSTD::addressof(__val_)) 
value_type(_VSTD::move(__x.__val_));
+::new((void*)_VSTD::addressof(__val_)) 
value_type(_VSTD::move(__x.__val_));
 }
 
 _LIBCPP_INLINE_VISIBILITY
@@ -262,7 +262,7 @@ protected:
 :  __engaged_(__x.__engaged_)
 {
 if (__engaged_)
-::new(_VSTD::addressof(__val_)) value_type(__x.__val_);
+::new((void*)_VSTD::addressof(__val_)) value_type(__x.__val_);
 }
 
 _LIBCPP_INLINE_VISIBILITY
@@ -271,7 +271,7 @@ protected:
 :  __engaged_(__x.__engaged_)
 {
 if (__engaged_)
-::new(_VSTD::addressof(__val_)) 
value_type(_VSTD::move(__x.__val_));
+::new((void*)_VSTD::addressof(__val_)) 
value_type(_VSTD::move(__x.__val_));
 }
 
 _LIBCPP_INLINE_VISIBILITY
@@ -368,7 +368,7 @@ public:
 if (this->__engaged_)
 this->__val_.~value_type();
 else
-::new(_VSTD::addressof(this->__val_)) value_type(__opt.__val_);
+::new((void*)_VSTD::addressof(this->__val_)) 
value_type(__opt.__val_);
 this->__engaged_ = __opt.__engaged_;
 }
 return *this;
@@ -390,7 +390,8 @@ public:
 if (this->__engaged_)
 this->__val_.~value_type();
 else
-::new(_VSTD::addressof(this->__val_)) 
value_type(_VSTD::move(__opt.__val_));
+::new((void*)_VSTD::addressof(this->__val_))
+value_type(_VSTD::move(__opt.__val_));
 this->__engaged_ = __opt.__engaged_;
 }
 return *this;
@@ -412,7 +413,7 @@ public:
 this->__val_ = _VSTD::forward<_Up>(__v);
 else
 {
-::new(_VSTD::addressof(this->__val_)) 
value_type(_VSTD::forward<_Up>(__v));
+::new((void*)_VSTD::addressof(this->__val_)) 
value_type(_VSTD::forward<_Up>(__v));
 this->__engaged_ = true;
 }
 return *this;
@@ -429,7 +430,8 @@ public:
 emplace(_Args&&... __args)
 {
 *this = nullopt;
-::new(_VSTD::addressof(this->__val_)) 
value_type(_VSTD::forward<_Args>(__args)...);
+::new((void*)_VSTD::addressof(this->__val_))
+value_type(_VSTD::forward<_Args>(__args)...);
 this->__engaged_ = true;
 }
 
@@ -444,7 +446,8 @@ public:
 emplace(initializer_list<_Up> __il, _Args&&... __args)
 {
 *this = nullopt;
-::new(_VSTD::addressof(this->__val_)) value_type(__il, 

Re: r280728 - Modules: Fix an assertion in DeclContext::buildLookup.

2016-09-06 Thread Richard Smith via cfe-commits
On Tue, Sep 6, 2016 at 11:16 AM, Manman Ren via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: mren
> Date: Tue Sep  6 13:16:54 2016
> New Revision: 280728
>
> URL: http://llvm.org/viewvc/llvm-project?rev=280728=rev
> Log:
> Modules: Fix an assertion in DeclContext::buildLookup.
>
> When calling getMostRecentDecl, we can pull in more definitions from
> a module. We call getPrimaryContext afterwards to make sure that
> we buildLookup on a primary context.
>
> rdar://27926200
>
> Added:
> cfe/trunk/test/Modules/Inputs/lookup-assert/
> cfe/trunk/test/Modules/Inputs/lookup-assert/Base.h
> cfe/trunk/test/Modules/Inputs/lookup-assert/Derive.h
> cfe/trunk/test/Modules/Inputs/lookup-assert/H3.h
> cfe/trunk/test/Modules/Inputs/lookup-assert/module.map
> cfe/trunk/test/Modules/lookup-assert.m
> Modified:
> cfe/trunk/lib/AST/DeclBase.cpp
>
> Modified: cfe/trunk/lib/AST/DeclBase.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/
> DeclBase.cpp?rev=280728=280727=280728=diff
> 
> ==
> --- cfe/trunk/lib/AST/DeclBase.cpp (original)
> +++ cfe/trunk/lib/AST/DeclBase.cpp Tue Sep  6 13:16:54 2016
> @@ -1411,10 +1411,6 @@ DeclContext::lookup(DeclarationName Name
>assert(DeclKind != Decl::LinkageSpec &&
>   "Should not perform lookups into linkage specs!");
>
> -  const DeclContext *PrimaryContext = getPrimaryContext();
> -  if (PrimaryContext != this)
> -return PrimaryContext->lookup(Name);
> -
>// If we have an external source, ensure that any later redeclarations
> of this
>// context have been loaded, since they may add names to the result of
> this
>// lookup (or add external visible storage).
> @@ -1422,6 +1418,12 @@ DeclContext::lookup(DeclarationName Name
>if (Source)
>  (void)cast(this)->getMostRecentDecl();
>
> +  // getMostRecentDecl can change the result of getPrimaryContext. Call
> +  // getPrimaryContext afterwards.
> +  const DeclContext *PrimaryContext = getPrimaryContext();
> +  if (PrimaryContext != this)
> +return PrimaryContext->lookup(Name);
>

This seems like a bug in getPrimaryContext() -- if there is a
not-yet-loaded definition of the DeclContext, getPrimaryContext() should
return that instead of returning a non-defining declaration. Why is
ObjCInterfaceDecl::hasDefinition (indirectly called by getPrimaryContext)
not loading the definition in this case?


> +
>if (hasExternalVisibleStorage()) {
>  assert(Source && "external visible storage but no external source?");
>
>
> Added: cfe/trunk/test/Modules/Inputs/lookup-assert/Base.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> Modules/Inputs/lookup-assert/Base.h?rev=280728=auto
> 
> ==
> --- cfe/trunk/test/Modules/Inputs/lookup-assert/Base.h (added)
> +++ cfe/trunk/test/Modules/Inputs/lookup-assert/Base.h Tue Sep  6
> 13:16:54 2016
> @@ -0,0 +1,4 @@
> +@interface BaseInterface
> +- (void) test;
> +@end
> +
>
> Added: cfe/trunk/test/Modules/Inputs/lookup-assert/Derive.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> Modules/Inputs/lookup-assert/Derive.h?rev=280728=auto
> 
> ==
> --- cfe/trunk/test/Modules/Inputs/lookup-assert/Derive.h (added)
> +++ cfe/trunk/test/Modules/Inputs/lookup-assert/Derive.h Tue Sep  6
> 13:16:54 2016
> @@ -0,0 +1,3 @@
> +#include "Base.h"
> +@interface DerivedInterface : BaseInterface
> +@end
>
> Added: cfe/trunk/test/Modules/Inputs/lookup-assert/H3.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> Modules/Inputs/lookup-assert/H3.h?rev=280728=auto
> 
> ==
> --- cfe/trunk/test/Modules/Inputs/lookup-assert/H3.h (added)
> +++ cfe/trunk/test/Modules/Inputs/lookup-assert/H3.h Tue Sep  6 13:16:54
> 2016
> @@ -0,0 +1 @@
> +#include "Base.h"
>
> Added: cfe/trunk/test/Modules/Inputs/lookup-assert/module.map
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> Modules/Inputs/lookup-assert/module.map?rev=280728=auto
> 
> ==
> --- cfe/trunk/test/Modules/Inputs/lookup-assert/module.map (added)
> +++ cfe/trunk/test/Modules/Inputs/lookup-assert/module.map Tue Sep  6
> 13:16:54 2016
> @@ -0,0 +1,4 @@
> +module X {
> +  header "H3.h"
> +  export *
> +}
>
> Added: cfe/trunk/test/Modules/lookup-assert.m
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> Modules/lookup-assert.m?rev=280728=auto
> 
> ==
> --- cfe/trunk/test/Modules/lookup-assert.m (added)
> +++ cfe/trunk/test/Modules/lookup-assert.m Tue Sep  6 13:16:54 2016
> @@ -0,0 +1,10 @@
> +// RUN: rm -rf %t
> +// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules
> -fimplicit-module-maps 

Re: [PATCH] D24268: Traversing template paramter lists of DeclaratorDecls and/or TagDecls.

2016-09-06 Thread Richard Smith via cfe-commits
On Tue, Sep 6, 2016 at 3:47 PM, Łukasz Anforowicz 
wrote:

> lukasza added inline comments.
>
> 
> Comment at: include/clang/AST/RecursiveASTVisitor.h:487-489
> @@ +486,5 @@
> +  // Traverses template parameter lists of either a DeclaratorDecl or
> TagDecl.
> +  template  +  std::is_base_of::value ||
> +  std::is_base_of::value>::type>
> +  bool TraverseDeclTemplateParameterLists(T *D);
> 
> rsmith wrote:
> > What's the purpose of the `enable_if` here?
> enable_if is here to document via code that this method works for
> arguments that are either a TagDecl or a DeclaratorDecl.  enable_if is not
> really necessary here - I could take it out and just make the
> TraverseDeclTemplateParameterLists method compile as long as T
> contains the right getNumTemplateParameterLists and
> getTemplateParameterList methods.
>
> FWIW, I got rid of std::enable_if above in the latest patch revision.
> Does the code look better and less surprising now?
>
> 
> Comment at: include/clang/AST/RecursiveASTVisitor.h:1728
> @@ -1708,2 +1727,3 @@
>
> +  TRY_TO(TraverseDeclTemplateParameterLists(D));
>TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
> 
> rsmith wrote:
> > lukasza wrote:
> > > I think that tweaks of EnumDecl traversal together with tweaks of
> TraverseRecordHelper tweaks, take care of all the relevant node types
> derived from TagDecl:
> > >
> > > - EnumDecl - traversal now calls TraverseDeclTemplateParameterLists
> (+EnumDecl is covered by the new unit tests)
> > > - RecordDecl - TraverseRecordHelper now calls
> TraverseDeclTemplateParameterLists (+RecordDecl is covered by the new
> unit tests)
> > > - CXXRecordDecl - traversal includes a call to TraverseRecordHelper
> > >
> > > I believe that nodes derived further from CXXRecordDecl cannot have a
> template parameter list (?):
> > > - ClassTemplateSpecializationDecl
> > > - ClassTemplatePartialSpecializationDecl
> > > If this is not correct, then can you please help me see the shape of
> unit tests that would cover these nodes?
> > I don't think `ClassTemplateSpecializationDecl` can have a template
> parameter list for its qualifier. A `ClassTemplatePartialSpecializationDecl`
> can, though:
> >
> >   template struct A {
> > template struct B;
> >   };
> >   template template struct A::B {};
> Thanks for the example.  I've added a unit test covering this case (and
> verified that it fails before the fix and passes afterwards).  A bit
> surprisingly, the extra test passed without further tweaks to the product
> code (surprisingly, because I am not sure how 
> TraverseDeclTemplateParameterLists
> ends up getting called for ClassTemplatePartialSpecializationDecl).  I
> don't think I want to keep digging to understand why things work without
> further tweaks, but the surprise factor makes me think the extra test is
> worth keeping (even though it apparently doesn't really increase test
> coverage).
>
> 
> Comment at: include/clang/AST/RecursiveASTVisitor.h:1823
> @@ -1802,2 +1822,3 @@
>  bool RecursiveASTVisitor::TraverseDeclaratorHelper(DeclaratorDecl
> *D) {
> +  TRY_TO(TraverseDeclTemplateParameterLists(D));
>TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
> 
> rsmith wrote:
> > lukasza wrote:
> > > I think that TraverseDeclaratorHelper together with
> TraverseFunctionHelper tweaks, this takes care of all node types derived
> from DeclaratorDecl:
> > > - FieldDecl - traversal calls TraverseDeclaratorHelper
> > > - FunctionDecl - traversal calls TraverseFunctionHelper
> > > - CXXMethodDecl - traversal calls TraverseFunctionHelper
> (+CXXMethodDecl is covered by the new unit tests)
> > > - CXXConstructorDecl - traversal calls TraverseFunctionHelper
> > > - CXXConversionDecl - traversal calls TraverseFunctionHelper
> > > - CXXDestructorDecl - traversal calls TraverseFunctionHelper
> > > - VarDecl - TraverseVarHelper calls TraverseDeclaratorHelper (+VarDecl
> is covered by the new unit tests)
> > >
> > > I believe that nodes derived further from VarDecl cannot have a
> template parameter list (?), but most of them should still be safe (because
> their traversal goes through TraverseVarHelper):
> > > - DecompositionDecl - traversal calls TraverseVarHelper
> > > - ImplicitParamDecl - traversal calls TraverseVarHelper
> > > - OMPCapturedExprDecl - traversal calls TraverseVarHelper
> > > - ParmVarDecl - traversal calls TraverseVarHelper
> > > - VarTemplateSpecializationDecl
> > > - VarTemplatePartialSpecializationDecl
> > >
> > > Please let me know if I am wrong above and it is indeed possible to
> have template parameter lists next to VarTemplateSpecializationDecl and/or
> VarTemplatePartialSpecializationDecl (and I would also appreciate if you
> could help me see the shape of unit tests that would cover these nodes).
> > `VarTemplatePartialSpecializationDecl`s can have 

Re: [PATCH] D24268: Traversing template paramter lists of DeclaratorDecls and/or TagDecls.

2016-09-06 Thread Łukasz Anforowicz via cfe-commits
lukasza added inline comments.


Comment at: include/clang/AST/RecursiveASTVisitor.h:487-489
@@ +486,5 @@
+  // Traverses template parameter lists of either a DeclaratorDecl or TagDecl.
+  template ::value ||
+  std::is_base_of::value>::type>
+  bool TraverseDeclTemplateParameterLists(T *D);

rsmith wrote:
> What's the purpose of the `enable_if` here?
enable_if is here to document via code that this method works for arguments 
that are either a TagDecl or a DeclaratorDecl.  enable_if is not really 
necessary here - I could take it out and just make the 
TraverseDeclTemplateParameterLists method compile as long as T contains the 
right getNumTemplateParameterLists and getTemplateParameterList methods.

FWIW, I got rid of std::enable_if above in the latest patch revision.  Does the 
code look better and less surprising now?


Comment at: include/clang/AST/RecursiveASTVisitor.h:1728
@@ -1708,2 +1727,3 @@
 
+  TRY_TO(TraverseDeclTemplateParameterLists(D));
   TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));

rsmith wrote:
> lukasza wrote:
> > I think that tweaks of EnumDecl traversal together with tweaks of 
> > TraverseRecordHelper tweaks, take care of all the relevant node types 
> > derived from TagDecl:
> > 
> > - EnumDecl - traversal now calls TraverseDeclTemplateParameterLists 
> > (+EnumDecl is covered by the new unit tests)
> > - RecordDecl - TraverseRecordHelper now calls 
> > TraverseDeclTemplateParameterLists (+RecordDecl is covered by the new unit 
> > tests)
> > - CXXRecordDecl - traversal includes a call to TraverseRecordHelper
> > 
> > I believe that nodes derived further from CXXRecordDecl cannot have a 
> > template parameter list (?):
> > - ClassTemplateSpecializationDecl
> > - ClassTemplatePartialSpecializationDecl
> > If this is not correct, then can you please help me see the shape of unit 
> > tests that would cover these nodes?
> I don't think `ClassTemplateSpecializationDecl` can have a template parameter 
> list for its qualifier. A `ClassTemplatePartialSpecializationDecl` can, 
> though:
> 
>   template struct A {
> template struct B; 
>   };
>   template template struct A::B {};
Thanks for the example.  I've added a unit test covering this case (and 
verified that it fails before the fix and passes afterwards).  A bit 
surprisingly, the extra test passed without further tweaks to the product code 
(surprisingly, because I am not sure how TraverseDeclTemplateParameterLists 
ends up getting called for ClassTemplatePartialSpecializationDecl).  I don't 
think I want to keep digging to understand why things work without further 
tweaks, but the surprise factor makes me think the extra test is worth keeping 
(even though it apparently doesn't really increase test coverage).


Comment at: include/clang/AST/RecursiveASTVisitor.h:1823
@@ -1802,2 +1822,3 @@
 bool RecursiveASTVisitor::TraverseDeclaratorHelper(DeclaratorDecl *D) 
{
+  TRY_TO(TraverseDeclTemplateParameterLists(D));
   TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));

rsmith wrote:
> lukasza wrote:
> > I think that TraverseDeclaratorHelper together with TraverseFunctionHelper 
> > tweaks, this takes care of all node types derived from DeclaratorDecl:
> > - FieldDecl - traversal calls TraverseDeclaratorHelper
> > - FunctionDecl - traversal calls TraverseFunctionHelper
> > - CXXMethodDecl - traversal calls TraverseFunctionHelper (+CXXMethodDecl is 
> > covered by the new unit tests)
> > - CXXConstructorDecl - traversal calls TraverseFunctionHelper
> > - CXXConversionDecl - traversal calls TraverseFunctionHelper
> > - CXXDestructorDecl - traversal calls TraverseFunctionHelper
> > - VarDecl - TraverseVarHelper calls TraverseDeclaratorHelper (+VarDecl is 
> > covered by the new unit tests)
> > 
> > I believe that nodes derived further from VarDecl cannot have a template 
> > parameter list (?), but most of them should still be safe (because their 
> > traversal goes through TraverseVarHelper):
> > - DecompositionDecl - traversal calls TraverseVarHelper
> > - ImplicitParamDecl - traversal calls TraverseVarHelper
> > - OMPCapturedExprDecl - traversal calls TraverseVarHelper
> > - ParmVarDecl - traversal calls TraverseVarHelper
> > - VarTemplateSpecializationDecl
> > - VarTemplatePartialSpecializationDecl
> > 
> > Please let me know if I am wrong above and it is indeed possible to have 
> > template parameter lists next to VarTemplateSpecializationDecl and/or 
> > VarTemplatePartialSpecializationDecl (and I would also appreciate if you 
> > could help me see the shape of unit tests that would cover these nodes).
> `VarTemplatePartialSpecializationDecl`s can have template parameter lists:
> 
>   template struct A { template static int n; };
>   template template int A::n;
> 
> I don't think other `VarTemplateSpecializationDecl`s can.
Thanks for the example.  I've added a unit test covering 

Re: [PATCH] D24268: Traversing template paramter lists of DeclaratorDecls and/or TagDecls.

2016-09-06 Thread Łukasz Anforowicz via cfe-commits
lukasza added inline comments.


Comment at: include/clang/AST/RecursiveASTVisitor.h:1728
@@ -1708,2 +1727,3 @@
 
+  TRY_TO(TraverseDeclTemplateParameterLists(D));
   TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));

I think that tweaks of EnumDecl traversal together with tweaks of 
TraverseRecordHelper tweaks, take care of all the relevant node types derived 
from TagDecl:

- EnumDecl - traversal now calls TraverseDeclTemplateParameterLists (+EnumDecl 
is covered by the new unit tests)
- RecordDecl - TraverseRecordHelper now calls 
TraverseDeclTemplateParameterLists (+RecordDecl is covered by the new unit 
tests)
- CXXRecordDecl - traversal includes a call to TraverseRecordHelper

I believe that nodes derived further from CXXRecordDecl cannot have a template 
parameter list (?):
- ClassTemplateSpecializationDecl
- ClassTemplatePartialSpecializationDecl
If this is not correct, then can you please help me see the shape of unit tests 
that would cover these nodes?


Comment at: include/clang/AST/RecursiveASTVisitor.h:1823
@@ -1802,2 +1822,3 @@
 bool RecursiveASTVisitor::TraverseDeclaratorHelper(DeclaratorDecl *D) 
{
+  TRY_TO(TraverseDeclTemplateParameterLists(D));
   TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));

I think that TraverseDeclaratorHelper together with TraverseFunctionHelper 
tweaks, this takes care of all node types derived from DeclaratorDecl:
- FieldDecl - traversal calls TraverseDeclaratorHelper
- FunctionDecl - traversal calls TraverseFunctionHelper
- CXXMethodDecl - traversal calls TraverseFunctionHelper (+CXXMethodDecl is 
covered by the new unit tests)
- CXXConstructorDecl - traversal calls TraverseFunctionHelper
- CXXConversionDecl - traversal calls TraverseFunctionHelper
- CXXDestructorDecl - traversal calls TraverseFunctionHelper
- VarDecl - TraverseVarHelper calls TraverseDeclaratorHelper (+VarDecl is 
covered by the new unit tests)

I believe that nodes derived further from VarDecl cannot have a template 
parameter list (?), but most of them should still be safe (because their 
traversal goes through TraverseVarHelper):
- DecompositionDecl - traversal calls TraverseVarHelper
- ImplicitParamDecl - traversal calls TraverseVarHelper
- OMPCapturedExprDecl - traversal calls TraverseVarHelper
- ParmVarDecl - traversal calls TraverseVarHelper
- VarTemplateSpecializationDecl
- VarTemplatePartialSpecializationDecl

Please let me know if I am wrong above and it is indeed possible to have 
template parameter lists next to VarTemplateSpecializationDecl and/or 
VarTemplatePartialSpecializationDecl (and I would also appreciate if you could 
help me see the shape of unit tests that would cover these nodes).


Comment at: include/clang/AST/RecursiveASTVisitor.h:1870
@@ -1848,2 +1869,3 @@
 bool RecursiveASTVisitor::TraverseFunctionHelper(FunctionDecl *D) {
+  TRY_TO(TraverseDeclTemplateParameterLists(D));
   TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));

Richard, in https://llvm.org/bugs/show_bug.cgi?id=29042#c6 you've suggested 
reusing TraverseDeclaratorHelper here.  I agree that there are refactoring and 
code reusing opportunities here (e.g. TraverseNestedNameSpecifier[Loc] are 
getting called from both TraverseDeclaratorHelper and from 
TraverseFunctionHelper), but I didn't pursue them in this patch, because I was 
worried about little details:

1. traversal order (i.e. TraverseDeclaratorHelper traverses NestedNameSpecifier 
immediately before traversing TypeSourceInfo;  this is different than 
TraverseFunctionHelper which traverses DeclarationNameInfo in-between 
traversing NestedNameSpecifier and TypeSourceInfo)

2. traversal in absence of TypeSourceInfo (i.e. when TypeSourceInfo is missing, 
then TraverseDeclaratorHelper traverses Type;  this is different than 
TraverseFunctionHelper which in this case 1) checks shouldVisitImplicitCode 
condition and only then 2) traverses function parameters).

Because of the above, I think that for now it is better to call 
TraverseDeclTemplateParameterLists directly from TraverseFunctionHelper, rather 
than trying to reuse the whole (or bigger part of) TraverseDeclaratorHelper 
from TraverseFunctionHelper.


Comment at: unittests/ASTMatchers/ASTMatchersTraversalTest.cpp:1730
@@ +1729,3 @@
+  return type && InnerMatcher.matches(*type, Finder, Builder);
+}
+

I've needed this custom AST matcher in 
https://codereview.chromium.org/2256913002 - let me try to sneak in a question 
related to this other CL:  Can I somehow avoid introducing a new, custom AST 
matcher?  (i.e. is it possible to express hasUnderlyingType in terms of 
built-in matchers?)


https://reviews.llvm.org/D24268



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


Re: [PATCH] D24268: Traversing template paramter lists of DeclaratorDecls and/or TagDecls.

2016-09-06 Thread Łukasz Anforowicz via cfe-commits
lukasza updated the summary for this revision.
lukasza updated this revision to Diff 70483.
lukasza added a comment.

Addressing CR feedbackfrom rsmith@.


https://reviews.llvm.org/D24268

Files:
  include/clang/AST/RecursiveASTVisitor.h
  unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -641,6 +641,89 @@
 functionDecl(hasAnyTemplateArgument(templateArgument();
 }
 
+TEST(TemplateTypeParmDecl, CXXMethodDecl) {
+  const char input[] =
+  "template\n"
+  "class Class {\n"
+  "  void method();\n"
+  "};\n"
+  "template\n"
+  "void Class::method() {}\n";
+  EXPECT_TRUE(matches(input, templateTypeParmDecl(hasName("T";
+  EXPECT_TRUE(matches(input, templateTypeParmDecl(hasName("U";
+}
+
+TEST(TemplateTypeParmDecl, VarDecl) {
+  const char input[] =
+  "template\n"
+  "class Class {\n"
+  "  static T pi;\n"
+  "};\n"
+  "template\n"
+  "U Class::pi = U(3.1415926535897932385);\n";
+  EXPECT_TRUE(matches(input, templateTypeParmDecl(hasName("T";
+  EXPECT_TRUE(matches(input, templateTypeParmDecl(hasName("U";
+}
+
+TEST(TemplateTypeParmDecl, VarTemplatePartialSpecializationDecl) {
+  const char input[] =
+  "template\n"
+  "struct Struct {\n"
+  "  template static int field;\n"
+  "};\n"
+  "template\n"
+  "template\n"
+  "int Struct::field = 123;\n";
+  EXPECT_TRUE(matches(input, templateTypeParmDecl(hasName("T";
+  EXPECT_TRUE(matches(input, templateTypeParmDecl(hasName("T2";
+  EXPECT_TRUE(matches(input, templateTypeParmDecl(hasName("U";
+  EXPECT_TRUE(matches(input, templateTypeParmDecl(hasName("U2";
+}
+
+TEST(TemplateTypeParmDecl, ClassTemplatePartialSpecializationDecl) {
+  const char input[] =
+  "template\n"
+  "class Class {\n"
+  "  template struct Struct;\n"
+  "};\n"
+  "template\n"
+  "template\n"
+  "struct Class::Struct {};\n";
+  EXPECT_TRUE(matches(input, templateTypeParmDecl(hasName("T";
+  EXPECT_TRUE(matches(input, templateTypeParmDecl(hasName("T2";
+  EXPECT_TRUE(matches(input, templateTypeParmDecl(hasName("U";
+  EXPECT_TRUE(matches(input, templateTypeParmDecl(hasName("U2";
+}
+
+TEST(TemplateTypeParmDecl, EnumDecl) {
+  const char input[] =
+  "template\n"
+  "struct Struct {\n"
+  "  enum class Enum : T;\n"
+  "};\n"
+  "template\n"
+  "enum class Struct::Enum : U {\n"
+  "  e1,\n"
+  "  e2\n"
+  "};\n";
+  EXPECT_TRUE(matches(input, templateTypeParmDecl(hasName("T";
+  EXPECT_TRUE(matches(input, templateTypeParmDecl(hasName("U";
+}
+
+TEST(TemplateTypeParmDecl, RecordDecl) {
+  const char input[] =
+  "template\n"
+  "class Class {\n"
+  "  struct Struct;\n"
+  "};\n"
+  "template\n"
+  "struct Class::Struct {\n"
+  "  U field;\n"
+  "};\n";
+  EXPECT_TRUE(matches(input, templateTypeParmDecl(hasName("T";
+  EXPECT_TRUE(matches(input, templateTypeParmDecl(hasName("U";
+}
+
 TEST(RefersToIntegralType, Matches) {
   EXPECT_TRUE(matches("template struct C {}; C<42> c;",
   classTemplateSpecializationDecl(
Index: include/clang/AST/RecursiveASTVisitor.h
===
--- include/clang/AST/RecursiveASTVisitor.h
+++ include/clang/AST/RecursiveASTVisitor.h
@@ -482,6 +482,11 @@
 private:
   // These are helper methods used by more than one Traverse* method.
   bool TraverseTemplateParameterListHelper(TemplateParameterList *TPL);
+
+  // Traverses template parameter lists of either a DeclaratorDecl or TagDecl.
+  template 
+  bool TraverseDeclTemplateParameterLists(T *D);
+
 #define DEF_TRAVERSE_TMPL_INST(TMPLDECLKIND)   \
   bool TraverseTemplateInstantiations(TMPLDECLKIND##TemplateDecl *D);
   DEF_TRAVERSE_TMPL_INST(Class)
@@ -1532,6 +1537,16 @@
 }
 
 template 
+template 
+bool RecursiveASTVisitor::TraverseDeclTemplateParameterLists(T *D) {
+  for (unsigned i = 0; i < D->getNumTemplateParameterLists(); i++) {
+TemplateParameterList *TPL = D->getTemplateParameterList(i);
+TraverseTemplateParameterListHelper(TPL);
+  }
+  return true;
+}
+
+template 
 bool RecursiveASTVisitor::TraverseTemplateInstantiations(
 ClassTemplateDecl *D) {
   for (auto *SD : D->specializations()) {
@@ -1692,6 +1707,8 @@
 })
 
 DEF_TRAVERSE_DECL(EnumDecl, {
+  TRY_TO(TraverseDeclTemplateParameterLists(D));
+
   if (D->getTypeForDecl())
 TRY_TO(TraverseType(QualType(D->getTypeForDecl(), 0)));
 
@@ -1706,6 +1723,7 @@
   // We shouldn't traverse D->getTypeForDecl(); it's a result of
   // declaring the type, not something that was written in the source.
 
+  TRY_TO(TraverseDeclTemplateParameterLists(D));
   

[PATCH] D24268: Traversing template paramter lists of DeclaratorDecls and/or TagDecls.

2016-09-06 Thread Łukasz Anforowicz via cfe-commits
lukasza created this revision.
lukasza added a reviewer: rsmith.
lukasza added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

The unit tests in this patch demonstrate the need to traverse template
parameter lists of DeclaratorDecls (e.g. VarDecls, CXXMethodDecls) and
TagDecls (e.g. EnumDecls, RecordDecls).  Without new traversal code
in RecursiveASTVisitor, the new unit tests would trigger an assert
failure in MatchASTVisitor::matchesAncestorOfRecursively while verifing
that all AST nodes have a parent:
  bool matchesAncestorOfRecursively(const ast_type_traits::DynTypedNode ,
...) {
const auto  = ActiveASTContext->getParents(Node);
assert(!Parents.empty() && "Found node that is not in the parent map.");

Fixes PR29042.

https://reviews.llvm.org/D24268

Files:
  include/clang/AST/RecursiveASTVisitor.h
  unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -1720,6 +1720,68 @@
 "}\n",
   declRefExpr(to(decl(hasAncestor(decl()));
 }
+
+AST_MATCHER_P(QualType,
+  hasUnderlyingType,
+  internal::Matcher,
+  InnerMatcher) {
+  const Type* type = Node.getTypePtrOrNull();
+  return type && InnerMatcher.matches(*type, Finder, Builder);
+}
+
+TEST(HasAncestor, TemplateTypeParmDeclUnderCXXMethodDecl) {
+  EXPECT_TRUE(matches(
+  "template\n"
+  "class Class {\n"
+  "  void method();\n"
+  "};\n"
+  "template\n"
+  "void Class::method() {}\n",
+  qualType(hasUnderlyingType(templateTypeParmType(hasDeclaration(decl(
+  hasAncestor(decl();
+}
+
+TEST(HasAncestor, TemplateTypeParmDeclUnderVarDecl) {
+  EXPECT_TRUE(matches(
+  "template\n"
+  "class Class {\n"
+  "  static T pi;\n"
+  "};\n"
+  "template\n"
+  "U Class::pi = U(3.1415926535897932385);\n",
+  qualType(hasUnderlyingType(templateTypeParmType(hasDeclaration(decl(
+  hasAncestor(decl();
+}
+
+TEST(HasAncestor, TemplateTypeParmDeclUnderEnumDecl) {
+  EXPECT_TRUE(matches(
+  "template\n"
+  "struct Struct {\n"
+  "  enum class Enum : T;\n"
+  "};\n"
+  "template\n"
+  "enum class Struct::Enum : U {\n"
+  "  e1,\n"
+  "  e2\n"
+  "};\n",
+  qualType(hasUnderlyingType(templateTypeParmType(hasDeclaration(decl(
+  hasAncestor(decl();
+}
+
+TEST(HasAncestor, TemplateTypeParmDeclUnderStructDecl) {
+  EXPECT_TRUE(matches(
+  "template\n"
+  "class Class {\n"
+  "  struct Struct;\n"
+  "};\n"
+  "template\n"
+  "struct Class::Struct {\n"
+  "  U field;\n"
+  "};\n",
+  qualType(hasUnderlyingType(templateTypeParmType(hasDeclaration(decl(
+  hasAncestor(decl();
+}
+
 TEST(HasAncestor, NonParmDependentTemplateParmVarDeclRefExpr) {
   EXPECT_TRUE(matches("struct PartitionAllocator {\n"
 "  template\n"
Index: include/clang/AST/RecursiveASTVisitor.h
===
--- include/clang/AST/RecursiveASTVisitor.h
+++ include/clang/AST/RecursiveASTVisitor.h
@@ -482,6 +482,13 @@
 private:
   // These are helper methods used by more than one Traverse* method.
   bool TraverseTemplateParameterListHelper(TemplateParameterList *TPL);
+
+  // Traverses template parameter lists of either a DeclaratorDecl or TagDecl.
+  template ::value ||
+  std::is_base_of::value>::type>
+  bool TraverseDeclTemplateParameterLists(T *D);
+
 #define DEF_TRAVERSE_TMPL_INST(TMPLDECLKIND)   \
   bool TraverseTemplateInstantiations(TMPLDECLKIND##TemplateDecl *D);
   DEF_TRAVERSE_TMPL_INST(Class)
@@ -1532,6 +1539,16 @@
 }
 
 template 
+template 
+bool RecursiveASTVisitor::TraverseDeclTemplateParameterLists(T *D) {
+  for (unsigned i = 0; i < D->getNumTemplateParameterLists(); i++) {
+TemplateParameterList *TPL = D->getTemplateParameterList(i);
+TraverseTemplateParameterListHelper(TPL);
+  }
+  return true;
+}
+
+template 
 bool RecursiveASTVisitor::TraverseTemplateInstantiations(
 ClassTemplateDecl *D) {
   for (auto *SD : D->specializations()) {
@@ -1692,6 +1709,8 @@
 })
 
 DEF_TRAVERSE_DECL(EnumDecl, {
+  TRY_TO(TraverseDeclTemplateParameterLists(D));
+
   if (D->getTypeForDecl())
 TRY_TO(TraverseType(QualType(D->getTypeForDecl(), 0)));
 
@@ -1706,6 +1725,7 @@
   // We shouldn't traverse D->getTypeForDecl(); it's a result of
   // declaring the type, not something that was written in the source.
 
+  TRY_TO(TraverseDeclTemplateParameterLists(D));
   TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));
   return true;
 }
@@ -1800,6 +1820,7 @@
 
 template 
 bool 

[libcxx] r280773 - Enable installation of libc++experimental by default.

2016-09-06 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Sep  6 20:15:10 2016
New Revision: 280773

URL: http://llvm.org/viewvc/llvm-project?rev=280773=rev
Log:
Enable installation of libc++experimental by default.

When libc++experimental was originally created it was empty and therefore there
was no reason to install it. Now that the library contains
 and  there is a good
reason to install it.

Specifically this patch enables the installation whenever LIBCXX_INSTALL_LIBRARY
is true and LIBCPP_ENABLE_EXPERIMENTAL_LIBRARY is true.

Modified:
libcxx/trunk/CMakeLists.txt
libcxx/trunk/docs/BuildingLibcxx.rst

Modified: libcxx/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=280773=280772=280773=diff
==
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Tue Sep  6 20:15:10 2016
@@ -48,6 +48,7 @@ MACRO_ENSURE_OUT_OF_SOURCE_BUILD(
 
#===
 # Setup CMake Options
 
#===
+include(CMakeDependentOption)
 
 # Basic options ---
 option(LIBCXX_ENABLE_ASSERTIONS "Enable assertions independent of build mode." 
ON)
@@ -65,7 +66,9 @@ set(LIBCXX_LIBDIR_SUFFIX "${LLVM_LIBDIR_
 option(LIBCXX_INSTALL_HEADERS "Install the libc++ headers." ON)
 option(LIBCXX_INSTALL_LIBRARY "Install the libc++ library." ON)
 option(LIBCXX_INSTALL_SUPPORT_HEADERS "Install libc++ support headers." ON)
-option(LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY "Install libc++experimental.a" OFF)
+cmake_dependent_option(LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY
+"Install libc++experimental.a" ON
+"LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY;LIBCXX_INSTALL_LIBRARY" OFF)
 set(LIBCXX_ABI_VERSION 1 CACHE STRING "ABI version of libc++.")
 option(LIBCXX_ABI_UNSTABLE "Unstable ABI of libc++." OFF)
 option(LIBCXX_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF)

Modified: libcxx/trunk/docs/BuildingLibcxx.rst
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/BuildingLibcxx.rst?rev=280773=280772=280773=diff
==
--- libcxx/trunk/docs/BuildingLibcxx.rst (original)
+++ libcxx/trunk/docs/BuildingLibcxx.rst Tue Sep  6 20:15:10 2016
@@ -179,7 +179,7 @@ libc++experimental Specific Options
 
 .. option:: LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY:BOOL
 
-  **Default**: ``OFF``
+  **Default**: ``LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY AND 
LIBCXX_INSTALL_LIBRARY``
 
   Install libc++experimental.a alongside libc++.
 


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


Re: [PATCH] D24268: Traversing template paramter lists of DeclaratorDecls and/or TagDecls.

2016-09-06 Thread Richard Smith via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

This patch looks great, thank you! Do you have an SVN account or do you need 
someone to commit this for you?



Comment at: unittests/ASTMatchers/ASTMatchersTraversalTest.cpp:729
@@ -645,2 +728,2 @@
   EXPECT_TRUE(matches("template struct C {}; C<42> c;",
   classTemplateSpecializationDecl(

I'd view the `hasAncestor` failure as an indirect symptom of the root problem, 
which is that we were failing to traverse some nodes. I prefer the new 
`hasName` test, since it more directly checks for that immediate problem.


https://reviews.llvm.org/D24268



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


[libcxx] r280771 - Improve CMake output when registering benchmarks

2016-09-06 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Sep  6 19:57:26 2016
New Revision: 280771

URL: http://llvm.org/viewvc/llvm-project?rev=280771=rev
Log:
Improve CMake output when registering benchmarks

Modified:
libcxx/trunk/benchmarks/CMakeLists.txt

Modified: libcxx/trunk/benchmarks/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/benchmarks/CMakeLists.txt?rev=280771=280770=280771=diff
==
--- libcxx/trunk/benchmarks/CMakeLists.txt (original)
+++ libcxx/trunk/benchmarks/CMakeLists.txt Tue Sep  6 19:57:26 2016
@@ -120,7 +120,7 @@ endmacro()
 file(GLOB BENCHMARK_TESTS "*.bench.cpp")
 foreach(test_path ${BENCHMARK_TESTS})
   get_filename_component(test_file "${test_path}" NAME)
-  message(STATUS "-- Adding Benchmark: ${test_file}")
+  message(STATUS "Adding Benchmark: ${test_file}")
   string(REPLACE ".bench.cpp" "" test_name "${test_file}")
   add_benchmark_test(${test_name} ${test_file})
 endforeach()


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


Re: [PATCH] D21803: [libcxxabi] Provide a fallback __cxa_thread_atexit() implementation

2016-09-06 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

LGTM modulo bug fix.



Comment at: src/cxa_thread_atexit.cpp:70
@@ +69,3 @@
+while (auto head = dtors) {
+  dtors = head->next;
+  head->dtor(head->obj);

There is a bug here. If `head->next == nullptr` and if `head->dtor(head->obj))` 
creates a TL variable in the destructor then that destructor will not be 
invoked.

Here's an updated test case which catches the bug: 
https://gist.github.com/EricWF/3bb50d4f28b91aa28d2adefea0e94a0e


https://reviews.llvm.org/D21803



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


Re: [PATCH] D24218: [libc++] Fix support for multibyte thousands_sep and decimal_point in moneypunct_byname and numpunct_byname.

2016-09-06 Thread Eric Fiselier via cfe-commits
EricWF retitled this revision from "[libc++] Fix support for multibyte 
thousands_sep and decimal_point in moneypunct_byname" to "[libc++] Fix support 
for multibyte thousands_sep and decimal_point in moneypunct_byname and 
numpunct_byname.".
EricWF updated the summary for this revision.
EricWF updated this revision to Diff 70494.

https://reviews.llvm.org/D24218

Files:
  src/locale.cpp
  
test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/decimal_point.pass.cpp
  
test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp
  
test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/grouping.pass.cpp
  
test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp

Index: test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp
===
--- test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp
+++ test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp
@@ -16,12 +16,11 @@
 
 // char_type thousands_sep() const;
 
-// TODO: investigation needed
-// XFAIL: linux-gnu
 
 #include 
 #include 
 
+#include "test_macros.h"
 #include "platform_support.h" // locale name macros
 
 int main()
@@ -54,15 +53,22 @@
 }
 {
 std::locale l(LOCALE_fr_FR_UTF_8);
+#if defined(TEST_HAS_GLIBC)
+const char sep = ' ';
+const wchar_t wsep = L' ';
+#else
+const char sep = ',';
+const wchar_t wsep = L',';
+#endif
 {
 typedef char C;
 const std::numpunct& np = std::use_facet(l);
-assert(np.thousands_sep() == ',');
+assert(np.thousands_sep() == sep);
 }
 {
 typedef wchar_t C;
 const std::numpunct& np = std::use_facet(l);
-assert(np.thousands_sep() == L',');
+assert(np.thousands_sep() == wsep);
 }
 }
 }
Index: test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/grouping.pass.cpp
===
--- test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/grouping.pass.cpp
+++ test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/grouping.pass.cpp
@@ -16,12 +16,10 @@
 
 // string grouping() const;
 
-// TODO: investigation needed
-// XFAIL: linux-gnu
-
 #include 
 #include 
 
+#include "test_macros.h"
 #include "platform_support.h" // locale name macros
 
 int main()
@@ -54,15 +52,20 @@
 }
 {
 std::locale l(LOCALE_fr_FR_UTF_8);
+#if defined(TEST_HAS_GLIBC)
+const char* const group = "\3";
+#else
+const char* const group = "\x7f";
+#endif
 {
 typedef char C;
 const std::numpunct& np = std::use_facet(l);
-assert(np.grouping() == "\x7F");
+assert(np.grouping() ==  group);
 }
 {
 typedef wchar_t C;
 const std::numpunct& np = std::use_facet(l);
-assert(np.grouping() == "\x7F");
+assert(np.grouping() == group);
 }
 }
 }
Index: test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp
===
--- test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp
+++ test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp
@@ -18,16 +18,11 @@
 
 // charT thousands_sep() const;
 
-// Failure related to GLIBC's use of U00A0 as mon_thousands_sep
-// and U002E as mon_decimal_point.
-// TODO: U00A0 should be investigated.
-// Possibly related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=16006
-// XFAIL: linux-gnu
-
 #include 
 #include 
 #include 
 
+#include "test_macros.h"
 #include "platform_support.h" // locale name macros
 
 class Fnf
@@ -114,22 +109,34 @@
 Fwt f(LOCALE_fr_FR_UTF_8, 1);
 assert(f.thousands_sep() == L' ');
 }
-
+// The below tests work around GLIBC's use of U00A0 as mon_thousands_sep
+// and U002E as mon_decimal_point.
+// TODO: Fix thousands_sep for 'char'.
+// related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=16006
+#ifndef TEST_HAS_GLIBC
+const char sep = ' ';
+const wchar_t wsep = L' ';
+#else
+// FIXME libc++ specifically works around \u00A0 by translating it into
+// a regular space.
+const char sep = ' ';
+const wchar_t wsep = L'\u00A0';
+#endif
 {
 Fnf f(LOCALE_ru_RU_UTF_8, 1);
-assert(f.thousands_sep() == ' ');
+assert(f.thousands_sep() == sep);
 }
 {
 Fnt f(LOCALE_ru_RU_UTF_8, 1);
-

r280768 - [scan-build-py] Increase precision of timestamp in report directory name

2016-09-06 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Tue Sep  6 18:42:51 2016
New Revision: 280768

URL: http://llvm.org/viewvc/llvm-project?rev=280768=rev
Log:
[scan-build-py] Increase precision of timestamp in report directory name

This commit improves compatibility with the perl version of scan-build.

The perl version of scan-build produces output report directories with
increasing lexicographic ordering. This ordering is relied on by the CmpRuns.py
tool in utils/analyzer when comparing results for build commands with multiple
steps. That tool tries to line up the output directory for each step between
different runs of the analyzer based on the increasing directory name.

The python version of scan-build uses file.mkdtemp() with a time stamp
prefix to create report directories. The timestamp has a 1-second precision.
This means that when analysis of a single build step takes less than a second
the ordering property that CmpRuns.py expects will sometimes not hold,
depending on the timing and the random suffix generated by mkdtemp(). Ultimately
this causes CmpRuns to incorrectly correlate results from build steps and report
spurious differences between runs.

This commit increases the precision of the timestamp used in scan-build-py to
the microsecond level. This approach still has the same underlying issue -- but
in practice analysis of any build step is unlikely to take less than a
millisecond.

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

Modified:
cfe/trunk/tools/scan-build-py/libscanbuild/report.py
cfe/trunk/tools/scan-build-py/tests/unit/test_report.py

Modified: cfe/trunk/tools/scan-build-py/libscanbuild/report.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-build-py/libscanbuild/report.py?rev=280768=280767=280768=diff
==
--- cfe/trunk/tools/scan-build-py/libscanbuild/report.py (original)
+++ cfe/trunk/tools/scan-build-py/libscanbuild/report.py Tue Sep  6 18:42:51 
2016
@@ -21,6 +21,7 @@ import glob
 import json
 import logging
 import contextlib
+import datetime
 from libscanbuild import duplicate_check
 from libscanbuild.clang import get_version
 
@@ -34,7 +35,8 @@ def report_directory(hint, keep):
 hint -- could specify the parent directory of the output directory.
 keep -- a boolean value to keep or delete the empty report directory. """
 
-stamp = time.strftime('scan-build-%Y-%m-%d-%H%M%S-', time.localtime())
+stamp_format = 'scan-build-%Y-%m-%d-%H-%M-%S-%f-'
+stamp = datetime.datetime.now().strftime(stamp_format)
 
 parentdir = os.path.abspath(hint)
 if not os.path.exists(parentdir):

Modified: cfe/trunk/tools/scan-build-py/tests/unit/test_report.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-build-py/tests/unit/test_report.py?rev=280768=280767=280768=diff
==
--- cfe/trunk/tools/scan-build-py/tests/unit/test_report.py (original)
+++ cfe/trunk/tools/scan-build-py/tests/unit/test_report.py Tue Sep  6 18:42:51 
2016
@@ -146,3 +146,16 @@ class GetPrefixFromCompilationDatabaseTe
 def test_empty(self):
 self.assertEqual(
 sut.commonprefix([]), '')
+
+class ReportDirectoryTest(unittest.TestCase):
+
+# Test that successive report directory names ascend in lexicographic
+# order. This is required so that report directories from two runs of
+# scan-build can be easily matched up to compare results.
+def test_directory_name_comparison(self):
+with libear.TemporaryDirectory() as tmpdir, \
+ sut.report_directory(tmpdir, False) as report_dir1, \
+ sut.report_directory(tmpdir, False) as report_dir2, \
+ sut.report_directory(tmpdir, False) as report_dir3:
+self.assertLess(report_dir1, report_dir2)
+self.assertLess(report_dir2, report_dir3)


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


Re: [PATCH] D24163: [scan-build-py] Increase precision of timestamp in report directory name

2016-09-06 Thread Devin Coughlin via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL280768: [scan-build-py] Increase precision of timestamp in 
report directory name (authored by dcoughlin).

Changed prior to commit:
  https://reviews.llvm.org/D24163?vs=70458=70493#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24163

Files:
  cfe/trunk/tools/scan-build-py/libscanbuild/report.py
  cfe/trunk/tools/scan-build-py/tests/unit/test_report.py

Index: cfe/trunk/tools/scan-build-py/libscanbuild/report.py
===
--- cfe/trunk/tools/scan-build-py/libscanbuild/report.py
+++ cfe/trunk/tools/scan-build-py/libscanbuild/report.py
@@ -21,6 +21,7 @@
 import json
 import logging
 import contextlib
+import datetime
 from libscanbuild import duplicate_check
 from libscanbuild.clang import get_version
 
@@ -34,7 +35,8 @@
 hint -- could specify the parent directory of the output directory.
 keep -- a boolean value to keep or delete the empty report directory. """
 
-stamp = time.strftime('scan-build-%Y-%m-%d-%H%M%S-', time.localtime())
+stamp_format = 'scan-build-%Y-%m-%d-%H-%M-%S-%f-'
+stamp = datetime.datetime.now().strftime(stamp_format)
 
 parentdir = os.path.abspath(hint)
 if not os.path.exists(parentdir):
Index: cfe/trunk/tools/scan-build-py/tests/unit/test_report.py
===
--- cfe/trunk/tools/scan-build-py/tests/unit/test_report.py
+++ cfe/trunk/tools/scan-build-py/tests/unit/test_report.py
@@ -146,3 +146,16 @@
 def test_empty(self):
 self.assertEqual(
 sut.commonprefix([]), '')
+
+class ReportDirectoryTest(unittest.TestCase):
+
+# Test that successive report directory names ascend in lexicographic
+# order. This is required so that report directories from two runs of
+# scan-build can be easily matched up to compare results.
+def test_directory_name_comparison(self):
+with libear.TemporaryDirectory() as tmpdir, \
+ sut.report_directory(tmpdir, False) as report_dir1, \
+ sut.report_directory(tmpdir, False) as report_dir2, \
+ sut.report_directory(tmpdir, False) as report_dir3:
+self.assertLess(report_dir1, report_dir2)
+self.assertLess(report_dir2, report_dir3)


Index: cfe/trunk/tools/scan-build-py/libscanbuild/report.py
===
--- cfe/trunk/tools/scan-build-py/libscanbuild/report.py
+++ cfe/trunk/tools/scan-build-py/libscanbuild/report.py
@@ -21,6 +21,7 @@
 import json
 import logging
 import contextlib
+import datetime
 from libscanbuild import duplicate_check
 from libscanbuild.clang import get_version
 
@@ -34,7 +35,8 @@
 hint -- could specify the parent directory of the output directory.
 keep -- a boolean value to keep or delete the empty report directory. """
 
-stamp = time.strftime('scan-build-%Y-%m-%d-%H%M%S-', time.localtime())
+stamp_format = 'scan-build-%Y-%m-%d-%H-%M-%S-%f-'
+stamp = datetime.datetime.now().strftime(stamp_format)
 
 parentdir = os.path.abspath(hint)
 if not os.path.exists(parentdir):
Index: cfe/trunk/tools/scan-build-py/tests/unit/test_report.py
===
--- cfe/trunk/tools/scan-build-py/tests/unit/test_report.py
+++ cfe/trunk/tools/scan-build-py/tests/unit/test_report.py
@@ -146,3 +146,16 @@
 def test_empty(self):
 self.assertEqual(
 sut.commonprefix([]), '')
+
+class ReportDirectoryTest(unittest.TestCase):
+
+# Test that successive report directory names ascend in lexicographic
+# order. This is required so that report directories from two runs of
+# scan-build can be easily matched up to compare results.
+def test_directory_name_comparison(self):
+with libear.TemporaryDirectory() as tmpdir, \
+ sut.report_directory(tmpdir, False) as report_dir1, \
+ sut.report_directory(tmpdir, False) as report_dir2, \
+ sut.report_directory(tmpdir, False) as report_dir3:
+self.assertLess(report_dir1, report_dir2)
+self.assertLess(report_dir2, report_dir3)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21678: Fix For pr28288 - Error message in shift of vector values

2016-09-06 Thread Akira Hatanaka via cfe-commits
This is urgent, so I’ve tried to come up with a patch to fix this. I tried 
reverting r278501 and then made changes to have Sema::CheckVectorOperands call 
tryVectorConvertAndSplat when the vector type is a normal gcc vector. This 
fixes the test case I sent and also doesn’t affect the regression tests except 
that clang prints different error messages in a few cases and doesn’t print an 
expected diagnostic in one case, which is line 63 of test/Sema/vector-cast.c. 
We currently expect clang to print a diagnostic when we have a compound 
assignment like “double += <1 X double>”, but my patch makes clang accept it.

> On Sep 5, 2016, at 6:36 AM, Vladimir Yakovlev via cfe-commits 
>  wrote:
> 
> I'll fix this.
> 
> 
> 
> Vladimir
> 
> 
> 
> ---
> 
> From: Akira Hatanaka >
> Date: Fri, Sep 2, 2016 at 3:00 AM
> Subject: Re: [PATCH] D21678: Fix For pr28288 - Error message in shift of 
> vector values
> To: vladimi...@gmail.com , 
> ulrich.weig...@de.ibm.com , 
> amjad.ab...@intel.com , guy.ben...@intel.com 
> , aaron.ball...@gmail.com 
> 
> Cc: ahata...@gmail.com , andreybokha...@gmail.com 
> , anastasia.stul...@arm.com 
> , dmitry.poluk...@gmail.com 
> , cfe-commits@lists.llvm.org 
> 
> 
> 
> ahatanak added a subscriber: ahatanak.
> ahatanak added a comment.
> 
> This patch causes clang to error out on the following code, which used to 
> compile fine:
> 
> $ cat f2.c
> 
>   typedef __attribute__((__ext_vector_type__(8))) unsigned short 
> vector_ushort8;
> 
>   vector_ushort8 foo1(void) {
> return 1 << (vector_ushort8){7,6,5,4,3,2,1,0};
>   }
> 
> $ clang f2.c -c
> 
> clang used to transform the scaler operand to a vector operand (similar to 
> the way gcc's vector is handled) when compiling for normal c/c++ (but printed 
> an error message when compiling for opencl), but this patch dropped the check 
> for LangOpts added in r230464 and changed that behavior. I don't think this 
> was intentional?
> 
> 
> 
> Repository:
>   rL LLVM
> 
> https://reviews.llvm.org/D21678 
> ___
> 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] D23284: Add -Rpass-with-hotness

2016-09-06 Thread Adam Nemet via cfe-commits
anemet added a comment.

In https://reviews.llvm.org/D23284#535258, @rsmith wrote:

> I think this should start with `-fdiagnostics` to group it with other similar 
> flags. `-fdiagnostics-include-hotness-in-remarks` seems too specific to me -- 
> I could imagine generating warnings from the middle-end including hotness 
> information, not just remarks. How about `-fdiagnostics-show-hotness`? (This 
> would fit nicely with the existing `-fdiagnostics-show-*` flags.)


SGTM.  I'll update the patch.


https://reviews.llvm.org/D23284



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


Re: [PATCH] D23284: Add -Rpass-with-hotness

2016-09-06 Thread Richard Smith via cfe-commits
rsmith added a comment.

In https://reviews.llvm.org/D23284#534919, @anemet wrote:

> In https://reviews.llvm.org/D23284#534879, @rsmith wrote:
>
> > I think this should not be an -R option at all; like -W flags, the idea is 
> > for -R to only act as a filter for which diagnostics are shown. This option 
> > seems much more closely related to options like -fdiagnostics-show-option 
> > and -fdiagnostics-format=, and so should probably have a 
> > -fdiagnostics-something name.
>
>
> Sounds fine to me.  Any preference from:
>
>   -fdiagnostics-include-hotness-in-remarks
>   -fpass-diagnostics-with-hotness
>   -fpass-diagnostics-include-hotness
>   
>
> or something else?


I think this should start with `-fdiagnostics` to group it with other similar 
flags. `-fdiagnostics-include-hotness-in-remarks` seems too specific to me -- I 
could imagine generating warnings from the middle-end including hotness 
information, not just remarks. How about `-fdiagnostics-show-hotness`? (This 
would fit nicely with the existing `-fdiagnostics-show-*` flags.)


https://reviews.llvm.org/D23284



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


Re: [PATCH] D24113: Allow implicit conversions between incompatible pointer types in overload resolution in C.

2016-09-06 Thread George Burgess IV via cfe-commits
george.burgess.iv marked an inline comment as done.
george.burgess.iv added a comment.

Thanks for the heads-up!

I'm assuming that below is an example of code that this patch broke?

  void foo(int *a, int) __attribute__((overloadable));
  void foo(unsigned int *a, unsigned int) __attribute__((overloadable));
  
  void callFoo() {
unsigned int i;
foo(, 0u); // fine.
foo(, 0); // now-ambiguous overload.
  }


Repository:
  rL LLVM

https://reviews.llvm.org/D24113



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


Re: [PATCH] D17741: adds __FILE_BASENAME__ builtin macro

2016-09-06 Thread Weiming Zhao via cfe-commits
weimingz added a comment.

ping?


https://reviews.llvm.org/D17741



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


[libcxx] r280754 - Try 2 - Remove include from ``

2016-09-06 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Sep  6 16:25:27 2016
New Revision: 280754

URL: http://llvm.org/viewvc/llvm-project?rev=280754=rev
Log:
Try 2 - Remove  include from ``

This patch removes the `` include from exception where it is no longer
needed. Unlike my previous attempt this patch also adds  where needed
in other headers like  and .

This won't fix the Firefox build issues discussed on IRC but it is more correct
for libc++.

Modified:
libcxx/trunk/include/exception
libcxx/trunk/include/new
libcxx/trunk/include/stdexcept
libcxx/trunk/include/typeinfo

Modified: libcxx/trunk/include/exception
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/exception?rev=280754=280753=280754=diff
==
--- libcxx/trunk/include/exception (original)
+++ libcxx/trunk/include/exception Tue Sep  6 16:25:27 2016
@@ -80,10 +80,6 @@ template  void rethrow_if_neste
 #include <__config>
 #include 
 #include 
-#if defined(_LIBCPP_NO_EXCEPTIONS)
-#include 
-#include 
-#endif
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header

Modified: libcxx/trunk/include/new
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/new?rev=280754=280753=280754=diff
==
--- libcxx/trunk/include/new (original)
+++ libcxx/trunk/include/new Tue Sep  6 16:25:27 2016
@@ -69,6 +69,9 @@ void  operator delete[](void* ptr, void*
 #include <__config>
 #include 
 #include 
+#ifdef _LIBCPP_NO_EXCEPTIONS
+#include 
+#endif
 
 #include <__undef___deallocate>
 

Modified: libcxx/trunk/include/stdexcept
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/stdexcept?rev=280754=280753=280754=diff
==
--- libcxx/trunk/include/stdexcept (original)
+++ libcxx/trunk/include/stdexcept Tue Sep  6 16:25:27 2016
@@ -45,6 +45,9 @@ public:
 #include <__config>
 #include 
 #include   // for string forward decl
+#ifdef _LIBCPP_NO_EXCEPTIONS
+#include 
+#endif
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header

Modified: libcxx/trunk/include/typeinfo
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/typeinfo?rev=280754=280753=280754=diff
==
--- libcxx/trunk/include/typeinfo (original)
+++ libcxx/trunk/include/typeinfo Tue Sep  6 16:25:27 2016
@@ -61,6 +61,9 @@ public:
 #include 
 #include 
 #include 
+#ifdef _LIBCPP_NO_EXCEPTIONS
+#include 
+#endif
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header


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


[libcxx] r280752 - Revert r280743 and r280745. Remove include from ``

2016-09-06 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Sep  6 16:06:41 2016
New Revision: 280752

URL: http://llvm.org/viewvc/llvm-project?rev=280752=rev
Log:
Revert r280743 and r280745. Remove  include from ``

Apparently I missed a number of additional include which need to be added.
Reverting so I can recommit as a single patch with all of the required includes.

Modified:
libcxx/trunk/include/exception
libcxx/trunk/include/typeinfo

Modified: libcxx/trunk/include/exception
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/exception?rev=280752=280751=280752=diff
==
--- libcxx/trunk/include/exception (original)
+++ libcxx/trunk/include/exception Tue Sep  6 16:06:41 2016
@@ -80,6 +80,10 @@ template  void rethrow_if_neste
 #include <__config>
 #include 
 #include 
+#if defined(_LIBCPP_NO_EXCEPTIONS)
+#include 
+#include 
+#endif
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header

Modified: libcxx/trunk/include/typeinfo
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/typeinfo?rev=280752=280751=280752=diff
==
--- libcxx/trunk/include/typeinfo (original)
+++ libcxx/trunk/include/typeinfo Tue Sep  6 16:06:41 2016
@@ -61,7 +61,6 @@ public:
 #include 
 #include 
 #include 
-#include 
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header


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


Re: [PATCH] D24183: A clang tool for changing surrouding namespaces of class/function definitions.

2016-09-06 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 70465.
ioeric marked 10 inline comments as done.
ioeric added a comment.

- Addressed some review comments.


https://reviews.llvm.org/D24183

Files:
  CMakeLists.txt
  change-namespace/CMakeLists.txt
  change-namespace/ChangeNamespace.cpp
  change-namespace/ChangeNamespace.h
  change-namespace/tool/CMakeLists.txt
  change-namespace/tool/ClangChangeNamespace.cpp
  test/CMakeLists.txt
  test/change-namespace/simple-move.cpp
  unittests/CMakeLists.txt
  unittests/change-namespace/CMakeLists.txt
  unittests/change-namespace/ChangeNamespaceTests.cpp

Index: unittests/change-namespace/ChangeNamespaceTests.cpp
===
--- /dev/null
+++ unittests/change-namespace/ChangeNamespaceTests.cpp
@@ -0,0 +1,234 @@
+//===-- ChangeNamespaceTests.cpp - Change namespace unit tests ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "ChangeNamespace.h"
+#include "unittests/Tooling/RewriterTestContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Basic/FileManager.h"
+#include "clang/Basic/FileSystemOptions.h"
+#include "clang/Basic/VirtualFileSystem.h"
+#include "clang/Format/Format.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/PCHContainerOperations.h"
+#include "clang/Tooling/Refactoring.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace change_namespace {
+namespace {
+
+class ChangeNamespaceTest : public ::testing::Test {
+public:
+  std::string runChangeNamespaceOnCode(llvm::StringRef Code) {
+clang::RewriterTestContext Context;
+clang::FileID ID = Context.createInMemoryFile(FileName, Code);
+
+std::map FileToReplacements;
+change_namespace::ChangeNamespaceTool NamespaceTool(
+OldNamespace, NewNamespace, FilePattern, );
+ast_matchers::MatchFinder Finder;
+NamespaceTool.registerMatchers();
+std::unique_ptr Factory =
+tooling::newFrontendActionFactory();
+tooling::runToolOnCodeWithArgs(Factory->create(), Code, {"-std=c++11"},
+   FileName);
+formatAndApplyAllReplacements(FileToReplacements, Context.Rewrite);
+return format(Context.getRewrittenText(ID));
+  }
+
+  std::string format(llvm::StringRef Code) {
+tooling::Replacements Replaces = format::reformat(
+format::getLLVMStyle(), Code, {tooling::Range(0, Code.size())});
+auto ChangedCode = tooling::applyAllReplacements(Code, Replaces);
+EXPECT_TRUE(static_cast(ChangedCode));
+if (!ChangedCode) {
+  llvm::errs() << llvm::toString(ChangedCode.takeError());
+  return "";
+}
+return *ChangedCode;
+  }
+
+protected:
+  std::string FileName = "input.cc";
+  std::string OldNamespace = "na::nb";
+  std::string NewNamespace = "x::y";
+  std::string FilePattern = "input.cc";
+};
+
+TEST_F(ChangeNamespaceTest, NoMatchingNamespace) {
+  std::string Code = "namespace na {\n"
+ "namespace nx {\n"
+ "class A {};\n"
+ "} // namespace nx\n"
+ "} // namespace na\n";
+  std::string Expected = "namespace na {\n"
+ "namespace nx {\n"
+ "class A {};\n"
+ "} // namespace nx\n"
+ "} // namespace na\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
+TEST_F(ChangeNamespaceTest, SimpleMoveWithoutTypeRefs) {
+  std::string Code = "namespace na {\n"
+ "namespace nb {\n"
+ "class A {};\n"
+ "} // namespace nb\n"
+ "} // namespace na\n";
+  std::string Expected = "\n\n"
+ "namespace x {\n"
+ "namespace y {\n"
+ "class A {};\n"
+ "} // namespace y\n"
+ "} // namespace x\n";
+  EXPECT_EQ(format(Expected), runChangeNamespaceOnCode(Code));
+}
+
+TEST_F(ChangeNamespaceTest, SimpleMoveIntoAnotherNestedNamespace) {
+  NewNamespace = "na::nc";
+  std::string Code = "namespace na {\n"
+ "namespace nb {\n"
+ "class A {};\n"
+ "} // namespace nb\n"
+ "} // namespace na\n";
+  std::string Expected = "namespace na {\n"
+ "\n"
+ "namespace nc {\n"
+ "class A {};\n"
+ "} // namespace nc\n"
+ 

Re: [PATCH] D24268: Traversing template paramter lists of DeclaratorDecls and/or TagDecls.

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


Comment at: include/clang/AST/RecursiveASTVisitor.h:487-489
@@ +486,5 @@
+  // Traverses template parameter lists of either a DeclaratorDecl or TagDecl.
+  template ::value ||
+  std::is_base_of::value>::type>
+  bool TraverseDeclTemplateParameterLists(T *D);

What's the purpose of the `enable_if` here?


Comment at: include/clang/AST/RecursiveASTVisitor.h:1728
@@ -1708,2 +1727,3 @@
 
+  TRY_TO(TraverseDeclTemplateParameterLists(D));
   TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));

lukasza wrote:
> I think that tweaks of EnumDecl traversal together with tweaks of 
> TraverseRecordHelper tweaks, take care of all the relevant node types derived 
> from TagDecl:
> 
> - EnumDecl - traversal now calls TraverseDeclTemplateParameterLists 
> (+EnumDecl is covered by the new unit tests)
> - RecordDecl - TraverseRecordHelper now calls 
> TraverseDeclTemplateParameterLists (+RecordDecl is covered by the new unit 
> tests)
> - CXXRecordDecl - traversal includes a call to TraverseRecordHelper
> 
> I believe that nodes derived further from CXXRecordDecl cannot have a 
> template parameter list (?):
> - ClassTemplateSpecializationDecl
> - ClassTemplatePartialSpecializationDecl
> If this is not correct, then can you please help me see the shape of unit 
> tests that would cover these nodes?
I don't think `ClassTemplateSpecializationDecl` can have a template parameter 
list for its qualifier. A `ClassTemplatePartialSpecializationDecl` can, though:

  template struct A {
template struct B; 
  };
  template template struct A::B {};


Comment at: include/clang/AST/RecursiveASTVisitor.h:1823
@@ -1802,2 +1822,3 @@
 bool RecursiveASTVisitor::TraverseDeclaratorHelper(DeclaratorDecl *D) 
{
+  TRY_TO(TraverseDeclTemplateParameterLists(D));
   TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));

lukasza wrote:
> I think that TraverseDeclaratorHelper together with TraverseFunctionHelper 
> tweaks, this takes care of all node types derived from DeclaratorDecl:
> - FieldDecl - traversal calls TraverseDeclaratorHelper
> - FunctionDecl - traversal calls TraverseFunctionHelper
> - CXXMethodDecl - traversal calls TraverseFunctionHelper (+CXXMethodDecl is 
> covered by the new unit tests)
> - CXXConstructorDecl - traversal calls TraverseFunctionHelper
> - CXXConversionDecl - traversal calls TraverseFunctionHelper
> - CXXDestructorDecl - traversal calls TraverseFunctionHelper
> - VarDecl - TraverseVarHelper calls TraverseDeclaratorHelper (+VarDecl is 
> covered by the new unit tests)
> 
> I believe that nodes derived further from VarDecl cannot have a template 
> parameter list (?), but most of them should still be safe (because their 
> traversal goes through TraverseVarHelper):
> - DecompositionDecl - traversal calls TraverseVarHelper
> - ImplicitParamDecl - traversal calls TraverseVarHelper
> - OMPCapturedExprDecl - traversal calls TraverseVarHelper
> - ParmVarDecl - traversal calls TraverseVarHelper
> - VarTemplateSpecializationDecl
> - VarTemplatePartialSpecializationDecl
> 
> Please let me know if I am wrong above and it is indeed possible to have 
> template parameter lists next to VarTemplateSpecializationDecl and/or 
> VarTemplatePartialSpecializationDecl (and I would also appreciate if you 
> could help me see the shape of unit tests that would cover these nodes).
`VarTemplatePartialSpecializationDecl`s can have template parameter lists:

  template struct A { template static int n; };
  template template int A::n;

I don't think other `VarTemplateSpecializationDecl`s can.


Comment at: include/clang/AST/RecursiveASTVisitor.h:1870
@@ -1848,2 +1869,3 @@
 bool RecursiveASTVisitor::TraverseFunctionHelper(FunctionDecl *D) {
+  TRY_TO(TraverseDeclTemplateParameterLists(D));
   TRY_TO(TraverseNestedNameSpecifierLoc(D->getQualifierLoc()));

lukasza wrote:
> Richard, in https://llvm.org/bugs/show_bug.cgi?id=29042#c6 you've suggested 
> reusing TraverseDeclaratorHelper here.  I agree that there are refactoring 
> and code reusing opportunities here (e.g. TraverseNestedNameSpecifier[Loc] 
> are getting called from both TraverseDeclaratorHelper and from 
> TraverseFunctionHelper), but I didn't pursue them in this patch, because I 
> was worried about little details:
> 
> 1. traversal order (i.e. TraverseDeclaratorHelper traverses 
> NestedNameSpecifier immediately before traversing TypeSourceInfo;  this is 
> different than TraverseFunctionHelper which traverses DeclarationNameInfo 
> in-between traversing NestedNameSpecifier and TypeSourceInfo)
> 
> 2. traversal in absence of TypeSourceInfo (i.e. when TypeSourceInfo is 
> missing, then TraverseDeclaratorHelper traverses Type;  this is different 
> than TraverseFunctionHelper which in this case 1) checks 
> shouldVisitImplicitCode condition and only then 2) traverses function 
> 

[PATCH] D24278: [analyzer] Extend bug reports with extra notes.

2016-09-06 Thread Artem Dergachev via cfe-commits
NoQ created this revision.
NoQ added reviewers: zaks.anna, dcoughlin, xazax.hun, a.sidorin, teemperor, 
v.g.vassilev.
NoQ added a subscriber: cfe-commits.

This patch allows injecting extra note-like diagnostics into bug reports, which 
are separate from path diagnostics. Previously, we could only display 
single-piece warnings and auto-generated path diagnostics; the latter could 
have been extended with the means of bug reporter visitors, however diagnostics 
injected by the visitors were still tied to the execution paths.

The primary purpose of this patch is to get the Clone checker integrated into 
the clang static analyzer's bug reporter mechanism. It is absolutely vital to 
this checker to display a warning that refers to multiple source ranges (code 
clones). This patch properly integrates the Clone checker, so that its warnings 
were visible in the analyzer GUIs such as scan-view.

Other checkers, even path-sensitive ones, could also benefit from the ability 
to add extra diagnostic pieces that are separate from path events. For example, 
if a bug report refers to a declaration of a class member, it is a good idea to 
highlight the relevant declaration, which may be far away from the execution 
path. This patch applies the new technique to the ObjCDealloc checker. Here we 
also see how the new extra notes interact with other path pieces.

HTML diagnostic consumer (`-analyzer-output=html`) is updated to use the new 
technique. Extra notes appear as blue planks (unlike the yellow path event 
planks and grey control flow planks), they are not numbered, and cannot be 
navigated through arrows, but they are included in the header. This represents 
the idea of how extra notes should ideally look like. The color is, of course, 
is chosen arbitrarily. Here are some examples of the newly generated HTML 
reports: {F2409277} {F2409279} {F2409280} {F2409281}

Null diagnostic consumer (with `-analyzer-output` unspecified) displays extra 
notes as "note:" diagnostics. It makes testing extra note pieces easier. Note 
that normal path notes are not displayed at this mode, so i'm not absolutely 
sure this is the right decision; however, this lets clone checker tests work 
without changes.

Text diagnostic consumer (with `-analyzer-output=text`) displays extra notes as 
"note:" diagnostics before the path diagnostics.

Plist diagnostic consumer was not updated yet(!) Currently, it ignores extra 
notes. This is because it is important to agree upon the format, so this 
decision will be delayed. Feedback on this matter is welcome :)

An option is added, `-analyzer-config extra-notes-as-events=true` (defaults to 
`false`), which converts extra notes to path events before sending to any 
diagnostic consumer. This allows to see the newly added notes in the Plist 
diagnostic consumer and display them without any changes to the viewer 
application (such as Xcode), however the looks would probably not be ideal or 
user-friendly (see also "HTML diagnostic consumer" above). The extra notes are 
put at the beginning, before any path events.

I slightly fixed the clone checker diagnostics. In particular, diagnostics 
cannot end with a period, and i capitalized the first letter. Also made slight 
changes to the suspicious clone structure, because path pieces require more 
than source ranges to operate (didn't look why though).

This patch includes a minor refactoring in `FlushReport()`, which introduces 
the `BugReport::isPathSensitive()` method and uses it. This should have no 
functional change, however it adds a stronger assertion, and, most importantly, 
this refactoring was useful for me to understand this piece of code and realize 
that i'm putting my code in the right place, so i decided that i should keep it.

https://reviews.llvm.org/D24278

Files:
  include/clang/Analysis/CloneDetection.h
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
  include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
  lib/Analysis/CloneDetection.cpp
  lib/Rewrite/HTMLRewrite.cpp
  lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
  lib/StaticAnalyzer/Checkers/CloneChecker.cpp
  lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  lib/StaticAnalyzer/Core/BugReporter.cpp
  lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
  lib/StaticAnalyzer/Core/PathDiagnostic.cpp
  lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
  lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  test/Analysis/DeallocMissingRelease.m
  test/Analysis/PR2978.m
  test/Analysis/copypaste/blocks.cpp
  test/Analysis/copypaste/function-try-block.cpp
  test/Analysis/copypaste/functions.cpp
  test/Analysis/copypaste/macro-complexity.cpp
  test/Analysis/copypaste/macros.cpp
  test/Analysis/copypaste/objc-methods.m
  test/Analysis/copypaste/plist-diagnostics-extra-notes-as-events.cpp
  test/Analysis/copypaste/plist-diagnostics.cpp
  test/Analysis/copypaste/sub-sequences.cpp
  test/Analysis/copypaste/suspicious-clones.cpp
  

[libcxx] r280745 - Add missing include. Sorry about the bot breakage

2016-09-06 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Sep  6 15:10:13 2016
New Revision: 280745

URL: http://llvm.org/viewvc/llvm-project?rev=280745=rev
Log:
Add missing  include. Sorry about the bot breakage

Modified:
libcxx/trunk/include/typeinfo

Modified: libcxx/trunk/include/typeinfo
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/typeinfo?rev=280745=280744=280745=diff
==
--- libcxx/trunk/include/typeinfo (original)
+++ libcxx/trunk/include/typeinfo Tue Sep  6 15:10:13 2016
@@ -61,6 +61,7 @@ public:
 #include 
 #include 
 #include 
+#include 
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header


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


Re: [PATCH] D24243: [clang-move] A prototype tool for moving class definition to new file.

2016-09-06 Thread Eric Liu via cfe-commits
ioeric added a comment.

NIce! Some initial comments.



Comment at: clang-move/ClangMove.cpp:38
@@ +37,3 @@
+  const clang::Module * /*Imported*/) override {
+if (const auto *FileEntry = SM.getFileEntryForID(SM.getFileID(HashLoc))) {
+  if (IsAngled) {

Might want to comment on how #include "old_header" is handled here?


Comment at: clang-move/ClangMove.cpp:39
@@ +38,3 @@
+if (const auto *FileEntry = SM.getFileEntryForID(SM.getFileID(HashLoc))) {
+  if (IsAngled) {
+MoveTool->addIncludes("#include <" + FileName.str() + ">\n",

Braces not needed.


Comment at: clang-move/ClangMove.cpp:103
@@ +102,3 @@
+ const clang::SourceManager *SM) {
+  // Gets the ending ";".
+  auto EndLoc = clang::Lexer::getLocForEndOfToken(D->getLocEnd(), 0, *SM,

Consider the code below to also include trailing comment.
clang::SourceLocation after_semi = clang::Lexer::findLocationAfterToken(
D->getLocEnd, clang::tok::semi, *SM,
result.Context->getLangOpts(),
/*SkipTrailingWhitespaceAndNewLine=*/true);



Comment at: clang-move/ClangMove.cpp:113
@@ +112,3 @@
+clang::tooling::Replacements
+createInsertedReplacements(const std::vector ,
+   const std::vector ,

Intuitively, it would be easier and more efficient if you construct the code as 
a string and then insert the code with one replacement.


Comment at: clang-move/ClangMove.cpp:119
@@ +118,3 @@
+  // Add #Includes.
+  // FIXME: Filter out  the old_header.h.
+  for (const auto  : Includes) {

FIXME: add header guard for new header file.


Comment at: clang-move/ClangMove.cpp:125
@@ +124,3 @@
+
+  // Add moved class definition and its related declarations. All declarations
+  // in same namespace are grouped together.

If two declarations in the same namespace are not consecutive in the vector 
(i.e. there is a decl in a different ns between them), will they be put into 
two canonical namespace blocks?


Comment at: clang-move/ClangMove.cpp:129
@@ +128,3 @@
+  for (const auto  : Decls) {
+std::vector DeclNamespaces = GetNamespaces(MovedDecl.Decl);
+auto CurrentIt = CurrentNamespaces.begin();

Is it possible to restrict all `MovedDecl.Decl` to NamedDecl so that we can use 
`getQualifiedNameAsString` instead of having a second implementation of 
retrieving namespaces. 

Also how is anonymous namespace handled here?




Comment at: clang-move/ClangMove.cpp:157
@@ +156,3 @@
+
+clang::tooling::Replacement InsertedReplacement(
+FileName, 0, 0, getDeclarationSourceText(MovedDecl.Decl, 
MovedDecl.SM));

FIXME: also consider comments for the declaration.


Comment at: clang-move/ClangMove.cpp:199
@@ +198,3 @@
+
+  // Match functions defined in anonymous namespace.
+  Finder->addMatcher(

What about static functions?


Comment at: clang-move/ClangMove.cpp:210
@@ +209,3 @@
+  this);
+}
+

FIXME: support out-of-line member variable initializations etc? Or is it 
already covered?


Comment at: clang-move/ClangMove.cpp:240
@@ +239,3 @@
+llvm::StringRef FileName) {
+  if (!Spec.OldHeader.empty() && FileName.endswith(Spec.OldHeader)) {
+HeaderIncludes.push_back(IncludeLine.str());

No braces.

Also, I am worrying if `endswith` is a safe way to compare files. For example, 
what if `FileName` is relative path? 


Comment at: clang-move/ClangMove.cpp:254
@@ +253,3 @@
+  MovedDecl.Decl->getLocEnd(), 0, *MovedDecl.SM, clang::LangOptions());
+  clang::tooling::Replacement RemovedReplacement(
+  *MovedDecl.SM, clang::CharSourceRange::getTokenRange(

nit: `RemovedReplacement` sounds like the replacement itself is being removed. 
`RemoveReplacement` would be better IMO.


Comment at: clang-move/ClangMove.h:39
@@ +38,3 @@
+  struct MoveDefinitionSpec {
+std::string Name;
+std::string OldHeader;

Should the `Name` be fully qualified?


Comment at: clang-move/ClangMove.h:52
@@ +51,3 @@
+
+  void registerMatchers(clang::ast_matchers::MatchFinder *match_finder);
+

Variable style. Here and some more below.


Comment at: clang-move/ClangMove.h:59
@@ +58,3 @@
+
+  void addIncludes(llvm::StringRef include_line, llvm::StringRef file_name);
+

A comment for what this function does would be appreciated.


Comment at: clang-move/ClangMove.h:65
@@ +64,3 @@
+
+  const MoveDefinitionSpec 
+  // The Key is file path, value is the replacements being applied to the file.

Is there any reason why you 

[libcxx] r280743 - Remove unneeded includes in after removing __libcpp_throw

2016-09-06 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue Sep  6 14:56:40 2016
New Revision: 280743

URL: http://llvm.org/viewvc/llvm-project?rev=280743=rev
Log:
Remove unneeded includes in  after removing __libcpp_throw

Modified:
libcxx/trunk/include/exception

Modified: libcxx/trunk/include/exception
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/exception?rev=280743=280742=280743=diff
==
--- libcxx/trunk/include/exception (original)
+++ libcxx/trunk/include/exception Tue Sep  6 14:56:40 2016
@@ -80,10 +80,6 @@ template  void rethrow_if_neste
 #include <__config>
 #include 
 #include 
-#if defined(_LIBCPP_NO_EXCEPTIONS)
-#include 
-#include 
-#endif
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header


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


[clang-tools-extra] r280741 - [include-fixer] Fix some Clang-tidy modernize-use-override and Include What You Use warnings; other minor fixes.

2016-09-06 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Tue Sep  6 14:53:26 2016
New Revision: 280741

URL: http://llvm.org/viewvc/llvm-project?rev=280741=rev
Log:
[include-fixer] Fix some Clang-tidy modernize-use-override and Include What You 
Use warnings; other minor fixes.

Differential revision: https://reviews.llvm.org/D24179

Modified:

clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.cpp

clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.h

Modified: 
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.cpp?rev=280741=280740=280741=diff
==
--- 
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.cpp 
(original)
+++ 
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.cpp 
Tue Sep  6 14:53:26 2016
@@ -8,6 +8,10 @@
 
//===--===//
 
 #include "FindAllSymbolsAction.h"
+#include "FindAllMacros.h"
+#include "clang/Lex/PPCallbacks.h"
+#include "clang/Lex/Preprocessor.h"
+#include "llvm/ADT/STLExtras.h"
 
 namespace clang {
 namespace find_all_symbols {

Modified: 
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.h?rev=280741=280740=280741=diff
==
--- 
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.h 
(original)
+++ 
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.h 
Tue Sep  6 14:53:26 2016
@@ -10,13 +10,15 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_FIND_ALL_SYMBOLS_ACTION_H
 #define LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_FIND_ALL_SYMBOLS_ACTION_H
 
-#include "FindAllMacros.h"
 #include "FindAllSymbols.h"
 #include "HeaderMapCollector.h"
 #include "PragmaCommentHandler.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Frontend/CompilerInstance.h"
-#include "clang/Frontend/FrontendActions.h"
+#include "clang/Frontend/FrontendAction.h"
 #include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/StringRef.h"
+#include 
 
 namespace clang {
 namespace find_all_symbols {
@@ -46,7 +48,7 @@ public:
   const HeaderMapCollector::RegexHeaderMap *RegexHeaderMap = nullptr)
   : Reporter(Reporter), RegexHeaderMap(RegexHeaderMap) {}
 
-  virtual clang::FrontendAction *create() override {
+  clang::FrontendAction *create() override {
 return new FindAllSymbolsAction(Reporter, RegexHeaderMap);
   }
 


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


Re: [PATCH] D24179: [include-fixer] Fix some Clang-tidy modernize-use-override and Include What You Use warnings; other minor fixes

2016-09-06 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL280741: [include-fixer] Fix some Clang-tidy 
modernize-use-override and Include What… (authored by eugenezelenko).

Changed prior to commit:
  https://reviews.llvm.org/D24179?vs=70121=70459#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24179

Files:
  
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.cpp
  clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.h

Index: 
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.cpp
===
--- 
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.cpp
+++ 
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.cpp
@@ -8,6 +8,10 @@
 
//===--===//
 
 #include "FindAllSymbolsAction.h"
+#include "FindAllMacros.h"
+#include "clang/Lex/PPCallbacks.h"
+#include "clang/Lex/Preprocessor.h"
+#include "llvm/ADT/STLExtras.h"
 
 namespace clang {
 namespace find_all_symbols {
Index: 
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.h
===
--- 
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.h
+++ 
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.h
@@ -10,13 +10,15 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_FIND_ALL_SYMBOLS_ACTION_H
 #define LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_FIND_ALL_SYMBOLS_ACTION_H
 
-#include "FindAllMacros.h"
 #include "FindAllSymbols.h"
 #include "HeaderMapCollector.h"
 #include "PragmaCommentHandler.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Frontend/CompilerInstance.h"
-#include "clang/Frontend/FrontendActions.h"
+#include "clang/Frontend/FrontendAction.h"
 #include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/StringRef.h"
+#include 
 
 namespace clang {
 namespace find_all_symbols {
@@ -46,7 +48,7 @@
   const HeaderMapCollector::RegexHeaderMap *RegexHeaderMap = nullptr)
   : Reporter(Reporter), RegexHeaderMap(RegexHeaderMap) {}
 
-  virtual clang::FrontendAction *create() override {
+  clang::FrontendAction *create() override {
 return new FindAllSymbolsAction(Reporter, RegexHeaderMap);
   }
 


Index: clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.cpp
===
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.cpp
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.cpp
@@ -8,6 +8,10 @@
 //===--===//
 
 #include "FindAllSymbolsAction.h"
+#include "FindAllMacros.h"
+#include "clang/Lex/PPCallbacks.h"
+#include "clang/Lex/Preprocessor.h"
+#include "llvm/ADT/STLExtras.h"
 
 namespace clang {
 namespace find_all_symbols {
Index: clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.h
===
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.h
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbolsAction.h
@@ -10,13 +10,15 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_FIND_ALL_SYMBOLS_ACTION_H
 #define LLVM_CLANG_TOOLS_EXTRA_FIND_ALL_SYMBOLS_FIND_ALL_SYMBOLS_ACTION_H
 
-#include "FindAllMacros.h"
 #include "FindAllSymbols.h"
 #include "HeaderMapCollector.h"
 #include "PragmaCommentHandler.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Frontend/CompilerInstance.h"
-#include "clang/Frontend/FrontendActions.h"
+#include "clang/Frontend/FrontendAction.h"
 #include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/StringRef.h"
+#include 
 
 namespace clang {
 namespace find_all_symbols {
@@ -46,7 +48,7 @@
   const HeaderMapCollector::RegexHeaderMap *RegexHeaderMap = nullptr)
   : Reporter(Reporter), RegexHeaderMap(RegexHeaderMap) {}
 
-  virtual clang::FrontendAction *create() override {
+  clang::FrontendAction *create() override {
 return new FindAllSymbolsAction(Reporter, RegexHeaderMap);
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24243: [clang-move] A prototype tool for moving class definition to new file.

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

Probably old_source/new_source will be better, because different extensions are 
used for C++ files.


https://reviews.llvm.org/D24243



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


Re: [PATCH] D24272: clang-format: [JS] whitespace required between ! and as.

2016-09-06 Thread Martin Probst via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL280731: clang-format: [JS] whitespace required between ! and 
as. (authored by mprobst).

Changed prior to commit:
  https://reviews.llvm.org/D24272?vs=70442=70446#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24272

Files:
  cfe/trunk/lib/Format/TokenAnnotator.cpp
  cfe/trunk/unittests/Format/FormatTestJS.cpp

Index: cfe/trunk/lib/Format/TokenAnnotator.cpp
===
--- cfe/trunk/lib/Format/TokenAnnotator.cpp
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp
@@ -2158,6 +2158,8 @@
 tok::r_square, tok::r_brace) ||
Left.Tok.isLiteral()))
   return false;
+if (Left.is(tok::exclaim) && Right.is(Keywords.kw_as))
+  return true; // "x! as string"
   } else if (Style.Language == FormatStyle::LK_Java) {
 if (Left.is(tok::r_square) && Right.is(tok::l_brace))
   return true;
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -1236,6 +1236,7 @@
   verifyFormat("x = x as [a, b];");
   verifyFormat("x = x as {a: string};");
   verifyFormat("x = x as (string);");
+  verifyFormat("x = x! as (string);");
 }
 
 TEST_F(FormatTestJS, TypeArguments) {


Index: cfe/trunk/lib/Format/TokenAnnotator.cpp
===
--- cfe/trunk/lib/Format/TokenAnnotator.cpp
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp
@@ -2158,6 +2158,8 @@
 tok::r_square, tok::r_brace) ||
Left.Tok.isLiteral()))
   return false;
+if (Left.is(tok::exclaim) && Right.is(Keywords.kw_as))
+  return true; // "x! as string"
   } else if (Style.Language == FormatStyle::LK_Java) {
 if (Left.is(tok::r_square) && Right.is(tok::l_brace))
   return true;
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -1236,6 +1236,7 @@
   verifyFormat("x = x as [a, b];");
   verifyFormat("x = x as {a: string};");
   verifyFormat("x = x as (string);");
+  verifyFormat("x = x! as (string);");
 }
 
 TEST_F(FormatTestJS, TypeArguments) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r280731 - clang-format: [JS] whitespace required between ! and as.

2016-09-06 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Tue Sep  6 13:55:34 2016
New Revision: 280731

URL: http://llvm.org/viewvc/llvm-project?rev=280731=rev
Log:
clang-format: [JS] whitespace required between ! and as.

Summary:
Before:
x!as string
After:
x! as string

Reviewers: djasper

Subscribers: klimek, cfe-commits

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

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=280731=280730=280731=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue Sep  6 13:55:34 2016
@@ -2158,6 +2158,8 @@ bool TokenAnnotator::spaceRequiredBefore
 tok::r_square, tok::r_brace) ||
Left.Tok.isLiteral()))
   return false;
+if (Left.is(tok::exclaim) && Right.is(Keywords.kw_as))
+  return true; // "x! as string"
   } else if (Style.Language == FormatStyle::LK_Java) {
 if (Left.is(tok::r_square) && Right.is(tok::l_brace))
   return true;

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=280731=280730=280731=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Tue Sep  6 13:55:34 2016
@@ -1236,6 +1236,7 @@ TEST_F(FormatTestJS, CastSyntax) {
   verifyFormat("x = x as [a, b];");
   verifyFormat("x = x as {a: string};");
   verifyFormat("x = x as (string);");
+  verifyFormat("x = x! as (string);");
 }
 
 TEST_F(FormatTestJS, TypeArguments) {


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


Re: [PATCH] D24243: [clang-move] A prototype tool for moving class definition to new file.

2016-09-06 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added inline comments.


Comment at: clang-move/ClangMove.h:13
@@ +12,3 @@
+
+#include 
+#include 

Isn't C++ headers should be after Clang headers?


https://reviews.llvm.org/D24243



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


Re: [PATCH] D23852: [SemaObjC] Fix crash while parsing type arguments and protocols

2016-09-06 Thread Bruno Cardoso Lopes via cfe-commits
bruno added a comment.

Ping!

In https://reviews.llvm.org/D23852#529308, @aaron.ballman wrote:

> In https://reviews.llvm.org/D23852#525291, @doug.gregor wrote:
>
> > This will work, but it's *really* unfortunate to put tentative parsing into 
> > this code path because tentative parsing is far from free, and specialized 
> > Objective-C types are getting pretty common in Objective-C headers. Why 
> > can't the callers be taught to handle EOF and bail out?
>
>
> The unfortunate part of that is it makes all of the callers fragile -- we 
> have to sprinkle "are we at EOF now" checks all over, or risk running into 
> the same problem later. We don't typically do that (there are only 7 eof 
> checks in the parser currently, this adds 6 more). I don't know which option 
> is worse.


Likewise, I'm not sure what's the best tradeoff. And there's probably more to 
come: some part of PR23057 is likely the need to properly handle EOFs.


https://reviews.llvm.org/D23852



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


Re: [PATCH] D24272: clang-format: [JS] whitespace required between ! and as.

2016-09-06 Thread Daniel Jasper via cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

Looks good.


https://reviews.llvm.org/D24272



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


Re: [PATCH] D24048: [Driver] [Darwin] Add sanitizer libraries even if -nodefaultlibs is passed

2016-09-06 Thread Vitaly Buka via cfe-commits
vitalybuka resigned from this revision.
vitalybuka removed a reviewer: vitalybuka.
vitalybuka added a comment.

I have no strong opinion on that. There is already exception for startfiles, so 
maybe sanitizes are OK as well.


https://reviews.llvm.org/D24048



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


Re: [PATCH] D24257: clang-format: [JS] ignore comments when wrapping returns.

2016-09-06 Thread Martin Probst via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL280730: clang-format: [JS] ignore comments when wrapping 
returns. (authored by mprobst).

Changed prior to commit:
  https://reviews.llvm.org/D24257?vs=70405=70444#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24257

Files:
  cfe/trunk/lib/Format/TokenAnnotator.cpp
  cfe/trunk/unittests/Format/FormatTestJS.cpp

Index: cfe/trunk/lib/Format/TokenAnnotator.cpp
===
--- cfe/trunk/lib/Format/TokenAnnotator.cpp
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp
@@ -2381,7 +2381,12 @@
   Keywords.kw_implements))
   return true;
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
-if (Left.is(tok::kw_return))
+const FormatToken *NonComment = Right.getPreviousNonComment();
+if (Left.isOneOf(tok::kw_return, tok::kw_continue, tok::kw_break,
+ tok::kw_throw) ||
+(NonComment &&
+ NonComment->isOneOf(tok::kw_return, tok::kw_continue, tok::kw_break,
+ tok::kw_throw)))
   return false; // Otherwise a semicolon is inserted.
 if (Left.is(TT_JsFatArrow) && Right.is(tok::l_brace))
   return false;
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -686,7 +686,9 @@
   // would change due to automatic semicolon insertion.
   // See http://www.ecma-international.org/ecma-262/5.1/#sec-7.9.1.
   verifyFormat("return a;", getGoogleJSStyleWithColumns(10));
+  verifyFormat("return /* hello! */ a;", getGoogleJSStyleWithColumns(10));
   verifyFormat("continue a;", getGoogleJSStyleWithColumns(10));
+  verifyFormat("continue /* hello! */ a;", 
getGoogleJSStyleWithColumns(10));
   verifyFormat("break a;", getGoogleJSStyleWithColumns(10));
   verifyFormat("throw a;", getGoogleJSStyleWithColumns(10));
   verifyFormat("a++;", getGoogleJSStyleWithColumns(10));


Index: cfe/trunk/lib/Format/TokenAnnotator.cpp
===
--- cfe/trunk/lib/Format/TokenAnnotator.cpp
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp
@@ -2381,7 +2381,12 @@
   Keywords.kw_implements))
   return true;
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
-if (Left.is(tok::kw_return))
+const FormatToken *NonComment = Right.getPreviousNonComment();
+if (Left.isOneOf(tok::kw_return, tok::kw_continue, tok::kw_break,
+ tok::kw_throw) ||
+(NonComment &&
+ NonComment->isOneOf(tok::kw_return, tok::kw_continue, tok::kw_break,
+ tok::kw_throw)))
   return false; // Otherwise a semicolon is inserted.
 if (Left.is(TT_JsFatArrow) && Right.is(tok::l_brace))
   return false;
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -686,7 +686,9 @@
   // would change due to automatic semicolon insertion.
   // See http://www.ecma-international.org/ecma-262/5.1/#sec-7.9.1.
   verifyFormat("return a;", getGoogleJSStyleWithColumns(10));
+  verifyFormat("return /* hello! */ a;", getGoogleJSStyleWithColumns(10));
   verifyFormat("continue a;", getGoogleJSStyleWithColumns(10));
+  verifyFormat("continue /* hello! */ a;", getGoogleJSStyleWithColumns(10));
   verifyFormat("break a;", getGoogleJSStyleWithColumns(10));
   verifyFormat("throw a;", getGoogleJSStyleWithColumns(10));
   verifyFormat("a++;", getGoogleJSStyleWithColumns(10));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r280730 - clang-format: [JS] ignore comments when wrapping returns.

2016-09-06 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Tue Sep  6 13:39:30 2016
New Revision: 280730

URL: http://llvm.org/viewvc/llvm-project?rev=280730=rev
Log:
clang-format: [JS] ignore comments when wrapping returns.

Summary:
When code contains a comment between `return` and the value:

return /* lengthy comment here */ (
lengthyValueComesHere);

Do not wrap before the comment, as that'd break the code through JS' automatic
semicolon insertion.

Reviewers: djasper

Subscribers: klimek, cfe-commits

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

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=280730=280729=280730=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue Sep  6 13:39:30 2016
@@ -2381,7 +2381,12 @@ bool TokenAnnotator::canBreakBefore(cons
   Keywords.kw_implements))
   return true;
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
-if (Left.is(tok::kw_return))
+const FormatToken *NonComment = Right.getPreviousNonComment();
+if (Left.isOneOf(tok::kw_return, tok::kw_continue, tok::kw_break,
+ tok::kw_throw) ||
+(NonComment &&
+ NonComment->isOneOf(tok::kw_return, tok::kw_continue, tok::kw_break,
+ tok::kw_throw)))
   return false; // Otherwise a semicolon is inserted.
 if (Left.is(TT_JsFatArrow) && Right.is(tok::l_brace))
   return false;

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=280730=280729=280730=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Tue Sep  6 13:39:30 2016
@@ -686,7 +686,9 @@ TEST_F(FormatTestJS, WrapRespectsAutomat
   // would change due to automatic semicolon insertion.
   // See http://www.ecma-international.org/ecma-262/5.1/#sec-7.9.1.
   verifyFormat("return a;", getGoogleJSStyleWithColumns(10));
+  verifyFormat("return /* hello! */ a;", getGoogleJSStyleWithColumns(10));
   verifyFormat("continue a;", getGoogleJSStyleWithColumns(10));
+  verifyFormat("continue /* hello! */ a;", 
getGoogleJSStyleWithColumns(10));
   verifyFormat("break a;", getGoogleJSStyleWithColumns(10));
   verifyFormat("throw a;", getGoogleJSStyleWithColumns(10));
   verifyFormat("a++;", getGoogleJSStyleWithColumns(10));


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


Re: [PATCH] D24257: clang-format: [JS] ignore comments when wrapping returns.

2016-09-06 Thread Daniel Jasper via cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

Looks good.



Comment at: lib/Format/TokenAnnotator.cpp:2384
@@ -2383,2 +2383,3 @@
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
-if (Left.is(tok::kw_return))
+const FormatToken *NonComment = Right.getPreviousNonComment();
+if (Left.isOneOf(tok::kw_return, tok::kw_continue, tok::kw_break,

mprobst wrote:
> Should the entire method generally consider the previous non-comment, instead 
> of just the previous token? Not sure if that makes sense in all cases, and I 
> don't think we always have a previous non-comment token either.
Lets leave this as is for now. Yes, some of these should likely look past 
comments, but probably not all of them.


https://reviews.llvm.org/D24257



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


Re: [PATCH] D24113: Allow implicit conversions between incompatible pointer types in overload resolution in C.

2016-09-06 Thread Jan Vesely via cfe-commits
jvesely added a subscriber: jvesely.
jvesely added a comment.

This change breaks OpenCL(libclc). CLC expects signed/unsigned overloads to be 
non-ambiguous.
For example:
atomic_max(global int *p, int val);
atomic_max(global unsigned int *p, unsigned int val);

need to work and be unambiguous (they are implemented using different 
instructions different instructions).


Repository:
  rL LLVM

https://reviews.llvm.org/D24113



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


Re: [PATCH] D23953: OpenCL: Defining __ENDIAN_LITTLE__ and fix target endianness

2016-09-06 Thread Anastasia Stulova via cfe-commits
Anastasia added a subscriber: Anastasia.
Anastasia accepted this revision.
Anastasia added a reviewer: Anastasia.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM!


https://reviews.llvm.org/D23953



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


Re: [PATCH] D23284: Add -Rpass-with-hotness

2016-09-06 Thread Adam Nemet via cfe-commits
anemet added a comment.

In https://reviews.llvm.org/D23284#534879, @rsmith wrote:

> I think this should not be an -R option at all; like -W flags, the idea is 
> for -R to only act as a filter for which diagnostics are shown. This option 
> seems much more closely related to options like -fdiagnostics-show-option and 
> -fdiagnostics-format=, and so should probably have a -fdiagnostics-something 
> name.


Sounds fine to me.  Any preference from:

-fdiagnostics-include-hotness-in-remarks
-fpass-diagnostics-with-hotness
-fpass-diagnostics-include-hotness

or something else?


https://reviews.llvm.org/D23284



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


r280728 - Modules: Fix an assertion in DeclContext::buildLookup.

2016-09-06 Thread Manman Ren via cfe-commits
Author: mren
Date: Tue Sep  6 13:16:54 2016
New Revision: 280728

URL: http://llvm.org/viewvc/llvm-project?rev=280728=rev
Log:
Modules: Fix an assertion in DeclContext::buildLookup.

When calling getMostRecentDecl, we can pull in more definitions from
a module. We call getPrimaryContext afterwards to make sure that
we buildLookup on a primary context.

rdar://27926200

Added:
cfe/trunk/test/Modules/Inputs/lookup-assert/
cfe/trunk/test/Modules/Inputs/lookup-assert/Base.h
cfe/trunk/test/Modules/Inputs/lookup-assert/Derive.h
cfe/trunk/test/Modules/Inputs/lookup-assert/H3.h
cfe/trunk/test/Modules/Inputs/lookup-assert/module.map
cfe/trunk/test/Modules/lookup-assert.m
Modified:
cfe/trunk/lib/AST/DeclBase.cpp

Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=280728=280727=280728=diff
==
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Tue Sep  6 13:16:54 2016
@@ -1411,10 +1411,6 @@ DeclContext::lookup(DeclarationName Name
   assert(DeclKind != Decl::LinkageSpec &&
  "Should not perform lookups into linkage specs!");
 
-  const DeclContext *PrimaryContext = getPrimaryContext();
-  if (PrimaryContext != this)
-return PrimaryContext->lookup(Name);
-
   // If we have an external source, ensure that any later redeclarations of 
this
   // context have been loaded, since they may add names to the result of this
   // lookup (or add external visible storage).
@@ -1422,6 +1418,12 @@ DeclContext::lookup(DeclarationName Name
   if (Source)
 (void)cast(this)->getMostRecentDecl();
 
+  // getMostRecentDecl can change the result of getPrimaryContext. Call
+  // getPrimaryContext afterwards.
+  const DeclContext *PrimaryContext = getPrimaryContext();
+  if (PrimaryContext != this)
+return PrimaryContext->lookup(Name);
+
   if (hasExternalVisibleStorage()) {
 assert(Source && "external visible storage but no external source?");
 

Added: cfe/trunk/test/Modules/Inputs/lookup-assert/Base.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/lookup-assert/Base.h?rev=280728=auto
==
--- cfe/trunk/test/Modules/Inputs/lookup-assert/Base.h (added)
+++ cfe/trunk/test/Modules/Inputs/lookup-assert/Base.h Tue Sep  6 13:16:54 2016
@@ -0,0 +1,4 @@
+@interface BaseInterface
+- (void) test;
+@end
+

Added: cfe/trunk/test/Modules/Inputs/lookup-assert/Derive.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/lookup-assert/Derive.h?rev=280728=auto
==
--- cfe/trunk/test/Modules/Inputs/lookup-assert/Derive.h (added)
+++ cfe/trunk/test/Modules/Inputs/lookup-assert/Derive.h Tue Sep  6 13:16:54 
2016
@@ -0,0 +1,3 @@
+#include "Base.h"
+@interface DerivedInterface : BaseInterface
+@end

Added: cfe/trunk/test/Modules/Inputs/lookup-assert/H3.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/lookup-assert/H3.h?rev=280728=auto
==
--- cfe/trunk/test/Modules/Inputs/lookup-assert/H3.h (added)
+++ cfe/trunk/test/Modules/Inputs/lookup-assert/H3.h Tue Sep  6 13:16:54 2016
@@ -0,0 +1 @@
+#include "Base.h"

Added: cfe/trunk/test/Modules/Inputs/lookup-assert/module.map
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/lookup-assert/module.map?rev=280728=auto
==
--- cfe/trunk/test/Modules/Inputs/lookup-assert/module.map (added)
+++ cfe/trunk/test/Modules/Inputs/lookup-assert/module.map Tue Sep  6 13:16:54 
2016
@@ -0,0 +1,4 @@
+module X {
+  header "H3.h"
+  export *
+}

Added: cfe/trunk/test/Modules/lookup-assert.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/lookup-assert.m?rev=280728=auto
==
--- cfe/trunk/test/Modules/lookup-assert.m (added)
+++ cfe/trunk/test/Modules/lookup-assert.m Tue Sep  6 13:16:54 2016
@@ -0,0 +1,10 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I 
%S/Inputs/lookup-assert %s -verify
+// expected-no-diagnostics
+
+#include "Derive.h"
+#import 
+@implementation DerivedInterface
+- (void)test {
+}
+@end


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


Re: [PATCH] D23712: [OpenCL] Override supported OpenCL extensions with -cl-ext option

2016-09-06 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

In https://reviews.llvm.org/D23712#524021, @asavonic wrote:

> In https://reviews.llvm.org/D23712#520818, @Anastasia wrote:
>
> > What would be the use case to override the supported extensions for the end 
> > user?
>
>
> Some extensions may be supported by the platform in general, but not by the
>  specific version of the OpenCL runtime.


Would triple not be suitable in this case, because they include OS/RT 
information?


https://reviews.llvm.org/D23712



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


Re: [PATCH] D24201: [Clang-tools-extra] Fix links in release notes

2016-09-06 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL280725: [Release notes] Fix links. (authored by 
eugenezelenko).

Changed prior to commit:
  https://reviews.llvm.org/D24201?vs=70229=70433#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D24201

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

Index: clang-tools-extra/trunk/docs/ReleaseNotes.rst
===
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst
@@ -10,17 +10,17 @@
 
 .. warning::
 
-   These are in-progress notes for the upcoming Clang 4.0.0 release. You may
-   prefer the `Clang 3.8 Release Notes
-   `_.
+   These are in-progress notes for the upcoming Extra Clang Tools 4.0 release.
+   You may prefer the `Extra Clang Tools 3.9 Release Notes
+   
`_.
 
 Introduction
 
 
 This document contains the release notes for the Extra Clang Tools, part of the
-Clang release 4.0.0.  Here we describe the status of the Extra Clang Tools in 
some
-detail, including major improvements from the previous release and new feature
-work.  All LLVM releases may be downloaded from the `LLVM releases web
+Clang release 4.0.0. Here we describe the status of the Extra Clang Tools in
+some detail, including major improvements from the previous release and new
+feature work. All LLVM releases may be downloaded from the `LLVM releases web
 site `_.
 
 For more information about Clang or LLVM, including information about


Index: clang-tools-extra/trunk/docs/ReleaseNotes.rst
===
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst
@@ -10,17 +10,17 @@
 
 .. warning::
 
-   These are in-progress notes for the upcoming Clang 4.0.0 release. You may
-   prefer the `Clang 3.8 Release Notes
-   `_.
+   These are in-progress notes for the upcoming Extra Clang Tools 4.0 release.
+   You may prefer the `Extra Clang Tools 3.9 Release Notes
+   `_.
 
 Introduction
 
 
 This document contains the release notes for the Extra Clang Tools, part of the
-Clang release 4.0.0.  Here we describe the status of the Extra Clang Tools in some
-detail, including major improvements from the previous release and new feature
-work.  All LLVM releases may be downloaded from the `LLVM releases web
+Clang release 4.0.0. Here we describe the status of the Extra Clang Tools in
+some detail, including major improvements from the previous release and new
+feature work. All LLVM releases may be downloaded from the `LLVM releases web
 site `_.
 
 For more information about Clang or LLVM, including information about
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r280725 - [Release notes] Fix links.

2016-09-06 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Tue Sep  6 12:52:44 2016
New Revision: 280725

URL: http://llvm.org/viewvc/llvm-project?rev=280725=rev
Log:
[Release notes] Fix links.

Differential revision: https://reviews.llvm.org/D24201

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

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=280725=280724=280725=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Tue Sep  6 12:52:44 2016
@@ -10,17 +10,17 @@ Written by the `LLVM Team `_.
+   These are in-progress notes for the upcoming Extra Clang Tools 4.0 release.
+   You may prefer the `Extra Clang Tools 3.9 Release Notes
+   
`_.
 
 Introduction
 
 
 This document contains the release notes for the Extra Clang Tools, part of the
-Clang release 4.0.0.  Here we describe the status of the Extra Clang Tools in 
some
-detail, including major improvements from the previous release and new feature
-work.  All LLVM releases may be downloaded from the `LLVM releases web
+Clang release 4.0.0. Here we describe the status of the Extra Clang Tools in
+some detail, including major improvements from the previous release and new
+feature work. All LLVM releases may be downloaded from the `LLVM releases web
 site `_.
 
 For more information about Clang or LLVM, including information about


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


Re: [PATCH] D23992: [OpenCL] Augment pipe built-ins with pipe packet size and alignment.

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

LGTM! Thanks!


https://reviews.llvm.org/D23992



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


LLVM buildmaster will be restarted in few minutes

2016-09-06 Thread Galina Kistanova via cfe-commits
Hello everyone,

LLVM buildmaster will be restarted in few minutes.
Sorry for inconvenience.

Thanks

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


Re: [PATCH] D23284: Add -Rpass-with-hotness

2016-09-06 Thread Richard Smith via cfe-commits
rsmith added a comment.

Sorry I missed this until now.

I think this should not be an -R option at all; like -W flags, the idea is for 
-R to only act as a filter for which diagnostics are shown. This option seems 
much more closely related to options like -fdiagnostics-show-option and 
-fdiagnostics-format=, and so should probably have a -fdiagnostics-something 
name.


https://reviews.llvm.org/D23284



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


Re: [PATCH] D24243: [clang-move] A prototype tool for moving class definition to new file.

2016-09-06 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a subscriber: Eugene.Zelenko.


Comment at: clang-move/ClangMove.h:33
@@ +32,3 @@
+clang::SourceManager *SM;
+MovedDecl() : Decl(nullptr), SM(nullptr) {}
+MovedDecl(const clang::Decl *Decl, clang::SourceManager *SM)

Please add empty line before. Why don't use C++11 members initialization and = 
default?


Comment at: clang-move/ClangMove.h:83
@@ +82,3 @@
+public:
+  explicit ClangMoveAction(
+  const ClangMoveTool::MoveDefinitionSpec ,

Is explicit necessary?


Comment at: clang-move/ClangMove.h:106
@@ +105,3 @@
+  : Spec(Spec), FileToReplacements(FileToReplacements) {}
+  clang::FrontendAction *create() override {
+return new ClangMoveAction(Spec, FileToReplacements);

Please add empty line before.


https://reviews.llvm.org/D24243



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


Re: [PATCH] D24136: [OpenCL] Fix pipe built-in functions return type.

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

LGTM! Thanks!


https://reviews.llvm.org/D24136



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


r280718 - Formatting with clang-format patch r280701

2016-09-06 Thread Leny Kholodov via cfe-commits
Author: lkholodov
Date: Tue Sep  6 12:06:14 2016
New Revision: 280718

URL: http://llvm.org/viewvc/llvm-project?rev=280718=rev
Log:
Formatting with clang-format patch r280701

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

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=280718=280717=280718=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Sep  6 12:06:14 2016
@@ -495,14 +495,14 @@ llvm::DIType *CGDebugInfo::CreateType(co
 
 auto *ISATy = DBuilder.createPointerType(ClassTy, Size);
 
-ObjTy =
-DBuilder.createStructType(TheCU, "objc_object", getOrCreateMainFile(),
-  0, 0, 0, llvm::DINode::FlagZero, nullptr, 
llvm::DINodeArray());
+ObjTy = DBuilder.createStructType(
+TheCU, "objc_object", getOrCreateMainFile(), 0, 0, 0,
+llvm::DINode::FlagZero, nullptr, llvm::DINodeArray());
 
 DBuilder.replaceArrays(
-ObjTy,
-DBuilder.getOrCreateArray(&*DBuilder.createMemberType(
-ObjTy, "isa", getOrCreateMainFile(), 0, Size, 0, 0, 
llvm::DINode::FlagZero, ISATy)));
+ObjTy, DBuilder.getOrCreateArray(&*DBuilder.createMemberType(
+   ObjTy, "isa", getOrCreateMainFile(), 0, Size, 0, 0,
+   llvm::DINode::FlagZero, ISATy)));
 return ObjTy;
   }
   case BuiltinType::ObjCSel: {
@@ -811,9 +811,9 @@ llvm::DIType *CGDebugInfo::CreateType(co
   FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy);
   FieldSize = CGM.getContext().getTypeSize(Ty);
   FieldAlign = CGM.getContext().getTypeAlign(Ty);
-  EltTys.push_back(DBuilder.createMemberType(Unit, "__descriptor", nullptr, 
LineNo,
- FieldSize, FieldAlign, 
FieldOffset,
- llvm::DINode::FlagZero, DescTy));
+  EltTys.push_back(DBuilder.createMemberType(
+  Unit, "__descriptor", nullptr, LineNo, FieldSize, FieldAlign, 
FieldOffset,
+  llvm::DINode::FlagZero, DescTy));
 
   FieldOffset += FieldSize;
   Elements = DBuilder.getOrCreateArray(EltTys);
@@ -924,7 +924,8 @@ llvm::DIType *CGDebugInfo::CreateType(co
 /// Convert an AccessSpecifier into the corresponding DINode flag.
 /// As an optimization, return 0 if the access specifier equals the
 /// default for the containing type.
-static llvm::DINode::DIFlags getAccessFlag(AccessSpecifier Access, const 
RecordDecl *RD) {
+static llvm::DINode::DIFlags getAccessFlag(AccessSpecifier Access,
+   const RecordDecl *RD) {
   AccessSpecifier Default = clang::AS_none;
   if (RD && RD->isClass())
 Default = clang::AS_private;
@@ -1978,7 +1979,8 @@ llvm::DIType *CGDebugInfo::CreateTypeDef
 if (!SClassTy)
   return nullptr;
 
-llvm::DIType *InhTag = DBuilder.createInheritance(RealDecl, SClassTy, 0, 
llvm::DINode::FlagZero);
+llvm::DIType *InhTag = DBuilder.createInheritance(RealDecl, SClassTy, 0,
+  llvm::DINode::FlagZero);
 EltTys.push_back(InhTag);
   }
 
@@ -2656,9 +2658,9 @@ llvm::DIType *CGDebugInfo::CreateMemberT
   llvm::DIType *FieldTy = CGDebugInfo::getOrCreateType(FType, Unit);
   uint64_t FieldSize = CGM.getContext().getTypeSize(FType);
   unsigned FieldAlign = CGM.getContext().getTypeAlign(FType);
-  llvm::DIType *Ty = DBuilder.createMemberType(Unit, Name, Unit, 0, FieldSize,
-   FieldAlign, *Offset,
-   llvm::DINode::FlagZero, 
FieldTy);
+  llvm::DIType *Ty =
+  DBuilder.createMemberType(Unit, Name, Unit, 0, FieldSize, FieldAlign,
+*Offset, llvm::DINode::FlagZero, FieldTy);
   *Offset += FieldSize;
   return Ty;
 }
@@ -3518,10 +3520,9 @@ void CGDebugInfo::EmitDeclareOfBlockLite
   uint64_t xoffset;
   fieldType = EmitTypeForVarWithBlocksAttr(variable, );
   fieldType = DBuilder.createPointerType(fieldType, PtrInfo.Width);
-  fieldType =
-  DBuilder.createMemberType(tunit, name, tunit, line, PtrInfo.Width,
-PtrInfo.Align, offsetInBits,
-llvm::DINode::FlagZero, fieldType);
+  fieldType = DBuilder.createMemberType(
+  tunit, name, tunit, line, PtrInfo.Width, PtrInfo.Align, offsetInBits,
+  llvm::DINode::FlagZero, fieldType);
 } else {
   fieldType = createFieldType(name, variable->getType(), loc, AS_public,
   offsetInBits, tunit, tunit);
@@ -3535,11 +3536,11 @@ void CGDebugInfo::EmitDeclareOfBlockLite
 
   llvm::DINodeArray fieldsArray = DBuilder.getOrCreateArray(fields);
 
-  llvm::DIType *type = DBuilder.createStructType(
-  tunit, typeName.str(), tunit, line,
-  

Re: [PATCH] D23953: OpenCL: Defining __ENDIAN_LITTLE__ and fix target endianness

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

ping


https://reviews.llvm.org/D23953



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


Re: [PATCH] D23284: Add -Rpass-with-hotness

2016-09-06 Thread Adam Nemet via cfe-commits
anemet added a comment.

In https://reviews.llvm.org/D23284#526413, @dnovillo wrote:

> I'm fine with it, but I don't have much of a say in how option groups are 
> organized.  If Richard agrees, then it LGTM.


Ping.  Would it be OK to commit this with the two LGTMs?  I am around to fix 
any fall-outs or post-commit reviews from Richard.


https://reviews.llvm.org/D23284



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


Re: r253269 - Make FP_CONTRACT ON the default.

2016-09-06 Thread Hal Finkel via cfe-commits
Hi Steve, et al.,

It looks like this crasher was fixed in r254573. Should we move forward with 
recommitting this now?

Thanks again,
Hal

- Original Message -
> From: "Manuel Klimek" 
> To: "Hal Finkel" , "Renato Golin" 
> Cc: "Clang Commits" 
> Sent: Tuesday, November 17, 2015 9:47:11 AM
> Subject: Re: r253269 - Make FP_CONTRACT ON the default.
> 
> 
> Reverted in r253337. Failing test case in commit message.
> 
> 
> 
> On Tue, Nov 17, 2015 at 4:39 PM Manuel Klimek < kli...@google.com >
> wrote:
> 
> Repro:
> float foo(float U, float base, float cell) { return (U = 2 * base) -
> cell; }
> Preparing rollback of the CL.
> 
> 
> On Tue, Nov 17, 2015 at 2:46 PM Manuel Klimek < kli...@google.com >
> wrote:
> 
> 
> 
> Note that due to this change we're hitting an assert at
> lib/CodeGen/CGExprScalar.cpp:2570 in llvm::Value
> *tryEmitFMulAdd(const (anonymous namespace)::BinOpInfo &, const
> clang::CodeGen::CodeGenFunction &, clang::CodeGen::CGBuilderTy &,
> bool): LHSBinOp->getNumUses(
> ) == 0 && "Operations with multiple uses shouldn't be contracted."
> 
> 
> Don't have a small repro yet :(
> 
> 
> On Tue, Nov 17, 2015 at 1:39 PM Hal Finkel via cfe-commits <
> cfe-commits@lists.llvm.org > wrote:
> 
> 
> - Original Message -
> > From: "Renato Golin via cfe-commits" < cfe-commits@lists.llvm.org >
> > To: "Stephen Canon" < sca...@apple.com >
> > Cc: "Clang Commits" < cfe-commits@lists.llvm.org >
> > Sent: Tuesday, November 17, 2015 3:51:23 AM
> > Subject: Re: r253269 - Make FP_CONTRACT ON the default.
> > 
> > On 16 November 2015 at 23:09, Stephen Canon via cfe-commits
> > < cfe-commits@lists.llvm.org > wrote:
> > > Author: scanon
> > > Date: Mon Nov 16 17:09:11 2015
> > > New Revision: 253269
> > > 
> > > URL: http://llvm.org/viewvc/llvm-project?rev=253269=rev
> > > Log:
> > > Make FP_CONTRACT ON the default.
> > > 
> > > Differential Revision: D14200
> > 
> > Hi Stephen,
> > 
> > It seems your commit in the blame list is the only one that affects
> > AArch64 directly:
> > 
> > http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/2388
> > 
> > I haven't bisected yet, but would be good if you could try those
> > tests
> > locally, just to make sure it wasn't your commit, and revert if it
> > was, to fix offline.
> 
> The test suite already has logic to add -ffp-contract=off on PowerPC
> so that we can compare to the binary outputs. We may need to do this
> now for all targets, at least until be come up with a better
> solution.
> 
> -Hal
> 
> > 
> > cheers,
> > --renato
> > ___
> > cfe-commits mailing list
> > cfe-commits@lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> > 
> 
> --
> Hal Finkel
> Assistant Computational Scientist
> Leadership Computing Facility
> Argonne National Laboratory
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> 

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


Re: [PATCH] D24257: clang-format: [JS] ignore comments when wrapping returns.

2016-09-06 Thread Martin Probst via cfe-commits
mprobst added inline comments.


Comment at: lib/Format/TokenAnnotator.cpp:2384
@@ -2383,2 +2383,3 @@
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
-if (Left.is(tok::kw_return))
+const FormatToken *NonComment = Right.getPreviousNonComment();
+if (Left.isOneOf(tok::kw_return, tok::kw_continue, tok::kw_break,

Should the entire method generally consider the previous non-comment, instead 
of just the previous token? Not sure if that makes sense in all cases, and I 
don't think we always have a previous non-comment token either.


https://reviews.llvm.org/D24257



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


[PATCH] D24257: clang-format: [JS] ignore comments when wrapping returns.

2016-09-06 Thread Martin Probst via cfe-commits
mprobst created this revision.
mprobst added a reviewer: djasper.
mprobst added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

When code contains a comment between `return` and the value:

return /* lengthy comment here */ (
lengthyValueComesHere);

Do not wrap before the comment, as that'd break the code through JS' automatic
semicolon insertion.

https://reviews.llvm.org/D24257

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTestJS.cpp

Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -686,7 +686,9 @@
   // would change due to automatic semicolon insertion.
   // See http://www.ecma-international.org/ecma-262/5.1/#sec-7.9.1.
   verifyFormat("return a;", getGoogleJSStyleWithColumns(10));
+  verifyFormat("return /* hello! */ a;", getGoogleJSStyleWithColumns(10));
   verifyFormat("continue a;", getGoogleJSStyleWithColumns(10));
+  verifyFormat("continue /* hello! */ a;", 
getGoogleJSStyleWithColumns(10));
   verifyFormat("break a;", getGoogleJSStyleWithColumns(10));
   verifyFormat("throw a;", getGoogleJSStyleWithColumns(10));
   verifyFormat("a++;", getGoogleJSStyleWithColumns(10));
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2381,7 +2381,12 @@
   Keywords.kw_implements))
   return true;
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
-if (Left.is(tok::kw_return))
+const FormatToken *NonComment = Right.getPreviousNonComment();
+if (Left.isOneOf(tok::kw_return, tok::kw_continue, tok::kw_break,
+ tok::kw_throw) ||
+(NonComment &&
+ NonComment->isOneOf(tok::kw_return, tok::kw_continue, tok::kw_break,
+ tok::kw_throw)))
   return false; // Otherwise a semicolon is inserted.
 if (Left.is(TT_JsFatArrow) && Right.is(tok::l_brace))
   return false;


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -686,7 +686,9 @@
   // would change due to automatic semicolon insertion.
   // See http://www.ecma-international.org/ecma-262/5.1/#sec-7.9.1.
   verifyFormat("return a;", getGoogleJSStyleWithColumns(10));
+  verifyFormat("return /* hello! */ a;", getGoogleJSStyleWithColumns(10));
   verifyFormat("continue a;", getGoogleJSStyleWithColumns(10));
+  verifyFormat("continue /* hello! */ a;", getGoogleJSStyleWithColumns(10));
   verifyFormat("break a;", getGoogleJSStyleWithColumns(10));
   verifyFormat("throw a;", getGoogleJSStyleWithColumns(10));
   verifyFormat("a++;", getGoogleJSStyleWithColumns(10));
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2381,7 +2381,12 @@
   Keywords.kw_implements))
   return true;
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
-if (Left.is(tok::kw_return))
+const FormatToken *NonComment = Right.getPreviousNonComment();
+if (Left.isOneOf(tok::kw_return, tok::kw_continue, tok::kw_break,
+ tok::kw_throw) ||
+(NonComment &&
+ NonComment->isOneOf(tok::kw_return, tok::kw_continue, tok::kw_break,
+ tok::kw_throw)))
   return false; // Otherwise a semicolon is inserted.
 if (Left.is(TT_JsFatArrow) && Right.is(tok::l_brace))
   return false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24192: [clang-refactor] introducing clang-refactor

2016-09-06 Thread Kirill Bobyrev via cfe-commits
omtcyfz added a comment.

Thank you for reviewing, @hokein!

Also, please note that this is not a final version, the interface will change a 
lot in the upcoming diffs.



Comment at: clang-refactor/driver/Driver.cpp:46
@@ +45,3 @@
+llvm::StringRef FirstArgument(argv[1]);
+if (FirstArgument == "-h" || FirstArgument == "-help" ||
+FirstArgument == "--help")

hokein wrote:
> Any reason implementing the command-line options and not using the `cl::opt` 
> here?
I might be mistaken, but it'd require parsing whole option sequence, which 
should be delegated to the submodules.

E.g. "help" should be only called if the the tool is invoked as `clang-refactor 
--help`, but if I parse all options I'd also invoke "help" while having 
"clang-refactor rename --help" for example. At least that's what I have been 
thinking.


Comment at: clang-refactor/modules/core/RefactoringModule.h:89
@@ +88,3 @@
+  //
+  int run(int argc, const char **argv) {
+// Register options.

hokein wrote:
> I'd make this interface a virtual function too, and provide this default 
> implementation.
I'll update the interface soonish.

Had an offline discussion with Alex about the interface and we came up to a 
conclusion that the interface should be way more strict. This one is just a 
general idea of how it might be implemented.

Thus, run shouldn't be overridden in my opinion, but I'll update the diff and 
make some high-level comments on that later.


Comment at: clang-refactor/modules/core/RefactoringModule.h:128
@@ +127,3 @@
+  //
+  // Panic: if refactoring can not be applied. E.g. unsupported cases like
+  // renaming macros etc.

hokein wrote:
> Does the panic mean something like `exit(1)`? But from the interface, it 
> looks like returning an error code, right?
1. Well, no. I believe that the error should be thrown to the `run` and 
"printed out" there.
2. Also, not that we're aiming for a multi-TU multi-threaded architecture in 
the end (although it doesn't make sense with the current interface, but again, 
I'll update it later).


Comment at: clang-refactor/modules/core/RefactoringModule.h:146
@@ +145,3 @@
+  // Panic: if there are conflicting replacements.
+  virtual int applyReplacements() = 0;
+

hokein wrote:
> A further thought:
> 
> `applyReplacement` is more likely a postprocess step of 
> `handleTranslationUnit`, what if some clang-refactor subtools just want to 
> dump the results only? I'd prefer to rename it to 
> `OnEndOfHandlingTranslationUnit`. I'm open to hear better suggestions. 
/* comment about multi-TU multi-threaded stuff */

Suppose a refactoring can't be applied to some translation units. Say, "rename" 
tool encountered name conflict in any TU. In this case the tool should fail and 
not process the last step.

If your comment is about naming only, I'll change it, too.


Comment at: clang-refactor/modules/template/TemplateModule.h:15
@@ +14,3 @@
+
+#include 
+

hokein wrote:
> Not needed.
Deleting TemplateModule.


Comment at: clang-refactor/modules/template/TemplateModule.h:20
@@ +19,3 @@
+namespace template_module {
+
+class TemplateModule : public RefactoringModule {

hokein wrote:
> It'd be clear to add a small paragraph describing that this is a template 
> module which is only used to lower the "barrier to entry" for writing 
> clang-refactor subtool.
Deleting TemplateModule.


https://reviews.llvm.org/D24192



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


Re: [PATCH] D24192: [clang-refactor] introducing clang-refactor

2016-09-06 Thread Kirill Bobyrev via cfe-commits
omtcyfz updated this revision to Diff 70397.
omtcyfz marked 11 inline comments as done.
omtcyfz added a comment.

Addressing a round of comments.


https://reviews.llvm.org/D24192

Files:
  CMakeLists.txt
  clang-refactor/CMakeLists.txt
  clang-refactor/driver/CMakeLists.txt
  clang-refactor/driver/Driver.cpp
  clang-refactor/driver/ModuleManager.cpp
  clang-refactor/driver/ModuleManager.h
  clang-refactor/modules/CMakeLists.txt
  clang-refactor/modules/core/RefactoringModule.h

Index: clang-refactor/modules/core/RefactoringModule.h
===
--- /dev/null
+++ clang-refactor/modules/core/RefactoringModule.h
@@ -0,0 +1,169 @@
+//===--- RefactoringModule.h - clang-refactor ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_REFACTOR_REFACTORING_MODULE_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_REFACTOR_REFACTORING_MODULE_H
+
+#include "clang/Tooling/CommonOptionsParser.h"
+#include "clang/Tooling/Refactoring.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Signals.h"
+
+#include 
+
+namespace clang {
+namespace refactor {
+
+class RefactoringModule {
+public:
+  RefactoringModule(const std::string ,
+const std::string )
+  : ModuleName(ModuleName), ModuleMetaDescription(ModuleMetaDescription) {}
+
+  // Refactoring consists of 3.5 stages:
+  //
+  // 0. Check arguments for validity.
+  //
+  // 1. Extract infromation needed for the refactoring upon tool invocation.
+  //
+  // 2. Handle translation unit and identify whether the refactoring can be
+  // applied. If it can, store the replacements. Panic otherwise.
+  //
+  // 3. Merge duplicate replacements, panic if there are conflicting ones.
+  // Process translation unit and apply refactoring.
+  //
+  // Few examples of how each of these stages would look like for future
+  // modules "rename" and "inline".
+  //
+  // Rename
+  // ==
+  //
+  // 0. Check arguments for validity.
+  //
+  // 1. Rename operates with USRs, so the first stage would be finding the
+  // symbol, which will be renamed and storing its USR.
+  //
+  // 2. Check whether renaming will introduce any name conflicts. If it won't
+  // find each occurance of the symbol in translation unit using USR and store
+  // replacements.
+  //
+  // 3. Apply replacements or output diagnostics. Handle duplicates and panic if
+  // there are conflicts.
+  //
+  // Inline
+  // ==
+  //
+  // 0. Check arguments for validity.
+  //
+  // 1. Find function, identify what the possible issues might be.
+  //
+  // 2. Check whether inlining will introduce any issues, e.g. there is a
+  // pointer passed somewhere to the inlined function and after inlining it the
+  // code will no longer compile. If it won't find function calls, add needed
+  // temprorary variables and replace the call with function body.
+  //
+  // 3. Apply replacements. Handle duplicates and panic if there are conflicts.
+  //
+  // Summary
+  // ===
+  //
+  // As one can easily see, step 1 should be performed upon module invocation
+  // and it needs to process translation unit, from which the passed 
+  // comes from.
+  //
+  // With appropriate facilities step 2 can be parallelized to process multiple
+  // translation units of the project independently. If none of them have any
+  // issues with applying this refactoring replacements are stored and queued
+  // for later.
+  //
+  // Step 3 can be parallelized even more easily. It basically consists of text
+  // replacements.
+  //
+  int run(int argc, const char **argv) {
+// Register options.
+llvm::cl::OptionCategory RefactoringModuleOptions(ModuleName.c_str(),
+  ModuleMetaDescription.c_str());
+registerCustomOptions(RefactoringModuleOptions);
+registerCustomOptions(RefactoringModuleOptions);
+// Parse options and get compilations.
+llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
+tooling::CommonOptionsParser OptionsParser(argc, argv,
+   RefactoringModuleOptions);
+tooling::RefactoringTool Tool(OptionsParser.getCompilations(),
+  OptionsParser.getSourcePathList());
+
+// Actual routine.
+checkArguments();
+extractRefactoringInformation();
+handleTranslationUnit();
+applyReplacementsOrOutputDiagnostics();
+return 0;
+  }
+
+  // Routine for regiestering common modules options.
+  void registerCommonOptions(llvm::cl::OptionCategory ) {
+  }
+
+  // A way for each tool to provide additional 

Re: [PATCH] D22130: Link static PIE programs against rcrt0.o on OpenBSD

2016-09-06 Thread Vedant Kumar via cfe-commits
vsk resigned from this revision.
vsk removed a reviewer: vsk.
vsk added a comment.

I don't see any issues with this patch, but also don't know enough about the 
openbsd toolchain to lgtm it.


https://reviews.llvm.org/D22130



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


RE: r275095 - [NFC] Reorder fields of VersionTuple to reduce size

2016-09-06 Thread Vasileios Kalintiris via cfe-commits
It turns out that there's no need to revert this as the problem persists even 
without your patch. I'm preparing a patch that fixes the underlying issue.

- V. Kalintiris

From: cfe-commits [cfe-commits-boun...@lists.llvm.org] on behalf of Vasileios 
Kalintiris via cfe-commits [cfe-commits@lists.llvm.org]
Sent: 06 September 2016 10:12
To: Erik Pilkington; cfe-commits@lists.llvm.org
Subject: RE: r275095 - [NFC] Reorder fields of VersionTuple to reduce size

Hi Erik, would you mind reverting this temporarily? It broke our recursive 
builds buildbot because the re-ordering of VersionTuple's bitfields generates 
an i128 which our MIPS backend erroneously accepts for the o32 ABI.

- V. Kalintiris


From: cfe-commits [cfe-commits-boun...@lists.llvm.org] on behalf of Erik 
Pilkington via cfe-commits [cfe-commits@lists.llvm.org]
Sent: 11 July 2016 21:00
To: cfe-commits@lists.llvm.org
Subject: r275095 - [NFC] Reorder fields of VersionTuple to reduce size

Author: epilk
Date: Mon Jul 11 15:00:48 2016
New Revision: 275095

URL: http://llvm.org/viewvc/llvm-project?rev=275095=rev
Log:
[NFC] Reorder fields of VersionTuple to reduce size

Differential revision: http://reviews.llvm.org/D19934

Modified:
cfe/trunk/include/clang/Basic/VersionTuple.h

Modified: cfe/trunk/include/clang/Basic/VersionTuple.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/VersionTuple.h?rev=275095=275094=275095=diff
==
--- cfe/trunk/include/clang/Basic/VersionTuple.h (original)
+++ cfe/trunk/include/clang/Basic/VersionTuple.h Mon Jul 11 15:00:48 2016
@@ -25,39 +25,44 @@ namespace clang {
 /// \brief Represents a version number in the form 
major[.minor[.subminor[.build]]].
 class VersionTuple {
   unsigned Major : 31;
+
+  unsigned UsesUnderscores : 1;
+
   unsigned Minor : 31;
-  unsigned Subminor : 31;
-  unsigned Build : 31;
   unsigned HasMinor : 1;
+
+  unsigned Subminor : 31;
   unsigned HasSubminor : 1;
+
+  unsigned Build : 31;
   unsigned HasBuild : 1;
-  unsigned UsesUnderscores : 1;

 public:
   VersionTuple()
-  : Major(0), Minor(0), Subminor(0), Build(0), HasMinor(false),
-HasSubminor(false), HasBuild(false), UsesUnderscores(false) {}
+  : Major(0), UsesUnderscores(false), Minor(0), HasMinor(false),
+Subminor(0), HasSubminor(false), Build(0), HasBuild(false) {}

   explicit VersionTuple(unsigned Major)
-  : Major(Major), Minor(0), Subminor(0), Build(0), HasMinor(false),
-HasSubminor(false), HasBuild(false), UsesUnderscores(false) {}
+  : Major(Major), UsesUnderscores(false), Minor(0), HasMinor(false),
+Subminor(0), HasSubminor(false), Build(0), HasBuild(false) {}

   explicit VersionTuple(unsigned Major, unsigned Minor,
 bool UsesUnderscores = false)
-  : Major(Major), Minor(Minor), Subminor(0), Build(0), HasMinor(true),
-HasSubminor(false), HasBuild(false), UsesUnderscores(UsesUnderscores) 
{}
+  : Major(Major), UsesUnderscores(UsesUnderscores), Minor(Minor),
+HasMinor(true), Subminor(0), HasSubminor(false), Build(0),
+HasBuild(false) {}

   explicit VersionTuple(unsigned Major, unsigned Minor, unsigned Subminor,
 bool UsesUnderscores = false)
-  : Major(Major), Minor(Minor), Subminor(Subminor), Build(0),
-HasMinor(true), HasSubminor(true), HasBuild(false),
-UsesUnderscores(UsesUnderscores) {}
+  : Major(Major), UsesUnderscores(UsesUnderscores), Minor(Minor),
+HasMinor(true), Subminor(Subminor), HasSubminor(true), Build(0),
+HasBuild(false) {}

   explicit VersionTuple(unsigned Major, unsigned Minor, unsigned Subminor,
 unsigned Build, bool UsesUnderscores = false)
-  : Major(Major), Minor(Minor), Subminor(Subminor), Build(Build),
-HasMinor(true), HasSubminor(true), HasBuild(true),
-UsesUnderscores(UsesUnderscores) {}
+  : Major(Major), UsesUnderscores(UsesUnderscores), Minor(Minor),
+HasMinor(true), Subminor(Subminor), HasSubminor(true), Build(Build),
+HasBuild(true) {}

   /// \brief Determine whether this version information is empty
   /// (e.g., all version components are zero).


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


Re: [PATCH] D24224: [clang-rename] Merge rename-{ at | all } and optimise USRFindingAction.

2016-09-06 Thread Kirill Bobyrev via cfe-commits
omtcyfz added inline comments.


Comment at: clang-rename/USRFindingAction.h:23
@@ -19,1 +22,3 @@
+
+using llvm::ArrayRef;
 

alexfh wrote:
> No using declarations in headers, please. Also, since your code is in the 
> clang namespace, you can include clang/Basic/LLVM.h that re-declares ArrayRef 
> in namespace clang.
Ah, I didn't think why this might be bad at first, but now I see.


https://reviews.llvm.org/D24224



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


Re: [PATCH] D24224: [clang-rename] Merge rename-{ at | all } and optimise USRFindingAction.

2016-09-06 Thread Kirill Bobyrev via cfe-commits
omtcyfz updated this revision to Diff 70388.
omtcyfz marked 6 inline comments as done.
omtcyfz added a comment.

Address comments.


https://reviews.llvm.org/D24224

Files:
  clang-rename/USRFindingAction.cpp
  clang-rename/USRFindingAction.h
  clang-rename/tool/ClangRename.cpp
  docs/clang-rename.rst
  test/clang-rename/ClassFindByName.cpp
  test/clang-rename/ClassTestMulti.cpp
  test/clang-rename/ClassTestMultiByName.cpp
  test/clang-rename/ClassTestMultiByNameYAML.cpp
  test/clang-rename/FunctionWithClassFindByName.cpp
  test/clang-rename/Inputs/ClassTestMultiByNameYAMLRenameAll.yaml
  test/clang-rename/Inputs/ClassTestMultiByNameYAMLRenameAt.yaml
  test/clang-rename/InvalidOldName.cpp
  test/clang-rename/NoNewName.cpp

Index: test/clang-rename/NoNewName.cpp
===
--- test/clang-rename/NoNewName.cpp
+++ test/clang-rename/NoNewName.cpp
@@ -1,4 +1,4 @@
 // Check for an error while -new-name argument has not been passed to
 // clang-rename.
 // RUN: not clang-rename -offset=133 %s 2>&1 | FileCheck %s
-// CHECK: clang-rename: for the -new-name option: must be specified
+// CHECK: clang-rename: -new-name must be specified.
Index: test/clang-rename/InvalidOldName.cpp
===
--- test/clang-rename/InvalidOldName.cpp
+++ /dev/null
@@ -1,2 +0,0 @@
-// RUN: not clang-rename rename-all -new-name=Foo -old-name=Bar %s -- 2>&1 | FileCheck %s
-// CHECK: clang-rename: could not find symbol Bar.
Index: test/clang-rename/Inputs/ClassTestMultiByNameYAMLRenameAt.yaml
===
--- test/clang-rename/Inputs/ClassTestMultiByNameYAMLRenameAt.yaml
+++ /dev/null
@@ -1,6 +0,0 @@

-- Offset: 6
-  NewName:Bar1
-- Offset: 44
-  NewName:Bar2
-...
Index: test/clang-rename/Inputs/ClassTestMultiByNameYAMLRenameAll.yaml
===
--- test/clang-rename/Inputs/ClassTestMultiByNameYAMLRenameAll.yaml
+++ /dev/null
@@ -1,6 +0,0 @@

-- OldName:Foo1
-  NewName:Bar1
-- OldName:Foo2
-  NewName:Bar2
-...
Index: test/clang-rename/FunctionWithClassFindByName.cpp
===
--- test/clang-rename/FunctionWithClassFindByName.cpp
+++ test/clang-rename/FunctionWithClassFindByName.cpp
@@ -9,4 +9,4 @@
   return 0;
 }
 
-// RUN: clang-rename rename-all -old-name=Foo -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s
+// RUN: clang-rename -qualified-name=Foo -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s
Index: test/clang-rename/ClassTestMultiByNameYAML.cpp
===
--- test/clang-rename/ClassTestMultiByNameYAML.cpp
+++ /dev/null
@@ -1,10 +0,0 @@
-class Foo1 { // CHECK: class Bar1
-};
-
-class Foo2 { // CHECK: class Bar2
-};
-
-// Test 1.
-// RUN: clang-rename rename-all -input %S/Inputs/ClassTestMultiByNameYAMLRenameAll.yaml %s -- | sed 's,//.*,,' | FileCheck %s
-// Test 2.
-// RUN: clang-rename rename-all -input %S/Inputs/ClassTestMultiByNameYAMLRenameAt.yaml %s -- | sed 's,//.*,,' | FileCheck %s
Index: test/clang-rename/ClassTestMultiByName.cpp
===
--- test/clang-rename/ClassTestMultiByName.cpp
+++ test/clang-rename/ClassTestMultiByName.cpp
@@ -5,4 +5,4 @@
 };
 
 // Test 1.
-// RUN: clang-rename rename-all -old-name=Foo1 -new-name=Bar1 -old-name=Foo2 -new-name=Bar2 %s -- | sed 's,//.*,,' | FileCheck %s
+// RUN: clang-rename -qualified-name=Foo1 -new-name=Bar1 -qualified-name=Foo2 -new-name=Bar2 %s -- | sed 's,//.*,,' | FileCheck %s
Index: test/clang-rename/ClassTestMulti.cpp
===
--- test/clang-rename/ClassTestMulti.cpp
+++ test/clang-rename/ClassTestMulti.cpp
@@ -5,7 +5,7 @@
 };
 
 // Test 1.
-// RUN: clang-rename rename-all -offset=6 -new-name=Bar1 -offset=76 -new-name=Bar2 %s -- | sed 's,//.*,,' | FileCheck %s
+// RUN: clang-rename -offset=6 -new-name=Bar1 -offset=76 -new-name=Bar2 %s -- | sed 's,//.*,,' | FileCheck %s
 
 // To find offsets after modifying the file, use:
 //   grep -Ubo 'Foo.*' 
Index: test/clang-rename/ClassFindByName.cpp
===
--- test/clang-rename/ClassFindByName.cpp
+++ test/clang-rename/ClassFindByName.cpp
@@ -7,4 +7,4 @@
 }
 
 // Test 1.
-// RUN: clang-rename rename-all -old-name=Foo -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s
+// RUN: clang-rename -qualified-name=Foo -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s
Index: docs/clang-rename.rst
===
--- docs/clang-rename.rst
+++ docs/clang-rename.rst
@@ -52,21 +52,29 @@
 Although a command line interface exists, it is highly recommended to use the
 text editor interface instead for better 

Re: [PATCH] D24224: [clang-rename] Merge rename-{ at | all } and optimise USRFindingAction.

2016-09-06 Thread Alexander Kornienko via cfe-commits
alexfh requested changes to this revision.
This revision now requires changes to proceed.


Comment at: clang-rename/USRFindingAction.cpp:49
@@ -47,4 +48,3 @@
 public:
-  explicit AdditionalUSRFinder(const Decl *FoundDecl, ASTContext ,
-   std::vector *USRs)
-  : FoundDecl(FoundDecl), Context(Context), USRs(USRs) {}
+  explicit AdditionalUSRFinder(const Decl *FoundDecl, ASTContext )
+  : FoundDecl(FoundDecl), Context(Context) {}

Why explicit?


Comment at: clang-rename/USRFindingAction.cpp:140
@@ +139,3 @@
+public:
+  explicit NamedDeclFindingConsumer(
+  ArrayRef SymbolOffsets, ArrayRef QualifiedNames,

What's the reason to make the constructor explicit?


Comment at: clang-rename/USRFindingAction.cpp:158
@@ -150,1 +157,3 @@
+
+if (QualifiedName.empty())
   FoundDecl = getNamedDeclAt(Context, Point);

Use conditional operator.


Comment at: clang-rename/USRFindingAction.h:23
@@ -19,1 +22,3 @@
+
+using llvm::ArrayRef;
 

No using declarations in headers, please. Also, since your code is in the clang 
namespace, you can include clang/Basic/LLVM.h that re-declares ArrayRef in 
namespace clang.


Comment at: clang-rename/USRFindingAction.h:38
@@ -31,5 +37,3 @@
 
-  // \brief get the spelling of the USR(s) as it would appear in source files.
-  const std::string () { return SpellingName; }
-
-  const std::vector () { return USRs; }
+  const std::vector () { return SpellingNames; }
+  const std::vector () { return USRList; }

Return ArrayRef.


Comment at: clang-rename/USRFindingAction.h:39
@@ -36,1 +38,3 @@
+  const std::vector () { return SpellingNames; }
+  const std::vector () { return USRList; }
 

Same here.


https://reviews.llvm.org/D24224



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


Re: [PATCH] D21505: [Clang][AVX512][Intrinsics]Adding intrinsics for mov{ss|sd} instruction set

2016-09-06 Thread michael zuckerman via cfe-commits
m_zuckerman updated this revision to Diff 70383.

https://reviews.llvm.org/D21505

Files:
  lib/Headers/avx512fintrin.h
  test/CodeGen/avx512f-builtins.c

Index: test/CodeGen/avx512f-builtins.c
===
--- test/CodeGen/avx512f-builtins.c
+++ test/CodeGen/avx512f-builtins.c
@@ -241,6 +241,20 @@
   _mm512_mask_store_pd(p, m, a);
 }
 
+void test_mm_mask_store_ss (float * __W, __mmask8 __U, __m128 __A)
+{
+  // CHECK-LABEL: @test_mm_mask_store_ss
+  // CHECK:  store float {{.*}}, float* {{.*}}
+  return _mm_mask_store_ss (__W, __U, __A);
+}
+
+void test_mm_mask_store_sd (double * __W, __mmask8 __U, __m128d __A)
+{
+  // CHECK-LABEL: @test_mm_mask_store_sd
+  // CHECK:  store double {{.*}}, double* {{.*}}
+  return _mm_mask_store_sd ( __W,  __U,  __A);
+}
+
 void test_mm512_mask_storeu_epi32(void *__P, __mmask16 __U, __m512i __A) {
   // CHECK-LABEL: @test_mm512_mask_storeu_epi32
   // CHECK: @llvm.masked.store.v16i32.p0v16i32(<16 x i32> %{{.*}}, <16 x i32>* %{{.*}}, i32 1, <16 x i1> %{{.*}})
@@ -371,6 +385,46 @@
   return _mm512_maskz_load_pd(__U, __P);
 }
 
+__m128 test_mm_mask_load_ss (__m128 __W, __mmask8 __U, float const* __A)
+{
+  // CHECK-LABEL: @test_mm_mask_load_ss
+  // CHECK:cond.true.i
+  // CHECK: store <4 x float> {{.*}}, <4 x float>* {{.*}}
+  // CHECK:cond.false.i
+  // CHECK: store <4 x float> {{.*}}, <4 x float>* {{.*}}
+  return _mm_mask_load_ss ( __W,  __U,  __A);
+}
+
+__m128 test_mm_maskz_load_ss (__mmask8 __U, float const* __A)
+{
+  // CHECK-LABEL: @test_mm_maskz_load_ss
+  // CHECK:cond.true.i
+  // CHECK: store <4 x float> {{.*}}, <4 x float>* {{.*}}
+  // CHECK:cond.false.i
+  // CHECK: store <4 x float> zeroinitializer, <4 x float>* {{.*}}
+  return _mm_maskz_load_ss (__U, __A);
+}
+
+__m128d test_mm_mask_load_sd (__m128 __W, __mmask8 __U, double const* __A)
+{
+  // CHECK-LABEL: test_mm_mask_load_sd
+  // CHECK:cond.true.i
+  // CHECK: store <2 x double> {{.*}}, <2 x double>* {{.*}}
+  // CHECK:cond.false.i
+  // CHECK: store <2 x double> {{.*}}, <2 x double>* {{.*}}
+  return _mm_mask_load_sd ( __W,  __U,  __A);
+}
+
+__m128d test_mm_maskz_load_sd (__mmask8 __U, double const* __A)
+{
+  // CHECK-LABEL: test_mm_maskz_load_sd
+  // CHECK:cond.true.i
+  // CHECK: store <2 x double> {{.*}}, <2 x double>* {{.*}}
+  // CHECK:cond.false.i
+  // CHECK: store <2 x double> zeroinitializer, <2 x double>* {{.*}}
+  return _mm_maskz_load_sd (__U, __A);
+}
+
 __m512d test_mm512_set1_pd(double d)
 {
   // CHECK-LABEL: @test_mm512_set1_pd
@@ -6199,6 +6253,54 @@
   return _mm512_maskz_mov_ps(__U, __A); 
 }
 
+__m128 test_mm_mask_move_ss (__m128 __W, __mmask8 __U, __m128 __A, __m128 __B)
+{
+  // CHECK-LABEL: @test_mm_mask_move_ss
+  // CHECK: cond.true.i
+  // CHECK: %6 = load <4 x float>, <4 x float>* %__B.addr.i, align 16
+  // CHECK: cond.false.i
+  // CHECK: %7 = load <4 x float>, <4 x float>* %__W.addr.i, align 16
+  // CHECK: %8 = load <4 x float>, <4 x float>* %res.i, align 16
+  // CHECK: %vecins.i = insertelement <4 x float> %8, float %cond.i, i32 0
+ return _mm_mask_move_ss ( __W,  __U,  __A,  __B);
+}
+
+__m128 test_mm_maskz_move_ss (__mmask8 __U, __m128 __A, __m128 __B)
+{
+  // CHECK-LABEL: @test_mm_maskz_move_ss
+  // CHECK: cond.true.i
+  // CHECK: %5 = load <4 x float>, <4 x float>* %__B.addr.i
+  // CHECK: cond.false.i
+  // CHECK: br label %_mm_maskz_move_ss.exit
+  // CHECK: %6 = load <4 x float>, <4 x float>* %res.i, align 16
+  // CHECK: %vecins.i = insertelement <4 x float> %6, float %cond.i, i32 0
+  return _mm_maskz_move_ss (__U, __A, __B);
+}
+
+__m128d test_mm_mask_move_sd (__m128 __W, __mmask8 __U, __m128d __A, __m128d __B)
+{
+  // CHECK-LABEL: @test_mm_mask_move_sd
+  // CHECK: cond.true.i
+  // CHECK: %7 = load <2 x double>, <2 x double>* %__B.addr.i, align 16
+  // CHECK: cond.false.i
+  // CHECK: %8 = load <2 x double>, <2 x double>* %__W.addr.i, align 16
+  // CHECK: %9 = load <2 x double>, <2 x double>* %res.i, align 16
+  // CHECK: %vecins.i = insertelement <2 x double> %9, double %cond.i, i32 0
+  return _mm_mask_move_sd ( __W,  __U,  __A,  __B);
+}
+
+__m128d test_mm_maskz_move_sd (__mmask8 __U, __m128d __A, __m128d __B)
+{
+  // CHECK-LABEL: @test_mm_maskz_move_sd
+  // CHECK: cond.true.i
+  // CHECK: %5 = load <2 x double>, <2 x double>* %__B.addr.i, align 16
+  // CHECK: cond.false.i
+  // CHECK: br label %_mm_maskz_move_sd.exit
+  // CHECK: %6 = load <2 x double>, <2 x double>* %res.i, align 16
+  // CHECK: %vecins.i = insertelement <2 x double> %6, double %cond.i, i32 0
+  return _mm_maskz_move_sd (__U, __A, __B);
+}
+
 void test_mm512_mask_compressstoreu_pd(void *__P, __mmask8 __U, __m512d __A) {
   // CHECK-LABEL: @test_mm512_mask_compressstoreu_pd
   // CHECK: @llvm.x86.avx512.mask.compress.store.pd.512
Index: lib/Headers/avx512fintrin.h
===
--- lib/Headers/avx512fintrin.h
+++ lib/Headers/avx512fintrin.h
@@ -4558,6 +4558,30 @@
   

Re: [PATCH] D24087: [lit] Allow more file extensions for test cases.

2016-09-06 Thread Eric Fiselier via cfe-commits
EricWF added inline comments.


Comment at: test/libcxx/test/format.py:69
@@ +68,3 @@
+name_root, name_ext = os.path.splitext(name)
+is_sh_test = name_root.endswith('.sh')
+is_pass_test = name_root.endswith('.pass')

logan wrote:
> EricWF wrote:
> > Since we only support `.sh.XXX` tests let's only loosen the restriction 
> > there for now.
> Do you mean that it is preferred to revert following two lines back?  For 
> example:
> 
> is_sh_test = name_root.endswith('.sh')
> is_pass_test = name.endswith('.pass.cpp')
> is_fail_test = name.endswith('.fail.cpp')
> assert is_sh_test or name_ext == '.cpp'
Yeah. Leave a FIXME about `CXXCompiler` not supporting assembly if you want. 


https://reviews.llvm.org/D24087



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


Re: [PATCH] D24083: [CMake] Fix libc++abi __aeabi_idiv() link error.

2016-09-06 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

In https://reviews.llvm.org/D24083#534459, @logan wrote:

> One solution might be adding the `libclang_rt.builtins.${arch}.a` detection 
> rules[1] to CMakeLists.txt, and manually specify 
> `-lclang_rt.builtins-${arch}.a` when `LIBCXXABI_USE_COMPILER_RT` is enabled.  
> How do you think about this solution?


That SGTM. There's a similar workaround in libc++ to link the sanitizer 
run-times on OS X (found here 
).


https://reviews.llvm.org/D24083



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


Re: [PATCH] D21968: [libcxx] Externally threaded libc++ variant - Take 2

2016-09-06 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

This looks great.  Two comments:

1. The declarations should be used in both the inline and external pthread 
implementation. They also need visibility declarations.
2. Why can't we use the inline implementation to implement 
`external_threads.cpp`?

I took a stab at it here 
.

After that this LGTM.



Comment at: lib/CMakeLists.txt:211
@@ +210,3 @@
+
+  set_target_properties(cxx_external_threads
+PROPERTIES

When this is building as a shared library it needs to do the `-nodefaultlibs` 
dance to prevent linking to libstdc++.so or other unwanted system libraries.


https://reviews.llvm.org/D21968



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


Re: [PATCH] D24083: [CMake] Fix libc++abi __aeabi_idiv() link error.

2016-09-06 Thread Logan Chien via cfe-commits
logan added a comment.

Hi @rengolin and @EricWF,

After tracing the commit log of clang, it seems that `--rtlib=` is ignored 
intentionally when `-nodefaultlibs` is present.  (see also: 
https://reviews.llvm.org/rL254535)

And, unfortunately, we don't have a command line option to ask clang to link 
compiler-rt built-in library along (regardless the `-nodefaultlibs` option.)

One solution might be adding the `libclang_rt.builtins.${arch}.a` detection 
rules[1] to CMakeLists.txt, and manually specify 
`-lclang_rt.builtins-${arch}.a` when `LIBCXXABI_USE_COMPILER_RT` is enabled.  
How do you think about this solution?

[1] There is a function named `ToolChain::getCompilerRT()` in 
`${clang}/lib/Driver/ToolChain.cpp` which is responsible to detect and pick the 
correct compiler-rt library.


https://reviews.llvm.org/D24083



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


Re: [PATCH] D23842: [CFG] Add iterator_ranges to CFG and CFGBlock.

2016-09-06 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: include/clang/Analysis/CFG.h:526
@@ -524,1 +525,3 @@
   typedef AdjacentBlocks::const_reverse_iterator  const_pred_reverse_iterator;
+  typedef llvm::iterator_range  pred_range;
+  typedef llvm::iterator_range  pred_const_range;

mboehme wrote:
> alexfh wrote:
> > Most of the time the new functions will be used in a range-based for loop. 
> > I don't think the type returned by the functions will need to be explicitly 
> > specified anywhere. I'd remove the typedefs.
> I agree the typedefs will probably never be used outside this class, but 
> typedefs for iterator_ranges seem to be a common pattern in the Clang 
> codebase. (EnumDecl::enumerator_range and CallExpr::arg_range are two random 
> examples.) I assume the intent is to make the definition of the functions 
> that return these ranges less verbose.
> 
> Are you OK with me submitting this patch as-is (with the typedefs)?
Makes sense.


https://reviews.llvm.org/D23842



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


r280701 - DebugInfo: use llvm::DINode::DIFlags type for debug info flags

2016-09-06 Thread Leny Kholodov via cfe-commits
Author: lkholodov
Date: Tue Sep  6 05:48:04 2016
New Revision: 280701

URL: http://llvm.org/viewvc/llvm-project?rev=280701=rev
Log:
DebugInfo: use llvm::DINode::DIFlags type for debug info flags

Use llvm::DINode::DIFlags type (strongly typed enum) for debug flags instead of 
unsigned int to avoid problems on platforms with sizeof(int) < 4: we already 
have flags with values > (1 << 16).

Patch by: Victor Leschuk 

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


Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=280701=280700=280701=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Sep  6 05:48:04 2016
@@ -497,12 +497,12 @@ llvm::DIType *CGDebugInfo::CreateType(co
 
 ObjTy =
 DBuilder.createStructType(TheCU, "objc_object", getOrCreateMainFile(),
-  0, 0, 0, 0, nullptr, llvm::DINodeArray());
+  0, 0, 0, llvm::DINode::FlagZero, nullptr, 
llvm::DINodeArray());
 
 DBuilder.replaceArrays(
 ObjTy,
 DBuilder.getOrCreateArray(&*DBuilder.createMemberType(
-ObjTy, "isa", getOrCreateMainFile(), 0, Size, 0, 0, 0, ISATy)));
+ObjTy, "isa", getOrCreateMainFile(), 0, Size, 0, 0, 
llvm::DINode::FlagZero, ISATy)));
 return ObjTy;
   }
   case BuiltinType::ObjCSel: {
@@ -787,7 +787,7 @@ llvm::DIType *CGDebugInfo::CreateType(co
   Elements = DBuilder.getOrCreateArray(EltTys);
   EltTys.clear();
 
-  unsigned Flags = llvm::DINode::FlagAppleBlock;
+  llvm::DINode::DIFlags Flags = llvm::DINode::FlagAppleBlock;
   unsigned LineNo = 0;
 
   auto *EltTy =
@@ -813,7 +813,7 @@ llvm::DIType *CGDebugInfo::CreateType(co
   FieldAlign = CGM.getContext().getTypeAlign(Ty);
   EltTys.push_back(DBuilder.createMemberType(Unit, "__descriptor", nullptr, 
LineNo,
  FieldSize, FieldAlign, 
FieldOffset,
- 0, DescTy));
+ llvm::DINode::FlagZero, DescTy));
 
   FieldOffset += FieldSize;
   Elements = DBuilder.getOrCreateArray(EltTys);
@@ -917,14 +917,14 @@ llvm::DIType *CGDebugInfo::CreateType(co
   }
 
   llvm::DITypeRefArray EltTypeArray = DBuilder.getOrCreateTypeArray(EltTys);
-  return DBuilder.createSubroutineType(EltTypeArray, 0,
+  return DBuilder.createSubroutineType(EltTypeArray, llvm::DINode::FlagZero,
getDwarfCC(Ty->getCallConv()));
 }
 
 /// Convert an AccessSpecifier into the corresponding DINode flag.
 /// As an optimization, return 0 if the access specifier equals the
 /// default for the containing type.
-static unsigned getAccessFlag(AccessSpecifier Access, const RecordDecl *RD) {
+static llvm::DINode::DIFlags getAccessFlag(AccessSpecifier Access, const 
RecordDecl *RD) {
   AccessSpecifier Default = clang::AS_none;
   if (RD && RD->isClass())
 Default = clang::AS_private;
@@ -932,7 +932,7 @@ static unsigned getAccessFlag(AccessSpec
 Default = clang::AS_public;
 
   if (Access == Default)
-return 0;
+return llvm::DINode::FlagZero;
 
   switch (Access) {
   case clang::AS_private:
@@ -942,7 +942,7 @@ static unsigned getAccessFlag(AccessSpec
   case clang::AS_public:
 return llvm::DINode::FlagPublic;
   case clang::AS_none:
-return 0;
+return llvm::DINode::FlagZero;
   }
   llvm_unreachable("unexpected access enumerator");
 }
@@ -968,7 +968,7 @@ llvm::DIType *CGDebugInfo::createBitFiel
   uint64_t StorageOffsetInBits =
   CGM.getContext().toBits(BitFieldInfo.StorageOffset);
   uint64_t OffsetInBits = StorageOffsetInBits + BitFieldInfo.Offset;
-  unsigned Flags = getAccessFlag(BitFieldDecl->getAccess(), RD);
+  llvm::DINode::DIFlags Flags = getAccessFlag(BitFieldDecl->getAccess(), RD);
   return DBuilder.createBitFieldMemberType(
   RecordTy, Name, File, Line, SizeInBits, AlignInBits, OffsetInBits,
   StorageOffsetInBits, Flags, DebugType);
@@ -993,7 +993,7 @@ CGDebugInfo::createFieldType(StringRef n
 AlignInBits = TI.Align;
   }
 
-  unsigned flags = getAccessFlag(AS, RD);
+  llvm::DINode::DIFlags flags = getAccessFlag(AS, RD);
   return DBuilder.createMemberType(scope, name, file, line, SizeInBits,
AlignInBits, offsetInBits, flags, 
debugType);
 }
@@ -1060,7 +1060,7 @@ CGDebugInfo::CreateRecordStaticField(con
 }
   }
 
-  unsigned Flags = getAccessFlag(Var->getAccess(), RD);
+  llvm::DINode::DIFlags Flags = getAccessFlag(Var->getAccess(), RD);
   llvm::DIDerivedType *GV = DBuilder.createStaticMemberType(
   RecordTy, VName, VUnit, LineNumber, VTy, Flags, C);
   StaticDataMemberCache[Var->getCanonicalDecl()].reset(GV);
@@ 

Re: [PATCH] D23767: DebugInfo: use llvm::DINode::DIFlags type for debug info flags

2016-09-06 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL280701: DebugInfo: use llvm::DINode::DIFlags type for debug 
info flags (authored by lkholodov).

Changed prior to commit:
  https://reviews.llvm.org/D23767?vs=69755=70375#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23767

Files:
  cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
  cfe/trunk/lib/CodeGen/CGDebugInfo.h

Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
@@ -497,12 +497,12 @@
 
 ObjTy =
 DBuilder.createStructType(TheCU, "objc_object", getOrCreateMainFile(),
-  0, 0, 0, 0, nullptr, llvm::DINodeArray());
+  0, 0, 0, llvm::DINode::FlagZero, nullptr, llvm::DINodeArray());
 
 DBuilder.replaceArrays(
 ObjTy,
 DBuilder.getOrCreateArray(&*DBuilder.createMemberType(
-ObjTy, "isa", getOrCreateMainFile(), 0, Size, 0, 0, 0, ISATy)));
+ObjTy, "isa", getOrCreateMainFile(), 0, Size, 0, 0, llvm::DINode::FlagZero, ISATy)));
 return ObjTy;
   }
   case BuiltinType::ObjCSel: {
@@ -787,7 +787,7 @@
   Elements = DBuilder.getOrCreateArray(EltTys);
   EltTys.clear();
 
-  unsigned Flags = llvm::DINode::FlagAppleBlock;
+  llvm::DINode::DIFlags Flags = llvm::DINode::FlagAppleBlock;
   unsigned LineNo = 0;
 
   auto *EltTy =
@@ -813,7 +813,7 @@
   FieldAlign = CGM.getContext().getTypeAlign(Ty);
   EltTys.push_back(DBuilder.createMemberType(Unit, "__descriptor", nullptr, LineNo,
  FieldSize, FieldAlign, FieldOffset,
- 0, DescTy));
+ llvm::DINode::FlagZero, DescTy));
 
   FieldOffset += FieldSize;
   Elements = DBuilder.getOrCreateArray(EltTys);
@@ -917,22 +917,22 @@
   }
 
   llvm::DITypeRefArray EltTypeArray = DBuilder.getOrCreateTypeArray(EltTys);
-  return DBuilder.createSubroutineType(EltTypeArray, 0,
+  return DBuilder.createSubroutineType(EltTypeArray, llvm::DINode::FlagZero,
getDwarfCC(Ty->getCallConv()));
 }
 
 /// Convert an AccessSpecifier into the corresponding DINode flag.
 /// As an optimization, return 0 if the access specifier equals the
 /// default for the containing type.
-static unsigned getAccessFlag(AccessSpecifier Access, const RecordDecl *RD) {
+static llvm::DINode::DIFlags getAccessFlag(AccessSpecifier Access, const RecordDecl *RD) {
   AccessSpecifier Default = clang::AS_none;
   if (RD && RD->isClass())
 Default = clang::AS_private;
   else if (RD && (RD->isStruct() || RD->isUnion()))
 Default = clang::AS_public;
 
   if (Access == Default)
-return 0;
+return llvm::DINode::FlagZero;
 
   switch (Access) {
   case clang::AS_private:
@@ -942,7 +942,7 @@
   case clang::AS_public:
 return llvm::DINode::FlagPublic;
   case clang::AS_none:
-return 0;
+return llvm::DINode::FlagZero;
   }
   llvm_unreachable("unexpected access enumerator");
 }
@@ -968,7 +968,7 @@
   uint64_t StorageOffsetInBits =
   CGM.getContext().toBits(BitFieldInfo.StorageOffset);
   uint64_t OffsetInBits = StorageOffsetInBits + BitFieldInfo.Offset;
-  unsigned Flags = getAccessFlag(BitFieldDecl->getAccess(), RD);
+  llvm::DINode::DIFlags Flags = getAccessFlag(BitFieldDecl->getAccess(), RD);
   return DBuilder.createBitFieldMemberType(
   RecordTy, Name, File, Line, SizeInBits, AlignInBits, OffsetInBits,
   StorageOffsetInBits, Flags, DebugType);
@@ -993,7 +993,7 @@
 AlignInBits = TI.Align;
   }
 
-  unsigned flags = getAccessFlag(AS, RD);
+  llvm::DINode::DIFlags flags = getAccessFlag(AS, RD);
   return DBuilder.createMemberType(scope, name, file, line, SizeInBits,
AlignInBits, offsetInBits, flags, debugType);
 }
@@ -1060,7 +1060,7 @@
 }
   }
 
-  unsigned Flags = getAccessFlag(Var->getAccess(), RD);
+  llvm::DINode::DIFlags Flags = getAccessFlag(Var->getAccess(), RD);
   llvm::DIDerivedType *GV = DBuilder.createStaticMemberType(
   RecordTy, VName, VUnit, LineNumber, VTy, Flags, C);
   StaticDataMemberCache[Var->getCanonicalDecl()].reset(GV);
@@ -1203,7 +1203,7 @@
 
   llvm::DITypeRefArray EltTypeArray = DBuilder.getOrCreateTypeArray(Elts);
 
-  unsigned Flags = 0;
+  llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
   if (Func->getExtProtoInfo().RefQualifier == RQ_LValue)
 Flags |= llvm::DINode::FlagLValueReference;
   if (Func->getExtProtoInfo().RefQualifier == RQ_RValue)
@@ -1254,7 +1254,7 @@
   llvm::DIType *ContainingType = nullptr;
   unsigned Virtuality = 0;
   unsigned VIndex = 0;
-  unsigned Flags = 0;
+  llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
   int ThisAdjustment = 0;
 
   if (Method->isVirtual()) {
@@ -1367,7 +1367,7 @@
   llvm::DIType *RecordTy) {
   

r280702 - [clang-cl] Check that we are in clang cl mode before enabling support for the CL environment variable.

2016-09-06 Thread Pierre Gousseau via cfe-commits
Author: pgousseau
Date: Tue Sep  6 05:48:27 2016
New Revision: 280702

URL: http://llvm.org/viewvc/llvm-project?rev=280702=rev
Log:
[clang-cl] Check that we are in clang cl mode before enabling support for the 
CL environment variable.

Checking for the type of the command line tokenizer should not be the criteria 
to enable support for the CL environment variable, this change checks that we 
are in clang-cl mode instead.

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

Modified:
cfe/trunk/test/Driver/cl-options.c
cfe/trunk/tools/driver/driver.cpp

Modified: cfe/trunk/test/Driver/cl-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=280702=280701=280702=diff
==
--- cfe/trunk/test/Driver/cl-options.c (original)
+++ cfe/trunk/test/Driver/cl-options.c Tue Sep  6 05:48:27 2016
@@ -493,6 +493,8 @@
 // RUN: env CL="/Gy" _CL_="/Gy- -- %s" %clang_cl -### 2>&1 | FileCheck 
-check-prefix=ENV-_CL_ %s
 // ENV-_CL_-NOT: "-ffunction-sections"
 
+// RUN: env CL="%s" _CL_="%s" not %clang --rsp-quoting=windows -c
+
 // Accept "core" clang options.
 // (/Zs is for syntax-only, -Werror makes it fail hard on unknown options)
 // RUN: %clang_cl \

Modified: cfe/trunk/tools/driver/driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/driver.cpp?rev=280702=280701=280702=diff
==
--- cfe/trunk/tools/driver/driver.cpp (original)
+++ cfe/trunk/tools/driver/driver.cpp Tue Sep  6 05:48:27 2016
@@ -393,7 +393,7 @@ int main(int argc_, const char **argv_)
 
   // Handle CL and _CL_ which permits additional command line options to be
   // prepended or appended.
-  if (Tokenizer == ::cl::TokenizeWindowsCommandLine) {
+  if (ClangCLMode) {
 // Arguments in "CL" are prepended.
 llvm::Optional OptCL = llvm::sys::Process::GetEnv("CL");
 if (OptCL.hasValue()) {


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


Re: [PATCH] D23503: [clang-cl] Check that we are in clang cl mode before enabling support for the CL environment variable.

2016-09-06 Thread pierre gousseau via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL280702: [clang-cl] Check that we are in clang cl mode before 
enabling support for the… (authored by pgousseau).

Changed prior to commit:
  https://reviews.llvm.org/D23503?vs=68020=70376#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23503

Files:
  cfe/trunk/test/Driver/cl-options.c
  cfe/trunk/tools/driver/driver.cpp

Index: cfe/trunk/tools/driver/driver.cpp
===
--- cfe/trunk/tools/driver/driver.cpp
+++ cfe/trunk/tools/driver/driver.cpp
@@ -393,7 +393,7 @@
 
   // Handle CL and _CL_ which permits additional command line options to be
   // prepended or appended.
-  if (Tokenizer == ::cl::TokenizeWindowsCommandLine) {
+  if (ClangCLMode) {
 // Arguments in "CL" are prepended.
 llvm::Optional OptCL = llvm::sys::Process::GetEnv("CL");
 if (OptCL.hasValue()) {
Index: cfe/trunk/test/Driver/cl-options.c
===
--- cfe/trunk/test/Driver/cl-options.c
+++ cfe/trunk/test/Driver/cl-options.c
@@ -493,6 +493,8 @@
 // RUN: env CL="/Gy" _CL_="/Gy- -- %s" %clang_cl -### 2>&1 | FileCheck 
-check-prefix=ENV-_CL_ %s
 // ENV-_CL_-NOT: "-ffunction-sections"
 
+// RUN: env CL="%s" _CL_="%s" not %clang --rsp-quoting=windows -c
+
 // Accept "core" clang options.
 // (/Zs is for syntax-only, -Werror makes it fail hard on unknown options)
 // RUN: %clang_cl \


Index: cfe/trunk/tools/driver/driver.cpp
===
--- cfe/trunk/tools/driver/driver.cpp
+++ cfe/trunk/tools/driver/driver.cpp
@@ -393,7 +393,7 @@
 
   // Handle CL and _CL_ which permits additional command line options to be
   // prepended or appended.
-  if (Tokenizer == ::cl::TokenizeWindowsCommandLine) {
+  if (ClangCLMode) {
 // Arguments in "CL" are prepended.
 llvm::Optional OptCL = llvm::sys::Process::GetEnv("CL");
 if (OptCL.hasValue()) {
Index: cfe/trunk/test/Driver/cl-options.c
===
--- cfe/trunk/test/Driver/cl-options.c
+++ cfe/trunk/test/Driver/cl-options.c
@@ -493,6 +493,8 @@
 // RUN: env CL="/Gy" _CL_="/Gy- -- %s" %clang_cl -### 2>&1 | FileCheck -check-prefix=ENV-_CL_ %s
 // ENV-_CL_-NOT: "-ffunction-sections"
 
+// RUN: env CL="%s" _CL_="%s" not %clang --rsp-quoting=windows -c
+
 // Accept "core" clang options.
 // (/Zs is for syntax-only, -Werror makes it fail hard on unknown options)
 // RUN: %clang_cl \
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24192: [clang-refactor] introducing clang-refactor

2016-09-06 Thread Kirill Bobyrev via cfe-commits
omtcyfz added a comment.

Bringing results of an offline discussion with Eric (@ioeric) live.

Eric's point was that this patch should only care about `clang-refactor` and 
introduce changes directly related to creating `clang-rename`. `clang-rename` 
and all other tools migration can be done later, which is also good in terms of 
this patch not growing too large.

Another point was that it should be easier if there would be a class, from 
which refactoring tools would derive and use it as an interface.

Advantages are as follows:

- It would be easier to implement multi-TU support as the tools wouldn't simply 
care about that part while delegating the "hard work" to the common part.
- It would be easier to implement new tools, because there will be a slightly 
simpler interface.
- It would be easier to setup unit tests and other routine, because right now 
all tools have to implement basic routine for unit tests, for example, which is 
just copied from the other tools' unit tests with slight changes. Delegating 
that to the common interface is also nice.

The current diff isn't final, but I wanted to bring it to the reviews, because 
it gives an overview of what I am doing and if there are any high-level 
comments to address it's better to get them sooner than later.


https://reviews.llvm.org/D24192



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


Re: [PATCH] D24192: [clang-refactor] introducing clang-refactor

2016-09-06 Thread Kirill Bobyrev via cfe-commits
omtcyfz updated the summary for this revision.
omtcyfz removed a reviewer: bkramer.
omtcyfz added subscribers: bkramer, hokein.
omtcyfz updated this revision to Diff 70373.
omtcyfz added a comment.

Removed whole clang-rename part, only making this patch clang-rename specific.


https://reviews.llvm.org/D24192

Files:
  CMakeLists.txt
  clang-refactor/CMakeLists.txt
  clang-refactor/driver/CMakeLists.txt
  clang-refactor/driver/Driver.cpp
  clang-refactor/driver/ModuleManager.cpp
  clang-refactor/driver/ModuleManager.h
  clang-refactor/modules/CMakeLists.txt
  clang-refactor/modules/core/RefactoringModule.h
  clang-refactor/modules/template/CMakeLists.txt
  clang-refactor/modules/template/TemplateModule.cpp
  clang-refactor/modules/template/TemplateModule.h

Index: clang-refactor/modules/template/TemplateModule.h
===
--- /dev/null
+++ clang-refactor/modules/template/TemplateModule.h
@@ -0,0 +1,42 @@
+//===--- RefactoringModuleTemplate.h - clang-refactor ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_REFACTOR_REFACTORING_MODULE_TEMPLATE_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_REFACTOR_REFACTORING_MODULE_TEMPLATE_H
+
+#include "../core/RefactoringModule.h"
+
+#include 
+
+namespace clang {
+namespace clang_refactor {
+namespace template_module {
+
+class TemplateModule : public RefactoringModule {
+public:
+  TemplateModule(const std::string ,
+ const std::string )
+  : RefactoringModule(ModuleName, ModuleMetaDesciption) {}
+
+  int checkArguments() override;
+
+  int extractRefactoringInformation() override;
+
+  int handleTranslationUnit() override;
+
+  int applyReplacements() override;
+
+  ~TemplateModule() override {}
+};
+
+} // end namespace template_module
+} // end namespace clang_refactor
+} // end namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_REFACTOR_REFACTORING_MODULE_TEMPLATE_H
Index: clang-refactor/modules/template/TemplateModule.cpp
===
--- /dev/null
+++ clang-refactor/modules/template/TemplateModule.cpp
@@ -0,0 +1,36 @@
+//===--- RefactoringModuleTemplate.cpp - clang-refactor -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "TemplateModule.h"
+
+#include 
+
+namespace clang {
+namespace clang_refactor {
+namespace template_module {
+
+int TemplateModule::checkArguments() {
+  return 0;
+}
+
+int TemplateModule::extractRefactoringInformation() {
+  return 0;
+}
+
+int TemplateModule::handleTranslationUnit() {
+  return 0;
+}
+
+int TemplateModule::applyReplacements() {
+  return 0;
+}
+
+} // end namespace template_module
+} // end namespace clang_refactor
+} // end namespace clang
Index: clang-refactor/modules/template/CMakeLists.txt
===
--- /dev/null
+++ clang-refactor/modules/template/CMakeLists.txt
@@ -0,0 +1,12 @@
+set(LLVM_LINK_COMPONENTS support)
+
+add_clang_library(clangRefactorTemplateModule
+  TemplateModule.cpp
+
+  LINK_LIBS
+  clangAST
+  clangASTMatchers
+  clangBasic
+  clangFrontend
+  clangTooling
+  )
Index: clang-refactor/modules/core/RefactoringModule.h
===
--- /dev/null
+++ clang-refactor/modules/core/RefactoringModule.h
@@ -0,0 +1,167 @@
+//===--- RefactoringModule.h - clang-refactor ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_REFACTOR_REFACTORING_MODULE_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_REFACTOR_REFACTORING_MODULE_H
+
+#include "clang/Tooling/CommonOptionsParser.h"
+#include "clang/Tooling/Refactoring.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Signals.h"
+
+#include 
+
+namespace clang {
+namespace clang_refactor {
+
+class RefactoringModule {
+public:
+  RefactoringModule(const std::string ,
+const std::string )
+  : ModuleName(ModuleName), ModuleMetaDescription(ModuleMetaDescription) {}
+
+  // Refactoring consists of 3.5 stages:
+  //
+  // 0. Check arguments for validity.
+  //
+  // 1. Extract infromation needed for the 

Re: [PATCH] D23915: [OpenCL] Remove access qualifiers on images in arg info metadata.

2016-09-06 Thread Alexey Bader via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL280699: [OpenCL] Remove access qualifiers on images in arg 
info metadata. (authored by bader).

Changed prior to commit:
  https://reviews.llvm.org/D23915?vs=69649=70372#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23915

Files:
  cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
  cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl

Index: cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl
===
--- cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl
+++ cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown | FileCheck %s
-// RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown -cl-kernel-arg-info | FileCheck %s -check-prefix ARGINFO
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -o - -triple spir-unknown-unknown | FileCheck %s
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -o - -triple spir-unknown-unknown -cl-kernel-arg-info | FileCheck %s -check-prefix ARGINFO
 
 kernel void foo(__global int * restrict X, const int Y, 
 volatile int anotherArg, __constant float * restrict Z) {
@@ -14,7 +14,7 @@
 // CHECK-NOT: !kernel_arg_name
 // ARGINFO: !kernel_arg_name ![[MD15:[0-9]+]]
 
-kernel void foo2(read_only image1d_t img1, image2d_t img2, write_only image2d_array_t img3) {
+kernel void foo2(read_only image1d_t img1, image2d_t img2, write_only image2d_array_t img3, read_write image1d_t img4) {
 }
 // CHECK: define spir_kernel void @foo2{{[^!]+}}
 // CHECK: !kernel_arg_addr_space ![[MD21:[0-9]+]]
@@ -65,11 +65,11 @@
 // CHECK: ![[MD13]] = !{!"int*", !"int", !"int", !"float*"}
 // CHECK: ![[MD14]] = !{!"restrict", !"const", !"volatile", !"restrict const"}
 // ARGINFO: ![[MD15]] = !{!"X", !"Y", !"anotherArg", !"Z"}
-// CHECK: ![[MD21]] = !{i32 1, i32 1, i32 1}
-// CHECK: ![[MD22]] = !{!"read_only", !"read_only", !"write_only"}
-// CHECK: ![[MD23]] = !{!"__read_only image1d_t", !"__read_only image2d_t", !"__write_only image2d_array_t"}
-// CHECK: ![[MD24]] = !{!"", !"", !""}
-// ARGINFO: ![[MD25]] = !{!"img1", !"img2", !"img3"}
+// CHECK: ![[MD21]] = !{i32 1, i32 1, i32 1, i32 1}
+// CHECK: ![[MD22]] = !{!"read_only", !"read_only", !"write_only", !"read_write"}
+// CHECK: ![[MD23]] = !{!"image1d_t", !"image2d_t", !"image2d_array_t", !"image1d_t"}
+// CHECK: ![[MD24]] = !{!"", !"", !"", !""}
+// ARGINFO: ![[MD25]] = !{!"img1", !"img2", !"img3", !"img4"}
 // CHECK: ![[MD31]] = !{i32 1}
 // CHECK: ![[MD32]] = !{!"none"}
 // CHECK: ![[MD33]] = !{!"half*"}
@@ -82,7 +82,7 @@
 // CHECK: ![[MD45]] = !{!"", !""}
 // ARGINFO: ![[MD46]] = !{!"X", !"Y"}
 // CHECK: ![[MD51]] = !{!"read_only", !"write_only"}
-// CHECK: ![[MD52]] = !{!"myImage", !"__write_only image1d_t"}
-// CHECK: ![[MD53]] = !{!"__read_only image1d_t", !"__write_only image1d_t"}
+// CHECK: ![[MD52]] = !{!"myImage", !"image1d_t"}
+// CHECK: ![[MD53]] = !{!"image1d_t", !"image1d_t"}
 // ARGINFO: ![[MD54]] = !{!"img1", !"img2"}
 
Index: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
@@ -428,6 +428,26 @@
   EmitNounwindRuntimeCall(F, args);
 }
 
+static void removeImageAccessQualifier(std::string& TyName) {
+  std::string ReadOnlyQual("__read_only");
+  std::string::size_type ReadOnlyPos = TyName.find(ReadOnlyQual);
+  if (ReadOnlyPos != std::string::npos)
+// "+ 1" for the space after access qualifier.
+TyName.erase(ReadOnlyPos, ReadOnlyQual.size() + 1);
+  else {
+std::string WriteOnlyQual("__write_only");
+std::string::size_type WriteOnlyPos = TyName.find(WriteOnlyQual);
+if (WriteOnlyPos != std::string::npos)
+  TyName.erase(WriteOnlyPos, WriteOnlyQual.size() + 1);
+else {
+  std::string ReadWriteQual("__read_write");
+  std::string::size_type ReadWritePos = TyName.find(ReadWriteQual);
+  if (ReadWritePos != std::string::npos)
+TyName.erase(ReadWritePos, ReadWriteQual.size() + 1);
+}
+  }
+}
+
 // OpenCL v1.2 s5.6.4.6 allows the compiler to store kernel argument
 // information in the program executable. The argument information stored
 // includes the argument name, its type, the address and access qualifiers used.
@@ -524,8 +544,6 @@
   if (ty.isCanonical() && pos != std::string::npos)
 typeName.erase(pos+1, 8);
 
-  argTypeNames.push_back(llvm::MDString::get(Context, typeName));
-
   std::string baseTypeName;
   if (isPipe)
 baseTypeName = ty.getCanonicalType()->getAs()
@@ -535,6 +553,17 @@
 baseTypeName =
   ty.getUnqualifiedType().getCanonicalType().getAsString(Policy);
 
+  // Remove access qualifiers on images
+  // (as they are inseparable from type in clang implementation,
+  // but OpenCL spec provides a special query to get access 

r280699 - [OpenCL] Remove access qualifiers on images in arg info metadata.

2016-09-06 Thread Alexey Bader via cfe-commits
Author: bader
Date: Tue Sep  6 05:10:28 2016
New Revision: 280699

URL: http://llvm.org/viewvc/llvm-project?rev=280699=rev
Log:
[OpenCL] Remove access qualifiers on images in arg info metadata.

Summary:
Remove access qualifiers on images in arg info metadata:
 * kernel_arg_type
 * kernel_arg_base_type

Image access qualifiers are inseparable from type in clang implementation,
but OpenCL spec provides a special query to get access qualifier
via clGetKernelArgInfo with CL_KERNEL_ARG_ACCESS_QUALIFIER.

Besides that OpenCL conformance test_api get_kernel_arg_info expects
image types without access qualifier.

Patch by Evgeniy Tyurin.

Reviewers: bader, yaxunl, Anastasia

Subscribers: cfe-commits

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


Modified:
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=280699=280698=280699=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Tue Sep  6 05:10:28 2016
@@ -428,6 +428,26 @@ void CodeGenFunction::EmitFunctionInstru
   EmitNounwindRuntimeCall(F, args);
 }
 
+static void removeImageAccessQualifier(std::string& TyName) {
+  std::string ReadOnlyQual("__read_only");
+  std::string::size_type ReadOnlyPos = TyName.find(ReadOnlyQual);
+  if (ReadOnlyPos != std::string::npos)
+// "+ 1" for the space after access qualifier.
+TyName.erase(ReadOnlyPos, ReadOnlyQual.size() + 1);
+  else {
+std::string WriteOnlyQual("__write_only");
+std::string::size_type WriteOnlyPos = TyName.find(WriteOnlyQual);
+if (WriteOnlyPos != std::string::npos)
+  TyName.erase(WriteOnlyPos, WriteOnlyQual.size() + 1);
+else {
+  std::string ReadWriteQual("__read_write");
+  std::string::size_type ReadWritePos = TyName.find(ReadWriteQual);
+  if (ReadWritePos != std::string::npos)
+TyName.erase(ReadWritePos, ReadWriteQual.size() + 1);
+}
+  }
+}
+
 // OpenCL v1.2 s5.6.4.6 allows the compiler to store kernel argument
 // information in the program executable. The argument information stored
 // includes the argument name, its type, the address and access qualifiers 
used.
@@ -524,8 +544,6 @@ static void GenOpenCLArgMetadata(const F
   if (ty.isCanonical() && pos != std::string::npos)
 typeName.erase(pos+1, 8);
 
-  argTypeNames.push_back(llvm::MDString::get(Context, typeName));
-
   std::string baseTypeName;
   if (isPipe)
 baseTypeName = ty.getCanonicalType()->getAs()
@@ -535,6 +553,17 @@ static void GenOpenCLArgMetadata(const F
 baseTypeName =
   ty.getUnqualifiedType().getCanonicalType().getAsString(Policy);
 
+  // Remove access qualifiers on images
+  // (as they are inseparable from type in clang implementation,
+  // but OpenCL spec provides a special query to get access qualifier
+  // via clGetKernelArgInfo with CL_KERNEL_ARG_ACCESS_QUALIFIER):
+  if (ty->isImageType()) {
+removeImageAccessQualifier(typeName);
+removeImageAccessQualifier(baseTypeName);
+  }
+
+  argTypeNames.push_back(llvm::MDString::get(Context, typeName));
+
   // Turn "unsigned type" to "utype"
   pos = baseTypeName.find("unsigned");
   if (pos != std::string::npos)

Modified: cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl?rev=280699=280698=280699=diff
==
--- cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl Tue Sep  6 05:10:28 2016
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown | FileCheck 
%s
-// RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown 
-cl-kernel-arg-info | FileCheck %s -check-prefix ARGINFO
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -o - -triple 
spir-unknown-unknown | FileCheck %s
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -o - -triple 
spir-unknown-unknown -cl-kernel-arg-info | FileCheck %s -check-prefix ARGINFO
 
 kernel void foo(__global int * restrict X, const int Y, 
 volatile int anotherArg, __constant float * restrict Z) {
@@ -14,7 +14,7 @@ kernel void foo(__global int * restrict
 // CHECK-NOT: !kernel_arg_name
 // ARGINFO: !kernel_arg_name ![[MD15:[0-9]+]]
 
-kernel void foo2(read_only image1d_t img1, image2d_t img2, write_only 
image2d_array_t img3) {
+kernel void foo2(read_only image1d_t img1, image2d_t img2, write_only 
image2d_array_t img3, read_write image1d_t img4) {
 }
 // CHECK: define spir_kernel void @foo2{{[^!]+}}
 // CHECK: !kernel_arg_addr_space ![[MD21:[0-9]+]]
@@ -65,11 +65,11 @@ kernel void foo5(myImage img1, 

Re: [PATCH] D24136: [OpenCL] Fix pipe built-in functions return type.

2016-09-06 Thread Alexey Bader via cfe-commits
bader updated this revision to Diff 70368.
bader added a comment.

Added get_pipe_num_packets and get_pipe_max_packets test cases.


https://reviews.llvm.org/D24136

Files:
  lib/Sema/SemaChecking.cpp
  test/CodeGenOpenCL/pipe_builtin.cl

Index: test/CodeGenOpenCL/pipe_builtin.cl
===
--- test/CodeGenOpenCL/pipe_builtin.cl
+++ test/CodeGenOpenCL/pipe_builtin.cl
@@ -59,3 +59,19 @@
   // CHECK: call i32 @__get_pipe_max_packets(%opencl.pipe_t* %{{.*}})
   *ptr = get_pipe_max_packets(p);
 }
+
+void test8(read_only pipe int r, write_only pipe int w, global int *ptr) {
+  // verify that return type is correctly casted to i1 value
+  // CHECK: %[[R:[0-9]+]] = call i32 @__read_pipe_2
+  // CHECK: icmp ne i32 %[[R]], 0
+  if (read_pipe(r, ptr)) *ptr = -1;
+  // CHECK: %[[W:[0-9]+]] = call i32 @__write_pipe_2
+  // CHECK: icmp ne i32 %[[W]], 0
+  if (write_pipe(w, ptr)) *ptr = -1;
+  // CHECK: %[[N:[0-9]+]] = call i32 @__get_pipe_num_packets
+  // CHECK: icmp ne i32 %[[N]], 0
+  if (get_pipe_num_packets(r)) *ptr = -1;
+  // CHECK: %[[M:[0-9]+]] = call i32 @__get_pipe_max_packets
+  // CHECK: icmp ne i32 %[[M]], 0
+  if (get_pipe_max_packets(w)) *ptr = -1;
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -1020,6 +1020,7 @@
 // check for the argument.
 if (SemaBuiltinRWPipe(*this, TheCall))
   return ExprError();
+TheCall->setType(Context.IntTy);
 break;
   case Builtin::BIreserve_read_pipe:
   case Builtin::BIreserve_write_pipe:
@@ -1047,6 +1048,7 @@
   case Builtin::BIget_pipe_max_packets:
 if (SemaBuiltinPipePackets(*this, TheCall))
   return ExprError();
+TheCall->setType(Context.UnsignedIntTy);
 break;
   case Builtin::BIto_global:
   case Builtin::BIto_local:


Index: test/CodeGenOpenCL/pipe_builtin.cl
===
--- test/CodeGenOpenCL/pipe_builtin.cl
+++ test/CodeGenOpenCL/pipe_builtin.cl
@@ -59,3 +59,19 @@
   // CHECK: call i32 @__get_pipe_max_packets(%opencl.pipe_t* %{{.*}})
   *ptr = get_pipe_max_packets(p);
 }
+
+void test8(read_only pipe int r, write_only pipe int w, global int *ptr) {
+  // verify that return type is correctly casted to i1 value
+  // CHECK: %[[R:[0-9]+]] = call i32 @__read_pipe_2
+  // CHECK: icmp ne i32 %[[R]], 0
+  if (read_pipe(r, ptr)) *ptr = -1;
+  // CHECK: %[[W:[0-9]+]] = call i32 @__write_pipe_2
+  // CHECK: icmp ne i32 %[[W]], 0
+  if (write_pipe(w, ptr)) *ptr = -1;
+  // CHECK: %[[N:[0-9]+]] = call i32 @__get_pipe_num_packets
+  // CHECK: icmp ne i32 %[[N]], 0
+  if (get_pipe_num_packets(r)) *ptr = -1;
+  // CHECK: %[[M:[0-9]+]] = call i32 @__get_pipe_max_packets
+  // CHECK: icmp ne i32 %[[M]], 0
+  if (get_pipe_max_packets(w)) *ptr = -1;
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -1020,6 +1020,7 @@
 // check for the argument.
 if (SemaBuiltinRWPipe(*this, TheCall))
   return ExprError();
+TheCall->setType(Context.IntTy);
 break;
   case Builtin::BIreserve_read_pipe:
   case Builtin::BIreserve_write_pipe:
@@ -1047,6 +1048,7 @@
   case Builtin::BIget_pipe_max_packets:
 if (SemaBuiltinPipePackets(*this, TheCall))
   return ExprError();
+TheCall->setType(Context.UnsignedIntTy);
 break;
   case Builtin::BIto_global:
   case Builtin::BIto_local:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23992: [OpenCL] Augment pipe built-ins with pipe packet size and alignment.

2016-09-06 Thread Alexey Bader via cfe-commits
bader updated this revision to Diff 70366.
bader added a comment.

Applied code review comment from Anastasia.

Use getTypeSizeInChars instead of getTypeSize to get type size in bytes. Assume 
that char size is always one byte.


https://reviews.llvm.org/D23992

Files:
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CGOpenCLRuntime.cpp
  lib/CodeGen/CGOpenCLRuntime.h
  test/CodeGenOpenCL/pipe_builtin.cl
  test/CodeGenOpenCL/pipe_types.cl

Index: test/CodeGenOpenCL/pipe_types.cl
===
--- test/CodeGenOpenCL/pipe_types.cl
+++ test/CodeGenOpenCL/pipe_types.cl
@@ -41,7 +41,7 @@
  read_only pipe struct Person SPipe) {
 // CHECK: define void @test_reserved_read_pipe
   read_pipe (SPipe, SDst);
-  // CHECK: call i32 @__read_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}})
+  // CHECK: call i32 @__read_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}}, i32 16, i32 8)
   read_pipe (SPipe, SDst);
-  // CHECK: call i32 @__read_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}})
+  // CHECK: call i32 @__read_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}}, i32 16, i32 8)
 }
Index: test/CodeGenOpenCL/pipe_builtin.cl
===
--- test/CodeGenOpenCL/pipe_builtin.cl
+++ test/CodeGenOpenCL/pipe_builtin.cl
@@ -4,58 +4,58 @@
 // CHECK: %opencl.reserve_id_t = type opaque
 
 void test1(read_only pipe int p, global int *ptr) {
-  // CHECK: call i32 @__read_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}})
+  // CHECK: call i32 @__read_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}}, i32 4, i32 4)
   read_pipe(p, ptr);
-  // CHECK: call %opencl.reserve_id_t* @__reserve_read_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}})
+  // CHECK: call %opencl.reserve_id_t* @__reserve_read_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}, i32 4, i32 4)
   reserve_id_t rid = reserve_read_pipe(p, 2);
-  // CHECK: call i32 @__read_pipe_4(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 {{.*}}, i8* %{{.*}})
+  // CHECK: call i32 @__read_pipe_4(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 {{.*}}, i8* %{{.*}}, i32 4, i32 4)
   read_pipe(p, rid, 2, ptr);
-  // CHECK: call void @__commit_read_pipe(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}})
+  // CHECK: call void @__commit_read_pipe(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 4, i32 4)
   commit_read_pipe(p, rid);
 }
 
 void test2(write_only pipe int p, global int *ptr) {
-  // CHECK: call i32 @__write_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}})
+  // CHECK: call i32 @__write_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}}, i32 4, i32 4)
   write_pipe(p, ptr);
-  // CHECK: call %opencl.reserve_id_t* @__reserve_write_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}})
+  // CHECK: call %opencl.reserve_id_t* @__reserve_write_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}, i32 4, i32 4)
   reserve_id_t rid = reserve_write_pipe(p, 2);
-  // CHECK: call i32 @__write_pipe_4(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 {{.*}}, i8* %{{.*}})
+  // CHECK: call i32 @__write_pipe_4(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 {{.*}}, i8* %{{.*}}, i32 4, i32 4)
   write_pipe(p, rid, 2, ptr);
-  // CHECK: call void @__commit_write_pipe(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}})
+  // CHECK: call void @__commit_write_pipe(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 4, i32 4)
   commit_write_pipe(p, rid);
 }
 
 void test3(read_only pipe int p, global int *ptr) {
-  // CHECK: call %opencl.reserve_id_t* @__work_group_reserve_read_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}})
+  // CHECK: call %opencl.reserve_id_t* @__work_group_reserve_read_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}, i32 4, i32 4)
   reserve_id_t rid = work_group_reserve_read_pipe(p, 2);
-  // CHECK: call void @__work_group_commit_read_pipe(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}})
+  // CHECK: call void @__work_group_commit_read_pipe(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 4, i32 4)
   work_group_commit_read_pipe(p, rid);
 }
 
 void test4(write_only pipe int p, global int *ptr) {
-  // CHECK: call %opencl.reserve_id_t* @__work_group_reserve_write_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}})
+  // CHECK: call %opencl.reserve_id_t* @__work_group_reserve_write_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}, i32 4, i32 4)
   reserve_id_t rid = work_group_reserve_write_pipe(p, 2);
-  // CHECK: call void @__work_group_commit_write_pipe(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}})
+  // CHECK: call void @__work_group_commit_write_pipe(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 4, i32 4)
   work_group_commit_write_pipe(p, rid);
 }
 
 void test5(read_only pipe int p, global int *ptr) {
-  // CHECK: call %opencl.reserve_id_t* @__sub_group_reserve_read_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}})
+  // CHECK: call %opencl.reserve_id_t* @__sub_group_reserve_read_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}, i32 4, i32 4)
   

[PATCH] D24245: [ARM] ARM-specific attributes should be accepted for big-endian

2016-09-06 Thread Oliver Stannard via cfe-commits
olista01 created this revision.
olista01 added reviewers: rengolin, t.p.northover.
olista01 added a subscriber: cfe-commits.
olista01 set the repository for this revision to rL LLVM.
Herald added subscribers: samparker, rengolin, aemerson.

The ARM-specific C attributes (currently just interrupt) need to check
for both the big- and little-endian versions of the triples, so that
they are accepted for both big and little endian targets.

TargetWindows and TargetMicrosoftCXXABI also only use the little-endian
triples, but this is correct as windows is not supported on big-endian
ARM targets (and this is asserted in lib/Basic/Targets.cpp).

Repository:
  rL LLVM

https://reviews.llvm.org/D24245

Files:
  include/clang/Basic/Attr.td
  test/Sema/arm-interrupt-attr.c

Index: test/Sema/arm-interrupt-attr.c
===
--- test/Sema/arm-interrupt-attr.c
+++ test/Sema/arm-interrupt-attr.c
@@ -1,4 +1,7 @@
 // RUN: %clang_cc1 %s -triple arm-apple-darwin -verify -fsyntax-only
+// RUN: %clang_cc1 %s -triple thumb-apple-darwin -verify -fsyntax-only
+// RUN: %clang_cc1 %s -triple armeb-none-eabi -verify -fsyntax-only
+// RUN: %clang_cc1 %s -triple thumbeb-none-eabi -verify -fsyntax-only
 
 __attribute__((interrupt(IRQ))) void foo() {} // expected-error {{'interrupt' 
attribute requires a string}}
 __attribute__((interrupt("irq"))) void foo1() {} // expected-warning 
{{'interrupt' attribute argument not supported: irq}}
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -254,7 +254,7 @@
   list OSes;
   list CXXABIs;
 }
-def TargetARM : TargetArch<["arm", "thumb"]>;
+def TargetARM : TargetArch<["arm", "thumb", "armeb", "thumbeb"]>;
 def TargetMips : TargetArch<["mips", "mipsel"]>;
 def TargetMSP430 : TargetArch<["msp430"]>;
 def TargetX86 : TargetArch<["x86"]>;


Index: test/Sema/arm-interrupt-attr.c
===
--- test/Sema/arm-interrupt-attr.c
+++ test/Sema/arm-interrupt-attr.c
@@ -1,4 +1,7 @@
 // RUN: %clang_cc1 %s -triple arm-apple-darwin -verify -fsyntax-only
+// RUN: %clang_cc1 %s -triple thumb-apple-darwin -verify -fsyntax-only
+// RUN: %clang_cc1 %s -triple armeb-none-eabi -verify -fsyntax-only
+// RUN: %clang_cc1 %s -triple thumbeb-none-eabi -verify -fsyntax-only
 
 __attribute__((interrupt(IRQ))) void foo() {} // expected-error {{'interrupt' attribute requires a string}}
 __attribute__((interrupt("irq"))) void foo1() {} // expected-warning {{'interrupt' attribute argument not supported: irq}}
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -254,7 +254,7 @@
   list OSes;
   list CXXABIs;
 }
-def TargetARM : TargetArch<["arm", "thumb"]>;
+def TargetARM : TargetArch<["arm", "thumb", "armeb", "thumbeb"]>;
 def TargetMips : TargetArch<["mips", "mipsel"]>;
 def TargetMSP430 : TargetArch<["msp430"]>;
 def TargetX86 : TargetArch<["x86"]>;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24183: A clang tool for changing surrouding namespaces of class/function definitions.

2016-09-06 Thread Haojian Wu via cfe-commits
hokein added a comment.

some initial comments.



Comment at: change-namespace/CMakeLists.txt:9
@@ +8,3 @@
+  LINK_LIBS
+  clangAST
+  clangBasic

I think `clangASTMatchers` is needed here.


Comment at: change-namespace/ChangeNamespace.cpp:21
@@ +20,3 @@
+inline std::string formatNamespace(llvm::StringRef NS) {
+  (void)NS.ltrim(':');
+  return NS.str();

this statement doesn't do the intended thing (It won't change `NS`). The result 
returned by `ltrim` is what you want here, I think.


Comment at: change-namespace/ChangeNamespace.cpp:141
@@ +140,3 @@
+tooling::Replacement createReplacement(SourceLocation Start, SourceLocation 
End,
+   const std::string ,
+   const SourceManager ) {

StringRef?


Comment at: change-namespace/ChangeNamespace.cpp:214
@@ +213,3 @@
+ChangeNamespaceTool::ChangeNamespaceTool(
+const std::string , const std::string ,
+const std::string ,

Use `StringRef`.


Comment at: change-namespace/ChangeNamespace.cpp:480
@@ +479,3 @@
+Replaces = Replaces.merge(NewReplacements);
+format::FormatStyle Style = format::getStyle("file", FilePath, "google");
+// Clean up old namespaces if there is nothing in it after moving.

omtcyfz wrote:
> omtcyfz wrote:
> > By the way, shouldn't this one be "LLVM"?
> Alternatively, it might be nice to provide an option to specify desired 
> formatting style.
+1 on adding a `CodeStyle` command-line option.


Comment at: change-namespace/ChangeNamespace.h:67
@@ +66,3 @@
+
+  void FixUsingShadowDecl(const ast_matchers::MatchFinder::MatchResult ,
+  const UsingDecl *UsingDecl);

The first letter should be lower case.


Comment at: change-namespace/ChangeNamespace.h:70
@@ +69,3 @@
+
+  void ReplaceQualifiedSymbolInDeclContext(
+  const ast_matchers::MatchFinder::MatchResult ,

The same.


Comment at: change-namespace/tool/ClangChangeNamespace.cpp:95
@@ +94,3 @@
+
+  if (!formatAndApplyAllReplacements(Tool.getReplacements(), Rewrite)) {
+llvm::errs() << "Failed applying all replacements.\n";

Add a `CodeStyle` option?


Comment at: change-namespace/tool/ClangChangeNamespace.cpp:104
@@ +103,3 @@
+auto ID = Sources.translateFile(Entry);
+outs() << "== " << File << " ==\n";
+Rewrite.getEditBuffer(ID).write(llvm::outs());

Instead of printing results in a customized format, it makes more sense to 
print it in a JSON format, like:

```
[
   { "FilePath": "XXX"
 "SourceText": ""}
]
```


Comment at: test/change-namespace/simple-move.cpp:7
@@ +6,2 @@
+
+// RUN: clang-change-namespace -old_namespace "na::nb" -new_namespace "x::y" 
--file_pattern ".*" %s -- | sed 's,// CHECK.*,,' | FileCheck %s

Usually, we put the test scripts at top of the test file, and use `CHECK-NEXT` 
is more suitable in your case here?


Comment at: unittests/change-namespace/ChangeNamespaceTests.cpp:49
@@ +48,3 @@
+formatAndApplyAllReplacements(FileToReplacements, Context.Rewrite);
+return format(Context.getRewrittenText(ID));
+  }

Looks like `formatAndApplyAllReplacements` has already formatted the code, why 
do we need to format it again?


https://reviews.llvm.org/D24183



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


RE: r275095 - [NFC] Reorder fields of VersionTuple to reduce size

2016-09-06 Thread Vasileios Kalintiris via cfe-commits
Hi Erik, would you mind reverting this temporarily? It broke our recursive 
builds buildbot because the re-ordering of VersionTuple's bitfields generates 
an i128 which our MIPS backend erroneously accepts for the o32 ABI.

- V. Kalintiris


From: cfe-commits [cfe-commits-boun...@lists.llvm.org] on behalf of Erik 
Pilkington via cfe-commits [cfe-commits@lists.llvm.org]
Sent: 11 July 2016 21:00
To: cfe-commits@lists.llvm.org
Subject: r275095 - [NFC] Reorder fields of VersionTuple to reduce size

Author: epilk
Date: Mon Jul 11 15:00:48 2016
New Revision: 275095

URL: http://llvm.org/viewvc/llvm-project?rev=275095=rev
Log:
[NFC] Reorder fields of VersionTuple to reduce size

Differential revision: http://reviews.llvm.org/D19934

Modified:
cfe/trunk/include/clang/Basic/VersionTuple.h

Modified: cfe/trunk/include/clang/Basic/VersionTuple.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/VersionTuple.h?rev=275095=275094=275095=diff
==
--- cfe/trunk/include/clang/Basic/VersionTuple.h (original)
+++ cfe/trunk/include/clang/Basic/VersionTuple.h Mon Jul 11 15:00:48 2016
@@ -25,39 +25,44 @@ namespace clang {
 /// \brief Represents a version number in the form 
major[.minor[.subminor[.build]]].
 class VersionTuple {
   unsigned Major : 31;
+
+  unsigned UsesUnderscores : 1;
+
   unsigned Minor : 31;
-  unsigned Subminor : 31;
-  unsigned Build : 31;
   unsigned HasMinor : 1;
+
+  unsigned Subminor : 31;
   unsigned HasSubminor : 1;
+
+  unsigned Build : 31;
   unsigned HasBuild : 1;
-  unsigned UsesUnderscores : 1;

 public:
   VersionTuple()
-  : Major(0), Minor(0), Subminor(0), Build(0), HasMinor(false),
-HasSubminor(false), HasBuild(false), UsesUnderscores(false) {}
+  : Major(0), UsesUnderscores(false), Minor(0), HasMinor(false),
+Subminor(0), HasSubminor(false), Build(0), HasBuild(false) {}

   explicit VersionTuple(unsigned Major)
-  : Major(Major), Minor(0), Subminor(0), Build(0), HasMinor(false),
-HasSubminor(false), HasBuild(false), UsesUnderscores(false) {}
+  : Major(Major), UsesUnderscores(false), Minor(0), HasMinor(false),
+Subminor(0), HasSubminor(false), Build(0), HasBuild(false) {}

   explicit VersionTuple(unsigned Major, unsigned Minor,
 bool UsesUnderscores = false)
-  : Major(Major), Minor(Minor), Subminor(0), Build(0), HasMinor(true),
-HasSubminor(false), HasBuild(false), UsesUnderscores(UsesUnderscores) 
{}
+  : Major(Major), UsesUnderscores(UsesUnderscores), Minor(Minor),
+HasMinor(true), Subminor(0), HasSubminor(false), Build(0),
+HasBuild(false) {}

   explicit VersionTuple(unsigned Major, unsigned Minor, unsigned Subminor,
 bool UsesUnderscores = false)
-  : Major(Major), Minor(Minor), Subminor(Subminor), Build(0),
-HasMinor(true), HasSubminor(true), HasBuild(false),
-UsesUnderscores(UsesUnderscores) {}
+  : Major(Major), UsesUnderscores(UsesUnderscores), Minor(Minor),
+HasMinor(true), Subminor(Subminor), HasSubminor(true), Build(0),
+HasBuild(false) {}

   explicit VersionTuple(unsigned Major, unsigned Minor, unsigned Subminor,
 unsigned Build, bool UsesUnderscores = false)
-  : Major(Major), Minor(Minor), Subminor(Subminor), Build(Build),
-HasMinor(true), HasSubminor(true), HasBuild(true),
-UsesUnderscores(UsesUnderscores) {}
+  : Major(Major), UsesUnderscores(UsesUnderscores), Minor(Minor),
+HasMinor(true), Subminor(Subminor), HasSubminor(true), Build(Build),
+HasBuild(true) {}

   /// \brief Determine whether this version information is empty
   /// (e.g., all version components are zero).


___
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] D24243: [clang-move] A prototype tool for moving class definition to new file.

2016-09-06 Thread Kirill Bobyrev via cfe-commits
omtcyfz added inline comments.


Comment at: clang-move/ClangMove.h:25
@@ +24,3 @@
+
+// TODO(hokein): Make it support more types, e.g. function definitions.
+// Currently only support moving class definition.

`FIXME`?


https://reviews.llvm.org/D24243



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


Re: [PATCH] D24243: [clang-move] A prototype tool for moving class definition to new file.

2016-09-06 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 70363.
hokein added a comment.

Fix function name style.


https://reviews.llvm.org/D24243

Files:
  CMakeLists.txt
  clang-move/CMakeLists.txt
  clang-move/ClangMove.cpp
  clang-move/ClangMove.h
  clang-move/tool/CMakeLists.txt
  clang-move/tool/ClangMoveMain.cpp
  unittests/CMakeLists.txt
  unittests/clang-move/CMakeLists.txt
  unittests/clang-move/ClangMoveTests.cpp

Index: unittests/clang-move/ClangMoveTests.cpp
===
--- /dev/null
+++ unittests/clang-move/ClangMoveTests.cpp
@@ -0,0 +1,198 @@
+//===-- ClangMoveTest.cpp - clang-move unit tests -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "ClangMove.h"
+#include "unittests/Tooling/RewriterTestContext.h"
+#include "clang/Format/Format.h"
+#include "clang/Frontend/FrontendActions.h"
+#include "clang/Frontend/TextDiagnosticPrinter.h"
+#include "clang/Rewrite/Core/Rewriter.h"
+#include "clang/Tooling/Refactoring.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/StringRef.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+
+namespace clang {
+namespace move {
+namespace {
+
+const char TestHeaderName[] = "foo.h";
+
+const char TestCCName[] = "foo.cc";
+
+const char TestHeader[] = "namespace a {\n"
+  "class C1;\n"
+  "namespace b {\n"
+  "class Foo {\n"
+  "public:\n"
+  "  void f();\n"
+  "\n"
+  "private:\n"
+  "  C1 *c1;\n"
+  "};\n"
+  "\n"
+  "class Foo2 {\n"
+  "public:\n"
+  "  int f();\n"
+  "};\n"
+  "} // namespace b\n"
+  "} // namespace a\n";
+
+const char TestCC[] = "#include \"foo.h\"\n"
+  "namespace a {\n"
+  "namespace b {\n"
+  "namespace {\n"
+  "void f1() {}\n"
+  "} // namespace\n"
+  "void Foo::f() { f1(); }\n"
+  "int Foo2::f() {\n"
+  "  f1();\n"
+  "  return 1;\n"
+  "}\n"
+  "} // namespace b\n"
+  "} // namespace a\n";
+
+const char ExpectedTestHeader[] = "namespace a {\n"
+  "class C1;\n"
+  "namespace b {\n"
+  "\n"
+  "class Foo2 {\n"
+  "public:\n"
+  "  int f();\n"
+  "};\n"
+  "} // namespace b\n"
+  "} // namespace a\n";
+
+const char ExpectedTestCC[] = "#include \"foo.h\"\n"
+  "namespace a {\n"
+  "namespace b {\n"
+  "namespace {\n"
+  "void f1() {}\n"
+  "} // namespace\n"
+  "\n"
+  "int Foo2::f() {\n"
+  "  f1();\n"
+  "  return 1;\n"
+  "}\n"
+  "} // namespace b\n"
+  "} // namespace a\n";
+
+const char ExpectedNewHeader[] = "namespace a {\n"
+ "class C1;\n"
+ "namespace b {\n"
+ "class Foo {\n"
+ "public:\n"
+ "  void f();\n"
+ "\n"
+ "private:\n"
+ "  C1 *c1;\n"
+ "};\n"
+ "} // namespace b\n"
+ "} // namespace a\n";
+
+const char ExpectedNewCC[] = "#include \"foo.h\"\n"
+ "namespace a {\n"
+ "namespace b {\n"
+ "namespace {\n"
+ "void f1() {}\n"
+ "} // namespace\n"
+ "void Foo::f() { f1(); }\n"
+ "} // namespace b\n"
+ "} // namespace a\n";
+
+std::map
+runClangMoveOnCode(const move::ClangMoveTool::MoveDefinitionSpec ) {
+  

Re: [PATCH] D24243: [clang-move] A prototype tool for moving class definition to new file.

2016-09-06 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 70362.
hokein added a comment.

Minor cleanup.


https://reviews.llvm.org/D24243

Files:
  CMakeLists.txt
  clang-move/CMakeLists.txt
  clang-move/ClangMove.cpp
  clang-move/ClangMove.h
  clang-move/tool/CMakeLists.txt
  clang-move/tool/ClangMoveMain.cpp
  unittests/CMakeLists.txt
  unittests/clang-move/CMakeLists.txt
  unittests/clang-move/ClangMoveTests.cpp

Index: unittests/clang-move/ClangMoveTests.cpp
===
--- /dev/null
+++ unittests/clang-move/ClangMoveTests.cpp
@@ -0,0 +1,198 @@
+//===-- ClangMoveTest.cpp - clang-move unit tests -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "ClangMove.h"
+#include "unittests/Tooling/RewriterTestContext.h"
+#include "clang/Format/Format.h"
+#include "clang/Frontend/FrontendActions.h"
+#include "clang/Frontend/TextDiagnosticPrinter.h"
+#include "clang/Rewrite/Core/Rewriter.h"
+#include "clang/Tooling/Refactoring.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/StringRef.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+
+namespace clang {
+namespace move {
+namespace {
+
+const char TestHeaderName[] = "foo.h";
+
+const char TestCCName[] = "foo.cc";
+
+const char TestHeader[] = "namespace a {\n"
+  "class C1;\n"
+  "namespace b {\n"
+  "class Foo {\n"
+  "public:\n"
+  "  void f();\n"
+  "\n"
+  "private:\n"
+  "  C1 *c1;\n"
+  "};\n"
+  "\n"
+  "class Foo2 {\n"
+  "public:\n"
+  "  int f();\n"
+  "};\n"
+  "} // namespace b\n"
+  "} // namespace a\n";
+
+const char TestCC[] = "#include \"foo.h\"\n"
+  "namespace a {\n"
+  "namespace b {\n"
+  "namespace {\n"
+  "void f1() {}\n"
+  "} // namespace\n"
+  "void Foo::f() { f1(); }\n"
+  "int Foo2::f() {\n"
+  "  f1();\n"
+  "  return 1;\n"
+  "}\n"
+  "} // namespace b\n"
+  "} // namespace a\n";
+
+const char ExpectedTestHeader[] = "namespace a {\n"
+  "class C1;\n"
+  "namespace b {\n"
+  "\n"
+  "class Foo2 {\n"
+  "public:\n"
+  "  int f();\n"
+  "};\n"
+  "} // namespace b\n"
+  "} // namespace a\n";
+
+const char ExpectedTestCC[] = "#include \"foo.h\"\n"
+  "namespace a {\n"
+  "namespace b {\n"
+  "namespace {\n"
+  "void f1() {}\n"
+  "} // namespace\n"
+  "\n"
+  "int Foo2::f() {\n"
+  "  f1();\n"
+  "  return 1;\n"
+  "}\n"
+  "} // namespace b\n"
+  "} // namespace a\n";
+
+const char ExpectedNewHeader[] = "namespace a {\n"
+ "class C1;\n"
+ "namespace b {\n"
+ "class Foo {\n"
+ "public:\n"
+ "  void f();\n"
+ "\n"
+ "private:\n"
+ "  C1 *c1;\n"
+ "};\n"
+ "} // namespace b\n"
+ "} // namespace a\n";
+
+const char ExpectedNewCC[] = "#include \"foo.h\"\n"
+ "namespace a {\n"
+ "namespace b {\n"
+ "namespace {\n"
+ "void f1() {}\n"
+ "} // namespace\n"
+ "void Foo::f() { f1(); }\n"
+ "} // namespace b\n"
+ "} // namespace a\n";
+
+std::map
+runClangMoveOnCode(const move::ClangMoveTool::MoveDefinitionSpec ) {
+  

[PATCH] D24243: [clang-move] A prototype tool for moving class definition to new file.

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

This patch introduces a new tool which moves a specific class definition
from files (.h, .cc) to new files (.h, .cc), which mostly acts like
"Extract class defintion". In the long term, this tool should be
merged in to clang-refactoring as a subtool.

clang-move not only moves class definition, but also moves all the
forward declarations, functions defined in anonymous namespace and #include
headers to new files, to make sure the new files are compliable as much
as possible.

To move `Foo` from old.[h/cc] to new.[h/cc], use:

```
clang-move -name=Foo -old_header=old.h -old_cc=old.cc -new_header=new.h
-new_cc=new.cc old.cc
```

To move `Foo` from old.h to new.h, use:

```
clang-move -name=Foo -old_header=old.h -new_header=new.h old.cc
```

https://reviews.llvm.org/D24243

Files:
  CMakeLists.txt
  clang-move/CMakeLists.txt
  clang-move/ClangMove.cpp
  clang-move/ClangMove.h
  clang-move/tool/CMakeLists.txt
  clang-move/tool/ClangMoveMain.cpp
  unittests/CMakeLists.txt
  unittests/clang-move/CMakeLists.txt
  unittests/clang-move/ClangMoveTests.cpp

Index: unittests/clang-move/ClangMoveTests.cpp
===
--- /dev/null
+++ unittests/clang-move/ClangMoveTests.cpp
@@ -0,0 +1,198 @@
+//===-- ClangMoveTest.cpp - clang-move unit tests -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "ClangMove.h"
+#include "unittests/Tooling/RewriterTestContext.h"
+#include "clang/Format/Format.h"
+#include "clang/Frontend/FrontendActions.h"
+#include "clang/Frontend/TextDiagnosticPrinter.h"
+#include "clang/Rewrite/Core/Rewriter.h"
+#include "clang/Tooling/Refactoring.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/StringRef.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+
+namespace clang {
+namespace move {
+namespace {
+
+const char TestHeaderName[] = "foo.h";
+
+const char TestCCName[] = "foo.cc";
+
+const char TestHeader[] = "namespace a {\n"
+  "class C1;\n"
+  "namespace b {\n"
+  "class Foo {\n"
+  "public:\n"
+  "  void f();\n"
+  "\n"
+  "private:\n"
+  "  C1 *c1;\n"
+  "};\n"
+  "\n"
+  "class Foo2 {\n"
+  "public:\n"
+  "  int f();\n"
+  "};\n"
+  "} // namespace b\n"
+  "} // namespace a\n";
+
+const char TestCC[] = "#include \"foo.h\"\n"
+  "namespace a {\n"
+  "namespace b {\n"
+  "namespace {\n"
+  "void f1() {}\n"
+  "} // namespace\n"
+  "void Foo::f() { f1(); }\n"
+  "int Foo2::f() {\n"
+  "  f1();\n"
+  "  return 1;\n"
+  "}\n"
+  "} // namespace b\n"
+  "} // namespace a\n";
+
+const char ExpectedTestHeader[] = "namespace a {\n"
+  "class C1;\n"
+  "namespace b {\n"
+  "\n"
+  "class Foo2 {\n"
+  "public:\n"
+  "  int f();\n"
+  "};\n"
+  "} // namespace b\n"
+  "} // namespace a\n";
+
+const char ExpectedTestCC[] = "#include \"foo.h\"\n"
+  "namespace a {\n"
+  "namespace b {\n"
+  "namespace {\n"
+  "void f1() {}\n"
+  "} // namespace\n"
+  "\n"
+  "int Foo2::f() {\n"
+  "  f1();\n"
+  "  return 1;\n"
+  "}\n"
+  "} // namespace b\n"
+  "} // namespace a\n";
+
+const char ExpectedNewHeader[] = "namespace a {\n"
+ "class C1;\n"
+ "namespace b {\n"
+ "class Foo {\n"
+ "public:\n"
+ "  void f();\n"
+ "\n"
+ "private:\n"
+ "  C1 *c1;\n"
+ 

Re: [PATCH] D23926: [libcxx] Don't use C99 math ops in -std=c++03 mode

2016-09-06 Thread Asiri Rathnayake via cfe-commits
Hi @EricWD, @mclow.lists,

Thanks for the comments.

I will discuss this downstream a bit and get back. What I don't want to do
is deviate too much from upstream in terms of expectations. We may have to
shed some of our old expectations with libc++, I wanted to first clarify
upstream position on this.

Would be good to get these points documented though. I will do a docs patch
once i have discussed this internally.

Cheers,

/ Asiri

PS: @mclow.lists: Ping on the thread api patch... ;)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits