Re: [PATCH] D13280: [OpenCL] Adding reserved operator logical xor for OpenCL

2016-01-08 Thread Xiuli PAN via cfe-commits
pxli168 added a subscriber: pxli168.
pxli168 accepted this revision.
pxli168 added a reviewer: pxli168.
pxli168 added a comment.

LGTM!


http://reviews.llvm.org/D13280



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


r257159 - clang-format: [JS] Add some Closure Compiler JSDoc tags to the default

2016-01-08 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Fri Jan  8 02:14:58 2016
New Revision: 257159

URL: http://llvm.org/viewvc/llvm-project?rev=257159=rev
Log:
clang-format: [JS] Add some Closure Compiler JSDoc tags to the default
Google configuration so that they aren't line-wrapped.

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

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=257159=257158=257159=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Fri Jan  8 02:14:58 2016
@@ -583,6 +583,7 @@ FormatStyle getGoogleStyle(FormatStyle::
 GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline;
 GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
 GoogleStyle.BreakBeforeTernaryOperators = false;
+GoogleStyle.CommentPragmas = "@(export|visibility) {";
 GoogleStyle.MaxEmptyLinesToKeep = 3;
 GoogleStyle.SpacesInContainerLiterals = false;
   } else if (Language == FormatStyle::LK_Proto) {

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=257159=257158=257159=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Fri Jan  8 02:14:58 2016
@@ -1030,5 +1030,15 @@ TEST_F(FormatTestJS, WrapAfterParen) {
"   bb) {\n}");
 }
 
+TEST_F(FormatTestJS, JSDocAnnotations) {
+  EXPECT_EQ("/**\n"
+" * @export {this.is.a.long.path.to.a.Type}\n"
+" */",
+format("/**\n"
+   " * @export {this.is.a.long.path.to.a.Type}\n"
+   " */",
+   getGoogleJSStyleWithColumns(20)));
+}
+
 } // end namespace tooling
 } // end namespace clang


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


Fwd: r256287 - Document that we recommend to turn off -gmodules when building a static

2016-01-08 Thread David Blaikie via cfe-commits
(oops, forgot to reply-all)

-- Forwarded message --
From: David Blaikie 
Date: Fri, Jan 8, 2016 at 10:51 AM
Subject: Re: r256287 - Document that we recommend to turn off -gmodules
when building a static
To: Adrian Prantl 




On Fri, Jan 8, 2016 at 8:34 AM, Adrian Prantl  wrote:

>
> On Jan 7, 2016, at 6:54 PM, David Blaikie  wrote:
>
> Presumably this only applies when using implicit modules builds, not when
> using explicit modules builds. (though I'm not sure what the current
> behavior of -gmodules is with explicit modules, maybe it's
> untested/broken/etc anyway)
>
>
> Why would explicit modules be any different? Unless you distribute the
> modules together with the static library (and ensure they end up in the
> same location on the other machine) you would still run into the problem,
> wouldn’t you?
>

Right - though it'd be a bit more obvious/easy (I would imagine/assume) to
find and move that build product too, since it'd be in your build tree
rather than an OS-wide cache somewhere else.


>
> -- adrian
>
>
> On Tue, Dec 22, 2015 at 2:37 PM, Adrian Prantl via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: adrian
>> Date: Tue Dec 22 16:37:22 2015
>> New Revision: 256287
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=256287=rev
>> Log:
>> Document that we recommend to turn off -gmodules when building a static
>> library for distribution to other machines on the clang man page.
>>
>> Modified:
>> cfe/trunk/docs/CommandGuide/clang.rst
>>
>> Modified: cfe/trunk/docs/CommandGuide/clang.rst
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/CommandGuide/clang.rst?rev=256287=256286=256287=diff
>>
>> ==
>> --- cfe/trunk/docs/CommandGuide/clang.rst (original)
>> +++ cfe/trunk/docs/CommandGuide/clang.rst Tue Dec 22 16:37:22 2015
>> @@ -262,7 +262,12 @@ Code Generation Options
>>Generate debug information that contains external references to
>>types defined in clang modules or precompiled headers instead of
>>emitting redundant debug type information into every object file.
>> -  This option implies `-fmodule-format=obj`.
>> +  This option implies :option:`-fmodule-format=obj`.
>> +
>> +  This option should not be used when building static libraries for
>> +  distribution to other machines because the debug info will contain
>> +  references to the module cache on the machine the object files in
>> +  the library were built on.
>>
>>  .. option:: -fstandalone-debug -fno-standalone-debug
>>
>>
>>
>> ___
>> 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] D15911: Move ownership of Action objects into Compilation.

2016-01-08 Thread David Blaikie via cfe-commits
On Fri, Jan 8, 2016 at 10:55 AM, David Blaikie  wrote:

>
>
> On Fri, Jan 8, 2016 at 10:08 AM, Artem Belevich via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> tra added inline comments.
>>
>> 
>> Comment at: include/clang/Driver/Action.h:36
>> @@ -35,1 +35,3 @@
>> +///
>> +/// Actions are usually owned by a Compilation.
>>  class Action {
>> 
>> There's no API to pass ownership to Compilation explicitly, so the only
>> way for an Action to be owned by Compilation is to create it with
>> MakeAction.
>>
>> Perhaps "Actions created with MakeAction<>() are owned by Compilation"
>>
>> BTW, should we (can we?) make MakeAction<>() the only way to create
>> actions?
>>
>
> I suspect not - from an API design perspective it might be nice to be able
> to test Actions in isolation without the Compilation (I assume this isn't
> being done, because we don't unit test all that much - and I don't know the
> APIs well enough to know if such testing makes sense (maybe Action and
> Compilation are too tied together to do that separation anyway))
>

(but if we wanted to, we could, by making each Action subclass's ctor
private and friending Compilation from them - might be a bit repetitious
though)


>
>
>>
>>
>> http://reviews.llvm.org/D15911
>>
>>
>>
>> ___
>> 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] D15936: Update code in buildCudaActions and BuildActions to latest idiom.

2016-01-08 Thread Justin Lebar via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL257190: Update code in buildCudaActions and BuildActions to 
latest idiom. (authored by jlebar).

Changed prior to commit:
  http://reviews.llvm.org/D15936?vs=44158=44341#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15936

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

Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -1298,11 +1298,11 @@
   SmallVector GpuArchList;
   llvm::StringSet<> GpuArchNames;
   for (Arg *A : Args) {
-if (A->getOption().matches(options::OPT_cuda_gpu_arch_EQ)) {
-  A->claim();
-  if (GpuArchNames.insert(A->getValue()).second)
-GpuArchList.push_back(A->getValue());
-}
+if (!A->getOption().matches(options::OPT_cuda_gpu_arch_EQ))
+  continue;
+A->claim();
+if (GpuArchNames.insert(A->getValue()).second)
+  GpuArchList.push_back(A->getValue());
   }
 
   // Default to sm_20 which is the lowest common denominator for supported 
GPUs.
@@ -1325,13 +1325,10 @@
  "Failed to create actions for all devices");
 
   // Check whether any of device actions stopped before they could generate 
PTX.
-  bool PartialCompilation = false;
-  for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I) {
-if (CudaDeviceActions[I]->getKind() != Action::BackendJobClass) {
-  PartialCompilation = true;
-  break;
-}
-  }
+  bool PartialCompilation =
+  llvm::any_of(CudaDeviceActions, [](const Action *a) {
+return a->getKind() != Action::BackendJobClass;
+  });
 
   // Figure out what to do with device actions -- pass them as inputs to the
   // host action or run each of them independently.
@@ -1470,12 +1467,11 @@
   continue;
 }
 
-phases::ID CudaInjectionPhase = FinalPhase;
-for (const auto  : PL)
-  if (Phase <= FinalPhase && Phase == phases::Compile) {
-CudaInjectionPhase = Phase;
-break;
-  }
+phases::ID CudaInjectionPhase =
+(phases::Compile < FinalPhase &&
+ llvm::find(PL, phases::Compile) != PL.end())
+? phases::Compile
+: FinalPhase;
 
 // Build the pipeline for this file.
 std::unique_ptr Current(new InputAction(*InputArg, InputType));


Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -1298,11 +1298,11 @@
   SmallVector GpuArchList;
   llvm::StringSet<> GpuArchNames;
   for (Arg *A : Args) {
-if (A->getOption().matches(options::OPT_cuda_gpu_arch_EQ)) {
-  A->claim();
-  if (GpuArchNames.insert(A->getValue()).second)
-GpuArchList.push_back(A->getValue());
-}
+if (!A->getOption().matches(options::OPT_cuda_gpu_arch_EQ))
+  continue;
+A->claim();
+if (GpuArchNames.insert(A->getValue()).second)
+  GpuArchList.push_back(A->getValue());
   }
 
   // Default to sm_20 which is the lowest common denominator for supported GPUs.
@@ -1325,13 +1325,10 @@
  "Failed to create actions for all devices");
 
   // Check whether any of device actions stopped before they could generate PTX.
-  bool PartialCompilation = false;
-  for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I) {
-if (CudaDeviceActions[I]->getKind() != Action::BackendJobClass) {
-  PartialCompilation = true;
-  break;
-}
-  }
+  bool PartialCompilation =
+  llvm::any_of(CudaDeviceActions, [](const Action *a) {
+return a->getKind() != Action::BackendJobClass;
+  });
 
   // Figure out what to do with device actions -- pass them as inputs to the
   // host action or run each of them independently.
@@ -1470,12 +1467,11 @@
   continue;
 }
 
-phases::ID CudaInjectionPhase = FinalPhase;
-for (const auto  : PL)
-  if (Phase <= FinalPhase && Phase == phases::Compile) {
-CudaInjectionPhase = Phase;
-break;
-  }
+phases::ID CudaInjectionPhase =
+(phases::Compile < FinalPhase &&
+ llvm::find(PL, phases::Compile) != PL.end())
+? phases::Compile
+: FinalPhase;
 
 // Build the pipeline for this file.
 std::unique_ptr Current(new InputAction(*InputArg, InputType));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r255177 - Remove visibility attributes from out-of-class method definitions in iostreams.

2016-01-08 Thread Evgenii Stepanov via cfe-commits
Reverted in r257193.

On Fri, Jan 8, 2016 at 11:12 AM, Evgenii Stepanov
 wrote:
> On Fri, Jan 8, 2016 at 11:02 AM, Duncan P. N. Exon Smith
>  wrote:
>>
>>> On 2016-Jan-08, at 10:49, Nico Weber via cfe-commits 
>>>  wrote:
>>>
>>> On OS X 10.8, __ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5sputcEc 
>>> (and others) are a hidden symbol in libc++.1.dylib. This means:
>>>
>>> * If I use streambuf::sputc() and link against the 10.8 SDK, and the 
>>> compiler decides to not inline the call, I will get linker errors.
>>> * If I do the same with the 10.10 SDK when targeting 10.8, then (even 
>>> worse) the link will silently succeed (since it links against the 10.10 
>>> libc++ which does have a public symbol for this -- the SDK assumes that 
>>> libc++ is abi-compatible with itself) but it will then fail to run on a 
>>> 10.8 system.
>>>
>>> I don't see a way to save this change -- I think this needs to be reverted.
>>
>> FWIW, we're working on a plan to add availability markup to libc++
>> (it shouldn't be too intrusive (since you can annotate blocks of
>> API); had some initial talks with Marshall at the dev meeting).  I
>> plan to send out an RFC soon.
>>
>> I didn't think there'd be interest in having the availability
>> attributes themselves in open source (just some placeholder macros),
>> but it would be an option.
>>
>> Anyway, until that's done, I agree this needs to be reverted.
>>
>>> Have you made similar changes elsewhere? These probably need to be reverted 
>>> too.
>>
>> I agree.
>
> This is the only one of my changes that removes attributes. I'll revert.
>
>>> On Wed, Dec 9, 2015 at 6:42 PM, Evgeniy Stepanov via cfe-commits 
>>>  wrote:
>>> Author: eugenis
>>> Date: Wed Dec  9 17:42:30 2015
>>> New Revision: 255177
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=255177=rev
>>> Log:
>>> Remove visibility attributes from out-of-class method definitions in 
>>> iostreams.
>>>
>>> No point in pretending that these methods are hidden - they are
>>> actually exported from libc++.so. Extern template declarations make
>>> them part of libc++ ABI.
>>>
>>> This patch does not change libc++.so export list (at least on Linux).
>>>
>>> Modified:
>>> libcxx/trunk/include/istream
>>> libcxx/trunk/include/ostream
>>> libcxx/trunk/include/sstream
>>> libcxx/trunk/include/streambuf
>>>
>>> Modified: libcxx/trunk/include/istream
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/istream?rev=255177=255176=255177=diff
>>> ==
>>> --- libcxx/trunk/include/istream (original)
>>> +++ libcxx/trunk/include/istream Wed Dec  9 17:42:30 2015
>>> @@ -304,7 +304,7 @@ basic_istream<_CharT, _Traits>::sentry::
>>>  }
>>>
>>>  template 
>>> -inline _LIBCPP_INLINE_VISIBILITY
>>> +inline
>>>  basic_istream<_CharT, _Traits>::basic_istream(basic_streambuf>> traits_type>* __sb)
>>>  : __gc_(0)
>>>  {
>>> @@ -314,7 +314,7 @@ basic_istream<_CharT, _Traits>::basic_is
>>>  #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
>>>
>>>  template 
>>> -inline _LIBCPP_INLINE_VISIBILITY
>>> +inline
>>>  basic_istream<_CharT, _Traits>::basic_istream(basic_istream&& __rhs)
>>>  : __gc_(__rhs.__gc_)
>>>  {
>>> @@ -323,7 +323,7 @@ basic_istream<_CharT, _Traits>::basic_is
>>>  }
>>>
>>>  template 
>>> -inline _LIBCPP_INLINE_VISIBILITY
>>> +inline
>>>  basic_istream<_CharT, _Traits>&
>>>  basic_istream<_CharT, _Traits>::operator=(basic_istream&& __rhs)
>>>  {
>>> @@ -339,7 +339,7 @@ basic_istream<_CharT, _Traits>::~basic_i
>>>  }
>>>
>>>  template 
>>> -inline _LIBCPP_INLINE_VISIBILITY
>>> +inline
>>>  void
>>>  basic_istream<_CharT, _Traits>::swap(basic_istream& __rhs)
>>>  {
>>> @@ -725,7 +725,7 @@ basic_istream<_CharT, _Traits>::operator
>>>  }
>>>
>>>  template 
>>> -inline _LIBCPP_INLINE_VISIBILITY
>>> +inline
>>>  basic_istream<_CharT, _Traits>&
>>>  basic_istream<_CharT, _Traits>::operator>>(basic_istream& 
>>> (*__pf)(basic_istream&))
>>>  {
>>> @@ -733,7 +733,7 @@ basic_istream<_CharT, _Traits>::operator
>>>  }
>>>
>>>  template 
>>> -inline _LIBCPP_INLINE_VISIBILITY
>>> +inline
>>>  basic_istream<_CharT, _Traits>&
>>>  basic_istream<_CharT, _Traits>::operator>>(basic_ios>> traits_type>&
>>> (*__pf)(basic_ios>> traits_type>&))
>>> @@ -743,7 +743,7 @@ basic_istream<_CharT, _Traits>::operator
>>>  }
>>>
>>>  template 
>>> -inline _LIBCPP_INLINE_VISIBILITY
>>> +inline
>>>  basic_istream<_CharT, _Traits>&
>>>  basic_istream<_CharT, _Traits>::operator>>(ios_base& (*__pf)(ios_base&))
>>>  {
>>> @@ -800,7 +800,7 @@ operator>>(basic_istream<_CharT, _Traits
>>>  }
>>>
>>>  template
>>> -inline _LIBCPP_INLINE_VISIBILITY
>>> +inline
>>>  basic_istream&
>>>  operator>>(basic_istream& __is, unsigned char* __s)
>>>  {
>>> @@ 

Re: [PATCH] D15911: Move ownership of Action objects into Compilation.

2016-01-08 Thread David Blaikie via cfe-commits
On Fri, Jan 8, 2016 at 10:08 AM, Artem Belevich via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> tra added inline comments.
>
> 
> Comment at: include/clang/Driver/Action.h:36
> @@ -35,1 +35,3 @@
> +///
> +/// Actions are usually owned by a Compilation.
>  class Action {
> 
> There's no API to pass ownership to Compilation explicitly, so the only
> way for an Action to be owned by Compilation is to create it with
> MakeAction.
>
> Perhaps "Actions created with MakeAction<>() are owned by Compilation"
>
> BTW, should we (can we?) make MakeAction<>() the only way to create
> actions?
>

I suspect not - from an API design perspective it might be nice to be able
to test Actions in isolation without the Compilation (I assume this isn't
being done, because we don't unit test all that much - and I don't know the
APIs well enough to know if such testing makes sense (maybe Action and
Compilation are too tied together to do that separation anyway))


>
>
> http://reviews.llvm.org/D15911
>
>
>
> ___
> 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] D15911: Move ownership of Action objects into Compilation.

2016-01-08 Thread Artem Belevich via cfe-commits
tra added inline comments.


Comment at: include/clang/Driver/Action.h:36
@@ -35,1 +35,3 @@
+///
+/// Actions are usually owned by a Compilation.
 class Action {

There's no API to pass ownership to Compilation explicitly, so the only way for 
an Action to be owned by Compilation is to create it with MakeAction. 

Perhaps "Actions created with MakeAction<>() are owned by Compilation"

BTW, should we (can we?) make MakeAction<>() the only way to create actions?


http://reviews.llvm.org/D15911



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


Re: [libcxx] r255177 - Remove visibility attributes from out-of-class method definitions in iostreams.

2016-01-08 Thread Nico Weber via cfe-commits
On OS X 10.8, __ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5sputcEc
(and others) are a hidden symbol in libc++.1.dylib. This means:

* If I use streambuf::sputc() and link against the 10.8 SDK, and the
compiler decides to not inline the call, I will get linker errors.
* If I do the same with the 10.10 SDK when targeting 10.8, then (even
worse) the link will silently succeed (since it links against the 10.10
libc++ which does have a public symbol for this -- the SDK assumes that
libc++ is abi-compatible with itself) but it will then fail to run on a
10.8 system.

I don't see a way to save this change -- I think this needs to be reverted.

Have you made similar changes elsewhere? These probably need to be reverted
too.

On Wed, Dec 9, 2015 at 6:42 PM, Evgeniy Stepanov via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: eugenis
> Date: Wed Dec  9 17:42:30 2015
> New Revision: 255177
>
> URL: http://llvm.org/viewvc/llvm-project?rev=255177=rev
> Log:
> Remove visibility attributes from out-of-class method definitions in
> iostreams.
>
> No point in pretending that these methods are hidden - they are
> actually exported from libc++.so. Extern template declarations make
> them part of libc++ ABI.
>
> This patch does not change libc++.so export list (at least on Linux).
>
> Modified:
> libcxx/trunk/include/istream
> libcxx/trunk/include/ostream
> libcxx/trunk/include/sstream
> libcxx/trunk/include/streambuf
>
> Modified: libcxx/trunk/include/istream
> URL:
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/istream?rev=255177=255176=255177=diff
>
> ==
> --- libcxx/trunk/include/istream (original)
> +++ libcxx/trunk/include/istream Wed Dec  9 17:42:30 2015
> @@ -304,7 +304,7 @@ basic_istream<_CharT, _Traits>::sentry::
>  }
>
>  template 
> -inline _LIBCPP_INLINE_VISIBILITY
> +inline
>  basic_istream<_CharT, _Traits>::basic_istream(basic_streambuf traits_type>* __sb)
>  : __gc_(0)
>  {
> @@ -314,7 +314,7 @@ basic_istream<_CharT, _Traits>::basic_is
>  #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
>
>  template 
> -inline _LIBCPP_INLINE_VISIBILITY
> +inline
>  basic_istream<_CharT, _Traits>::basic_istream(basic_istream&& __rhs)
>  : __gc_(__rhs.__gc_)
>  {
> @@ -323,7 +323,7 @@ basic_istream<_CharT, _Traits>::basic_is
>  }
>
>  template 
> -inline _LIBCPP_INLINE_VISIBILITY
> +inline
>  basic_istream<_CharT, _Traits>&
>  basic_istream<_CharT, _Traits>::operator=(basic_istream&& __rhs)
>  {
> @@ -339,7 +339,7 @@ basic_istream<_CharT, _Traits>::~basic_i
>  }
>
>  template 
> -inline _LIBCPP_INLINE_VISIBILITY
> +inline
>  void
>  basic_istream<_CharT, _Traits>::swap(basic_istream& __rhs)
>  {
> @@ -725,7 +725,7 @@ basic_istream<_CharT, _Traits>::operator
>  }
>
>  template 
> -inline _LIBCPP_INLINE_VISIBILITY
> +inline
>  basic_istream<_CharT, _Traits>&
>  basic_istream<_CharT, _Traits>::operator>>(basic_istream&
> (*__pf)(basic_istream&))
>  {
> @@ -733,7 +733,7 @@ basic_istream<_CharT, _Traits>::operator
>  }
>
>  template 
> -inline _LIBCPP_INLINE_VISIBILITY
> +inline
>  basic_istream<_CharT, _Traits>&
>  basic_istream<_CharT, _Traits>::operator>>(basic_ios traits_type>&
> (*__pf)(basic_ios traits_type>&))
> @@ -743,7 +743,7 @@ basic_istream<_CharT, _Traits>::operator
>  }
>
>  template 
> -inline _LIBCPP_INLINE_VISIBILITY
> +inline
>  basic_istream<_CharT, _Traits>&
>  basic_istream<_CharT, _Traits>::operator>>(ios_base& (*__pf)(ios_base&))
>  {
> @@ -800,7 +800,7 @@ operator>>(basic_istream<_CharT, _Traits
>  }
>
>  template
> -inline _LIBCPP_INLINE_VISIBILITY
> +inline
>  basic_istream&
>  operator>>(basic_istream& __is, unsigned char* __s)
>  {
> @@ -808,7 +808,7 @@ operator>>(basic_istream&
>  }
>
>  template
> -inline _LIBCPP_INLINE_VISIBILITY
> +inline
>  basic_istream&
>  operator>>(basic_istream& __is, signed char* __s)
>  {
> @@ -843,7 +843,7 @@ operator>>(basic_istream<_CharT, _Traits
>  }
>
>  template
> -inline _LIBCPP_INLINE_VISIBILITY
> +inline
>  basic_istream&
>  operator>>(basic_istream& __is, unsigned char& __c)
>  {
> @@ -851,7 +851,7 @@ operator>>(basic_istream&
>  }
>
>  template
> -inline _LIBCPP_INLINE_VISIBILITY
> +inline
>  basic_istream&
>  operator>>(basic_istream& __is, signed char& __c)
>  {
> @@ -947,7 +947,7 @@ basic_istream<_CharT, _Traits>::get()
>  }
>
>  template
> -inline _LIBCPP_INLINE_VISIBILITY
> +inline
>  basic_istream<_CharT, _Traits>&
>  basic_istream<_CharT, _Traits>::get(char_type& __c)
>  {
> @@ -1006,7 +1006,7 @@ basic_istream<_CharT, _Traits>::get(char
>  }
>
>  template
> -inline _LIBCPP_INLINE_VISIBILITY
> +inline
>  basic_istream<_CharT, _Traits>&
>  basic_istream<_CharT, _Traits>::get(char_type* __s, streamsize __n)
>  {

Re: [libcxx] r255177 - Remove visibility attributes from out-of-class method definitions in iostreams.

2016-01-08 Thread Evgenii Stepanov via cfe-commits
On Fri, Jan 8, 2016 at 11:02 AM, Duncan P. N. Exon Smith
 wrote:
>
>> On 2016-Jan-08, at 10:49, Nico Weber via cfe-commits 
>>  wrote:
>>
>> On OS X 10.8, __ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5sputcEc 
>> (and others) are a hidden symbol in libc++.1.dylib. This means:
>>
>> * If I use streambuf::sputc() and link against the 10.8 SDK, and the 
>> compiler decides to not inline the call, I will get linker errors.
>> * If I do the same with the 10.10 SDK when targeting 10.8, then (even worse) 
>> the link will silently succeed (since it links against the 10.10 libc++ 
>> which does have a public symbol for this -- the SDK assumes that libc++ is 
>> abi-compatible with itself) but it will then fail to run on a 10.8 system.
>>
>> I don't see a way to save this change -- I think this needs to be reverted.
>
> FWIW, we're working on a plan to add availability markup to libc++
> (it shouldn't be too intrusive (since you can annotate blocks of
> API); had some initial talks with Marshall at the dev meeting).  I
> plan to send out an RFC soon.
>
> I didn't think there'd be interest in having the availability
> attributes themselves in open source (just some placeholder macros),
> but it would be an option.
>
> Anyway, until that's done, I agree this needs to be reverted.
>
>> Have you made similar changes elsewhere? These probably need to be reverted 
>> too.
>
> I agree.

This is the only one of my changes that removes attributes. I'll revert.

>> On Wed, Dec 9, 2015 at 6:42 PM, Evgeniy Stepanov via cfe-commits 
>>  wrote:
>> Author: eugenis
>> Date: Wed Dec  9 17:42:30 2015
>> New Revision: 255177
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=255177=rev
>> Log:
>> Remove visibility attributes from out-of-class method definitions in 
>> iostreams.
>>
>> No point in pretending that these methods are hidden - they are
>> actually exported from libc++.so. Extern template declarations make
>> them part of libc++ ABI.
>>
>> This patch does not change libc++.so export list (at least on Linux).
>>
>> Modified:
>> libcxx/trunk/include/istream
>> libcxx/trunk/include/ostream
>> libcxx/trunk/include/sstream
>> libcxx/trunk/include/streambuf
>>
>> Modified: libcxx/trunk/include/istream
>> URL: 
>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/istream?rev=255177=255176=255177=diff
>> ==
>> --- libcxx/trunk/include/istream (original)
>> +++ libcxx/trunk/include/istream Wed Dec  9 17:42:30 2015
>> @@ -304,7 +304,7 @@ basic_istream<_CharT, _Traits>::sentry::
>>  }
>>
>>  template 
>> -inline _LIBCPP_INLINE_VISIBILITY
>> +inline
>>  basic_istream<_CharT, _Traits>::basic_istream(basic_streambuf> traits_type>* __sb)
>>  : __gc_(0)
>>  {
>> @@ -314,7 +314,7 @@ basic_istream<_CharT, _Traits>::basic_is
>>  #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
>>
>>  template 
>> -inline _LIBCPP_INLINE_VISIBILITY
>> +inline
>>  basic_istream<_CharT, _Traits>::basic_istream(basic_istream&& __rhs)
>>  : __gc_(__rhs.__gc_)
>>  {
>> @@ -323,7 +323,7 @@ basic_istream<_CharT, _Traits>::basic_is
>>  }
>>
>>  template 
>> -inline _LIBCPP_INLINE_VISIBILITY
>> +inline
>>  basic_istream<_CharT, _Traits>&
>>  basic_istream<_CharT, _Traits>::operator=(basic_istream&& __rhs)
>>  {
>> @@ -339,7 +339,7 @@ basic_istream<_CharT, _Traits>::~basic_i
>>  }
>>
>>  template 
>> -inline _LIBCPP_INLINE_VISIBILITY
>> +inline
>>  void
>>  basic_istream<_CharT, _Traits>::swap(basic_istream& __rhs)
>>  {
>> @@ -725,7 +725,7 @@ basic_istream<_CharT, _Traits>::operator
>>  }
>>
>>  template 
>> -inline _LIBCPP_INLINE_VISIBILITY
>> +inline
>>  basic_istream<_CharT, _Traits>&
>>  basic_istream<_CharT, _Traits>::operator>>(basic_istream& 
>> (*__pf)(basic_istream&))
>>  {
>> @@ -733,7 +733,7 @@ basic_istream<_CharT, _Traits>::operator
>>  }
>>
>>  template 
>> -inline _LIBCPP_INLINE_VISIBILITY
>> +inline
>>  basic_istream<_CharT, _Traits>&
>>  basic_istream<_CharT, _Traits>::operator>>(basic_ios> traits_type>&
>> (*__pf)(basic_ios> traits_type>&))
>> @@ -743,7 +743,7 @@ basic_istream<_CharT, _Traits>::operator
>>  }
>>
>>  template 
>> -inline _LIBCPP_INLINE_VISIBILITY
>> +inline
>>  basic_istream<_CharT, _Traits>&
>>  basic_istream<_CharT, _Traits>::operator>>(ios_base& (*__pf)(ios_base&))
>>  {
>> @@ -800,7 +800,7 @@ operator>>(basic_istream<_CharT, _Traits
>>  }
>>
>>  template
>> -inline _LIBCPP_INLINE_VISIBILITY
>> +inline
>>  basic_istream&
>>  operator>>(basic_istream& __is, unsigned char* __s)
>>  {
>> @@ -808,7 +808,7 @@ operator>>(basic_istream&
>>  }
>>
>>  template
>> -inline _LIBCPP_INLINE_VISIBILITY
>> +inline
>>  basic_istream&
>>  operator>>(basic_istream& __is, signed char* __s)
>>  {
>> @@ -843,7 +843,7 

Re: [clang-tools-extra] r257178 - [clang-tidy] Add non-inline function definition and variable definition check in header files.

2016-01-08 Thread David Blaikie via cfe-commits
This sounds sort of like the missing-declaration warning in Clang, no?
(granted, it's a bit more direct & thus perhaps easier to use, but fulfills
a similar purpose)

On Fri, Jan 8, 2016 at 8:37 AM, Alexander Kornienko via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: alexfh
> Date: Fri Jan  8 10:37:11 2016
> New Revision: 257178
>
> URL: http://llvm.org/viewvc/llvm-project?rev=257178=rev
> Log:
> [clang-tidy] Add non-inline function definition and variable definition
> check in header files.
>
> Summary: The new check will find all functionand variable definitions
> which may violate cpp one definition rule in header file.
>
> Reviewers: aaron.ballman, alexfh
>
> Subscribers: aaron.ballman, cfe-commits
>
> Patch by Haojian Wu!
>
> Differential Revision: http://reviews.llvm.org/D15710
>
> Added:
> clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
> clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.h
>
> clang-tools-extra/trunk/docs/clang-tidy/checks/misc-definitions-in-headers.rst
> clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp
> Modified:
> clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
> clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
> clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
> clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py
> clang-tools-extra/trunk/test/lit.cfg
>
> Modified: clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt?rev=257178=257177=257178=diff
>
> ==
> --- clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt (original)
> +++ clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt Fri Jan  8
> 10:37:11 2016
> @@ -5,6 +5,7 @@ add_clang_library(clangTidyMiscModule
>AssertSideEffectCheck.cpp
>AssignOperatorSignatureCheck.cpp
>BoolPointerImplicitConversionCheck.cpp
> +  DefinitionsInHeadersCheck.cpp
>InaccurateEraseCheck.cpp
>InefficientAlgorithmCheck.cpp
>MacroParenthesesCheck.cpp
>
> Added:
> clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp?rev=257178=auto
>
> ==
> --- clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
> (added)
> +++ clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
> Fri Jan  8 10:37:11 2016
> @@ -0,0 +1,126 @@
> +//===--- DefinitionsInHeadersCheck.cpp -
> clang-tidy===//
> +//
> +// The LLVM Compiler Infrastructure
> +//
> +// This file is distributed under the University of Illinois Open Source
> +// License. See LICENSE.TXT for details.
> +//
>
> +//===--===//
> +
> +#include "DefinitionsInHeadersCheck.h"
> +#include "clang/AST/ASTContext.h"
> +#include "clang/ASTMatchers/ASTMatchFinder.h"
> +
> +using namespace clang::ast_matchers;
> +
> +namespace clang {
> +namespace tidy {
> +namespace misc {
> +
> +namespace {
> +
> +AST_MATCHER(NamedDecl, isHeaderFileExtension) {
> +  SourceManager& SM = Finder->getASTContext().getSourceManager();
> +  SourceLocation ExpansionLoc = SM.getExpansionLoc(Node.getLocStart());
> +  StringRef Filename = SM.getFilename(ExpansionLoc);
> +  return Filename.endswith(".h") || Filename.endswith(".hh") ||
> + Filename.endswith(".hpp") || Filename.endswith(".hxx") ||
> + llvm::sys::path::extension(Filename).empty();
> +}
> +
> +} // namespace
> +
> +DefinitionsInHeadersCheck::DefinitionsInHeadersCheck(
> +StringRef Name, ClangTidyContext *Context)
> +  : ClangTidyCheck(Name, Context),
> +UseHeaderFileExtension(Options.get("UseHeaderFileExtension",
> true)) {}
> +
> +void DefinitionsInHeadersCheck::storeOptions(
> +ClangTidyOptions::OptionMap ) {
> +  Options.store(Opts, "UseHeaderFileExtension", UseHeaderFileExtension);
> +}
> +
> +void DefinitionsInHeadersCheck::registerMatchers(MatchFinder *Finder) {
> +  if (UseHeaderFileExtension) {
> +Finder->addMatcher(
> +namedDecl(anyOf(functionDecl(isDefinition()),
> varDecl(isDefinition())),
> +  isHeaderFileExtension()).bind("name-decl"),
> +this);
> +  } else {
> +Finder->addMatcher(
> +namedDecl(anyOf(functionDecl(isDefinition()),
> varDecl(isDefinition())),
> +  anyOf(isHeaderFileExtension(),
> +
> unless(isExpansionInMainFile(.bind("name-decl"),
> +this);
> +  }
> +}
> +
> +void DefinitionsInHeadersCheck::check(const MatchFinder::MatchResult
> ) {
> +  // C++ [basic.def.odr] p6:
> +  // There can be more than one definition of a class type, enumeration
> type,
> +  // inline 

r257190 - Update code in buildCudaActions and BuildActions to latest idiom.

2016-01-08 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Fri Jan  8 13:04:11 2016
New Revision: 257190

URL: http://llvm.org/viewvc/llvm-project?rev=257190=rev
Log:
Update code in buildCudaActions and BuildActions to latest idiom.

Summary:
Use llvm::any_of, llvm::find, etc.

No functional changes.

Reviewers: tra

Subscribers: cfe-commits

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

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

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=257190=257189=257190=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Fri Jan  8 13:04:11 2016
@@ -1298,11 +1298,11 @@ buildCudaActions(Compilation , Derived
   SmallVector GpuArchList;
   llvm::StringSet<> GpuArchNames;
   for (Arg *A : Args) {
-if (A->getOption().matches(options::OPT_cuda_gpu_arch_EQ)) {
-  A->claim();
-  if (GpuArchNames.insert(A->getValue()).second)
-GpuArchList.push_back(A->getValue());
-}
+if (!A->getOption().matches(options::OPT_cuda_gpu_arch_EQ))
+  continue;
+A->claim();
+if (GpuArchNames.insert(A->getValue()).second)
+  GpuArchList.push_back(A->getValue());
   }
 
   // Default to sm_20 which is the lowest common denominator for supported 
GPUs.
@@ -1325,13 +1325,10 @@ buildCudaActions(Compilation , Derived
  "Failed to create actions for all devices");
 
   // Check whether any of device actions stopped before they could generate 
PTX.
-  bool PartialCompilation = false;
-  for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I) {
-if (CudaDeviceActions[I]->getKind() != Action::BackendJobClass) {
-  PartialCompilation = true;
-  break;
-}
-  }
+  bool PartialCompilation =
+  llvm::any_of(CudaDeviceActions, [](const Action *a) {
+return a->getKind() != Action::BackendJobClass;
+  });
 
   // Figure out what to do with device actions -- pass them as inputs to the
   // host action or run each of them independently.
@@ -1470,12 +1467,11 @@ void Driver::BuildActions(Compilation 
   continue;
 }
 
-phases::ID CudaInjectionPhase = FinalPhase;
-for (const auto  : PL)
-  if (Phase <= FinalPhase && Phase == phases::Compile) {
-CudaInjectionPhase = Phase;
-break;
-  }
+phases::ID CudaInjectionPhase =
+(phases::Compile < FinalPhase &&
+ llvm::find(PL, phases::Compile) != PL.end())
+? phases::Compile
+: FinalPhase;
 
 // Build the pipeline for this file.
 std::unique_ptr Current(new InputAction(*InputArg, InputType));


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


[libcxx] r257193 - Revert "Remove visibility attributes from out-of-class method definitions in iostreams."

2016-01-08 Thread Evgeniy Stepanov via cfe-commits
Author: eugenis
Date: Fri Jan  8 13:21:02 2016
New Revision: 257193

URL: http://llvm.org/viewvc/llvm-project?rev=257193=rev
Log:
Revert "Remove visibility attributes from out-of-class method definitions in 
iostreams."

Modified:
libcxx/trunk/include/istream
libcxx/trunk/include/ostream
libcxx/trunk/include/sstream
libcxx/trunk/include/streambuf

Modified: libcxx/trunk/include/istream
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/istream?rev=257193=257192=257193=diff
==
--- libcxx/trunk/include/istream (original)
+++ libcxx/trunk/include/istream Fri Jan  8 13:21:02 2016
@@ -304,7 +304,7 @@ basic_istream<_CharT, _Traits>::sentry::
 }
 
 template 
-inline
+inline _LIBCPP_INLINE_VISIBILITY
 basic_istream<_CharT, _Traits>::basic_istream(basic_streambuf* __sb)
 : __gc_(0)
 {
@@ -314,7 +314,7 @@ basic_istream<_CharT, _Traits>::basic_is
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template 
-inline
+inline _LIBCPP_INLINE_VISIBILITY
 basic_istream<_CharT, _Traits>::basic_istream(basic_istream&& __rhs)
 : __gc_(__rhs.__gc_)
 {
@@ -323,7 +323,7 @@ basic_istream<_CharT, _Traits>::basic_is
 }
 
 template 
-inline
+inline _LIBCPP_INLINE_VISIBILITY
 basic_istream<_CharT, _Traits>&
 basic_istream<_CharT, _Traits>::operator=(basic_istream&& __rhs)
 {
@@ -339,7 +339,7 @@ basic_istream<_CharT, _Traits>::~basic_i
 }
 
 template 
-inline
+inline _LIBCPP_INLINE_VISIBILITY
 void
 basic_istream<_CharT, _Traits>::swap(basic_istream& __rhs)
 {
@@ -725,7 +725,7 @@ basic_istream<_CharT, _Traits>::operator
 }
 
 template 
-inline
+inline _LIBCPP_INLINE_VISIBILITY
 basic_istream<_CharT, _Traits>&
 basic_istream<_CharT, _Traits>::operator>>(basic_istream& 
(*__pf)(basic_istream&))
 {
@@ -733,7 +733,7 @@ basic_istream<_CharT, _Traits>::operator
 }
 
 template 
-inline
+inline _LIBCPP_INLINE_VISIBILITY
 basic_istream<_CharT, _Traits>&
 basic_istream<_CharT, _Traits>::operator>>(basic_ios&
(*__pf)(basic_ios&))
@@ -743,7 +743,7 @@ basic_istream<_CharT, _Traits>::operator
 }
 
 template 
-inline
+inline _LIBCPP_INLINE_VISIBILITY
 basic_istream<_CharT, _Traits>&
 basic_istream<_CharT, _Traits>::operator>>(ios_base& (*__pf)(ios_base&))
 {
@@ -800,7 +800,7 @@ operator>>(basic_istream<_CharT, _Traits
 }
 
 template
-inline
+inline _LIBCPP_INLINE_VISIBILITY
 basic_istream&
 operator>>(basic_istream& __is, unsigned char* __s)
 {
@@ -808,7 +808,7 @@ operator>>(basic_istream&
 }
 
 template
-inline
+inline _LIBCPP_INLINE_VISIBILITY
 basic_istream&
 operator>>(basic_istream& __is, signed char* __s)
 {
@@ -843,7 +843,7 @@ operator>>(basic_istream<_CharT, _Traits
 }
 
 template
-inline
+inline _LIBCPP_INLINE_VISIBILITY
 basic_istream&
 operator>>(basic_istream& __is, unsigned char& __c)
 {
@@ -851,7 +851,7 @@ operator>>(basic_istream&
 }
 
 template
-inline
+inline _LIBCPP_INLINE_VISIBILITY
 basic_istream&
 operator>>(basic_istream& __is, signed char& __c)
 {
@@ -947,7 +947,7 @@ basic_istream<_CharT, _Traits>::get()
 }
 
 template
-inline
+inline _LIBCPP_INLINE_VISIBILITY
 basic_istream<_CharT, _Traits>&
 basic_istream<_CharT, _Traits>::get(char_type& __c)
 {
@@ -1006,7 +1006,7 @@ basic_istream<_CharT, _Traits>::get(char
 }
 
 template
-inline
+inline _LIBCPP_INLINE_VISIBILITY
 basic_istream<_CharT, _Traits>&
 basic_istream<_CharT, _Traits>::get(char_type* __s, streamsize __n)
 {
@@ -1068,7 +1068,7 @@ basic_istream<_CharT, _Traits>::get(basi
 }
 
 template
-inline
+inline _LIBCPP_INLINE_VISIBILITY
 basic_istream<_CharT, _Traits>&
 basic_istream<_CharT, _Traits>::get(basic_streambuf& 
__sb)
 {
@@ -1129,7 +1129,7 @@ basic_istream<_CharT, _Traits>::getline(
 }
 
 template
-inline
+inline _LIBCPP_INLINE_VISIBILITY
 basic_istream<_CharT, _Traits>&
 basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n)
 {
@@ -1462,7 +1462,7 @@ ws(basic_istream<_CharT, _Traits>& __is)
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template 
-inline
+inline _LIBCPP_INLINE_VISIBILITY
 basic_istream<_CharT, _Traits>&
 operator>>(basic_istream<_CharT, _Traits>&& __is, _Tp& __x)
 {
@@ -1504,7 +1504,7 @@ public:
 };
 
 template 
-inline
+inline _LIBCPP_INLINE_VISIBILITY
 basic_iostream<_CharT, _Traits>::basic_iostream(basic_streambuf* __sb)
 : basic_istream<_CharT, _Traits>(__sb)
 {
@@ -1513,14 +1513,14 @@ basic_iostream<_CharT, _Traits>::basic_i
 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
 
 template 
-inline
+inline _LIBCPP_INLINE_VISIBILITY
 basic_iostream<_CharT, _Traits>::basic_iostream(basic_iostream&& __rhs)
 : basic_istream<_CharT, _Traits>(_VSTD::move(__rhs))
 {
 }
 
 template 
-inline
+inline _LIBCPP_INLINE_VISIBILITY
 

Re: [PATCH] D15589: [PPC] Add long long/double support for vec_cts, vec_ctu and vec_ctf.

2016-01-08 Thread Tim Shen via cfe-commits
timshen closed this revision.
timshen added a comment.

Thanks iteratee for committing as r257135 !


http://reviews.llvm.org/D15589



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


[PATCH] D16006: [libcxxabi] Teach cxa_demangle about Hexagon's long double size

2016-01-08 Thread Ben Craig via cfe-commits
bcraig created this revision.
bcraig added reviewers: howard.hinnant, logan, dsanders, rengolin.
bcraig added a subscriber: cfe-commits.

cxa_demangle's default size for a long double is 10 bytes.  Hexagon only has an 
8 byte long double though.

http://reviews.llvm.org/D16006

Files:
  src/cxa_demangle.cpp

Index: src/cxa_demangle.cpp
===
--- src/cxa_demangle.cpp
+++ src/cxa_demangle.cpp
@@ -167,7 +167,7 @@
 {
 #if defined(__mips__) && defined(__mips_n64) || defined(__aarch64__)
 static const size_t mangled_size = 32;
-#elif defined(__arm__) || defined(__mips__)
+#elif defined(__arm__) || defined(__mips__) || defined(__hexagon__)
 static const size_t mangled_size = 16;
 #else
 static const size_t mangled_size = 20;  // May need to be adjusted to 16 
or 24 on other platforms


Index: src/cxa_demangle.cpp
===
--- src/cxa_demangle.cpp
+++ src/cxa_demangle.cpp
@@ -167,7 +167,7 @@
 {
 #if defined(__mips__) && defined(__mips_n64) || defined(__aarch64__)
 static const size_t mangled_size = 32;
-#elif defined(__arm__) || defined(__mips__)
+#elif defined(__arm__) || defined(__mips__) || defined(__hexagon__)
 static const size_t mangled_size = 16;
 #else
 static const size_t mangled_size = 20;  // May need to be adjusted to 16 or 24 on other platforms
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D16007: [libcxxabi] Make test tolerant of uncommon floating literal demanglings

2016-01-08 Thread Ben Craig via cfe-commits
bcraig created this revision.
bcraig added reviewers: howard.hinnant, logan, EricWF.
bcraig added a subscriber: cfe-commits.

libcxxabi uses the C99 library's %a format specifier to turn a floating point 
value into a hexadecimal string representation.  The %a format specifier is 
rather loosely defined in the C spec though, and some C libraries emit a 
different (but valid) string for a given floating point value.  In particular, 
the C spec only requires that there is a single, non-zero hexadecimal digit on 
the left of the decimal point.  Given that constraint, there are typically four 
different valid representations of a floating point number.  I have updated the 
test to accept any of the valid representations for demangled floating point 
literals.

http://reviews.llvm.org/D16007

Files:
  test/test_demangle.pass.cpp

Index: test/test_demangle.pass.cpp
===
--- test/test_demangle.pass.cpp
+++ test/test_demangle.pass.cpp
@@ -29516,11 +29516,6 @@
 {"_ZN6PR58615AllocIcNS_6PolicyINS_1PELb18allocateEiPKv", 
"PR5861::Alloc >::allocate(int, void 
const*)"},
 {"_ZN5test01fIdEEvT_RAszcl3ovlcvS1__EE_c", "void test0::f(double, 
char (&) [sizeof (ovl((double)()))])"},
 {"_ZN5test01fIiEEvT_RAszcl3ovlcvS1__EE_c", "void test0::f(int, char 
(&) [sizeof (ovl((int)()))])"},
-{"_ZN5test01gIfEEvRAszplcvT__ELf40a0E_c", "void test0::g(char 
(&) [sizeof (((float)()) + (0x1.4p+2f))])"},
-{"_ZN5test01hIfEEvRAszplcvT__ELd4014E_c", "void 
test0::h(char (&) [sizeof (((float)()) + (0x1.4p+2))])"},
-#if LDBL_FP80
-{"_ZN5test01hIfEEvRAcvjplstT_Le4001a000E_c", "void 
test0::h(char (&) [(unsigned int)((sizeof (float)) + (0xap-1L))])"},
-#endif
 {"_ZN5test01jINS_1AEEEvRAszdtcvT__E6buffer_c", "void 
test0::j(char (&) [sizeof ((test0::A)().buffer)])"},
 {"_ZN5test11fINS_1XEiEEvT_IT0_E", "void test1::f(test1::X)"},
 {"_ZN5test211read_memberINS_1AEEEDtptcvPT_Li0E6memberERS2_", 
"decltype((test2::A*)(0)->member) test2::read_member(test2::A&)"},
@@ -29600,6 +29595,37 @@
 
 const unsigned N = sizeof(cases) / sizeof(cases[0]);
 
+struct FPLiteralCase {
+const char *mangled;
+// There are four possible demanglings of a given float.
+std::string expecting[4];
+} fp_literal_cases[] =
+{
+{"_ZN5test01gIfEEvRAszplcvT__ELf40a0E_c", {
+"void test0::g(char (&) [sizeof (((float)()) + (0x1.4p+2f))])",
+"void test0::g(char (&) [sizeof (((float)()) + (0x2.8p+1f))])",
+"void test0::g(char (&) [sizeof (((float)()) + (0x5p+0f))])",
+"void test0::g(char (&) [sizeof (((float)()) + (0xap-1f))])",
+}},
+{"_ZN5test01hIfEEvRAszplcvT__ELd4014E_c", {
+"void test0::h(char (&) [sizeof (((float)()) + (0x1.4p+2))])",
+"void test0::h(char (&) [sizeof (((float)()) + (0x2.8p+1))])",
+"void test0::h(char (&) [sizeof (((float)()) + (0x5p+0))])",
+"void test0::h(char (&) [sizeof (((float)()) + (0xap-1))])",
+}},
+#if LDBL_FP80
+{"_ZN5test01hIfEEvRAcvjplstT_Le4001a000E_c", {
+"void test0::h(char (&) [(unsigned int)((sizeof (float)) + 
(0x1.4p+2L))])",
+"void test0::h(char (&) [(unsigned int)((sizeof (float)) + 
(0x2.8p+1L))])",
+"void test0::h(char (&) [(unsigned int)((sizeof (float)) + 
(0x5p+0L))])",
+"void test0::h(char (&) [(unsigned int)((sizeof (float)) + 
(0xap-1L))])",
+}},
+#endif
+};
+const unsigned NF = sizeof(fp_literal_cases) / sizeof(fp_literal_cases[0]);
+const unsigned NEF = sizeof(fp_literal_cases[0].expecting) / 
sizeof(fp_literal_cases[0].expecting[0]);
+
+
 const char* invalid_cases[] =
 {
 "_ZIPPreEncode",
@@ -29665,6 +29691,36 @@
 free(buf);
 }
 
+void testFPLiterals()
+{
+std::size_t len = 0;
+char* buf = nullptr;
+for (unsigned i = 0; i < NF; ++i)
+{
+FPLiteralCase *fpCase = fp_literal_cases+i;
+int status;
+char* demang = __cxxabiv1::__cxa_demangle(fpCase->mangled, buf, , 
);
+if (demang == 0)
+{
+std::cout << fpCase->mangled << " -> " << fpCase->expecting[0] << 
'\n';
+std::cout << "Got instead: NULL, " << status << '\n';
+assert(false);
+continue;
+}
+std::string *e_beg = fpCase->expecting;
+std::string *e_end = fpCase->expecting + NEF;
+if (std::find(e_beg, e_end, demang) == e_end)
+{
+std::cout << fpCase->mangled << " -> " << fpCase->expecting[0] << 
'\n';
+std::cout << "Got instead: " << demang << '\n';
+assert(false);
+continue;
+}
+buf = demang;
+}
+free(buf);
+}
+
 int main()
 {
 std::cout << "Testing " << N << " symbols." << std::endl;
@@ -29672,6 +29728,7 @@
 timer t;
 test();
 test2();
+testFPLiterals();
 }
 #if 0
 std::string input;



Re: r256962 - Module debugging: Defer emitting tag types until their definition

2016-01-08 Thread Adrian Prantl via cfe-commits

> On Jan 8, 2016, at 1:31 PM, David Blaikie  wrote:
> 
> 
> 
> On Wed, Jan 6, 2016 at 11:22 AM, Adrian Prantl via cfe-commits 
> > wrote:
> Author: adrian
> Date: Wed Jan  6 13:22:19 2016
> New Revision: 256962
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=256962=rev 
> 
> Log:
> Module debugging: Defer emitting tag types until their definition
> was visited and all decls have been merged.
> 
> We only get a single chance to emit the types for virtual classes because
> CGDebugInfo::completeRequiredType() categorically doesn't complete them.
> 
> Not sure I'm following this comment. Could you explain this in other 
> words/detail?
> 
> If we visit a declaration we shouldn't do anything, right? (no point putting 
> declarations in the modules debug info, unless it's needed for something 
> else?) & then when we see the definition we'd build the debug info for it?

Yes. Your statement pretty much summarizes this commit :-)

-- adrian

>  
> 
> Modified:
> cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
> cfe/trunk/test/Modules/Inputs/DebugCXX.h
> cfe/trunk/test/Modules/ModuleDebugInfo.cpp
> 
> Modified: cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp?rev=256962=256961=256962=diff
>  
> 
> ==
> --- cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp (original)
> +++ cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp Wed Jan  6 
> 13:22:19 2016
> @@ -59,8 +59,10 @@ class PCHContainerGenerator : public AST
>struct DebugTypeVisitor : public RecursiveASTVisitor {
>  clang::CodeGen::CGDebugInfo 
>  ASTContext 
> -DebugTypeVisitor(clang::CodeGen::CGDebugInfo , ASTContext )
> -: DI(DI), Ctx(Ctx) {}
> +bool SkipTagDecls;
> +DebugTypeVisitor(clang::CodeGen::CGDebugInfo , ASTContext ,
> + bool SkipTagDecls)
> +: DI(DI), Ctx(Ctx), SkipTagDecls(SkipTagDecls) {}
> 
>  /// Determine whether this type can be represented in DWARF.
>  static bool CanRepresent(const Type *Ty) {
> @@ -75,6 +77,12 @@ class PCHContainerGenerator : public AST
>  }
> 
>  bool VisitTypeDecl(TypeDecl *D) {
> +  // TagDecls may be deferred until after all decls have been merged and 
> we
> +  // know the complete type. Pure forward declarations will be skipped, 
> but
> +  // they don't need to be emitted into the module anyway.
> +  if (SkipTagDecls && isa(D))
> +  return true;
> +
>QualType QualTy = Ctx.getTypeDeclType(D);
>if (!QualTy.isNull() && CanRepresent(QualTy.getTypePtr()))
>  DI.getOrCreateStandaloneType(QualTy, D->getLocation());
> @@ -165,7 +173,7 @@ public:
>  // Collect debug info for all decls in this group.
>  for (auto *I : D)
>if (!I->isFromASTFile()) {
> -DebugTypeVisitor DTV(*Builder->getModuleDebugInfo(), *Ctx);
> +DebugTypeVisitor DTV(*Builder->getModuleDebugInfo(), *Ctx, true);
>  DTV.TraverseDecl(I);
>}
>  return true;
> @@ -179,6 +187,11 @@ public:
>  if (Diags.hasErrorOccurred())
>return;
> 
> +if (D->isFromASTFile())
> +  return;
> +
> +DebugTypeVisitor DTV(*Builder->getModuleDebugInfo(), *Ctx, false);
> +DTV.TraverseDecl(D);
>  Builder->UpdateCompletedType(D);
>}
> 
> 
> Modified: cfe/trunk/test/Modules/Inputs/DebugCXX.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/DebugCXX.h?rev=256962=256961=256962=diff
>  
> 
> ==
> --- cfe/trunk/test/Modules/Inputs/DebugCXX.h (original)
> +++ cfe/trunk/test/Modules/Inputs/DebugCXX.h Wed Jan  6 13:22:19 2016
> @@ -50,3 +50,9 @@ namespace DebugCXX {
>typedef A B;
>void foo(B) {}
>  }
> +
> +// Virtual class with a forward declaration.
> +class FwdVirtual;
> +class FwdVirtual {
> +  virtual ~FwdVirtual() {}
> +};
> 
> Modified: cfe/trunk/test/Modules/ModuleDebugInfo.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ModuleDebugInfo.cpp?rev=256962=256961=256962=diff
>  
> 
> ==
> --- cfe/trunk/test/Modules/ModuleDebugInfo.cpp (original)
> +++ cfe/trunk/test/Modules/ModuleDebugInfo.cpp Wed Jan  6 13:22:19 2016
> @@ -7,13 +7,11 @@
>  // RUN: rm -rf %t
>  // RUN: %clang_cc1 

Re: [PATCH] D15705: Adding a scripted test for PR25717

2016-01-08 Thread Yunzhong Gao via cfe-commits
ygao updated this revision to Diff 44351.

http://reviews.llvm.org/D15705

Files:
  test/Preprocessor/bigoutput.c

Index: test/Preprocessor/bigoutput.c
===
--- test/Preprocessor/bigoutput.c
+++ test/Preprocessor/bigoutput.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -E -x c %s > /dev/console
+// The original bug requires UNIX line endings to trigger.
+// The original bug triggers only when outputting directly to console.
+
+// Make sure clang does not crash during preprocessing
+
+#define M0 extern int x;
+#define M2  M0  M0  M0  M0
+#define M4  M2  M2  M2  M2
+#define M6  M4  M4  M4  M4
+#define M8  M6  M6  M6  M6
+#define M10 M8  M8  M8  M8
+#define M12 M10 M10 M10 M10
+#define M14 M12 M12 M12 M12
+
+M14


Index: test/Preprocessor/bigoutput.c
===
--- test/Preprocessor/bigoutput.c
+++ test/Preprocessor/bigoutput.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -E -x c %s > /dev/console
+// The original bug requires UNIX line endings to trigger.
+// The original bug triggers only when outputting directly to console.
+
+// Make sure clang does not crash during preprocessing
+
+#define M0 extern int x;
+#define M2  M0  M0  M0  M0
+#define M4  M2  M2  M2  M2
+#define M6  M4  M4  M4  M4
+#define M8  M6  M6  M6  M6
+#define M10 M8  M8  M8  M8
+#define M12 M10 M10 M10 M10
+#define M14 M12 M12 M12 M12
+
+M14
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r256962 - Module debugging: Defer emitting tag types until their definition

2016-01-08 Thread David Blaikie via cfe-commits
On Wed, Jan 6, 2016 at 11:22 AM, Adrian Prantl via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: adrian
> Date: Wed Jan  6 13:22:19 2016
> New Revision: 256962
>
> URL: http://llvm.org/viewvc/llvm-project?rev=256962=rev
> Log:
> Module debugging: Defer emitting tag types until their definition
> was visited and all decls have been merged.
>
> We only get a single chance to emit the types for virtual classes because
> CGDebugInfo::completeRequiredType() categorically doesn't complete them.
>

Not sure I'm following this comment. Could you explain this in other
words/detail?

If we visit a declaration we shouldn't do anything, right? (no point
putting declarations in the modules debug info, unless it's needed for
something else?) & then when we see the definition we'd build the debug
info for it?


>
> Modified:
> cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
> cfe/trunk/test/Modules/Inputs/DebugCXX.h
> cfe/trunk/test/Modules/ModuleDebugInfo.cpp
>
> Modified: cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp?rev=256962=256961=256962=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp (original)
> +++ cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp Wed Jan  6
> 13:22:19 2016
> @@ -59,8 +59,10 @@ class PCHContainerGenerator : public AST
>struct DebugTypeVisitor : public RecursiveASTVisitor {
>  clang::CodeGen::CGDebugInfo 
>  ASTContext 
> -DebugTypeVisitor(clang::CodeGen::CGDebugInfo , ASTContext )
> -: DI(DI), Ctx(Ctx) {}
> +bool SkipTagDecls;
> +DebugTypeVisitor(clang::CodeGen::CGDebugInfo , ASTContext ,
> + bool SkipTagDecls)
> +: DI(DI), Ctx(Ctx), SkipTagDecls(SkipTagDecls) {}
>
>  /// Determine whether this type can be represented in DWARF.
>  static bool CanRepresent(const Type *Ty) {
> @@ -75,6 +77,12 @@ class PCHContainerGenerator : public AST
>  }
>
>  bool VisitTypeDecl(TypeDecl *D) {
> +  // TagDecls may be deferred until after all decls have been merged
> and we
> +  // know the complete type. Pure forward declarations will be
> skipped, but
> +  // they don't need to be emitted into the module anyway.
> +  if (SkipTagDecls && isa(D))
> +  return true;
> +
>QualType QualTy = Ctx.getTypeDeclType(D);
>if (!QualTy.isNull() && CanRepresent(QualTy.getTypePtr()))
>  DI.getOrCreateStandaloneType(QualTy, D->getLocation());
> @@ -165,7 +173,7 @@ public:
>  // Collect debug info for all decls in this group.
>  for (auto *I : D)
>if (!I->isFromASTFile()) {
> -DebugTypeVisitor DTV(*Builder->getModuleDebugInfo(), *Ctx);
> +DebugTypeVisitor DTV(*Builder->getModuleDebugInfo(), *Ctx, true);
>  DTV.TraverseDecl(I);
>}
>  return true;
> @@ -179,6 +187,11 @@ public:
>  if (Diags.hasErrorOccurred())
>return;
>
> +if (D->isFromASTFile())
> +  return;
> +
> +DebugTypeVisitor DTV(*Builder->getModuleDebugInfo(), *Ctx, false);
> +DTV.TraverseDecl(D);
>  Builder->UpdateCompletedType(D);
>}
>
>
> Modified: cfe/trunk/test/Modules/Inputs/DebugCXX.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/DebugCXX.h?rev=256962=256961=256962=diff
>
> ==
> --- cfe/trunk/test/Modules/Inputs/DebugCXX.h (original)
> +++ cfe/trunk/test/Modules/Inputs/DebugCXX.h Wed Jan  6 13:22:19 2016
> @@ -50,3 +50,9 @@ namespace DebugCXX {
>typedef A B;
>void foo(B) {}
>  }
> +
> +// Virtual class with a forward declaration.
> +class FwdVirtual;
> +class FwdVirtual {
> +  virtual ~FwdVirtual() {}
> +};
>
> Modified: cfe/trunk/test/Modules/ModuleDebugInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ModuleDebugInfo.cpp?rev=256962=256961=256962=diff
>
> ==
> --- cfe/trunk/test/Modules/ModuleDebugInfo.cpp (original)
> +++ cfe/trunk/test/Modules/ModuleDebugInfo.cpp Wed Jan  6 13:22:19 2016
> @@ -7,13 +7,11 @@
>  // RUN: rm -rf %t
>  // RUN: %clang_cc1 -triple %itanium_abi_triple -x objective-c++
> -std=c++11 -debug-info-kind=limited -fmodules -fmodule-format=obj
> -fimplicit-module-maps -DMODULES -fmodules-cache-path=%t %s -I %S/Inputs -I
> %t -emit-llvm -o %t.ll -mllvm -debug-only=pchcontainer &>%t-mod.ll
>  // RUN: cat %t-mod.ll | FileCheck %s
> -// RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-NEG %s
>  // RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-DWO %s
>
>  // PCH:
>  // RUN: %clang_cc1 -triple %itanium_abi_triple -x c++ -std=c++11
> -emit-pch -fmodule-format=obj -I %S/Inputs -o %t.pch %S/Inputs/DebugCXX.h
> -mllvm -debug-only=pchcontainer &>%t-pch.ll
>  // 

r257205 - [MS ABI] Complete and base constructor GlobalDecls must have the same name

2016-01-08 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Fri Jan  8 14:48:26 2016
New Revision: 257205

URL: http://llvm.org/viewvc/llvm-project?rev=257205=rev
Log:
[MS ABI] Complete and base constructor GlobalDecls must have the same name

Clang got itself into the situation where we mangled the same
constructor twice with two different constructor types.  After one of
the constructors were utilized, the tag used for one of the types
changed from class to struct because a class template became complete.
This resulted in one of the constructor types varying from the other
constructor.

Instead, force "base" constructor types to "complete" if the ABI doesn't
have constructor variants.  This will ensure that GlobalDecls for both
variants will get the same mangled name.

This fixes PR26029.

Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/CodeGenCXX/mangle-ms.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=257205=257204=257205=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri Jan  8 14:48:26 2016
@@ -615,7 +615,20 @@ void CodeGenModule::setTLSMode(llvm::Glo
 }
 
 StringRef CodeGenModule::getMangledName(GlobalDecl GD) {
-  StringRef  = MangledDeclNames[GD.getCanonicalDecl()];
+  GlobalDecl CanonicalGD = GD.getCanonicalDecl();
+
+  // Some ABIs don't have constructor variants.  Make sure that base and
+  // complete constructors get mangled the same.
+  if (const auto *CD = dyn_cast(CanonicalGD.getDecl())) {
+if (!getTarget().getCXXABI().hasConstructorVariants()) {
+  CXXCtorType OrigCtorType = GD.getCtorType();
+  assert(OrigCtorType == Ctor_Base || OrigCtorType == Ctor_Complete);
+  if (OrigCtorType == Ctor_Base)
+CanonicalGD = GlobalDecl(CD, Ctor_Complete);
+}
+  }
+
+  StringRef  = MangledDeclNames[CanonicalGD];
   if (!FoundStr.empty())
 return FoundStr;
 

Modified: cfe/trunk/test/CodeGenCXX/mangle-ms.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-ms.cpp?rev=257205=257204=257205=diff
==
--- cfe/trunk/test/CodeGenCXX/mangle-ms.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle-ms.cpp Fri Jan  8 14:48:26 2016
@@ -454,3 +454,28 @@ namespace Complex {
 // CHECK-DAG: define void @"\01?f@Complex@@YAXU?$_Complex@H@__clang@@@Z"(
 void f(_Complex int) {}
 }
+
+namespace PR26029 {
+template 
+struct L {
+  L() {}
+};
+template 
+class H;
+struct M : L {};
+
+template 
+struct H {};
+
+template 
+void m_fn3() {
+  (H());
+  M();
+}
+
+void runOnFunction() {
+  L b;
+  m_fn3();
+}
+// CHECK-DAG: call {{.*}} @"\01??0?$L@V?$H@PAH@PR26029@@@PR26029@@QAE@XZ"
+}


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


Re: [PATCH] D15861: Support fully-qualified names for all QualTypes

2016-01-08 Thread Sterling Augustine via cfe-commits
saugustine added a comment.

Thanks for the reviews. Please take another look when you get a chance.



Comment at: include/clang/Tooling/Core/QualTypeNames.h:32-33
@@ +31,4 @@
+namespace TypeName {
+///\brief Convert the type into one with fully qualified template
+/// arguments.
+///\param[in] QT - the type for which the fully qualified type will be

rsmith wrote:
> rsmith wrote:
> > Please ensure there's a space between each `/// ` and the content.
> What do you mean by "fully qualified template arguments" here? Let me give 
> you some examples:
> 
> namespace A {
>   struct X {};
> }
> using A::X;
> namespace B {
>   using std::tuple;
>   typedef typle TX;
>   TX t;
>   struct A { typedef int X; };
> }
> 
> What is the fully-qualified name of `B::t`'s type? Is it `B::TX` or 
> `std::tuple` or `std::tuple<::A::X>`? Note that if you want to 
> redeclare `t` from within namespace `B`, `std::tuple` will name the 
> wrong type.
> 
> 
> Why does this only affect template arguments? Its name suggests it should 
> affect the type as a whole (for instance, in the above case it should produce 
> `std::tuple<...>`, not `tuple<...>`).
> 
> 
> Generally, I think this interface needs to specify where the produced names 
> can be used as a name for the specified type, otherwise I don't see how it 
> can ever be reliable. For instance:
> 
> > "Generates a name for a type that can be used to name the same type if used 
> > at the end of the current translation unit." (eg, `B::TX` or 
> > `std::tuple`)
> 
> or:
> 
> > "Generates a maximally-explicit name for a type that can be used in any 
> > context where all the relevant components have been declared. In such a 
> > context, this name will either name the intended type or produce an 
> > ambiguity error." (eg, `::std::tuple<::A::X>`)
> 
> You should also specify what happens when it's not possible to generate such 
> a name. For instance, given:
> 
> void f() {
>   struct X {} x;
> }
> 
> ... there's no way to name the type of `x` from outside `f` (which makes 
> certain refactoring operations impossible unless you also move the definition 
> of `struct X`).
> 
> 
> I think the ideal interface here would allow you to specify a location where 
> you wish to insert the name, and would produce a "best possible" name for 
> that type for that location, avoiding adding explicit qualification / 
> desugaring wherever possible, but the interface should at least take the 
> context-sensitivity of names into account.
My use case is to take a function signature, and communicate to a developer one 
way to declare the variables they need to call the function.

It does expand entire qualtypes, not just template parameters. (I've updated 
that description.)

Given the use case, "at the end of the translation unit" is the closest 
description of where these names would be valid, with the exception that this 
code avoids relying on any "using" declaration. "using foo::bar; void bat(bar 
b);", this code would describe foo's parameter as type foo::bar, rather than 
plain "bar", even though plain "bar" would work at the end of the translation 
unit.

I have updated the file header's comment to reflect all this, and added a 
couple of test cases to prove to myself that it does what I have documented. 
Along the way I have found a couple of places to explicitly mark where one 
would do things differently if one wanted to change this behavior.

The "ideal interface" idea is a good--and very cool--one, but my use case 
doesn't call for it.


Comment at: include/clang/Tooling/Core/QualTypeNames.h:49-79
@@ +48,33 @@
+
+///\brief Create a NestedNameSpecifier for Namesp and its enclosing
+/// scopes.
+///
+///\param[in] Ctx - the AST Context to be used.
+///\param[in] Namesp - the NamespaceDecl for which a NestedNameSpecifier
+/// is requested.
+clang::NestedNameSpecifier *createNestedNameSpecifier(
+const clang::ASTContext , const clang::NamespaceDecl *Namesp);
+
+///\brief Create a NestedNameSpecifier for TagDecl and its enclosing
+/// scopes.
+///
+///\param[in] Ctx - the AST Context to be used.
+///\param[in] TD - the TagDecl for which a NestedNameSpecifier is
+/// requested.
+///\param[in] FullyQualify - Convert all template arguments into fully
+/// qualified names.
+clang::NestedNameSpecifier *createNestedNameSpecifier(
+const clang::ASTContext , const clang::TagDecl *TD, bool FullyQualify);
+
+///\brief Create a NestedNameSpecifier for TypedefDecl and its enclosing
+/// scopes.
+///
+///\param[in] Ctx - the AST Context to be used.
+///\param[in] TD - the TypedefDecl for which a NestedNameSpecifier is
+/// requested.
+///\param[in] FullyQualify - Convert all template arguments (of possible
+/// parent scopes) into fully qualified names.
+clang::NestedNameSpecifier *createNestedNameSpecifier(
+const clang::ASTContext , const clang::TypedefNameDecl *TD,
+bool FullyQualify);

Re: r249995 - [Sema] Allow C conversions in C overload logic

2016-01-08 Thread Bob Wilson via cfe-commits
George,

This change caused a serious regression for Objective-C method lookup. See 
PR26085 (http://llvm.org/pr26085).

For the test case in that PR, Sema::SelectBestMethod looks at the two candidate 
"test" methods. It will match the second one, but in the process of considering 
the first candidate, an error diagnostic is generated. This happens within the 
call to CheckSingleAssignmentConstraints that was added here in 
IsStandardConversion. The "Diagnose" argument in that call is set to false, but 
the diagnostic is generated anyway. For the test case in the PR, the diagnostic 
comes from CheckObjCARCConversion, but it looks like there are some other 
diagnostics that could also be generated from within 
CheckSingleAssignmentConstraints.

I think I could manage a fix, e.g., by threading the “Diagnose” flag through 
all the relevant code and consistently checking it before emitting diagnostics, 
but I’m not especially familiar with this part of clang. If you or someone else 
who knows more about this area can figure out the best way to fix it, I would 
appreciate it.

—Bob

> On Oct 11, 2015, at 1:13 PM, George Burgess IV via cfe-commits 
>  wrote:
> 
> Author: gbiv
> Date: Sun Oct 11 15:13:20 2015
> New Revision: 249995
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=249995=rev
> Log:
> [Sema] Allow C conversions in C overload logic
> 
> C allows for some implicit conversions that C++ does not, e.g. void* ->
> char*. This patch teaches clang that these conversions are okay when
> dealing with overloads in C.
> 
> Differential Revision: http://reviews.llvm.org/D13604
> 
> Modified:
>cfe/trunk/include/clang/Sema/Overload.h
>cfe/trunk/include/clang/Sema/Sema.h
>cfe/trunk/lib/Sema/SemaExpr.cpp
>cfe/trunk/lib/Sema/SemaOverload.cpp
>cfe/trunk/test/Sema/overloadable.c
> 
> Modified: cfe/trunk/include/clang/Sema/Overload.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Overload.h?rev=249995=249994=249995=diff
> ==
> --- cfe/trunk/include/clang/Sema/Overload.h (original)
> +++ cfe/trunk/include/clang/Sema/Overload.h Sun Oct 11 15:13:20 2015
> @@ -83,7 +83,8 @@ namespace clang {
> ICK_TransparentUnionConversion, ///< Transparent Union Conversions
> ICK_Writeback_Conversion,  ///< Objective-C ARC writeback conversion
> ICK_Zero_Event_Conversion, ///< Zero constant to event (OpenCL1.2 6.12.10)
> -ICK_Num_Conversion_Kinds   ///< The number of conversion kinds
> +ICK_C_Only_Conversion, ///< Conversions allowed in C, but not C++
> +ICK_Num_Conversion_Kinds,  ///< The number of conversion kinds
>   };
> 
>   /// ImplicitConversionRank - The rank of an implicit conversion
> @@ -95,7 +96,9 @@ namespace clang {
> ICR_Promotion,   ///< Promotion
> ICR_Conversion,  ///< Conversion
> ICR_Complex_Real_Conversion, ///< Complex <-> Real conversion
> -ICR_Writeback_Conversion ///< ObjC ARC writeback conversion
> +ICR_Writeback_Conversion,///< ObjC ARC writeback conversion
> +ICR_C_Conversion ///< Conversion only allowed in the C 
> standard.
> + ///  (e.g. void* to char*)
>   };
> 
>   ImplicitConversionRank GetConversionRank(ImplicitConversionKind Kind);
> 
> Modified: cfe/trunk/include/clang/Sema/Sema.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=249995=249994=249995=diff
> ==
> --- cfe/trunk/include/clang/Sema/Sema.h (original)
> +++ cfe/trunk/include/clang/Sema/Sema.h Sun Oct 11 15:13:20 2015
> @@ -8292,19 +8292,23 @@ public:
>QualType LHSType,
>QualType RHSType);
> 
> -  /// Check assignment constraints and prepare for a conversion of the
> -  /// RHS to the LHS type.
> +  /// Check assignment constraints and optionally prepare for a conversion of
> +  /// the RHS to the LHS type. The conversion is prepared for if ConvertRHS
> +  /// is true.
>   AssignConvertType CheckAssignmentConstraints(QualType LHSType,
>ExprResult ,
> -   CastKind );
> +   CastKind ,
> +   bool ConvertRHS = true);
> 
>   // CheckSingleAssignmentConstraints - Currently used by
>   // CheckAssignmentOperands, and ActOnReturnStmt. Prior to type checking,
> -  // this routine performs the default function/array converions.
> +  // this routine performs the default function/array converions, if 
> ConvertRHS
> +  // is true.
>   AssignConvertType CheckSingleAssignmentConstraints(QualType LHSType,
>  ExprResult ,
>   

Re: [PATCH] D15097: [Sema] Issue a warning for integer overflow in struct initializer

2016-01-08 Thread Vedant Kumar via cfe-commits
vsk added a subscriber: vsk.
vsk added a comment.

Looks good to me.

Caveat: This isn't quite my area. This seems reasonable given what I've read in 
`EvaluateForOverflow` and `EvaluateAsRValue`. I think you should be fine to 
commit if no one objects soon.


http://reviews.llvm.org/D15097



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


Re: [libcxx] r255177 - Remove visibility attributes from out-of-class method definitions in iostreams.

2016-01-08 Thread Nico Weber via cfe-commits
Thank you!

On Fri, Jan 8, 2016 at 2:24 PM, Evgenii Stepanov 
wrote:

> Reverted in r257193.
>
> On Fri, Jan 8, 2016 at 11:12 AM, Evgenii Stepanov
>  wrote:
> > On Fri, Jan 8, 2016 at 11:02 AM, Duncan P. N. Exon Smith
> >  wrote:
> >>
> >>> On 2016-Jan-08, at 10:49, Nico Weber via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> >>>
> >>> On OS X 10.8,
> __ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5sputcEc (and others) are
> a hidden symbol in libc++.1.dylib. This means:
> >>>
> >>> * If I use streambuf::sputc() and link against the 10.8 SDK, and the
> compiler decides to not inline the call, I will get linker errors.
> >>> * If I do the same with the 10.10 SDK when targeting 10.8, then (even
> worse) the link will silently succeed (since it links against the 10.10
> libc++ which does have a public symbol for this -- the SDK assumes that
> libc++ is abi-compatible with itself) but it will then fail to run on a
> 10.8 system.
> >>>
> >>> I don't see a way to save this change -- I think this needs to be
> reverted.
> >>
> >> FWIW, we're working on a plan to add availability markup to libc++
> >> (it shouldn't be too intrusive (since you can annotate blocks of
> >> API); had some initial talks with Marshall at the dev meeting).  I
> >> plan to send out an RFC soon.
> >>
> >> I didn't think there'd be interest in having the availability
> >> attributes themselves in open source (just some placeholder macros),
> >> but it would be an option.
> >>
> >> Anyway, until that's done, I agree this needs to be reverted.
> >>
> >>> Have you made similar changes elsewhere? These probably need to be
> reverted too.
> >>
> >> I agree.
> >
> > This is the only one of my changes that removes attributes. I'll revert.
> >
> >>> On Wed, Dec 9, 2015 at 6:42 PM, Evgeniy Stepanov via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> >>> Author: eugenis
> >>> Date: Wed Dec  9 17:42:30 2015
> >>> New Revision: 255177
> >>>
> >>> URL: http://llvm.org/viewvc/llvm-project?rev=255177=rev
> >>> Log:
> >>> Remove visibility attributes from out-of-class method definitions in
> iostreams.
> >>>
> >>> No point in pretending that these methods are hidden - they are
> >>> actually exported from libc++.so. Extern template declarations make
> >>> them part of libc++ ABI.
> >>>
> >>> This patch does not change libc++.so export list (at least on Linux).
> >>>
> >>> Modified:
> >>> libcxx/trunk/include/istream
> >>> libcxx/trunk/include/ostream
> >>> libcxx/trunk/include/sstream
> >>> libcxx/trunk/include/streambuf
> >>>
> >>> Modified: libcxx/trunk/include/istream
> >>> URL:
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/istream?rev=255177=255176=255177=diff
> >>>
> ==
> >>> --- libcxx/trunk/include/istream (original)
> >>> +++ libcxx/trunk/include/istream Wed Dec  9 17:42:30 2015
> >>> @@ -304,7 +304,7 @@ basic_istream<_CharT, _Traits>::sentry::
> >>>  }
> >>>
> >>>  template 
> >>> -inline _LIBCPP_INLINE_VISIBILITY
> >>> +inline
> >>>  basic_istream<_CharT,
> _Traits>::basic_istream(basic_streambuf* __sb)
> >>>  : __gc_(0)
> >>>  {
> >>> @@ -314,7 +314,7 @@ basic_istream<_CharT, _Traits>::basic_is
> >>>  #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
> >>>
> >>>  template 
> >>> -inline _LIBCPP_INLINE_VISIBILITY
> >>> +inline
> >>>  basic_istream<_CharT, _Traits>::basic_istream(basic_istream&& __rhs)
> >>>  : __gc_(__rhs.__gc_)
> >>>  {
> >>> @@ -323,7 +323,7 @@ basic_istream<_CharT, _Traits>::basic_is
> >>>  }
> >>>
> >>>  template 
> >>> -inline _LIBCPP_INLINE_VISIBILITY
> >>> +inline
> >>>  basic_istream<_CharT, _Traits>&
> >>>  basic_istream<_CharT, _Traits>::operator=(basic_istream&& __rhs)
> >>>  {
> >>> @@ -339,7 +339,7 @@ basic_istream<_CharT, _Traits>::~basic_i
> >>>  }
> >>>
> >>>  template 
> >>> -inline _LIBCPP_INLINE_VISIBILITY
> >>> +inline
> >>>  void
> >>>  basic_istream<_CharT, _Traits>::swap(basic_istream& __rhs)
> >>>  {
> >>> @@ -725,7 +725,7 @@ basic_istream<_CharT, _Traits>::operator
> >>>  }
> >>>
> >>>  template 
> >>> -inline _LIBCPP_INLINE_VISIBILITY
> >>> +inline
> >>>  basic_istream<_CharT, _Traits>&
> >>>  basic_istream<_CharT, _Traits>::operator>>(basic_istream&
> (*__pf)(basic_istream&))
> >>>  {
> >>> @@ -733,7 +733,7 @@ basic_istream<_CharT, _Traits>::operator
> >>>  }
> >>>
> >>>  template 
> >>> -inline _LIBCPP_INLINE_VISIBILITY
> >>> +inline
> >>>  basic_istream<_CharT, _Traits>&
> >>>  basic_istream<_CharT, _Traits>::operator>>(basic_ios traits_type>&
> >>>
>  (*__pf)(basic_ios&))
> >>> @@ -743,7 +743,7 @@ basic_istream<_CharT, _Traits>::operator
> >>>  }
> >>>
> >>>  template 
> >>> -inline _LIBCPP_INLINE_VISIBILITY
> >>> +inline
> >>>  basic_istream<_CharT, _Traits>&
> >>>  basic_istream<_CharT, _Traits>::operator>>(ios_base&
> (*__pf)(ios_base&))
> >>>  

Re: [PATCH] D15097: [Sema] Issue a warning for integer overflow in struct initializer

2016-01-08 Thread Akira Hatanaka via cfe-commits
ahatanak added a comment.

ping


http://reviews.llvm.org/D15097



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


Re: r256962 - Module debugging: Defer emitting tag types until their definition

2016-01-08 Thread David Blaikie via cfe-commits
On Fri, Jan 8, 2016 at 1:34 PM, Adrian Prantl  wrote:

>
> On Jan 8, 2016, at 1:31 PM, David Blaikie  wrote:
>
>
>
> On Wed, Jan 6, 2016 at 11:22 AM, Adrian Prantl via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: adrian
>> Date: Wed Jan  6 13:22:19 2016
>> New Revision: 256962
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=256962=rev
>> Log:
>> Module debugging: Defer emitting tag types until their definition
>> was visited and all decls have been merged.
>>
>> We only get a single chance to emit the types for virtual classes because
>> CGDebugInfo::completeRequiredType() categorically doesn't complete them.
>>
>
> Not sure I'm following this comment. Could you explain this in other
> words/detail?
>
> If we visit a declaration we shouldn't do anything, right? (no point
> putting declarations in the modules debug info, unless it's needed for
> something else?) & then when we see the definition we'd build the debug
> info for it?
>
>
> Yes. Your statement pretty much summarizes this commit :-)
>

Then I'm still confused - were we emitting type declarations in modules
prior to this change?

Perhaps a test case for a lone declaration (with no follow up definition)
would be in order, then?


>
> -- adrian
>
>
>
>>
>> Modified:
>> cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
>> cfe/trunk/test/Modules/Inputs/DebugCXX.h
>> cfe/trunk/test/Modules/ModuleDebugInfo.cpp
>>
>> Modified: cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp?rev=256962=256961=256962=diff
>>
>> ==
>> --- cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp Wed Jan  6
>> 13:22:19 2016
>> @@ -59,8 +59,10 @@ class PCHContainerGenerator : public AST
>>struct DebugTypeVisitor : public RecursiveASTVisitor
>> {
>>  clang::CodeGen::CGDebugInfo 
>>  ASTContext 
>> -DebugTypeVisitor(clang::CodeGen::CGDebugInfo , ASTContext )
>> -: DI(DI), Ctx(Ctx) {}
>> +bool SkipTagDecls;
>> +DebugTypeVisitor(clang::CodeGen::CGDebugInfo , ASTContext ,
>> + bool SkipTagDecls)
>> +: DI(DI), Ctx(Ctx), SkipTagDecls(SkipTagDecls) {}
>>
>>  /// Determine whether this type can be represented in DWARF.
>>  static bool CanRepresent(const Type *Ty) {
>> @@ -75,6 +77,12 @@ class PCHContainerGenerator : public AST
>>  }
>>
>>  bool VisitTypeDecl(TypeDecl *D) {
>> +  // TagDecls may be deferred until after all decls have been merged
>> and we
>> +  // know the complete type. Pure forward declarations will be
>> skipped, but
>> +  // they don't need to be emitted into the module anyway.
>> +  if (SkipTagDecls && isa(D))
>> +  return true;
>> +
>>QualType QualTy = Ctx.getTypeDeclType(D);
>>if (!QualTy.isNull() && CanRepresent(QualTy.getTypePtr()))
>>  DI.getOrCreateStandaloneType(QualTy, D->getLocation());
>> @@ -165,7 +173,7 @@ public:
>>  // Collect debug info for all decls in this group.
>>  for (auto *I : D)
>>if (!I->isFromASTFile()) {
>> -DebugTypeVisitor DTV(*Builder->getModuleDebugInfo(), *Ctx);
>> +DebugTypeVisitor DTV(*Builder->getModuleDebugInfo(), *Ctx, true);
>>  DTV.TraverseDecl(I);
>>}
>>  return true;
>> @@ -179,6 +187,11 @@ public:
>>  if (Diags.hasErrorOccurred())
>>return;
>>
>> +if (D->isFromASTFile())
>> +  return;
>> +
>> +DebugTypeVisitor DTV(*Builder->getModuleDebugInfo(), *Ctx, false);
>> +DTV.TraverseDecl(D);
>>  Builder->UpdateCompletedType(D);
>>}
>>
>>
>> Modified: cfe/trunk/test/Modules/Inputs/DebugCXX.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/DebugCXX.h?rev=256962=256961=256962=diff
>>
>> ==
>> --- cfe/trunk/test/Modules/Inputs/DebugCXX.h (original)
>> +++ cfe/trunk/test/Modules/Inputs/DebugCXX.h Wed Jan  6 13:22:19 2016
>> @@ -50,3 +50,9 @@ namespace DebugCXX {
>>typedef A B;
>>void foo(B) {}
>>  }
>> +
>> +// Virtual class with a forward declaration.
>> +class FwdVirtual;
>> +class FwdVirtual {
>> +  virtual ~FwdVirtual() {}
>> +};
>>
>> Modified: cfe/trunk/test/Modules/ModuleDebugInfo.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ModuleDebugInfo.cpp?rev=256962=256961=256962=diff
>>
>> ==
>> --- cfe/trunk/test/Modules/ModuleDebugInfo.cpp (original)
>> +++ cfe/trunk/test/Modules/ModuleDebugInfo.cpp Wed Jan  6 13:22:19 2016
>> @@ -7,13 +7,11 @@
>>  // RUN: rm -rf %t
>>  // RUN: %clang_cc1 -triple %itanium_abi_triple -x objective-c++
>> -std=c++11 

Re: [PATCH] D15911: Move ownership of Action objects into Compilation.

2016-01-08 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 44379.
jlebar marked 4 inline comments as done.
jlebar added a comment.

Address tra and dblaikie's review comments.


http://reviews.llvm.org/D15911

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

Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1049,19 +1049,15 @@
   << types::getTypeName(Act->getType());
 
 ActionList Inputs;
-for (unsigned i = 0, e = Archs.size(); i != e; ++i) {
-  Inputs.push_back(
-  new BindArchAction(std::unique_ptr(Act), Archs[i]));
-  if (i != 0)
-Inputs.back()->setOwnsInputs(false);
-}
+for (unsigned i = 0, e = Archs.size(); i != e; ++i)
+  Inputs.push_back(C.MakeAction(Act, Archs[i]));
 
 // Lipo if necessary, we do it this way because we need to set the arch flag
 // so that -Xarch_ gets overwritten.
 if (Inputs.size() == 1 || Act->getType() == types::TY_Nothing)
   Actions.append(Inputs.begin(), Inputs.end());
 else
-  Actions.push_back(new LipoJobAction(Inputs, Act->getType()));
+  Actions.push_back(C.MakeAction(Inputs, Act->getType()));
 
 // Handle debug info queries.
 Arg *A = Args.getLastArg(options::OPT_g_Group);
@@ -1077,15 +1073,16 @@
 ActionList Inputs;
 Inputs.push_back(Actions.back());
 Actions.pop_back();
-Actions.push_back(new DsymutilJobAction(Inputs, types::TY_dSYM));
+Actions.push_back(
+C.MakeAction(Inputs, types::TY_dSYM));
   }
 
   // Verify the debug info output.
   if (Args.hasArg(options::OPT_verify_debug_info)) {
-std::unique_ptr VerifyInput(Actions.back());
+Action* LastAction = Actions.back();
 Actions.pop_back();
-Actions.push_back(new VerifyDebugInfoJobAction(std::move(VerifyInput),
-   types::TY_Nothing));
+Actions.push_back(C.MakeAction(
+LastAction, types::TY_Nothing));
   }
 }
   }
@@ -1283,16 +1280,15 @@
 // Actions and /p Current is released. Otherwise the function creates
 // and returns a new CudaHostAction which wraps /p Current and device
 // side actions.
-static std::unique_ptr
-buildCudaActions(Compilation , DerivedArgList , const Arg *InputArg,
- std::unique_ptr HostAction, ActionList ) {
+static Action *buildCudaActions(Compilation , DerivedArgList ,
+const Arg *InputArg, Action *HostAction,
+ActionList ) {
   Arg *PartialCompilationArg = Args.getLastArg(options::OPT_cuda_host_only,
options::OPT_cuda_device_only);
   // Host-only compilation case.
   if (PartialCompilationArg &&
   PartialCompilationArg->getOption().matches(options::OPT_cuda_host_only))
-return std::unique_ptr(
-new CudaHostAction(std::move(HostAction), {}));
+return C.MakeAction(HostAction, ActionList());
 
   // Collect all cuda_gpu_arch parameters, removing duplicates.
   SmallVector GpuArchList;
@@ -1347,26 +1343,25 @@
 }
 
 for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I)
-  Actions.push_back(new CudaDeviceAction(
-  std::unique_ptr(CudaDeviceActions[I]), GpuArchList[I],
-  /* AtTopLevel */ true));
+  Actions.push_back(C.MakeAction(CudaDeviceActions[I],
+   GpuArchList[I],
+   /* AtTopLevel */ true));
 // Kill host action in case of device-only compilation.
 if (DeviceOnlyCompilation)
-  HostAction.reset(nullptr);
+  return nullptr;
 return HostAction;
   }
 
   // Outputs of device actions during complete CUDA compilation get created
   // with AtTopLevel=false and become inputs for the host action.
   ActionList DeviceActions;
   for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I)
-DeviceActions.push_back(new CudaDeviceAction(
-std::unique_ptr(CudaDeviceActions[I]), GpuArchList[I],
-/* AtTopLevel */ false));
+DeviceActions.push_back(
+C.MakeAction(CudaDeviceActions[I], GpuArchList[I],
+   /* AtTopLevel */ false));
   // Return a new host action that incorporates original host action and all
   // device actions.
-  return std::unique_ptr(
-  new CudaHostAction(std::move(HostAction), DeviceActions));
+  return C.MakeAction(HostAction, DeviceActions);
 }
 
 void Driver::BuildActions(Compilation , const ToolChain ,
@@ -1474,7 +1469,7 @@
 : FinalPhase;
 
 // Build the pipeline for this file.
-std::unique_ptr Current(new InputAction(*InputArg, InputType));
+Action *Current = C.MakeAction(*InputArg, InputType);
 for 

Re: [PATCH] D15911: Move ownership of Action objects into Compilation.

2016-01-08 Thread Justin Lebar via cfe-commits
jlebar added inline comments.


Comment at: include/clang/Driver/Action.h:36
@@ -35,1 +35,3 @@
+///
+/// Actions are usually owned by a Compilation.
 class Action {

tra wrote:
> There's no API to pass ownership to Compilation explicitly, so the only way 
> for an Action to be owned by Compilation is to create it with MakeAction. 
> 
> Perhaps "Actions created with MakeAction<>() are owned by Compilation"
> 
> BTW, should we (can we?) make MakeAction<>() the only way to create actions?
Updated the comment.


Comment at: include/clang/Driver/Compilation.h:118
@@ +117,3 @@
+  template  T *MakeAction(Args &&... Arg) {
+static_assert(std::is_convertible::value,
+  "T must be derived from Action.");

dblaikie wrote:
> Did you find this static_assert to be particularly helpful? Similar errors 
> (though somewhat more verbose) would be produced during the push_back call a 
> few lines down anyway.
Fair enough.  I got rid of it but changed my unique_ptr into a 
unique_ptr so that we'll get an error somewhere other than inside the 
bowels of SmallVector.


Comment at: include/clang/Driver/Compilation.h:120
@@ +119,3 @@
+  "T must be derived from Action.");
+std::unique_ptr A = llvm::make_unique(std::forward(Arg)...);
+T* RawPtr = A.get();

dblaikie wrote:
> Up to you, but we usually just drop the "std::unique_ptr" in favor of 
> "auto" when the RHS has "make_unique".
Done, but then I realized I can just use operator new and skirt this entirely.


http://reviews.llvm.org/D15911



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


Re: r252114 - [modules] If we're given a module file, via -fmodule-file=, for a module, but

2016-01-08 Thread Adrian Prantl via cfe-commits
Hi Richard,

This change 
> @@ -2239,16 +2240,21 @@ ASTReader::ReadControlBlock(ModuleFile ,
[...]
> -  if (!DisableValidation && Result != Success &&
> -  (Result != ConfigurationMismatch || 
> !AllowConfigurationMismatch))
> +  if (DisableValidation ||
> +  (AllowConfigurationMismatch && Result == 
> ConfigurationMismatch))
> +Result = Success;
> +
> +  // If we've diagnosed a problem, we're done.
> +  if (Result != Success &&
> +  isDiagnosedResult(Result, ClientLoadCapabilities))
>  return Result;

either causes or uncovers a bug:

> CC=/Volumes/Data/llvm/_build.ninja.debug/bin/clang # r256948
> rm -rf cache && mkdir cache
> rm -rf Test && mkdir Test
> echo 'module Test {
>   umbrella header "Test.h"
> }' >Test/module.modulemap
> touch Test/Test.h
> echo '#import '>2.m
> 
> clang -x objective-c -fmodules -fmodules-cache-path=cache  -DA=0 -I. -c 2.m 
> -o 1.o
> clang -x objective-c -fmodules -fmodules-cache-path=cache -Werror -DA=0 -I. 
> -c 2.m -o 2.o
> 


After encountering a configuration mismatch or out-of-date error, we now 
continue instead of returning early and subsequently crash in

  ASTReader::ReadControlBlock()
ASTReader::getInputFile()
  Cursor.JumpToBit(F.InputFileOffsets[ID-1]);

I’ll keep digging deeper, but I thought you may have an intuition of what’s 
going on here.
Is the behavior change intentional? From the commit message it sounds as if 
implicit module builds shouldn’t be affected.

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


Re: r256049 - Split RequireCompleteType into a function that actually requires that the type

2016-01-08 Thread Richard Smith via cfe-commits
On Thu, Jan 7, 2016 at 6:00 PM, David Blaikie  wrote:

> On Fri, Dec 18, 2015 at 2:40 PM, Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rsmith
>> Date: Fri Dec 18 16:40:25 2015
>> New Revision: 256049
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=256049=rev
>> Log:
>> Split RequireCompleteType into a function that actually requires that the
>> type
>> is complete (with an error produced if not) and a function that merely
>> queries
>> whether the type is complete. Either way we'll trigger instantiation if
>> necessary, but only the former will diagnose and recover from missing
>> module
>> imports.
>>
>> The intent of this change is to prevent a class of bugs where code would
>> call
>> RequireCompleteType(..., 0) and then ignore the result. With modules, we
>> must
>> check the return value and use it to determine whether the definition of
>> the
>> type is visible.
>>
>> This also fixes a debug info quality issue: calls to isCompleteType do not
>> trigger the emission of debug information for a type in limited-debug-info
>> mode. This allows us to avoid emitting debug information for type
>> definitions
>> in more cases where we believe it is safe to do so.
>>
>
> Thanks for mentioning - I was wondering if that was the case.
>
> Do you have a canonical example where we previously required the type to
> be complete, but we now only query it?
>

The example in test/CodeGenCXX/debug-info-limited.cpp is probably as good
as any. I regressed that one a while back while fixing an ADL bug and it's
now doing the right thing again.


> Modified:
>> cfe/trunk/include/clang/Sema/Sema.h
>> cfe/trunk/lib/Sema/SemaCast.cpp
>> cfe/trunk/lib/Sema/SemaCodeComplete.cpp
>> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>> cfe/trunk/lib/Sema/SemaDeclObjC.cpp
>> cfe/trunk/lib/Sema/SemaExpr.cpp
>> cfe/trunk/lib/Sema/SemaExprCXX.cpp
>> cfe/trunk/lib/Sema/SemaExprObjC.cpp
>> cfe/trunk/lib/Sema/SemaInit.cpp
>> cfe/trunk/lib/Sema/SemaLookup.cpp
>> cfe/trunk/lib/Sema/SemaOverload.cpp
>> cfe/trunk/lib/Sema/SemaStmt.cpp
>> cfe/trunk/lib/Sema/SemaStmtAsm.cpp
>> cfe/trunk/lib/Sema/SemaTemplate.cpp
>> cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
>> cfe/trunk/lib/Sema/SemaType.cpp
>> cfe/trunk/test/CodeGenCXX/debug-info-limited.cpp
>>
>> Modified: cfe/trunk/include/clang/Sema/Sema.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=256049=256048=256049=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Sema/Sema.h (original)
>> +++ cfe/trunk/include/clang/Sema/Sema.h Fri Dec 18 16:40:25 2015
>> @@ -1316,9 +1316,7 @@ public:
>>
>>/// \brief Abstract class used to diagnose incomplete types.
>>struct TypeDiagnoser {
>> -bool Suppressed;
>> -
>> -TypeDiagnoser(bool Suppressed = false) : Suppressed(Suppressed) { }
>> +TypeDiagnoser() {}
>>
>>  virtual void diagnose(Sema , SourceLocation Loc, QualType T) = 0;
>>  virtual ~TypeDiagnoser() {}
>> @@ -1354,11 +1352,11 @@ public:
>>
>>public:
>>  BoundTypeDiagnoser(unsigned DiagID, const Ts &...Args)
>> -: TypeDiagnoser(DiagID == 0), DiagID(DiagID), Args(Args...) {}
>> +: TypeDiagnoser(), DiagID(DiagID), Args(Args...) {
>> +  assert(DiagID != 0 && "no diagnostic for type diagnoser");
>> +}
>>
>>  void diagnose(Sema , SourceLocation Loc, QualType T) override {
>> -  if (Suppressed)
>> -return;
>>const SemaDiagnosticBuilder  = S.Diag(Loc, DiagID);
>>emit(DB, llvm::index_sequence_for());
>>DB << T;
>> @@ -1367,7 +1365,7 @@ public:
>>
>>  private:
>>bool RequireCompleteTypeImpl(SourceLocation Loc, QualType T,
>> -   TypeDiagnoser );
>> +   TypeDiagnoser *Diagnoser);
>>
>>VisibleModuleSet VisibleModules;
>>llvm::SmallVector VisibleModulesStack;
>> @@ -1413,6 +1411,9 @@ public:
>>SourceLocation Loc, const NamedDecl *D,
>>ArrayRef Equiv);
>>
>> +  bool isCompleteType(SourceLocation Loc, QualType T) {
>> +return !RequireCompleteTypeImpl(Loc, T, nullptr);
>> +  }
>>bool RequireCompleteType(SourceLocation Loc, QualType T,
>> TypeDiagnoser );
>>bool RequireCompleteType(SourceLocation Loc, QualType T,
>> @@ -5502,6 +5503,7 @@ public:
>>  AbstractArrayType
>>};
>>
>> +  bool isAbstractType(SourceLocation Loc, QualType T);
>>bool RequireNonAbstractType(SourceLocation Loc, QualType T,
>>TypeDiagnoser );
>>template 
>> @@ -5513,9 +5515,6 @@ public:
>>
>>void DiagnoseAbstractType(const CXXRecordDecl *RD);
>>
>> -  bool RequireNonAbstractType(SourceLocation Loc, QualType T, unsigned
>> DiagID,
>> -  AbstractDiagSelID SelID = AbstractNone);
>> -
>>
>>  
>> 

Re: [libcxx] r196411 - Give all members of exception types default visibility. Lack of this is causing some illegal code relocations rare and hard to reproduce cases.

2016-01-08 Thread Duncan P. N. Exon Smith via cfe-commits
[re-send to lists.llvm.org]
[necromancy]

This is causing some strangeness for users of libc++ headers that
ship dylibs and build with -fno-rtti and -fvisibility=hidden.

Strangely, -fno-rtti does *not* imply -fno-exceptions; the type info
needed for exceptions is generated on-the-fly.  This means that each
translation unit generates a linkonce_odr copy of the std::exception
type info -- weird, but kind of reasonable?

Because of this commit, the (non-canonical) type info from these
other dylibs is getting exported, even though they compile with
-fvisibility=hidden.  On Darwin, this means that a link line like
this:
--
$ ld -o a.out a.o -library-without-rtti -lc++
--
will find the type info in libibrary-without-rtti.dylib instead of
libc++.1.dylib.  That doesn't seem reasonable.

The request I've had from such dylib owners is to effectively revert
this commit, so that their copy of std::exception type info isn't
exported when they use -fvisibility=hidden.  However, then their
copy of the type info won't get coalesced with libc++.1.dylib's.

Does anyone have an opinion on this?  Should we care about the
visibility of std::exception type info when -fno-rtti?  (Note that
when RTTI is on, clang correctly does not generate the type info
for std::exception and friends.)

Howard, any chance you remember more about the problems this fixed?

> On 2013-Dec-04, at 13:03, Howard Hinnant  wrote:
> 
> Author: hhinnant
> Date: Wed Dec  4 15:03:23 2013
> New Revision: 196411
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=196411=rev
> Log:
> Give all members of exception types default visibility.  Lack of this is 
> causing some illegal code relocations rare and hard to reproduce cases.
> 
> Modified:
>   libcxx/trunk/include/__config
> 
> Modified: libcxx/trunk/include/__config
> URL: 
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=196411=196410=196411=diff
> ==
> --- libcxx/trunk/include/__config (original)
> +++ libcxx/trunk/include/__config Wed Dec  4 15:03:23 2013
> @@ -194,7 +194,7 @@
> #endif
> 
> #ifndef _LIBCPP_EXCEPTION_ABI
> -#define _LIBCPP_EXCEPTION_ABI _LIBCPP_TYPE_VIS
> +#define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default")))
> #endif
> 
> #ifndef _LIBCPP_ALWAYS_INLINE
> 
> 
> ___
> cfe-commits mailing list
> cfe-comm...@cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits


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


r257240 - Only take NULL macros instead of all macros into account for -Wnull-conversion.

2016-01-08 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Jan  8 19:10:17 2016
New Revision: 257240

URL: http://llvm.org/viewvc/llvm-project?rev=257240=rev
Log:
Only take NULL macros instead of all macros into account for -Wnull-conversion.

Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/SemaCXX/conversion.cpp

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=257240=257239=257240=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri Jan  8 19:10:17 2016
@@ -7066,8 +7066,12 @@ static void DiagnoseNullConversion(Sema
 
   // __null is usually wrapped in a macro.  Go up a macro if that is the case.
   if (NullKind == Expr::NPCK_GNUNull) {
-if (Loc.isMacroID())
-  Loc = S.SourceMgr.getImmediateExpansionRange(Loc).first;
+if (Loc.isMacroID()) {
+  StringRef MacroName =
+  Lexer::getImmediateMacroName(Loc, S.SourceMgr, S.getLangOpts());
+  if (MacroName == "NULL")
+Loc = S.SourceMgr.getImmediateExpansionRange(Loc).first;
+}
   }
 
   // Only warn if the null and context location are in the same macro 
expansion.

Modified: cfe/trunk/test/SemaCXX/conversion.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/conversion.cpp?rev=257240=257239=257240=diff
==
--- cfe/trunk/test/SemaCXX/conversion.cpp (original)
+++ cfe/trunk/test/SemaCXX/conversion.cpp Fri Jan  8 19:10:17 2016
@@ -208,3 +208,23 @@ namespace test9 {
 return EXIT();
   }
 }
+
+// Test NULL macro inside a macro has same warnings nullptr inside a macro.
+namespace test10 {
+#define test1(cond) \
+  ((cond) ? nullptr : NULL)
+#define test2(cond) \
+  ((cond) ? NULL : nullptr)
+
+#define assert(cond) \
+  ((cond) ? foo() : bar())
+  void foo();
+  void bar();
+
+  void run(int x) {
+if (test1(x)) {}
+if (test2(x)) {}
+assert(test1(x));
+assert(test2(x));
+  }
+}


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


Lit Test C++11 Compatibility Patch #7

2016-01-08 Thread Li, Charles via cfe-commits
Hi Everyone,


I am back again with another Lit test C++11 patch.
This is the 7th patch.
There are 13 tests in total.

CXX/class.access/class.access.dcl/p1.cpp
  Access declarations are deprecated in C++11.
  As a result, there are 4 types of diagnostics changes:

  For simple access declarations, there is a change in diagnostics.
C++98: warning: access declarations are deprecated; use using declarations 
instead
C++11: error: ISO C++11 does not allow access declarations; use using 
declarations instead

  For Self-referential access declarations, there is also an additional error 
message.
C++98: warning: access declarations are deprecated; use using declarations 
instead
C++11: error: ISO C++11 does not allow access declarations; use using 
declarations instead
C++11: error: using declaration refers to its own class

  For an access declaration of a non-base method, there is a different 
additional error message.
C++98: warning: access declarations are deprecated; use using declarations 
instead
C++11: error: ISO C++11 does not allow access declarations; use using 
declarations instead
C++11: error: using declaration refers into 'Subclass::', which is not a 
base class of 'C'

  For self-referential access declaration with local declaration, there is the 
additional error message but one less note message.
C++98: warning: access declarations are deprecated; use using declarations 
instead [-Wdeprecated]
C++98: error: using declaration refers to its own class
C++98: note: target of using declaration
C++11: error: ISO C++11 does not allow access declarations; use using 
declarations instead
C++11: error: using declaration refers to its own class

CXX/temp/temp.spec/temp.expl.spec/p2.cpp
  Guard multiple instances of the following diagnostics to C++98.
C++98: warning: first declaration of function template specialization of 
'f0' outside namespace 'N0' is a C++11 extension
C++98: note: explicitly specialized declaration is here

CXX/temp/temp.spec/temp.expl.spec/p3.cpp
  Guard one instance of the following diagnostics to C++98.
C++98: warning: first declaration of class template specialization of 'X' 
outside namespace 'N' is a C++11 extension
C++98: note: explicitly specialized declaration is here

CXX/temp/temp.spec/temp.explicit/p2.cpp
CXX/temp/temp.spec/temp.explicit/p5.cpp
  In C++98 with -Wc++11-compat, Out-of-scope explicit instantiations of 
template is a Warning.
  In C++11, it is now an Error.
C++98: warning: explicit instantiation of 'N::f1' must occur in namespace 
'N'
C++11: error: explicit instantiation of 'N::f1' must occur in namespace 'N'

CodeGenCXX/debug-info-static-member.cpp
  In C++11, replace "const" with "constexpr" for in-class static initializer of 
non-integral type.
  Otherwise compiler would complain:
C++11: error: in-class initializer for static data member of type 'const 
float' requires 'constexpr' specifier

SemaCXX/dcl_init_aggr.cpp
  Diagnostic change due to initializer list
C++98: error: non-aggregate type 'NonAggregate' cannot be initialized with 
an initializer list
C++11: error no matching constructor for initialization of 'NonAggregate'
   note: candidate constructor (the implicit copy constructor) not 
viable
   note: candidate constructor (the implicit move constructor) not 
viable
   note: candidate constructor not viable

  Diagnostic Change
C++98: conversion from string literal to 'char *' is deprecated
C++11: ISO C++11 does not allow conversion from string literal to 'char *'

  Addition C++11 move constructor diagnostics
C++11: note: candidate constructor (the implicit move constructor) not 
viable

  The next 2 lines caused a lot of diff.
Source: TooFewError too_few_error = { 1 }
C++98: error: no matching constructor for initialization of 
'NoDefaultConstructor'
   note: candidate constructor not viable: requires 1 argument, but 0 
were provided
   note: candidate constructor (the implicit copy constructor) not 
viable
   note: in implicit initialization of field 'nodef' with omitted 
initializer
   error: implicit default constructor for 'TooFewError' must 
explicitly initialize
  the member 'nodef' which does not have a default constructor
   note: member is declared here
   note: 'NoDefaultConstructor' declared here

C++11: error: no matching constructor for initialization of 
'NoDefaultConstructor'
   note: candidate constructor not viable: requires 1 argument, but 0 
were provided
   note: candidate constructor (the implicit copy constructor) not 
viable
   note: candidate constructor (the implicit move constructor) not 
viable
   note: in implicit initialization of field 'nodef' with omitted 
initializer

Source: TooFewError too_few_okay2[2] = { 1, 1 };
C++98: note: implicit default constructor for 'TooFewError' first 

Re: [libcxx] Reinstate and fix overload sets to be const-correct wherever possible

2016-01-08 Thread Richard Smith via cfe-commits
Ping, is this OK to commit?

On Thu, Dec 10, 2015 at 3:32 PM, Richard Smith 
wrote:

> On Thu, Dec 10, 2015 at 11:45 AM, Marshall Clow 
> wrote:
>
>> On Tue, Dec 8, 2015 at 3:52 PM, Richard Smith 
>>> wrote:
>>>
 Ping.

>>>
>> Sorry about that.
>> Completely missed this in my email flood.
>>
>> This approach looks ok to me, but I wonder if it would be better to get
>> Apple to fix their iOS C library instead.
>>
>
> Well, it's not broken in the sense that it does what the C standard
> library is supposed to do. But it's not providing the "C pieces" of a C++
> standard library. I don't know what its design goal is here, but with this
> patch we don't need to care.
>
> Duncan offered to file a bug on this, but I don't know if that's happened.
>
> Are there other broken C libraries that we are concerned with?
>>
>
> Probably :) I don't know the complete set of C standard library
> implementations that people use with libc++, but I'd be surprised if Darwin
> were the only case we need to fix.
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] Reinstate and fix overload sets to be const-correct wherever possible

2016-01-08 Thread Duncan P. N. Exon Smith via cfe-commits
No one is waiting for me on this, are they?  FWIW, this seems like
a good solution to me.  I'll see what I can do internally (I filed
a radar), but other platforms will likely need this anyway.

> On 2016-Jan-08, at 16:06, Richard Smith  wrote:
> 
> Ping, is this OK to commit?
> 
> On Thu, Dec 10, 2015 at 3:32 PM, Richard Smith  wrote:
> On Thu, Dec 10, 2015 at 11:45 AM, Marshall Clow  wrote:
> On Tue, Dec 8, 2015 at 3:52 PM, Richard Smith  wrote:
> Ping.
> 
> Sorry about that.
> Completely missed this in my email flood.
> 
> This approach looks ok to me, but I wonder if it would be better to get Apple 
> to fix their iOS C library instead.
> 
> Well, it's not broken in the sense that it does what the C standard library 
> is supposed to do. But it's not providing the "C pieces" of a C++ standard 
> library. I don't know what its design goal is here, but with this patch we 
> don't need to care.
> 
> Duncan offered to file a bug on this, but I don't know if that's happened.
> 
> Are there other broken C libraries that we are concerned with?
> 
> Probably :) I don't know the complete set of C standard library 
> implementations that people use with libc++, but I'd be surprised if Darwin 
> were the only case we need to fix.
> 

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


Re: [libcxx] r196411 - Give all members of exception types default visibility. Lack of this is causing some illegal code relocations rare and hard to reproduce cases.

2016-01-08 Thread Howard Hinnant via cfe-commits
On Jan 8, 2016, at 7:50 PM, Duncan P. N. Exon Smith  
wrote:
> 
> [re-send to lists.llvm.org]
> [necromancy]
> 
> This is causing some strangeness for users of libc++ headers that
> ship dylibs and build with -fno-rtti and -fvisibility=hidden.
> 
> Strangely, -fno-rtti does *not* imply -fno-exceptions; the type info
> needed for exceptions is generated on-the-fly.  This means that each
> translation unit generates a linkonce_odr copy of the std::exception
> type info -- weird, but kind of reasonable?
> 
> Because of this commit, the (non-canonical) type info from these
> other dylibs is getting exported, even though they compile with
> -fvisibility=hidden.  On Darwin, this means that a link line like
> this:
> --
> $ ld -o a.out a.o -library-without-rtti -lc++
> --
> will find the type info in libibrary-without-rtti.dylib instead of
> libc++.1.dylib.  That doesn't seem reasonable.
> 
> The request I've had from such dylib owners is to effectively revert
> this commit, so that their copy of std::exception type info isn't
> exported when they use -fvisibility=hidden.  However, then their
> copy of the type info won't get coalesced with libc++.1.dylib's.
> 
> Does anyone have an opinion on this?  Should we care about the
> visibility of std::exception type info when -fno-rtti?  (Note that
> when RTTI is on, clang correctly does not generate the type info
> for std::exception and friends.)
> 
> Howard, any chance you remember more about the problems this fixed?

Sorry, nope.

I have no opinion on this.  The only thing I would have to say in this area is 
that if Nick says it, you can take it to the bank.

Howard

> 
>> On 2013-Dec-04, at 13:03, Howard Hinnant  wrote:
>> 
>> Author: hhinnant
>> Date: Wed Dec  4 15:03:23 2013
>> New Revision: 196411
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=196411=rev
>> Log:
>> Give all members of exception types default visibility.  Lack of this is 
>> causing some illegal code relocations rare and hard to reproduce cases.
>> 
>> Modified:
>>  libcxx/trunk/include/__config
>> 
>> Modified: libcxx/trunk/include/__config
>> URL: 
>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=196411=196410=196411=diff
>> ==
>> --- libcxx/trunk/include/__config (original)
>> +++ libcxx/trunk/include/__config Wed Dec  4 15:03:23 2013
>> @@ -194,7 +194,7 @@
>> #endif
>> 
>> #ifndef _LIBCPP_EXCEPTION_ABI
>> -#define _LIBCPP_EXCEPTION_ABI _LIBCPP_TYPE_VIS
>> +#define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default")))
>> #endif
>> 
>> #ifndef _LIBCPP_ALWAYS_INLINE
>> 
>> 
>> ___
>> cfe-commits mailing list
>> cfe-comm...@cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
> 
> 

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


Re: r256962 - Module debugging: Defer emitting tag types until their definition

2016-01-08 Thread Adrian Prantl via cfe-commits

> On Jan 8, 2016, at 2:18 PM, Adrian Prantl via cfe-commits 
>  wrote:
> 
>> 
>> On Jan 8, 2016, at 1:59 PM, David Blaikie  wrote:
>> 
>> 
>> 
>> On Fri, Jan 8, 2016 at 1:34 PM, Adrian Prantl  wrote:
>> 
>>> On Jan 8, 2016, at 1:31 PM, David Blaikie  wrote:
>>> 
>>> 
>>> 
>>> On Wed, Jan 6, 2016 at 11:22 AM, Adrian Prantl via cfe-commits 
>>>  wrote:
>>> Author: adrian
>>> Date: Wed Jan  6 13:22:19 2016
>>> New Revision: 256962
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=256962=rev
>>> Log:
>>> Module debugging: Defer emitting tag types until their definition
>>> was visited and all decls have been merged.
>>> 
>>> We only get a single chance to emit the types for virtual classes because
>>> CGDebugInfo::completeRequiredType() categorically doesn't complete them.
>>> 
>>> Not sure I'm following this comment. Could you explain this in other 
>>> words/detail?
>>> 
>>> If we visit a declaration we shouldn't do anything, right? (no point 
>>> putting declarations in the modules debug info, unless it's needed for 
>>> something else?) & then when we see the definition we'd build the debug 
>>> info for it?
>> 
>> Yes. Your statement pretty much summarizes this commit :-)
>> 
>> Then I'm still confused - were we emitting type declarations in modules 
>> prior to this change?
> 
> Yes. Dsymutil used to expect every forward declaration in a skeleton CU to 
> have a corresponding declaration in the module dwo. I just verified that 
> dsymutil does no longer prune forward declarations from skeleton CUs that 
> don’t have a definition in the DWO, so everything should be fine now.
> 
>> Perhaps a test case for a lone declaration (with no follow up definition) 
>> would be in order, then?
> 
> Yes, that would make sense. I’ll add one.

Done in r257241.
-- adrian
>  
>> 
>> -- adrian
>> 
>>>  
>>> 
>>> Modified:
>>> cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
>>> cfe/trunk/test/Modules/Inputs/DebugCXX.h
>>> cfe/trunk/test/Modules/ModuleDebugInfo.cpp
>>> 
>>> Modified: cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp?rev=256962=256961=256962=diff
>>> ==
>>> --- cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp (original)
>>> +++ cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp Wed Jan  6 
>>> 13:22:19 2016
>>> @@ -59,8 +59,10 @@ class PCHContainerGenerator : public AST
>>>struct DebugTypeVisitor : public RecursiveASTVisitor {
>>>  clang::CodeGen::CGDebugInfo 
>>>  ASTContext 
>>> -DebugTypeVisitor(clang::CodeGen::CGDebugInfo , ASTContext )
>>> -: DI(DI), Ctx(Ctx) {}
>>> +bool SkipTagDecls;
>>> +DebugTypeVisitor(clang::CodeGen::CGDebugInfo , ASTContext ,
>>> + bool SkipTagDecls)
>>> +: DI(DI), Ctx(Ctx), SkipTagDecls(SkipTagDecls) {}
>>> 
>>>  /// Determine whether this type can be represented in DWARF.
>>>  static bool CanRepresent(const Type *Ty) {
>>> @@ -75,6 +77,12 @@ class PCHContainerGenerator : public AST
>>>  }
>>> 
>>>  bool VisitTypeDecl(TypeDecl *D) {
>>> +  // TagDecls may be deferred until after all decls have been merged 
>>> and we
>>> +  // know the complete type. Pure forward declarations will be 
>>> skipped, but
>>> +  // they don't need to be emitted into the module anyway.
>>> +  if (SkipTagDecls && isa(D))
>>> +  return true;
>>> +
>>>QualType QualTy = Ctx.getTypeDeclType(D);
>>>if (!QualTy.isNull() && CanRepresent(QualTy.getTypePtr()))
>>>  DI.getOrCreateStandaloneType(QualTy, D->getLocation());
>>> @@ -165,7 +173,7 @@ public:
>>>  // Collect debug info for all decls in this group.
>>>  for (auto *I : D)
>>>if (!I->isFromASTFile()) {
>>> -DebugTypeVisitor DTV(*Builder->getModuleDebugInfo(), *Ctx);
>>> +DebugTypeVisitor DTV(*Builder->getModuleDebugInfo(), *Ctx, true);
>>>  DTV.TraverseDecl(I);
>>>}
>>>  return true;
>>> @@ -179,6 +187,11 @@ public:
>>>  if (Diags.hasErrorOccurred())
>>>return;
>>> 
>>> +if (D->isFromASTFile())
>>> +  return;
>>> +
>>> +DebugTypeVisitor DTV(*Builder->getModuleDebugInfo(), *Ctx, false);
>>> +DTV.TraverseDecl(D);
>>>  Builder->UpdateCompletedType(D);
>>>}
>>> 
>>> 
>>> Modified: cfe/trunk/test/Modules/Inputs/DebugCXX.h
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/DebugCXX.h?rev=256962=256961=256962=diff
>>> ==
>>> --- cfe/trunk/test/Modules/Inputs/DebugCXX.h (original)
>>> +++ cfe/trunk/test/Modules/Inputs/DebugCXX.h Wed Jan  6 13:22:19 2016
>>> @@ -50,3 +50,9 @@ namespace DebugCXX {
>>>

r257241 - Module debugging: Add a testcase for standalone forward declarations.

2016-01-08 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Fri Jan  8 19:11:35 2016
New Revision: 257241

URL: http://llvm.org/viewvc/llvm-project?rev=257241=rev
Log:
Module debugging: Add a testcase for standalone forward declarations.

Modified:
cfe/trunk/test/Modules/Inputs/DebugCXX.h
cfe/trunk/test/Modules/ModuleDebugInfo.cpp

Modified: cfe/trunk/test/Modules/Inputs/DebugCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/DebugCXX.h?rev=257241=257240=257241=diff
==
--- cfe/trunk/test/Modules/Inputs/DebugCXX.h (original)
+++ cfe/trunk/test/Modules/Inputs/DebugCXX.h Fri Jan  8 19:11:35 2016
@@ -56,3 +56,5 @@ class FwdVirtual;
 class FwdVirtual {
   virtual ~FwdVirtual() {}
 };
+
+struct PureForwardDecl;

Modified: cfe/trunk/test/Modules/ModuleDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ModuleDebugInfo.cpp?rev=257241=257240=257241=diff
==
--- cfe/trunk/test/Modules/ModuleDebugInfo.cpp (original)
+++ cfe/trunk/test/Modules/ModuleDebugInfo.cpp Fri Jan  8 19:11:35 2016
@@ -7,11 +7,13 @@
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -triple %itanium_abi_triple -x objective-c++ -std=c++11 
-debug-info-kind=limited -fmodules -fmodule-format=obj -fimplicit-module-maps 
-DMODULES -fmodules-cache-path=%t %s -I %S/Inputs -I %t -emit-llvm -o %t.ll 
-mllvm -debug-only=pchcontainer &>%t-mod.ll
 // RUN: cat %t-mod.ll | FileCheck %s
+// RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-NEG %s
 // RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-DWO %s
 
 // PCH:
 // RUN: %clang_cc1 -triple %itanium_abi_triple -x c++ -std=c++11 -emit-pch 
-fmodule-format=obj -I %S/Inputs -o %t.pch %S/Inputs/DebugCXX.h -mllvm 
-debug-only=pchcontainer &>%t-pch.ll
 // RUN: cat %t-pch.ll | FileCheck %s
+// RUN: cat %t-pch.ll | FileCheck --check-prefix=CHECK-NEG %s
 
 #ifdef MODULES
 @import DebugCXX;
@@ -50,3 +52,5 @@
 
 // CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "B",
 // no mangled name here yet.
+
+// CHECK-NEG-NOT: !DICompositeType(tag: DW_TAG_structure_type, name: 
"PureForwardDecl"


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


Re: [PATCH] D16008: [clang-tidy] Add calling virtual functions in constructors/destructors check.

2016-01-08 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a subscriber: Eugene.Zelenko.
Eugene.Zelenko added a comment.

This check is duplicate of clang-analyzer-alpha.cplusplus.VirtualCall.

From my point of view, Clang-tidy is better place, since such calls doesn't 
depend of run-time paths.

I think will be good idea to try to establish better functionality separation 
between Clang/Clang-tidy/Clang Static Analyzer. Current situation looks like 
different teams try to take everything coming to them without considering big 
picture. This my impression based on including padding check in Clang Static 
Analyzer.


Repository:
  rL LLVM

http://reviews.llvm.org/D16008



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


Re: [PATCH] D8940: Clang changes for indirect call target profiling

2016-01-08 Thread Vedant Kumar via cfe-commits
vsk added a subscriber: vsk.
vsk added a comment.

Thanks betul! Just a minor nit.



Comment at: lib/CodeGen/CGCall.cpp:3550
@@ +3549,3 @@
+DirectCallee = dyn_cast (Callee);
+  if (!DirectCallee)
+PGO.valueProfile(Builder, llvm::IPVK_IndirectCallTarget,

Replacing this condition with `!CS.getCalledFunction()` lets us get rid of the 
previous conditional, IIUC.


http://reviews.llvm.org/D8940



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


[PATCH] D16012: Carry raw string literal information through to the AST StringLiteral representation

2016-01-08 Thread Aaron Ballman via cfe-commits
aaron.ballman created this revision.
aaron.ballman added reviewers: rsmith, dblaikie.
aaron.ballman added a subscriber: cfe-commits.

The AST does not currently carry information about whether a string literal is 
raw or not in the StringLiteral AST representation, which this patch rectifies. 
It exposes information about whether a string literal is raw, and what prefix 
(if any) a raw string literal uses. The patch also adds support for pretty 
printing a raw string literal.

One thing to note, however, is that this is not 100% perfect because of 
translation phase 6, where adjacent string literals are concatenated. This 
patch only supports concatenated raw string literals that have the same prefix. 
It does not support differing prefixes, or adjacent raw & nonraw literals. I 
felt that these were a sufficiently uncommon edge case to not attempt to 
support.

http://reviews.llvm.org/D16012

Files:
  include/clang/AST/Expr.h
  include/clang/Lex/LiteralSupport.h
  lib/AST/Expr.cpp
  lib/Frontend/Rewrite/RewriteModernObjC.cpp
  lib/Frontend/Rewrite/RewriteObjC.cpp
  lib/Lex/LiteralSupport.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprObjC.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/Misc/ast-print-string-literal.cpp
  test/PCH/cxx-string-literal.cpp
  test/SemaCXX/cxx11-ast-print.cpp

Index: test/SemaCXX/cxx11-ast-print.cpp
===
--- test/SemaCXX/cxx11-ast-print.cpp
+++ test/SemaCXX/cxx11-ast-print.cpp
@@ -20,7 +20,7 @@
 
 // CHECK: const char *p1 = "bar1"_foo;
 const char *p1 = "bar1"_foo;
-// CHECK: const char *p2 = "bar2"_foo;
+// CHECK: const char *p2 = R"x(bar2)x"_foo;
 const char *p2 = R"x(bar2)x"_foo;
 // CHECK: const char *p3 = u8"bar3"_foo;
 const char *p3 = u8"bar3"_foo;
Index: test/PCH/cxx-string-literal.cpp
===
--- test/PCH/cxx-string-literal.cpp
+++ test/PCH/cxx-string-literal.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -emit-pch -std=c++1z -o %t %s
+// RUN: %clang_cc1 -std=c++1z -x ast -ast-print %t | FileCheck %s
+
+const char *S = R"T(This is a test)T";
+// CHECK: const char *S = R"T(This is a test)T";
+
+const wchar_t *WS = LR"Teehee(This is a test
+with a newline in it)Teehee";
+// CHECK: const wchar_t *WS = LR"Teehee(This is a test
+// CHECK-NEXT: with a newline in it)Teehee";
+
+const char *T = u8R"(This is also a test)";
+// CHECK: const char *T = u8R"(This is also a test)";
Index: test/Misc/ast-print-string-literal.cpp
===
--- test/Misc/ast-print-string-literal.cpp
+++ test/Misc/ast-print-string-literal.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -ast-print -std=c++1z %s -o - | FileCheck %s
+
+const char *S = R"T(This is a test)T";
+
+const wchar_t *WS = LR"Teehee(This is a test
+with a newline in it)Teehee";
+
+const char *T = u8R"(This is also a test)";
+
+const char *U = R"(This test has \b and a tab	)";
+
+const char *V = R"(This is a test )" R"test(that should concat to a non-raw string)test";
+
+const char *W = R"test(This is a test )test" R"test(that should concat to a raw string)test";
+
+const char *X = "This is a test " R"(that should concat to a non-raw string)";
+
+// CHECK: const char *S = R"T(This is a test)T";
+// CHECK: const wchar_t *WS = LR"Teehee(This is a test
+// CHECK-NEXT: with a newline in it)Teehee";
+// CHECK: const char *T = u8R"(This is also a test)";
+// CHECK: const char *U = R"(This test has \b and a tab	)";
+// CHECK: const char *V = "This is a test that should concat to a non-raw string";
+// CHECK: const char *W = R"test(This is a test that should concat to a raw string)test";
+// CHECK: const char *X = "This is a test that should concat to a non-raw string";
Index: lib/Serialization/ASTWriterStmt.cpp
===
--- lib/Serialization/ASTWriterStmt.cpp
+++ lib/Serialization/ASTWriterStmt.cpp
@@ -429,6 +429,11 @@
   Record.push_back(E->getNumConcatenated());
   Record.push_back(E->getKind());
   Record.push_back(E->isPascal());
+  Record.push_back(E->isRaw());
+  StringRef RawPrefix = E->getRawPrefix();
+  Record.push_back(RawPrefix.size());
+  Record.append(RawPrefix.begin(), RawPrefix.end());
+
   // FIXME: String data should be stored as a blob at the end of the
   // StringLiteral. However, we can't do so now because we have no
   // provision for coping with abbreviations when we're jumping around
Index: lib/Serialization/ASTReaderStmt.cpp
===
--- lib/Serialization/ASTReaderStmt.cpp
+++ lib/Serialization/ASTReaderStmt.cpp
@@ -506,10 +506,14 @@
   StringLiteral::StringKind kind =
 static_cast(Record[Idx++]);
   bool isPascal = Record[Idx++];
+  bool isRaw = Record[Idx++];
+  unsigned RawPrefixLen = Record[Idx++];
+  SmallString<8> RawPrefix([Idx], [Idx] + RawPrefixLen);
+  Idx += RawPrefixLen;
 
   

Re: [PATCH] D15743: Fix assert hit when tree-transforming template template parameter packs.

2016-01-08 Thread David Blaikie via cfe-commits
dblaikie added a subscriber: dblaikie.


Comment at: test/SemaTemplate/temp_arg_template.cpp:80
@@ +79,3 @@
+#if __cplusplus >= 201103L
+  static constexpr int N = sizeof...(Templates);
+#endif

It would be good if we tested for some specific behavior here other than "don't 
crash" (doing anything other than crashing is a bit underspecified) - maybe we 
should be testing that N has the right value?

(don't have quite enough context on the fix itself to sign off on it though, 
unfortunately :/)


http://reviews.llvm.org/D15743



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


Re: [PATCH] D15911: Move ownership of Action objects into Compilation.

2016-01-08 Thread David Blaikie via cfe-commits
dblaikie added inline comments.


Comment at: include/clang/Driver/Compilation.h:54
@@ +53,3 @@
+  /// to consumers; it's here just to manage ownership.
+  std::vector OwningActions;
+

Seems like this name isn't quite right ("OwningActions" sounds like "these are 
the actions that own ") - perhaps "AllActions"? (maybe 
"ActionHolder"? Not sure)


Comment at: include/clang/Driver/Compilation.h:118
@@ +117,3 @@
+  template  T *MakeAction(Args &&... Arg) {
+static_assert(std::is_convertible::value,
+  "T must be derived from Action.");

Did you find this static_assert to be particularly helpful? Similar errors 
(though somewhat more verbose) would be produced during the push_back call a 
few lines down anyway.


Comment at: include/clang/Driver/Compilation.h:120
@@ +119,3 @@
+  "T must be derived from Action.");
+std::unique_ptr A = llvm::make_unique(std::forward(Arg)...);
+T* RawPtr = A.get();

Up to you, but we usually just drop the "std::unique_ptr" in favor of "auto" 
when the RHS has "make_unique".


http://reviews.llvm.org/D15911



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


Re: r256962 - Module debugging: Defer emitting tag types until their definition

2016-01-08 Thread Adrian Prantl via cfe-commits

> On Jan 8, 2016, at 1:59 PM, David Blaikie  wrote:
> 
> 
> 
> On Fri, Jan 8, 2016 at 1:34 PM, Adrian Prantl  > wrote:
> 
>> On Jan 8, 2016, at 1:31 PM, David Blaikie > > wrote:
>> 
>> 
>> 
>> On Wed, Jan 6, 2016 at 11:22 AM, Adrian Prantl via cfe-commits 
>> > wrote:
>> Author: adrian
>> Date: Wed Jan  6 13:22:19 2016
>> New Revision: 256962
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=256962=rev 
>> 
>> Log:
>> Module debugging: Defer emitting tag types until their definition
>> was visited and all decls have been merged.
>> 
>> We only get a single chance to emit the types for virtual classes because
>> CGDebugInfo::completeRequiredType() categorically doesn't complete them.
>> 
>> Not sure I'm following this comment. Could you explain this in other 
>> words/detail?
>> 
>> If we visit a declaration we shouldn't do anything, right? (no point putting 
>> declarations in the modules debug info, unless it's needed for something 
>> else?) & then when we see the definition we'd build the debug info for it?
> 
> Yes. Your statement pretty much summarizes this commit :-)
> 
> Then I'm still confused - were we emitting type declarations in modules prior 
> to this change?

Yes. Dsymutil used to expect every forward declaration in a skeleton CU to have 
a corresponding declaration in the module dwo. I just verified that dsymutil 
does no longer prune forward declarations from skeleton CUs that don’t have a 
definition in the DWO, so everything should be fine now.

> Perhaps a test case for a lone declaration (with no follow up definition) 
> would be in order, then?

Yes, that would make sense. I’ll add one.
 
> 
> -- adrian
> 
>>  
>> 
>> Modified:
>> cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
>> cfe/trunk/test/Modules/Inputs/DebugCXX.h
>> cfe/trunk/test/Modules/ModuleDebugInfo.cpp
>> 
>> Modified: cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp?rev=256962=256961=256962=diff
>>  
>> 
>> ==
>> --- cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp Wed Jan  6 
>> 13:22:19 2016
>> @@ -59,8 +59,10 @@ class PCHContainerGenerator : public AST
>>struct DebugTypeVisitor : public RecursiveASTVisitor {
>>  clang::CodeGen::CGDebugInfo 
>>  ASTContext 
>> -DebugTypeVisitor(clang::CodeGen::CGDebugInfo , ASTContext )
>> -: DI(DI), Ctx(Ctx) {}
>> +bool SkipTagDecls;
>> +DebugTypeVisitor(clang::CodeGen::CGDebugInfo , ASTContext ,
>> + bool SkipTagDecls)
>> +: DI(DI), Ctx(Ctx), SkipTagDecls(SkipTagDecls) {}
>> 
>>  /// Determine whether this type can be represented in DWARF.
>>  static bool CanRepresent(const Type *Ty) {
>> @@ -75,6 +77,12 @@ class PCHContainerGenerator : public AST
>>  }
>> 
>>  bool VisitTypeDecl(TypeDecl *D) {
>> +  // TagDecls may be deferred until after all decls have been merged 
>> and we
>> +  // know the complete type. Pure forward declarations will be skipped, 
>> but
>> +  // they don't need to be emitted into the module anyway.
>> +  if (SkipTagDecls && isa(D))
>> +  return true;
>> +
>>QualType QualTy = Ctx.getTypeDeclType(D);
>>if (!QualTy.isNull() && CanRepresent(QualTy.getTypePtr()))
>>  DI.getOrCreateStandaloneType(QualTy, D->getLocation());
>> @@ -165,7 +173,7 @@ public:
>>  // Collect debug info for all decls in this group.
>>  for (auto *I : D)
>>if (!I->isFromASTFile()) {
>> -DebugTypeVisitor DTV(*Builder->getModuleDebugInfo(), *Ctx);
>> +DebugTypeVisitor DTV(*Builder->getModuleDebugInfo(), *Ctx, true);
>>  DTV.TraverseDecl(I);
>>}
>>  return true;
>> @@ -179,6 +187,11 @@ public:
>>  if (Diags.hasErrorOccurred())
>>return;
>> 
>> +if (D->isFromASTFile())
>> +  return;
>> +
>> +DebugTypeVisitor DTV(*Builder->getModuleDebugInfo(), *Ctx, false);
>> +DTV.TraverseDecl(D);
>>  Builder->UpdateCompletedType(D);
>>}
>> 
>> 
>> Modified: cfe/trunk/test/Modules/Inputs/DebugCXX.h
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/DebugCXX.h?rev=256962=256961=256962=diff
>>  
>> 
>> ==
>> --- 

Re: r256907 - [modules] When a tag type that was imported from a module is referenced via an

2016-01-08 Thread NAKAMURA Takumi via cfe-commits
Seems causes failure in selfhosting.
http://lab.llvm.org:8011/builders/clang-x86_64-linux-selfhost-modules/builds/10188

FYI, I saw the log below (on my local branch);

While building module 'LLVM_Utils' imported from
~/llvm/llvm-project/llvm/lib/Support/TargetParser.cpp:15:
While building module 'std' imported from
~/llvm/llvm-project/llvm/include/llvm/ADT/StringRef.h:14:
In file included from :4:
In file included from ~/llvm/install/bin/../include/c++/v1/bitset:124:
In file included from ~/llvm/install/bin/../include/c++/v1/string:438:
~/llvm/install/bin/../include/c++/v1/cwchar:118:9: error: no member named
'tm' in the global namespace; did you mean 'tm'?
using ::tm;
  ~~^
/usr/include/time.h:133:8: note: 'tm' declared here
struct tm
   ^
While building module 'LLVM_Utils' imported from
~/llvm/llvm-project/llvm/lib/Support/TargetParser.cpp:15:
In file included from :1:
In file included from
~/llvm/llvm-project/llvm/include/llvm/ADT/StringMap.h:17:
~/llvm/llvm-project/llvm/include/llvm/ADT/StringRef.h:14:10: fatal error:
could not build module 'std'
#include 
 ^
While building module 'LLVM_Utils' imported from
~/llvm/llvm-project/llvm/lib/Support/TargetParser.cpp:15:
While building module 'LLVM_Support_DataTypes' imported from
~/llvm/llvm-project/llvm/include/llvm/Support/SwapByteOrder.h:19:
In file included from :1:
include/llvm/Support/DataTypes.h:35:10: fatal error: could not build module
'std'
#include 
 ^
While building module 'LLVM_Utils' imported from
~/llvm/llvm-project/llvm/lib/Support/TargetParser.cpp:15:
While building module 'LLVM_C' imported from
~/llvm/llvm-project/llvm/include/llvm/Support/CBindingWrapping.h:18:
In file included from :1:
~/llvm/llvm-project/llvm/include/llvm-c/./Support.h:17:10: fatal error:
could not build module 'LLVM_Support_DataTypes'
#include "llvm/Support/DataTypes.h"
 ^~
~/llvm/llvm-project/llvm/lib/Support/TargetParser.cpp:15:10: fatal error:
could not build module 'LLVM_Utils'
#include "llvm/Support/ARMBuildAttributes.h"
 ^~~
5 errors generated.

Reverting r256907 just works for me. Lemme know if you would like more
information.

On Wed, Jan 6, 2016 at 12:55 PM Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Tue Jan  5 21:52:10 2016
> New Revision: 256907
>
> URL: http://llvm.org/viewvc/llvm-project?rev=256907=rev
> Log:
> [modules] When a tag type that was imported from a module is referenced
> via an
> elaborated-type-specifier, create a declaration of it to track that the
> current
> module makes it visible too.
>
> Added:
> cfe/trunk/test/Modules/tag-injection.cpp
> Modified:
> cfe/trunk/lib/Sema/SemaDecl.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=256907=256906=256907=diff
>
> ==
> --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Jan  5 21:52:10 2016
> @@ -12277,16 +12277,35 @@ Decl *Sema::ActOnTag(Scope *S, unsigned
>  if (!Invalid) {
>// If this is a use, just return the declaration we found,
> unless
>// we have attributes.
> -
> -  // FIXME: In the future, return a variant or some other clue
> -  // for the consumer of this Decl to know it doesn't own it.
> -  // For our current ASTs this shouldn't be a problem, but will
> -  // need to be changed with DeclGroups.
> -  if (!Attr &&
> -  ((TUK == TUK_Reference &&
> -(!PrevTagDecl->getFriendObjectKind() ||
> getLangOpts().MicrosoftExt))
> -   || TUK == TUK_Friend))
> -return PrevTagDecl;
> +  if (TUK == TUK_Reference || TUK == TUK_Friend) {
> +if (Attr) {
> +  // FIXME: Diagnose these attributes. For now, we create a
> new
> +  // declaration to hold them.
> +} else if (TUK == TUK_Reference &&
> +   (PrevTagDecl->getFriendObjectKind() ==
> +Decl::FOK_Undeclared ||
> +getOwningModule(PrevDecl) !=
> +PP.getModuleContainingLocation(KWLoc)) &&
> +   SS.isEmpty()) {
> +  // This declaration is a reference to an existing entity,
> but
> +  // has different visibility from that entity: it either
> makes
> +  // a friend visible or it makes a type visible in a new
> module.
> +  // In either case, create a new declaration. We only do
> this if
> +  // the declaration would have meant the same thing if no
> prior
> +  // declaration were found, that is, if it was found in the
> same
> +  // scope where we would have injected a declaration.
> +  DeclContext *InjectedDC = CurContext;

Re: [PATCH] D15861: Support fully-qualified names for all QualTypes

2016-01-08 Thread Philippe Canal via cfe-commits

  
  
Hi Richard,

In our use (Persistency of C++ objects, including the
(meta)description of their data content as well as use the name as
key to access the class' reflection information at run-time), the
'context' is indeed always the "at the end of the translation unit"
(or global scope).
Thus (for us), 

> What is the fully-qualified name of `B::t`'s type? Is it
`B::TX` or `std::tuple` or `std::tuple<::A::X>`?

It indeed either `B::TX` or `std::tuple` depending on
whether the typedefs are being desugared or not.

> from within namespace `B`

Within our API there is no way to actually express this (and I can't
think of a semantic where it would make sense). Thus by construction
it is always the "end of the translation unit" case.

> The "ideal interface" idea is a good--and very cool--one, but
my use case doesn't call for it. 

This also our situation. In addition, I do think that supporting the
general case would increase the implementation complexity.  One
'simple' adaption is to support also the case with the leading ::
(i.e. ::std::tuple<::A::X> which would always be safe no
matter which context you use it).

Cheers,
Philippe.



  

 Forwarded Message 

  

  Subject:


  
  Re: [PATCH] D15861: Support fully-qualified names for
all QualTypes


  Date:
  
  Fri, 8 Jan 2016 19:50:16 +


  From:
  
  Sterling Augustine via cfe-commits 


  Reply-To:


  
  reviews+d15861+public+e412d660379b2...@reviews.llvm.org,
Sterling Augustine 


  To: 
  saugust...@google.com,
rich...@metafoo.co.uk


  CC: 
  cfe-commits@lists.llvm.org

  



saugustine added a comment.

Thanks for the reviews. Please take another look when you get a chance.



Comment at: include/clang/Tooling/Core/QualTypeNames.h:32-33
@@ +31,4 @@
+namespace TypeName {
+///\brief Convert the type into one with fully qualified template
+/// arguments.
+///\param[in] QT - the type for which the fully qualified type will be

rsmith wrote:
> rsmith wrote:
> > Please ensure there's a space between each `/// ` and the content.
> What do you mean by "fully qualified template arguments" here? Let me give you some examples:
> 
> namespace A {
>   struct X {};
> }
> using A::X;
> namespace B {
>   using std::tuple;
>   typedef typle TX;
>   TX t;
>   struct A { typedef int X; };
> }
> 
> What is the fully-qualified name of `B::t`'s type? Is it `B::TX` or `std::tuple` or `std::tuple<::A::X>`? Note that if you want to redeclare `t` from within namespace `B`, `std::tuple` will name the wrong type.
> 
> 
> Why does this only affect template arguments? Its name suggests it should affect the type as a whole (for instance, in the above case it should produce `std::tuple<...>`, not `tuple<...>`).
> 
> 
> Generally, I think this interface needs to specify where the produced names can be used as a name for the specified type, otherwise I don't see how it can ever be reliable. For instance:
> 
> > "Generates a name for a type that can be used to name the same type if used at the end of the current translation unit." (eg, `B::TX` or `std::tuple`)
> 
> or:
> 
> > "Generates a maximally-explicit name for a type that can be used in any context where all the relevant components have been declared. In such a context, this name will either name the intended type or produce an ambiguity error." (eg, `::std::tuple<::A::X>`)
> 
> You should also specify what happens when it's not possible to generate such a name. For instance, given:
> 
> void f() {
>   struct X {} x;
> }
> 
> ... there's no way to name the type of `x` from outside `f` (which makes certain refactoring operations impossible unless you also move the definition of `struct X`).
> 
> 
> I think the ideal interface here would allow you to specify a location where you wish to insert the name, and would produce a "best possible" name for that type for that location, avoiding adding explicit qualification / desugaring wherever possible, but the interface should at least take the context-sensitivity of names into account.
My use case is to take a function signature, and communicate to a developer one way to declare the variables they need to call the function.

It does expand entire qualtypes, not just template parameters. (I've updated that description.)

Given the use case, 

Re: [PATCH] D15960: Don't build jobs for the same Action + ToolChain twice.

2016-01-08 Thread Justin Lebar via cfe-commits
jlebar updated this revision to Diff 44377.
jlebar added a dependency: D16013: Make Driver::BuildJobsForAction return an 
InputInfo, instead of using an outparam..
jlebar added a comment.

Fixing bug caused by missing an outparam.

Covered by tests in WIP CUDA+ptxas+fatbin patch.

Depends on http://reviews.llvm.org/D16013.


http://reviews.llvm.org/D15960

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

Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1628,6 +1628,8 @@
   if (A->getOption().matches(options::OPT_arch))
 ArchNames.insert(A->getValue());
 
+  // Set of (Action, canonical ToolChain triple) pairs we've built jobs for.
+  std::map CachedResults;
   for (Action *A : C.getActions()) {
 // If we are linking an image for multiple archs then the linker wants
 // -arch_multiple and -final_output . Unfortunately, this
@@ -1647,7 +1649,7 @@
/*BoundArch*/ nullptr,
/*AtTopLevel*/ true,
/*MultipleArchs*/ ArchNames.size() > 1,
-   /*LinkingOutput*/ LinkingOutput);
+   /*LinkingOutput*/ LinkingOutput, CachedResults);
   }
 
   // If the user passed -Qunused-arguments or there were errors, don't warn
@@ -1775,19 +1777,38 @@
   return ToolForJob;
 }
 
-InputInfo Driver::BuildJobsForAction(Compilation , const Action *A,
- const ToolChain *TC, const char *BoundArch,
- bool AtTopLevel, bool MultipleArchs,
- const char *LinkingOutput) const {
+InputInfo Driver::BuildJobsForAction(
+Compilation , const Action *A, const ToolChain *TC, const char *BoundArch,
+bool AtTopLevel, bool MultipleArchs, const char *LinkingOutput,
+std::map )
+const {
+  std::pair ActionTC = {
+  A, TC->getTriple().normalize()};
+  auto CachedResult = CachedResults.find(ActionTC);
+  if (CachedResult != CachedResults.end()) {
+return CachedResult->second;
+  }
+  InputInfo Result =
+  BuildJobsForActionNoCache(C, A, TC, BoundArch, AtTopLevel, MultipleArchs,
+LinkingOutput, CachedResults);
+  CachedResults[ActionTC] = Result;
+  return Result;
+}
+
+InputInfo Driver::BuildJobsForActionNoCache(
+Compilation , const Action *A, const ToolChain *TC, const char *BoundArch,
+bool AtTopLevel, bool MultipleArchs, const char *LinkingOutput,
+std::map )
+const {
   llvm::PrettyStackTraceString CrashInfo("Building compilation jobs");
 
   InputInfoList CudaDeviceInputInfos;
   if (const CudaHostAction *CHA = dyn_cast(A)) {
 // Append outputs of device jobs to the input list.
 for (const Action *DA : CHA->getDeviceActions()) {
-  CudaDeviceInputInfos.push_back(
-  BuildJobsForAction(C, DA, TC, nullptr, AtTopLevel,
- /*MultipleArchs*/ false, LinkingOutput));
+  CudaDeviceInputInfos.push_back(BuildJobsForAction(
+  C, DA, TC, nullptr, AtTopLevel,
+  /*MultipleArchs*/ false, LinkingOutput, CachedResults));
 }
 // Override current action with a real host compile action and continue
 // processing it.
@@ -1818,16 +1839,17 @@
   TC = ();
 
 return BuildJobsForAction(C, *BAA->begin(), TC, ArchName, AtTopLevel,
-  MultipleArchs, LinkingOutput);
+  MultipleArchs, LinkingOutput, CachedResults);
   }
 
   if (const CudaDeviceAction *CDA = dyn_cast(A)) {
 // Initial processing of CudaDeviceAction carries host params.
 // Call BuildJobsForAction() again, now with correct device parameters.
 assert(CDA->getGpuArchName() && "No GPU name in device action.");
 return BuildJobsForAction(C, *CDA->begin(), C.getCudaDeviceToolChain(),
   CDA->getGpuArchName(), CDA->isAtTopLevel(),
-  /*MultipleArchs*/ true, LinkingOutput);
+  /*MultipleArchs*/ true, LinkingOutput,
+  CachedResults);
   }
 
   const ActionList *Inputs = >getInputs();
@@ -1843,9 +1865,9 @@
   // need to build jobs for device-side inputs it may have held.
   if (CollapsedCHA) {
 for (const Action *DA : CollapsedCHA->getDeviceActions()) {
-  CudaDeviceInputInfos.push_back(
-  BuildJobsForAction(C, DA, TC, "", AtTopLevel,
- /*MultipleArchs*/ false, LinkingOutput));
+  CudaDeviceInputInfos.push_back(BuildJobsForAction(
+  C, DA, TC, "", AtTopLevel,
+  /*MultipleArchs*/ false, LinkingOutput, CachedResults));
 }
   }
 
@@ -1859,7 +1881,7 @@
 AtTopLevel && (isa(A) || isa(A));
 InputInfos.push_back(BuildJobsForAction(C, Input, TC, BoundArch,

Re: [PATCH] D8056: Fix for bug 21725: wrong results with union and strict-aliasing

2016-01-08 Thread Yin Ma via cfe-commits
yinma added a subscriber: yinma.
yinma added a comment.

Hello, I am wondering if the current llvm/clang's tbaa supports union or not?


http://reviews.llvm.org/D8056



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


r257231 - Exclude function calls for functions which have return type nullptr_t from

2016-01-08 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Jan  8 17:35:06 2016
New Revision: 257231

URL: http://llvm.org/viewvc/llvm-project?rev=257231=rev
Log:
Exclude function calls for functions which have return type nullptr_t from
-Wnull-conversion warning.

These functions are basically equivalent to other pointer returning fuctions
which are already excluded by -Wnull-conversion.

Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/SemaCXX/conversion.cpp

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=257231=257230=257231=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri Jan  8 17:35:06 2016
@@ -7047,6 +7047,10 @@ static void DiagnoseNullConversion(Sema
 E->getExprLoc()))
 return;
 
+  // Don't warn on functions which have return type nullptr_t.
+  if (isa(E))
+return;
+
   // Check for NULL (GNUNull) or nullptr (CXX11_nullptr).
   const Expr::NullPointerConstantKind NullKind =
   E->isNullPointerConstant(S.Context, Expr::NPC_ValueDependentIsNotNull);

Modified: cfe/trunk/test/SemaCXX/conversion.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/conversion.cpp?rev=257231=257230=257231=diff
==
--- cfe/trunk/test/SemaCXX/conversion.cpp (original)
+++ cfe/trunk/test/SemaCXX/conversion.cpp Fri Jan  8 17:35:06 2016
@@ -197,3 +197,14 @@ namespace test8 {
 template_and_macro2();
   }
 }
+
+// Don't warn on a nullptr to bool conversion when the nullptr is the return
+// type of a function.
+namespace test9 {
+  typedef decltype(nullptr) nullptr_t;
+  nullptr_t EXIT();
+
+  bool test() {
+return EXIT();
+  }
+}


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


Re: [libcxx] r255177 - Remove visibility attributes from out-of-class method definitions in iostreams.

2016-01-08 Thread Duncan P. N. Exon Smith via cfe-commits

> On 2016-Jan-08, at 10:49, Nico Weber via cfe-commits 
>  wrote:
> 
> On OS X 10.8, __ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5sputcEc (and 
> others) are a hidden symbol in libc++.1.dylib. This means:
> 
> * If I use streambuf::sputc() and link against the 10.8 SDK, and the compiler 
> decides to not inline the call, I will get linker errors.
> * If I do the same with the 10.10 SDK when targeting 10.8, then (even worse) 
> the link will silently succeed (since it links against the 10.10 libc++ which 
> does have a public symbol for this -- the SDK assumes that libc++ is 
> abi-compatible with itself) but it will then fail to run on a 10.8 system.
> 
> I don't see a way to save this change -- I think this needs to be reverted.

FWIW, we're working on a plan to add availability markup to libc++
(it shouldn't be too intrusive (since you can annotate blocks of
API); had some initial talks with Marshall at the dev meeting).  I
plan to send out an RFC soon.

I didn't think there'd be interest in having the availability
attributes themselves in open source (just some placeholder macros),
but it would be an option.

Anyway, until that's done, I agree this needs to be reverted.

> Have you made similar changes elsewhere? These probably need to be reverted 
> too.

I agree.

> On Wed, Dec 9, 2015 at 6:42 PM, Evgeniy Stepanov via cfe-commits 
>  wrote:
> Author: eugenis
> Date: Wed Dec  9 17:42:30 2015
> New Revision: 255177
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=255177=rev
> Log:
> Remove visibility attributes from out-of-class method definitions in 
> iostreams.
> 
> No point in pretending that these methods are hidden - they are
> actually exported from libc++.so. Extern template declarations make
> them part of libc++ ABI.
> 
> This patch does not change libc++.so export list (at least on Linux).
> 
> Modified:
> libcxx/trunk/include/istream
> libcxx/trunk/include/ostream
> libcxx/trunk/include/sstream
> libcxx/trunk/include/streambuf
> 
> Modified: libcxx/trunk/include/istream
> URL: 
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/istream?rev=255177=255176=255177=diff
> ==
> --- libcxx/trunk/include/istream (original)
> +++ libcxx/trunk/include/istream Wed Dec  9 17:42:30 2015
> @@ -304,7 +304,7 @@ basic_istream<_CharT, _Traits>::sentry::
>  }
> 
>  template 
> -inline _LIBCPP_INLINE_VISIBILITY
> +inline
>  basic_istream<_CharT, _Traits>::basic_istream(basic_streambuf traits_type>* __sb)
>  : __gc_(0)
>  {
> @@ -314,7 +314,7 @@ basic_istream<_CharT, _Traits>::basic_is
>  #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
> 
>  template 
> -inline _LIBCPP_INLINE_VISIBILITY
> +inline
>  basic_istream<_CharT, _Traits>::basic_istream(basic_istream&& __rhs)
>  : __gc_(__rhs.__gc_)
>  {
> @@ -323,7 +323,7 @@ basic_istream<_CharT, _Traits>::basic_is
>  }
> 
>  template 
> -inline _LIBCPP_INLINE_VISIBILITY
> +inline
>  basic_istream<_CharT, _Traits>&
>  basic_istream<_CharT, _Traits>::operator=(basic_istream&& __rhs)
>  {
> @@ -339,7 +339,7 @@ basic_istream<_CharT, _Traits>::~basic_i
>  }
> 
>  template 
> -inline _LIBCPP_INLINE_VISIBILITY
> +inline
>  void
>  basic_istream<_CharT, _Traits>::swap(basic_istream& __rhs)
>  {
> @@ -725,7 +725,7 @@ basic_istream<_CharT, _Traits>::operator
>  }
> 
>  template 
> -inline _LIBCPP_INLINE_VISIBILITY
> +inline
>  basic_istream<_CharT, _Traits>&
>  basic_istream<_CharT, _Traits>::operator>>(basic_istream& 
> (*__pf)(basic_istream&))
>  {
> @@ -733,7 +733,7 @@ basic_istream<_CharT, _Traits>::operator
>  }
> 
>  template 
> -inline _LIBCPP_INLINE_VISIBILITY
> +inline
>  basic_istream<_CharT, _Traits>&
>  basic_istream<_CharT, _Traits>::operator>>(basic_ios&
> (*__pf)(basic_ios traits_type>&))
> @@ -743,7 +743,7 @@ basic_istream<_CharT, _Traits>::operator
>  }
> 
>  template 
> -inline _LIBCPP_INLINE_VISIBILITY
> +inline
>  basic_istream<_CharT, _Traits>&
>  basic_istream<_CharT, _Traits>::operator>>(ios_base& (*__pf)(ios_base&))
>  {
> @@ -800,7 +800,7 @@ operator>>(basic_istream<_CharT, _Traits
>  }
> 
>  template
> -inline _LIBCPP_INLINE_VISIBILITY
> +inline
>  basic_istream&
>  operator>>(basic_istream& __is, unsigned char* __s)
>  {
> @@ -808,7 +808,7 @@ operator>>(basic_istream&
>  }
> 
>  template
> -inline _LIBCPP_INLINE_VISIBILITY
> +inline
>  basic_istream&
>  operator>>(basic_istream& __is, signed char* __s)
>  {
> @@ -843,7 +843,7 @@ operator>>(basic_istream<_CharT, _Traits
>  }
> 
>  template
> -inline _LIBCPP_INLINE_VISIBILITY
> +inline
>  basic_istream&
>  operator>>(basic_istream& __is, unsigned char& __c)
>  {
> @@ -851,7 +851,7 @@ operator>>(basic_istream&
>  }
> 
>  template

r257162 - clang-format: [JS] Prefer wrapping before the TypeScript return type

2016-01-08 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Fri Jan  8 04:51:24 2016
New Revision: 257162

URL: http://llvm.org/viewvc/llvm-project?rev=257162=rev
Log:
clang-format: [JS] Prefer wrapping before the TypeScript return type
over wrapping before parameters.

Before:
  function someFunc(
  args: string[]): {longReturnValue: string[]} {}

After:
  function someFunc(args: string[]):
  {longReturnValue: string[]} {}

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=257162=257161=257162=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri Jan  8 04:51:24 2016
@@ -1725,7 +1725,7 @@ unsigned TokenAnnotator::splitPenalty(co
 if (Right.is(Keywords.kw_function) && Left.isNot(tok::comma))
   return 100;
 if (Left.is(TT_JsTypeColon))
-  return 100;
+  return 35;
   }
 
   if (Left.is(tok::comma) || (Right.is(tok::identifier) && Right.Next &&

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=257162=257161=257162=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Fri Jan  8 04:51:24 2016
@@ -740,6 +740,9 @@ TEST_F(FormatTestJS, TypeAnnotations) {
   verifyFormat("var x: P string>;");
   verifyFormat("var x = {y: function(): z { return 1; }};");
   verifyFormat("var x = {y: function(): {a: number} { return 1; }};");
+  verifyFormat("function someFunc(args: string[]):\n"
+   "{longReturnValue: string[]} {}",
+   getGoogleJSStyleWithColumns(60));
 }
 
 TEST_F(FormatTestJS, ClassDeclarations) {


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


r257251 - [modules] If we're treating an elaborated-type-specifier as if it introduces a

2016-01-08 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Sat Jan  9 00:58:48 2016
New Revision: 257251

URL: http://llvm.org/viewvc/llvm-project?rev=257251=rev
Log:
[modules] If we're treating an elaborated-type-specifier as if it introduces a
tag (because the previous declaration was found in a different module), inject
the tag into the appropriate scope (that is, the enclosing scope if we're in a
function prototype scope in C++).

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Modules/tag-injection.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=257251=257250=257251=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Sat Jan  9 00:58:48 2016
@@ -11798,6 +11798,28 @@ static bool isAcceptableTagRedeclContext
   return false;
 }
 
+/// Find the DeclContext in which a tag is implicitly declared if we see an
+/// elaborated type specifier in the specified context, and lookup finds
+/// nothing.
+static DeclContext *getTagInjectionContext(DeclContext *DC) {
+  while (!DC->isFileContext() && !DC->isFunctionOrMethod())
+DC = DC->getParent();
+  return DC;
+}
+
+/// Find the Scope in which a tag is implicitly declared if we see an
+/// elaborated type specifier in the specified context, and lookup finds
+/// nothing.
+static Scope *getTagInjectionScope(Scope *S, const LangOptions ) {
+  while (S->isClassScope() ||
+ (LangOpts.CPlusPlus &&
+  S->isFunctionPrototypeScope()) ||
+ ((S->getFlags() & Scope::DeclScope) == 0) ||
+ (S->getEntity() && S->getEntity()->isTransparentContext()))
+S = S->getParent();
+  return S;
+}
+
 /// \brief This is invoked when we see 'struct foo' or 'struct {'.  In the
 /// former case, Name will be non-null.  In the later case, Name will be null.
 /// TagSpec indicates what kind of tag this is. TUK indicates whether this is a
@@ -12114,16 +12136,10 @@ Decl *Sema::ActOnTag(Scope *S, unsigned
   // Find the context where we'll be declaring the tag.
   // FIXME: We would like to maintain the current DeclContext as the
   // lexical context,
-  while (!SearchDC->isFileContext() && !SearchDC->isFunctionOrMethod())
-SearchDC = SearchDC->getParent();
+  SearchDC = getTagInjectionContext(SearchDC);
 
   // Find the scope where we'll be declaring the tag.
-  while (S->isClassScope() ||
- (getLangOpts().CPlusPlus &&
-  S->isFunctionPrototypeScope()) ||
- ((S->getFlags() & Scope::DeclScope) == 0) ||
- (S->getEntity() && S->getEntity()->isTransparentContext()))
-S = S->getParent();
+  S = getTagInjectionScope(S, getLangOpts());
 } else {
   assert(TUK == TUK_Friend);
   // C++ [namespace.memdef]p3:
@@ -12293,14 +12309,13 @@ Decl *Sema::ActOnTag(Scope *S, unsigned
   // the declaration would have meant the same thing if no prior
   // declaration were found, that is, if it was found in the same
   // scope where we would have injected a declaration.
-  DeclContext *InjectedDC = CurContext;
-  while (!InjectedDC->isFileContext() &&
- !InjectedDC->isFunctionOrMethod())
-InjectedDC = InjectedDC->getParent();
-  if (!InjectedDC->getRedeclContext()->Equals(
-  PrevDecl->getDeclContext()->getRedeclContext()))
+  if (!getTagInjectionContext(CurContext)
+   ->getRedeclContext()
+   
->Equals(PrevDecl->getDeclContext()->getRedeclContext()))
 return PrevTagDecl;
-  // This is in the injected scope, create a new declaration.
+  // This is in the injected scope, create a new declaration in
+  // that scope.
+  S = getTagInjectionScope(S, getLangOpts());
 } else {
   return PrevTagDecl;
 }

Modified: cfe/trunk/test/Modules/tag-injection.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/tag-injection.cpp?rev=257251=257250=257251=diff
==
--- cfe/trunk/test/Modules/tag-injection.cpp (original)
+++ cfe/trunk/test/Modules/tag-injection.cpp Sat Jan  9 00:58:48 2016
@@ -1,12 +1,15 @@
 // RUN: rm -rf %t
 // RUN: mkdir %t
-// RUN: touch %t/a.h
-// RUN: echo 'struct X {};' > %t/b.h
+// RUN: echo 'struct tm;' > %t/a.h
+// RUN: echo 'struct X {}; void foo(struct tm*);' > %t/b.h
 // RUN: echo 'module X { module a { header "a.h" } module b { header "b.h" } 
}' > %t/x.modulemap
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -x c++ 
-fmodule-map-file=%t/x.modulemap %s -I%t -verify -std=c++11
 // RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -x c++ 
-fmodule-map-file=%t/x.modulemap %s -I%t -verify 
-fmodules-local-submodule-visibility 

Re: r256907 - [modules] When a tag type that was imported from a module is referenced via an

2016-01-08 Thread Richard Smith via cfe-commits
On Fri, Jan 8, 2016 at 3:19 PM, NAKAMURA Takumi 
wrote:

> Seems causes failure in selfhosting.
>
> http://lab.llvm.org:8011/builders/clang-x86_64-linux-selfhost-modules/builds/10188
>
> FYI, I saw the log below (on my local branch);
>
> While building module 'LLVM_Utils' imported from
> ~/llvm/llvm-project/llvm/lib/Support/TargetParser.cpp:15:
> While building module 'std' imported from
> ~/llvm/llvm-project/llvm/include/llvm/ADT/StringRef.h:14:
> In file included from :4:
> In file included from ~/llvm/install/bin/../include/c++/v1/bitset:124:
> In file included from ~/llvm/install/bin/../include/c++/v1/string:438:
> ~/llvm/install/bin/../include/c++/v1/cwchar:118:9: error: no member named
> 'tm' in the global namespace; did you mean 'tm'?
> using ::tm;
>   ~~^
> /usr/include/time.h:133:8: note: 'tm' declared here
> struct tm
>^
> While building module 'LLVM_Utils' imported from
> ~/llvm/llvm-project/llvm/lib/Support/TargetParser.cpp:15:
> In file included from :1:
> In file included from
> ~/llvm/llvm-project/llvm/include/llvm/ADT/StringMap.h:17:
> ~/llvm/llvm-project/llvm/include/llvm/ADT/StringRef.h:14:10: fatal error:
> could not build module 'std'
> #include 
>  ^
> While building module 'LLVM_Utils' imported from
> ~/llvm/llvm-project/llvm/lib/Support/TargetParser.cpp:15:
> While building module 'LLVM_Support_DataTypes' imported from
> ~/llvm/llvm-project/llvm/include/llvm/Support/SwapByteOrder.h:19:
> In file included from :1:
> include/llvm/Support/DataTypes.h:35:10: fatal error: could not build
> module 'std'
> #include 
>  ^
> While building module 'LLVM_Utils' imported from
> ~/llvm/llvm-project/llvm/lib/Support/TargetParser.cpp:15:
> While building module 'LLVM_C' imported from
> ~/llvm/llvm-project/llvm/include/llvm/Support/CBindingWrapping.h:18:
> In file included from :1:
> ~/llvm/llvm-project/llvm/include/llvm-c/./Support.h:17:10: fatal error:
> could not build module 'LLVM_Support_DataTypes'
> #include "llvm/Support/DataTypes.h"
>  ^~
> ~/llvm/llvm-project/llvm/lib/Support/TargetParser.cpp:15:10: fatal error:
> could not build module 'LLVM_Utils'
> #include "llvm/Support/ARMBuildAttributes.h"
>  ^~~
> 5 errors generated.
>
> Reverting r256907 just works for me. Lemme know if you would like more
> information.
>

Thanks, should be fixed in r257251.


> On Wed, Jan 6, 2016 at 12:55 PM Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rsmith
>> Date: Tue Jan  5 21:52:10 2016
>> New Revision: 256907
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=256907=rev
>> Log:
>> [modules] When a tag type that was imported from a module is referenced
>> via an
>> elaborated-type-specifier, create a declaration of it to track that the
>> current
>> module makes it visible too.
>>
>> Added:
>> cfe/trunk/test/Modules/tag-injection.cpp
>> Modified:
>> cfe/trunk/lib/Sema/SemaDecl.cpp
>>
>> Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=256907=256906=256907=diff
>>
>> ==
>> --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Jan  5 21:52:10 2016
>> @@ -12277,16 +12277,35 @@ Decl *Sema::ActOnTag(Scope *S, unsigned
>>  if (!Invalid) {
>>// If this is a use, just return the declaration we found,
>> unless
>>// we have attributes.
>> -
>> -  // FIXME: In the future, return a variant or some other clue
>> -  // for the consumer of this Decl to know it doesn't own it.
>> -  // For our current ASTs this shouldn't be a problem, but will
>> -  // need to be changed with DeclGroups.
>> -  if (!Attr &&
>> -  ((TUK == TUK_Reference &&
>> -(!PrevTagDecl->getFriendObjectKind() ||
>> getLangOpts().MicrosoftExt))
>> -   || TUK == TUK_Friend))
>> -return PrevTagDecl;
>> +  if (TUK == TUK_Reference || TUK == TUK_Friend) {
>> +if (Attr) {
>> +  // FIXME: Diagnose these attributes. For now, we create a
>> new
>> +  // declaration to hold them.
>> +} else if (TUK == TUK_Reference &&
>> +   (PrevTagDecl->getFriendObjectKind() ==
>> +Decl::FOK_Undeclared ||
>> +getOwningModule(PrevDecl) !=
>> +PP.getModuleContainingLocation(KWLoc)) &&
>> +   SS.isEmpty()) {
>> +  // This declaration is a reference to an existing entity,
>> but
>> +  // has different visibility from that entity: it either
>> makes
>> +  // a friend visible or it makes a type visible in a new
>> module.
>> +  // In either case, create a new declaration. We only do
>> this if

r257252 - Test Commit

2016-01-08 Thread Xiuli Pan via cfe-commits
Author: pxl
Date: Sat Jan  9 01:12:32 2016
New Revision: 257252

URL: http://llvm.org/viewvc/llvm-project?rev=257252=rev
Log:
Test Commit

Fix a typo

Modified:
cfe/trunk/lib/AST/Type.cpp

Modified: cfe/trunk/lib/AST/Type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=257252=257251=257252=diff
==
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Sat Jan  9 01:12:32 2016
@@ -2614,7 +2614,7 @@ StringRef BuiltinType::getName(const Pri
   case OCLQueue:
 return "queue_t";
   case OCLNDRange:
-return "event_t";
+return "ndrange_t";
   case OCLReserveID:
 return "reserve_id_t";
   case OMPArraySection:


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


Re: r257251 - [modules] If we're treating an elaborated-type-specifier as if it introduces a

2016-01-08 Thread NAKAMURA Takumi via cfe-commits
Thanks. But a few C headers are complaining. Investigating.

http://lab.llvm.org:8011/builders/clang-x86_64-linux-selfhost-modules/builds/10380

On Sat, Jan 9, 2016 at 4:02 PM Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Sat Jan  9 00:58:48 2016
> New Revision: 257251
>
> URL: http://llvm.org/viewvc/llvm-project?rev=257251=rev
> Log:
> [modules] If we're treating an elaborated-type-specifier as if it
> introduces a
> tag (because the previous declaration was found in a different module),
> inject
> the tag into the appropriate scope (that is, the enclosing scope if we're
> in a
> function prototype scope in C++).
>
> Modified:
> cfe/trunk/lib/Sema/SemaDecl.cpp
> cfe/trunk/test/Modules/tag-injection.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=257251=257250=257251=diff
>
> ==
> --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDecl.cpp Sat Jan  9 00:58:48 2016
> @@ -11798,6 +11798,28 @@ static bool isAcceptableTagRedeclContext
>return false;
>  }
>
> +/// Find the DeclContext in which a tag is implicitly declared if we see
> an
> +/// elaborated type specifier in the specified context, and lookup finds
> +/// nothing.
> +static DeclContext *getTagInjectionContext(DeclContext *DC) {
> +  while (!DC->isFileContext() && !DC->isFunctionOrMethod())
> +DC = DC->getParent();
> +  return DC;
> +}
> +
> +/// Find the Scope in which a tag is implicitly declared if we see an
> +/// elaborated type specifier in the specified context, and lookup finds
> +/// nothing.
> +static Scope *getTagInjectionScope(Scope *S, const LangOptions )
> {
> +  while (S->isClassScope() ||
> + (LangOpts.CPlusPlus &&
> +  S->isFunctionPrototypeScope()) ||
> + ((S->getFlags() & Scope::DeclScope) == 0) ||
> + (S->getEntity() && S->getEntity()->isTransparentContext()))
> +S = S->getParent();
> +  return S;
> +}
> +
>  /// \brief This is invoked when we see 'struct foo' or 'struct {'.  In the
>  /// former case, Name will be non-null.  In the later case, Name will be
> null.
>  /// TagSpec indicates what kind of tag this is. TUK indicates whether
> this is a
> @@ -12114,16 +12136,10 @@ Decl *Sema::ActOnTag(Scope *S, unsigned
>// Find the context where we'll be declaring the tag.
>// FIXME: We would like to maintain the current DeclContext as the
>// lexical context,
> -  while (!SearchDC->isFileContext() &&
> !SearchDC->isFunctionOrMethod())
> -SearchDC = SearchDC->getParent();
> +  SearchDC = getTagInjectionContext(SearchDC);
>
>// Find the scope where we'll be declaring the tag.
> -  while (S->isClassScope() ||
> - (getLangOpts().CPlusPlus &&
> -  S->isFunctionPrototypeScope()) ||
> - ((S->getFlags() & Scope::DeclScope) == 0) ||
> - (S->getEntity() && S->getEntity()->isTransparentContext()))
> -S = S->getParent();
> +  S = getTagInjectionScope(S, getLangOpts());
>  } else {
>assert(TUK == TUK_Friend);
>// C++ [namespace.memdef]p3:
> @@ -12293,14 +12309,13 @@ Decl *Sema::ActOnTag(Scope *S, unsigned
>// the declaration would have meant the same thing if no
> prior
>// declaration were found, that is, if it was found in the
> same
>// scope where we would have injected a declaration.
> -  DeclContext *InjectedDC = CurContext;
> -  while (!InjectedDC->isFileContext() &&
> - !InjectedDC->isFunctionOrMethod())
> -InjectedDC = InjectedDC->getParent();
> -  if (!InjectedDC->getRedeclContext()->Equals(
> -  PrevDecl->getDeclContext()->getRedeclContext()))
> +  if (!getTagInjectionContext(CurContext)
> +   ->getRedeclContext()
> +
>  ->Equals(PrevDecl->getDeclContext()->getRedeclContext()))
>  return PrevTagDecl;
> -  // This is in the injected scope, create a new declaration.
> +  // This is in the injected scope, create a new declaration
> in
> +  // that scope.
> +  S = getTagInjectionScope(S, getLangOpts());
>  } else {
>return PrevTagDecl;
>  }
>
> Modified: cfe/trunk/test/Modules/tag-injection.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/tag-injection.cpp?rev=257251=257250=257251=diff
>
> ==
> --- cfe/trunk/test/Modules/tag-injection.cpp (original)
> +++ cfe/trunk/test/Modules/tag-injection.cpp Sat Jan  9 00:58:48 2016
> @@ -1,12 +1,15 @@
>  // RUN: rm -rf %t
>  // RUN: mkdir %t
> -// RUN: touch %t/a.h
> -// RUN: echo 'struct X {};' > %t/b.h
> +// RUN: echo 'struct 

Re: [PATCH] D15960: Don't build jobs for the same Action + ToolChain twice.

2016-01-08 Thread Justin Lebar via cfe-commits
jlebar added a comment.

OK, this is now working, please have a look.  I'm not sure if it's possible to 
write a test as-is, but I have a test for my mistake in my WIP CUDA patch.  
(Also this mistake is much harder to make after http://reviews.llvm.org/D16013.)


http://reviews.llvm.org/D15960



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


r257222 - [modules] Make sure we always include the contents of private headers when

2016-01-08 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Jan  8 16:36:45 2016
New Revision: 257222

URL: http://llvm.org/viewvc/llvm-project?rev=257222=rev
Log:
[modules] Make sure we always include the contents of private headers when
building a module. Prior to this change, the private header's content would
only be included if the header were included by another header in the same
module. If not (if the private header is only used by the .cc files of the
module, or is included from outside the module via -Wno-private-header),
a #include of that file would be silently ignored.

Modified:
cfe/trunk/lib/Frontend/FrontendActions.cpp
cfe/trunk/test/Modules/Inputs/dummy.h
cfe/trunk/test/Modules/modular_maps.cpp
cfe/trunk/test/Modules/separate_map_tree.cpp

Modified: cfe/trunk/lib/Frontend/FrontendActions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendActions.cpp?rev=257222=257221=257222=diff
==
--- cfe/trunk/lib/Frontend/FrontendActions.cpp (original)
+++ cfe/trunk/lib/Frontend/FrontendActions.cpp Fri Jan  8 16:36:45 2016
@@ -187,15 +187,17 @@ collectModuleHeaderIncludes(const LangOp
 return std::error_code();
 
   // Add includes for each of these headers.
-  for (Module::Header  : Module->Headers[Module::HK_Normal]) {
-Module->addTopHeader(H.Entry);
-// Use the path as specified in the module map file. We'll look for this
-// file relative to the module build directory (the directory containing
-// the module map file) so this will find the same file that we found
-// while parsing the module map.
-if (std::error_code Err = addHeaderInclude(H.NameAsWritten, Includes,
-   LangOpts, Module->IsExternC))
-  return Err;
+  for (auto HK : {Module::HK_Normal, Module::HK_Private}) {
+for (Module::Header  : Module->Headers[HK]) {
+  Module->addTopHeader(H.Entry);
+  // Use the path as specified in the module map file. We'll look for this
+  // file relative to the module build directory (the directory containing
+  // the module map file) so this will find the same file that we found
+  // while parsing the module map.
+  if (std::error_code Err = addHeaderInclude(H.NameAsWritten, Includes,
+ LangOpts, Module->IsExternC))
+return Err;
+}
   }
   // Note that Module->PrivateHeaders will not be a TopHeader.
 

Modified: cfe/trunk/test/Modules/Inputs/dummy.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/dummy.h?rev=257222=257221=257222=diff
==
--- cfe/trunk/test/Modules/Inputs/dummy.h (original)
+++ cfe/trunk/test/Modules/Inputs/dummy.h Fri Jan  8 16:36:45 2016
@@ -1,3 +1,5 @@
 // This module only exists to make local decl IDs and global decl IDs 
different.
-
+#ifndef DUMMY_H
+#define DUMMY_H
 struct Dummy {} extern *dummy1, *dummy2, *dummy3;
+#endif

Modified: cfe/trunk/test/Modules/modular_maps.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/modular_maps.cpp?rev=257222=257221=257222=diff
==
--- cfe/trunk/test/Modules/modular_maps.cpp (original)
+++ cfe/trunk/test/Modules/modular_maps.cpp Fri Jan  8 16:36:45 2016
@@ -16,4 +16,4 @@
 #include "b.h" // expected-error {{private header}}
 @import C;
 const int v = a + c + x;
-const int val = a + b + c + x; // expected-error {{undeclared identifier}}
+const int val = a + b + c + x;

Modified: cfe/trunk/test/Modules/separate_map_tree.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/separate_map_tree.cpp?rev=257222=257221=257222=diff
==
--- cfe/trunk/test/Modules/separate_map_tree.cpp (original)
+++ cfe/trunk/test/Modules/separate_map_tree.cpp Fri Jan  8 16:36:45 2016
@@ -5,4 +5,4 @@
 #include "public-in-b.h" // expected-error {{private header}}
 #include "public-in-c.h"
 #include "private-in-c.h" // expected-error {{private header}}
-const int val = common + b + c + c_; // expected-error {{undeclared 
identifier}}
+const int val = common + b + c + c_;


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


Re: r252114 - [modules] If we're given a module file, via -fmodule-file=, for a module, but

2016-01-08 Thread Adrian Prantl via cfe-commits

> On Jan 8, 2016, at 2:39 PM, Adrian Prantl  wrote:
> 
> Hi Richard,
> 
> This change 
>> @@ -2239,16 +2240,21 @@ ASTReader::ReadControlBlock(ModuleFile ,
> [...]
>> -  if (!DisableValidation && Result != Success &&
>> -  (Result != ConfigurationMismatch || 
>> !AllowConfigurationMismatch))
>> +  if (DisableValidation ||
>> +  (AllowConfigurationMismatch && Result == 
>> ConfigurationMismatch))
>> +Result = Success;
>> +
>> +  // If we've diagnosed a problem, we're done.
>> +  if (Result != Success &&
>> +  isDiagnosedResult(Result, ClientLoadCapabilities))
>> return Result;
> 
> either causes or uncovers a bug:
> 
>> CC=/Volumes/Data/llvm/_build.ninja.debug/bin/clang # r256948
>> rm -rf cache && mkdir cache
>> rm -rf Test && mkdir Test
>> echo 'module Test {
>>  umbrella header "Test.h"
>> }' >Test/module.modulemap
>> touch Test/Test.h
>> echo '#import '>2.m
>> 
>> clang -x objective-c -fmodules -fmodules-cache-path=cache  -DA=0 -I. -c 2.m 
>> -o 1.o
>> clang -x objective-c -fmodules -fmodules-cache-path=cache -Werror -DA=0 -I. 
>> -c 2.m -o 2.o
>> 
> 
> 
> After encountering a configuration mismatch or out-of-date error, we now 
> continue instead of returning early and subsequently crash in
> 
>  ASTReader::ReadControlBlock()
>ASTReader::getInputFile()
>  Cursor.JumpToBit(F.InputFileOffsets[ID-1]);
> 
> I’ll keep digging deeper, but I thought you may have an intuition of what’s 
> going on here.
> Is the behavior change intentional? From the commit message it sounds as if 
> implicit module builds shouldn’t be affected.

In my particular crash isDiagnosedResult returns false for an OutOfDate result 
thus skipping the early return.

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


Re: [clang-tools-extra] r257178 - [clang-tidy] Add non-inline function definition and variable definition check in header files.

2016-01-08 Thread Alexander Kornienko via cfe-commits
I don't see how -Wmissing-declarations relates to this check. None of the
warnings in the MissingDeclarations group in DiagnosticSemaKinds.td seem to
be anywhere close to what this check does. Am I missing something?

On Fri, Jan 8, 2016 at 7:53 PM, David Blaikie  wrote:

> This sounds sort of like the missing-declaration warning in Clang, no?
> (granted, it's a bit more direct & thus perhaps easier to use, but fulfills
> a similar purpose)
>
> On Fri, Jan 8, 2016 at 8:37 AM, Alexander Kornienko via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: alexfh
>> Date: Fri Jan  8 10:37:11 2016
>> New Revision: 257178
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=257178=rev
>> Log:
>> [clang-tidy] Add non-inline function definition and variable definition
>> check in header files.
>>
>> Summary: The new check will find all functionand variable definitions
>> which may violate cpp one definition rule in header file.
>>
>> Reviewers: aaron.ballman, alexfh
>>
>> Subscribers: aaron.ballman, cfe-commits
>>
>> Patch by Haojian Wu!
>>
>> Differential Revision: http://reviews.llvm.org/D15710
>>
>> Added:
>> clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
>> clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.h
>>
>> clang-tools-extra/trunk/docs/clang-tidy/checks/misc-definitions-in-headers.rst
>>
>> clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp
>> Modified:
>> clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
>> clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
>> clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
>> clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py
>> clang-tools-extra/trunk/test/lit.cfg
>>
>> Modified: clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
>> URL:
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt?rev=257178=257177=257178=diff
>>
>> ==
>> --- clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt (original)
>> +++ clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt Fri Jan  8
>> 10:37:11 2016
>> @@ -5,6 +5,7 @@ add_clang_library(clangTidyMiscModule
>>AssertSideEffectCheck.cpp
>>AssignOperatorSignatureCheck.cpp
>>BoolPointerImplicitConversionCheck.cpp
>> +  DefinitionsInHeadersCheck.cpp
>>InaccurateEraseCheck.cpp
>>InefficientAlgorithmCheck.cpp
>>MacroParenthesesCheck.cpp
>>
>> Added:
>> clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp?rev=257178=auto
>>
>> ==
>> --- clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
>> (added)
>> +++ clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
>> Fri Jan  8 10:37:11 2016
>> @@ -0,0 +1,126 @@
>> +//===--- DefinitionsInHeadersCheck.cpp -
>> clang-tidy===//
>> +//
>> +// The LLVM Compiler Infrastructure
>> +//
>> +// This file is distributed under the University of Illinois Open Source
>> +// License. See LICENSE.TXT for details.
>> +//
>>
>> +//===--===//
>> +
>> +#include "DefinitionsInHeadersCheck.h"
>> +#include "clang/AST/ASTContext.h"
>> +#include "clang/ASTMatchers/ASTMatchFinder.h"
>> +
>> +using namespace clang::ast_matchers;
>> +
>> +namespace clang {
>> +namespace tidy {
>> +namespace misc {
>> +
>> +namespace {
>> +
>> +AST_MATCHER(NamedDecl, isHeaderFileExtension) {
>> +  SourceManager& SM = Finder->getASTContext().getSourceManager();
>> +  SourceLocation ExpansionLoc = SM.getExpansionLoc(Node.getLocStart());
>> +  StringRef Filename = SM.getFilename(ExpansionLoc);
>> +  return Filename.endswith(".h") || Filename.endswith(".hh") ||
>> + Filename.endswith(".hpp") || Filename.endswith(".hxx") ||
>> + llvm::sys::path::extension(Filename).empty();
>> +}
>> +
>> +} // namespace
>> +
>> +DefinitionsInHeadersCheck::DefinitionsInHeadersCheck(
>> +StringRef Name, ClangTidyContext *Context)
>> +  : ClangTidyCheck(Name, Context),
>> +UseHeaderFileExtension(Options.get("UseHeaderFileExtension",
>> true)) {}
>> +
>> +void DefinitionsInHeadersCheck::storeOptions(
>> +ClangTidyOptions::OptionMap ) {
>> +  Options.store(Opts, "UseHeaderFileExtension", UseHeaderFileExtension);
>> +}
>> +
>> +void DefinitionsInHeadersCheck::registerMatchers(MatchFinder *Finder) {
>> +  if (UseHeaderFileExtension) {
>> +Finder->addMatcher(
>> +namedDecl(anyOf(functionDecl(isDefinition()),
>> varDecl(isDefinition())),
>> +  isHeaderFileExtension()).bind("name-decl"),
>> +this);
>> +  } else {
>> +Finder->addMatcher(
>> +

Re: r256962 - Module debugging: Defer emitting tag types until their definition

2016-01-08 Thread David Blaikie via cfe-commits
Thanks!

On Fri, Jan 8, 2016 at 5:15 PM, Adrian Prantl  wrote:

>
> > On Jan 8, 2016, at 2:18 PM, Adrian Prantl via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> >
> >>
> >> On Jan 8, 2016, at 1:59 PM, David Blaikie  wrote:
> >>
> >>
> >>
> >> On Fri, Jan 8, 2016 at 1:34 PM, Adrian Prantl 
> wrote:
> >>
> >>> On Jan 8, 2016, at 1:31 PM, David Blaikie  wrote:
> >>>
> >>>
> >>>
> >>> On Wed, Jan 6, 2016 at 11:22 AM, Adrian Prantl via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> >>> Author: adrian
> >>> Date: Wed Jan  6 13:22:19 2016
> >>> New Revision: 256962
> >>>
> >>> URL: http://llvm.org/viewvc/llvm-project?rev=256962=rev
> >>> Log:
> >>> Module debugging: Defer emitting tag types until their definition
> >>> was visited and all decls have been merged.
> >>>
> >>> We only get a single chance to emit the types for virtual classes
> because
> >>> CGDebugInfo::completeRequiredType() categorically doesn't complete
> them.
> >>>
> >>> Not sure I'm following this comment. Could you explain this in other
> words/detail?
> >>>
> >>> If we visit a declaration we shouldn't do anything, right? (no point
> putting declarations in the modules debug info, unless it's needed for
> something else?) & then when we see the definition we'd build the debug
> info for it?
> >>
> >> Yes. Your statement pretty much summarizes this commit :-)
> >>
> >> Then I'm still confused - were we emitting type declarations in modules
> prior to this change?
> >
> > Yes. Dsymutil used to expect every forward declaration in a skeleton CU
> to have a corresponding declaration in the module dwo. I just verified that
> dsymutil does no longer prune forward declarations from skeleton CUs that
> don’t have a definition in the DWO, so everything should be fine now.
> >
> >> Perhaps a test case for a lone declaration (with no follow up
> definition) would be in order, then?
> >
> > Yes, that would make sense. I’ll add one.
>
> Done in r257241.
> -- adrian
> >
> >>
> >> -- adrian
> >>
> >>>
> >>>
> >>> Modified:
> >>> cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
> >>> cfe/trunk/test/Modules/Inputs/DebugCXX.h
> >>> cfe/trunk/test/Modules/ModuleDebugInfo.cpp
> >>>
> >>> Modified: cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
> >>> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp?rev=256962=256961=256962=diff
> >>>
> ==
> >>> --- cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
> (original)
> >>> +++ cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp Wed
> Jan  6 13:22:19 2016
> >>> @@ -59,8 +59,10 @@ class PCHContainerGenerator : public AST
> >>>struct DebugTypeVisitor : public
> RecursiveASTVisitor {
> >>>  clang::CodeGen::CGDebugInfo 
> >>>  ASTContext 
> >>> -DebugTypeVisitor(clang::CodeGen::CGDebugInfo , ASTContext )
> >>> -: DI(DI), Ctx(Ctx) {}
> >>> +bool SkipTagDecls;
> >>> +DebugTypeVisitor(clang::CodeGen::CGDebugInfo , ASTContext ,
> >>> + bool SkipTagDecls)
> >>> +: DI(DI), Ctx(Ctx), SkipTagDecls(SkipTagDecls) {}
> >>>
> >>>  /// Determine whether this type can be represented in DWARF.
> >>>  static bool CanRepresent(const Type *Ty) {
> >>> @@ -75,6 +77,12 @@ class PCHContainerGenerator : public AST
> >>>  }
> >>>
> >>>  bool VisitTypeDecl(TypeDecl *D) {
> >>> +  // TagDecls may be deferred until after all decls have been
> merged and we
> >>> +  // know the complete type. Pure forward declarations will be
> skipped, but
> >>> +  // they don't need to be emitted into the module anyway.
> >>> +  if (SkipTagDecls && isa(D))
> >>> +  return true;
> >>> +
> >>>QualType QualTy = Ctx.getTypeDeclType(D);
> >>>if (!QualTy.isNull() && CanRepresent(QualTy.getTypePtr()))
> >>>  DI.getOrCreateStandaloneType(QualTy, D->getLocation());
> >>> @@ -165,7 +173,7 @@ public:
> >>>  // Collect debug info for all decls in this group.
> >>>  for (auto *I : D)
> >>>if (!I->isFromASTFile()) {
> >>> -DebugTypeVisitor DTV(*Builder->getModuleDebugInfo(), *Ctx);
> >>> +DebugTypeVisitor DTV(*Builder->getModuleDebugInfo(), *Ctx,
> true);
> >>>  DTV.TraverseDecl(I);
> >>>}
> >>>  return true;
> >>> @@ -179,6 +187,11 @@ public:
> >>>  if (Diags.hasErrorOccurred())
> >>>return;
> >>>
> >>> +if (D->isFromASTFile())
> >>> +  return;
> >>> +
> >>> +DebugTypeVisitor DTV(*Builder->getModuleDebugInfo(), *Ctx, false);
> >>> +DTV.TraverseDecl(D);
> >>>  Builder->UpdateCompletedType(D);
> >>>}
> >>>
> >>>
> >>> Modified: cfe/trunk/test/Modules/Inputs/DebugCXX.h
> >>> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/DebugCXX.h?rev=256962=256961=256962=diff
> >>>
> 

Re: r256049 - Split RequireCompleteType into a function that actually requires that the type

2016-01-08 Thread David Blaikie via cfe-commits
On Fri, Jan 8, 2016 at 4:08 PM, Richard Smith  wrote:

> On Thu, Jan 7, 2016 at 6:00 PM, David Blaikie  wrote:
>
>> On Fri, Dec 18, 2015 at 2:40 PM, Richard Smith via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: rsmith
>>> Date: Fri Dec 18 16:40:25 2015
>>> New Revision: 256049
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=256049=rev
>>> Log:
>>> Split RequireCompleteType into a function that actually requires that
>>> the type
>>> is complete (with an error produced if not) and a function that merely
>>> queries
>>> whether the type is complete. Either way we'll trigger instantiation if
>>> necessary, but only the former will diagnose and recover from missing
>>> module
>>> imports.
>>>
>>> The intent of this change is to prevent a class of bugs where code would
>>> call
>>> RequireCompleteType(..., 0) and then ignore the result. With modules, we
>>> must
>>> check the return value and use it to determine whether the definition of
>>> the
>>> type is visible.
>>>
>>> This also fixes a debug info quality issue: calls to isCompleteType do
>>> not
>>> trigger the emission of debug information for a type in
>>> limited-debug-info
>>> mode. This allows us to avoid emitting debug information for type
>>> definitions
>>> in more cases where we believe it is safe to do so.
>>>
>>
>> Thanks for mentioning - I was wondering if that was the case.
>>
>> Do you have a canonical example where we previously required the type to
>> be complete, but we now only query it?
>>
>
> The example in test/CodeGenCXX/debug-info-limited.cpp is probably as good
> as any. I regressed that one a while back while fixing an ADL bug and it's
> now doing the right thing again.
>

Oh, I remember that one now. Awesome - thanks!


>
>
>> Modified:
>>> cfe/trunk/include/clang/Sema/Sema.h
>>> cfe/trunk/lib/Sema/SemaCast.cpp
>>> cfe/trunk/lib/Sema/SemaCodeComplete.cpp
>>> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>>> cfe/trunk/lib/Sema/SemaDeclObjC.cpp
>>> cfe/trunk/lib/Sema/SemaExpr.cpp
>>> cfe/trunk/lib/Sema/SemaExprCXX.cpp
>>> cfe/trunk/lib/Sema/SemaExprObjC.cpp
>>> cfe/trunk/lib/Sema/SemaInit.cpp
>>> cfe/trunk/lib/Sema/SemaLookup.cpp
>>> cfe/trunk/lib/Sema/SemaOverload.cpp
>>> cfe/trunk/lib/Sema/SemaStmt.cpp
>>> cfe/trunk/lib/Sema/SemaStmtAsm.cpp
>>> cfe/trunk/lib/Sema/SemaTemplate.cpp
>>> cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
>>> cfe/trunk/lib/Sema/SemaType.cpp
>>> cfe/trunk/test/CodeGenCXX/debug-info-limited.cpp
>>>
>>> Modified: cfe/trunk/include/clang/Sema/Sema.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=256049=256048=256049=diff
>>>
>>> ==
>>> --- cfe/trunk/include/clang/Sema/Sema.h (original)
>>> +++ cfe/trunk/include/clang/Sema/Sema.h Fri Dec 18 16:40:25 2015
>>> @@ -1316,9 +1316,7 @@ public:
>>>
>>>/// \brief Abstract class used to diagnose incomplete types.
>>>struct TypeDiagnoser {
>>> -bool Suppressed;
>>> -
>>> -TypeDiagnoser(bool Suppressed = false) : Suppressed(Suppressed) { }
>>> +TypeDiagnoser() {}
>>>
>>>  virtual void diagnose(Sema , SourceLocation Loc, QualType T) = 0;
>>>  virtual ~TypeDiagnoser() {}
>>> @@ -1354,11 +1352,11 @@ public:
>>>
>>>public:
>>>  BoundTypeDiagnoser(unsigned DiagID, const Ts &...Args)
>>> -: TypeDiagnoser(DiagID == 0), DiagID(DiagID), Args(Args...) {}
>>> +: TypeDiagnoser(), DiagID(DiagID), Args(Args...) {
>>> +  assert(DiagID != 0 && "no diagnostic for type diagnoser");
>>> +}
>>>
>>>  void diagnose(Sema , SourceLocation Loc, QualType T) override {
>>> -  if (Suppressed)
>>> -return;
>>>const SemaDiagnosticBuilder  = S.Diag(Loc, DiagID);
>>>emit(DB, llvm::index_sequence_for());
>>>DB << T;
>>> @@ -1367,7 +1365,7 @@ public:
>>>
>>>  private:
>>>bool RequireCompleteTypeImpl(SourceLocation Loc, QualType T,
>>> -   TypeDiagnoser );
>>> +   TypeDiagnoser *Diagnoser);
>>>
>>>VisibleModuleSet VisibleModules;
>>>llvm::SmallVector VisibleModulesStack;
>>> @@ -1413,6 +1411,9 @@ public:
>>>SourceLocation Loc, const NamedDecl *D,
>>>ArrayRef Equiv);
>>>
>>> +  bool isCompleteType(SourceLocation Loc, QualType T) {
>>> +return !RequireCompleteTypeImpl(Loc, T, nullptr);
>>> +  }
>>>bool RequireCompleteType(SourceLocation Loc, QualType T,
>>> TypeDiagnoser );
>>>bool RequireCompleteType(SourceLocation Loc, QualType T,
>>> @@ -5502,6 +5503,7 @@ public:
>>>  AbstractArrayType
>>>};
>>>
>>> +  bool isAbstractType(SourceLocation Loc, QualType T);
>>>bool RequireNonAbstractType(SourceLocation Loc, QualType T,
>>>TypeDiagnoser );
>>>template 
>>> @@ -5513,9 +5515,6 @@ 

Re: [clang-tools-extra] r257178 - [clang-tidy] Add non-inline function definition and variable definition check in header files.

2016-01-08 Thread David Blaikie via cfe-commits
On Fri, Jan 8, 2016 at 6:26 PM, Alexander Kornienko 
wrote:

> I don't see how -Wmissing-declarations relates to this check. None of the
> warnings in the MissingDeclarations group in DiagnosticSemaKinds.td seem to
> be anywhere close to what this check does. Am I missing something?
>

Ah, sorry - wrong diagnostic name. Apparently it's missing-prototypes and
missing-variable-declarations (close... )

If you put a function or variable definition in a header, chances are you
were intending to declare it (or make it inline) & it has no prior
declaration, and thus the missing-declaration warning(s) would catch it:

func.cpp:1:6: warning: no previous prototype for function 'func'
[-Wmissing-prototypes]
void func() {
 ^



>
>
> On Fri, Jan 8, 2016 at 7:53 PM, David Blaikie  wrote:
>
>> This sounds sort of like the missing-declaration warning in Clang, no?
>> (granted, it's a bit more direct & thus perhaps easier to use, but fulfills
>> a similar purpose)
>>
>> On Fri, Jan 8, 2016 at 8:37 AM, Alexander Kornienko via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: alexfh
>>> Date: Fri Jan  8 10:37:11 2016
>>> New Revision: 257178
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=257178=rev
>>> Log:
>>> [clang-tidy] Add non-inline function definition and variable definition
>>> check in header files.
>>>
>>> Summary: The new check will find all functionand variable definitions
>>> which may violate cpp one definition rule in header file.
>>>
>>> Reviewers: aaron.ballman, alexfh
>>>
>>> Subscribers: aaron.ballman, cfe-commits
>>>
>>> Patch by Haojian Wu!
>>>
>>> Differential Revision: http://reviews.llvm.org/D15710
>>>
>>> Added:
>>> clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
>>> clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.h
>>>
>>> clang-tools-extra/trunk/docs/clang-tidy/checks/misc-definitions-in-headers.rst
>>>
>>> clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp
>>> Modified:
>>> clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
>>> clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
>>> clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
>>> clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py
>>> clang-tools-extra/trunk/test/lit.cfg
>>>
>>> Modified: clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt?rev=257178=257177=257178=diff
>>>
>>> ==
>>> --- clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt (original)
>>> +++ clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt Fri Jan  8
>>> 10:37:11 2016
>>> @@ -5,6 +5,7 @@ add_clang_library(clangTidyMiscModule
>>>AssertSideEffectCheck.cpp
>>>AssignOperatorSignatureCheck.cpp
>>>BoolPointerImplicitConversionCheck.cpp
>>> +  DefinitionsInHeadersCheck.cpp
>>>InaccurateEraseCheck.cpp
>>>InefficientAlgorithmCheck.cpp
>>>MacroParenthesesCheck.cpp
>>>
>>> Added:
>>> clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp?rev=257178=auto
>>>
>>> ==
>>> ---
>>> clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
>>> (added)
>>> +++
>>> clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp Fri
>>> Jan  8 10:37:11 2016
>>> @@ -0,0 +1,126 @@
>>> +//===--- DefinitionsInHeadersCheck.cpp -
>>> clang-tidy===//
>>> +//
>>> +// The LLVM Compiler Infrastructure
>>> +//
>>> +// This file is distributed under the University of Illinois Open Source
>>> +// License. See LICENSE.TXT for details.
>>> +//
>>>
>>> +//===--===//
>>> +
>>> +#include "DefinitionsInHeadersCheck.h"
>>> +#include "clang/AST/ASTContext.h"
>>> +#include "clang/ASTMatchers/ASTMatchFinder.h"
>>> +
>>> +using namespace clang::ast_matchers;
>>> +
>>> +namespace clang {
>>> +namespace tidy {
>>> +namespace misc {
>>> +
>>> +namespace {
>>> +
>>> +AST_MATCHER(NamedDecl, isHeaderFileExtension) {
>>> +  SourceManager& SM = Finder->getASTContext().getSourceManager();
>>> +  SourceLocation ExpansionLoc = SM.getExpansionLoc(Node.getLocStart());
>>> +  StringRef Filename = SM.getFilename(ExpansionLoc);
>>> +  return Filename.endswith(".h") || Filename.endswith(".hh") ||
>>> + Filename.endswith(".hpp") || Filename.endswith(".hxx") ||
>>> + llvm::sys::path::extension(Filename).empty();
>>> +}
>>> +
>>> +} // namespace
>>> +
>>> +DefinitionsInHeadersCheck::DefinitionsInHeadersCheck(
>>> +StringRef Name, ClangTidyContext *Context)
>>> +  : ClangTidyCheck(Name, 

Re: [PATCH] D15710: [clang-tidy] Add non-inline function definition and variable definition check in header files.

2016-01-08 Thread Haojian Wu via cfe-commits
hokein marked 4 inline comments as done.


Comment at: clang-tidy/misc/DefinitionsInHeadersCheck.cpp:22
@@ +21,3 @@
+
+AST_MATCHER(NamedDecl, useHeaderFileExtension) {
+  SourceManager& SM = Finder->getASTContext().getSourceManager();

alexfh wrote:
> nit: This name is not clear to me. Did you mean `isHeaderFileExtension` or 
> `usesHeaderFileExtension`?
`IsHeaderFileExtension` is more descriptive. Have renamed to it now.


http://reviews.llvm.org/D15710



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


Re: [PATCH] D15710: [clang-tidy] Add non-inline function definition and variable definition check in header files.

2016-01-08 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 44313.
hokein added a comment.

Address Alex's comments.


http://reviews.llvm.org/D15710

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/DefinitionsInHeadersCheck.cpp
  clang-tidy/misc/DefinitionsInHeadersCheck.h
  clang-tidy/misc/MiscTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-definitions-in-headers.rst
  test/clang-tidy/check_clang_tidy.py
  test/clang-tidy/misc-definitions-in-headers.hpp
  test/lit.cfg

Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -43,7 +43,8 @@
 config.test_format = lit.formats.ShTest(execute_external)
 
 # suffixes: A list of file extensions to treat as test files.
-config.suffixes = ['.c', '.cpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s', '.modularize', '.module-map-checker']
+config.suffixes = ['.c', '.cpp', '.hpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s',
+  '.modularize', '.module-map-checker']
 
 # Test-time dependencies located in directories called 'Inputs' are excluded
 # from test suites; there won't be any lit tests within them.
Index: test/clang-tidy/misc-definitions-in-headers.hpp
===
--- /dev/null
+++ test/clang-tidy/misc-definitions-in-headers.hpp
@@ -0,0 +1,135 @@
+// RUN: %check_clang_tidy %s misc-definitions-in-headers %t
+
+int f() {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f' defined in a header file;
+// CHECK-FIXES: inline int f() {
+  return 1;
+}
+
+class CA {
+  void f1() {} // OK: inline class member function definition.
+  void f2();
+  template
+  T f3() {
+T a = 1;
+return a;
+  }
+  template
+  struct CAA {
+struct CAB {
+  void f4();
+};
+  };
+};
+
+void CA::f2() { }
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: function 'f2' defined in a header file;
+// CHECK-FIXES: inline void CA::f2() {
+
+template <>
+int CA::f3() {
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: function 'f3' defined in a header file;
+  int a = 1;
+  return a;
+}
+
+template 
+void CA::CAA::CAB::f4() {
+// OK: member function definition of a nested template class in a class.
+}
+
+template 
+struct CB {
+  void f1();
+  struct CCA {
+void f2(T a);
+  };
+  struct CCB;  // OK: forward declaration.
+  static int a; // OK: class static data member declaration.
+};
+
+template 
+void CB::f1() { // OK: Member function definition of a class template.
+}
+
+template 
+void CB::CCA::f2(T a) {
+// OK: member function definition of a nested class in a class template.
+}
+
+template 
+struct CB::CCB {
+  void f3();
+};
+
+template 
+void CB::CCB::f3() {
+// OK: member function definition of a nested class in a class template.
+}
+
+template 
+int CB::a = 2; // OK: static data member definition of a class template.
+
+template 
+T tf() { // OK: template function definition.
+  T a;
+  return a;
+}
+
+
+namespace NA {
+  int f() { return 1; }
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: function 'f' defined in a header file;
+// CHECK-FIXES: inline int f() { return 1; }
+}
+
+template 
+T f3() {
+  T a = 1;
+  return a;
+}
+
+template <>
+// CHECK-MESSAGES: :[[@LINE+1]]:5: warning: function 'f3' defined in a header file;
+int f3() {
+  int a = 1;
+  return a;
+}
+
+int f5(); // OK: function declaration.
+inline int f6() { return 1; } // OK: inline function definition.
+namespace {
+  int f7() { return 1; }
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: function 'f7' defined in a header file;
+}
+
+int a = 1;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: variable 'a' defined in a header file;
+CA a1;
+// CHECK-MESSAGES: :[[@LINE-1]]:4: warning: variable 'a1' defined in a header file;
+
+namespace NB {
+  int b = 1;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: variable 'b' defined in a header file;
+  const int c = 1; // OK: internal linkage variable definition.
+}
+
+class CC {
+  static int d; // OK: class static data member declaration.
+};
+
+int CC::d = 1;
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: variable 'd' defined in a header file;
+
+const char* ca = "foo";
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: variable 'ca' defined in a header file;
+
+namespace {
+  int e = 2;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: variable 'e' defined in a header file;
+}
+
+const char* const g = "foo"; // OK: internal linkage variable definition.
+static int h = 1; // OK: internal linkage variable definition.
+const int i = 1; // OK: internal linkage variable definition.
+extern int j; // OK: internal linkage variable definition.
Index: test/clang-tidy/check_clang_tidy.py
===
--- test/clang-tidy/check_clang_tidy.py
+++ test/clang-tidy/check_clang_tidy.py
@@ -52,6 +52,8 @@
   extension = '.cpp'
   if (input_file_name.endswith('.c')):
 extension = '.c'
+  if (input_file_name.endswith('.hpp')):
+extension = '.hpp'
   temp_file_name = temp_file_name + extension
 
   

Re: [PATCH] D15710: [clang-tidy] Add non-inline function definition and variable definition check in header files.

2016-01-08 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: test/clang-tidy/misc-definitions-in-headers.hpp:5
@@ +4,3 @@
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f' defined in a header 
file; function definitions in header files can lead to ODR violations
+// CHECK-FIXES: inline int f() {
+  return 1;

Now please address the "including the check name" part and I'm happy ;)


http://reviews.llvm.org/D15710



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


Re: [PATCH] D15710: [clang-tidy] Add non-inline function definition and variable definition check in header files.

2016-01-08 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 44318.
hokein added a comment.

Add check name in test.


http://reviews.llvm.org/D15710

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/DefinitionsInHeadersCheck.cpp
  clang-tidy/misc/DefinitionsInHeadersCheck.h
  clang-tidy/misc/MiscTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-definitions-in-headers.rst
  test/clang-tidy/check_clang_tidy.py
  test/clang-tidy/misc-definitions-in-headers.hpp
  test/lit.cfg

Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -43,7 +43,8 @@
 config.test_format = lit.formats.ShTest(execute_external)
 
 # suffixes: A list of file extensions to treat as test files.
-config.suffixes = ['.c', '.cpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s', '.modularize', '.module-map-checker']
+config.suffixes = ['.c', '.cpp', '.hpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s',
+  '.modularize', '.module-map-checker']
 
 # Test-time dependencies located in directories called 'Inputs' are excluded
 # from test suites; there won't be any lit tests within them.
Index: test/clang-tidy/misc-definitions-in-headers.hpp
===
--- /dev/null
+++ test/clang-tidy/misc-definitions-in-headers.hpp
@@ -0,0 +1,135 @@
+// RUN: %check_clang_tidy %s misc-definitions-in-headers %t
+
+int f() {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f' defined in a header file; function definitions in header files can lead to ODR violations [misc-definitions-in-headers]
+// CHECK-FIXES: inline int f() {
+  return 1;
+}
+
+class CA {
+  void f1() {} // OK: inline class member function definition.
+  void f2();
+  template
+  T f3() {
+T a = 1;
+return a;
+  }
+  template
+  struct CAA {
+struct CAB {
+  void f4();
+};
+  };
+};
+
+void CA::f2() { }
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: function 'f2' defined in a header file;
+// CHECK-FIXES: inline void CA::f2() {
+
+template <>
+int CA::f3() {
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: function 'f3' defined in a header file;
+  int a = 1;
+  return a;
+}
+
+template 
+void CA::CAA::CAB::f4() {
+// OK: member function definition of a nested template class in a class.
+}
+
+template 
+struct CB {
+  void f1();
+  struct CCA {
+void f2(T a);
+  };
+  struct CCB;  // OK: forward declaration.
+  static int a; // OK: class static data member declaration.
+};
+
+template 
+void CB::f1() { // OK: Member function definition of a class template.
+}
+
+template 
+void CB::CCA::f2(T a) {
+// OK: member function definition of a nested class in a class template.
+}
+
+template 
+struct CB::CCB {
+  void f3();
+};
+
+template 
+void CB::CCB::f3() {
+// OK: member function definition of a nested class in a class template.
+}
+
+template 
+int CB::a = 2; // OK: static data member definition of a class template.
+
+template 
+T tf() { // OK: template function definition.
+  T a;
+  return a;
+}
+
+
+namespace NA {
+  int f() { return 1; }
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: function 'f' defined in a header file;
+// CHECK-FIXES: inline int f() { return 1; }
+}
+
+template 
+T f3() {
+  T a = 1;
+  return a;
+}
+
+template <>
+// CHECK-MESSAGES: :[[@LINE+1]]:5: warning: function 'f3' defined in a header file;
+int f3() {
+  int a = 1;
+  return a;
+}
+
+int f5(); // OK: function declaration.
+inline int f6() { return 1; } // OK: inline function definition.
+namespace {
+  int f7() { return 1; }
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: function 'f7' defined in a header file;
+}
+
+int a = 1;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: variable 'a' defined in a header file; variable definitions in header files can lead to ODR violations [misc-definitions-in-headers]
+CA a1;
+// CHECK-MESSAGES: :[[@LINE-1]]:4: warning: variable 'a1' defined in a header file;
+
+namespace NB {
+  int b = 1;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: variable 'b' defined in a header file;
+  const int c = 1; // OK: internal linkage variable definition.
+}
+
+class CC {
+  static int d; // OK: class static data member declaration.
+};
+
+int CC::d = 1;
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: variable 'd' defined in a header file;
+
+const char* ca = "foo";
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: variable 'ca' defined in a header file;
+
+namespace {
+  int e = 2;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: variable 'e' defined in a header file;
+}
+
+const char* const g = "foo"; // OK: internal linkage variable definition.
+static int h = 1; // OK: internal linkage variable definition.
+const int i = 1; // OK: internal linkage variable definition.
+extern int j; // OK: internal linkage variable definition.
Index: test/clang-tidy/check_clang_tidy.py
===
--- test/clang-tidy/check_clang_tidy.py
+++ test/clang-tidy/check_clang_tidy.py
@@ -52,6 +52,8 @@
   extension = '.cpp'
   if 

[PATCH] D15994: Allow for unfinished #if blocks in preambles.

2016-01-08 Thread Erik Verbruggen via cfe-commits
erikjv created this revision.
erikjv added a reviewer: bkramer.
erikjv added a subscriber: cfe-commits.

Previously, a preamble only included #if blocks (and friends like
#ifdef) if there was a corresponding #endif before any declaration or
definition. The problem is that any header file that uses include guards
will not have a preamble generated, which makes code-completion very
slow.

This fixes PR26045.


http://reviews.llvm.org/D15994

Files:
  lib/Lex/Lexer.cpp
  test/Lexer/preamble.c
  test/Lexer/preamble2.c

Index: test/Lexer/preamble2.c
===
--- /dev/null
+++ test/Lexer/preamble2.c
@@ -0,0 +1,19 @@
+// Preamble detection test: header with an include guard.
+#ifndef HEADER_H
+#define HEADER_H
+#include "foo"
+int bar;
+#endif
+
+// This test checks for detection of the preamble of a file, which
+// includes all of the starting comments and #includes.
+
+// RUN: %clang_cc1 -print-preamble %s > %t
+// RUN: echo END. >> %t
+// RUN: FileCheck < %t %s
+
+// CHECK: // Preamble detection test: header with an include guard.
+// CHECK-NEXT: #ifndef HEADER_H
+// CHECK-NEXT: #define HEADER_H
+// CHECK-NEXT: #include "foo"
+// CHECK-NEXT: END.
Index: test/Lexer/preamble.c
===
--- test/Lexer/preamble.c
+++ test/Lexer/preamble.c
@@ -9,15 +9,12 @@
 #pragma unknown
 #endif
 #ifdef WIBBLE
-#include "honk"
-#else
-int foo();
+#include "foo"
+int bar;
 #endif
 
 // This test checks for detection of the preamble of a file, which
-// includes all of the starting comments and #includes. Note that any
-// changes to the preamble part of this file must be mirrored in
-// Inputs/preamble.txt, since we diff against it.
+// includes all of the starting comments and #includes.
 
 // RUN: %clang_cc1 -print-preamble %s > %t
 // RUN: echo END. >> %t
@@ -33,4 +30,6 @@
 // CHECK-NEXT: #endif
 // CHECK-NEXT: #pragma unknown
 // CHECK-NEXT: #endif
+// CHECK-NEXT: #ifdef WIBBLE
+// CHECK-NEXT: #include "foo"
 // CHECK-NEXT: END.
Index: lib/Lex/Lexer.cpp
===
--- lib/Lex/Lexer.cpp
+++ lib/Lex/Lexer.cpp
@@ -552,7 +552,7 @@
   bool InPreprocessorDirective = false;
   Token TheTok;
   Token IfStartTok;
-  unsigned IfCount = 0;
+  int IfCount = 0;
   SourceLocation ActiveCommentLoc;
 
   unsigned MaxLineOffset = 0;
@@ -656,8 +656,10 @@
 
 case PDK_EndIf:
   // Mismatched #endif. The preamble ends here.
-  if (IfCount == 0)
+  if (IfCount == 0) {
+--IfCount;
 break;
+  }
 
   --IfCount;
   continue;
@@ -682,7 +684,8 @@
   } while (true);
   
   SourceLocation End;
-  if (IfCount)
+  if (IfCount < 0) // This allows for open #ifs, so a header with an include
+   // guard will have a preamble generated for it.
 End = IfStartTok.getLocation();
   else if (ActiveCommentLoc.isValid())
 End = ActiveCommentLoc; // don't truncate a decl comment.


Index: test/Lexer/preamble2.c
===
--- /dev/null
+++ test/Lexer/preamble2.c
@@ -0,0 +1,19 @@
+// Preamble detection test: header with an include guard.
+#ifndef HEADER_H
+#define HEADER_H
+#include "foo"
+int bar;
+#endif
+
+// This test checks for detection of the preamble of a file, which
+// includes all of the starting comments and #includes.
+
+// RUN: %clang_cc1 -print-preamble %s > %t
+// RUN: echo END. >> %t
+// RUN: FileCheck < %t %s
+
+// CHECK: // Preamble detection test: header with an include guard.
+// CHECK-NEXT: #ifndef HEADER_H
+// CHECK-NEXT: #define HEADER_H
+// CHECK-NEXT: #include "foo"
+// CHECK-NEXT: END.
Index: test/Lexer/preamble.c
===
--- test/Lexer/preamble.c
+++ test/Lexer/preamble.c
@@ -9,15 +9,12 @@
 #pragma unknown
 #endif
 #ifdef WIBBLE
-#include "honk"
-#else
-int foo();
+#include "foo"
+int bar;
 #endif
 
 // This test checks for detection of the preamble of a file, which
-// includes all of the starting comments and #includes. Note that any
-// changes to the preamble part of this file must be mirrored in
-// Inputs/preamble.txt, since we diff against it.
+// includes all of the starting comments and #includes.
 
 // RUN: %clang_cc1 -print-preamble %s > %t
 // RUN: echo END. >> %t
@@ -33,4 +30,6 @@
 // CHECK-NEXT: #endif
 // CHECK-NEXT: #pragma unknown
 // CHECK-NEXT: #endif
+// CHECK-NEXT: #ifdef WIBBLE
+// CHECK-NEXT: #include "foo"
 // CHECK-NEXT: END.
Index: lib/Lex/Lexer.cpp
===
--- lib/Lex/Lexer.cpp
+++ lib/Lex/Lexer.cpp
@@ -552,7 +552,7 @@
   bool InPreprocessorDirective = false;
   Token TheTok;
   Token IfStartTok;
-  unsigned IfCount = 0;
+  int IfCount = 0;
   SourceLocation ActiveCommentLoc;
 
   unsigned MaxLineOffset = 0;
@@ -656,8 +656,10 @@
 
 case 

Re: [PATCH] D15921: [analyzer] Utility to match function calls.

2016-01-08 Thread Gábor Horváth via cfe-commits
xazax.hun updated this revision to Diff 44325.
xazax.hun added a comment.

Updated the comments.


http://reviews.llvm.org/D15921

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
  lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp
  lib/StaticAnalyzer/Core/CheckerContext.cpp

Index: lib/StaticAnalyzer/Core/CheckerContext.cpp
===
--- lib/StaticAnalyzer/Core/CheckerContext.cpp
+++ lib/StaticAnalyzer/Core/CheckerContext.cpp
@@ -13,6 +13,7 @@
 //===--===//
 
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
 #include "clang/Basic/Builtins.h"
 #include "clang/Lex/Lexer.h"
 
@@ -35,6 +36,16 @@
   return funI->getName();
 }
 
+bool CheckerContext::isCalled(const CallEvent ,
+  const CallDescription ) {
+  assert(Call.getKind() != CE_ObjCMessage && "Obj-C methods are not supported");
+  if (!CD.II)
+CD.II = ().Idents.get(CD.FuncName);
+  if (Call.getCalleeIdentifier() != CD.II)
+return false;
+  return (CD.RequiredArgs == CallDescription::NoArgRequirement ||
+  CD.RequiredArgs == Call.getNumArgs());
+}
 
 bool CheckerContext::isCLibraryFunction(const FunctionDecl *FD,
 StringRef Name) {
Index: lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp
+++ lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp
@@ -51,14 +51,11 @@
check::PreCall,
check::DeadSymbols,
check::PointerEscape> {
-
-  mutable IdentifierInfo *IIfopen, *IIfclose;
+  CallDescription OpenFn, CloseFn;
 
   std::unique_ptr DoubleCloseBugType;
   std::unique_ptr LeakBugType;
 
-  void initIdentifierInfo(ASTContext ) const;
-
   void reportDoubleClose(SymbolRef FileDescSym,
  const CallEvent ,
  CheckerContext ) const;
@@ -106,7 +103,7 @@
 } // end anonymous namespace
 
 SimpleStreamChecker::SimpleStreamChecker()
-: IIfopen(nullptr), IIfclose(nullptr) {
+: OpenFn("fopen"), CloseFn("fclose", 1) {
   // Initialize the bug types.
   DoubleCloseBugType.reset(
   new BugType(this, "Double fclose", "Unix Stream API Error"));
@@ -119,12 +116,10 @@
 
 void SimpleStreamChecker::checkPostCall(const CallEvent ,
 CheckerContext ) const {
-  initIdentifierInfo(C.getASTContext());
-
   if (!Call.isGlobalCFunction())
 return;
 
-  if (Call.getCalleeIdentifier() != IIfopen)
+  if (!C.isCalled(Call, OpenFn))
 return;
 
   // Get the symbolic value corresponding to the file handle.
@@ -140,15 +135,10 @@
 
 void SimpleStreamChecker::checkPreCall(const CallEvent ,
CheckerContext ) const {
-  initIdentifierInfo(C.getASTContext());
-
   if (!Call.isGlobalCFunction())
 return;
 
-  if (Call.getCalleeIdentifier() != IIfclose)
-return;
-
-  if (Call.getNumArgs() != 1)
+  if (!C.isCalled(Call, CloseFn))
 return;
 
   // Get the symbolic value corresponding to the file handle.
@@ -275,13 +265,6 @@
   return State;
 }
 
-void SimpleStreamChecker::initIdentifierInfo(ASTContext ) const {
-  if (IIfopen)
-return;
-  IIfopen = ("fopen");
-  IIfclose = ("fclose");
-}
-
 void ento::registerSimpleStreamChecker(CheckerManager ) {
   mgr.registerChecker();
 }
Index: include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
@@ -66,6 +66,26 @@
   #define REGISTER_LIST_WITH_PROGRAMSTATE(Name, Elem) \
 REGISTER_TRAIT_WITH_PROGRAMSTATE(Name, llvm::ImmutableList)
 
+/// This class represents a description of a function call using the number of
+/// arguments and the name of the function.
+class CallDescription {
+  friend class CheckerContext;
+  mutable IdentifierInfo *II;
+  StringRef FuncName;
+  unsigned RequiredArgs;
+
+public:
+  const static unsigned NoArgRequirement = ~0;
+  /// \brief Constructs a CallDescription object.
+  ///
+  /// @param FuncName The name of the function that will be matched.
+  ///
+  /// @param RequiredArgs The number of arguments that is expected to match a
+  /// call. Omit this parameter to match every occurance of call with a given
+  /// name regardless the number of arguments.
+  CallDescription(StringRef FuncName, unsigned RequiredArgs = NoArgRequirement)
+  : FuncName(FuncName), RequiredArgs(RequiredArgs) {}
+};
 
 class CheckerContext {
   ExprEngine 
@@ -284,6 +304,13 @@
 return getCalleeName(FunDecl);
  

Re: [PATCH] D15710: [clang-tidy] Add non-inline function definition and variable definition check in header files.

2016-01-08 Thread Haojian Wu via cfe-commits
hokein marked an inline comment as done.
hokein added a comment.

http://reviews.llvm.org/D15710



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


Re: [PATCH] D15921: [analyzer] Utility to match function calls.

2016-01-08 Thread Gábor Horváth via cfe-commits
xazax.hun updated this revision to Diff 44322.
xazax.hun marked 4 inline comments as done.
xazax.hun added a comment.

- Removed support for matching ObjC messages. It might be added in a later.
- Addressed review comments.


http://reviews.llvm.org/D15921

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
  lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp
  lib/StaticAnalyzer/Core/CheckerContext.cpp

Index: lib/StaticAnalyzer/Core/CheckerContext.cpp
===
--- lib/StaticAnalyzer/Core/CheckerContext.cpp
+++ lib/StaticAnalyzer/Core/CheckerContext.cpp
@@ -13,6 +13,7 @@
 //===--===//
 
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
 #include "clang/Basic/Builtins.h"
 #include "clang/Lex/Lexer.h"
 
@@ -35,6 +36,16 @@
   return funI->getName();
 }
 
+bool CheckerContext::isCalled(const CallEvent ,
+  const CallDescription ) {
+  assert(Call.getKind() != CE_ObjCMessage && "Obj-C methods are not supported");
+  if (!CD.II)
+CD.II = ().Idents.get(CD.FuncName);
+  if (Call.getCalleeIdentifier() != CD.II)
+return false;
+  return (CD.RequiredArgs == CallDescription::NoArgRequirement ||
+  CD.RequiredArgs == Call.getNumArgs());
+}
 
 bool CheckerContext::isCLibraryFunction(const FunctionDecl *FD,
 StringRef Name) {
Index: lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp
+++ lib/StaticAnalyzer/Checkers/SimpleStreamChecker.cpp
@@ -51,14 +51,11 @@
check::PreCall,
check::DeadSymbols,
check::PointerEscape> {
-
-  mutable IdentifierInfo *IIfopen, *IIfclose;
+  CallDescription OpenFn, CloseFn;
 
   std::unique_ptr DoubleCloseBugType;
   std::unique_ptr LeakBugType;
 
-  void initIdentifierInfo(ASTContext ) const;
-
   void reportDoubleClose(SymbolRef FileDescSym,
  const CallEvent ,
  CheckerContext ) const;
@@ -106,7 +103,7 @@
 } // end anonymous namespace
 
 SimpleStreamChecker::SimpleStreamChecker()
-: IIfopen(nullptr), IIfclose(nullptr) {
+: OpenFn("fopen"), CloseFn("fclose", 1) {
   // Initialize the bug types.
   DoubleCloseBugType.reset(
   new BugType(this, "Double fclose", "Unix Stream API Error"));
@@ -119,12 +116,10 @@
 
 void SimpleStreamChecker::checkPostCall(const CallEvent ,
 CheckerContext ) const {
-  initIdentifierInfo(C.getASTContext());
-
   if (!Call.isGlobalCFunction())
 return;
 
-  if (Call.getCalleeIdentifier() != IIfopen)
+  if (!C.isCalled(Call, OpenFn))
 return;
 
   // Get the symbolic value corresponding to the file handle.
@@ -140,15 +135,10 @@
 
 void SimpleStreamChecker::checkPreCall(const CallEvent ,
CheckerContext ) const {
-  initIdentifierInfo(C.getASTContext());
-
   if (!Call.isGlobalCFunction())
 return;
 
-  if (Call.getCalleeIdentifier() != IIfclose)
-return;
-
-  if (Call.getNumArgs() != 1)
+  if (!C.isCalled(Call, CloseFn))
 return;
 
   // Get the symbolic value corresponding to the file handle.
@@ -275,13 +265,6 @@
   return State;
 }
 
-void SimpleStreamChecker::initIdentifierInfo(ASTContext ) const {
-  if (IIfopen)
-return;
-  IIfopen = ("fopen");
-  IIfclose = ("fclose");
-}
-
 void ento::registerSimpleStreamChecker(CheckerManager ) {
   mgr.registerChecker();
 }
Index: include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
@@ -66,6 +66,28 @@
   #define REGISTER_LIST_WITH_PROGRAMSTATE(Name, Elem) \
 REGISTER_TRAIT_WITH_PROGRAMSTATE(Name, llvm::ImmutableList)
 
+/// This class represents a description of a function call using the number of
+/// arguments and the name of the function. It can also represent descriptions
+/// of Obj-C message expressions.
+class CallDescription {
+  friend class CheckerContext;
+  mutable IdentifierInfo *II;
+  StringRef FuncName;
+  unsigned RequiredArgs;
+
+public:
+  const static unsigned NoArgRequirement = ~0;
+  /// \brief Constructs a CallDescription object.
+  ///
+  /// @param FuncName The name of the function or the selector that will be
+  /// matched.
+  ///
+  /// @param RequiredArgs The number of arguments that is expected to match a
+  /// call. Omit this parameter to match every occurance of call with a given
+  /// name regardless the number of arguments.
+  

Re: [PATCH] D15710: [clang-tidy] Add non-inline function definition and variable definition check in header files.

2016-01-08 Thread Haojian Wu via cfe-commits
hokein marked 3 inline comments as done.


Comment at: test/clang-tidy/misc-definitions-in-headers.hpp:4
@@ +3,3 @@
+int f() {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f' defined in a header 
file;
+// CHECK-FIXES: inline int f() {

alexfh wrote:
> Please specify each distinct warning message (in your case, there are two of 
> them) completely (including the check name) once. Having it in the test (just 
> once) is useful to verify that the message is formatted correctly (in your 
> case, there's no space after the ';', for example).
Didn't notice it. Done (also add a space after ";").


http://reviews.llvm.org/D15710



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


Re: [PATCH] D15710: [clang-tidy] Add non-inline function definition and variable definition check in header files.

2016-01-08 Thread Haojian Wu via cfe-commits
hokein marked an inline comment as done.
hokein added a comment.

http://reviews.llvm.org/D15710



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


Re: [PATCH] D15710: [clang-tidy] Add non-inline function definition and variable definition check in header files.

2016-01-08 Thread Haojian Wu via cfe-commits
hokein updated this revision to Diff 44317.
hokein added a comment.

More updates.


http://reviews.llvm.org/D15710

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/DefinitionsInHeadersCheck.cpp
  clang-tidy/misc/DefinitionsInHeadersCheck.h
  clang-tidy/misc/MiscTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-definitions-in-headers.rst
  test/clang-tidy/check_clang_tidy.py
  test/clang-tidy/misc-definitions-in-headers.hpp
  test/lit.cfg

Index: test/lit.cfg
===
--- test/lit.cfg
+++ test/lit.cfg
@@ -43,7 +43,8 @@
 config.test_format = lit.formats.ShTest(execute_external)
 
 # suffixes: A list of file extensions to treat as test files.
-config.suffixes = ['.c', '.cpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s', '.modularize', '.module-map-checker']
+config.suffixes = ['.c', '.cpp', '.hpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s',
+  '.modularize', '.module-map-checker']
 
 # Test-time dependencies located in directories called 'Inputs' are excluded
 # from test suites; there won't be any lit tests within them.
Index: test/clang-tidy/misc-definitions-in-headers.hpp
===
--- /dev/null
+++ test/clang-tidy/misc-definitions-in-headers.hpp
@@ -0,0 +1,135 @@
+// RUN: %check_clang_tidy %s misc-definitions-in-headers %t
+
+int f() {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f' defined in a header file; function definitions in header files can lead to ODR violations
+// CHECK-FIXES: inline int f() {
+  return 1;
+}
+
+class CA {
+  void f1() {} // OK: inline class member function definition.
+  void f2();
+  template
+  T f3() {
+T a = 1;
+return a;
+  }
+  template
+  struct CAA {
+struct CAB {
+  void f4();
+};
+  };
+};
+
+void CA::f2() { }
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: function 'f2' defined in a header file;
+// CHECK-FIXES: inline void CA::f2() {
+
+template <>
+int CA::f3() {
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: function 'f3' defined in a header file;
+  int a = 1;
+  return a;
+}
+
+template 
+void CA::CAA::CAB::f4() {
+// OK: member function definition of a nested template class in a class.
+}
+
+template 
+struct CB {
+  void f1();
+  struct CCA {
+void f2(T a);
+  };
+  struct CCB;  // OK: forward declaration.
+  static int a; // OK: class static data member declaration.
+};
+
+template 
+void CB::f1() { // OK: Member function definition of a class template.
+}
+
+template 
+void CB::CCA::f2(T a) {
+// OK: member function definition of a nested class in a class template.
+}
+
+template 
+struct CB::CCB {
+  void f3();
+};
+
+template 
+void CB::CCB::f3() {
+// OK: member function definition of a nested class in a class template.
+}
+
+template 
+int CB::a = 2; // OK: static data member definition of a class template.
+
+template 
+T tf() { // OK: template function definition.
+  T a;
+  return a;
+}
+
+
+namespace NA {
+  int f() { return 1; }
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: function 'f' defined in a header file;
+// CHECK-FIXES: inline int f() { return 1; }
+}
+
+template 
+T f3() {
+  T a = 1;
+  return a;
+}
+
+template <>
+// CHECK-MESSAGES: :[[@LINE+1]]:5: warning: function 'f3' defined in a header file;
+int f3() {
+  int a = 1;
+  return a;
+}
+
+int f5(); // OK: function declaration.
+inline int f6() { return 1; } // OK: inline function definition.
+namespace {
+  int f7() { return 1; }
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: function 'f7' defined in a header file;
+}
+
+int a = 1;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: variable 'a' defined in a header file; variable definitions in header files can lead to ODR violations
+CA a1;
+// CHECK-MESSAGES: :[[@LINE-1]]:4: warning: variable 'a1' defined in a header file;
+
+namespace NB {
+  int b = 1;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: variable 'b' defined in a header file;
+  const int c = 1; // OK: internal linkage variable definition.
+}
+
+class CC {
+  static int d; // OK: class static data member declaration.
+};
+
+int CC::d = 1;
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: variable 'd' defined in a header file;
+
+const char* ca = "foo";
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: variable 'ca' defined in a header file;
+
+namespace {
+  int e = 2;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: variable 'e' defined in a header file;
+}
+
+const char* const g = "foo"; // OK: internal linkage variable definition.
+static int h = 1; // OK: internal linkage variable definition.
+const int i = 1; // OK: internal linkage variable definition.
+extern int j; // OK: internal linkage variable definition.
Index: test/clang-tidy/check_clang_tidy.py
===
--- test/clang-tidy/check_clang_tidy.py
+++ test/clang-tidy/check_clang_tidy.py
@@ -52,6 +52,8 @@
   extension = '.cpp'
   if (input_file_name.endswith('.c')):
 extension = '.c'
+  if 

r257135 - [PPC] Add long long/double support for vec_cts, vec_ctu and vec_ctf

2016-01-08 Thread Kyle Butt via cfe-commits
Author: iteratee
Date: Thu Jan  7 20:00:48 2016
New Revision: 257135

URL: http://llvm.org/viewvc/llvm-project?rev=257135=rev
Log:
[PPC] Add long long/double support for vec_cts, vec_ctu and vec_ctf

Add long long/double support for vec_cts, vec_ctu and vec_ctf.

Similar to this change in GCC:
https://gcc.gnu.org/ml/gcc-patches/2014-08/msg02653.html

Patch by Tim Shen.

Modified:
cfe/trunk/lib/Headers/altivec.h
cfe/trunk/test/CodeGen/builtins-ppc-vsx.c

Modified: cfe/trunk/lib/Headers/altivec.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/altivec.h?rev=257135=257134=257135=diff
==
--- cfe/trunk/lib/Headers/altivec.h (original)
+++ cfe/trunk/lib/Headers/altivec.h Thu Jan  7 20:00:48 2016
@@ -1891,6 +1891,22 @@ static vector float __ATTRS_o_ai vec_ctf
   return __builtin_altivec_vcfux((vector int)__a, __b);
 }
 
+#ifdef __VSX__
+static vector double __ATTRS_o_ai vec_ctf(vector unsigned long long __a,
+  int __b) {
+  vector double __ret = __builtin_convertvector(__a, vector double);
+  __ret *= (vector double)(vector unsigned long long)((0x3ffULL - __b) << 52);
+  return __ret;
+}
+
+static vector double __ATTRS_o_ai vec_ctf(vector signed long long __a,
+  int __b) {
+  vector double __ret = __builtin_convertvector(__a, vector double);
+  __ret *= (vector double)(vector unsigned long long)((0x3ffULL - __b) << 52);
+  return __ret;
+}
+#endif
+
 /* vec_vcfsx */
 
 static vector float __attribute__((__always_inline__))
@@ -1907,11 +1923,18 @@ vec_vcfux(vector unsigned int __a, int _
 
 /* vec_cts */
 
-static vector int __attribute__((__always_inline__))
-vec_cts(vector float __a, int __b) {
+static vector int __ATTRS_o_ai vec_cts(vector float __a, int __b) {
   return __builtin_altivec_vctsxs(__a, __b);
 }
 
+#ifdef __VSX__
+static vector signed long long __ATTRS_o_ai vec_cts(vector double __a,
+int __b) {
+  __a *= (vector double)(vector unsigned long long)((0x3ffULL + __b) << 52);
+  return __builtin_convertvector(__a, vector signed long long);
+}
+#endif
+
 /* vec_vctsxs */
 
 static vector int __attribute__((__always_inline__))
@@ -1921,11 +1944,18 @@ vec_vctsxs(vector float __a, int __b) {
 
 /* vec_ctu */
 
-static vector unsigned int __attribute__((__always_inline__))
-vec_ctu(vector float __a, int __b) {
+static vector unsigned int __ATTRS_o_ai vec_ctu(vector float __a, int __b) {
   return __builtin_altivec_vctuxs(__a, __b);
 }
 
+#ifdef __VSX__
+static vector unsigned long long __ATTRS_o_ai vec_ctu(vector double __a,
+  int __b) {
+  __a *= (vector double)(vector unsigned long long)((0x3ffULL + __b) << 52);
+  return __builtin_convertvector(__a, vector unsigned long long);
+}
+#endif
+
 /* vec_vctuxs */
 
 static vector unsigned int __attribute__((__always_inline__))

Modified: cfe/trunk/test/CodeGen/builtins-ppc-vsx.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-ppc-vsx.c?rev=257135=257134=257135=diff
==
--- cfe/trunk/test/CodeGen/builtins-ppc-vsx.c (original)
+++ cfe/trunk/test/CodeGen/builtins-ppc-vsx.c Thu Jan  7 20:00:48 2016
@@ -845,4 +845,51 @@ void test1() {
 // CHECK: xor <2 x i64>
 // CHECK-LE: xor <2 x i64>
 
+  res_vsll = vec_cts(vd, 0);
+// CHECK: fmul <2 x double>
+// CHECK: fptosi <2 x double> %{{.*}} to <2 x i64>
+// CHECK-LE: fmul <2 x double>
+// CHECK-LE: fptosi <2 x double> %{{.*}} to <2 x i64>
+
+  res_vsll = vec_cts(vd, 31);
+// CHECK: fmul <2 x double>
+// CHECK: fptosi <2 x double> %{{.*}} to <2 x i64>
+// CHECK-LE: fmul <2 x double>
+// CHECK-LE: fptosi <2 x double> %{{.*}} to <2 x i64>
+
+  res_vsll = vec_ctu(vd, 0);
+// CHECK: fmul <2 x double>
+// CHECK: fptoui <2 x double> %{{.*}} to <2 x i64>
+// CHECK-LE: fmul <2 x double>
+// CHECK-LE: fptoui <2 x double> %{{.*}} to <2 x i64>
+
+  res_vsll = vec_ctu(vd, 31);
+// CHECK: fmul <2 x double>
+// CHECK: fptoui <2 x double> %{{.*}} to <2 x i64>
+// CHECK-LE: fmul <2 x double>
+// CHECK-LE: fptoui <2 x double> %{{.*}} to <2 x i64>
+
+  res_vd = vec_ctf(vsll, 0);
+// CHECK: sitofp <2 x i64> %{{.*}} to <2 x double>
+// CHECK: fmul <2 x double>
+// CHECK-LE: sitofp <2 x i64> %{{.*}} to <2 x double>
+// CHECK-LE: fmul <2 x double>
+
+  res_vd = vec_ctf(vsll, 31);
+// CHECK: sitofp <2 x i64> %{{.*}} to <2 x double>
+// CHECK: fmul <2 x double>
+// CHECK-LE: sitofp <2 x i64> %{{.*}} to <2 x double>
+// CHECK-LE: fmul <2 x double>
+
+  res_vd = vec_ctf(vull, 0);
+// CHECK: uitofp <2 x i64> %{{.*}} to <2 x double>
+// CHECK: fmul <2 x double>
+// CHECK-LE: uitofp <2 x i64> %{{.*}} to <2 x double>
+// CHECK-LE: fmul <2 x double>
+
+  res_vd = vec_ctf(vull, 31);
+// CHECK: uitofp <2 x i64> %{{.*}} to <2 x double>
+// CHECK: fmul <2 x double>
+// 

Re: [PATCH] D15710: [clang-tidy] Add non-inline function definition and variable definition check in header files.

2016-01-08 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Looks good with a few nits. Please fix them and I'll submit the patch for you.

Thank you for working on this!



Comment at: clang-tidy/misc/DefinitionsInHeadersCheck.cpp:23
@@ +22,3 @@
+AST_MATCHER(NamedDecl, isHeaderFileExtension) {
+  SourceManager& SM = Finder->getASTContext().getSourceManager();
+  SourceLocation ExpansionLoc = SM.getExpansionLoc(Node.getLocStart());

Actually, this name is also confusing, but I don't have a better idea now. 
Let's leave it like this.


Comment at: clang-tidy/misc/DefinitionsInHeadersCheck.cpp:25
@@ +24,3 @@
+  SourceLocation ExpansionLoc = SM.getExpansionLoc(Node.getLocStart());
+  if (SM.isInSystemHeader(ExpansionLoc))
+return false;

I think, this should be opposite for two reasons:
1. variable definitions and declarations in system headers are not better than 
in user headers and can lead to the same problems;
2. there are people who care about system headers, so we need to produce 
diagnostics on them and let clang-tidy filter them out when not needed.


Comment at: clang-tidy/misc/DefinitionsInHeadersCheck.h:23
@@ +22,3 @@
+// There is one option:
+// - `UseHeaderFileExtension`: Whether to use file extension(h, hh, hpp, hxx) 
to
+//   distinguish header files. True by default.

nit: add a space before the '('


Comment at: docs/clang-tidy/checks/misc-definitions-in-headers.rst:15
@@ +14,3 @@
+
+   // Internal linkage variable definitions are ignored for now,
+   // Although these might also cause ODR violations, we can be less certain 
and

nit: the sentence should end with a period, not a comma.


Comment at: test/clang-tidy/misc-definitions-in-headers.hpp:4
@@ +3,3 @@
+int f() {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f' defined in a header 
file;
+// CHECK-FIXES: inline int f() {

Please specify each distinct warning message (in your case, there are two of 
them) completely (including the check name) once. Having it in the test (just 
once) is useful to verify that the message is formatted correctly (in your 
case, there's no space after the ';', for example).


http://reviews.llvm.org/D15710



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


Re: [PATCH] D15823: Support virtual-near-miss check.

2016-01-08 Thread Cong Liu via cfe-commits
congliu added inline comments.


Comment at: clang-tidy/misc/VirtualNearMissCheck.cpp:232
@@ +231,3 @@
+const auto *BaseRD = BaseSpec.getType()->getAsCXXRecordDecl();
+if (BaseRD == nullptr)
+  return;

alexfh wrote:
> 1. When is this going to be nullptr?
> 2. Why do you return here instead of continuing to check other base classes?
1. Just to assure it's not nullptr. If the base specification contains a class 
type that was not declared anywhere, it would be nullptr. I found similar code 
here [[ 
https://cs.corp.google.com/#piper///depot/google3/third_party/llvm/llvm/tools/clang/tools/extra/clang-tidy/misc/NewDeleteOverloadsCheck.cpp=121
 | NewDeleteOverloadsCheck.cpp, line 121]]
2. Sorry, it's a mistake, should be 'continue' not 'return'.


Comment at: test/clang-tidy/misc-virtual-near-miss.cpp:41
@@ +40,3 @@
+
+class Child : Father, Mother {
+public:

alexfh wrote:
> Is private inheritance intended here?
Yes, it's intended. This is for the case in line 57: although Father is a 
private base class of Child, since that function itself is in Child class, the 
conversion is accessible. 


http://reviews.llvm.org/D15823



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


Re: [PATCH] D15953: Driver: Pass -flavor gnu to lld for AMDGPU rather than -flavor gnu-old

2016-01-08 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL257175: Driver: Use the new ELF lld linker for AMDGPU 
(authored by tstellar).

Changed prior to commit:
  http://reviews.llvm.org/D15953?vs=44249=44327#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15953

Files:
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/lib/Driver/Tools.h
  cfe/trunk/test/Driver/amdgpu-toolchain.c

Index: cfe/trunk/test/Driver/amdgpu-toolchain.c
===
--- cfe/trunk/test/Driver/amdgpu-toolchain.c
+++ cfe/trunk/test/Driver/amdgpu-toolchain.c
@@ -1,3 +1,3 @@
 // RUN: %clang -### -target amdgcn--amdhsa -x assembler -mcpu=kaveri %s 2>&1 | 
FileCheck -check-prefix=AS_LINK %s
 // AS_LINK: clang{{.*}} "-cc1as"
-// AS_LINK: lld{{.*}} "-flavor" "old-gnu" "-target" "amdgcn--amdhsa"
+// AS_LINK: ld.lld{{.*}}
Index: cfe/trunk/lib/Driver/Tools.h
===
--- cfe/trunk/lib/Driver/Tools.h
+++ cfe/trunk/lib/Driver/Tools.h
@@ -240,7 +240,7 @@
 
 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
 public:
-  Linker(const ToolChain ) : GnuTool("amdgpu::Linker", "lld", TC) {}
+  Linker(const ToolChain ) : GnuTool("amdgpu::Linker", "ld.lld", TC) {}
   bool isLinkJob() const override { return true; }
   bool hasIntegratedCPP() const override { return false; }
   void ConstructJob(Compilation , const JobAction ,
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -6520,10 +6520,6 @@
 
   std::string Linker = getToolChain().GetProgramPath(getShortName());
   ArgStringList CmdArgs;
-  CmdArgs.push_back("-flavor");
-  CmdArgs.push_back("old-gnu");
-  CmdArgs.push_back("-target");
-  CmdArgs.push_back(Args.MakeArgString(getToolChain().getTripleString()));
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());


Index: cfe/trunk/test/Driver/amdgpu-toolchain.c
===
--- cfe/trunk/test/Driver/amdgpu-toolchain.c
+++ cfe/trunk/test/Driver/amdgpu-toolchain.c
@@ -1,3 +1,3 @@
 // RUN: %clang -### -target amdgcn--amdhsa -x assembler -mcpu=kaveri %s 2>&1 | FileCheck -check-prefix=AS_LINK %s
 // AS_LINK: clang{{.*}} "-cc1as"
-// AS_LINK: lld{{.*}} "-flavor" "old-gnu" "-target" "amdgcn--amdhsa"
+// AS_LINK: ld.lld{{.*}}
Index: cfe/trunk/lib/Driver/Tools.h
===
--- cfe/trunk/lib/Driver/Tools.h
+++ cfe/trunk/lib/Driver/Tools.h
@@ -240,7 +240,7 @@
 
 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
 public:
-  Linker(const ToolChain ) : GnuTool("amdgpu::Linker", "lld", TC) {}
+  Linker(const ToolChain ) : GnuTool("amdgpu::Linker", "ld.lld", TC) {}
   bool isLinkJob() const override { return true; }
   bool hasIntegratedCPP() const override { return false; }
   void ConstructJob(Compilation , const JobAction ,
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -6520,10 +6520,6 @@
 
   std::string Linker = getToolChain().GetProgramPath(getShortName());
   ArgStringList CmdArgs;
-  CmdArgs.push_back("-flavor");
-  CmdArgs.push_back("old-gnu");
-  CmdArgs.push_back("-target");
-  CmdArgs.push_back(Args.MakeArgString(getToolChain().getTripleString()));
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r257175 - Driver: Use the new ELF lld linker for AMDGPU

2016-01-08 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Fri Jan  8 09:14:31 2016
New Revision: 257175

URL: http://llvm.org/viewvc/llvm-project?rev=257175=rev
Log:
Driver: Use the new ELF lld linker for AMDGPU

Summary: 'gnu-old' has been deprecated in favor or 'gnu'.

Reviewers: arsenm, ruiu, rafael

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Driver/Tools.h
cfe/trunk/test/Driver/amdgpu-toolchain.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=257175=257174=257175=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Jan  8 09:14:31 2016
@@ -6520,10 +6520,6 @@ void amdgpu::Linker::ConstructJob(Compil
 
   std::string Linker = getToolChain().GetProgramPath(getShortName());
   ArgStringList CmdArgs;
-  CmdArgs.push_back("-flavor");
-  CmdArgs.push_back("old-gnu");
-  CmdArgs.push_back("-target");
-  CmdArgs.push_back(Args.MakeArgString(getToolChain().getTripleString()));
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());

Modified: cfe/trunk/lib/Driver/Tools.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.h?rev=257175=257174=257175=diff
==
--- cfe/trunk/lib/Driver/Tools.h (original)
+++ cfe/trunk/lib/Driver/Tools.h Fri Jan  8 09:14:31 2016
@@ -240,7 +240,7 @@ namespace amdgpu {
 
 class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
 public:
-  Linker(const ToolChain ) : GnuTool("amdgpu::Linker", "lld", TC) {}
+  Linker(const ToolChain ) : GnuTool("amdgpu::Linker", "ld.lld", TC) {}
   bool isLinkJob() const override { return true; }
   bool hasIntegratedCPP() const override { return false; }
   void ConstructJob(Compilation , const JobAction ,

Modified: cfe/trunk/test/Driver/amdgpu-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/amdgpu-toolchain.c?rev=257175=257174=257175=diff
==
--- cfe/trunk/test/Driver/amdgpu-toolchain.c (original)
+++ cfe/trunk/test/Driver/amdgpu-toolchain.c Fri Jan  8 09:14:31 2016
@@ -1,3 +1,3 @@
 // RUN: %clang -### -target amdgcn--amdhsa -x assembler -mcpu=kaveri %s 2>&1 | 
FileCheck -check-prefix=AS_LINK %s
 // AS_LINK: clang{{.*}} "-cc1as"
-// AS_LINK: lld{{.*}} "-flavor" "old-gnu" "-target" "amdgcn--amdhsa"
+// AS_LINK: ld.lld{{.*}}


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


Re: [PATCH] D15823: Support virtual-near-miss check.

2016-01-08 Thread Cong Liu via cfe-commits
congliu updated this revision to Diff 44328.
congliu marked 33 inline comments as done.
congliu added a comment.

- Completed [class.virtual] p7 covarient check. Updated test.
- Corrected implement of checkParamType.
- Clean up.
- Corrected typos. Changed some methods to free-standing. Changed warning 
message. Updated tests.
- Finished correcting cpp. Updated doc.


http://reviews.llvm.org/D15823

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/VirtualNearMissCheck.cpp
  clang-tidy/misc/VirtualNearMissCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-virtual-near-miss.rst
  test/clang-tidy/misc-virtual-near-miss.cpp

Index: test/clang-tidy/misc-virtual-near-miss.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-virtual-near-miss.cpp
@@ -0,0 +1,65 @@
+// RUN: %check_clang_tidy %s misc-virtual-near-miss %t
+
+struct Base {
+  virtual void func();
+  virtual void gunk();
+};
+
+struct Derived : Base {
+  // Should not warn "do you want to override 'gunk'?", because gunk is already
+  // overriden by this class.
+  virtual void funk();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'Derived::funk' has a similar name and the same signature with virtual method 'Base::func'. Did you meant to override it? [misc-virtual-near-miss]
+
+  void func2();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'Derived::func2' has a similar name and the same signature with virtual method 'Base::func'. Did you meant to override it?
+
+  void func22(); // Should not warn.
+
+  void gunk(); // Should not warn: gunk is override.
+
+  void fun();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'Derived::fun' has a similar name and the same signature with virtual method 'Base::func'. Did you meant to override it?
+};
+
+class Father {
+public:
+  Father();
+  virtual void func();
+  virtual Father *create(int i);
+  virtual Base &();
+};
+
+class Mother {
+public:
+  Mother();
+  static void method();
+  virtual int method(int argc, const char **argv);
+  virtual int method(int argc) const;
+};
+
+class Child : Father, Mother {
+public:
+  Child();
+
+  virtual void func2();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'Child::func2' has a similar name and the same signature with virtual method 'Father::func'. Did you meant to override it?
+
+  int methoe(int x, char **strs); // Should not warn: parameter types don't match.
+
+  int methoe(int x); // Should not warn: method is not const.
+
+  void methof(int x, const char **strs); // Should not warn: return types don't match.
+
+  int methoh(int x, const char **strs);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'Child::methoh' has a similar name and the same signature with virtual method 'Mother::method'. Did you meant to override it?
+
+  virtual Child *creat(int i);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'Child::creat' has a similar name and the same signature with virtual method 'Father::create'. Did you meant to override it?
+
+  virtual Derived &();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'Child::generat' has a similar name and the same signature with virtual method 'Father::generate'. Did you meant to override it?
+
+private:
+  void funk(); // Should not warn: access qualifers don't match.
+};
Index: docs/clang-tidy/checks/misc-virtual-near-miss.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-virtual-near-miss.rst
@@ -0,0 +1,17 @@
+misc-virtual-near-miss
+==
+
+Warn if a function is a near miss (ie. the name is very similar and the function signiture is the same) to a virtual function from a base class.
+
+Example:
+
+.. code-block:: c++
+
+  struct Base {
+virtual void func();
+  };
+
+  struct Derived : Base {
+virtual funk();
+// warning: Do you want to override 'func'?
+  };
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -56,6 +56,7 @@
misc-unused-alias-decls
misc-unused-parameters
misc-unused-raii
+   misc-virtual-near-miss
modernize-loop-convert
modernize-make-unique
modernize-pass-by-value
Index: clang-tidy/misc/VirtualNearMissCheck.h
===
--- /dev/null
+++ clang-tidy/misc/VirtualNearMissCheck.h
@@ -0,0 +1,65 @@
+//===--- VirtualNearMissCheck.h - clang-tidy-*- 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_TIDY_MISC_VIRTUAL_NEAR_MISS_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_VIRTUAL_NEAR_MISS_H
+
+#include 

Re: r256287 - Document that we recommend to turn off -gmodules when building a static

2016-01-08 Thread Adrian Prantl via cfe-commits

> On Jan 7, 2016, at 6:54 PM, David Blaikie  wrote:
> 
> Presumably this only applies when using implicit modules builds, not when 
> using explicit modules builds. (though I'm not sure what the current behavior 
> of -gmodules is with explicit modules, maybe it's untested/broken/etc anyway)

Why would explicit modules be any different? Unless you distribute the modules 
together with the static library (and ensure they end up in the same location 
on the other machine) you would still run into the problem, wouldn’t you?

-- adrian

> 
> On Tue, Dec 22, 2015 at 2:37 PM, Adrian Prantl via cfe-commits 
> > wrote:
> Author: adrian
> Date: Tue Dec 22 16:37:22 2015
> New Revision: 256287
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=256287=rev 
> 
> Log:
> Document that we recommend to turn off -gmodules when building a static
> library for distribution to other machines on the clang man page.
> 
> Modified:
> cfe/trunk/docs/CommandGuide/clang.rst
> 
> Modified: cfe/trunk/docs/CommandGuide/clang.rst
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/CommandGuide/clang.rst?rev=256287=256286=256287=diff
>  
> 
> ==
> --- cfe/trunk/docs/CommandGuide/clang.rst (original)
> +++ cfe/trunk/docs/CommandGuide/clang.rst Tue Dec 22 16:37:22 2015
> @@ -262,7 +262,12 @@ Code Generation Options
>Generate debug information that contains external references to
>types defined in clang modules or precompiled headers instead of
>emitting redundant debug type information into every object file.
> -  This option implies `-fmodule-format=obj`.
> +  This option implies :option:`-fmodule-format=obj`.
> +
> +  This option should not be used when building static libraries for
> +  distribution to other machines because the debug info will contain
> +  references to the module cache on the machine the object files in
> +  the library were built on.
> 
>  .. option:: -fstandalone-debug -fno-standalone-debug
> 
> 
> 
> ___
> 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


[clang-tools-extra] r257176 - [clang-tidy] Use proper capitalization and punctuation for diagnostic messages.

2016-01-08 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Fri Jan  8 09:21:40 2016
New Revision: 257176

URL: http://llvm.org/viewvc/llvm-project?rev=257176=rev
Log:
[clang-tidy] Use proper capitalization and punctuation for diagnostic messages.

Use diagnostic parameters where possible instead of string concatenation.

Modified:
clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.cpp
clang-tools-extra/trunk/clang-tidy/google/StringReferenceMemberCheck.cpp
clang-tools-extra/trunk/clang-tidy/google/UnnamedNamespaceInHeaderCheck.cpp
clang-tools-extra/trunk/clang-tidy/google/UsingNamespaceDirectiveCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/AssertSideEffectCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/google-namespaces.cpp
clang-tools-extra/trunk/test/clang-tidy/google-readability-casting.cpp

clang-tools-extra/trunk/test/clang-tidy/google-runtime-member-string-references.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-redundant-smartptr-get.cpp

Modified: clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.cpp?rev=257176=257175=257176=diff
==
--- clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.cpp Fri Jan 
 8 09:21:40 2016
@@ -112,10 +112,10 @@ void AvoidCStyleCastsCheck::check(const
SM, Result.Context->getLangOpts());
 
   auto diag_builder =
-  diag(CastExpr->getLocStart(), "C-style casts are discouraged. %0");
+  diag(CastExpr->getLocStart(), "C-style casts are discouraged; use %0");
 
   auto ReplaceWithCast = [&](StringRef CastType) {
-diag_builder << ("Use " + CastType).str();
+diag_builder << CastType;
 
 const Expr *SubExpr = CastExpr->getSubExprAsWritten()->IgnoreImpCasts();
 std::string CastText = (CastType + "<" + DestTypeString + ">").str();
@@ -166,7 +166,7 @@ void AvoidCStyleCastsCheck::check(const
 break;
   }
 
-  diag_builder << "Use static_cast/const_cast/reinterpret_cast";
+  diag_builder << "static_cast/const_cast/reinterpret_cast";
 }
 
 } // namespace readability

Modified: 
clang-tools-extra/trunk/clang-tidy/google/StringReferenceMemberCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/StringReferenceMemberCheck.cpp?rev=257176=257175=257176=diff
==
--- clang-tools-extra/trunk/clang-tidy/google/StringReferenceMemberCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/google/StringReferenceMemberCheck.cpp 
Fri Jan  8 09:21:40 2016
@@ -40,9 +40,9 @@ void StringReferenceMemberCheck::registe
 void
 StringReferenceMemberCheck::check(const MatchFinder::MatchResult ) {
   const auto *Member = Result.Nodes.getNodeAs("member");
-  diag(Member->getLocStart(), "const string& members are dangerous. It is much 
"
+  diag(Member->getLocStart(), "const string& members are dangerous; it is much 
"
   "better to use alternatives, such as pointers or 
"
-  "simple constants.");
+  "simple constants");
 }
 
 } // namespace runtime

Modified: 
clang-tools-extra/trunk/clang-tidy/google/UnnamedNamespaceInHeaderCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/UnnamedNamespaceInHeaderCheck.cpp?rev=257176=257175=257176=diff
==
--- clang-tools-extra/trunk/clang-tidy/google/UnnamedNamespaceInHeaderCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/google/UnnamedNamespaceInHeaderCheck.cpp 
Fri Jan  8 09:21:40 2016
@@ -41,7 +41,7 @@ UnnamedNamespaceInHeaderCheck::check(con
   StringRef FileName = SM->getPresumedLoc(Loc).getFilename();
   if (FileName.endswith(".h") || FileName.endswith(".hh") ||
   FileName.endswith(".hpp") || FileName.endswith(".hxx"))
-diag(Loc, "do not use unnamed namespaces in header files.");
+diag(Loc, "do not use unnamed namespaces in header files");
 }
 
 } // namespace build

Modified: 
clang-tools-extra/trunk/clang-tidy/google/UsingNamespaceDirectiveCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/UsingNamespaceDirectiveCheck.cpp?rev=257176=257175=257176=diff
==
--- clang-tools-extra/trunk/clang-tidy/google/UsingNamespaceDirectiveCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/google/UsingNamespaceDirectiveCheck.cpp 
Fri Jan  8 09:21:40 2016
@@ -34,8 +34,8 @@ UsingNamespaceDirectiveCheck::check(cons
   if (U->isImplicit() || !Loc.isValid())
 return;

Re: [PATCH] D15914: [OpenCL] Pipe builtin functions

2016-01-08 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

Do you have any tests? We won't be able to commit without. Also having them 
would help understanding what this modification does.



Comment at: include/clang/Basic/Builtins.def:1260
@@ +1259,3 @@
+
+LANGBUILTIN(reserve_read_pipe, "i.", "tn", OCLC_LANG)
+LANGBUILTIN(reserve_write_pipe, "i.", "tn", OCLC_LANG)

That's right! I am just saying that we don't have to make it variadic, so you 
can change "v." -> "v" and "i." -> "i"


Comment at: lib/CodeGen/CGBuiltin.cpp:2033
@@ +2032,3 @@
+else if (BuiltinID == Builtin::BIwork_group_reserve_write_pipe)
+  Name = "_Z29work_group_reserve_write_pipePU3AS110ocl_pipe_tji";
+else if (BuiltinID == Builtin::BIsub_group_reserve_read_pipe)

I am still not convinced we need to mangle here at all. It seems we mainly have 
only one prototype for those functions apart from read/write_pipe in which case 
we can generate two versions of that function:

read_pipe_2(...) - for two parameters case
read_pipe_4(...) - for four parameters case

Having a mangler would complicate the implementation. And if used it would be 
better to adhere to conventional scheme  (i.e. calling getMangledName()). But 
that won't work here as we are generating parameters different from originally 
specified. I don't see any need or benefit in mangling at the moment since the 
function signatures are all known here.

Regarding the packet size, I prefer to pass it in. This way we can allow simple 
BIF implementation without using any metadata magic. Usage of metadata often 
implies adding non-conventional compilation mechanisms somewhere that are best 
to avoid.


Comment at: lib/Sema/SemaChecking.cpp:268
@@ +267,3 @@
+static OpenCLImageAccessAttr *getOpenCLImageAcces(const Decl *D) {
+  if (D->hasAttr())
+return D->getAttr();

Let's rename this new function in this commit and I agree with renaming an 
attribute later on. May be leaving TODO explaining that would be good.


Comment at: lib/Sema/SemaChecking.cpp:282
@@ +281,3 @@
+  }
+  OpenCLImageAccessAttr *AccessQual =
+  getOpenCLImageAcces(cast(Arg0)->getDecl());

Ah yes, I see. It should be fine!


http://reviews.llvm.org/D15914



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


[clang-tools-extra] r257178 - [clang-tidy] Add non-inline function definition and variable definition check in header files.

2016-01-08 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Fri Jan  8 10:37:11 2016
New Revision: 257178

URL: http://llvm.org/viewvc/llvm-project?rev=257178=rev
Log:
[clang-tidy] Add non-inline function definition and variable definition check 
in header files.

Summary: The new check will find all functionand variable definitions which may 
violate cpp one definition rule in header file.

Reviewers: aaron.ballman, alexfh

Subscribers: aaron.ballman, cfe-commits

Patch by Haojian Wu!

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

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

clang-tools-extra/trunk/docs/clang-tidy/checks/misc-definitions-in-headers.rst
clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp
Modified:
clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py
clang-tools-extra/trunk/test/lit.cfg

Modified: clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt?rev=257178=257177=257178=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt Fri Jan  8 10:37:11 
2016
@@ -5,6 +5,7 @@ add_clang_library(clangTidyMiscModule
   AssertSideEffectCheck.cpp
   AssignOperatorSignatureCheck.cpp
   BoolPointerImplicitConversionCheck.cpp
+  DefinitionsInHeadersCheck.cpp
   InaccurateEraseCheck.cpp
   InefficientAlgorithmCheck.cpp
   MacroParenthesesCheck.cpp

Added: clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp?rev=257178=auto
==
--- clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp 
(added)
+++ clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp Fri 
Jan  8 10:37:11 2016
@@ -0,0 +1,126 @@
+//===--- DefinitionsInHeadersCheck.cpp - 
clang-tidy===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "DefinitionsInHeadersCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+namespace {
+
+AST_MATCHER(NamedDecl, isHeaderFileExtension) {
+  SourceManager& SM = Finder->getASTContext().getSourceManager();
+  SourceLocation ExpansionLoc = SM.getExpansionLoc(Node.getLocStart());
+  StringRef Filename = SM.getFilename(ExpansionLoc);
+  return Filename.endswith(".h") || Filename.endswith(".hh") ||
+ Filename.endswith(".hpp") || Filename.endswith(".hxx") ||
+ llvm::sys::path::extension(Filename).empty();
+}
+
+} // namespace
+
+DefinitionsInHeadersCheck::DefinitionsInHeadersCheck(
+StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context),
+UseHeaderFileExtension(Options.get("UseHeaderFileExtension", true)) {}
+
+void DefinitionsInHeadersCheck::storeOptions(
+ClangTidyOptions::OptionMap ) {
+  Options.store(Opts, "UseHeaderFileExtension", UseHeaderFileExtension);
+}
+
+void DefinitionsInHeadersCheck::registerMatchers(MatchFinder *Finder) {
+  if (UseHeaderFileExtension) {
+Finder->addMatcher(
+namedDecl(anyOf(functionDecl(isDefinition()), varDecl(isDefinition())),
+  isHeaderFileExtension()).bind("name-decl"),
+this);
+  } else {
+Finder->addMatcher(
+namedDecl(anyOf(functionDecl(isDefinition()), varDecl(isDefinition())),
+  anyOf(isHeaderFileExtension(),
+unless(isExpansionInMainFile(.bind("name-decl"),
+this);
+  }
+}
+
+void DefinitionsInHeadersCheck::check(const MatchFinder::MatchResult ) {
+  // C++ [basic.def.odr] p6:
+  // There can be more than one definition of a class type, enumeration type,
+  // inline function with external linkage, class template, non-static function
+  // template, static data member of a class template, member function of a
+  // class template, or template specialization for which some template
+  // parameters are not specifiedin a program provided that each definition
+  // appears in a different translation unit, and provided the definitions
+  // satisfy the following requirements.
+  const auto *ND = Result.Nodes.getNodeAs("name-decl");
+  assert(ND);
+
+  // 

Re: [PATCH] D15710: [clang-tidy] Add non-inline function definition and variable definition check in header files.

2016-01-08 Thread Alexander Kornienko via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL257178: [clang-tidy] Add non-inline function definition and 
variable definition check… (authored by alexfh).

Changed prior to commit:
  http://reviews.llvm.org/D15710?vs=44318=44331#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D15710

Files:
  clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
  clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.h
  clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/misc-definitions-in-headers.rst
  clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py
  clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp
  clang-tools-extra/trunk/test/lit.cfg

Index: clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
@@ -0,0 +1,126 @@
+//===--- DefinitionsInHeadersCheck.cpp - clang-tidy===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "DefinitionsInHeadersCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+namespace {
+
+AST_MATCHER(NamedDecl, isHeaderFileExtension) {
+  SourceManager& SM = Finder->getASTContext().getSourceManager();
+  SourceLocation ExpansionLoc = SM.getExpansionLoc(Node.getLocStart());
+  StringRef Filename = SM.getFilename(ExpansionLoc);
+  return Filename.endswith(".h") || Filename.endswith(".hh") ||
+ Filename.endswith(".hpp") || Filename.endswith(".hxx") ||
+ llvm::sys::path::extension(Filename).empty();
+}
+
+} // namespace
+
+DefinitionsInHeadersCheck::DefinitionsInHeadersCheck(
+StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context),
+UseHeaderFileExtension(Options.get("UseHeaderFileExtension", true)) {}
+
+void DefinitionsInHeadersCheck::storeOptions(
+ClangTidyOptions::OptionMap ) {
+  Options.store(Opts, "UseHeaderFileExtension", UseHeaderFileExtension);
+}
+
+void DefinitionsInHeadersCheck::registerMatchers(MatchFinder *Finder) {
+  if (UseHeaderFileExtension) {
+Finder->addMatcher(
+namedDecl(anyOf(functionDecl(isDefinition()), varDecl(isDefinition())),
+  isHeaderFileExtension()).bind("name-decl"),
+this);
+  } else {
+Finder->addMatcher(
+namedDecl(anyOf(functionDecl(isDefinition()), varDecl(isDefinition())),
+  anyOf(isHeaderFileExtension(),
+unless(isExpansionInMainFile(.bind("name-decl"),
+this);
+  }
+}
+
+void DefinitionsInHeadersCheck::check(const MatchFinder::MatchResult ) {
+  // C++ [basic.def.odr] p6:
+  // There can be more than one definition of a class type, enumeration type,
+  // inline function with external linkage, class template, non-static function
+  // template, static data member of a class template, member function of a
+  // class template, or template specialization for which some template
+  // parameters are not specifiedin a program provided that each definition
+  // appears in a different translation unit, and provided the definitions
+  // satisfy the following requirements.
+  const auto *ND = Result.Nodes.getNodeAs("name-decl");
+  assert(ND);
+
+  // Internal linkage variable definitions are ignored for now:
+  //   const int a = 1;
+  //   static int b = 1;
+  //
+  // Although these might also cause ODR violations, we can be less certain and
+  // should try to keep the false-positive rate down.
+  if (ND->getLinkageInternal() == InternalLinkage)
+return;
+
+  if (const auto *FD = dyn_cast(ND)) {
+// Inline functions are allowed.
+if (FD->isInlined())
+  return;
+// Function templates are allowed.
+if (FD->getTemplatedKind() == FunctionDecl::TK_FunctionTemplate)
+  return;
+// Function template full specialization is prohibited in header file.
+if (FD->getTemplateSpecializationKind() == TSK_ImplicitInstantiation)
+  return;
+// Member function of a class template and member function of a nested class
+// in a class template are allowed.
+if (const auto *MD = dyn_cast(FD)) {
+  const auto *DC = MD->getDeclContext();
+  while (DC->isRecord()) {
+if (const auto *RD = dyn_cast(DC))
+  if (RD->getDescribedClassTemplate())
+return;
+ 

Re: [PATCH] D15924: [analyzer] Utility to extract the variable name from a memory region.

2016-01-08 Thread Gábor Horváth via cfe-commits
xazax.hun added inline comments.


Comment at: lib/StaticAnalyzer/Core/MemRegion.cpp:586
@@ +585,3 @@
+return "";
+  return nd->getName();
+}

Alexander_Droste wrote:
> Isn't calling `getDecl()` and `getName()` afterwards identical to 
> `printPretty()`?
> Is it possible that a `NamedDecl` cannot be obtained from a `DeclRegion`?
The printPretty function copy the name of the variable. First I wanted to avoid 
any copy and memory allocation, but I realized this utility will probably only 
be used for diagnostics which is the exceptional case, I think allocations 
should not cause any performance problem here.

But you are right printPretty is almost identical except for FieldRegions, 
where it also try to print the super region. 
I checked and DeclRegion has 3 superclasses, all of them should contain 
NamedDecls, so that check should never fail. 


Comment at: lib/StaticAnalyzer/Core/MemRegion.cpp:588
@@ -576,1 +587,3 @@
+}
+
 void MemRegion::printPretty(raw_ostream ) const {

Alexander_Droste wrote:
> Regarding the MPI-Checker patch http://reviews.llvm.org/D12761 it is 
> insufficient 
> if the array index (if obtainable) is not provided. 
> I think it would be nice if a `getVariableName` function could always provide 
> as much
> information as possible, regarding the passed memory region. Do you actually 
> see a case in 
> the other implementation where this function fails?
> The index is a member variable of the `ElementRegion` why obtaining that
> value cannot fail. If the memory region passed is no `ElementRegion` then 
> simply `printPretty()` is called. I could submit the patch right away if this 
> helps.
> 
> 
> 
In this case I think you should commit your version. 


http://reviews.llvm.org/D15924



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


[clang-tools-extra] r257177 - Disable part of the misc-move-constructor-init checker when the check is enabled through cert-oop11-cpp. The CERT guideline does not cover moveable parameters as part of

2016-01-08 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Fri Jan  8 09:50:51 2016
New Revision: 257177

URL: http://llvm.org/viewvc/llvm-project?rev=257177=rev
Log:
Disable part of the misc-move-constructor-init checker when the check is 
enabled through cert-oop11-cpp. The CERT guideline does not cover moveable 
parameters as part of the OOP11-CPP recommendation, just copy construction from 
move constructors.

Added:
clang-tools-extra/trunk/test/clang-tidy/cert-oop11-cpp.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.h

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp?rev=257177=257176=257177=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp Fri Jan  
8 09:50:51 2016
@@ -233,6 +233,10 @@ GlobList ::getChecksFil
   return *CheckFilter;
 }
 
+bool ClangTidyContext::isCheckEnabled(StringRef CheckName) const {
+  return CheckFilter->contains(CheckName);
+}
+
 /// \brief Store a \c ClangTidyError.
 void ClangTidyContext::storeError(const ClangTidyError ) {
   Errors.push_back(Error);

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h?rev=257177=257176=257177=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.h Fri Jan  8 
09:50:51 2016
@@ -161,6 +161,9 @@ public:
   /// The \c CurrentFile can be changed using \c setCurrentFile.
   GlobList ();
 
+  /// \brief Returns true if the check name is enabled for the \c CurrentFile.
+  bool isCheckEnabled(StringRef CheckName) const;
+
   /// \brief Returns global options.
   const ClangTidyGlobalOptions () const;
 

Modified: clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.cpp?rev=257177=257176=257177=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.cpp Fri 
Jan  8 09:50:51 2016
@@ -42,7 +42,8 @@ MoveConstructorInitCheck::MoveConstructo
ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
   IncludeStyle(IncludeSorter::parseIncludeStyle(
-  Options.get("IncludeStyle", "llvm"))) {}
+  Options.get("IncludeStyle", "llvm"))),
+  UseCERTSemantics(Context->isCheckEnabled("cert-oop11-cpp")) {}
 
 void MoveConstructorInitCheck::registerMatchers(MatchFinder *Finder) {
   // Only register the matchers for C++11; the functionality currently does not
@@ -67,21 +68,26 @@ void MoveConstructorInitCheck::registerM
  hasDeclaration(cxxRecordDecl(hasMethod(cxxConstructorDecl(
  isMoveConstructor(), unless(isDeleted()),
  matchers::isExpensiveToCopy()));
-  Finder->addMatcher(
-  cxxConstructorDecl(
-  allOf(
-  unless(isMoveConstructor()),
-  hasAnyConstructorInitializer(withInitializer(cxxConstructExpr(
-  hasDeclaration(cxxConstructorDecl(isCopyConstructor())),
-  hasArgument(
-  0, declRefExpr(
- to(parmVarDecl(
-hasType(
-
NonConstValueMovableAndExpensiveToCopy))
-.bind("movable-param")))
- .bind("init-arg")))
-  .bind("ctor-decl"),
-  this);
+
+  // This checker is also used to implement cert-oop11-cpp, but when using that
+  // form of the checker, we do not want to diagnose movable parameters.
+  if (!UseCERTSemantics)
+Finder->addMatcher(
+cxxConstructorDecl(
+allOf(
+unless(isMoveConstructor()),
+hasAnyConstructorInitializer(withInitializer(cxxConstructExpr(
+hasDeclaration(cxxConstructorDecl(isCopyConstructor())),
+hasArgument(
+0,
+declRefExpr(
+to(parmVarDecl(
+   hasType(
+  

r257179 - [ThinLTO] Leverage new in-place renaming support

2016-01-08 Thread Teresa Johnson via cfe-commits
Author: tejohnson
Date: Fri Jan  8 11:04:29 2016
New Revision: 257179

URL: http://llvm.org/viewvc/llvm-project?rev=257179=rev
Log:
[ThinLTO] Leverage new in-place renaming support

Due to the new in-place renaming support added in r257174, we no
longer need to invoke ThinLTO global renaming from clang. It will be
invoked on the module in the FunctionImport pass (by an immediately
following llvm commit).

As a result, we don't need to load the FunctionInfoIndex as early,
so that is moved down into EmitAssemblyHelper::EmitAssembly.

Modified:
cfe/trunk/include/clang/CodeGen/BackendUtil.h
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/CodeGen/CodeGenAction.cpp

Modified: cfe/trunk/include/clang/CodeGen/BackendUtil.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/BackendUtil.h?rev=257179=257178=257179=diff
==
--- cfe/trunk/include/clang/CodeGen/BackendUtil.h (original)
+++ cfe/trunk/include/clang/CodeGen/BackendUtil.h Fri Jan  8 11:04:29 2016
@@ -33,12 +33,10 @@ namespace clang {
 Backend_EmitObj///< Emit native object files
   };
 
-  void
-  EmitBackendOutput(DiagnosticsEngine , const CodeGenOptions ,
-const TargetOptions , const LangOptions ,
-StringRef TDesc, llvm::Module *M, BackendAction Action,
-raw_pwrite_stream *OS,
-std::unique_ptr Index = nullptr);
+  void EmitBackendOutput(DiagnosticsEngine , const CodeGenOptions 
,
+ const TargetOptions , const LangOptions ,
+ StringRef TDesc, llvm::Module *M, BackendAction 
Action,
+ raw_pwrite_stream *OS);
 }
 
 #endif

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=257179=257178=257179=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Fri Jan  8 11:04:29 2016
@@ -28,6 +28,7 @@
 #include "llvm/IR/Module.h"
 #include "llvm/IR/Verifier.h"
 #include "llvm/MC/SubtargetFeature.h"
+#include "llvm/Object/FunctionIndexObjectFile.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/TargetRegistry.h"
@@ -54,7 +55,6 @@ class EmitAssemblyHelper {
   const clang::TargetOptions 
   const LangOptions 
   Module *TheModule;
-  std::unique_ptr FunctionIndex;
 
   Timer CodeGenerationTime;
 
@@ -97,7 +97,7 @@ private:
 return PerFunctionPasses;
   }
 
-  void CreatePasses();
+  void CreatePasses(FunctionInfoIndex *FunctionIndex);
 
   /// Generates the TargetMachine.
   /// Returns Null if it is unable to create the target machine.
@@ -117,12 +117,11 @@ private:
 public:
   EmitAssemblyHelper(DiagnosticsEngine &_Diags, const CodeGenOptions ,
  const clang::TargetOptions ,
- const LangOptions , Module *M,
- std::unique_ptr Index)
+ const LangOptions , Module *M)
   : Diags(_Diags), CodeGenOpts(CGOpts), TargetOpts(TOpts), LangOpts(LOpts),
-TheModule(M), FunctionIndex(std::move(Index)),
-CodeGenerationTime("Code Generation Time"), CodeGenPasses(nullptr),
-PerModulePasses(nullptr), PerFunctionPasses(nullptr) {}
+TheModule(M), CodeGenerationTime("Code Generation Time"),
+CodeGenPasses(nullptr), PerModulePasses(nullptr),
+PerFunctionPasses(nullptr) {}
 
   ~EmitAssemblyHelper() {
 delete CodeGenPasses;
@@ -278,7 +277,7 @@ static void addSymbolRewriterPass(const
   MPM->add(createRewriteSymbolsPass(DL));
 }
 
-void EmitAssemblyHelper::CreatePasses() {
+void EmitAssemblyHelper::CreatePasses(FunctionInfoIndex *FunctionIndex) {
   if (CodeGenOpts.DisableLLVMPasses)
 return;
 
@@ -332,9 +331,8 @@ void EmitAssemblyHelper::CreatePasses()
 
   // If we are performing a ThinLTO importing compile, invoke the LTO
   // pipeline and pass down the in-memory function index.
-  if (!CodeGenOpts.ThinLTOIndexFile.empty()) {
-assert(FunctionIndex && "Expected non-empty function index");
-PMBuilder.FunctionIndex = FunctionIndex.get();
+  if (FunctionIndex) {
+PMBuilder.FunctionIndex = FunctionIndex;
 PMBuilder.populateLTOPassManager(*MPM);
 return;
   }
@@ -642,7 +640,28 @@ void EmitAssemblyHelper::EmitAssembly(Ba
 return;
   if (TM)
 TheModule->setDataLayout(TM->createDataLayout());
-  CreatePasses();
+
+  // If we are performing a ThinLTO importing compile, load the function
+  // index into memory and pass it into CreatePasses, which will add it
+  // to the PassManagerBuilder and invoke LTO passes.
+  std::unique_ptr FunctionIndex;
+  if (!CodeGenOpts.ThinLTOIndexFile.empty()) {
+ErrorOr IndexOrErr =
+