[PATCH] D35109: [Analyzer] SValBuilder Comparison Rearrangement

2017-08-10 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In https://reviews.llvm.org/D35109#837673, @zaks.anna wrote:

> > What do you suggest? Should we widen the type of the difference, or abandon 
> > this patch and revert back to the local solution I originally used in the 
> > iterator checker?
>
> Does the local solution you used in the iterator checker not have the same 
> problem?


It's something similar to assuming that the string length is within range [0, 
INT_MAX/4] in CStringChecker: we can easily assume that no overflow is 
happening in computations involving string lengths or iterator positions, but 
not on generic integers. Which lead me to believing that we could maintain a 
no-overflow variant of evalBinOp (questionable).

Would anything go wrong if we only enable this code when both symbols are known 
to be within range [-max/4, max/4]? And in the checker, add the respective 
assumption. I believe it's a very clear way to express that no overflow is 
happening. In fact, in the program state we can add an API `ProgramStateRef 
assumeNoOverflow(SVal, QualType)`, which tries to assume that the value is 
within range [-max/4, max/4] for signed types or [0, max/4] for unsigned types 
(and fails when such assumption is known be violated), so that to avoid 
duplicating similar trick in every checker.


https://reviews.llvm.org/D35109



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


[PATCH] D29660: [OpenMP] Add flag for overwriting default PTX version for OpenMP targets

2017-08-10 Thread Jacob Bandes-Storch via Phabricator via cfe-commits
jtbandes added a comment.

I'm still seeing a failure after r301549: 
https://gist.github.com/jtbandes/de6118abaadc6c5a5c9b4223a62f596c


Repository:
  rL LLVM

https://reviews.llvm.org/D29660



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


[PATCH] D36251: [analyzer] Suppress warning when bug path contains noreturn function or return from main in MagentaHandleChecker

2017-08-10 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/MagentaHandleChecker.cpp:483-498
+void MagentaHandleChecker::checkPreStmt(const ReturnStmt *RS,
+CheckerContext &Ctx) const {
+  ProgramStateRef State = Ctx.getState();
+  const StackFrameContext *SFCtx = Ctx.getStackFrame();
+  if (!SFCtx || !SFCtx->inTopFrame())
+return;
+  const FunctionDecl *FD = dyn_cast_or_null(SFCtx->getDecl());

I think the analyzer core should do this. This code already has a global effect 
on the analysis - it's enough for one checker to generate the sink. 
Additionally, there's also the CFG-based variant of suppress-on-sink, which 
would need to be extended to support this as well - this other variant kicks in 
when the analysis was interrupted before reaching the sink (see D35673 and 
D35674).


https://reviews.llvm.org/D36251



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


[PATCH] D35205: [Clang][x86][Inline Asm] support for GCC style inline asm - Y constraints

2017-08-10 Thread coby via Phabricator via cfe-commits
coby abandoned this revision.
coby added a comment.

superseded by https://reviews.llvm.org/D36371


Repository:
  rL LLVM

https://reviews.llvm.org/D35205



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


Re: r310401 - PR19668, PR23034: Fix handling of move constructors and deleted copy

2017-08-10 Thread Vassil Vassilev via cfe-commits

It looks like I can not reproduce it on osx (non-arm)... :(
On 09/08/17 22:54, Diana Picus wrote:

Reverting this also fixed the selfhost bots:
http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15-full-sh/builds/2142
http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost/builds/2309
http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost-neon/builds/1819

I'm afraid the logs for those look even less helpful.

On 9 August 2017 at 16:17, Diana Picus  wrote:

Hi,

See attached. FWIW, when I ran this on a very similar machine, I got
194 failures, all of which went away after reverting. So there might
be something fishy going on.

Regards,
Diana

On 9 August 2017 at 15:02, Vassil Vassilev  wrote:

Hi Diana,

   It seems the service is down. Could you send us the details of the
failures (incl stack traces if any)

Many thanks,
Vassil

On 09/08/17 15:27, Diana Picus via cfe-commits wrote:

Hi Richard,

I'm sorry but I've reverted this in r310464 because it was breaking
some ASAN tests on this bot:
http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-full/builds/9452

Please let me know if I can help debug this.

Cheers,
Diana

On 8 August 2017 at 21:14, Richard Smith via cfe-commits
 wrote:

I forgot to say:

Based on a patch by Vassil Vassilev, which was based on a patch by Bernd
Schmidt, which was based on a patch by Reid Kleckner.

On 8 August 2017 at 12:12, Richard Smith via cfe-commits
 wrote:

Author: rsmith
Date: Tue Aug  8 12:12:28 2017
New Revision: 310401

URL: http://llvm.org/viewvc/llvm-project?rev=310401&view=rev
Log:
PR19668, PR23034: Fix handling of move constructors and deleted copy
constructors when deciding whether classes should be passed indirectly.

This fixes ABI differences between Clang and GCC:

   * Previously, Clang ignored the move constructor when making this
 determination. It now takes the move constructor into account, per
 https://github.com/itanium-cxx-abi/cxx-abi/pull/17 (this change may
 seem recent, but the ABI change was agreed on the Itanium C++ ABI
 list a long time ago).

   * Previously, Clang's behavior when the copy constructor was deleted
 was unstable -- depending on whether the lazy declaration of the
 copy constructor had been triggered, you might get different
behavior.
 We now eagerly declare the copy constructor whenever its deletedness
 is unclear, and ignore deleted copy/move constructors when looking
for
 a trivial such constructor.

This also fixes an ABI difference between Clang and MSVC:

   * If the copy constructor would be implicitly deleted (but has not
been
 lazily declared yet), for instance because the class has an rvalue
 reference member, we would pass it directly. We now pass such a
class
 indirectly, matching MSVC.

Modified:
  cfe/trunk/include/clang/AST/DeclCXX.h
  cfe/trunk/lib/AST/ASTImporter.cpp
  cfe/trunk/lib/AST/DeclCXX.cpp
  cfe/trunk/lib/CodeGen/CGCXXABI.cpp
  cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
  cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
  cfe/trunk/lib/Sema/SemaDeclCXX.cpp
  cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
  cfe/trunk/lib/Serialization/ASTWriter.cpp
  cfe/trunk/test/CodeGenCXX/uncopyable-args.cpp
  cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL:

http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=310401&r1=310400&r2=310401&view=diff


==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Tue Aug  8 12:12:28 2017
@@ -375,6 +375,7 @@ class CXXRecordDecl : public RecordDecl
   /// \brief These flags are \c true if a defaulted corresponding
special
   /// member can't be fully analyzed without performing overload
resolution.
   /// @{
+unsigned NeedOverloadResolutionForCopyConstructor : 1;
   unsigned NeedOverloadResolutionForMoveConstructor : 1;
   unsigned NeedOverloadResolutionForMoveAssignment : 1;
   unsigned NeedOverloadResolutionForDestructor : 1;
@@ -383,6 +384,7 @@ class CXXRecordDecl : public RecordDecl
   /// \brief These flags are \c true if an implicit defaulted
corresponding
   /// special member would be defined as deleted.
   /// @{
+unsigned DefaultedCopyConstructorIsDeleted : 1;
   unsigned DefaultedMoveConstructorIsDeleted : 1;
   unsigned DefaultedMoveAssignmentIsDeleted : 1;
   unsigned DefaultedDestructorIsDeleted : 1;
@@ -415,6 +417,12 @@ class CXXRecordDecl : public RecordDecl
   /// constructor.
   unsigned HasDefaultedDefaultConstructor : 1;

+/// \brief True if this class can be passed in a
non-address-preserving
+/// fashion (such as in registers) according to the C++ language
rules.
+/// This does not imply anything about how the ABI in use will
actually
+/// pass an object of this clas

Re: r310401 - PR19668, PR23034: Fix handling of move constructors and deleted copy

2017-08-10 Thread Diana Picus via cfe-commits
Hi Vassil,

My build is in progress, but since it's a full build it's probably
going to take another couple of hours to complete. I'll let you know
when it's done.

Thanks,
Diana

On 10 August 2017 at 10:09, Vassil Vassilev  wrote:
> It looks like I can not reproduce it on osx (non-arm)... :(
> On 09/08/17 22:54, Diana Picus wrote:
>>
>> Reverting this also fixed the selfhost bots:
>>
>> http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15-full-sh/builds/2142
>>
>> http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost/builds/2309
>>
>> http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost-neon/builds/1819
>>
>> I'm afraid the logs for those look even less helpful.
>>
>> On 9 August 2017 at 16:17, Diana Picus  wrote:
>>>
>>> Hi,
>>>
>>> See attached. FWIW, when I ran this on a very similar machine, I got
>>> 194 failures, all of which went away after reverting. So there might
>>> be something fishy going on.
>>>
>>> Regards,
>>> Diana
>>>
>>> On 9 August 2017 at 15:02, Vassil Vassilev 
>>> wrote:

 Hi Diana,

It seems the service is down. Could you send us the details of the
 failures (incl stack traces if any)

 Many thanks,
 Vassil

 On 09/08/17 15:27, Diana Picus via cfe-commits wrote:
>
> Hi Richard,
>
> I'm sorry but I've reverted this in r310464 because it was breaking
> some ASAN tests on this bot:
>
> http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-full/builds/9452
>
> Please let me know if I can help debug this.
>
> Cheers,
> Diana
>
> On 8 August 2017 at 21:14, Richard Smith via cfe-commits
>  wrote:
>>
>> I forgot to say:
>>
>> Based on a patch by Vassil Vassilev, which was based on a patch by
>> Bernd
>> Schmidt, which was based on a patch by Reid Kleckner.
>>
>> On 8 August 2017 at 12:12, Richard Smith via cfe-commits
>>  wrote:
>>>
>>> Author: rsmith
>>> Date: Tue Aug  8 12:12:28 2017
>>> New Revision: 310401
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=310401&view=rev
>>> Log:
>>> PR19668, PR23034: Fix handling of move constructors and deleted copy
>>> constructors when deciding whether classes should be passed
>>> indirectly.
>>>
>>> This fixes ABI differences between Clang and GCC:
>>>
>>>* Previously, Clang ignored the move constructor when making this
>>>  determination. It now takes the move constructor into account,
>>> per
>>>  https://github.com/itanium-cxx-abi/cxx-abi/pull/17 (this change
>>> may
>>>  seem recent, but the ABI change was agreed on the Itanium C++
>>> ABI
>>>  list a long time ago).
>>>
>>>* Previously, Clang's behavior when the copy constructor was
>>> deleted
>>>  was unstable -- depending on whether the lazy declaration of the
>>>  copy constructor had been triggered, you might get different
>>> behavior.
>>>  We now eagerly declare the copy constructor whenever its
>>> deletedness
>>>  is unclear, and ignore deleted copy/move constructors when
>>> looking
>>> for
>>>  a trivial such constructor.
>>>
>>> This also fixes an ABI difference between Clang and MSVC:
>>>
>>>* If the copy constructor would be implicitly deleted (but has not
>>> been
>>>  lazily declared yet), for instance because the class has an
>>> rvalue
>>>  reference member, we would pass it directly. We now pass such a
>>> class
>>>  indirectly, matching MSVC.
>>>
>>> Modified:
>>>   cfe/trunk/include/clang/AST/DeclCXX.h
>>>   cfe/trunk/lib/AST/ASTImporter.cpp
>>>   cfe/trunk/lib/AST/DeclCXX.cpp
>>>   cfe/trunk/lib/CodeGen/CGCXXABI.cpp
>>>   cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
>>>   cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
>>>   cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>>>   cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
>>>   cfe/trunk/lib/Serialization/ASTWriter.cpp
>>>   cfe/trunk/test/CodeGenCXX/uncopyable-args.cpp
>>>   cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
>>>
>>> Modified: cfe/trunk/include/clang/AST/DeclCXX.h
>>> URL:
>>>
>>>
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=310401&r1=310400&r2=310401&view=diff
>>>
>>>
>>>
>>> ==
>>> --- cfe/trunk/include/clang/AST/DeclCXX.h (original)
>>> +++ cfe/trunk/include/clang/AST/DeclCXX.h Tue Aug  8 12:12:28 2017
>>> @@ -375,6 +375,7 @@ class CXXRecordDecl : public RecordDecl
>>>/// \brief These flags are \c true if a defaulted
>>> corresponding
>>> special
>>>/// member can't be fully analyzed without performing overload
>>> resolution

Re: r310401 - PR19668, PR23034: Fix handling of move constructors and deleted copy

2017-08-10 Thread Vassil Vassilev via cfe-commits

Hi Diana,

  Thanks for helping us out!

Cheers, Vassil
On 10/08/17 11:28, Diana Picus wrote:

Hi Vassil,

My build is in progress, but since it's a full build it's probably
going to take another couple of hours to complete. I'll let you know
when it's done.

Thanks,
Diana

On 10 August 2017 at 10:09, Vassil Vassilev  wrote:

It looks like I can not reproduce it on osx (non-arm)... :(
On 09/08/17 22:54, Diana Picus wrote:

Reverting this also fixed the selfhost bots:

http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15-full-sh/builds/2142

http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost/builds/2309

http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-selfhost-neon/builds/1819

I'm afraid the logs for those look even less helpful.

On 9 August 2017 at 16:17, Diana Picus  wrote:

Hi,

See attached. FWIW, when I ran this on a very similar machine, I got
194 failures, all of which went away after reverting. So there might
be something fishy going on.

Regards,
Diana

On 9 August 2017 at 15:02, Vassil Vassilev 
wrote:

Hi Diana,

It seems the service is down. Could you send us the details of the
failures (incl stack traces if any)

Many thanks,
Vassil

On 09/08/17 15:27, Diana Picus via cfe-commits wrote:

Hi Richard,

I'm sorry but I've reverted this in r310464 because it was breaking
some ASAN tests on this bot:

http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15-full/builds/9452

Please let me know if I can help debug this.

Cheers,
Diana

On 8 August 2017 at 21:14, Richard Smith via cfe-commits
 wrote:

I forgot to say:

Based on a patch by Vassil Vassilev, which was based on a patch by
Bernd
Schmidt, which was based on a patch by Reid Kleckner.

On 8 August 2017 at 12:12, Richard Smith via cfe-commits
 wrote:

Author: rsmith
Date: Tue Aug  8 12:12:28 2017
New Revision: 310401

URL: http://llvm.org/viewvc/llvm-project?rev=310401&view=rev
Log:
PR19668, PR23034: Fix handling of move constructors and deleted copy
constructors when deciding whether classes should be passed
indirectly.

This fixes ABI differences between Clang and GCC:

* Previously, Clang ignored the move constructor when making this
  determination. It now takes the move constructor into account,
per
  https://github.com/itanium-cxx-abi/cxx-abi/pull/17 (this change
may
  seem recent, but the ABI change was agreed on the Itanium C++
ABI
  list a long time ago).

* Previously, Clang's behavior when the copy constructor was
deleted
  was unstable -- depending on whether the lazy declaration of the
  copy constructor had been triggered, you might get different
behavior.
  We now eagerly declare the copy constructor whenever its
deletedness
  is unclear, and ignore deleted copy/move constructors when
looking
for
  a trivial such constructor.

This also fixes an ABI difference between Clang and MSVC:

* If the copy constructor would be implicitly deleted (but has not
been
  lazily declared yet), for instance because the class has an
rvalue
  reference member, we would pass it directly. We now pass such a
class
  indirectly, matching MSVC.

Modified:
   cfe/trunk/include/clang/AST/DeclCXX.h
   cfe/trunk/lib/AST/ASTImporter.cpp
   cfe/trunk/lib/AST/DeclCXX.cpp
   cfe/trunk/lib/CodeGen/CGCXXABI.cpp
   cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
   cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
   cfe/trunk/lib/Sema/SemaDeclCXX.cpp
   cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
   cfe/trunk/lib/Serialization/ASTWriter.cpp
   cfe/trunk/test/CodeGenCXX/uncopyable-args.cpp
   cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL:


http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=310401&r1=310400&r2=310401&view=diff



==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Tue Aug  8 12:12:28 2017
@@ -375,6 +375,7 @@ class CXXRecordDecl : public RecordDecl
/// \brief These flags are \c true if a defaulted
corresponding
special
/// member can't be fully analyzed without performing overload
resolution.
/// @{
+unsigned NeedOverloadResolutionForCopyConstructor : 1;
unsigned NeedOverloadResolutionForMoveConstructor : 1;
unsigned NeedOverloadResolutionForMoveAssignment : 1;
unsigned NeedOverloadResolutionForDestructor : 1;
@@ -383,6 +384,7 @@ class CXXRecordDecl : public RecordDecl
/// \brief These flags are \c true if an implicit defaulted
corresponding
/// special member would be defined as deleted.
/// @{
+unsigned DefaultedCopyConstructorIsDeleted : 1;
unsigned DefaultedMoveConstructorIsDeleted : 1;
unsigned DefaultedMoveAssignmentIsDeleted : 1;
unsigned DefaultedDestructorIsDeleted : 1;
@@ -415,6 +417,12 @@ class CXXRe

[PATCH] D36251: [analyzer] Suppress warning when bug path contains noreturn function or return from main in MagentaHandleChecker

2017-08-10 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/MagentaHandleChecker.cpp:483-498
+void MagentaHandleChecker::checkPreStmt(const ReturnStmt *RS,
+CheckerContext &Ctx) const {
+  ProgramStateRef State = Ctx.getState();
+  const StackFrameContext *SFCtx = Ctx.getStackFrame();
+  if (!SFCtx || !SFCtx->inTopFrame())
+return;
+  const FunctionDecl *FD = dyn_cast_or_null(SFCtx->getDecl());

NoQ wrote:
> I think the analyzer core should do this. This code already has a global 
> effect on the analysis - it's enough for one checker to generate the sink. 
> Additionally, there's also the CFG-based variant of suppress-on-sink, which 
> would need to be extended to support this as well - this other variant kicks 
> in when the analysis was interrupted before reaching the sink (see D35673 and 
> D35674).
Do we want to do this unconditionally? Are all of the resources cleaned up on 
all of the supported OSes, or maybe for some leak issues it still makes sense 
to warn in these cases? Or we simply favor false negatives over false positives 
in this case (might make sense)? 


https://reviews.llvm.org/D36251



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


[clang-tools-extra] r310558 - [clang-tidy] Add missing doc in cppcoreguidelines-c-copy-assignment-signature check.

2017-08-10 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Thu Aug 10 02:12:32 2017
New Revision: 310558

URL: http://llvm.org/viewvc/llvm-project?rev=310558&view=rev
Log:
[clang-tidy] Add missing doc in cppcoreguidelines-c-copy-assignment-signature 
check.

Added:

clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-c-copy-assignment-signature.rst
Modified:
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Added: 
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-c-copy-assignment-signature.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-c-copy-assignment-signature.rst?rev=310558&view=auto
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-c-copy-assignment-signature.rst
 (added)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-c-copy-assignment-signature.rst
 Thu Aug 10 02:12:32 2017
@@ -0,0 +1,9 @@
+.. title:: clang-tidy - cppcoreguidelines-c-copy-assignment-signature
+.. meta::
+   :http-equiv=refresh: 5;URL=misc-unconventional-assign-operator.html
+
+cppcoreguidelines-c-copy-assignment-signature
+=
+
+The cppcoreguidelines-c-copy-assignment-signature check is an alias, please see
+`misc-unconventional-assign-operator`_ for more information.

Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst?rev=310558&r1=310557&r2=310558&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst Thu Aug 10 02:12:32 
2017
@@ -29,6 +29,7 @@ Clang-Tidy Checks
cert-msc30-c (redirects to cert-msc50-cpp) 
cert-msc50-cpp
cert-oop11-cpp (redirects to misc-move-constructor-init) 
+   cppcoreguidelines-c-copy-assignment-signature
cppcoreguidelines-interfaces-global-init
cppcoreguidelines-no-malloc
cppcoreguidelines-pro-bounds-array-to-pointer-decay


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


[clang-tools-extra] r310559 - [clang-tidy] Minor documentation improvement

2017-08-10 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Thu Aug 10 02:13:26 2017
New Revision: 310559

URL: http://llvm.org/viewvc/llvm-project?rev=310559&view=rev
Log:
[clang-tidy] Minor documentation improvement

Patch by: Lilla Barancsuk

Modified:

clang-tools-extra/trunk/docs/clang-tidy/checks/readability-static-accessed-through-instance.rst

clang-tools-extra/trunk/test/clang-tidy/readability-static-accessed-through-instance.cpp

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-static-accessed-through-instance.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/readability-static-accessed-through-instance.rst?rev=310559&r1=310558&r2=310559&view=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-static-accessed-through-instance.rst
 (original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-static-accessed-through-instance.rst
 Thu Aug 10 02:13:26 2017
@@ -25,6 +25,7 @@ is changed to:
 
 .. code-block:: c++
 
+  C *c1 = new C();
   C::foo();
   C::x;
 

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-static-accessed-through-instance.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-static-accessed-through-instance.cpp?rev=310559&r1=310558&r2=310559&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/readability-static-accessed-through-instance.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/readability-static-accessed-through-instance.cpp
 Thu Aug 10 02:13:26 2017
@@ -116,7 +116,7 @@ using E = D;
 
 template  void f(T t, C c) {
   t.x; // OK, t is a template parameter.
-  c.x; // 1
+  c.x;
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: static member
   // CHECK-FIXES: {{^}}  C::x; // 1{{$}}
 }


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


[PATCH] D34512: Add preliminary Cross Translation Unit support library

2017-08-10 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

In https://reviews.llvm.org/D34512#836831, @whisperity wrote:

> Apart from those in the in-line comments, I have a question: how safe is this 
> library to `Release` builds? I know this is only a submodule dependency for 
> the "real deal" in https://reviews.llvm.org/D30691, but I have seen some 
> asserts that "imported function should already have a body" and such.
>
> Will the static analyzer handle these errors gracefully and fall back to 
> "function is unknown, let's throw my presumptions out of the window" or will 
> it bail away? I'm explicitly thinking of the assert-lacking `Release` build.


The basic idea is that, if a function already have a body in the current 
translation unit and you still want to import it from somewhere else, it might 
be a programmer error, so we do not handle this gracefully.




Comment at: include/clang/CrossTU/CrossTranslationUnit.h:42
+/// Note that this class also implements caching.
+class CrossTranslationUnit {
+public:

whisperity wrote:
> Does the name of this class make sense? If I say
> 
> 
> ```
> CrossTranslationUnit *ctuptr = new CrossTranslationUnit(...);
> ```
> 
> did I construct a new //CrossTranslationUnit//? What even **is** a 
> //CrossTranslationUnit//? Other class names, such as `ASTImporter`, 
> `DiagOpts`, and `FrontendAction`, etc. somehow feel better at 
> ~~transmitting~~ reflecting upon their meaning in their name.
> 
> 
What would you think about `CrossTranslationUnitContext`?

The functionality of this class is have all the relevant data required for 
doing Cross TU lookups and also provide the interface for that. 


https://reviews.llvm.org/D34512



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


[PATCH] D36551: [mips] Show warning in case of mixing -mlong-calls and -mabicalls options

2017-08-10 Thread Simon Dardis via Phabricator via cfe-commits
sdardis added inline comments.



Comment at: include/clang/Basic/DiagnosticDriverKinds.td:296-297
+def warn_drv_unsupported_longcalls : Warning<
+  "ignoring '-mlong-calls' option as it cannot be used with "
+  "%select{|the implicit usage of }0-mabicalls">,
+  InGroup;

"as it is not currently supported with "

I think is better, as we currently don't support mixing the options but could 
do in the future.


Repository:
  rL LLVM

https://reviews.llvm.org/D36551



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


[clang-tools-extra] r310560 - [clang-tidy] Fix a check-fixes line

2017-08-10 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Thu Aug 10 02:29:39 2017
New Revision: 310560

URL: http://llvm.org/viewvc/llvm-project?rev=310560&view=rev
Log:
[clang-tidy] Fix a check-fixes line

Modified:

clang-tools-extra/trunk/test/clang-tidy/readability-static-accessed-through-instance.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-static-accessed-through-instance.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-static-accessed-through-instance.cpp?rev=310560&r1=310559&r2=310560&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/readability-static-accessed-through-instance.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/readability-static-accessed-through-instance.cpp
 Thu Aug 10 02:29:39 2017
@@ -118,7 +118,7 @@ template  void f(T t, C c) {
   t.x; // OK, t is a template parameter.
   c.x;
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: static member
-  // CHECK-FIXES: {{^}}  C::x; // 1{{$}}
+  // CHECK-FIXES: {{^}}  C::x;{{$}}
 }
 
 template  struct S { static int x; };


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


[PATCH] D35932: [clang-tidy] Add integer division check

2017-08-10 Thread Reka Kovacs via Phabricator via cfe-commits
rnkovacs updated this revision to Diff 110539.
rnkovacs marked 3 inline comments as done.
rnkovacs edited the summary of this revision.
rnkovacs added a comment.

Thanks for the comments. I improved the docs and truncated the messages in the 
test file.

We also had concerns about the nested `hasAncestor` matchers but thought that 
it might be worth a try. If this solution proves to cause too much of a 
performance burden I can rewrite it using RAVs.


https://reviews.llvm.org/D35932

Files:
  clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tidy/bugprone/CMakeLists.txt
  clang-tidy/bugprone/IntegerDivisionCheck.cpp
  clang-tidy/bugprone/IntegerDivisionCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/bugprone-integer-division.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/bugprone-integer-division.cpp

Index: test/clang-tidy/bugprone-integer-division.cpp
===
--- /dev/null
+++ test/clang-tidy/bugprone-integer-division.cpp
@@ -0,0 +1,130 @@
+// RUN: %check_clang_tidy %s bugprone-integer-division %t
+
+// Functions expecting a floating-point parameter.
+void floatArg(float x) {}
+void doubleArg(double x) {}
+void longDoubleArg(long double x) {}
+
+// Functions expected to return a floating-point value.
+float singleDiv() {
+  int x = -5;
+  int y = 2;
+  return x/y;
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: result of integer division used in
+}
+
+double wrongOrder(int x, int y) {
+  return x/y/0.1;
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: result of integer division used in
+}
+
+long double rightOrder(int x, int y) {
+  return 0.1/x/y; // OK
+}
+
+// Typical mathematical functions.
+float sin(float);
+double acos(double);
+long double tanh(long double);
+
+namespace std {
+  using ::sin;
+}
+
+template 
+void intDivSin(T x) {
+  sin(x);
+}
+
+int intFunc(int);
+
+struct X {
+  int n;
+  void m() {
+sin(n / 3);
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: result of integer division used in
+  }
+};
+
+void integerDivision() {
+  char a = 2;
+  short b = -5;
+  int c = 9784;
+  enum third { x, y, z=2 };
+  third d = z;
+  char e[] = {'a', 'b', 'c'};
+  char f = *(e + 1 / a);
+  bool g = 1;
+
+  sin(1 + c / (2 + 2));
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: result of integer division used in
+  sin(c / (1 + .5));
+  sin((c + .5) / 3);
+
+  sin(intFunc(3) / 5);
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: result of integer division used in
+  acos(2 / intFunc(7));
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: result of integer division used in
+
+  floatArg(1 + 2 / 3);
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: result of integer division used in
+  sin(1 + 2 / 3);
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: result of integer division used in
+  intFunc(sin(1 + 2 / 3));
+// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: result of integer division used in
+
+  floatArg(1 + intFunc(1 + 2 / 3));
+  floatArg(1 + 3 * intFunc(a / b));
+
+  1 << (2 / 3);
+  1 << intFunc(2 / 3);
+
+#define M_SIN sin(a / b);
+  M_SIN
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: result of integer division used in
+
+  intDivSin(a / b);
+// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: result of integer division used in
+  intDivSin(c / d);
+// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: result of integer division used in
+  intDivSin(f / g);
+// CHECK-MESSAGES: :[[@LINE-1]]:26: warning: result of integer division used in
+
+  floatArg(1 / 3);
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: result of integer division used in
+  doubleArg(a / b);
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: result of integer division used in
+  longDoubleArg(3 / d);
+// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: result of integer division used in
+  floatArg(a / b / 0.1);
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: result of integer division used in
+  doubleArg(1 / 3 / 0.1);
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: result of integer division used in
+  longDoubleArg(2 / 3 / 5);
+// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: result of integer division used in
+
+  std::sin(2 / 3);
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: result of integer division used in
+  ::acos(7 / d);
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: result of integer division used in
+  tanh(f / g);
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: result of integer division used in
+
+  floatArg(0.1 / a / b);
+  doubleArg(0.1 / 3 / 1);
+
+  singleDiv();
+  wrongOrder(a,b);
+  rightOrder(a,b);
+
+  sin(a / b);
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: result of integer division used in
+  acos(f / d);
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: result of integer division used in
+  tanh(c / g);
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: result of integer division used in
+
+  sin(3.0 / a);
+  acos(b / 3.14);
+  tanh(3.14 / f / g);
+}
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clan

[PATCH] D9912: PR20958 Allow redeclaration of type-generic builtins

2017-08-10 Thread Ilya Palachev via Phabricator via cfe-commits
ilya-palachev added a comment.

Hi! Thanks for this patch.

We're building Android6 with Clang (in order to apply static analyzer on it), 
and without this patch we've 613 build failures. This patch helps to get rid of 
521 of those build failures (85%).

"Works for me".




Comment at: lib/Sema/SemaDecl.cpp:1758
+  }
+  
+  QualType QT1 = FPT->getParamType(0);

Trailing space



Comment at: lib/Sema/SemaDecl.cpp:1763
+  ArgTypes.push_back(QT2);
+  
+  if (QT1->isRealFloatingType() && QT2->isRealFloatingType()) {

Ditto



Comment at: lib/Sema/SemaDecl.cpp:1775
+<< II->getName()
+<< QT1.getAsString();  
+  return DefaultFunctionType;

Ditto



Comment at: lib/Sema/SemaDecl.cpp:1837
+  case Builtin::BI__builtin_isnan:
+  case Builtin::BI__builtin_signbit:
+Diag(Loc, diag::err_incorrect_args_builtin_redecl)

Ditto


https://reviews.llvm.org/D9912



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


[PATCH] D36251: [analyzer] Suppress warning when bug path contains noreturn function or return from main in MagentaHandleChecker

2017-08-10 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/MagentaHandleChecker.cpp:483-498
+void MagentaHandleChecker::checkPreStmt(const ReturnStmt *RS,
+CheckerContext &Ctx) const {
+  ProgramStateRef State = Ctx.getState();
+  const StackFrameContext *SFCtx = Ctx.getStackFrame();
+  if (!SFCtx || !SFCtx->inTopFrame())
+return;
+  const FunctionDecl *FD = dyn_cast_or_null(SFCtx->getDecl());

xazax.hun wrote:
> NoQ wrote:
> > I think the analyzer core should do this. This code already has a global 
> > effect on the analysis - it's enough for one checker to generate the sink. 
> > Additionally, there's also the CFG-based variant of suppress-on-sink, which 
> > would need to be extended to support this as well - this other variant 
> > kicks in when the analysis was interrupted before reaching the sink (see 
> > D35673 and D35674).
> Do we want to do this unconditionally? Are all of the resources cleaned up on 
> all of the supported OSes, or maybe for some leak issues it still makes sense 
> to warn in these cases? Or we simply favor false negatives over false 
> positives in this case (might make sense)? 
We could add a flag to `setSuppressOnSink()` as an orthogonal change if it 
turns out that we need it; i'm not aware of any stuff that badly needs to be 
cleaned up before normal program termination in the existing checkers.


https://reviews.llvm.org/D36251



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


[PATCH] D34512: Add preliminary Cross Translation Unit support library

2017-08-10 Thread Whisperity via Phabricator via cfe-commits
whisperity added inline comments.



Comment at: include/clang/CrossTU/CrossTranslationUnit.h:42
+/// Note that this class also implements caching.
+class CrossTranslationUnit {
+public:

xazax.hun wrote:
> whisperity wrote:
> > Does the name of this class make sense? If I say
> > 
> > 
> > ```
> > CrossTranslationUnit *ctuptr = new CrossTranslationUnit(...);
> > ```
> > 
> > did I construct a new //CrossTranslationUnit//? What even **is** a 
> > //CrossTranslationUnit//? Other class names, such as `ASTImporter`, 
> > `DiagOpts`, and `FrontendAction`, etc. somehow feel better at 
> > ~~transmitting~~ reflecting upon their meaning in their name.
> > 
> > 
> What would you think about `CrossTranslationUnitContext`?
> 
> The functionality of this class is have all the relevant data required for 
> doing Cross TU lookups and also provide the interface for that. 
WFM. I'm not sure whose authority is the class names, but I like it a lot 
better.


https://reviews.llvm.org/D34512



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


r310576 - [Lexer] Finding beginning of token with escaped new line

2017-08-10 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu Aug 10 03:06:16 2017
New Revision: 310576

URL: http://llvm.org/viewvc/llvm-project?rev=310576&view=rev
Log:
[Lexer] Finding beginning of token with escaped new line

Summary:
Lexer::GetBeginningOfToken produced invalid location when
backtracking across escaped new lines.

This fixes PR26228

Reviewers: akyrtzi, alexfh, rsmith, doug.gregor

Reviewed By: alexfh

Subscribers: alexfh, cfe-commits

Patch by Paweł Żukowski!

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

Modified:
cfe/trunk/include/clang/Lex/Lexer.h
cfe/trunk/lib/Lex/Lexer.cpp
cfe/trunk/unittests/Lex/LexerTest.cpp

Modified: cfe/trunk/include/clang/Lex/Lexer.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Lexer.h?rev=310576&r1=310575&r2=310576&view=diff
==
--- cfe/trunk/include/clang/Lex/Lexer.h (original)
+++ cfe/trunk/include/clang/Lex/Lexer.h Thu Aug 10 03:06:16 2017
@@ -463,6 +463,10 @@ public:
   /// \brief Returns true if the given character could appear in an identifier.
   static bool isIdentifierBodyChar(char c, const LangOptions &LangOpts);
 
+  /// \brief Checks whether new line pointed by Str is preceded by escape
+  /// sequence.
+  static bool isNewLineEscaped(const char *BufferStart, const char *Str);
+
   /// getCharAndSizeNoWarn - Like the getCharAndSize method, but does not ever
   /// emit a warning.
   static inline char getCharAndSizeNoWarn(const char *Ptr, unsigned &Size,

Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=310576&r1=310575&r2=310576&view=diff
==
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Thu Aug 10 03:06:16 2017
@@ -463,19 +463,15 @@ static const char *findBeginningOfLine(S
   const char *BufStart = Buffer.data();
   if (Offset >= Buffer.size())
 return nullptr;
-  const char *StrData = BufStart + Offset;
 
-  if (StrData[0] == '\n' || StrData[0] == '\r')
-return StrData;
-
-  const char *LexStart = StrData;
-  while (LexStart != BufStart) {
-if (LexStart[0] == '\n' || LexStart[0] == '\r') {
+  const char *LexStart = BufStart + Offset;
+  for (; LexStart != BufStart; --LexStart) {
+if (isVerticalWhitespace(LexStart[0]) &&
+!Lexer::isNewLineEscaped(BufStart, LexStart)) {
+  // LexStart should point at first character of logical line.
   ++LexStart;
   break;
 }
-
---LexStart;
   }
   return LexStart;
 }
@@ -487,7 +483,7 @@ static SourceLocation getBeginningOfFile
   std::pair LocInfo = SM.getDecomposedLoc(Loc);
   if (LocInfo.first.isInvalid())
 return Loc;
-  
+
   bool Invalid = false;
   StringRef Buffer = SM.getBufferData(LocInfo.first, &Invalid);
   if (Invalid)
@@ -499,31 +495,31 @@ static SourceLocation getBeginningOfFile
   const char *LexStart = findBeginningOfLine(Buffer, LocInfo.second);
   if (!LexStart || LexStart == StrData)
 return Loc;
-  
+
   // Create a lexer starting at the beginning of this token.
   SourceLocation LexerStartLoc = Loc.getLocWithOffset(-LocInfo.second);
   Lexer TheLexer(LexerStartLoc, LangOpts, Buffer.data(), LexStart,
  Buffer.end());
   TheLexer.SetCommentRetentionState(true);
-  
+
   // Lex tokens until we find the token that contains the source location.
   Token TheTok;
   do {
 TheLexer.LexFromRawLexer(TheTok);
-
+
 if (TheLexer.getBufferLocation() > StrData) {
   // Lexing this token has taken the lexer past the source location we're
   // looking for. If the current token encompasses our source location,
   // return the beginning of that token.
   if (TheLexer.getBufferLocation() - TheTok.getLength() <= StrData)
 return TheTok.getLocation();
-  
+
   // We ended up skipping over the source location entirely, which means
   // that it points into whitespace. We're done here.
   break;
 }
   } while (TheTok.getKind() != tok::eof);
-  
+
   // We've passed our source location; just return the original source 
location.
   return Loc;
 }
@@ -531,20 +527,20 @@ static SourceLocation getBeginningOfFile
 SourceLocation Lexer::GetBeginningOfToken(SourceLocation Loc,
   const SourceManager &SM,
   const LangOptions &LangOpts) {
- if (Loc.isFileID())
-   return getBeginningOfFileToken(Loc, SM, LangOpts);
- 
- if (!SM.isMacroArgExpansion(Loc))
-   return Loc;
-
- SourceLocation FileLoc = SM.getSpellingLoc(Loc);
- SourceLocation BeginFileLoc = getBeginningOfFileToken(FileLoc, SM, LangOpts);
- std::pair FileLocInfo = SM.getDecomposedLoc(FileLoc);
- std::pair BeginFileLocInfo
-   = SM.getDecomposedLoc(BeginFileLoc);
- assert(FileLocInfo.first == BeginFileLocInfo.first &&
-FileLocInfo.second >= BeginFileLocInfo.second);
- return Loc.getLocWithOffset(BeginFile

[PATCH] D30748: [Lexer] Finding beginning of token with escaped new line

2017-08-10 Thread Alexander Kornienko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310576: [Lexer] Finding beginning of token with escaped new 
line (authored by alexfh).

Changed prior to commit:
  https://reviews.llvm.org/D30748?vs=110029&id=110544#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30748

Files:
  cfe/trunk/include/clang/Lex/Lexer.h
  cfe/trunk/lib/Lex/Lexer.cpp
  cfe/trunk/unittests/Lex/LexerTest.cpp

Index: cfe/trunk/lib/Lex/Lexer.cpp
===
--- cfe/trunk/lib/Lex/Lexer.cpp
+++ cfe/trunk/lib/Lex/Lexer.cpp
@@ -463,19 +463,15 @@
   const char *BufStart = Buffer.data();
   if (Offset >= Buffer.size())
 return nullptr;
-  const char *StrData = BufStart + Offset;
 
-  if (StrData[0] == '\n' || StrData[0] == '\r')
-return StrData;
-
-  const char *LexStart = StrData;
-  while (LexStart != BufStart) {
-if (LexStart[0] == '\n' || LexStart[0] == '\r') {
+  const char *LexStart = BufStart + Offset;
+  for (; LexStart != BufStart; --LexStart) {
+if (isVerticalWhitespace(LexStart[0]) &&
+!Lexer::isNewLineEscaped(BufStart, LexStart)) {
+  // LexStart should point at first character of logical line.
   ++LexStart;
   break;
 }
-
---LexStart;
   }
   return LexStart;
 }
@@ -487,7 +483,7 @@
   std::pair LocInfo = SM.getDecomposedLoc(Loc);
   if (LocInfo.first.isInvalid())
 return Loc;
-  
+
   bool Invalid = false;
   StringRef Buffer = SM.getBufferData(LocInfo.first, &Invalid);
   if (Invalid)
@@ -499,52 +495,52 @@
   const char *LexStart = findBeginningOfLine(Buffer, LocInfo.second);
   if (!LexStart || LexStart == StrData)
 return Loc;
-  
+
   // Create a lexer starting at the beginning of this token.
   SourceLocation LexerStartLoc = Loc.getLocWithOffset(-LocInfo.second);
   Lexer TheLexer(LexerStartLoc, LangOpts, Buffer.data(), LexStart,
  Buffer.end());
   TheLexer.SetCommentRetentionState(true);
-  
+
   // Lex tokens until we find the token that contains the source location.
   Token TheTok;
   do {
 TheLexer.LexFromRawLexer(TheTok);
-
+
 if (TheLexer.getBufferLocation() > StrData) {
   // Lexing this token has taken the lexer past the source location we're
   // looking for. If the current token encompasses our source location,
   // return the beginning of that token.
   if (TheLexer.getBufferLocation() - TheTok.getLength() <= StrData)
 return TheTok.getLocation();
-  
+
   // We ended up skipping over the source location entirely, which means
   // that it points into whitespace. We're done here.
   break;
 }
   } while (TheTok.getKind() != tok::eof);
-  
+
   // We've passed our source location; just return the original source location.
   return Loc;
 }
 
 SourceLocation Lexer::GetBeginningOfToken(SourceLocation Loc,
   const SourceManager &SM,
   const LangOptions &LangOpts) {
- if (Loc.isFileID())
-   return getBeginningOfFileToken(Loc, SM, LangOpts);
- 
- if (!SM.isMacroArgExpansion(Loc))
-   return Loc;
+  if (Loc.isFileID())
+return getBeginningOfFileToken(Loc, SM, LangOpts);
+
+  if (!SM.isMacroArgExpansion(Loc))
+return Loc;
 
- SourceLocation FileLoc = SM.getSpellingLoc(Loc);
- SourceLocation BeginFileLoc = getBeginningOfFileToken(FileLoc, SM, LangOpts);
- std::pair FileLocInfo = SM.getDecomposedLoc(FileLoc);
- std::pair BeginFileLocInfo
-   = SM.getDecomposedLoc(BeginFileLoc);
- assert(FileLocInfo.first == BeginFileLocInfo.first &&
-FileLocInfo.second >= BeginFileLocInfo.second);
- return Loc.getLocWithOffset(BeginFileLocInfo.second - FileLocInfo.second);
+  SourceLocation FileLoc = SM.getSpellingLoc(Loc);
+  SourceLocation BeginFileLoc = getBeginningOfFileToken(FileLoc, SM, LangOpts);
+  std::pair FileLocInfo = SM.getDecomposedLoc(FileLoc);
+  std::pair BeginFileLocInfo =
+  SM.getDecomposedLoc(BeginFileLoc);
+  assert(FileLocInfo.first == BeginFileLocInfo.first &&
+ FileLocInfo.second >= BeginFileLocInfo.second);
+  return Loc.getLocWithOffset(BeginFileLocInfo.second - FileLocInfo.second);
 }
 
 namespace {
@@ -1032,6 +1028,26 @@
   return isIdentifierBody(c, LangOpts.DollarIdents);
 }
 
+bool Lexer::isNewLineEscaped(const char *BufferStart, const char *Str) {
+  assert(isVerticalWhitespace(Str[0]));
+  if (Str - 1 < BufferStart)
+return false;
+
+  if ((Str[0] == '\n' && Str[-1] == '\r') ||
+  (Str[0] == '\r' && Str[-1] == '\n')) {
+if (Str - 2 < BufferStart)
+  return false;
+--Str;
+  }
+  --Str;
+
+  // Rewind to first non-space character:
+  while (Str > BufferStart && isHorizontalWhitespace(*Str))
+--Str;
+
+  return *Str == '\\';
+}
+
 StringRef Lexer::getIndentationForLine(SourceLocation Loc,
const SourceManager &SM) {
   if (Loc.isInvalid() || Loc.isMacroID())
Index: cfe/trunk/unittests/Lex/LexerTest.cpp
=

[clang-tools-extra] r310577 - [clang-tidy] add forwarders in the aliased checks from hicpp module

2017-08-10 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Thu Aug 10 03:12:31 2017
New Revision: 310577

URL: http://llvm.org/viewvc/llvm-project?rev=310577&view=rev
Log:
[clang-tidy] add forwarders in the aliased checks from hicpp module

Summary: Adds redirections notes and the actual redirections in the 
documentation for hicpp

Patch by: Jonas Toth

Reviewers: aaron.ballman, hokein, alexfh

Reviewed By: aaron.ballman, hokein

Subscribers: JDevlieghere, xazax.hun

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

Modified:

clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-explicit-conversions.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-function-size.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-invalid-access-moved.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-member-init.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-named-parameter.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-new-delete-operators.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-noexcept-move.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-special-member-functions.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-undelegated-constructor.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-use-equals-default.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-use-equals-delete.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-use-override.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-explicit-conversions.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-explicit-conversions.rst?rev=310577&r1=310576&r2=310577&view=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-explicit-conversions.rst 
(original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-explicit-conversions.rst 
Thu Aug 10 03:12:31 2017
@@ -1,9 +1,11 @@
 .. title:: clang-tidy - hicpp-explicit-conversions
+.. meta::
+   :http-equiv=refresh: 5;URL=google-explicit-constructor.html
 
 hicpp-explicit-conversions
 ==
 
-This check is an alias for `google-explicit-constructor 
`_.
+This check is an alias for `google-explicit-constructor 
`_.
 Used to enforce parts of `rule 5.4.1 
`_.
 This check will enforce that constructors and conversion operators are marked 
`explicit`.
 Other forms of casting checks are implemented in other places.

Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-function-size.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-function-size.rst?rev=310577&r1=310576&r2=310577&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-function-size.rst 
(original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-function-size.rst Thu 
Aug 10 03:12:31 2017
@@ -1,9 +1,11 @@
 .. title:: clang-tidy - hicpp-function-size
+.. meta::
+   :http-equiv=refresh: 5;URL=readability-function-size.html
 
 hicpp-function-size
 ===
 
-This check is an alias for `readability-function-size 
`_.
+This check is an alias for `readability-function-size 
`_.
 Useful to enforce multiple sections on function complexity.
 
 - `rule 8.2.2 
`_

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-invalid-access-moved.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-invalid-access-moved.rst?rev=310577&r1=310576&r2=310577&view=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-invalid-access-moved.rst 
(original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-invalid-access-moved.rst 
Thu Aug 10 03:12:31 2017
@@ -1,8 +1,10 @@
 .. title:: clang-tidy - hicpp-invalid-access-moved
+.. meta::
+   :http-equiv=refresh: 5;URL=misc-use-after-move.html
 
 hicpp-invalid-access-moved
 ==
 
-This check is an alias for `misc-use-after-move `_.
+This check is an alias for `misc-use-after-move `_.
 
 Implements parts of the `rule 8.4.1 
`_
 to check if moved-from objects are accessed.

Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-member-init.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-member-init.rst?rev=310577&r1=310576&r2=310577&view=diff
=

[clang-tools-extra] r310578 - [clang-tidy] Fix an error in the doc.

2017-08-10 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Thu Aug 10 03:15:48 2017
New Revision: 310578

URL: http://llvm.org/viewvc/llvm-project?rev=310578&view=rev
Log:
[clang-tidy] Fix an error in the doc.

Modified:

clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-c-copy-assignment-signature.rst

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-c-copy-assignment-signature.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-c-copy-assignment-signature.rst?rev=310578&r1=310577&r2=310578&view=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-c-copy-assignment-signature.rst
 (original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-c-copy-assignment-signature.rst
 Thu Aug 10 03:15:48 2017
@@ -6,4 +6,5 @@ cppcoreguidelines-c-copy-assignment-sign
 =
 
 The cppcoreguidelines-c-copy-assignment-signature check is an alias, please see
-`misc-unconventional-assign-operator`_ for more information.
+`misc-unconventional-assign-operator 
`_
+for more information.


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


[PATCH] D36529: Fixed a race condition in PrecompiledPreamble.

2017-08-10 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added inline comments.



Comment at: lib/Frontend/PrecompiledPreamble.cpp:470-471
+  int FD;
+  auto EC = llvm::sys::fs::createTemporaryFile(Prefix, Suffix, /*ref*/ FD,
+   /*ref*/ File);
   if (EC)

I don't understand that yet - why does keeping the file open around the EC 
check change any of the behavior?
Generally, both create the file, right? So only the first one should get no 
error?


https://reviews.llvm.org/D36529



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


[PATCH] D35449: [X86] Implement __builtin_cpu_is

2017-08-10 Thread Eric Christopher via Phabricator via cfe-commits
echristo accepted this revision.
echristo added a comment.
This revision is now accepted and ready to land.

SGTM.

-eric


https://reviews.llvm.org/D35449



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


r310580 - Revert r310489 and follow-up commits r310505, r310519, r310537 and r310549

2017-08-10 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Aug 10 03:34:46 2017
New Revision: 310580

URL: http://llvm.org/viewvc/llvm-project?rev=310580&view=rev
Log:
Revert r310489 and follow-up commits r310505, r310519, r310537 and r310549

Commit r310489 caused 'openmp-offload.c' test failures on Darwin and other
platforms:
http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_check/39230/testReport/junit/Clang/Driver/openmp_offload_c/

The follow-up commits tried to fix the test, but the test is still failing.

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
cfe/trunk/lib/Driver/ToolChains/Cuda.h
cfe/trunk/test/Driver/openmp-offload.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=310580&r1=310579&r2=310580&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Aug 10 03:34:46 2017
@@ -544,8 +544,6 @@ def no_cuda_version_check : Flag<["--"],
 def no_cuda_noopt_device_debug : Flag<["--"], "no-cuda-noopt-device-debug">;
 def cuda_path_EQ : Joined<["--"], "cuda-path=">, Group,
   HelpText<"CUDA installation path">;
-def fopenmp_ptx_EQ : Joined<["--"], "fopenmp-ptx=">, Flags<[DriverOption]>,
-  HelpText<"Pass a PTX version +ptxXX, default +ptx42 (for PTX version 4.2) 
used by OpenMP device offloading.">;
 def ptxas_path_EQ : Joined<["--"], "ptxas-path=">, Group,
   HelpText<"Path to ptxas (used for compiling CUDA code)">;
 def fcuda_flush_denormals_to_zero : Flag<["-"], 
"fcuda-flush-denormals-to-zero">,

Modified: cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Cuda.cpp?rev=310580&r1=310579&r2=310580&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Cuda.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Cuda.cpp Thu Aug 10 03:34:46 2017
@@ -484,13 +484,7 @@ void CudaToolChain::addClangTargetOption
   // than LLVM defaults to. Use PTX4.2 which is the PTX version that
   // came with CUDA-7.0.
   CC1Args.push_back("-target-feature");
-
-  if (DeviceOffloadingKind == Action::OFK_OpenMP)
-CC1Args.push_back(
-DriverArgs.getLastArgValue(options::OPT_fopenmp_ptx_EQ,
-   "+ptx42").data());
-  else
-CC1Args.push_back("+ptx42");
+  CC1Args.push_back("+ptx42");
 }
 
 void CudaToolChain::AddCudaIncludeArgs(const ArgList &DriverArgs,
@@ -533,14 +527,10 @@ CudaToolChain::TranslateArgs(const llvm:
 }
 
 StringRef Arch = DAL->getLastArgValue(options::OPT_march_EQ);
-if (Arch.empty()) {
-  // Default compute capability for CUDA toolchain is the
-  // lowest compute capability supported by the installed
-  // CUDA version.
+if (Arch.empty())
+  // Default compute capability for CUDA toolchain is sm_20.
   DAL->AddJoinedArg(nullptr,
-  Opts.getOption(options::OPT_march_EQ),
-  CudaInstallation.getLowestExistingArch());
-}
+  Opts.getOption(options::OPT_march_EQ), "sm_20");
 
 return DAL;
   }

Modified: cfe/trunk/lib/Driver/ToolChains/Cuda.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Cuda.h?rev=310580&r1=310579&r2=310580&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Cuda.h (original)
+++ cfe/trunk/lib/Driver/ToolChains/Cuda.h Thu Aug 10 03:34:46 2017
@@ -76,17 +76,6 @@ public:
   std::string getLibDeviceFile(StringRef Gpu) const {
 return LibDeviceMap.lookup(Gpu);
   }
-  /// \brief Get lowest available compute capability
-  /// for which a libdevice library exists.
-  std::string getLowestExistingArch() const {
-std::string LibDeviceFile;
-for (auto key : LibDeviceMap.keys()) {
-  LibDeviceFile = LibDeviceMap.lookup(key);
-  if (!LibDeviceFile.empty())
-return key;
-}
-llvm_unreachable("no libdevice exists.");
-  }
 };
 
 namespace tools {

Modified: cfe/trunk/test/Driver/openmp-offload.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/openmp-offload.c?rev=310580&r1=310579&r2=310580&view=diff
==
--- cfe/trunk/test/Driver/openmp-offload.c (original)
+++ cfe/trunk/test/Driver/openmp-offload.c Thu Aug 10 03:34:46 2017
@@ -691,7 +691,7 @@
 /// ###
 
 /// Check PTXAS is passed -c flag when offloading to an NVIDIA device using 
OpenMP.
-// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp 
-fopenmp-targets=nvptx64-nvidia-cuda %s 2>&1 \
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
-no-canonical-prefixes %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-PTXA

[PATCH] D29660: [OpenMP] Add flag for overwriting default PTX version for OpenMP targets

2017-08-10 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

1. I'm sorry, but I had to revert r310489 and follow-up commits r310505, 
r310519, r310537 and r310549 since it looks like the failures are accumulating. 
The revert commit was r310580. The following run lines were failing for me 
because of various assertion failures and file check errors:

  /// 
###
  
  /// Check cubin file generation and usage by nvlink
  // RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp 
-fopenmp-targets=nvptx64-nvidia-cuda -save-temps -no-canonical-prefixes %s 2>&1 
\
  // RUN:   | FileCheck -check-prefix=CHK-CUBIN %s
  
  // CHK-CUBIN: clang{{.*}}" "-o" "{{.*}}-openmp-nvptx64-nvidia-cuda.s"
  // CHK-CUBIN-NEXT: ptxas{{.*}}" "--output-file" 
"{{.*}}-openmp-nvptx64-nvidia-cuda.cubin" "{{.*}}-openmp-nvptx64-nvidia-cuda.s"
  // CHK-CUBIN-NEXT: nvlink" "-o" "{{.*}}-openmp-nvptx64-nvidia-cuda" {{.*}} 
"openmp-offload-openmp-nvptx64-nvidia-cuda.cubin"
  
  /// 
###
  
  /// Check cubin file generation and usage by nvlink when toolchain has 
BindArchAction
  // RUN:   %clang -### -no-canonical-prefixes -target 
x86_64-apple-darwin17.0.0 -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
-save-temps -no-canonical-prefixes %s 2>&1 \
  // RUN:   | FileCheck -check-prefix=CHK-CUBIN-DARWIN %s
  
  // CHK-CUBIN-DARWIN: clang{{.*}}" "-o" "{{.*}}-openmp-nvptx64-nvidia-cuda.s"
  // CHK-CUBIN-DARWIN-NEXT: ptxas{{.*}}" "--output-file" 
"{{.*}}-openmp-nvptx64-nvidia-cuda.cubin" "{{.*}}-openmp-nvptx64-nvidia-cuda.s"
  // CHK-CUBIN-DARWIN-NEXT: nvlink" "-o" "{{.*}}-openmp-nvptx64-nvidia-cuda" 
{{.*}} "openmp-offload-openmp-nvptx64-nvidia-cuda.cubin"
  
  /// 
###
  
  /// Check cubin file generation and usage by nvlink
  // RUN:   touch %t1.o
  // RUN:   touch %t2.o
  // RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp 
-fopenmp-targets=nvptx64-nvidia-cuda %t1.o %t2.o 2>&1 \
  // RUN:   | FileCheck -check-prefix=CHK-TWOCUBIN %s
  
  // CHK-TWOCUBIN: nvlink"{{.*}}"openmp-offload-{{.*}}.cubin" 
"openmp-offload-{{.*}}.cubin"
  
  /// 
###
  
  /// Check cubin file generation and usage by nvlink when toolchain has 
BindArchAction
  // RUN:   touch %t1.o
  // RUN:   touch %t2.o
  // RUN:   %clang -### -no-canonical-prefixes -target 
x86_64-apple-darwin17.0.0 -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
%t1.o %t2.o 2>&1 \
  // RUN:   | FileCheck -check-prefix=CHK-TWOCUBIN-DARWIN %s
  
  // CHK-TWOCUBIN-DARWIN: nvlink"{{.*}}"openmp-offload-{{.*}}.cubin" 
"openmp-offload-{{.*}}.cubin"
  
  /// 
###
  
  /// Check PTXAS is passed -c flag when offloading to an NVIDIA device using 
OpenMP.
  // RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp 
-fopenmp-targets=nvptx64-nvidia-cuda %s 2>&1 \
  // RUN:   | FileCheck -check-prefix=CHK-PTXAS-DEFAULT %s
  
  // CHK-PTXAS-DEFAULT: ptxas{{.*}}" "-c"
  
  /// 
###
  
  /// PTXAS is passed -c flag by default when offloading to an NVIDIA device 
using OpenMP - disable it.
  // RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp 
-fopenmp-targets=nvptx64-nvidia-cuda -fnoopenmp-relocatable-target %s 2>&1 \
  // RUN:   | FileCheck -check-prefix=CHK-PTXAS-NORELO %s
  
  // CHK-PTXAS-NORELO-NOT: ptxas{{.*}}" "-c"
  
  /// 
###
  
  /// PTXAS is passed -c flag by default when offloading to an NVIDIA device 
using OpenMP
  /// Check that the flag is passed when -fopenmp-relocatable-target is used.
  // RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp 
-fopenmp-targets=nvptx64-nvidia-cuda -fopenmp-relocatable-target %s 2>&1 \
  // RUN:   | FileCheck -check-prefix=CHK-PTXAS-RELO %s
  
  // CHK-PTXAS-RELO: ptxas{{.*}}" "-c"
  
  /// 
###
  
  /// Check PTXAS is passed the compute capability passed to the driver.
  // RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp 
-fopenmp-targets=nvptx64-nvidia-cuda --fopenmp-ptx=+ptx52 %s 2>&1 \
  // RUN:   | FileCheck -check-prefix=CHK-PTXAS-VERSION %s
  
  // CHK-PTXAS-VERSION: clang{{.*}}.bc" {{.*}}"-target-feature" "+ptx52"
  
  /// 
###
  
  /// Check PTXAS is passed the compute capability passed to the driver.
  // RUN:   %clang -### -no-canonical-prefixes -target 
x86_64-apple-darwin17.0.0 -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
--fopenmp-ptx=+ptx52 %s 2>&1 \
  // RUN:   | FileCheck -check-prefix=CHK-PTXAS-DARWIN-VERSION %s
  
  // CHK-PTXAS-DARWIN-VERSION: clang{{.*}}.bc" {{.*}}"-target-feature" "+pt

[PATCH] D36529: Fixed a race condition in PrecompiledPreamble.

2017-08-10 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: lib/Frontend/PrecompiledPreamble.cpp:470-471
+  int FD;
+  auto EC = llvm::sys::fs::createTemporaryFile(Prefix, Suffix, /*ref*/ FD,
+   /*ref*/ File);
   if (EC)

klimek wrote:
> I don't understand that yet - why does keeping the file open around the EC 
> check change any of the behavior?
> Generally, both create the file, right? So only the first one should get no 
> error?
`createTemporaryFile` without `fd` does not create a file, only checks if the 
it exists, hence the race condition. Do you think a better solution would be to 
make it create an empty file and close it right away, similarly to what this 
function does now?

`createTemporaryFile` with `fd` does not have that problem, it actually tries 
to create a file until it succeeds.


https://reviews.llvm.org/D36529



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


[PATCH] D36550: [mips] Notify user that `-mabicalls` is ignored on non-PIC N64 ABI

2017-08-10 Thread Simon Dardis via Phabricator via cfe-commits
sdardis added a comment.

Slight tweak to the summary:

> The -mabicalls option does not have a sense in case of non position 
> independent code on N64 ABI. After this change driver starts to show a 
> warning that -mabicalls is ignored in that case.

The -mabicalls option does not make sense in the case of non position 
independent code for the N64 ABI. After this change the driver shows a warning 
that -mabicalls is ignored in that case.

I think the major change in this patch is overly complex for what it should be, 
suggestion inline.




Comment at: include/clang/Basic/DiagnosticDriverKinds.td:297
+  "ignoring '-mabicalls' option as it cannot be used with "
+  "non position-independent code and N64 ABI">,
+  InGroup;

and the N64 ABI



Comment at: lib/Driver/ToolChains/Arch/Mips.cpp:233-253
+  Arg *ABICallsArg =
+  Args.getLastArg(options::OPT_mabicalls, options::OPT_mno_abicalls);
+  if (!ABICallsArg)
+NeedNoAbiCalls = DefNoAbiCalls;
+  else {
+if (ABICallsArg->getOption().matches(options::OPT_mno_abicalls))
+  NeedNoAbiCalls = true;

I think this logic can be simplified to:

  bool UseAbiCalls = false; 
   
  
  Arg *ABICallsArg =
  Args.getLastArg(options::OPT_mabicalls, options::OPT_mno_abicalls);   
   
  UseAbiCalls =
  !ABICallsArg || 
  (ABICallsArg && 
ABICallsArg->getOption().matches(options::OPT_mabicalls));  
 
  
  if (UseAbiCalls && IsN64 && NonPIC) {
D.Diag(diag::warn_drv_unsupported_abicalls);
   
UseAbiCalls = false;
   
  } 
   
  
  if (!UseAbiCalls)
Features.push_back("+noabicalls");  
   
  else
Features.push_back("-noabicalls"); 

As that way we immediately pick up the implicit case or explicit case of using 
-mabicalls and we can simply pick out the N64 && NonPic && UseAbiCalls case to 
warn and fix.

Although we don't need to add "-noabicalls" to the Features vector, the backend 
defaults to that, though the tests expect it.


Repository:
  rL LLVM

https://reviews.llvm.org/D36550



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


[PATCH] D36354: [clang-tidy] Implement type-based check for `gsl::owner`

2017-08-10 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 110547.
JonasToth marked 10 inline comments as done.
JonasToth added a comment.

[Misc] address issues from aaron, especially refactor the big check function


https://reviews.llvm.org/D36354

Files:
  clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp
  clang-tidy/cppcoreguidelines/OwningMemoryCheck.h
  clang-tidy/utils/Matchers.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cppcoreguidelines-c-copy-assignment-signature.rst
  docs/clang-tidy/checks/cppcoreguidelines-owning-memory.rst
  docs/clang-tidy/checks/hicpp-explicit-conversions.rst
  docs/clang-tidy/checks/hicpp-function-size.rst
  docs/clang-tidy/checks/hicpp-invalid-access-moved.rst
  docs/clang-tidy/checks/hicpp-member-init.rst
  docs/clang-tidy/checks/hicpp-named-parameter.rst
  docs/clang-tidy/checks/hicpp-new-delete-operators.rst
  docs/clang-tidy/checks/hicpp-noexcept-move.rst
  docs/clang-tidy/checks/hicpp-special-member-functions.rst
  docs/clang-tidy/checks/hicpp-undelegated-constructor.rst
  docs/clang-tidy/checks/hicpp-use-equals-default.rst
  docs/clang-tidy/checks/hicpp-use-equals-delete.rst
  docs/clang-tidy/checks/hicpp-use-override.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cppcoreguidelines-owning-memory.cpp

Index: test/clang-tidy/cppcoreguidelines-owning-memory.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-owning-memory.cpp
@@ -0,0 +1,347 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-owning-memory %t
+
+namespace gsl {
+template 
+using owner = T;
+} // namespace gsl
+
+template 
+class unique_ptr {
+public:
+  unique_ptr(gsl::owner resource) : memory(resource) {}
+  unique_ptr(const unique_ptr &) = default;
+
+  ~unique_ptr() { delete memory; }
+
+private:
+  gsl::owner memory;
+};
+
+void takes_owner(gsl::owner owned_int) {
+}
+
+void takes_pointer(int *unowned_int) {
+}
+
+void takes_owner_and_more(int some_int, gsl::owner owned_int, float f) {
+}
+
+template 
+void takes_templated_owner(gsl::owner owned_T) {
+}
+
+gsl::owner returns_owner1() { return gsl::owner(new int(42)); } // Ok
+gsl::owner returns_owner2() { return new int(42); } // Ok
+
+int *returns_no_owner1() { return nullptr; }
+int *returns_no_owner2() {
+  return new int(42);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: returning an owner/resource from a function but not declaring it as one
+}
+int *returns_no_owner3() {
+  int *should_be_owner = new int(42);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: initializing non owner with a newly created owner/resource
+  return should_be_owner;
+}
+int *returns_no_owner4() {
+  gsl::owner owner = new int(42);
+  return owner;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: returning an owner/resource from a function but not declaring it as one
+}
+
+unique_ptr returns_no_owner5() {
+  return unique_ptr(new int(42)); // Ok
+}
+
+/// FIXME CSA finds it, but the report is misleading.
+void csa_not_finding_leak() {
+  gsl::owner o1 = new int(42); // Ok
+
+  gsl::owner o2 = o1; // Ok
+  o2 = new int(45); // conceptual leak, the memory from o1 is now leaked, since its considered moved in the guideLINEs
+
+  delete o2;
+  // actual leak occurs here, its found, but mixed
+  delete o1;
+}
+
+void test_assignment_and_initialization() {
+  int stack_int1 = 15;
+  int stack_int2;
+
+  gsl::owner owned_int1 = &stack_int1; // BAD
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: initializing neither with an owner nor a recognized resource
+
+  gsl::owner owned_int2;
+  owned_int2 = &stack_int2; // BAD since no owner, bad since uninitialized
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: assigning neither an owner nor a recognized resource
+
+  gsl::owner owned_int3 = new int(42); // Good
+  owned_int3 = nullptr; // Good
+
+  gsl::owner owned_int4(nullptr); // Ok
+  owned_int4 = new int(42); // Good
+
+  gsl::owner owned_int5 = owned_int3; // Good
+
+  gsl::owner owned_int6{nullptr}; // Ok
+  owned_int6 = owned_int4; // Good
+
+  // FIXME, flow analysis for the case of reassignment. Value must be released before
+  owned_int6 = owned_int3; // BAD, because reassignment without resource release
+
+  auto owned_int7 = returns_owner1(); // Bad, since typededuction eliminates the owner wrapper
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: initializing non owner with a newly created owner/resource
+  // CHECK-MESSAGES: [[@LINE-2]]:3: note: type deduction did not result in an owner
+
+  const auto owned_int8 = returns_owner2(); // Bad, since typededuction eliminates the owner wrapper
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: initializing non owner with a newly created owner/resource
+  // CHECK-MESSAGES: [[@LINE-2]]:3: note: type deduction did not result in an owner
+
+  gsl::owner owned_int9 = returns_owner1(); // Ok
+  int *unowned_int3 = returns_owner1(); // Bad
+  // CHECK-MESSAGES: [[@LINE-1]]

[PATCH] D36354: [clang-tidy] Implement type-based check for `gsl::owner`

2017-08-10 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 110548.
JonasToth added a comment.

[Fix] typo


https://reviews.llvm.org/D36354

Files:
  clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp
  clang-tidy/cppcoreguidelines/OwningMemoryCheck.h
  clang-tidy/utils/Matchers.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cppcoreguidelines-c-copy-assignment-signature.rst
  docs/clang-tidy/checks/cppcoreguidelines-owning-memory.rst
  docs/clang-tidy/checks/hicpp-explicit-conversions.rst
  docs/clang-tidy/checks/hicpp-function-size.rst
  docs/clang-tidy/checks/hicpp-invalid-access-moved.rst
  docs/clang-tidy/checks/hicpp-member-init.rst
  docs/clang-tidy/checks/hicpp-named-parameter.rst
  docs/clang-tidy/checks/hicpp-new-delete-operators.rst
  docs/clang-tidy/checks/hicpp-noexcept-move.rst
  docs/clang-tidy/checks/hicpp-special-member-functions.rst
  docs/clang-tidy/checks/hicpp-undelegated-constructor.rst
  docs/clang-tidy/checks/hicpp-use-equals-default.rst
  docs/clang-tidy/checks/hicpp-use-equals-delete.rst
  docs/clang-tidy/checks/hicpp-use-override.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cppcoreguidelines-owning-memory.cpp

Index: test/clang-tidy/cppcoreguidelines-owning-memory.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-owning-memory.cpp
@@ -0,0 +1,347 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-owning-memory %t
+
+namespace gsl {
+template 
+using owner = T;
+} // namespace gsl
+
+template 
+class unique_ptr {
+public:
+  unique_ptr(gsl::owner resource) : memory(resource) {}
+  unique_ptr(const unique_ptr &) = default;
+
+  ~unique_ptr() { delete memory; }
+
+private:
+  gsl::owner memory;
+};
+
+void takes_owner(gsl::owner owned_int) {
+}
+
+void takes_pointer(int *unowned_int) {
+}
+
+void takes_owner_and_more(int some_int, gsl::owner owned_int, float f) {
+}
+
+template 
+void takes_templated_owner(gsl::owner owned_T) {
+}
+
+gsl::owner returns_owner1() { return gsl::owner(new int(42)); } // Ok
+gsl::owner returns_owner2() { return new int(42); } // Ok
+
+int *returns_no_owner1() { return nullptr; }
+int *returns_no_owner2() {
+  return new int(42);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: returning an owner/resource from a function but not declaring it as one
+}
+int *returns_no_owner3() {
+  int *should_be_owner = new int(42);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: initializing non owner with a newly created owner/resource
+  return should_be_owner;
+}
+int *returns_no_owner4() {
+  gsl::owner owner = new int(42);
+  return owner;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: returning an owner/resource from a function but not declaring it as one
+}
+
+unique_ptr returns_no_owner5() {
+  return unique_ptr(new int(42)); // Ok
+}
+
+/// FIXME CSA finds it, but the report is misleading.
+void csa_not_finding_leak() {
+  gsl::owner o1 = new int(42); // Ok
+
+  gsl::owner o2 = o1; // Ok
+  o2 = new int(45); // conceptual leak, the memory from o1 is now leaked, since its considered moved in the guideLINEs
+
+  delete o2;
+  // actual leak occurs here, its found, but mixed
+  delete o1;
+}
+
+void test_assignment_and_initialization() {
+  int stack_int1 = 15;
+  int stack_int2;
+
+  gsl::owner owned_int1 = &stack_int1; // BAD
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: initializing neither with an owner nor a recognized resource
+
+  gsl::owner owned_int2;
+  owned_int2 = &stack_int2; // BAD since no owner, bad since uninitialized
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: assigning neither an owner nor a recognized resource
+
+  gsl::owner owned_int3 = new int(42); // Good
+  owned_int3 = nullptr; // Good
+
+  gsl::owner owned_int4(nullptr); // Ok
+  owned_int4 = new int(42); // Good
+
+  gsl::owner owned_int5 = owned_int3; // Good
+
+  gsl::owner owned_int6{nullptr}; // Ok
+  owned_int6 = owned_int4; // Good
+
+  // FIXME, flow analysis for the case of reassignment. Value must be released before
+  owned_int6 = owned_int3; // BAD, because reassignment without resource release
+
+  auto owned_int7 = returns_owner1(); // Bad, since typededuction eliminates the owner wrapper
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: initializing non owner with a newly created owner/resource
+  // CHECK-MESSAGES: [[@LINE-2]]:3: note: type deduction did not result in an owner
+
+  const auto owned_int8 = returns_owner2(); // Bad, since typededuction eliminates the owner wrapper
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: initializing non owner with a newly created owner/resource
+  // CHECK-MESSAGES: [[@LINE-2]]:3: note: type deduction did not result in an owner
+
+  gsl::owner owned_int9 = returns_owner1(); // Ok
+  int *unowned_int3 = returns_owner1(); // Bad
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: initializing non owner with a newly created owner/resource
+
+  gsl::owner owned_int10;
+  owned_i

[PATCH] D36179: [clang-diff] Move printing of matches and changes to clang-diff

2017-08-10 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes updated this revision to Diff 110552.
johannes added a comment.

add test for 'Move' and 'Update and Move' in output


https://reviews.llvm.org/D36179

Files:
  include/clang/Tooling/ASTDiff/ASTDiff.h
  include/clang/Tooling/ASTDiff/ASTDiffInternal.h
  lib/Tooling/ASTDiff/ASTDiff.cpp
  test/Tooling/clang-diff-basic.cpp
  tools/clang-diff/ClangDiff.cpp

Index: tools/clang-diff/ClangDiff.cpp
===
--- tools/clang-diff/ClangDiff.cpp
+++ tools/clang-diff/ClangDiff.cpp
@@ -129,7 +129,7 @@
   auto Offsets = Tree.getSourceRangeOffsets(N);
   OS << R"(,"begin":)" << Offsets.first;
   OS << R"(,"end":)" << Offsets.second;
-  std::string Value = Tree.getNodeValue(N.ASTNode);
+  std::string Value = Tree.getNodeValue(N);
   if (!Value.empty()) {
 OS << R"(,"value":")";
 printJsonString(OS, Value);
@@ -153,6 +153,52 @@
   OS << "]}";
 }
 
+static void printNode(raw_ostream &OS, diff::SyntaxTree &Tree,
+  diff::NodeId Id) {
+  if (Id.isInvalid()) {
+OS << "None";
+return;
+  }
+  OS << Tree.getNode(Id).getTypeLabel();
+  std::string Value = Tree.getNodeValue(Id);
+  if (!Value.empty())
+OS << ": " << Value;
+  OS << "(" << Id << ")";
+}
+
+static void printDstChange(raw_ostream &OS, diff::ASTDiff &Diff,
+   diff::SyntaxTree &SrcTree, diff::SyntaxTree &DstTree,
+   diff::NodeId Dst) {
+  const diff::Node &DstNode = DstTree.getNode(Dst);
+  diff::NodeId Src = Diff.getMapped(DstTree, Dst);
+  switch (DstNode.ChangeKind) {
+  case diff::None:
+break;
+  case diff::Delete:
+llvm_unreachable("The destination tree can't have deletions.");
+  case diff::Update:
+OS << "Update ";
+printNode(OS, SrcTree, Src);
+OS << " to " << DstTree.getNodeValue(Dst) << "\n";
+break;
+  case diff::Insert:
+  case diff::Move:
+  case diff::UpdateMove:
+if (DstNode.ChangeKind == diff::Insert)
+  OS << "Insert";
+else if (DstNode.ChangeKind == diff::Move)
+  OS << "Move";
+else if (DstNode.ChangeKind == diff::UpdateMove)
+  OS << "Update and Move";
+OS << " ";
+printNode(OS, DstTree, Dst);
+OS << " into ";
+printNode(OS, DstTree, DstNode.Parent);
+OS << " at " << DstTree.findPositionInParent(Dst) << "\n";
+break;
+  }
+}
+
 int main(int argc, const char **argv) {
   std::string ErrorMessage;
   std::unique_ptr CommonCompilations =
@@ -199,11 +245,26 @@
 Options.MaxSize = MaxSize;
   diff::SyntaxTree SrcTree(Src->getASTContext());
   diff::SyntaxTree DstTree(Dst->getASTContext());
-  diff::ASTDiff DiffTool(SrcTree, DstTree, Options);
-  for (const auto &Match : DiffTool.getMatches())
-DiffTool.printMatch(llvm::outs(), Match);
-  for (const auto &Change : DiffTool.getChanges())
-DiffTool.printChange(llvm::outs(), Change);
+  diff::ASTDiff Diff(SrcTree, DstTree, Options);
+
+  for (diff::NodeId Dst : DstTree) {
+diff::NodeId Src = Diff.getMapped(DstTree, Dst);
+if (Src.isValid()) {
+  llvm::outs() << "Match ";
+  printNode(llvm::outs(), SrcTree, Src);
+  llvm::outs() << " to ";
+  printNode(llvm::outs(), DstTree, Dst);
+  llvm::outs() << "\n";
+}
+printDstChange(llvm::outs(), Diff, SrcTree, DstTree, Dst);
+  }
+  for (diff::NodeId Src : SrcTree) {
+if (Diff.getMapped(SrcTree, Src).isInvalid()) {
+  llvm::outs() << "Delete ";
+  printNode(llvm::outs(), SrcTree, Src);
+  llvm::outs() << "\n";
+}
+  }
 
   return 0;
 }
Index: test/Tooling/clang-diff-basic.cpp
===
--- test/Tooling/clang-diff-basic.cpp
+++ test/Tooling/clang-diff-basic.cpp
@@ -31,6 +31,10 @@
   int id(int i) { return i; }
 };
 }
+
+void m() { int x = 0 + 0 + 0; }
+int um = 1 + 2 + 3;
+
 #else
 // CHECK: Match TranslationUnitDecl{{.*}} to TranslationUnitDecl
 // CHECK: Match NamespaceDecl: src{{.*}} to NamespaceDecl: dst
@@ -54,8 +58,8 @@
 typedef unsigned nat;
 
 // CHECK: Match VarDecl: p(int){{.*}} to VarDecl: prod(double)
-// CHECK: Match BinaryOperator: *{{.*}} to BinaryOperator: *
 // CHECK: Update VarDecl: p(int){{.*}} to prod(double)
+// CHECK: Match BinaryOperator: *{{.*}} to BinaryOperator: *
 double prod = 1 * 2 * 10;
 // CHECK: Update DeclRefExpr
 int squared = prod * prod;
@@ -70,9 +74,15 @@
   return "foo";
 return 0;
   }
-  // CHECK: Delete AccessSpecDecl: public
-  X(){};
-  // CHECK: Delete CXXMethodDecl
+  X(){}
 };
 }
+
+// CHECK: Move DeclStmt{{.*}} into CompoundStmt
+void m() { { int x = 0 + 0 + 0; } }
+// CHECK: Update and Move IntegerLiteral: 7{{.*}} into BinaryOperator: +({{.*}}) at 1
+int um = 1 + 7;
 #endif
+
+// CHECK: Delete AccessSpecDecl: public
+// CHECK: Delete CXXMethodDecl
Index: lib/Tooling/ASTDiff/ASTDiff.cpp
===
--- lib/Tooling/ASTDiff/ASTDiff.cpp
+++ lib/Tooling/ASTDiff/ASTDiff.cpp
@@ -82,26 +82,23 @@
 class ASTDiff::Impl {

[PATCH] D36182: [clang-diff] Add HTML side-by-side diff output

2017-08-10 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes updated this revision to Diff 110553.
johannes edited the summary of this revision.
johannes added a comment.

change tests


https://reviews.llvm.org/D36182

Files:
  test/Tooling/Inputs/clang-diff-basic-src.cpp
  test/Tooling/clang-diff-basic.cpp
  test/Tooling/clang-diff-html.test
  tools/clang-diff/CMakeLists.txt
  tools/clang-diff/ClangDiff.cpp

Index: tools/clang-diff/ClangDiff.cpp
===
--- tools/clang-diff/ClangDiff.cpp
+++ tools/clang-diff/ClangDiff.cpp
@@ -37,6 +37,10 @@
 PrintMatches("dump-matches", cl::desc("Print the matched nodes."),
  cl::init(false), cl::cat(ClangDiffCategory));
 
+static cl::opt HtmlDiff("html",
+  cl::desc("Output a side-by-side diff in HTML."),
+  cl::init(false), cl::cat(ClangDiffCategory));
+
 static cl::opt SourcePath(cl::Positional, cl::desc(""),
cl::Required,
cl::cat(ClangDiffCategory));
@@ -105,6 +109,161 @@
 
 static char hexdigit(int N) { return N &= 0xf, N + (N < 10 ? '0' : 'a' - 10); }
 
+static const char HtmlDiffHeader[] = R"(
+
+
+
+
+span.d { color: red; }
+span.u { color: #cc00cc; }
+span.i { color: green; }
+span.m { font-weight: bold; }
+span   { font-weight: normal; color: black; }
+div.code {
+  width: 48%;
+  height: 98%;
+  overflow: scroll;
+  float: left;
+  padding: 0 0 0.5% 0.5%;
+  border: solid 2px LightGrey;
+  border-radius: 5px;
+}
+
+
+
+highlightStack = []
+function clearHighlight() {
+  while (highlightStack.length) {
+let [l, r] = highlightStack.pop()
+document.getElementById(l).style.backgroundColor = 'white'
+document.getElementById(r).style.backgroundColor = 'white'
+  }
+}
+function highlight(event) {
+  id = event.target['id']
+  doHighlight(id)
+}
+function doHighlight(id) {
+  clearHighlight()
+  source = document.getElementById(id)
+  if (!source.attributes['tid'])
+return
+  tid = source.attributes['tid'].value
+  target = document.getElementById(tid)
+  if (!target || source.parentElement && source.parentElement.classList.contains('code'))
+return
+  source.style.backgroundColor = target.style.backgroundColor = 'lightgrey'
+  highlightStack.push([id, tid])
+  source.scrollIntoView()
+  target.scrollIntoView()
+  location.hash = '#' + id
+}
+function scrollToBoth() {
+  doHighlight(location.hash.substr(1))
+}
+window.onload = scrollToBoth
+
+
+
+)";
+
+static void printHtml(raw_ostream &OS, char C) {
+  switch (C) {
+  case '&':
+OS << "&";
+break;
+  case '<':
+OS << "<";
+break;
+  case '>':
+OS << ">";
+break;
+  case '\'':
+OS << "'";
+break;
+  case '"':
+OS << """;
+break;
+  default:
+OS << C;
+  }
+}
+
+static void printHtml(raw_ostream &OS, const StringRef Str) {
+  for (char C : Str)
+printHtml(OS, C);
+}
+
+static std::string getChangeKindAbbr(diff::ChangeKind Kind) {
+  switch (Kind) {
+  case diff::None:
+return "";
+  case diff::Delete:
+return "d";
+  case diff::Update:
+return "u";
+  case diff::Insert:
+return "i";
+  case diff::Move:
+return "m";
+  case diff::UpdateMove:
+return "u m";
+  }
+}
+
+static unsigned printHtmlForNode(raw_ostream &OS, const diff::ASTDiff &Diff,
+ diff::SyntaxTree &Tree, bool IsLeft,
+ diff::NodeId Id, unsigned Offset) {
+  const diff::Node &Node = Tree.getNode(Id);
+  char MyTag, OtherTag;
+  diff::NodeId LeftId, RightId;
+  diff::NodeId TargetId = Diff.getMapped(Tree, Id);
+  if (IsLeft) {
+MyTag = 'L';
+OtherTag = 'R';
+LeftId = Id;
+RightId = TargetId;
+  } else {
+MyTag = 'R';
+OtherTag = 'L';
+LeftId = TargetId;
+RightId = Id;
+  }
+  unsigned Begin, End;
+  std::tie(Begin, End) = Tree.getSourceRangeOffsets(Node);
+  const SourceManager &SrcMgr = Tree.getASTContext().getSourceManager();
+  auto Code = SrcMgr.getBuffer(SrcMgr.getMainFileID())->getBuffer();
+  for (; Offset < Begin; ++Offset)
+printHtml(OS, Code[Offset]);
+  OS << "";
+
+  for (diff::NodeId Child : Node.Children)
+Offset = printHtmlForNode(OS, Diff, Tree, IsLeft, Child, Offset);
+
+  for (; Offset < End; ++Offset)
+printHtml(OS, Code[Offset]);
+  if (Id == Tree.getRootId()) {
+End = Code.size();
+for (; Offset < End; ++Offset)
+  printHtml(OS, Code[Offset]);
+  }
+  OS << "";
+  return Offset;
+}
+
 static void printJsonString(raw_ostream &OS, const StringRef Str) {
   for (char C : Str) {
 switch (C) {
@@ -269,6 +428,19 @@
   diff::SyntaxTree DstTree(Dst->getASTContext());
   diff::ASTDiff Diff(SrcTree, DstTree, Options);
 
+  if (HtmlDiff) {
+llvm::outs() << HtmlDiffHeader << "";
+llvm::outs() << "";
+printHtmlForNode(llvm::outs(), Diff, SrcTree, true, SrcTree.getRootId(), 0);
+llvm::outs() << "";
+llvm::outs() << "";
+printHtmlForNode(llvm::outs(), Dif

[PATCH] D36572: Implemented P0409R2 - Allow lambda capture [=, this]

2017-08-10 Thread Hamza Sood via Phabricator via cfe-commits
hamzasood created this revision.

This patch implements P0409R2 .

'*this' capture is allowed pre-C++17 as an extension. So I've also allowed [=, 
this] pre-C++2a as an extension (with appropriate warnings) for consistency.


https://reviews.llvm.org/D36572

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaLambda.cpp
  test/CXX/expr/expr.prim/expr.prim.lambda/p8.cpp
  test/FixIt/fixit-cxx0x.cpp
  test/SemaCXX/cxx2a-lambda-equals-this.cpp
  www/cxx_status.html

Index: www/cxx_status.html
===
--- www/cxx_status.html
+++ www/cxx_status.html
@@ -777,13 +777,12 @@
 
 C++2a implementation status
 
-Clang does not yet support any of the proposed features of
-
+Clang has experimental support for some proposed features of
 the C++ standard following C++17, provisionally named C++2a.
 Note that support for these features may change or be removed without notice,
 as the draft C++2a standard evolves.
 
-
+You can use Clang in C++2a mode with the -std=c++2a option.
 
 
 List of features and minimum Clang version with support
@@ -808,7 +807,7 @@
 
   Allow lambda-capture [=, this]
   http://wg21.link/p0409r2";>P0409R2
-  No
+  SVN
 
 
   __VA_OPT__ for preprocessor comma elision
Index: test/SemaCXX/cxx2a-lambda-equals-this.cpp
===
--- test/SemaCXX/cxx2a-lambda-equals-this.cpp
+++ test/SemaCXX/cxx2a-lambda-equals-this.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -std=c++2a -verify %s
+// expected-no-diagnostics
+
+// This test does two things.
+// Deleting the copy constructor ensures that an [=, this] capture doesn't copy the object.
+// Accessing a member variable from the lambda ensures that the capture actually works.
+class A {
+  A(const A &) = delete;
+  int i;
+
+  void func() {
+auto L = [=, this]() -> int { return i; };
+L();
+  }
+};
Index: test/FixIt/fixit-cxx0x.cpp
===
--- test/FixIt/fixit-cxx0x.cpp
+++ test/FixIt/fixit-cxx0x.cpp
@@ -54,7 +54,6 @@
 
 void S2::f(int i) {
   (void)[&, &i, &i]{}; // expected-error 2{{'&' cannot precede a capture when the capture default is '&'}}
-  (void)[=, this]{ this->g(5); }; // expected-error{{'this' cannot be explicitly captured}}
   (void)[i, i]{ }; // expected-error{{'i' can appear only once in a capture list}}
   (void)[&, i, i]{ }; // expected-error{{'i' can appear only once in a capture list}}
   (void)[] mutable { }; // expected-error{{lambda requires '()' before 'mutable'}}
Index: test/CXX/expr/expr.prim/expr.prim.lambda/p8.cpp
===
--- test/CXX/expr/expr.prim/expr.prim.lambda/p8.cpp
+++ test/CXX/expr/expr.prim/expr.prim.lambda/p8.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++11 %s -verify -Wno-c++1y-extensions
+// RUN: %clang_cc1 -std=c++11 %s -verify -Wno-c++1y-extensions -Wno-c++2a-extensions
 
 class X0 {
   void explicit_capture() {
@@ -8,7 +8,7 @@
 (void)[this, this] () {}; // expected-error {{'this' can appear only once}}
 (void)[=, foo] () {}; // expected-error {{'&' must precede a capture when}}
 (void)[=, &foo] () {};
-(void)[=, this] () {}; // expected-error {{'this' cannot be explicitly captured}}
+(void)[=, this] () {};
 (void)[&, foo] () {};
 (void)[&, &foo] () {}; // expected-error {{'&' cannot precede a capture when}} 
 (void)[&, this] () {};
@@ -23,7 +23,7 @@
 void S2::f(int i) {
   (void)[&, i]{ };
   (void)[&, &i]{ }; // expected-error{{'&' cannot precede a capture when the capture default is '&'}}
-  (void)[=, this]{ }; // expected-error{{'this' cannot be explicitly captured}}
+  (void)[=, this]{ };
   (void)[=]{ this->g(i); };
   (void)[i, i]{ }; // expected-error{{'i' can appear only once in a capture list}}
   (void)[i(0), i(1)]{ }; // expected-error{{'i' can appear only once in a capture list}}
Index: lib/Sema/SemaLambda.cpp
===
--- lib/Sema/SemaLambda.cpp
+++ lib/Sema/SemaLambda.cpp
@@ -948,17 +948,15 @@
 continue;
   }
 
-  // C++1z [expr.prim.lambda]p8:
-  //  If a lambda-capture includes a capture-default that is =, each
-  //  simple-capture of that lambda-capture shall be of the form "&
-  //  identifier" or "* this". [ Note: The form [&,this] is redundant but
-  //  accepted for compatibility with ISO C++14. --end note ]
-  if (Intro.Default == LCD_ByCopy && C->Kind != LCK_StarThis) {
-Diag(C->Loc, diag::err_this_capture_with_copy_default)
-<< FixItHint::CreateRemoval(
-SourceRange(getLocForEndOfToken(PrevCaptureLoc), C->Loc));
-continue;
-  }
+  // C++2a [expr.prim.lambda]p8:
+  //  If a lambda-capture includes a capture-default that is =,
+  //  each simple-capture of that

[PATCH] D36183: [clang-diff] Simplify mapping

2017-08-10 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes updated this revision to Diff 110554.
johannes added a comment.

remove unused


https://reviews.llvm.org/D36183

Files:
  include/clang/Tooling/ASTDiff/ASTDiff.h
  lib/Tooling/ASTDiff/ASTDiff.cpp
  test/Tooling/Inputs/clang-diff-basic-src.cpp
  test/Tooling/clang-diff-basic.cpp

Index: test/Tooling/clang-diff-basic.cpp
===
--- test/Tooling/clang-diff-basic.cpp
+++ test/Tooling/clang-diff-basic.cpp
@@ -42,10 +42,16 @@
 };
 }
 
-// CHECK: Move DeclStmt{{.*}} into CompoundStmt
+// CHECK: Move CompoundStmt{{.*}} into CompoundStmt
 void m() { { int x = 0 + 0 + 0; } }
 // CHECK: Update and Move IntegerLiteral: 7{{.*}} into BinaryOperator: +({{.*}}) at 1
 int um = 1 + 7;
 
+namespace {
+// match with parents of different type
+// CHECK: Match FunctionDecl: f1{{.*}} to FunctionDecl: f1
+void f1() {{ (void) __func__;;; }}
+}
+
 // CHECK: Delete AccessSpecDecl: public
 // CHECK: Delete CXXMethodDecl
Index: test/Tooling/Inputs/clang-diff-basic-src.cpp
===
--- test/Tooling/Inputs/clang-diff-basic-src.cpp
+++ test/Tooling/Inputs/clang-diff-basic-src.cpp
@@ -28,4 +28,6 @@
 }
 
 void m() { int x = 0 + 0 + 0; }
-int um = 1 + 2 + 3;
+int um = 1 * 2 + 3;
+
+void f1() {{ (void) __func__;;; }}
Index: lib/Tooling/ASTDiff/ASTDiff.cpp
===
--- lib/Tooling/ASTDiff/ASTDiff.cpp
+++ lib/Tooling/ASTDiff/ASTDiff.cpp
@@ -34,48 +34,23 @@
   Mapping() = default;
   Mapping(Mapping &&Other) = default;
   Mapping &operator=(Mapping &&Other) = default;
-  Mapping(int Size1, int Size2) {
-// Maximum possible size after patching one tree.
-int Size = Size1 + Size2;
-SrcToDst = llvm::make_unique[]>(Size);
-DstToSrc = llvm::make_unique[]>(Size);
+
+  Mapping(size_t Size) {
+SrcToDst = llvm::make_unique(Size);
+DstToSrc = llvm::make_unique(Size);
   }
 
   void link(NodeId Src, NodeId Dst) {
-SrcToDst[Src].push_back(Dst);
-DstToSrc[Dst].push_back(Src);
-  }
-
-  NodeId getDst(NodeId Src) const {
-if (hasSrc(Src))
-  return SrcToDst[Src][0];
-return NodeId();
-  }
-  NodeId getSrc(NodeId Dst) const {
-if (hasDst(Dst))
-  return DstToSrc[Dst][0];
-return NodeId();
-  }
-  const SmallVector &getAllDsts(NodeId Src) const {
-return SrcToDst[Src];
-  }
-  const SmallVector &getAllSrcs(NodeId Dst) const {
-return DstToSrc[Dst];
-  }
-  bool hasSrc(NodeId Src) const { return !SrcToDst[Src].empty(); }
-  bool hasDst(NodeId Dst) const { return !DstToSrc[Dst].empty(); }
-  bool hasSrcDst(NodeId Src, NodeId Dst) const {
-for (NodeId DstId : SrcToDst[Src])
-  if (DstId == Dst)
-return true;
-for (NodeId SrcId : DstToSrc[Dst])
-  if (SrcId == Src)
-return true;
-return false;
+SrcToDst[Src] = Dst, DstToSrc[Dst] = Src;
   }
 
+  NodeId getDst(NodeId Src) const { return SrcToDst[Src]; }
+  NodeId getSrc(NodeId Dst) const { return DstToSrc[Dst]; }
+  bool hasSrc(NodeId Src) const { return getDst(Src).isValid(); }
+  bool hasDst(NodeId Dst) const { return getSrc(Dst).isValid(); }
+
 private:
-  std::unique_ptr[]> SrcToDst, DstToSrc;
+  std::unique_ptr SrcToDst, DstToSrc;
 };
 } // end anonymous namespace
 
@@ -104,8 +79,6 @@
   // Returns true if the two subtrees are identical.
   bool identical(NodeId Id1, NodeId Id2) const;
 
-  bool canBeAddedToMapping(const Mapping &M, NodeId Id1, NodeId Id2) const;
-
   // Returns false if the nodes must not be mached.
   bool isMatchingPossible(NodeId Id1, NodeId Id2) const;
 
@@ -711,23 +684,6 @@
   return true;
 }
 
-bool ASTDiff::Impl::canBeAddedToMapping(const Mapping &M, NodeId Id1,
-NodeId Id2) const {
-  assert(isMatchingPossible(Id1, Id2) &&
- "Matching must be possible in the first place.");
-  if (M.hasSrcDst(Id1, Id2))
-return false;
-  if (Options.EnableMatchingWithUnmatchableParents)
-return true;
-  const Node &N1 = T1.getNode(Id1);
-  const Node &N2 = T2.getNode(Id2);
-  NodeId P1 = N1.Parent;
-  NodeId P2 = N2.Parent;
-  // Only allow matching if parents can be matched.
-  return (P1.isInvalid() && P2.isInvalid()) ||
- (P1.isValid() && P2.isValid() && isMatchingPossible(P1, P2));
-}
-
 bool ASTDiff::Impl::isMatchingPossible(NodeId Id1, NodeId Id2) const {
   return Options.isMatchingAllowed(T1.getNode(Id1), T2.getNode(Id2));
 }
@@ -750,7 +706,7 @@
   for (const auto Tuple : R) {
 NodeId Src = Tuple.first;
 NodeId Dst = Tuple.second;
-if (canBeAddedToMapping(M, Src, Dst))
+if (!M.hasSrc(Src) && !M.hasDst(Dst))
   M.link(Src, Dst);
   }
 }
@@ -803,7 +759,7 @@
 if (Matched || !MatchedChildren)
   continue;
 NodeId Id2 = findCandidate(M, Id1);
-if (Id2.isValid() && canBeAddedToMapping(M, Id1, Id2)) {
+if (Id2.isValid()) {
   M.link(Id1, Id2);
   addOptimalMapping(M, Id1, Id2);
 }
@@ -814,7 +770,7 @@

[PATCH] D36184: [clang-diff] Filter AST nodes

2017-08-10 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes updated this revision to Diff 110555.
johannes added a comment.

refactor isNodeExcluded


https://reviews.llvm.org/D36184

Files:
  lib/Tooling/ASTDiff/ASTDiff.cpp
  test/Tooling/clang-diff-ast.cpp
  test/Tooling/clang-diff-json.cpp

Index: test/Tooling/clang-diff-json.cpp
===
--- test/Tooling/clang-diff-json.cpp
+++ test/Tooling/clang-diff-json.cpp
@@ -3,9 +3,9 @@
 // RUN: | FileCheck %s
 
 // CHECK: "begin": 299,
-// CHECK: "type": "CXXRecordDecl",
 // CHECK: "type": "FieldDecl",
 // CHECK: "end": 319,
+// CHECK: "type": "CXXRecordDecl",
 class A {
   int x;
 };
Index: test/Tooling/clang-diff-ast.cpp
===
--- test/Tooling/clang-diff-ast.cpp
+++ test/Tooling/clang-diff-ast.cpp
@@ -12,7 +12,8 @@
   // CHECK: IntegerLiteral: 1
   auto i = 1;
   // CHECK: CallExpr(
-  // CHECK: DeclRefExpr: f(
+  // CHECK-NOT: ImplicitCastExpr
+  // CHECK-NEXT: DeclRefExpr: f(
   f();
   // CHECK: BinaryOperator: =(
   i = i;
@@ -37,6 +38,7 @@
 if (i == 0)
   // CHECK: StringLiteral: foo(
   return "foo";
+// CHECK-NOT: ImplicitCastExpr
 return 0;
   }
 
@@ -48,3 +50,22 @@
 int x = m;
   }
 };
+
+#define M (void)1
+#define MA(a, b) (void)a, b
+// CHECK: FunctionDecl
+// CHECK-NEXT: CompoundStmt
+void macros() {
+  M;
+  MA(1, 2);
+}
+// CHECK-NEXT: NamespaceDecl
+
+#ifndef GUARD
+#define GUARD
+namespace world {
+// nodes from other files are excluded
+// CHECK-NOT {{.}}
+#include "clang-diff-ast.cpp"
+}
+#endif
Index: lib/Tooling/ASTDiff/ASTDiff.cpp
===
--- lib/Tooling/ASTDiff/ASTDiff.cpp
+++ lib/Tooling/ASTDiff/ASTDiff.cpp
@@ -68,7 +68,8 @@
   // Compute ChangeKind for each node based on similarity.
   void computeChangeKinds(Mapping &M);
 
-  NodeId getMapped(const std::unique_ptr &Tree, NodeId Id) const {
+  NodeId getMapped(const std::unique_ptr &Tree,
+   NodeId Id) const {
 if (&*Tree == &T1)
   return TheMapping.getDst(Id);
 assert(&*Tree == &T2 && "Invalid tree.");
@@ -157,12 +158,23 @@
   void setLeftMostDescendants();
 };
 
+static bool isSpecializedNodeExcluded(const Decl *D) { return D->isImplicit(); }
+static bool isSpecializedNodeExcluded(const Stmt *S) { return false; }
+
 template 
 static bool isNodeExcluded(const SourceManager &SrcMgr, T *N) {
   if (!N)
 return true;
   SourceLocation SLoc = N->getLocStart();
-  return SLoc.isValid() && SrcMgr.isInSystemHeader(SLoc);
+  if (SLoc.isValid()) {
+// Ignore everything from other files.
+if (!SrcMgr.isInMainFile(SLoc))
+  return true;
+// Ignore macros.
+if (SLoc != SrcMgr.getSpellingLoc(SLoc))
+  return true;
+  }
+  return isSpecializedNodeExcluded(N);
 }
 
 namespace {
@@ -179,6 +191,8 @@
 return true;
   }
   bool TraverseStmt(Stmt *S) {
+if (S)
+  S = S->IgnoreImplicit();
 if (isNodeExcluded(Tree.AST.getSourceManager(), S))
   return true;
 ++Count;
@@ -241,6 +255,8 @@
 return true;
   }
   bool TraverseStmt(Stmt *S) {
+if (S)
+  S = S->IgnoreImplicit();
 if (isNodeExcluded(Tree.AST.getSourceManager(), S))
   return true;
 auto SavedState = PreTraverse(S);
@@ -900,7 +916,8 @@
   return TreeImpl->findPositionInParent(Id);
 }
 
-std::pair SyntaxTree::getSourceRangeOffsets(const Node &N) const {
+std::pair
+SyntaxTree::getSourceRangeOffsets(const Node &N) const {
   const SourceManager &SrcMgr = TreeImpl->AST.getSourceManager();
   SourceRange Range = N.ASTNode.getSourceRange();
   SourceLocation BeginLoc = Range.getBegin();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r310582 - [ValueTracking] Enabling ValueTracking patch by default (recommit). Part 1.

2017-08-10 Thread Nikolai Bozhenov via cfe-commits
Author: n.bozhenov
Date: Thu Aug 10 04:22:52 2017
New Revision: 310582

URL: http://llvm.org/viewvc/llvm-project?rev=310582&view=rev
Log:
[ValueTracking] Enabling ValueTracking patch by default (recommit). Part 1.
 
The original patch was an improvement to IR ValueTracking on non-negative
integers. It has been checked in to trunk (D18777, r284022). But was disabled by
default due to performance regressions.
Perf impact has improved. The patch would be enabled by default.
 
Reviewers: reames, hfinkel
 
Differential Revision: https://reviews.llvm.org/D34101
 
Patch by: Olga Chupina 


Modified:
cfe/trunk/test/Frontend/optimization-remark-options.c

Modified: cfe/trunk/test/Frontend/optimization-remark-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/optimization-remark-options.c?rev=310582&r1=310581&r2=310582&view=diff
==
--- cfe/trunk/test/Frontend/optimization-remark-options.c (original)
+++ cfe/trunk/test/Frontend/optimization-remark-options.c Thu Aug 10 04:22:52 
2017
@@ -14,7 +14,7 @@ double foo(int N) {
 // CHECK: {{.*}}:17:3: remark: loop not vectorized: cannot prove it is safe to 
reorder memory operations; allow reordering by specifying '#pragma clang loop 
vectorize(enable)' before the loop. If the arrays will always be independent 
specify '#pragma clang loop vectorize(assume_safety)' before the loop or 
provide the '__restrict__' qualifier with the independent array arguments. 
Erroneous results will occur if these options are incorrectly applied!
 
 void foo2(int *dw, int *uw, int *A, int *B, int *C, int *D, int N) {
-  for (int i = 0; i < N; i++) {
+  for (long i = 0; i < N; i++) {
 dw[i] = A[i] + B[i - 1] + C[i - 2] + D[i - 3];
 uw[i] = A[i] + B[i + 1] + C[i + 2] + D[i + 3];
   }


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


[PATCH] D36187: [clang-diff] Use the relative name for NamedDecls

2017-08-10 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes updated this revision to Diff 110557.
johannes added a comment.

substr


https://reviews.llvm.org/D36187

Files:
  include/clang/Tooling/ASTDiff/ASTDiff.h
  lib/Tooling/ASTDiff/ASTDiff.cpp
  test/Tooling/clang-diff-ast.cpp
  test/Tooling/clang-diff-basic.cpp
  test/Tooling/clang-diff-html.test
  test/Tooling/clang-diff-topdown.cpp

Index: test/Tooling/clang-diff-topdown.cpp
===
--- test/Tooling/clang-diff-topdown.cpp
+++ test/Tooling/clang-diff-topdown.cpp
@@ -27,8 +27,19 @@
   {{;;}}
 }
 
+int x;
+
+namespace src {
+  int x;
+  int x1 = x + 1;
+  int x2 = ::x + 1;
+}
+
+class A { int x = 1 + 1; void f() { int x1 = x; } };
+
 #else
 
+
 void f1() {
 
   {{;}}
@@ -45,4 +56,28 @@
   ;
 }
 
+int x;
+
+namespace dst {
+  int x;
+  // CHECK: Match DeclRefExpr: :x(17) to DeclRefExpr: :x(22)
+  int x1 = x + 1;
+  // CHECK: Match DeclRefExpr: x(21) to DeclRefExpr: x(26)
+  int x2 = ::x + 1;
+}
+
+class B {
+  // Only the class name changed; it is not included in the field value,
+  // therefore there is no update.
+  // CHECK: Match FieldDecl: :x(int)(24) to FieldDecl: :x(int)(29)
+  // CHECK-NOT: Update FieldDecl: :x(int)(24)
+  int x = 1+1;
+  void f() {
+// CHECK: Match MemberExpr: :x(32) to MemberExpr: :x(37)
+// CHECK-NOT: Update MemberExpr: :x(32)
+int x1 = B::x;
+  }
+
+};
+
 #endif
Index: test/Tooling/clang-diff-html.test
===
--- test/Tooling/clang-diff-html.test
+++ test/Tooling/clang-diff-html.test
@@ -11,12 +11,12 @@
 // match, move
 // CHECK: void foo()
+// CHECK-NEXT: :foo(void ())' class='m'>void foo()
 
 // match
 // CHECK: void main()
+// CHECK-NEXT: :main(void ())'>void main()
 
 // deletion
 // CHECK: (Context))
+ContextPrefix = Namespace->getQualifiedNameAsString();
+  else if (auto *Tag = dyn_cast(Context))
+ContextPrefix = Tag->getQualifiedNameAsString();
+  std::string Val = ND->getQualifiedNameAsString();
+  // Strip the qualifier, if Val refers to somthing in the current scope.
+  // But leave one leading ':' in place, so that we know that this is a
+  // relative path.
+  if (!ContextPrefix.empty() &&
+  StringRef(Val).startswith(ContextPrefix))
+Val = Val.substr(ContextPrefix.size() + 1);
+  return Val;
+}
+
+static std::string getRelativeName(const NamedDecl *ND) {
+  return getRelativeName(ND, ND->getDeclContext());
+}
+
+static const DeclContext *getEnclosingDeclContext(ASTContext &AST,
+  const Stmt *S) {
+  while (S) {
+const auto &Parents = AST.getParents(*S);
+if (Parents.empty())
+  return nullptr;
+const auto &P = Parents[0];
+if (const auto *D = P.get())
+  return D->getDeclContext();
+S = P.get();
+  }
+  llvm_unreachable("Could not find Decl ancestor.");
+}
+
 std::string SyntaxTree::Impl::getNodeValue(NodeId Id) const {
   return getNodeValue(getNode(Id));
 }
@@ -384,8 +419,7 @@
   TypePP.AnonymousTagLocations = false;
 
   if (auto *V = dyn_cast(D)) {
-Value += V->getQualifiedNameAsString() + "(" +
- V->getType().getAsString(TypePP) + ")";
+Value += getRelativeName(V) + "(" + V->getType().getAsString(TypePP) + ")";
 if (auto *C = dyn_cast(D)) {
   for (auto *Init : C->inits()) {
 if (!Init->isWritten())
@@ -398,14 +432,14 @@
   Value += C->getNameAsString() + ",";
 } else {
   assert(Init->isAnyMemberInitializer());
-  Value += Init->getMember()->getQualifiedNameAsString() + ",";
+  Value += getRelativeName(Init->getMember()) + ",";
 }
   }
 }
 return Value;
   }
   if (auto *N = dyn_cast(D))
-Value += N->getQualifiedNameAsString() + ";";
+Value += getRelativeName(N) + ";";
   if (auto *T = dyn_cast(D))
 return Value + T->getUnderlyingType().getAsString(TypePP) + ";";
   if (auto *T = dyn_cast(D))
@@ -429,7 +463,7 @@
   if (auto *B = dyn_cast(S))
 return B->getOpcodeStr();
   if (auto *M = dyn_cast(S))
-return M->getMemberDecl()->getQualifiedNameAsString();
+return getRelativeName(M->getMemberDecl());
   if (auto *I = dyn_cast(S)) {
 SmallString<256> Str;
 I->getValue().toString(Str, /*Radix=*/10, /*Signed=*/false);
@@ -441,7 +475,7 @@
 return Str.str();
   }
   if (auto *D = dyn_cast(S))
-return D->getDecl()->getQualifiedNameAsString();
+return getRelativeName(D->getDecl(), getEnclosingDeclContext(AST, S));
   if (auto *String = dyn_cast(S))
 return String->getString();
   if (auto *B = dyn_cast(S))
@@ -946,7 +980,7 @@
   return DiffImpl->getMapped(SourceTree.TreeImpl, Id);
 }
 
-SyntaxTree::SyntaxTree(const ASTContext &AST)
+SyntaxTree::SyntaxTree(ASTContext &AST)
 : TreeImpl(llvm::make_unique(
   this, AST.getTranslationUnitDecl(), AST)) {}
 
Index: include/clang/Tooling/ASTDiff/ASTDiff.h
===
--- include/clang/Tooling/

[PATCH] D36529: Fixed a race condition in PrecompiledPreamble.

2017-08-10 Thread Manuel Klimek via Phabricator via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

LG, as discussed in person, it's probably a good idea to try to get rid of the 
non-file-creating version, if possible, or at least fix the comments on the 
functions to make this behavior clear.


https://reviews.llvm.org/D36529



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


[PATCH] D34512: Add preliminary Cross Translation Unit support library

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

- Address review comments


https://reviews.llvm.org/D34512

Files:
  include/clang/Basic/AllDiagnostics.h
  include/clang/Basic/CMakeLists.txt
  include/clang/Basic/Diagnostic.td
  include/clang/Basic/DiagnosticCrossTUKinds.td
  include/clang/Basic/DiagnosticIDs.h
  include/clang/CrossTU/CrossTUDiagnostic.h
  include/clang/CrossTU/CrossTranslationUnit.h
  lib/AST/ASTImporter.cpp
  lib/Basic/DiagnosticIDs.cpp
  lib/CrossTU/CMakeLists.txt
  lib/CrossTU/CrossTranslationUnit.cpp
  test/Analysis/func-mapping-test.cpp
  test/CMakeLists.txt
  test/lit.cfg
  tools/CMakeLists.txt
  tools/clang-func-mapping/CMakeLists.txt
  tools/clang-func-mapping/ClangFnMapGen.cpp
  tools/diagtool/DiagnosticNames.cpp
  unittests/CrossTU/CMakeLists.txt
  unittests/CrossTU/CrossTranslationUnitTest.cpp

Index: unittests/CrossTU/CrossTranslationUnitTest.cpp
===
--- /dev/null
+++ unittests/CrossTU/CrossTranslationUnitTest.cpp
@@ -0,0 +1,98 @@
+//===- unittest/Tooling/CrossTranslationUnitTest.cpp - Tooling unit tests -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/AST/ASTConsumer.h"
+#include "clang/CrossTU/CrossTranslationUnit.h"
+#include "clang/Frontend/FrontendAction.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/Config/llvm-config.h"
+#include "llvm/Support/Path.h"
+#include "gtest/gtest.h"
+#include 
+
+namespace clang {
+namespace cross_tu {
+
+namespace {
+StringRef IndexFileName = "index.txt";
+StringRef ASTFileName = "f.ast";
+StringRef DefinitionFileName = "input.cc";
+
+class CTUASTConsumer : public clang::ASTConsumer {
+public:
+  explicit CTUASTConsumer(clang::CompilerInstance &CI, bool *Success)
+  : CTU(CI), Success(Success) {}
+
+  void HandleTranslationUnit(ASTContext &Ctx) {
+const TranslationUnitDecl *TU = Ctx.getTranslationUnitDecl();
+const FunctionDecl *FD = nullptr;
+for (const Decl *D : TU->decls()) {
+  FD = dyn_cast(D);
+  if (FD && FD->getName() == "f")
+break;
+}
+assert(FD);
+bool OrigFDHasBody = FD->hasBody();
+
+// Prepare the index file and the AST file.
+std::error_code EC;
+llvm::raw_fd_ostream OS(IndexFileName, EC, llvm::sys::fs::F_Text);
+OS << "c:@F@f#I# " << ASTFileName << "\n";
+OS.flush();
+StringRef SourceText = "int f(int) { return 0; }\n";
+// This file must exist since the saved ASTFile will reference it.
+llvm::raw_fd_ostream OS2(DefinitionFileName, EC, llvm::sys::fs::F_Text);
+OS2 << SourceText;
+OS2.flush();
+std::unique_ptr ASTWithDefinition =
+tooling::buildASTFromCode(SourceText);
+ASTWithDefinition->Save(ASTFileName);
+
+// Load the definition from the AST file.
+const FunctionDecl *NewFD =
+CTU.getCrossTUDefinition(FD, ".", IndexFileName);
+
+*Success = NewFD && NewFD->hasBody() && !OrigFDHasBody;
+  }
+
+private:
+  CrossTranslationUnitContext CTU;
+  bool *Success;
+};
+
+class CTUAction : public clang::ASTFrontendAction {
+public:
+  CTUAction(bool *Success) : Success(Success) {}
+
+protected:
+  std::unique_ptr
+  CreateASTConsumer(clang::CompilerInstance &CI, StringRef) override {
+return llvm::make_unique(CI, Success);
+  }
+
+private:
+  bool *Success;
+};
+
+} // end namespace
+
+TEST(CrossTranslationUnit, CanLoadFunctionDefinition) {
+  bool Success = false;
+  EXPECT_TRUE(tooling::runToolOnCode(new CTUAction(&Success), "int f(int);"));
+  EXPECT_TRUE(Success);
+  EXPECT_TRUE(llvm::sys::fs::exists(IndexFileName));
+  EXPECT_FALSE((bool)llvm::sys::fs::remove(IndexFileName));
+  EXPECT_TRUE(llvm::sys::fs::exists(ASTFileName));
+  EXPECT_FALSE((bool)llvm::sys::fs::remove(ASTFileName));
+  EXPECT_TRUE(llvm::sys::fs::exists(DefinitionFileName));
+  EXPECT_FALSE((bool)llvm::sys::fs::remove(DefinitionFileName));
+}
+
+} // end namespace cross_tu
+} // end namespace clang
Index: unittests/CrossTU/CMakeLists.txt
===
--- /dev/null
+++ unittests/CrossTU/CMakeLists.txt
@@ -0,0 +1,16 @@
+set(LLVM_LINK_COMPONENTS
+  ${LLVM_TARGETS_TO_BUILD}
+  Support
+  )
+
+add_clang_unittest(CrossTUTests
+  CrossTranslationUnitTest.cpp
+  )
+
+target_link_libraries(CrossTUTests
+  clangAST
+  clangBasic
+  clangCrossTU
+  clangFrontend
+  clangTooling
+  )
Index: tools/diagtool/DiagnosticNames.cpp
===
--- tools/diagtool/DiagnosticNames.cpp
+++ tools/diagtool/DiagnosticNames.cpp
@@ -32,6 +32,7 @@
  SFINAE,NOWERROR,SHOWINSYSHEADER,CATEGORY)\
   { #ENUM, diag::ENUM, STR_SIZE(#ENUM, uint8_t) },
 #include "c

[clang-tools-extra] r310584 - [clang-tidy] Add modernize-use-emplace.IgnoreImplicitConstructors option

2017-08-10 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu Aug 10 05:19:05 2017
New Revision: 310584

URL: http://llvm.org/viewvc/llvm-project?rev=310584&view=rev
Log:
[clang-tidy] Add modernize-use-emplace.IgnoreImplicitConstructors option

Added:

clang-tools-extra/trunk/test/clang-tidy/modernize-use-emplace-ignore-implicit-constructors.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.h

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp?rev=310584&r1=310583&r2=310584&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp Thu Aug 10 
05:19:05 2017
@@ -30,6 +30,7 @@ const auto DefaultTupleMakeFunctions = "
 
 UseEmplaceCheck::UseEmplaceCheck(StringRef Name, ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
+  IgnoreImplicitConstructors(Options.get("IgnoreImplicitConstructors", 0)),
   ContainersWithPushBack(utils::options::parseStringList(Options.get(
   "ContainersWithPushBack", DefaultContainersWithPushBack))),
   SmartPointers(utils::options::parseStringList(
@@ -120,9 +121,13 @@ void UseEmplaceCheck::registerMatchers(M
 
 void UseEmplaceCheck::check(const MatchFinder::MatchResult &Result) {
   const auto *Call = Result.Nodes.getNodeAs("call");
-  const auto *InnerCtorCall = Result.Nodes.getNodeAs("ctor");
+  const auto *CtorCall = Result.Nodes.getNodeAs("ctor");
   const auto *MakeCall = Result.Nodes.getNodeAs("make");
-  assert((InnerCtorCall || MakeCall) && "No push_back parameter matched");
+  assert((CtorCall || MakeCall) && "No push_back parameter matched");
+
+  if (IgnoreImplicitConstructors && CtorCall && CtorCall->getNumArgs() >= 1 &&
+  CtorCall->getArg(0)->getSourceRange() == CtorCall->getSourceRange())
+return;
 
   const auto FunctionNameSourceRange = CharSourceRange::getCharRange(
   Call->getExprLoc(), Call->getArg(0)->getExprLoc());
@@ -138,14 +143,14 @@ void UseEmplaceCheck::check(const MatchF
   const SourceRange CallParensRange =
   MakeCall ? SourceRange(MakeCall->getCallee()->getLocEnd(),
  MakeCall->getRParenLoc())
-   : InnerCtorCall->getParenOrBraceRange();
+   : CtorCall->getParenOrBraceRange();
 
   // Finish if there is no explicit constructor call.
   if (CallParensRange.getBegin().isInvalid())
 return;
 
   const SourceLocation ExprBegin =
-  MakeCall ? MakeCall->getExprLoc() : InnerCtorCall->getExprLoc();
+  MakeCall ? MakeCall->getExprLoc() : CtorCall->getExprLoc();
 
   // Range for constructor name and opening brace.
   const auto ParamCallSourceRange =

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.h?rev=310584&r1=310583&r2=310584&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.h Thu Aug 10 
05:19:05 2017
@@ -33,10 +33,11 @@ public:
   void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
 
 private:
-  std::vector ContainersWithPushBack;
-  std::vector SmartPointers;
-  std::vector TupleTypes;
-  std::vector TupleMakeFunctions;
+  const bool IgnoreImplicitConstructors;
+  const std::vector ContainersWithPushBack;
+  const std::vector SmartPointers;
+  const std::vector TupleTypes;
+  const std::vector TupleMakeFunctions;
 };
 
 } // namespace modernize

Added: 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-emplace-ignore-implicit-constructors.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-emplace-ignore-implicit-constructors.cpp?rev=310584&view=auto
==
--- 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-emplace-ignore-implicit-constructors.cpp
 (added)
+++ 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-emplace-ignore-implicit-constructors.cpp
 Thu Aug 10 05:19:05 2017
@@ -0,0 +1,123 @@
+// RUN: %check_clang_tidy %s modernize-use-emplace %t -- \
+// RUN:   -config="{CheckOptions: \
+// RUN: [{key: modernize-use-emplace.IgnoreImplicitConstructors, \
+// RUN:   value: 1}] \
+// RUN: }" -- -std=c++11
+
+namespace std {
+template 
+class initializer_list
+{
+public:
+  initializer_list() noexcept {}
+};
+
+template 
+class vector {
+public:
+  vector() = default;
+  vector(initializer_list) {}
+
+  void push_back(const T &) {}
+  void push_back(T &&) {}
+
+  template 
+  void emplac

[clang-tools-extra] r310585 - [clang-tidy] Enable test for http://llvm.org/PR26228

2017-08-10 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu Aug 10 05:24:52 2017
New Revision: 310585

URL: http://llvm.org/viewvc/llvm-project?rev=310585&view=rev
Log:
[clang-tidy] Enable test for http://llvm.org/PR26228

Modified:

clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements.cpp?rev=310585&r1=310584&r2=310585&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/readability-braces-around-statements.cpp
 Thu Aug 10 05:24:52 2017
@@ -176,12 +176,13 @@ void f(const char *p) {
   if (!p)
 f("\
 ");
-  // CHECK-MESSAGES: :[[@LINE-3]]:10: warning: statement should be inside 
braces
-  // CHECK-FIXES:  {{^  }}if (!p) {{{$}}
-  // CHECK-FIXES-NEXT: {{^}}f("\{{$}}
-  // CHECK-FIXES-_NEXT: {{^}}");{{$}} FIXME: This breaks 
(http://llvm.org/PR26228)
-  // CHECK-FIXES-_NEXT: {{^}}}{{$}}
-}
+} // end of f
+// CHECK-MESSAGES: :[[@LINE-4]]:10: warning: statement should be inside braces
+// CHECK-FIXES:  {{^}}  if (!p) {{{$}}
+// CHECK-FIXES-NEXT: {{^}}f("\{{$}}
+// CHECK-FIXES-NEXT: {{^}}");{{$}}
+// CHECK-FIXES-NEXT: {{^}}}{{$}}
+// CHECK-FIXES-NEXT: {{^}}} // end of f{{$}}
 
 #define M(x) x
 


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


Re: [clang-tools-extra] r310584 - [clang-tidy] Add modernize-use-emplace.IgnoreImplicitConstructors option

2017-08-10 Thread Haojian Wu via cfe-commits
I think you also need to add the doc for the option in
modernize-use-emplace.rst.

On Thu, Aug 10, 2017 at 2:19 PM, Alexander Kornienko via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: alexfh
> Date: Thu Aug 10 05:19:05 2017
> New Revision: 310584
>
> URL: http://llvm.org/viewvc/llvm-project?rev=310584&view=rev
> Log:
> [clang-tidy] Add modernize-use-emplace.IgnoreImplicitConstructors option
>
> Added:
> clang-tools-extra/trunk/test/clang-tidy/modernize-use-
> emplace-ignore-implicit-constructors.cpp
> Modified:
> clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp
> clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.h
>
> Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clang-tidy/modernize/UseEmplaceCheck.cpp?rev=
> 310584&r1=310583&r2=310584&view=diff
> 
> ==
> --- clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp
> (original)
> +++ clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp Thu
> Aug 10 05:19:05 2017
> @@ -30,6 +30,7 @@ const auto DefaultTupleMakeFunctions = "
>
>  UseEmplaceCheck::UseEmplaceCheck(StringRef Name, ClangTidyContext
> *Context)
>  : ClangTidyCheck(Name, Context),
> +  IgnoreImplicitConstructors(Options.get("IgnoreImplicitConstructors",
> 0)),
>ContainersWithPushBack(utils::options::parseStringList(Options.get(
>"ContainersWithPushBack", DefaultContainersWithPushBack))),
>SmartPointers(utils::options::parseStringList(
> @@ -120,9 +121,13 @@ void UseEmplaceCheck::registerMatchers(M
>
>  void UseEmplaceCheck::check(const MatchFinder::MatchResult &Result) {
>const auto *Call = Result.Nodes.getNodeAs("call");
> -  const auto *InnerCtorCall = Result.Nodes.getNodeAs<
> CXXConstructExpr>("ctor");
> +  const auto *CtorCall = Result.Nodes.getNodeAs<
> CXXConstructExpr>("ctor");
>const auto *MakeCall = Result.Nodes.getNodeAs("make");
> -  assert((InnerCtorCall || MakeCall) && "No push_back parameter matched");
> +  assert((CtorCall || MakeCall) && "No push_back parameter matched");
> +
> +  if (IgnoreImplicitConstructors && CtorCall && CtorCall->getNumArgs() >=
> 1 &&
> +  CtorCall->getArg(0)->getSourceRange() ==
> CtorCall->getSourceRange())
> +return;
>
>const auto FunctionNameSourceRange = CharSourceRange::getCharRange(
>Call->getExprLoc(), Call->getArg(0)->getExprLoc());
> @@ -138,14 +143,14 @@ void UseEmplaceCheck::check(const MatchF
>const SourceRange CallParensRange =
>MakeCall ? SourceRange(MakeCall->getCallee()->getLocEnd(),
>   MakeCall->getRParenLoc())
> -   : InnerCtorCall->getParenOrBraceRange();
> +   : CtorCall->getParenOrBraceRange();
>
>// Finish if there is no explicit constructor call.
>if (CallParensRange.getBegin().isInvalid())
>  return;
>
>const SourceLocation ExprBegin =
> -  MakeCall ? MakeCall->getExprLoc() : InnerCtorCall->getExprLoc();
> +  MakeCall ? MakeCall->getExprLoc() : CtorCall->getExprLoc();
>
>// Range for constructor name and opening brace.
>const auto ParamCallSourceRange =
>
> Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.h
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clang-tidy/modernize/UseEmplaceCheck.h?rev=310584&
> r1=310583&r2=310584&view=diff
> 
> ==
> --- clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.h
> (original)
> +++ clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.h Thu
> Aug 10 05:19:05 2017
> @@ -33,10 +33,11 @@ public:
>void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
>
>  private:
> -  std::vector ContainersWithPushBack;
> -  std::vector SmartPointers;
> -  std::vector TupleTypes;
> -  std::vector TupleMakeFunctions;
> +  const bool IgnoreImplicitConstructors;
> +  const std::vector ContainersWithPushBack;
> +  const std::vector SmartPointers;
> +  const std::vector TupleTypes;
> +  const std::vector TupleMakeFunctions;
>  };
>
>  } // namespace modernize
>
> Added: clang-tools-extra/trunk/test/clang-tidy/modernize-use-
> emplace-ignore-implicit-constructors.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/test/clang-tidy/modernize-use-emplace-ignore-
> implicit-constructors.cpp?rev=310584&view=auto
> 
> ==
> --- clang-tools-extra/trunk/test/clang-tidy/modernize-use-
> emplace-ignore-implicit-constructors.cpp (added)
> +++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-
> emplace-ignore-implicit-constructors.cpp Thu Aug 10 05:19:05 2017
> @@ -0,0 +1,123 @@
> +// RUN: %check_clang_tidy %s modernize-use-emplace %t -- \
> +// RUN:   -config="{CheckOptions: \
> +

r310544 - [clang-format] let PointerAlignment dictate spacing of function ref qualifiers

2017-08-10 Thread Jacob Bandes-Storch via cfe-commits
Author: jtbandes
Date: Wed Aug  9 18:30:22 2017
New Revision: 310544

URL: http://llvm.org/viewvc/llvm-project?rev=310544&view=rev
Log:
[clang-format] let PointerAlignment dictate spacing of function ref qualifiers

Summary: The original changes for ref qualifiers in rL272537 and rL272548 
allowed function const+ref qualifier spacing to diverge from the spacing used 
for variables. It seems more consistent for `T const& x;` to match `void foo() 
const&;`.

Reviewers: djasper

Reviewed By: djasper

Subscribers: klimek, cfe-commits

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

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

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=310544&r1=310543&r2=310544&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Wed Aug  9 18:30:22 2017
@@ -2216,8 +2216,7 @@ bool TokenAnnotator::spaceRequiredBetwee
 return false;
   if (Right.is(TT_PointerOrReference))
 return (Left.is(tok::r_paren) && Line.MightBeFunctionDecl) ||
-   (Left.Tok.isLiteral() || (Left.is(tok::kw_const) && Left.Previous &&
- Left.Previous->is(tok::r_paren)) ||
+   (Left.Tok.isLiteral() ||
 (!Left.isOneOf(TT_PointerOrReference, tok::l_paren) &&
  (Style.PointerAlignment != FormatStyle::PAS_Left ||
   (Line.IsMultiVariableDeclStmt &&

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=310544&r1=310543&r2=310544&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Wed Aug  9 18:30:22 2017
@@ -5283,7 +5283,8 @@ TEST_F(FormatTest, UnderstandsFunctionRe
   verifyFormat("SomeType MemberFunction(const Deleted &) && {}");
   verifyFormat("SomeType MemberFunction(const Deleted &) && final {}");
   verifyFormat("SomeType MemberFunction(const Deleted &) && override {}");
-  verifyFormat("SomeType MemberFunction(const Deleted &) const &;");
+  verifyFormat("void Fn(T const &) const &;");
+  verifyFormat("void Fn(T const volatile &&) const volatile &&;");
   verifyFormat("template \n"
"void F(T) && = delete;",
getGoogleStyle());
@@ -5300,7 +5301,8 @@ TEST_F(FormatTest, UnderstandsFunctionRe
   verifyFormat("auto Function(T... t) & -> void {}", AlignLeft);
   verifyFormat("auto Function(T) & -> void {}", AlignLeft);
   verifyFormat("auto Function(T) & -> void;", AlignLeft);
-  verifyFormat("SomeType MemberFunction(const Deleted&) const &;", AlignLeft);
+  verifyFormat("void Fn(T const&) const&;", AlignLeft);
+  verifyFormat("void Fn(T const volatile&&) const volatile&&;", AlignLeft);
 
   FormatStyle Spaces = getLLVMStyle();
   Spaces.SpacesInCStyleCastParentheses = true;


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


[clang-tools-extra] r310586 - [clang-tidy] Add a test.

2017-08-10 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu Aug 10 05:38:46 2017
New Revision: 310586

URL: http://llvm.org/viewvc/llvm-project?rev=310586&view=rev
Log:
[clang-tidy] Add a test.

Modified:
clang-tools-extra/trunk/unittests/clang-tidy/ReadabilityModuleTest.cpp

Modified: clang-tools-extra/trunk/unittests/clang-tidy/ReadabilityModuleTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-tidy/ReadabilityModuleTest.cpp?rev=310586&r1=310585&r2=310586&view=diff
==
--- clang-tools-extra/trunk/unittests/clang-tidy/ReadabilityModuleTest.cpp 
(original)
+++ clang-tools-extra/trunk/unittests/clang-tidy/ReadabilityModuleTest.cpp Thu 
Aug 10 05:38:46 2017
@@ -487,11 +487,17 @@ TEST(BracesAroundStatementsCheckTest, Im
   ClangTidyOptions Opts;
   Opts.CheckOptions["test-check-0.ShortStatementLines"] = "1";
 
-  EXPECT_NO_CHANGES_WITH_OPTS(BracesAroundStatementsCheck, Opts,
-  "const char *f() {\n"
+  StringRef Input = "const char *f() {\n"
   "  if (true) return \"\";\n"
   "  return \"abc\";\n"
-  "}\n");
+  "}\n";
+  EXPECT_NO_CHANGES_WITH_OPTS(BracesAroundStatementsCheck, Opts, Input);
+  EXPECT_EQ("const char *f() {\n"
+"  if (true) { return \"\";\n"
+"}\n"
+"  return \"abc\";\n"
+"}\n",
+runCheckOnCode(Input));
 }
 
 } // namespace test


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


[PATCH] D36550: [mips] Notify user that `-mabicalls` is ignored on non-PIC N64 ABI

2017-08-10 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan updated this revision to Diff 110561.
atanasyan edited the summary of this revision.
atanasyan added a comment.

- Addressed review comments.


Repository:
  rL LLVM

https://reviews.llvm.org/D36550

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  lib/Driver/ToolChains/Arch/Mips.cpp
  test/Driver/mips-abicalls-warning.c
  test/Driver/mips-features.c


Index: test/Driver/mips-features.c
===
--- test/Driver/mips-features.c
+++ test/Driver/mips-features.c
@@ -10,6 +10,11 @@
 // RUN:   | FileCheck --check-prefix=CHECK-MNOABICALLS %s
 // CHECK-MNOABICALLS: "-target-feature" "+noabicalls"
 //
+// -mno-abicalls non-PIC N64
+// RUN: %clang -target mips64-linux-gnu -### -c -fno-PIC %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MNOABICALLS-N64NPIC %s
+// CHECK-MNOABICALLS-N64NPIC: "-target-feature" "+noabicalls"
+//
 // -mgpopt
 // RUN: %clang -target mips-linux-gnu -### -c %s -mno-gpopt -mgpopt 
-Wno-unsupported-gpopt 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-MGPOPT-DEF-ABICALLS %s
Index: test/Driver/mips-abicalls-warning.c
===
--- /dev/null
+++ test/Driver/mips-abicalls-warning.c
@@ -0,0 +1,3 @@
+// REQUIRES: mips-registered-target
+// RUN: %clang -### -c -target mips64-mti-elf -fno-PIC -mabicalls %s 2>&1 | 
FileCheck %s
+// CHECK: warning: ignoring '-mabicalls' option as it cannot be used with non 
position-independent code and the N64 ABI
Index: lib/Driver/ToolChains/Arch/Mips.cpp
===
--- lib/Driver/ToolChains/Arch/Mips.cpp
+++ lib/Driver/ToolChains/Arch/Mips.cpp
@@ -227,11 +227,23 @@
  O.matches(options::OPT_fno_PIE) || O.matches(options::OPT_fno_pie));
   }
 
-  if (IsN64 && NonPIC)
+  bool UseAbiCalls = false;
+
+  Arg *ABICallsArg =
+  Args.getLastArg(options::OPT_mabicalls, options::OPT_mno_abicalls);
+  UseAbiCalls =
+  !ABICallsArg ||
+  (ABICallsArg && 
ABICallsArg->getOption().matches(options::OPT_mabicalls));
+
+  if (UseAbiCalls && IsN64 && NonPIC) {
+D.Diag(diag::warn_drv_unsupported_abicalls);
+UseAbiCalls = false;
+  }
+
+  if (!UseAbiCalls)
 Features.push_back("+noabicalls");
   else
-AddTargetFeature(Args, Features, options::OPT_mno_abicalls,
- options::OPT_mabicalls, "noabicalls");
+Features.push_back("-noabicalls");
 
   mips::FloatABI FloatABI = mips::getMipsFloatABI(D, Args);
   if (FloatABI == mips::FloatABI::Soft) {
Index: include/clang/Basic/DiagnosticDriverKinds.td
===
--- include/clang/Basic/DiagnosticDriverKinds.td
+++ include/clang/Basic/DiagnosticDriverKinds.td
@@ -292,6 +292,10 @@
   "ignoring '-mgpopt' option as it cannot be used with %select{|the implicit"
   " usage of }0-mabicalls">,
   InGroup;
+def warn_drv_unsupported_abicalls : Warning<
+  "ignoring '-mabicalls' option as it cannot be used with "
+  "non position-independent code and the N64 ABI">,
+  InGroup;
 
 def warn_drv_unable_to_find_directory_expected : Warning<
   "unable to find %0 directory, expected to be in '%1'">,


Index: test/Driver/mips-features.c
===
--- test/Driver/mips-features.c
+++ test/Driver/mips-features.c
@@ -10,6 +10,11 @@
 // RUN:   | FileCheck --check-prefix=CHECK-MNOABICALLS %s
 // CHECK-MNOABICALLS: "-target-feature" "+noabicalls"
 //
+// -mno-abicalls non-PIC N64
+// RUN: %clang -target mips64-linux-gnu -### -c -fno-PIC %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MNOABICALLS-N64NPIC %s
+// CHECK-MNOABICALLS-N64NPIC: "-target-feature" "+noabicalls"
+//
 // -mgpopt
 // RUN: %clang -target mips-linux-gnu -### -c %s -mno-gpopt -mgpopt -Wno-unsupported-gpopt 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-MGPOPT-DEF-ABICALLS %s
Index: test/Driver/mips-abicalls-warning.c
===
--- /dev/null
+++ test/Driver/mips-abicalls-warning.c
@@ -0,0 +1,3 @@
+// REQUIRES: mips-registered-target
+// RUN: %clang -### -c -target mips64-mti-elf -fno-PIC -mabicalls %s 2>&1 | FileCheck %s
+// CHECK: warning: ignoring '-mabicalls' option as it cannot be used with non position-independent code and the N64 ABI
Index: lib/Driver/ToolChains/Arch/Mips.cpp
===
--- lib/Driver/ToolChains/Arch/Mips.cpp
+++ lib/Driver/ToolChains/Arch/Mips.cpp
@@ -227,11 +227,23 @@
  O.matches(options::OPT_fno_PIE) || O.matches(options::OPT_fno_pie));
   }
 
-  if (IsN64 && NonPIC)
+  bool UseAbiCalls = false;
+
+  Arg *ABICallsArg =
+  Args.getLastArg(options::OPT_mabicalls, options::OPT_mno_abicalls);
+  UseAbiCalls =
+  !ABICallsArg ||
+  (ABICallsArg && ABICallsArg->getOption().matches(options::OPT_mabicalls));
+
+  if (UseAbiCalls && IsN64 && NonPIC) {
+D.Diag(diag::warn_drv_

[PATCH] D36551: [mips] Show warning in case of mixing -mlong-calls and -mabicalls options

2017-08-10 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan updated this revision to Diff 110562.
atanasyan added a comment.

- Addressed review comments.


Repository:
  rL LLVM

https://reviews.llvm.org/D36551

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  lib/Driver/ToolChains/Arch/Mips.cpp
  test/Driver/mips-features.c
  test/Driver/mips-longcalls-warning.c


Index: test/Driver/mips-longcalls-warning.c
===
--- /dev/null
+++ test/Driver/mips-longcalls-warning.c
@@ -0,0 +1,6 @@
+// REQUIRES: mips-registered-target
+// RUN: %clang -### -c -target mips-mti-elf -mlong-calls %s 2>&1 | FileCheck 
-check-prefix=IMPLICIT %s
+// IMPLICIT: warning: ignoring '-mlong-calls' option as it is not currently 
supported with the implicit usage of -mabicalls
+
+// RUN: %clang -### -c -target mips-mti-elf -mlong-calls -mabicalls %s 2>&1 | 
FileCheck -check-prefix=EXPLICIT %s
+// EXPLICIT: warning: ignoring '-mlong-calls' option as it is not currently 
supported with -mabicalls
Index: test/Driver/mips-features.c
===
--- test/Driver/mips-features.c
+++ test/Driver/mips-features.c
@@ -336,12 +336,16 @@
 // CHECK-IMG-SINGLEFLOAT-FPXX: "-target-feature" "+fpxx"
 
 // -mlong-call
-// RUN: %clang -target mips-img-linux-gnu -### -c %s -mlong-calls 2>&1 \
+// RUN: %clang -target mips-img-linux-gnu -### -c %s \
+// RUN:-mno-abicalls -mlong-calls 2>&1 \
 // RUN:   | FileCheck --check-prefix=LONG-CALLS-ON %s
-// RUN: %clang -target mips-img-linux-gnu -### -c %s -mno-long-calls 2>&1 \
+// RUN: %clang -target mips-img-linux-gnu -### -c %s \
+// RUN:-mno-abicalls -mno-long-calls 2>&1 \
 // RUN:   | FileCheck --check-prefix=LONG-CALLS-OFF %s
 // RUN: %clang -target mips-img-linux-gnu -### -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=LONG-CALLS-DEF %s
+// RUN: %clang -target mips-img-linux-gnu -### -c %s -mlong-calls 2>&1 \
+// RUN:   | FileCheck --check-prefix=LONG-CALLS-DEF %s
 // LONG-CALLS-ON: "-target-feature" "+long-calls"
 // LONG-CALLS-OFF: "-target-feature" "-long-calls"
 // LONG-CALLS-DEF-NOT: "long-calls"
Index: lib/Driver/ToolChains/Arch/Mips.cpp
===
--- lib/Driver/ToolChains/Arch/Mips.cpp
+++ lib/Driver/ToolChains/Arch/Mips.cpp
@@ -245,6 +245,16 @@
   else
 Features.push_back("-noabicalls");
 
+  if (Arg *A = Args.getLastArg(options::OPT_mlong_calls,
+   options::OPT_mno_long_calls)) {
+if (A->getOption().matches(options::OPT_mno_long_calls))
+  Features.push_back("-long-calls");
+else if (!UseAbiCalls)
+  Features.push_back("+long-calls");
+else
+  D.Diag(diag::warn_drv_unsupported_longcalls) << (ABICallsArg ? 0 : 1);
+  }
+
   mips::FloatABI FloatABI = mips::getMipsFloatABI(D, Args);
   if (FloatABI == mips::FloatABI::Soft) {
 // FIXME: Note, this is a hack. We need to pass the selected float
@@ -309,8 +319,6 @@
 
   AddTargetFeature(Args, Features, options::OPT_mno_odd_spreg,
options::OPT_modd_spreg, "nooddspreg");
-  AddTargetFeature(Args, Features, options::OPT_mlong_calls,
-   options::OPT_mno_long_calls, "long-calls");
   AddTargetFeature(Args, Features, options::OPT_mmt, options::OPT_mno_mt, 
"mt");
 }
 
Index: include/clang/Basic/DiagnosticDriverKinds.td
===
--- include/clang/Basic/DiagnosticDriverKinds.td
+++ include/clang/Basic/DiagnosticDriverKinds.td
@@ -292,6 +292,10 @@
   "ignoring '-mgpopt' option as it cannot be used with %select{|the implicit"
   " usage of }0-mabicalls">,
   InGroup;
+def warn_drv_unsupported_longcalls : Warning<
+  "ignoring '-mlong-calls' option as it is not currently supported with "
+  "%select{|the implicit usage of }0-mabicalls">,
+  InGroup;
 def warn_drv_unsupported_abicalls : Warning<
   "ignoring '-mabicalls' option as it cannot be used with "
   "non position-independent code and the N64 ABI">,


Index: test/Driver/mips-longcalls-warning.c
===
--- /dev/null
+++ test/Driver/mips-longcalls-warning.c
@@ -0,0 +1,6 @@
+// REQUIRES: mips-registered-target
+// RUN: %clang -### -c -target mips-mti-elf -mlong-calls %s 2>&1 | FileCheck -check-prefix=IMPLICIT %s
+// IMPLICIT: warning: ignoring '-mlong-calls' option as it is not currently supported with the implicit usage of -mabicalls
+
+// RUN: %clang -### -c -target mips-mti-elf -mlong-calls -mabicalls %s 2>&1 | FileCheck -check-prefix=EXPLICIT %s
+// EXPLICIT: warning: ignoring '-mlong-calls' option as it is not currently supported with -mabicalls
Index: test/Driver/mips-features.c
===
--- test/Driver/mips-features.c
+++ test/Driver/mips-features.c
@@ -336,12 +336,16 @@
 // CHECK-IMG-SINGLEFLOAT-FPXX: "-target-feature" "+fpxx"
 
 // -mlong-call
-// RUN: %clang -target mips-img-linux-gn

[PATCH] D36075: [refactor] Initial support for refactoring action rules

2017-08-10 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

+ Introduce refactoring diagnostics.


Repository:
  rL LLVM

https://reviews.llvm.org/D36075



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


[PATCH] D36075: [refactor] Initial support for refactoring action rules

2017-08-10 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 110563.
arphaman edited the summary of this revision.
arphaman added a comment.

- Simplify error/diagnostic handling. Use `DiagnosticOr` instead of 
`DiagOr`.
- Simplify the code for the selection requirements by removing lambda deducers 
and instead using special classes for requirements instead of lambdas/functions.
- Rename `selectionRequirement` to `requiredSelection`


Repository:
  rL LLVM

https://reviews.llvm.org/D36075

Files:
  include/clang/Basic/AllDiagnostics.h
  include/clang/Basic/CMakeLists.txt
  include/clang/Basic/Diagnostic.td
  include/clang/Basic/DiagnosticIDs.h
  include/clang/Basic/DiagnosticOr.h
  include/clang/Basic/DiagnosticRefactoringKinds.td
  include/clang/Basic/LLVM.h
  include/clang/Tooling/Refactoring/AtomicChange.h
  include/clang/Tooling/Refactoring/RefactoringActionRules.h
  include/clang/Tooling/Refactoring/RefactoringDiagnostic.h
  include/clang/Tooling/Refactoring/RefactoringOperationController.h
  include/clang/Tooling/Refactoring/RefactoringResult.h
  include/clang/Tooling/Refactoring/SourceSelectionConstraints.h
  lib/Basic/DiagnosticIDs.cpp
  tools/diagtool/DiagnosticNames.cpp
  unittests/Tooling/CMakeLists.txt
  unittests/Tooling/RefactoringActionRulesTest.cpp

Index: unittests/Tooling/RefactoringActionRulesTest.cpp
===
--- /dev/null
+++ unittests/Tooling/RefactoringActionRulesTest.cpp
@@ -0,0 +1,157 @@
+//===- unittest/Tooling/RefactoringTestActionRulesTest.cpp ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "ReplacementTest.h"
+#include "RewriterTestContext.h"
+#include "clang/Tooling/Refactoring.h"
+#include "clang/Tooling/Refactoring/RefactoringActionRules.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/Support/Errc.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+using namespace tooling;
+using namespace refactoring_action_rules;
+
+namespace {
+
+class RefactoringActionRulesTest : public ::testing::Test {
+protected:
+  void SetUp() override {
+Context.Sources.setMainFileID(
+Context.createInMemoryFile("input.cpp", DefaultCode));
+  }
+
+  RewriterTestContext Context;
+  std::string DefaultCode = std::string(100, 'a');
+};
+
+TEST_F(RefactoringActionRulesTest, MyFirstRefactoringRule) {
+  auto ReplaceAWithB =
+  [](std::pair Selection)
+  -> Expected {
+const SourceManager &SM = Selection.first.getSources();
+SourceLocation Loc = Selection.first.getRange().getBegin().getLocWithOffset(
+Selection.second);
+AtomicChange Change(SM, Loc);
+llvm::Error E = Change.replace(SM, Loc, 1, "b");
+if (E)
+  return std::move(E);
+return Change;
+  };
+  class SelectionRequirement : public selection::Requirement {
+  public:
+std::pair
+evaluateSelection(selection::SourceSelectionRange Selection) const {
+  return std::make_pair(Selection, 20);
+}
+  };
+  auto Rule = apply(ReplaceAWithB, requiredSelection(SelectionRequirement()));
+
+  // When the requirements are satisifed, the rule's function must be invoked.
+  {
+RefactoringOperationController Operation(Context.Sources);
+SourceLocation Cursor =
+Context.Sources.getLocForStartOfFile(Context.Sources.getMainFileID())
+.getLocWithOffset(10);
+Operation.setSelectionRange({Cursor, Cursor});
+
+DiagnosticOr DiagOrResult = Rule->perform(Operation);
+ASSERT_FALSE(!DiagOrResult);
+RefactoringResult Result = std::move(*DiagOrResult);
+ASSERT_EQ(Result.getKind(), RefactoringResult::AtomicChanges);
+ASSERT_EQ(Result.getChanges().size(), 1u);
+std::string YAMLString = Result.getChanges()[0].toYAMLString();
+
+ASSERT_STREQ("---\n"
+ "Key: 'input.cpp:30'\n"
+ "FilePath:input.cpp\n"
+ "Error:   ''\n"
+ "InsertedHeaders: \n"
+ "RemovedHeaders:  \n"
+ "Replacements:\n" // Extra whitespace here!
+ "  - FilePath:input.cpp\n"
+ "Offset:  30\n"
+ "Length:  1\n"
+ "ReplacementText: b\n"
+ "...\n",
+ YAMLString.c_str());
+  }
+
+  // When one of the requirements is not satisfied, perform should return either
+  // None or a valid diagnostic.
+  {
+RefactoringOperationController Operation(Context.Sources);
+DiagnosticOr DiagOrResult = Rule->perform(Operation);
+
+// A failure to select returns the invalidSelectionError.
+ASSERT_TRUE(!DiagOrResult);
+EXPECT_EQ(DiagOrResult.getDiagnostic().first, SourceLocation());
+EXPECT_EQ(DiagOrResult.getDiagnostic().second.getDiagID(

[PATCH] D36574: [refactor] add clang-refactor tool with initial testing support and local-rename action

2017-08-10 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.
Herald added a subscriber: mgorny.

This patch depends on https://reviews.llvm.org/D36075 and 
https://reviews.llvm.org/D36156.

It introduces the `clang-refactor` tool alongside the `local-rename` action 
which is uses the existing renaming engine used by `clang-rename`. The tool 
doesn't actually perform the source transformations yet, it just provides 
testing support. I've moved one test from `clang-rename` over right now, but 
will move the others if the general direction of this patch is accepted.

The following options are supported by clang-refactor:

- `-v`: use verbose output
- `-dump`: dump results instead of applying them
- `-no-dbs`: avoid searching/loading databases like compilation database and/or 
indexer stores/databases
- `-selection`: The source range that corresponds to the portion of the source 
that's selected (currently only special command `test:` is supported).

The testing support provided by `clang-refactor` is described below:
When `-selection=test:` is given, `clang-refactor` will parse the 
selection commands from that file. The selection commands are grouped and the 
specified refactoring action invoked by the tool. Each command in a group is 
expected to produce an identical result. The precise syntax for the selection 
commands is described in a comment for `findTestSelectionRangesIn` in 
TestSupport.h.

Thanks for taking a look!


Repository:
  rL LLVM

https://reviews.llvm.org/D36574

Files:
  include/clang/Basic/DiagnosticRefactoringKinds.td
  include/clang/Tooling/Refactoring/RefactoringAction.h
  include/clang/Tooling/Refactoring/RefactoringActionRegistry.def
  include/clang/Tooling/Refactoring/RefactoringActionRules.h
  include/clang/Tooling/Refactoring/RefactoringEngine.h
  include/clang/Tooling/Refactoring/RefactoringOperationController.h
  include/clang/Tooling/Refactoring/RefactoringResult.h
  include/clang/Tooling/Refactoring/Rename/SymbolOccurrences.h
  include/clang/Tooling/Refactoring/Rename/USRFindingAction.h
  include/clang/Tooling/Refactoring/SourceSelectionConstraints.h
  include/clang/module.modulemap
  lib/Tooling/Refactoring/CMakeLists.txt
  lib/Tooling/Refactoring/RefactoringEngine.cpp
  lib/Tooling/Refactoring/Rename/RenamingAction.cpp
  lib/Tooling/Refactoring/Rename/USRFindingAction.cpp
  test/Refactor/LocalRename/Field.cpp
  test/Refactor/tool-common-options.c
  test/Refactor/tool-test-support.c
  test/clang-rename/Field.cpp
  tools/CMakeLists.txt
  tools/clang-refactor/CMakeLists.txt
  tools/clang-refactor/ClangRefactor.cpp
  tools/clang-refactor/TestSupport.cpp
  tools/clang-refactor/TestSupport.h
  unittests/Tooling/RefactoringActionRulesTest.cpp

Index: unittests/Tooling/RefactoringActionRulesTest.cpp
===
--- unittests/Tooling/RefactoringActionRulesTest.cpp
+++ unittests/Tooling/RefactoringActionRulesTest.cpp
@@ -56,7 +56,8 @@
 
   // When the requirements are satisifed, the rule's function must be invoked.
   {
-RefactoringOperationController Operation(Context.Sources);
+RefactoringOperationController Operation(Context.Sources,
+ Context.Diagnostics);
 SourceLocation Cursor =
 Context.Sources.getLocForStartOfFile(Context.Sources.getMainFileID())
 .getLocWithOffset(10);
@@ -87,7 +88,8 @@
   // When one of the requirements is not satisfied, perform should return either
   // None or a valid diagnostic.
   {
-RefactoringOperationController Operation(Context.Sources);
+RefactoringOperationController Operation(Context.Sources,
+ Context.Diagnostics);
 DiagnosticOr DiagOrResult = Rule->perform(Operation);
 
 // A failure to select returns the invalidSelectionError.
@@ -107,7 +109,8 @@
   apply(Func, requiredSelection(
   selection::identity()));
 
-  RefactoringOperationController Operation(Context.Sources);
+  RefactoringOperationController Operation(Context.Sources,
+   Context.Diagnostics);
   SourceLocation Cursor =
   Context.Sources.getLocForStartOfFile(Context.Sources.getMainFileID());
   Operation.setSelectionRange({Cursor, Cursor});
@@ -122,7 +125,8 @@
 TEST_F(RefactoringActionRulesTest, ReturnInitiationDiagnostic) {
   unsigned DiagID = Context.Diagnostics.getCustomDiagID(
   DiagnosticsEngine::Error, "Diagnostic: %0");
-  RefactoringOperationController Operation(Context.Sources);
+  RefactoringOperationController Operation(Context.Sources,
+   Context.Diagnostics);
   PartialDiagnostic Diag(DiagID, Operation.getDiagnosticStorage());
 
   class SelectionRequirement : public selection::Requirement {
Index: tools/clang-refactor/TestSupport.h
===
--- /dev/null
+++ tools/clang-refactor/TestSupport.h
@@ -0,0 +1,104 @@
+//===--- TestSupport.h - 

[clang-tools-extra] r310587 - [clang-tidy] Updated docs and release notes for r310584

2017-08-10 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu Aug 10 05:54:05 2017
New Revision: 310587

URL: http://llvm.org/viewvc/llvm-project?rev=310587&view=rev
Log:
[clang-tidy] Updated docs and release notes for r310584

Modified:
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-emplace.rst

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=310587&r1=310586&r2=310587&view=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Thu Aug 10 05:54:05 2017
@@ -57,26 +57,29 @@ The improvements are...
 Improvements to clang-tidy
 --
 
-* Renamed checks to use correct term "implicit conversion" instead of "implicit
+- Renamed checks to use correct term "implicit conversion" instead of "implicit
   cast" and modified messages and option names accordingly:
 
-- **performance-implicit-cast-in-loop** was renamed to
+* **performance-implicit-cast-in-loop** was renamed to
   `performance-implicit-conversion-in-loop
   
`_
-- **readability-implicit-bool-cast** was renamed to
+* **readability-implicit-bool-cast** was renamed to
   `readability-implicit-bool-conversion
   
`_;
   the check's options were renamed as follows:
   ``AllowConditionalIntegerCasts`` -> ``AllowIntegerConditions``,
   ``AllowConditionalPointerCasts`` -> ``AllowPointerConditions``.
 
-
 - New `readability-static-accessed-through-instance
   
`_
 check
 
   Finds member expressions that access static members through instances and
   replaces them with uses of the appropriate qualified-id.
 
+- Added `modernize-use-emplace.IgnoreImplicitConstructors
+  
`_
+  option.
+
 Improvements to include-fixer
 -
 

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-emplace.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-emplace.rst?rev=310587&r1=310586&r2=310587&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-emplace.rst 
(original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-emplace.rst 
Thu Aug 10 05:54:05 2017
@@ -102,6 +102,18 @@ Options
Semicolon-separated list of class names of custom containers that support
``push_back``.
 
+.. option:: IgnoreImplicitConstructors
+
+When non-zero, the check will ignore implicitly constructed arguments of
+``push_back``, e.g.
+
+.. code-block:: c++
+
+std::vector v;
+v.push_back("a"); // Ignored when IgnoreImplicitConstructors is ``1``.
+
+Default is ``0``.
+
 .. option:: SmartPointers
 
Semicolon-separated list of class names of custom smart pointers.


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


Re: [clang-tools-extra] r310584 - [clang-tidy] Add modernize-use-emplace.IgnoreImplicitConstructors option

2017-08-10 Thread Alexander Kornienko via cfe-commits
Thanks for noticing this! Committed in r310587.

On Thu, Aug 10, 2017 at 2:33 PM, Haojian Wu  wrote:

> I think you also need to add the doc for the option in
> modernize-use-emplace.rst.
>
> On Thu, Aug 10, 2017 at 2:19 PM, Alexander Kornienko via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: alexfh
>> Date: Thu Aug 10 05:19:05 2017
>> New Revision: 310584
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=310584&view=rev
>> Log:
>> [clang-tidy] Add modernize-use-emplace.IgnoreImplicitConstructors option
>>
>> Added:
>> clang-tools-extra/trunk/test/clang-tidy/modernize-use-emplac
>> e-ignore-implicit-constructors.cpp
>> Modified:
>> clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp
>> clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.h
>>
>> Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck
>> .cpp
>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>> clang-tidy/modernize/UseEmplaceCheck.cpp?rev=310584&r1=
>> 310583&r2=310584&view=diff
>> 
>> ==
>> --- clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp
>> (original)
>> +++ clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.cpp Thu
>> Aug 10 05:19:05 2017
>> @@ -30,6 +30,7 @@ const auto DefaultTupleMakeFunctions = "
>>
>>  UseEmplaceCheck::UseEmplaceCheck(StringRef Name, ClangTidyContext
>> *Context)
>>  : ClangTidyCheck(Name, Context),
>> +  IgnoreImplicitConstructors(Options.get("IgnoreImplicitConstructors",
>> 0)),
>>ContainersWithPushBack(utils::options::parseStringList(Opti
>> ons.get(
>>"ContainersWithPushBack", DefaultContainersWithPushBack))),
>>SmartPointers(utils::options::parseStringList(
>> @@ -120,9 +121,13 @@ void UseEmplaceCheck::registerMatchers(M
>>
>>  void UseEmplaceCheck::check(const MatchFinder::MatchResult &Result) {
>>const auto *Call = Result.Nodes.getNodeAs("call");
>> -  const auto *InnerCtorCall = Result.Nodes.getNodeAs> tructExpr>("ctor");
>> +  const auto *CtorCall = Result.Nodes.getNodeAs> tructExpr>("ctor");
>>const auto *MakeCall = Result.Nodes.getNodeAs("make");
>> -  assert((InnerCtorCall || MakeCall) && "No push_back parameter
>> matched");
>> +  assert((CtorCall || MakeCall) && "No push_back parameter matched");
>> +
>> +  if (IgnoreImplicitConstructors && CtorCall && CtorCall->getNumArgs()
>> >= 1 &&
>> +  CtorCall->getArg(0)->getSourceRange() ==
>> CtorCall->getSourceRange())
>> +return;
>>
>>const auto FunctionNameSourceRange = CharSourceRange::getCharRange(
>>Call->getExprLoc(), Call->getArg(0)->getExprLoc());
>> @@ -138,14 +143,14 @@ void UseEmplaceCheck::check(const MatchF
>>const SourceRange CallParensRange =
>>MakeCall ? SourceRange(MakeCall->getCallee()->getLocEnd(),
>>   MakeCall->getRParenLoc())
>> -   : InnerCtorCall->getParenOrBraceRange();
>> +   : CtorCall->getParenOrBraceRange();
>>
>>// Finish if there is no explicit constructor call.
>>if (CallParensRange.getBegin().isInvalid())
>>  return;
>>
>>const SourceLocation ExprBegin =
>> -  MakeCall ? MakeCall->getExprLoc() : InnerCtorCall->getExprLoc();
>> +  MakeCall ? MakeCall->getExprLoc() : CtorCall->getExprLoc();
>>
>>// Range for constructor name and opening brace.
>>const auto ParamCallSourceRange =
>>
>> Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.h
>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>> clang-tidy/modernize/UseEmplaceCheck.h?rev=310584&r1=310583&
>> r2=310584&view=diff
>> 
>> ==
>> --- clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.h
>> (original)
>> +++ clang-tools-extra/trunk/clang-tidy/modernize/UseEmplaceCheck.h Thu
>> Aug 10 05:19:05 2017
>> @@ -33,10 +33,11 @@ public:
>>void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
>>
>>  private:
>> -  std::vector ContainersWithPushBack;
>> -  std::vector SmartPointers;
>> -  std::vector TupleTypes;
>> -  std::vector TupleMakeFunctions;
>> +  const bool IgnoreImplicitConstructors;
>> +  const std::vector ContainersWithPushBack;
>> +  const std::vector SmartPointers;
>> +  const std::vector TupleTypes;
>> +  const std::vector TupleMakeFunctions;
>>  };
>>
>>  } // namespace modernize
>>
>> Added: clang-tools-extra/trunk/test/clang-tidy/modernize-use-emplac
>> e-ignore-implicit-constructors.cpp
>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>> test/clang-tidy/modernize-use-emplace-ignore-implicit-
>> constructors.cpp?rev=310584&view=auto
>> 
>> ==
>> --- clang-tools-extra/trunk/test/clang-tidy/modernize-use-emplac
>> e-ignore-implicit-constructors.cpp (added)
>> +++ clang-tools-extra/trunk/test/clang

[PATCH] D35932: [clang-tidy] Add integer division check

2017-08-10 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG


https://reviews.llvm.org/D35932



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


[PATCH] D36551: [mips] Show warning in case of mixing -mlong-calls and -mabicalls options

2017-08-10 Thread Simon Dardis via Phabricator via cfe-commits
sdardis added inline comments.



Comment at: test/Driver/mips-longcalls-warning.c:1
+// REQUIRES: mips-registered-target
+// RUN: %clang -### -c -target mips-mti-elf -mlong-calls %s 2>&1 | FileCheck 
-check-prefix=IMPLICIT %s

Can you put this in test/Driver/mips-abicalls-warning.c from the other patch? 
I'd prefer to keep all the abicalls warnings together rather than separate 
tests based on the feature the conflict with.


Repository:
  rL LLVM

https://reviews.llvm.org/D36551



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


[PATCH] D35372: [clang-tidy] Refactor the code and add a close-on-exec check on memfd_create() in Android module.

2017-08-10 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG with a few nits.




Comment at: clang-tidy/android/CloexecCheck.cpp:49
+  Finder->addMatcher(
+  ast_matchers::callExpr(
+  ast_matchers::callee(

No need to qualify names in `ast_matchers::`, since there's a using directive 
above.



Comment at: clang-tidy/android/CloexecCheck.h:38
+   ast_matchers::internal::Matcher Function);
+  /// Currently, we have three types of fixes.
+  ///

nit: Please add an empty line before this comment.



Comment at: clang-tidy/android/CloexecCheck.h:54
+  void insertMacroFlag(const ast_matchers::MatchFinder::MatchResult &Result,
+   const StringRef MarcoFlag, const int ArgPos);
+

Please remove top-level const from the last two arguments. It has no effect in 
declaration (and definition can still use top-level const, if needed, since it 
is not a part of the function signature). Same below.


https://reviews.llvm.org/D35372



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


[PATCH] D36551: [mips] Show warning in case of mixing -mlong-calls and -mabicalls options

2017-08-10 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan added inline comments.



Comment at: test/Driver/mips-longcalls-warning.c:1
+// REQUIRES: mips-registered-target
+// RUN: %clang -### -c -target mips-mti-elf -mlong-calls %s 2>&1 | FileCheck 
-check-prefix=IMPLICIT %s

sdardis wrote:
> Can you put this in test/Driver/mips-abicalls-warning.c from the other patch? 
> I'd prefer to keep all the abicalls warnings together rather than separate 
> tests based on the feature the conflict with.
> Can you put this in test/Driver/mips-abicalls-warning.c from the other patch?

I can, but in that case it's probably better to join both patches because that 
patch loses its test.



Repository:
  rL LLVM

https://reviews.llvm.org/D36551



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


[PATCH] D36551: [mips] Show warning in case of mixing -mlong-calls and -mabicalls options

2017-08-10 Thread Simon Dardis via Phabricator via cfe-commits
sdardis accepted this revision.
sdardis added a comment.
This revision is now accepted and ready to land.

LGTM.




Comment at: test/Driver/mips-longcalls-warning.c:1
+// REQUIRES: mips-registered-target
+// RUN: %clang -### -c -target mips-mti-elf -mlong-calls %s 2>&1 | FileCheck 
-check-prefix=IMPLICIT %s

atanasyan wrote:
> sdardis wrote:
> > Can you put this in test/Driver/mips-abicalls-warning.c from the other 
> > patch? I'd prefer to keep all the abicalls warnings together rather than 
> > separate tests based on the feature the conflict with.
> > Can you put this in test/Driver/mips-abicalls-warning.c from the other 
> > patch?
> 
> I can, but in that case it's probably better to join both patches because 
> that patch loses its test.
> 
You can do it as an NFC change afterward both commits in that case.


Repository:
  rL LLVM

https://reviews.llvm.org/D36551



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


[PATCH] D36551: [mips] Show warning in case of mixing -mlong-calls and -mabicalls options

2017-08-10 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan added inline comments.



Comment at: test/Driver/mips-longcalls-warning.c:1
+// REQUIRES: mips-registered-target
+// RUN: %clang -### -c -target mips-mti-elf -mlong-calls %s 2>&1 | FileCheck 
-check-prefix=IMPLICIT %s

sdardis wrote:
> atanasyan wrote:
> > sdardis wrote:
> > > Can you put this in test/Driver/mips-abicalls-warning.c from the other 
> > > patch? I'd prefer to keep all the abicalls warnings together rather than 
> > > separate tests based on the feature the conflict with.
> > > Can you put this in test/Driver/mips-abicalls-warning.c from the other 
> > > patch?
> > 
> > I can, but in that case it's probably better to join both patches because 
> > that patch loses its test.
> > 
> You can do it as an NFC change afterward both commits in that case.
OK. Thanks for review.


Repository:
  rL LLVM

https://reviews.llvm.org/D36551



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


[PATCH] D36550: [mips] Notify user that `-mabicalls` is ignored on non-PIC N64 ABI

2017-08-10 Thread Simon Dardis via Phabricator via cfe-commits
sdardis added a comment.

Nit: my comment on line 297,  "non position-independent code and N64 ABI" 
should be "non position-independent code and the N64 ABI".

LGTM otherwise.


Repository:
  rL LLVM

https://reviews.llvm.org/D36550



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


[clang-tools-extra] r310589 - [clang-tidy] Add integer division check

2017-08-10 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Thu Aug 10 06:30:30 2017
New Revision: 310589

URL: http://llvm.org/viewvc/llvm-project?rev=310589&view=rev
Log:
[clang-tidy] Add integer division check

Patch by: Reka Nikolett Kovacs

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

Added:
clang-tools-extra/trunk/clang-tidy/bugprone/IntegerDivisionCheck.cpp
clang-tools-extra/trunk/clang-tidy/bugprone/IntegerDivisionCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-integer-division.rst
clang-tools-extra/trunk/test/clang-tidy/bugprone-integer-division.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp?rev=310589&r1=310588&r2=310589&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp Thu Aug 
10 06:30:30 2017
@@ -10,6 +10,7 @@
 #include "../ClangTidy.h"
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
+#include "IntegerDivisionCheck.h"
 #include "SuspiciousMemsetUsageCheck.h"
 #include "UndefinedMemoryManipulationCheck.h"
 
@@ -20,6 +21,8 @@ namespace bugprone {
 class BugproneModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck(
+"bugprone-integer-division");
 CheckFactories.registerCheck(
 "bugprone-suspicious-memset-usage");
 CheckFactories.registerCheck(

Modified: clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt?rev=310589&r1=310588&r2=310589&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt Thu Aug 10 
06:30:30 2017
@@ -2,6 +2,7 @@ set(LLVM_LINK_COMPONENTS support)
 
 add_clang_library(clangTidyBugproneModule
   BugproneTidyModule.cpp
+  IntegerDivisionCheck.cpp
   SuspiciousMemsetUsageCheck.cpp
   UndefinedMemoryManipulationCheck.cpp
 

Added: clang-tools-extra/trunk/clang-tidy/bugprone/IntegerDivisionCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/IntegerDivisionCheck.cpp?rev=310589&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/IntegerDivisionCheck.cpp (added)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/IntegerDivisionCheck.cpp Thu 
Aug 10 06:30:30 2017
@@ -0,0 +1,57 @@
+//===--- IntegerDivisionCheck.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 "IntegerDivisionCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace bugprone {
+
+void IntegerDivisionCheck::registerMatchers(MatchFinder *Finder) {
+  const auto IntType = hasType(isInteger());
+
+  const auto BinaryOperators = binaryOperator(anyOf(
+  hasOperatorName("%"), hasOperatorName("<<"), hasOperatorName(">>"),
+  hasOperatorName("<<"), hasOperatorName("^"), hasOperatorName("|"),
+  hasOperatorName("&"), hasOperatorName("||"), hasOperatorName("&&"),
+  hasOperatorName("<"), hasOperatorName(">"), hasOperatorName("<="),
+  hasOperatorName(">="), hasOperatorName("=="), hasOperatorName("!=")));
+
+  const auto UnaryOperators =
+  unaryOperator(anyOf(hasOperatorName("~"), hasOperatorName("!")));
+
+  const auto Exceptions =
+  anyOf(BinaryOperators, conditionalOperator(), 
binaryConditionalOperator(),
+callExpr(IntType), explicitCastExpr(IntType), UnaryOperators);
+
+  Finder->addMatcher(
+  binaryOperator(
+  hasOperatorName("/"), hasLHS(expr(IntType)), hasRHS(expr(IntType)),
+  hasAncestor(
+  castExpr(hasCastKind(CK_IntegralToFloating)).bind("FloatCast")),
+  unless(hasAncestor(
+  expr(Exceptions,
+   hasAncestor(castExpr(equalsBoundNode("FloatCast")))
+  .bind("IntDiv"),
+  this);
+}
+
+void IntegerDivisionCheck::check(const MatchFinder::MatchResult &Result) {
+  const aut

[PATCH] D35932: [clang-tidy] Add integer division check

2017-08-10 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310589: [clang-tidy] Add integer division check (authored by 
xazax).

Changed prior to commit:
  https://reviews.llvm.org/D35932?vs=110539&id=110570#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35932

Files:
  clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/bugprone/IntegerDivisionCheck.cpp
  clang-tools-extra/trunk/clang-tidy/bugprone/IntegerDivisionCheck.h
  clang-tools-extra/trunk/docs/ReleaseNotes.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-integer-division.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  clang-tools-extra/trunk/test/clang-tidy/bugprone-integer-division.cpp

Index: clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt
===
--- clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt
+++ clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt
@@ -2,6 +2,7 @@
 
 add_clang_library(clangTidyBugproneModule
   BugproneTidyModule.cpp
+  IntegerDivisionCheck.cpp
   SuspiciousMemsetUsageCheck.cpp
   UndefinedMemoryManipulationCheck.cpp
 
Index: clang-tools-extra/trunk/clang-tidy/bugprone/IntegerDivisionCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/bugprone/IntegerDivisionCheck.h
+++ clang-tools-extra/trunk/clang-tidy/bugprone/IntegerDivisionCheck.h
@@ -0,0 +1,36 @@
+//===--- IntegerDivisionCheck.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_BUGPRONE_INTEGER_DIVISION_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_INTEGER_DIVISION_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace bugprone {
+
+/// Finds cases where integer division in a floating point context is likely to
+/// cause unintended loss of precision.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/bugprone-integer-division.html
+class IntegerDivisionCheck : public ClangTidyCheck {
+public:
+  IntegerDivisionCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace bugprone
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_INTEGER_DIVISION_H
Index: clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp
===
--- clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -10,6 +10,7 @@
 #include "../ClangTidy.h"
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
+#include "IntegerDivisionCheck.h"
 #include "SuspiciousMemsetUsageCheck.h"
 #include "UndefinedMemoryManipulationCheck.h"
 
@@ -20,6 +21,8 @@
 class BugproneModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck(
+"bugprone-integer-division");
 CheckFactories.registerCheck(
 "bugprone-suspicious-memset-usage");
 CheckFactories.registerCheck(
Index: clang-tools-extra/trunk/clang-tidy/bugprone/IntegerDivisionCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/bugprone/IntegerDivisionCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/bugprone/IntegerDivisionCheck.cpp
@@ -0,0 +1,57 @@
+//===--- IntegerDivisionCheck.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 "IntegerDivisionCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace bugprone {
+
+void IntegerDivisionCheck::registerMatchers(MatchFinder *Finder) {
+  const auto IntType = hasType(isInteger());
+
+  const auto BinaryOperators = binaryOperator(anyOf(
+  hasOperatorName("%"), hasOperatorName("<<"), hasOperatorName(">>"),
+  hasOperatorName("<<"), hasOperatorName("^"), hasOperatorName("|"),
+  hasOperatorName("&"), has

[PATCH] D29660: [OpenMP] Add flag for overwriting default PTX version for OpenMP targets

2017-08-10 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added a comment.

Hi Alex,

I have no idea what the errors you mention are. I worked until very late last 
night to fix the previous error with the compute capability. Maybe fixing that 
unlocked some other errors.

I would need a lot of help to figure out what's going on since I probably can't 
reproduce them locally. At the moment the turnaround time for getting feedback 
for these errors is way too long since I have to wait for the entire test suite 
to run every time I push something. Could you run everything you reverted 
locally and check what each failing compile line produces please? Being able to 
see the output is the first line of attack. I would also need to know what GPUs 
you have on the test systems that fail: which compute capability they support, 
what CUDA version you have installed if any etc.

I am extremely pressed for time so I need to land these patches as soon as 
possible - today at the latest.

Thanks a lot for your help,

--Doru


Repository:
  rL LLVM

https://reviews.llvm.org/D29660



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


[PATCH] D36580: [OpenCL] Support variable memory scope in atomic builtins

2017-08-10 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.

https://reviews.llvm.org/D36580

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/SyncScope.h
  lib/CodeGen/CGAtomic.cpp
  lib/Sema/SemaChecking.cpp
  test/CodeGenOpenCL/atomic-ops-libcall.cl
  test/CodeGenOpenCL/atomic-ops.cl
  test/SemaOpenCL/atomic-ops.cl

Index: test/SemaOpenCL/atomic-ops.cl
===
--- test/SemaOpenCL/atomic-ops.cl
+++ test/SemaOpenCL/atomic-ops.cl
@@ -151,7 +151,7 @@
   (void)__opencl_atomic_load(Ap, memory_order_relaxed, memory_scope_device);
   (void)__opencl_atomic_load(Ap, memory_order_relaxed, memory_scope_all_svm_devices);
   (void)__opencl_atomic_load(Ap, memory_order_relaxed, memory_scope_sub_group);
-  (void)__opencl_atomic_load(Ap, memory_order_relaxed, scope); // expected-error{{non-constant synchronization scope argument to atomic operation is not supported}}
+  (void)__opencl_atomic_load(Ap, memory_order_relaxed, scope);
   (void)__opencl_atomic_load(Ap, memory_order_relaxed, 10);//expected-error{{synchronization scope argument to atomic operation is invalid}}
 }
 
Index: test/CodeGenOpenCL/atomic-ops.cl
===
--- test/CodeGenOpenCL/atomic-ops.cl
+++ test/CodeGenOpenCL/atomic-ops.cl
@@ -52,6 +52,81 @@
   return __opencl_atomic_compare_exchange_strong(i, &cmp, 1, memory_order_acquire, memory_order_acquire, memory_scope_work_group);
 }
 
+void fi5(atomic_int *i, int scope) {
+  // CHECK-LABEL: @fi5
+  // CHECK: switch i32 %{{.*}}, label %opencl_allsvmdevices [
+  // CHECK-NEXT: i32 1, label %opencl_workgroup
+  // CHECK-NEXT: i32 2, label %opencl_device
+  // CHECK-NEXT: i32 4, label %opencl_subgroup
+  // CHECK-NEXT: ]
+  // CHECK: opencl_workgroup:
+  // CHECK: load atomic i32, i32 addrspace(4)* %{{.*}} syncscope("workgroup") seq_cst
+  // CHECK: br label %atomic.scope.continue
+  // CHECK: opencl_device:
+  // CHECK: load atomic i32, i32 addrspace(4)* %{{.*}} syncscope("agent") seq_cst
+  // CHECK: br label %atomic.scope.continue
+  // CHECK: opencl_allsvmdevices:
+  // CHECK: load atomic i32, i32 addrspace(4)* %{{.*}} seq_cst, align 4
+  // CHECK: br label %atomic.scope.continue
+  // CHECK: opencl_subgroup:
+  // CHECK: %5 = load atomic i32, i32 addrspace(4)* %0 syncscope("subgroup") seq_cst, align 4
+  // CHECK: br label %atomic.scope.continue
+  // CHECK: atomic.scope.continue:
+  int x = __opencl_atomic_load(i, memory_order_seq_cst, scope);
+}
+
+void fi6(atomic_int *i, int order, int scope) {
+  // CHECK-LABEL: @fi6
+  // CHECK: switch i32 %{{.*}}, label %monotonic [
+  // CHECK-NEXT: i32 1, label %acquire
+  // CHECK-NEXT: i32 2, label %acquire
+  // CHECK-NEXT: i32 5, label %seqcst
+  // CHECK-NEXT: ]
+  // CHECK: monotonic:
+  // CHECK: switch i32 %{{.*}}, label %[[MON_ALL:.*]] [
+  // CHECK-NEXT: i32 1, label %[[MON_WG:.*]]
+  // CHECK-NEXT: i32 2, label %[[MON_DEV:.*]]
+  // CHECK-NEXT: i32 4, label %[[MON_SUB:.*]]
+  // CHECK-NEXT: ]
+  // CHECK: acquire:
+  // CHECK: switch i32 %{{.*}}, label %[[ACQ_ALL:.*]] [
+  // CHECK-NEXT: i32 1, label %[[ACQ_WG:.*]]
+  // CHECK-NEXT: i32 2, label %[[ACQ_DEV:.*]]
+  // CHECK-NEXT: i32 4, label %[[ACQ_SUB:.*]]
+  // CHECK-NEXT: ]
+  // CHECK: seqcst:
+  // CHECK: switch i32 %2, label %[[SEQ_ALL:.*]] [
+  // CHECK-NEXT: i32 1, label %[[SEQ_WG:.*]]
+  // CHECK-NEXT: i32 2, label %[[SEQ_DEV:.*]]
+  // CHECK-NEXT: i32 4, label %[[SEQ_SUB:.*]]
+  // CHECK-NEXT: ]
+  // CHECK: [[MON_WG]]:
+  // CHECK: load atomic i32, i32 addrspace(4)* %{{.*}} syncscope("workgroup") monotonic
+  // CHECK: [[MON_DEV]]:
+  // CHECK: load atomic i32, i32 addrspace(4)* %{{.*}} syncscope("agent") monotonic
+  // CHECK: [[MON_ALL]]:
+  // CHECK: load atomic i32, i32 addrspace(4)* %{{.*}} monotonic
+  // CHECK: [[MON_SUB]]:
+  // CHECK: load atomic i32, i32 addrspace(4)* %{{.*}} syncscope("subgroup") monotonic
+  // CHECK: [[ACQ_WG]]:
+  // CHECK: load atomic i32, i32 addrspace(4)* %{{.*}} syncscope("workgroup") acquire
+  // CHECK: [[ACQ_DEV]]:
+  // CHECK: load atomic i32, i32 addrspace(4)* %{{.*}} syncscope("agent") acquire
+  // CHECK: [[ACQ_ALL]]:
+  // CHECK: load atomic i32, i32 addrspace(4)* %{{.*}} acquire
+  // CHECK: [[ACQ_SUB]]:
+  // CHECK: load atomic i32, i32 addrspace(4)* %{{.*}} syncscope("subgroup") acquire
+  // CHECK: [[SEQ_WG]]:
+  // CHECK: load atomic i32, i32 addrspace(4)* %{{.*}} syncscope("workgroup") seq_cst
+  // CHECK: [[SEQ_DEV]]:
+  // CHECK: load atomic i32, i32 addrspace(4)* %{{.*}} syncscope("agent") seq_cst
+  // CHECK: [[SEQ_ALL]]:
+  // CHECK: load atomic i32, i32 addrspace(4)* %{{.*}} seq_cst
+  // CHECK: [[SEQ_SUB]]:
+  // CHECK: load atomic i32, i32 addrspace(4)* %{{.*}} syncscope("subgroup") seq_cst
+  int x = __opencl_atomic_load(i, order, scope);
+}
+
 float ff1(global atomic_float *d) {
   // CHECK-LABEL: @ff1
   // CHECK: load atomic i32, i32 addrspace(1)* {{.*}} syncscope("workgroup") monotonic
Index: test/CodeGenOpenCL/atomi

[PATCH] D36492: [RFC][time-report] Add preprocessor timer

2017-08-10 Thread Brian Gesiak via Phabricator via cfe-commits
modocache added a reviewer: vsk.
modocache planned changes to this revision.
modocache added a comment.

Thanks for the feedback, @vsk, I really appreciate it! I have some other work 
done for this on my local checkout, but I was going a little bonkers working on 
it without knowing whether people would want it merged or not. I'll update this 
with your feedback and upload the rest for review as well.

> It'd be nice to dump this timer from Preprocessor::PrintStats(), too.

Good idea, will do!




Comment at: lib/Lex/Preprocessor.cpp:660
 
+  llvm::TimeRegion(PPOpts->ShowTimers ? &PreprocessingTimer : nullptr);
+

vsk wrote:
> vsk wrote:
> > I wonder whether this is too fine-grained. I think setting up a timer in 
> > Preprocessor::Lex() might capture more information. Would you mind 
> > experimenting with that?
> Nitpick: it may be useful to add PPOpts::getTimer(), in case we find more 
> sites where we need to either get back the PP timer or nullptr.
> I think setting up a timer in `Preprocessor::Lex()` might capture more 
> information.

Yes, can do! As it happens, the timers in this current diff cover all of the 
event counters that are incremented and then printed in  
`Preprocessor::PrintStats()`, except two: `NumTokenPaste` and 
`NumFastTokenPaste`. Beginning the timer in the Lexer would allow me to measure 
the time it takes to do token pasting as well, so I think this is a great idea. 
Thanks!

> it may be useful to add `PPOpts::getTimer()`

Agreed, will do!


https://reviews.llvm.org/D36492



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


[PATCH] D32896: [OpenCL] Make CLK_NULL_RESERVE_ID invalid reserve id.

2017-08-10 Thread Alexey Bader via Phabricator via cfe-commits
bader added inline comments.



Comment at: lib/Headers/opencl-c.h:16020
+// The macro CLK_NULL_RESERVE_ID refers to an invalid reservation ID.
+#define CLK_NULL_RESERVE_ID (__builtin_astype((void *)0, reserve_id_t))
 bool __ovld is_valid_reserve_id(reserve_id_t reserve_id);

b-sumner wrote:
> yaxunl wrote:
> > bader wrote:
> > > yaxunl wrote:
> > > > bader wrote:
> > > > > yaxunl wrote:
> > > > > > bader wrote:
> > > > > > > yaxunl wrote:
> > > > > > > > yaxunl wrote:
> > > > > > > > > bader wrote:
> > > > > > > > > > yaxunl wrote:
> > > > > > > > > > > Anastasia wrote:
> > > > > > > > > > > > echuraev wrote:
> > > > > > > > > > > > > yaxunl wrote:
> > > > > > > > > > > > > > Anastasia wrote:
> > > > > > > > > > > > > > > yaxunl wrote:
> > > > > > > > > > > > > > > > Anastasia wrote:
> > > > > > > > > > > > > > > > > Looks good from my side.
> > > > > > > > > > > > > > > > > 
> > > > > > > > > > > > > > > > > @yaxunl , since you originally committed 
> > > > > > > > > > > > > > > > > this. Could you please verify that changing 
> > > > > > > > > > > > > > > > > from `SIZE_MAX` to `0` would be fine.
> > > > > > > > > > > > > > > > > 
> > > > > > > > > > > > > > > > > Btw, we have a similar definition for 
> > > > > > > > > > > > > > > > > `CLK_NULL_EVENT`.
> > > > > > > > > > > > > > > > `__PIPE_RESERVE_ID_VALID_BIT` is implementation 
> > > > > > > > > > > > > > > > detail and not part of the spec. I would 
> > > > > > > > > > > > > > > > suggest to remove it from this header file.
> > > > > > > > > > > > > > > > 
> > > > > > > > > > > > > > > > The spec only requires CLK_NULL_RESERVE_ID to 
> > > > > > > > > > > > > > > > be defined but does not define its value. 
> > > > > > > > > > > > > > > > Naturally a valid id starts from 0 and 
> > > > > > > > > > > > > > > > increases. I don't see significant advantage to 
> > > > > > > > > > > > > > > > change CLK_NULL_RESERVE_ID from __SIZE_MAX to 0.
> > > > > > > > > > > > > > > > 
> > > > > > > > > > > > > > > > Is there any reason that this change is needed?
> > > > > > > > > > > > > > > I don't see issues to commit things outside of 
> > > > > > > > > > > > > > > spec as soon as they prefixed properly with "__". 
> > > > > > > > > > > > > > >  But I agree it would be nice to see if it's any 
> > > > > > > > > > > > > > > useful and what the motivation is for having 
> > > > > > > > > > > > > > > different implementation.
> > > > > > > > > > > > > > For `__PIPE_RESERVE_ID_VALID_BIT`, it assumes that 
> > > > > > > > > > > > > > the implementation uses one specific bit of a 
> > > > > > > > > > > > > > reserve id to indicate that the reserve id is 
> > > > > > > > > > > > > > valid. Not all implementations assume that. 
> > > > > > > > > > > > > > Actually I am curious why that is needed too.
> > > > > > > > > > > > > About `CLK_NULL_RESERVE_ID`: we check that reserve id 
> > > > > > > > > > > > > is valid if significant bit equal to one. 
> > > > > > > > > > > > > `CLK_NULL_RESERVE_ID refers to an invalid 
> > > > > > > > > > > > > reservation, so if `CLK_NULL_RESERVE_ID equal to 0, 
> > > > > > > > > > > > > we can be sure that significant bit doesn't equal to 
> > > > > > > > > > > > > 1 and it is invalid reserve id. Also it is more 
> > > > > > > > > > > > > obviously if CLK_**NULL**_RESERVE_ID is equal to 0.
> > > > > > > > > > > > > 
> > > > > > > > > > > > > What about `__PIPE_RESERVE_ID_VALID_BIT`: As I 
> > > > > > > > > > > > > understand previous implementation also assumes that 
> > > > > > > > > > > > > one specific bit was of a reverse id was used to 
> > > > > > > > > > > > > indicate that the reserve id is valid. So, we just 
> > > > > > > > > > > > > increased reserve id size by one bit on 32-bit 
> > > > > > > > > > > > > platforms and by 33 bits on 64-bit platforms. 
> > > > > > > > > > > > It is more logical to me that `CLK_NULL_RESERVE_ID` is 
> > > > > > > > > > > > 0, but spec doesn't define it of course.
> > > > > > > > > > > In our implementation, valid reserve id starts at 0 and 
> > > > > > > > > > > increasing linearly until `__SIZE_MAX-1`. This change 
> > > > > > > > > > > will break our implementation.
> > > > > > > > > > > 
> > > > > > > > > > > However, we can modify our implementation to adopt this 
> > > > > > > > > > > change since it brings about benefits overall.
> > > > > > > > > > Ideally it would be great to have unified implementation, 
> > > > > > > > > > but we can define device specific value for 
> > > > > > > > > > CLK_NULL_RESERVE_ID by using ifdef directive.
> > > > > > > > > How about
> > > > > > > > > 
> > > > > > > > > ```
> > > > > > > > > __attribute__((const)) size_t __clk_null_reserve_id();
> > > > > > > > > #define CLK_NULL_RESERVE_ID __clk_null_reserve_id()
> > > > > > > > > 
> > > > > > > > > ```
> > > > > > > > > I think the spec does not require it to be compile time 
> > > > > > > > > constant. Then each library can implement its own 
> > > > > > > > > __clk_null_res

r310600 - [sanitizer-coverage] Change cmp instrumentation to distinguish const operands

2017-08-10 Thread Alexander Potapenko via cfe-commits
Author: glider
Date: Thu Aug 10 08:00:13 2017
New Revision: 310600

URL: http://llvm.org/viewvc/llvm-project?rev=310600&view=rev
Log:
[sanitizer-coverage] Change cmp instrumentation to distinguish const operands

This implementation of SanitizerCoverage instrumentation inserts different
callbacks depending on constantness of operands:

  1. If both operands are non-const, then a usual
 __sanitizer_cov_trace_cmp[1248] call is inserted.
  2. If exactly one operand is const, then a
 __sanitizer_cov_trace_const_cmp[1248] call is inserted. The first
 argument of the call is always the constant one.
  3. If both operands are const, then no callback is inserted.

This separation comes useful in fuzzing when tasks like "find one operand
of the comparison in input arguments and replace it with the other one"
have to be done. The new instrumentation allows us to not waste time on
searching the constant operands in the input.

Patch by Victor Chibotaru.

Modified:
cfe/trunk/docs/SanitizerCoverage.rst

Modified: cfe/trunk/docs/SanitizerCoverage.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/SanitizerCoverage.rst?rev=310600&r1=310599&r2=310600&view=diff
==
--- cfe/trunk/docs/SanitizerCoverage.rst (original)
+++ cfe/trunk/docs/SanitizerCoverage.rst Thu Aug 10 08:00:13 2017
@@ -211,6 +211,14 @@ the `LLVM GEP instructions 

[PATCH] D34508: [Analyzer] Bug Reporter Visitor to Display Values of Variables - PRELIMINARY!

2017-08-10 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

In https://reviews.llvm.org/D34508#791048, @NoQ wrote:

> Currently, we already highlight the last assignments for the "interesting" 
> variables, which is implemented through, for example, 
> `bugreporter::trackNullOrUndefValue()` - see how various checkers use it. 
> This is, of course, far from perfect as well, because it's very hard to 
> figure out which variables are of interest.


I think concentrating on "interesting" things would be a great addition to this 
patch. So in case an `elementRegion` is marked as interesting, we could also 
mark the index as interesting automatically and later print out the relevant 
information only for interesting symbols, regions.


https://reviews.llvm.org/D34508



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


[PATCH] D29660: [OpenMP] Add flag for overwriting default PTX version for OpenMP targets

2017-08-10 Thread Aleksey Shlyapnikov via Phabricator via cfe-commits
alekseyshl added a comment.

While I do get the time pressure and such, doing it at the expense of others is 
not cool. Many teams work process is broken for days, folks are busy looking 
into it, investigating and reverting, other breakages are masked by these 
failures etc.

If your test depend on local configuration, you need to be extra careful 
pushing this fragile test. We are lucky, we have bots running continuously, but 
what about others who runs their tests less regularly? What about those who 
pulled LLVM code, built it and trying to run tests before contributing a patch? 
What's your plan to debug those configurations?


Repository:
  rL LLVM

https://reviews.llvm.org/D29660



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


r310605 - [Modules] Prevent #import to reenter header if not building a module.

2017-08-10 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Thu Aug 10 08:16:24 2017
New Revision: 310605

URL: http://llvm.org/viewvc/llvm-project?rev=310605&view=rev
Log:
[Modules] Prevent #import to reenter header if not building a module.

When non-modular headers are imported while not building a module but
in -fmodules mode, be conservative and preserve the default #import
semantic: do not reenter headers.

rdar://problem/33745031

Added:
cfe/trunk/test/Modules/Inputs/import-textual/x.h
cfe/trunk/test/Modules/import-textual-nomodules.m
Modified:
cfe/trunk/lib/Lex/HeaderSearch.cpp

Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=310605&r1=310604&r2=310605&view=diff
==
--- cfe/trunk/lib/Lex/HeaderSearch.cpp (original)
+++ cfe/trunk/lib/Lex/HeaderSearch.cpp Thu Aug 10 08:16:24 2017
@@ -1143,7 +1143,7 @@ bool HeaderSearch::ShouldEnterIncludeFil
 // headers find in the wild might rely only on #import and do not contain
 // controlling macros, be conservative and only try to enter textual 
headers
 // if such macro is present.
-if (!FileInfo.isModuleHeader &&
+if (FileInfo.isCompilingModuleHeader && !FileInfo.isModuleHeader &&
 FileInfo.getControllingMacro(ExternalLookup))
   TryEnterHdr = true;
 return TryEnterHdr;

Added: cfe/trunk/test/Modules/Inputs/import-textual/x.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/import-textual/x.h?rev=310605&view=auto
==
--- cfe/trunk/test/Modules/Inputs/import-textual/x.h (added)
+++ cfe/trunk/test/Modules/Inputs/import-textual/x.h Thu Aug 10 08:16:24 2017
@@ -0,0 +1,6 @@
+#ifndef RANDOM_DEP
+
+@interface X
+@end
+
+#endif // RANDOM_DEP

Added: cfe/trunk/test/Modules/import-textual-nomodules.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/import-textual-nomodules.m?rev=310605&view=auto
==
--- cfe/trunk/test/Modules/import-textual-nomodules.m (added)
+++ cfe/trunk/test/Modules/import-textual-nomodules.m Thu Aug 10 08:16:24 2017
@@ -0,0 +1,8 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fsyntax-only -fmodules -fimplicit-module-maps 
-I%S/Inputs/import-textual -fmodules-cache-path=%t %s -verify
+
+// expected-no-diagnostics
+
+#import "x.h"
+#import "x.h"
+


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


[PATCH] D29660: [OpenMP] Add flag for overwriting default PTX version for OpenMP targets

2017-08-10 Thread Aleksey Shlyapnikov via Phabricator via cfe-commits
alekseyshl added a comment.

Even after all the reverts in r310580, our tests are still failing 
(http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/7080). 
not surprising, but very disrupting. Please have a plan to fix it soon, 
otherwise I'll have to revert it even further.


Repository:
  rL LLVM

https://reviews.llvm.org/D29660



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


[PATCH] D36530: [Parse] Document PrintStats, SkipFunctionBodies

2017-08-10 Thread Brian Gesiak via Phabricator via cfe-commits
modocache added a comment.

Oops, sorry. I couldn't find anyone recent in the commit history. I hope no one 
minds if I just go ahead and commit this.


https://reviews.llvm.org/D36530



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


r310609 - [Parse] Document PrintStats, SkipFunctionBodies

2017-08-10 Thread Brian Gesiak via cfe-commits
Author: modocache
Date: Thu Aug 10 08:30:35 2017
New Revision: 310609

URL: http://llvm.org/viewvc/llvm-project?rev=310609&view=rev
Log:
[Parse] Document PrintStats, SkipFunctionBodies

Summary:
Add documentation for `clang::ParseAST` parameters `PrintStats` and
`SkipFunctionBodies`. Also, remove a tiny bit of trailing whitespace.

Reviewers: craig.topper, doug.gregor, erikjv

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/Parse/ParseAST.h

Modified: cfe/trunk/include/clang/Parse/ParseAST.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/ParseAST.h?rev=310609&r1=310608&r2=310609&view=diff
==
--- cfe/trunk/include/clang/Parse/ParseAST.h (original)
+++ cfe/trunk/include/clang/Parse/ParseAST.h Thu Aug 10 08:30:35 2017
@@ -29,10 +29,13 @@ namespace clang {
   /// This operation inserts the parsed decls into the translation
   /// unit held by Ctx.
   ///
+  /// \param PrintStats Whether to print LLVM statistics related to parsing.
   /// \param TUKind The kind of translation unit being parsed.
-  ///
   /// \param CompletionConsumer If given, an object to consume code completion
   /// results.
+  /// \param SkipFunctionBodies Whether to skip parsing of function bodies.
+  /// This option can be used, for example, to speed up searches for
+  /// delcarations/definitions when indexing.
   void ParseAST(Preprocessor &pp, ASTConsumer *C,
 ASTContext &Ctx, bool PrintStats = false,
 TranslationUnitKind TUKind = TU_Complete,
@@ -43,7 +46,7 @@ namespace clang {
   /// abstract syntax tree.
   void ParseAST(Sema &S, bool PrintStats = false,
 bool SkipFunctionBodies = false);
-  
+
 }  // end namespace clang
 
 #endif


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


[PATCH] D36530: [Parse] Document PrintStats, SkipFunctionBodies

2017-08-10 Thread Brian Gesiak via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310609: [Parse] Document PrintStats, SkipFunctionBodies 
(authored by modocache).

Repository:
  rL LLVM

https://reviews.llvm.org/D36530

Files:
  cfe/trunk/include/clang/Parse/ParseAST.h


Index: cfe/trunk/include/clang/Parse/ParseAST.h
===
--- cfe/trunk/include/clang/Parse/ParseAST.h
+++ cfe/trunk/include/clang/Parse/ParseAST.h
@@ -29,10 +29,13 @@
   /// This operation inserts the parsed decls into the translation
   /// unit held by Ctx.
   ///
+  /// \param PrintStats Whether to print LLVM statistics related to parsing.
   /// \param TUKind The kind of translation unit being parsed.
-  ///
   /// \param CompletionConsumer If given, an object to consume code completion
   /// results.
+  /// \param SkipFunctionBodies Whether to skip parsing of function bodies.
+  /// This option can be used, for example, to speed up searches for
+  /// delcarations/definitions when indexing.
   void ParseAST(Preprocessor &pp, ASTConsumer *C,
 ASTContext &Ctx, bool PrintStats = false,
 TranslationUnitKind TUKind = TU_Complete,
@@ -43,7 +46,7 @@
   /// abstract syntax tree.
   void ParseAST(Sema &S, bool PrintStats = false,
 bool SkipFunctionBodies = false);
-  
+
 }  // end namespace clang
 
 #endif


Index: cfe/trunk/include/clang/Parse/ParseAST.h
===
--- cfe/trunk/include/clang/Parse/ParseAST.h
+++ cfe/trunk/include/clang/Parse/ParseAST.h
@@ -29,10 +29,13 @@
   /// This operation inserts the parsed decls into the translation
   /// unit held by Ctx.
   ///
+  /// \param PrintStats Whether to print LLVM statistics related to parsing.
   /// \param TUKind The kind of translation unit being parsed.
-  ///
   /// \param CompletionConsumer If given, an object to consume code completion
   /// results.
+  /// \param SkipFunctionBodies Whether to skip parsing of function bodies.
+  /// This option can be used, for example, to speed up searches for
+  /// delcarations/definitions when indexing.
   void ParseAST(Preprocessor &pp, ASTConsumer *C,
 ASTContext &Ctx, bool PrintStats = false,
 TranslationUnitKind TUKind = TU_Complete,
@@ -43,7 +46,7 @@
   /// abstract syntax tree.
   void ParseAST(Sema &S, bool PrintStats = false,
 bool SkipFunctionBodies = false);
-  
+
 }  // end namespace clang
 
 #endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29660: [OpenMP] Add flag for overwriting default PTX version for OpenMP targets

2017-08-10 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added a comment.

First of all, I apologize if I've upset you with my previous post. I am 
actively working on understanding what is causing these issues. It is not my 
intention to write tests that work on local configurations only. I am upset to 
see that these tests keep failing for your and maybe other configurations. 
Without knowing the actual reason of the failures I can only speculate what is 
going wrong with them hence the flurry of changes.


Repository:
  rL LLVM

https://reviews.llvm.org/D29660



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


Re: [clang-tools-extra] r310559 - [clang-tidy] Minor documentation improvement

2017-08-10 Thread Alexander Kornienko via cfe-commits
On Thu, Aug 10, 2017 at 11:13 AM, Gabor Horvath via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: xazax
> Date: Thu Aug 10 02:13:26 2017
> New Revision: 310559
>
> URL: http://llvm.org/viewvc/llvm-project?rev=310559&view=rev
> Log:
> [clang-tidy] Minor documentation improvement
>
> Patch by: Lilla Barancsuk
>
> Modified:
> clang-tools-extra/trunk/docs/clang-tidy/checks/readability-
> static-accessed-through-instance.rst
> clang-tools-extra/trunk/test/clang-tidy/readability-static-
> accessed-through-instance.cpp
>
> Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/readability-
> static-accessed-through-instance.rst
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/docs/clang-tidy/checks/readability-static-accessed-
> through-instance.rst?rev=310559&r1=310558&r2=310559&view=diff
> 
> ==
> --- clang-tools-extra/trunk/docs/clang-tidy/checks/readability-
> static-accessed-through-instance.rst (original)
> +++ clang-tools-extra/trunk/docs/clang-tidy/checks/readability-
> static-accessed-through-instance.rst Thu Aug 10 02:13:26 2017
> @@ -25,6 +25,7 @@ is changed to:
>
>  .. code-block:: c++
>
> +  C *c1 = new C();
>C::foo();
>C::x;
>
>
> Modified: clang-tools-extra/trunk/test/clang-tidy/readability-static-
> accessed-through-instance.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/test/clang-tidy/readability-static-accessed-
> through-instance.cpp?rev=310559&r1=310558&r2=310559&view=diff
> 
> ==
> --- 
> clang-tools-extra/trunk/test/clang-tidy/readability-static-accessed-through-instance.cpp
> (original)
> +++ 
> clang-tools-extra/trunk/test/clang-tidy/readability-static-accessed-through-instance.cpp
> Thu Aug 10 02:13:26 2017
> @@ -116,7 +116,7 @@ using E = D;
>
>  template  void f(T t, C c) {
>t.x; // OK, t is a template parameter.
> -  c.x; // 1
> +  c.x;
>

This comment was there to make the CHECK-FIXES line unique so that it
doesn't match wrong line in the test. Any specific reason to remove it?


>// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: static member
>// CHECK-FIXES: {{^}}  C::x; // 1{{$}}
>  }
>
>
> ___
> 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


r310614 - [mips] Show warning in case of mixing -mlong-calls and -mabicalls options

2017-08-10 Thread Simon Atanasyan via cfe-commits
Author: atanasyan
Date: Thu Aug 10 08:42:25 2017
New Revision: 310614

URL: http://llvm.org/viewvc/llvm-project?rev=310614&view=rev
Log:
[mips] Show warning in case of mixing -mlong-calls and -mabicalls options

While we do not support `-mshared / -mno-shared` properly, show warning
and ignore `-mlong-calls` option in case of implicitly or explicitly
provided `-mabicalls` option.

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

Added:
cfe/trunk/test/Driver/mips-longcalls-warning.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
cfe/trunk/test/Driver/mips-features.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=310614&r1=310613&r2=310614&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Thu Aug 10 08:42:25 
2017
@@ -292,6 +292,10 @@ def warn_drv_unsupported_gpopt : Warning
   "ignoring '-mgpopt' option as it cannot be used with %select{|the implicit"
   " usage of }0-mabicalls">,
   InGroup;
+def warn_drv_unsupported_longcalls : Warning<
+  "ignoring '-mlong-calls' option as it is not currently supported with "
+  "%select{|the implicit usage of }0-mabicalls">,
+  InGroup;
 def warn_drv_unsupported_abicalls : Warning<
   "ignoring '-mabicalls' option as it cannot be used with "
   "non position-independent code and the N64 ABI">,

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp?rev=310614&r1=310613&r2=310614&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp Thu Aug 10 08:42:25 2017
@@ -245,6 +245,16 @@ void mips::getMIPSTargetFeatures(const D
   else
 Features.push_back("-noabicalls");
 
+  if (Arg *A = Args.getLastArg(options::OPT_mlong_calls,
+   options::OPT_mno_long_calls)) {
+if (A->getOption().matches(options::OPT_mno_long_calls))
+  Features.push_back("-long-calls");
+else if (!UseAbiCalls)
+  Features.push_back("+long-calls");
+else
+  D.Diag(diag::warn_drv_unsupported_longcalls) << (ABICallsArg ? 0 : 1);
+  }
+
   mips::FloatABI FloatABI = mips::getMipsFloatABI(D, Args);
   if (FloatABI == mips::FloatABI::Soft) {
 // FIXME: Note, this is a hack. We need to pass the selected float
@@ -309,8 +319,6 @@ void mips::getMIPSTargetFeatures(const D
 
   AddTargetFeature(Args, Features, options::OPT_mno_odd_spreg,
options::OPT_modd_spreg, "nooddspreg");
-  AddTargetFeature(Args, Features, options::OPT_mlong_calls,
-   options::OPT_mno_long_calls, "long-calls");
   AddTargetFeature(Args, Features, options::OPT_mmt, options::OPT_mno_mt, 
"mt");
 }
 

Modified: cfe/trunk/test/Driver/mips-features.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mips-features.c?rev=310614&r1=310613&r2=310614&view=diff
==
--- cfe/trunk/test/Driver/mips-features.c (original)
+++ cfe/trunk/test/Driver/mips-features.c Thu Aug 10 08:42:25 2017
@@ -336,12 +336,16 @@
 // CHECK-IMG-SINGLEFLOAT-FPXX: "-target-feature" "+fpxx"
 
 // -mlong-call
-// RUN: %clang -target mips-img-linux-gnu -### -c %s -mlong-calls 2>&1 \
+// RUN: %clang -target mips-img-linux-gnu -### -c %s \
+// RUN:-mno-abicalls -mlong-calls 2>&1 \
 // RUN:   | FileCheck --check-prefix=LONG-CALLS-ON %s
-// RUN: %clang -target mips-img-linux-gnu -### -c %s -mno-long-calls 2>&1 \
+// RUN: %clang -target mips-img-linux-gnu -### -c %s \
+// RUN:-mno-abicalls -mno-long-calls 2>&1 \
 // RUN:   | FileCheck --check-prefix=LONG-CALLS-OFF %s
 // RUN: %clang -target mips-img-linux-gnu -### -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=LONG-CALLS-DEF %s
+// RUN: %clang -target mips-img-linux-gnu -### -c %s -mlong-calls 2>&1 \
+// RUN:   | FileCheck --check-prefix=LONG-CALLS-DEF %s
 // LONG-CALLS-ON: "-target-feature" "+long-calls"
 // LONG-CALLS-OFF: "-target-feature" "-long-calls"
 // LONG-CALLS-DEF-NOT: "long-calls"

Added: cfe/trunk/test/Driver/mips-longcalls-warning.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mips-longcalls-warning.c?rev=310614&view=auto
==
--- cfe/trunk/test/Driver/mips-longcalls-warning.c (added)
+++ cfe/trunk/test/Driver/mips-longcalls-warning.c Thu Aug 10 08:42:25 2017
@@ -0,0 +1,6 @@
+// REQUIRES: mips-registered-target
+// RUN: %clang -### -c -target mips-mti-elf -mlong-calls %s 2>&1 | FileCheck 
-check-prefix=IMPLICIT %s
+// IMPLICIT: warning: ig

[PATCH] D36550: [mips] Notify user that `-mabicalls` is ignored on non-PIC N64 ABI

2017-08-10 Thread Simon Atanasyan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310613: [mips] Notify user that `-mabicalls` is ignored on 
non-PIC N64 ABI (authored by atanasyan).

Changed prior to commit:
  https://reviews.llvm.org/D36550?vs=110561&id=110585#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36550

Files:
  cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
  cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
  cfe/trunk/test/Driver/mips-abicalls-warning.c
  cfe/trunk/test/Driver/mips-features.c


Index: cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
@@ -227,11 +227,23 @@
  O.matches(options::OPT_fno_PIE) || O.matches(options::OPT_fno_pie));
   }
 
-  if (IsN64 && NonPIC)
+  bool UseAbiCalls = false;
+
+  Arg *ABICallsArg =
+  Args.getLastArg(options::OPT_mabicalls, options::OPT_mno_abicalls);
+  UseAbiCalls =
+  !ABICallsArg ||
+  (ABICallsArg && 
ABICallsArg->getOption().matches(options::OPT_mabicalls));
+
+  if (UseAbiCalls && IsN64 && NonPIC) {
+D.Diag(diag::warn_drv_unsupported_abicalls);
+UseAbiCalls = false;
+  }
+
+  if (!UseAbiCalls)
 Features.push_back("+noabicalls");
   else
-AddTargetFeature(Args, Features, options::OPT_mno_abicalls,
- options::OPT_mabicalls, "noabicalls");
+Features.push_back("-noabicalls");
 
   mips::FloatABI FloatABI = mips::getMipsFloatABI(D, Args);
   if (FloatABI == mips::FloatABI::Soft) {
Index: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
@@ -292,6 +292,10 @@
   "ignoring '-mgpopt' option as it cannot be used with %select{|the implicit"
   " usage of }0-mabicalls">,
   InGroup;
+def warn_drv_unsupported_abicalls : Warning<
+  "ignoring '-mabicalls' option as it cannot be used with "
+  "non position-independent code and the N64 ABI">,
+  InGroup;
 
 def warn_drv_unable_to_find_directory_expected : Warning<
   "unable to find %0 directory, expected to be in '%1'">,
Index: cfe/trunk/test/Driver/mips-features.c
===
--- cfe/trunk/test/Driver/mips-features.c
+++ cfe/trunk/test/Driver/mips-features.c
@@ -10,6 +10,11 @@
 // RUN:   | FileCheck --check-prefix=CHECK-MNOABICALLS %s
 // CHECK-MNOABICALLS: "-target-feature" "+noabicalls"
 //
+// -mno-abicalls non-PIC N64
+// RUN: %clang -target mips64-linux-gnu -### -c -fno-PIC %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MNOABICALLS-N64NPIC %s
+// CHECK-MNOABICALLS-N64NPIC: "-target-feature" "+noabicalls"
+//
 // -mgpopt
 // RUN: %clang -target mips-linux-gnu -### -c %s -mno-gpopt -mgpopt 
-Wno-unsupported-gpopt 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-MGPOPT-DEF-ABICALLS %s
Index: cfe/trunk/test/Driver/mips-abicalls-warning.c
===
--- cfe/trunk/test/Driver/mips-abicalls-warning.c
+++ cfe/trunk/test/Driver/mips-abicalls-warning.c
@@ -0,0 +1,3 @@
+// REQUIRES: mips-registered-target
+// RUN: %clang -### -c -target mips64-mti-elf -fno-PIC -mabicalls %s 2>&1 | 
FileCheck %s
+// CHECK: warning: ignoring '-mabicalls' option as it cannot be used with non 
position-independent code and the N64 ABI


Index: cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
@@ -227,11 +227,23 @@
  O.matches(options::OPT_fno_PIE) || O.matches(options::OPT_fno_pie));
   }
 
-  if (IsN64 && NonPIC)
+  bool UseAbiCalls = false;
+
+  Arg *ABICallsArg =
+  Args.getLastArg(options::OPT_mabicalls, options::OPT_mno_abicalls);
+  UseAbiCalls =
+  !ABICallsArg ||
+  (ABICallsArg && ABICallsArg->getOption().matches(options::OPT_mabicalls));
+
+  if (UseAbiCalls && IsN64 && NonPIC) {
+D.Diag(diag::warn_drv_unsupported_abicalls);
+UseAbiCalls = false;
+  }
+
+  if (!UseAbiCalls)
 Features.push_back("+noabicalls");
   else
-AddTargetFeature(Args, Features, options::OPT_mno_abicalls,
- options::OPT_mabicalls, "noabicalls");
+Features.push_back("-noabicalls");
 
   mips::FloatABI FloatABI = mips::getMipsFloatABI(D, Args);
   if (FloatABI == mips::FloatABI::Soft) {
Index: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
@@ -292,6 +292,10 @@
   "ignoring '-mgpopt' option as it cannot be used with %select{|the implicit"
   " usage of }0-mabicalls">,
   InGroup;
+def warn_drv_u

r310613 - [mips] Notify user that `-mabicalls` is ignored on non-PIC N64 ABI

2017-08-10 Thread Simon Atanasyan via cfe-commits
Author: atanasyan
Date: Thu Aug 10 08:42:16 2017
New Revision: 310613

URL: http://llvm.org/viewvc/llvm-project?rev=310613&view=rev
Log:
[mips] Notify user that `-mabicalls` is ignored on non-PIC N64 ABI

The -mabicalls option does not make sense in the case of non position
independent code for the N64 ABI. After this change the driver shows a
warning that -mabicalls is ignored in that case.

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

Added:
cfe/trunk/test/Driver/mips-abicalls-warning.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
cfe/trunk/test/Driver/mips-features.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=310613&r1=310612&r2=310613&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Thu Aug 10 08:42:16 
2017
@@ -292,6 +292,10 @@ def warn_drv_unsupported_gpopt : Warning
   "ignoring '-mgpopt' option as it cannot be used with %select{|the implicit"
   " usage of }0-mabicalls">,
   InGroup;
+def warn_drv_unsupported_abicalls : Warning<
+  "ignoring '-mabicalls' option as it cannot be used with "
+  "non position-independent code and the N64 ABI">,
+  InGroup;
 
 def warn_drv_unable_to_find_directory_expected : Warning<
   "unable to find %0 directory, expected to be in '%1'">,

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp?rev=310613&r1=310612&r2=310613&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp Thu Aug 10 08:42:16 2017
@@ -227,11 +227,23 @@ void mips::getMIPSTargetFeatures(const D
  O.matches(options::OPT_fno_PIE) || O.matches(options::OPT_fno_pie));
   }
 
-  if (IsN64 && NonPIC)
+  bool UseAbiCalls = false;
+
+  Arg *ABICallsArg =
+  Args.getLastArg(options::OPT_mabicalls, options::OPT_mno_abicalls);
+  UseAbiCalls =
+  !ABICallsArg ||
+  (ABICallsArg && 
ABICallsArg->getOption().matches(options::OPT_mabicalls));
+
+  if (UseAbiCalls && IsN64 && NonPIC) {
+D.Diag(diag::warn_drv_unsupported_abicalls);
+UseAbiCalls = false;
+  }
+
+  if (!UseAbiCalls)
 Features.push_back("+noabicalls");
   else
-AddTargetFeature(Args, Features, options::OPT_mno_abicalls,
- options::OPT_mabicalls, "noabicalls");
+Features.push_back("-noabicalls");
 
   mips::FloatABI FloatABI = mips::getMipsFloatABI(D, Args);
   if (FloatABI == mips::FloatABI::Soft) {

Added: cfe/trunk/test/Driver/mips-abicalls-warning.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mips-abicalls-warning.c?rev=310613&view=auto
==
--- cfe/trunk/test/Driver/mips-abicalls-warning.c (added)
+++ cfe/trunk/test/Driver/mips-abicalls-warning.c Thu Aug 10 08:42:16 2017
@@ -0,0 +1,3 @@
+// REQUIRES: mips-registered-target
+// RUN: %clang -### -c -target mips64-mti-elf -fno-PIC -mabicalls %s 2>&1 | 
FileCheck %s
+// CHECK: warning: ignoring '-mabicalls' option as it cannot be used with non 
position-independent code and the N64 ABI

Modified: cfe/trunk/test/Driver/mips-features.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mips-features.c?rev=310613&r1=310612&r2=310613&view=diff
==
--- cfe/trunk/test/Driver/mips-features.c (original)
+++ cfe/trunk/test/Driver/mips-features.c Thu Aug 10 08:42:16 2017
@@ -10,6 +10,11 @@
 // RUN:   | FileCheck --check-prefix=CHECK-MNOABICALLS %s
 // CHECK-MNOABICALLS: "-target-feature" "+noabicalls"
 //
+// -mno-abicalls non-PIC N64
+// RUN: %clang -target mips64-linux-gnu -### -c -fno-PIC %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MNOABICALLS-N64NPIC %s
+// CHECK-MNOABICALLS-N64NPIC: "-target-feature" "+noabicalls"
+//
 // -mgpopt
 // RUN: %clang -target mips-linux-gnu -### -c %s -mno-gpopt -mgpopt 
-Wno-unsupported-gpopt 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-MGPOPT-DEF-ABICALLS %s


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


r310615 - [mips] Group all `-mabicalls` related checks in the single place. NFC

2017-08-10 Thread Simon Atanasyan via cfe-commits
Author: atanasyan
Date: Thu Aug 10 08:42:31 2017
New Revision: 310615

URL: http://llvm.org/viewvc/llvm-project?rev=310615&view=rev
Log:
[mips] Group all `-mabicalls` related checks in the single place. NFC

Removed:
cfe/trunk/test/Driver/mips-longcalls-warning.c
Modified:
cfe/trunk/test/Driver/mips-abicalls-warning.c

Modified: cfe/trunk/test/Driver/mips-abicalls-warning.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mips-abicalls-warning.c?rev=310615&r1=310614&r2=310615&view=diff
==
--- cfe/trunk/test/Driver/mips-abicalls-warning.c (original)
+++ cfe/trunk/test/Driver/mips-abicalls-warning.c Thu Aug 10 08:42:31 2017
@@ -1,3 +1,9 @@
 // REQUIRES: mips-registered-target
 // RUN: %clang -### -c -target mips64-mti-elf -fno-PIC -mabicalls %s 2>&1 | 
FileCheck %s
 // CHECK: warning: ignoring '-mabicalls' option as it cannot be used with non 
position-independent code and the N64 ABI
+
+// RUN: %clang -### -c -target mips-mti-elf -mlong-calls %s 2>&1 | FileCheck 
-check-prefix=LONGCALL-IMP %s
+// LONGCALL-IMP: warning: ignoring '-mlong-calls' option as it is not 
currently supported with the implicit usage of -mabicalls
+
+// RUN: %clang -### -c -target mips-mti-elf -mlong-calls -mabicalls %s 2>&1 | 
FileCheck -check-prefix=LONGCALL-EXP %s
+// LONGCALL-EXP: warning: ignoring '-mlong-calls' option as it is not 
currently supported with -mabicalls

Removed: cfe/trunk/test/Driver/mips-longcalls-warning.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mips-longcalls-warning.c?rev=310614&view=auto
==
--- cfe/trunk/test/Driver/mips-longcalls-warning.c (original)
+++ cfe/trunk/test/Driver/mips-longcalls-warning.c (removed)
@@ -1,6 +0,0 @@
-// REQUIRES: mips-registered-target
-// RUN: %clang -### -c -target mips-mti-elf -mlong-calls %s 2>&1 | FileCheck 
-check-prefix=IMPLICIT %s
-// IMPLICIT: warning: ignoring '-mlong-calls' option as it is not currently 
supported with the implicit usage of -mabicalls
-
-// RUN: %clang -### -c -target mips-mti-elf -mlong-calls -mabicalls %s 2>&1 | 
FileCheck -check-prefix=EXPLICIT %s
-// EXPLICIT: warning: ignoring '-mlong-calls' option as it is not currently 
supported with -mabicalls


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


[PATCH] D36551: [mips] Show warning in case of mixing -mlong-calls and -mabicalls options

2017-08-10 Thread Simon Atanasyan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310614: [mips] Show warning in case of mixing -mlong-calls 
and -mabicalls options (authored by atanasyan).

Changed prior to commit:
  https://reviews.llvm.org/D36551?vs=110562&id=110586#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36551

Files:
  cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
  cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
  cfe/trunk/test/Driver/mips-features.c
  cfe/trunk/test/Driver/mips-longcalls-warning.c


Index: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
@@ -292,6 +292,10 @@
   "ignoring '-mgpopt' option as it cannot be used with %select{|the implicit"
   " usage of }0-mabicalls">,
   InGroup;
+def warn_drv_unsupported_longcalls : Warning<
+  "ignoring '-mlong-calls' option as it is not currently supported with "
+  "%select{|the implicit usage of }0-mabicalls">,
+  InGroup;
 def warn_drv_unsupported_abicalls : Warning<
   "ignoring '-mabicalls' option as it cannot be used with "
   "non position-independent code and the N64 ABI">,
Index: cfe/trunk/test/Driver/mips-features.c
===
--- cfe/trunk/test/Driver/mips-features.c
+++ cfe/trunk/test/Driver/mips-features.c
@@ -336,12 +336,16 @@
 // CHECK-IMG-SINGLEFLOAT-FPXX: "-target-feature" "+fpxx"
 
 // -mlong-call
-// RUN: %clang -target mips-img-linux-gnu -### -c %s -mlong-calls 2>&1 \
+// RUN: %clang -target mips-img-linux-gnu -### -c %s \
+// RUN:-mno-abicalls -mlong-calls 2>&1 \
 // RUN:   | FileCheck --check-prefix=LONG-CALLS-ON %s
-// RUN: %clang -target mips-img-linux-gnu -### -c %s -mno-long-calls 2>&1 \
+// RUN: %clang -target mips-img-linux-gnu -### -c %s \
+// RUN:-mno-abicalls -mno-long-calls 2>&1 \
 // RUN:   | FileCheck --check-prefix=LONG-CALLS-OFF %s
 // RUN: %clang -target mips-img-linux-gnu -### -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=LONG-CALLS-DEF %s
+// RUN: %clang -target mips-img-linux-gnu -### -c %s -mlong-calls 2>&1 \
+// RUN:   | FileCheck --check-prefix=LONG-CALLS-DEF %s
 // LONG-CALLS-ON: "-target-feature" "+long-calls"
 // LONG-CALLS-OFF: "-target-feature" "-long-calls"
 // LONG-CALLS-DEF-NOT: "long-calls"
Index: cfe/trunk/test/Driver/mips-longcalls-warning.c
===
--- cfe/trunk/test/Driver/mips-longcalls-warning.c
+++ cfe/trunk/test/Driver/mips-longcalls-warning.c
@@ -0,0 +1,6 @@
+// REQUIRES: mips-registered-target
+// RUN: %clang -### -c -target mips-mti-elf -mlong-calls %s 2>&1 | FileCheck 
-check-prefix=IMPLICIT %s
+// IMPLICIT: warning: ignoring '-mlong-calls' option as it is not currently 
supported with the implicit usage of -mabicalls
+
+// RUN: %clang -### -c -target mips-mti-elf -mlong-calls -mabicalls %s 2>&1 | 
FileCheck -check-prefix=EXPLICIT %s
+// EXPLICIT: warning: ignoring '-mlong-calls' option as it is not currently 
supported with -mabicalls
Index: cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
@@ -245,6 +245,16 @@
   else
 Features.push_back("-noabicalls");
 
+  if (Arg *A = Args.getLastArg(options::OPT_mlong_calls,
+   options::OPT_mno_long_calls)) {
+if (A->getOption().matches(options::OPT_mno_long_calls))
+  Features.push_back("-long-calls");
+else if (!UseAbiCalls)
+  Features.push_back("+long-calls");
+else
+  D.Diag(diag::warn_drv_unsupported_longcalls) << (ABICallsArg ? 0 : 1);
+  }
+
   mips::FloatABI FloatABI = mips::getMipsFloatABI(D, Args);
   if (FloatABI == mips::FloatABI::Soft) {
 // FIXME: Note, this is a hack. We need to pass the selected float
@@ -309,8 +319,6 @@
 
   AddTargetFeature(Args, Features, options::OPT_mno_odd_spreg,
options::OPT_modd_spreg, "nooddspreg");
-  AddTargetFeature(Args, Features, options::OPT_mlong_calls,
-   options::OPT_mno_long_calls, "long-calls");
   AddTargetFeature(Args, Features, options::OPT_mmt, options::OPT_mno_mt, 
"mt");
 }
 


Index: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
@@ -292,6 +292,10 @@
   "ignoring '-mgpopt' option as it cannot be used with %select{|the implicit"
   " usage of }0-mabicalls">,
   InGroup;
+def warn_drv_unsupported_longcalls : Warning<
+  "ignoring '-mlong-calls' option as it is not currently supported with "
+  "%select{|the implicit usage of }0-mabicalls">,
+  InGroup;
 def warn_drv_unsupported_abicalls

r310616 - Place implictly declared functions at block scope

2017-08-10 Thread Momchil Velikov via cfe-commits
Author: chill
Date: Thu Aug 10 08:43:06 2017
New Revision: 310616

URL: http://llvm.org/viewvc/llvm-project?rev=310616&view=rev
Log:
Place implictly declared functions at block scope

Such implicitly declared functions behave as if the enclosing block
contained the declaration extern int name() (C90, 6.3.3.2 Function calls),
thus their names should have block scope (C90, 6.1.2.1 Scope of identifiers).

This patch fixes https://bugs.llvm.org/show_bug.cgi?id=33224

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


Added:
cfe/trunk/test/Sema/implicit-decl-c90.c
Modified:
cfe/trunk/include/clang/Sema/Scope.h
cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/lib/Parse/ParseExprCXX.cpp
cfe/trunk/lib/Parse/ParseObjc.cpp
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/lib/Parse/ParsePragma.cpp
cfe/trunk/lib/Parse/ParseStmt.cpp
cfe/trunk/lib/Parse/ParseTemplate.cpp
cfe/trunk/lib/Parse/Parser.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Sema/implicit-decl.c

Modified: cfe/trunk/include/clang/Sema/Scope.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Scope.h?rev=310616&r1=310615&r2=310616&view=diff
==
--- cfe/trunk/include/clang/Sema/Scope.h (original)
+++ cfe/trunk/include/clang/Sema/Scope.h Thu Aug 10 08:43:06 2017
@@ -124,6 +124,9 @@ public:
 
 /// We are currently in the filter expression of an SEH except block.
 SEHFilterScope = 0x20,
+
+/// This is a compound statement scope.
+CompoundStmtScope = 0x40,
   };
 private:
   /// The parent scope for this scope.  This is null for the translation-unit
@@ -429,6 +432,11 @@ public:
   /// \brief Determine whether this scope is a SEH '__except' block.
   bool isSEHExceptScope() const { return getFlags() & Scope::SEHExceptScope; }
 
+  /// \brief Determine whether this scope is a compound statement scope.
+  bool isCompoundStmtScope() const {
+return getFlags() & Scope::CompoundStmtScope;
+  }
+
   /// \brief Returns if rhs has a higher scope depth than this.
   ///
   /// The caller is responsible for calling this only if one of the two scopes

Modified: cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp?rev=310616&r1=310615&r2=310616&view=diff
==
--- cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp (original)
+++ cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp Thu Aug 10 08:43:06 2017
@@ -518,7 +518,8 @@ void Parser::ParseLexedMethodDef(LexedMe
 
   // Parse the method body. Function body parsing code is similar enough
   // to be re-used for method bodies as well.
-  ParseScope FnScope(this, Scope::FnScope|Scope::DeclScope);
+  ParseScope FnScope(this, Scope::FnScope | Scope::DeclScope |
+   Scope::CompoundStmtScope);
   Actions.ActOnStartOfFunctionDef(getCurScope(), LM.D);
 
   if (Tok.is(tok::kw_try)) {

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=310616&r1=310615&r2=310616&view=diff
==
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Thu Aug 10 08:43:06 2017
@@ -1388,7 +1388,9 @@ void Parser::ParseLexedAttribute(LatePar
 
   // If the Decl is on a function, add function parameters to the scope.
   bool HasFunScope = EnterScope && D->isFunctionOrFunctionTemplate();
-  ParseScope FnScope(this, Scope::FnScope|Scope::DeclScope, HasFunScope);
+  ParseScope FnScope(
+  this, Scope::FnScope | Scope::DeclScope | Scope::CompoundStmtScope,
+  HasFunScope);
   if (HasFunScope)
 Actions.ActOnReenterFunctionContext(Actions.CurScope, D);
 

Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=310616&r1=310615&r2=310616&view=diff
==
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Thu Aug 10 08:43:06 2017
@@ -2881,7 +2881,7 @@ ExprResult Parser::ParseBlockLiteralExpr
   // allows determining whether a variable reference inside the block is
   // within or outside of the block.
   ParseScope BlockScope(this, Scope::BlockScope | Scope::FnScope |
-  Scope::DeclScope);
+  Scope::CompoundStmtScope | Scope::DeclScope);
 
   // Inform sema that we are starting a block.
   Actions.ActOnBlockStart(CaretLoc, getCurScope());

Modified: cfe/trunk/lib/Parse/ParseExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExprCXX.cpp?rev=310616&r1=310615&r2=

[PATCH] D33676: Place implictly declared functions at block scope

2017-08-10 Thread Momchil Velikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310616: Place implictly declared functions at block scope 
(authored by chill).

Changed prior to commit:
  https://reviews.llvm.org/D33676?vs=109366&id=110587#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33676

Files:
  cfe/trunk/include/clang/Sema/Scope.h
  cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
  cfe/trunk/lib/Parse/ParseDecl.cpp
  cfe/trunk/lib/Parse/ParseExpr.cpp
  cfe/trunk/lib/Parse/ParseExprCXX.cpp
  cfe/trunk/lib/Parse/ParseObjc.cpp
  cfe/trunk/lib/Parse/ParseOpenMP.cpp
  cfe/trunk/lib/Parse/ParsePragma.cpp
  cfe/trunk/lib/Parse/ParseStmt.cpp
  cfe/trunk/lib/Parse/ParseTemplate.cpp
  cfe/trunk/lib/Parse/Parser.cpp
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/test/Sema/implicit-decl-c90.c
  cfe/trunk/test/Sema/implicit-decl.c

Index: cfe/trunk/lib/Parse/ParseExprCXX.cpp
===
--- cfe/trunk/lib/Parse/ParseExprCXX.cpp
+++ cfe/trunk/lib/Parse/ParseExprCXX.cpp
@@ -1281,7 +1281,8 @@
 
   // FIXME: Rename BlockScope -> ClosureScope if we decide to continue using
   // it.
-  unsigned ScopeFlags = Scope::BlockScope | Scope::FnScope | Scope::DeclScope;
+  unsigned ScopeFlags = Scope::BlockScope | Scope::FnScope | Scope::DeclScope |
+Scope::CompoundStmtScope;
   ParseScope BodyScope(this, ScopeFlags);
 
   Actions.ActOnStartOfLambdaDefinition(Intro, D, getCurScope());
Index: cfe/trunk/lib/Parse/Parser.cpp
===
--- cfe/trunk/lib/Parse/Parser.cpp
+++ cfe/trunk/lib/Parse/Parser.cpp
@@ -1075,8 +1075,9 @@
   TemplateInfo.Kind == ParsedTemplateInfo::Template &&
   Actions.canDelayFunctionBody(D)) {
 MultiTemplateParamsArg TemplateParameterLists(*TemplateInfo.TemplateParams);
-
-ParseScope BodyScope(this, Scope::FnScope|Scope::DeclScope);
+
+ParseScope BodyScope(this, Scope::FnScope | Scope::DeclScope |
+   Scope::CompoundStmtScope);
 Scope *ParentScope = getCurScope()->getParent();
 
 D.setFunctionDefinitionKind(FDK_Definition);
@@ -1106,7 +1107,8 @@
(Tok.is(tok::l_brace) || Tok.is(tok::kw_try) ||
 Tok.is(tok::colon)) && 
   Actions.CurContext->isTranslationUnit()) {
-ParseScope BodyScope(this, Scope::FnScope|Scope::DeclScope);
+ParseScope BodyScope(this, Scope::FnScope | Scope::DeclScope |
+   Scope::CompoundStmtScope);
 Scope *ParentScope = getCurScope()->getParent();
 
 D.setFunctionDefinitionKind(FDK_Definition);
@@ -1124,7 +1126,8 @@
   }
 
   // Enter a scope for the function body.
-  ParseScope BodyScope(this, Scope::FnScope|Scope::DeclScope);
+  ParseScope BodyScope(this, Scope::FnScope | Scope::DeclScope |
+ Scope::CompoundStmtScope);
 
   // Tell the actions module that we have entered a function definition with the
   // specified Declarator for the function.
Index: cfe/trunk/lib/Parse/ParseOpenMP.cpp
===
--- cfe/trunk/lib/Parse/ParseOpenMP.cpp
+++ cfe/trunk/lib/Parse/ParseOpenMP.cpp
@@ -302,6 +302,7 @@
   for (auto *D : DRD.get()) {
 TentativeParsingAction TPA(*this);
 ParseScope OMPDRScope(this, Scope::FnScope | Scope::DeclScope |
+Scope::CompoundStmtScope |
 Scope::OpenMPDirectiveScope);
 // Parse  expression.
 Actions.ActOnOpenMPDeclareReductionCombinerStart(getCurScope(), D);
@@ -337,6 +338,7 @@
   IsCorrect;
   if (Tok.isNot(tok::annot_pragma_openmp_end)) {
 ParseScope OMPDRScope(this, Scope::FnScope | Scope::DeclScope |
+Scope::CompoundStmtScope |
 Scope::OpenMPDirectiveScope);
 // Parse expression.
 Actions.ActOnOpenMPDeclareReductionInitializerStart(getCurScope(), D);
@@ -405,8 +407,9 @@
 
 // If the Decl is on a function, add function parameters to the scope.
 HasFunScope = D->isFunctionOrFunctionTemplate();
-FnScope = new Parser::ParseScope(&P, Scope::FnScope | Scope::DeclScope,
- HasFunScope);
+FnScope = new Parser::ParseScope(
+&P, Scope::FnScope | Scope::DeclScope | Scope::CompoundStmtScope,
+HasFunScope);
 if (HasFunScope)
   Actions.ActOnReenterFunctionContext(Actions.getCurScope(), D);
   }
@@ -813,8 +816,8 @@
   SmallVector Clauses;
   SmallVector, OMPC_unknown + 1>
   FirstClauses(OMPC_unknown + 1);
-  unsigned ScopeFlags =
-  Scope::FnScope | Scope::DeclScope | Scope::OpenMPDirectiveScope;
+  unsigned ScopeFlags = Scope::FnScope | Scope::DeclScope |
+Scope::CompoundStmtScope | Scope::OpenMPDirectiveScope;
   SourceLocation Loc = ConsumeAnnotationToken(), EndLoc;
   auto DKind = ParseOpenMPDirect

[PATCH] D29660: [OpenMP] Add flag for overwriting default PTX version for OpenMP targets

2017-08-10 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

In https://reviews.llvm.org/D29660#838150, @gtbercea wrote:

> First of all, I apologize if I've upset you with my previous post. I am 
> actively working on understanding what is causing these issues. It is not my 
> intention to write tests that work on local configurations only. I am upset 
> to see that these tests keep failing for your and maybe other configurations. 
> Without knowing the actual reason of the failures I can only speculate what 
> is going wrong with them hence the flurry of changes.


Should we have a mock CUDA installation directory in the test directory? We 
have a bunch of these in test/Driver/Inputs for various other things. When we 
could point these tests at that directory (or directories if we have different 
mocks for different CUDA versions) and remove any dependence on local CUDA 
configurations.


Repository:
  rL LLVM

https://reviews.llvm.org/D29660



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


[PATCH] D36530: [Parse] Document PrintStats, SkipFunctionBodies

2017-08-10 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

Generally such NFC patches can be committed directly as they can be reviewed 
after the commit


Repository:
  rL LLVM

https://reviews.llvm.org/D36530



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


Re: [clang-tools-extra] r310559 - [clang-tidy] Minor documentation improvement

2017-08-10 Thread Gábor Horváth via cfe-commits
On 10 August 2017 at 17:40, Alexander Kornienko  wrote:

>
>
> On Thu, Aug 10, 2017 at 11:13 AM, Gabor Horvath via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: xazax
>> Date: Thu Aug 10 02:13:26 2017
>> New Revision: 310559
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=310559&view=rev
>> Log:
>> [clang-tidy] Minor documentation improvement
>>
>> Patch by: Lilla Barancsuk
>>
>> Modified:
>> clang-tools-extra/trunk/docs/clang-tidy/checks/readability-s
>> tatic-accessed-through-instance.rst
>> clang-tools-extra/trunk/test/clang-tidy/readability-static-a
>> ccessed-through-instance.cpp
>>
>> Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/readability-s
>> tatic-accessed-through-instance.rst
>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>> docs/clang-tidy/checks/readability-static-accessed-through-
>> instance.rst?rev=310559&r1=310558&r2=310559&view=diff
>> 
>> ==
>> --- clang-tools-extra/trunk/docs/clang-tidy/checks/readability-s
>> tatic-accessed-through-instance.rst (original)
>> +++ clang-tools-extra/trunk/docs/clang-tidy/checks/readability-s
>> tatic-accessed-through-instance.rst Thu Aug 10 02:13:26 2017
>> @@ -25,6 +25,7 @@ is changed to:
>>
>>  .. code-block:: c++
>>
>> +  C *c1 = new C();
>>C::foo();
>>C::x;
>>
>>
>> Modified: clang-tools-extra/trunk/test/clang-tidy/readability-static-a
>> ccessed-through-instance.cpp
>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>> test/clang-tidy/readability-static-accessed-through-
>> instance.cpp?rev=310559&r1=310558&r2=310559&view=diff
>> 
>> ==
>> --- 
>> clang-tools-extra/trunk/test/clang-tidy/readability-static-accessed-through-instance.cpp
>> (original)
>> +++ 
>> clang-tools-extra/trunk/test/clang-tidy/readability-static-accessed-through-instance.cpp
>> Thu Aug 10 02:13:26 2017
>> @@ -116,7 +116,7 @@ using E = D;
>>
>>  template  void f(T t, C c) {
>>t.x; // OK, t is a template parameter.
>> -  c.x; // 1
>> +  c.x;
>>
>
> This comment was there to make the CHECK-FIXES line unique so that it
> doesn't match wrong line in the test. Any specific reason to remove it?
>

There was no specific reason, this seemed to be redundant, and reducing
readability. But I just noticed there is a C::x; line far above, so it
looks like this was not redundant at all. Should I add this back or you are
fine with leaving it as is for now?


>
>
>>// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: static member
>>// CHECK-FIXES: {{^}}  C::x; // 1{{$}}
>>  }
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36530: [Parse] Document PrintStats, SkipFunctionBodies

2017-08-10 Thread Doug Gregor via Phabricator via cfe-commits
doug.gregor added a comment.

LGTM, thank you!


Repository:
  rL LLVM

https://reviews.llvm.org/D36530



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


[PATCH] D29660: [OpenMP] Add flag for overwriting default PTX version for OpenMP targets

2017-08-10 Thread Aleksey Shlyapnikov via Phabricator via cfe-commits
alekseyshl added a comment.

In https://reviews.llvm.org/D29660#838150, @gtbercea wrote:

> First of all, I apologize if I've upset you with my previous post. I am 
> actively working on understanding what is causing these issues. It is not my 
> intention to write tests that work on local configurations only. I am upset 
> to see that these tests keep failing for your and maybe other configurations. 
> Without knowing the actual reason of the failures I can only speculate what 
> is going wrong with them hence the flurry of changes.


Thank you, apology accepted. That was exactly my point, not to start a fight, 
but to emphasize that depending on local configuration is never going to work, 
you will never be able to see and test all of them. Please disable the test 
ASAP and until the better way to handle it is determined.


Repository:
  rL LLVM

https://reviews.llvm.org/D29660



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


[PATCH] D29660: [OpenMP] Add flag for overwriting default PTX version for OpenMP targets

2017-08-10 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

The failures were very widespread, e.g. there's a linux buildbot that was red 
until the revert: http://bb.pgr.jp/builders/test-clang-i686-linux-RA. If you 
have access to a linux machine you should be able to reproduce the failures 
that the bot experienced by using the same cmake arguments (I don't know the 
exact ones, but judging from the bot you should be able to reproduce them using 
32 bit release build with assertions enabled). I don't know what GPU that 
buildbot has.

I'll try to get the detailed test output for my local machine today as well.


Repository:
  rL LLVM

https://reviews.llvm.org/D29660



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


Re: [clang-tools-extra] r310559 - [clang-tidy] Minor documentation improvement

2017-08-10 Thread Alexander Kornienko via cfe-commits
There's also `C::x; // 2` below, so I'd add this comment back at least for
consistency.

On Thu, Aug 10, 2017 at 5:53 PM, Gábor Horváth  wrote:

>
>
> On 10 August 2017 at 17:40, Alexander Kornienko  wrote:
>
>>
>>
>> On Thu, Aug 10, 2017 at 11:13 AM, Gabor Horvath via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: xazax
>>> Date: Thu Aug 10 02:13:26 2017
>>> New Revision: 310559
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=310559&view=rev
>>> Log:
>>> [clang-tidy] Minor documentation improvement
>>>
>>> Patch by: Lilla Barancsuk
>>>
>>> Modified:
>>> clang-tools-extra/trunk/docs/clang-tidy/checks/readability-s
>>> tatic-accessed-through-instance.rst
>>> clang-tools-extra/trunk/test/clang-tidy/readability-static-a
>>> ccessed-through-instance.cpp
>>>
>>> Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/readability-s
>>> tatic-accessed-through-instance.rst
>>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>>> docs/clang-tidy/checks/readability-static-accessed-through-i
>>> nstance.rst?rev=310559&r1=310558&r2=310559&view=diff
>>> 
>>> ==
>>> --- clang-tools-extra/trunk/docs/clang-tidy/checks/readability-s
>>> tatic-accessed-through-instance.rst (original)
>>> +++ clang-tools-extra/trunk/docs/clang-tidy/checks/readability-s
>>> tatic-accessed-through-instance.rst Thu Aug 10 02:13:26 2017
>>> @@ -25,6 +25,7 @@ is changed to:
>>>
>>>  .. code-block:: c++
>>>
>>> +  C *c1 = new C();
>>>C::foo();
>>>C::x;
>>>
>>>
>>> Modified: clang-tools-extra/trunk/test/clang-tidy/readability-static-a
>>> ccessed-through-instance.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>>> test/clang-tidy/readability-static-accessed-through-instance
>>> .cpp?rev=310559&r1=310558&r2=310559&view=diff
>>> 
>>> ==
>>> --- 
>>> clang-tools-extra/trunk/test/clang-tidy/readability-static-accessed-through-instance.cpp
>>> (original)
>>> +++ 
>>> clang-tools-extra/trunk/test/clang-tidy/readability-static-accessed-through-instance.cpp
>>> Thu Aug 10 02:13:26 2017
>>> @@ -116,7 +116,7 @@ using E = D;
>>>
>>>  template  void f(T t, C c) {
>>>t.x; // OK, t is a template parameter.
>>> -  c.x; // 1
>>> +  c.x;
>>>
>>
>> This comment was there to make the CHECK-FIXES line unique so that it
>> doesn't match wrong line in the test. Any specific reason to remove it?
>>
>
> There was no specific reason, this seemed to be redundant, and reducing
> readability. But I just noticed there is a C::x; line far above, so it
> looks like this was not redundant at all. Should I add this back or you are
> fine with leaving it as is for now?
>
>
>>
>>
>>>// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: static member
>>>// CHECK-FIXES: {{^}}  C::x; // 1{{$}}
>>>  }
>>>
>>>
>>> ___
>>> 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


r310618 - Fixed a race condition in PrecompiledPreamble.

2017-08-10 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Thu Aug 10 09:10:40 2017
New Revision: 310618

URL: http://llvm.org/viewvc/llvm-project?rev=310618&view=rev
Log:
Fixed a race condition in PrecompiledPreamble.

Summary:
Two PrecompiledPreambles, used in parallel on separate threads,
could be writing preamble to the same temporary file.

Reviewers: bkramer, krasimir, klimek

Reviewed By: klimek

Subscribers: cfe-commits

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

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

Modified: cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp?rev=310618&r1=310617&r2=310618&view=diff
==
--- cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp (original)
+++ cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp Thu Aug 10 09:10:40 2017
@@ -28,6 +28,7 @@
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Mutex.h"
 #include "llvm/Support/MutexGuard.h"
+#include "llvm/Support/Process.h"
 
 using namespace clang;
 
@@ -462,9 +463,16 @@ llvm::ErrorOr File;
-  auto EC = llvm::sys::fs::createTemporaryFile(Prefix, Suffix, /*ref*/ File);
+  // Using a version of createTemporaryFile with a file descriptor guarantees
+  // that we would never get a race condition in a multi-threaded setting 
(i.e.,
+  // multiple threads getting the same temporary path).
+  int FD;
+  auto EC = llvm::sys::fs::createTemporaryFile(Prefix, Suffix, /*ref*/ FD,
+   /*ref*/ File);
   if (EC)
 return EC;
+  // We only needed to make sure the file exists, close the file right away.
+  llvm::sys::Process::SafelyCloseFileDescriptor(FD);
   return TempPCHFile(std::move(File).str());
 }
 


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


[PATCH] D36529: Fixed a race condition in PrecompiledPreamble.

2017-08-10 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310618: Fixed a race condition in PrecompiledPreamble. 
(authored by ibiryukov).

Repository:
  rL LLVM

https://reviews.llvm.org/D36529

Files:
  cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp


Index: cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
===
--- cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
+++ cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
@@ -28,6 +28,7 @@
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Mutex.h"
 #include "llvm/Support/MutexGuard.h"
+#include "llvm/Support/Process.h"
 
 using namespace clang;
 
@@ -462,9 +463,16 @@
 PrecompiledPreamble::TempPCHFile::createInSystemTempDir(const Twine &Prefix,
 StringRef Suffix) {
   llvm::SmallString<64> File;
-  auto EC = llvm::sys::fs::createTemporaryFile(Prefix, Suffix, /*ref*/ File);
+  // Using a version of createTemporaryFile with a file descriptor guarantees
+  // that we would never get a race condition in a multi-threaded setting 
(i.e.,
+  // multiple threads getting the same temporary path).
+  int FD;
+  auto EC = llvm::sys::fs::createTemporaryFile(Prefix, Suffix, /*ref*/ FD,
+   /*ref*/ File);
   if (EC)
 return EC;
+  // We only needed to make sure the file exists, close the file right away.
+  llvm::sys::Process::SafelyCloseFileDescriptor(FD);
   return TempPCHFile(std::move(File).str());
 }
 


Index: cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
===
--- cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
+++ cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
@@ -28,6 +28,7 @@
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Mutex.h"
 #include "llvm/Support/MutexGuard.h"
+#include "llvm/Support/Process.h"
 
 using namespace clang;
 
@@ -462,9 +463,16 @@
 PrecompiledPreamble::TempPCHFile::createInSystemTempDir(const Twine &Prefix,
 StringRef Suffix) {
   llvm::SmallString<64> File;
-  auto EC = llvm::sys::fs::createTemporaryFile(Prefix, Suffix, /*ref*/ File);
+  // Using a version of createTemporaryFile with a file descriptor guarantees
+  // that we would never get a race condition in a multi-threaded setting (i.e.,
+  // multiple threads getting the same temporary path).
+  int FD;
+  auto EC = llvm::sys::fs::createTemporaryFile(Prefix, Suffix, /*ref*/ FD,
+   /*ref*/ File);
   if (EC)
 return EC;
+  // We only needed to make sure the file exists, close the file right away.
+  llvm::sys::Process::SafelyCloseFileDescriptor(FD);
   return TempPCHFile(std::move(File).str());
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29660: [OpenMP] Add flag for overwriting default PTX version for OpenMP targets

2017-08-10 Thread Jacob Bandes-Storch via Phabricator via cfe-commits
jtbandes added a comment.

@gtbercea Hi, I just saw your comment on my gist. (Unfortunately github does 
not send email notifications about gist comments; commenting here is probably 
better.) If you have Docker installed, it should be easy to get whatever output 
you like — just change the Dockerfile to use `-DCMAKE_BUILD_TYPE=Debug`, then 
run `docker build -t llvm-test .` and `docker run -it llvm-test /bin/bash`.


Repository:
  rL LLVM

https://reviews.llvm.org/D29660



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


[PATCH] D29660: [OpenMP] Add flag for overwriting default PTX version for OpenMP targets

2017-08-10 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added a comment.

In https://reviews.llvm.org/D29660#838194, @arphaman wrote:

> The failures were very widespread, e.g. there's a linux buildbot that was red 
> until the revert: http://bb.pgr.jp/builders/test-clang-i686-linux-RA. If you 
> have access to a linux machine you should be able to reproduce the failures 
> that the bot experienced by using the same cmake arguments (I don't know the 
> exact ones, but judging from the bot you should be able to reproduce them 
> using 32 bit release build with assertions enabled). I don't know what GPU 
> that buildbot has.


Thanks Alex, I will try to reproduce it locally.

> I'll try to get the detailed test output for my local machine today as well.

Oh that would be great! Thanks a lot! :)


Repository:
  rL LLVM

https://reviews.llvm.org/D29660



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


Re: r310605 - [Modules] Prevent #import to reenter header if not building a module.

2017-08-10 Thread Bruno Cardoso Lopes via cfe-commits
Hi Hans, can we please get this merged into 5.0?

Thanks,

On Thu, Aug 10, 2017 at 12:16 PM, Bruno Cardoso Lopes via cfe-commits
 wrote:
> Author: bruno
> Date: Thu Aug 10 08:16:24 2017
> New Revision: 310605
>
> URL: http://llvm.org/viewvc/llvm-project?rev=310605&view=rev
> Log:
> [Modules] Prevent #import to reenter header if not building a module.
>
> When non-modular headers are imported while not building a module but
> in -fmodules mode, be conservative and preserve the default #import
> semantic: do not reenter headers.
>
> rdar://problem/33745031
>
> Added:
> cfe/trunk/test/Modules/Inputs/import-textual/x.h
> cfe/trunk/test/Modules/import-textual-nomodules.m
> Modified:
> cfe/trunk/lib/Lex/HeaderSearch.cpp
>
> Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=310605&r1=310604&r2=310605&view=diff
> ==
> --- cfe/trunk/lib/Lex/HeaderSearch.cpp (original)
> +++ cfe/trunk/lib/Lex/HeaderSearch.cpp Thu Aug 10 08:16:24 2017
> @@ -1143,7 +1143,7 @@ bool HeaderSearch::ShouldEnterIncludeFil
>  // headers find in the wild might rely only on #import and do not contain
>  // controlling macros, be conservative and only try to enter textual 
> headers
>  // if such macro is present.
> -if (!FileInfo.isModuleHeader &&
> +if (FileInfo.isCompilingModuleHeader && !FileInfo.isModuleHeader &&
>  FileInfo.getControllingMacro(ExternalLookup))
>TryEnterHdr = true;
>  return TryEnterHdr;
>
> Added: cfe/trunk/test/Modules/Inputs/import-textual/x.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/import-textual/x.h?rev=310605&view=auto
> ==
> --- cfe/trunk/test/Modules/Inputs/import-textual/x.h (added)
> +++ cfe/trunk/test/Modules/Inputs/import-textual/x.h Thu Aug 10 08:16:24 2017
> @@ -0,0 +1,6 @@
> +#ifndef RANDOM_DEP
> +
> +@interface X
> +@end
> +
> +#endif // RANDOM_DEP
>
> Added: cfe/trunk/test/Modules/import-textual-nomodules.m
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/import-textual-nomodules.m?rev=310605&view=auto
> ==
> --- cfe/trunk/test/Modules/import-textual-nomodules.m (added)
> +++ cfe/trunk/test/Modules/import-textual-nomodules.m Thu Aug 10 08:16:24 2017
> @@ -0,0 +1,8 @@
> +// RUN: rm -rf %t
> +// RUN: %clang_cc1 -fsyntax-only -fmodules -fimplicit-module-maps 
> -I%S/Inputs/import-textual -fmodules-cache-path=%t %s -verify
> +
> +// expected-no-diagnostics
> +
> +#import "x.h"
> +#import "x.h"
> +
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits



-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r310622 - Add a getName accessor for ModuleMacros.

2017-08-10 Thread Bob Wilson via cfe-commits
Author: bwilson
Date: Thu Aug 10 09:42:46 2017
New Revision: 310622

URL: http://llvm.org/viewvc/llvm-project?rev=310622&view=rev
Log:
Add a getName accessor for ModuleMacros.

Swift would like to be able to access the name of a ModuleMacro.
There was some discussion of this in
https://github.com/apple/swift-clang/pull/93, suggesting that it makes
sense to have this accessor in Clang.

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

Modified: cfe/trunk/include/clang/Lex/MacroInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/MacroInfo.h?rev=310622&r1=310621&r2=310622&view=diff
==
--- cfe/trunk/include/clang/Lex/MacroInfo.h (original)
+++ cfe/trunk/include/clang/Lex/MacroInfo.h Thu Aug 10 09:42:46 2017
@@ -510,6 +510,9 @@ public:
 ID.AddPointer(II);
   }
 
+  /// Get the name of the macro.
+  IdentifierInfo *getName() const { return II; }
+
   /// Get the ID of the module that exports this macro.
   Module *getOwningModule() const { return OwningModule; }
 


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


[PATCH] D36563: Add a getName accessor for ModuleMacros

2017-08-10 Thread Bob Wilson via Phabricator via cfe-commits
bob.wilson added a comment.

Committed in r310622


https://reviews.llvm.org/D36563



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


[PATCH] D29660: [OpenMP] Add flag for overwriting default PTX version for OpenMP targets

2017-08-10 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

I've traced the output across all the reverted commits:

F5233517: testFailures.md 

Note that after r310549 the last 9 RUN lines started failing because of the 
same crash:

  clang version 6.0.0  (http://llvm.org/git/llvm.git 
00708415fb45c18f9871def78647dd555c253e0b)
  Target: x86_64-apple-darwin17.0.0
  Thread model: posix
  InstalledDir: /Users/alex/bisect/b/./bin
  no libdevice exists.
  UNREACHABLE executed at 
/Users/alex/bisect/llvm/tools/clang/lib/Driver/ToolChains/Cuda.h:88!
  0  clang0x00010799795c 
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 60
  1  clang0x000107997f59 
PrintStackTraceSignalHandler(void*) + 25
  2  clang0x000107993969 llvm::sys::RunSignalHandlers() 
+ 425
  3  clang0x0001079982e2 SignalHandler(int) + 354
  4  libsystem_platform.dylib 0x7fffc35cfefa _sigtramp + 26
  5  libsystem_platform.dylib 0x7fff5b10b6a8 _sigtramp + 2545137608
  6  libsystem_c.dylib0x7fffc341014a abort + 127
  7  clang0x000107872cf0 LLVMInstallFatalErrorHandler + 0
  8  clang0x00010856c51c 
clang::driver::CudaInstallationDetector::getLowestExistingArch() const + 1644
  9  clang0x00010856acfb 
clang::driver::toolchains::CudaToolChain::TranslateArgs(llvm::opt::DerivedArgList
 const&, llvm::StringRef, clang::driver::Action::OffloadKind) const + 1291
  10 clang0x00010843ce37 
clang::driver::Compilation::getArgsForToolChain(clang::driver::ToolChain 
const*, llvm::StringRef, clang::driver::Action::OffloadKind) + 295
  11 clang0x0001084768c0 
clang::driver::Driver::BuildJobsForActionNoCache(clang::driver::Compilation&, 
clang::driver::Action const*, clang::driver::ToolChain const*, llvm::StringRef, 
bool, bool, char const*, std::__1::map, 
std::__1::allocator > >, clang::driver::InputInfo, 
std::__1::less, 
std::__1::allocator > > >, 
std::__1::allocator, 
std::__1::allocator > > const, clang::driver::InputInfo> > >&, 
clang::driver::Action::OffloadKind) const + 4064
  12 clang0x000108475541 
clang::driver::Driver::BuildJobsForAction(clang::driver::Compilation&, 
clang::driver::Action const*, clang::driver::ToolChain const*, llvm::StringRef, 
bool, bool, char const*, std::__1::map, 
std::__1::allocator > >, clang::driver::InputInfo, 
std::__1::less, 
std::__1::allocator > > >, 
std::__1::allocator, 
std::__1::allocator > > const, clang::driver::InputInfo> > >&, 
clang::driver::Action::OffloadKind) const + 1393
  13 clang0x0001084765e3 
clang::driver::Driver::BuildJobsForActionNoCache(clang::driver::Compilation&, 
clang::driver::Action const*, clang::driver::ToolChain const*, llvm::StringRef, 
bool, bool, char const*, std::__1::map, 
std::__1::allocator > >, clang::driver::InputInfo, 
std::__1::less, 
std::__1::allocator > > >, 
std::__1::allocator, 
std::__1::allocator > > const, clang::driver::InputInfo> > >&, 
clang::driver::Action::OffloadKind) const + 3331
  14 clang0x000108475541 
clang::driver::Driver::BuildJobsForAction(clang::driver::Compilation&, 
clang::driver::Action const*, clang::driver::ToolChain const*, llvm::StringRef, 
bool, bool, char const*, std::__1::map, 
std::__1::allocator > >, clang::driver::InputInfo, 
std::__1::less, 
std::__1::allocator > > >, 
std::__1::allocator, 
std::__1::allocator > > const, clang::driver::InputInfo> > >&, 
clang::driver::Action::OffloadKind) const + 1393
  15 clang0x0001084765e3 
clang::driver::Driver::BuildJobsForActionNoCache(clang::driver::Compilation&, 
clang::driver::Action const*, clang::driver::ToolChain const*, llvm::StringRef, 
bool, bool, char const*, std::__1::map, 
std::__1::allocator > >, clang::driver::InputInfo, 
std::__1::less, 
std::__1::allocator > > >, 
std::__1::allocator, 
std::__1::allocator > > const, clang::driver::InputInfo> > >&, 
clang::driver::Action::OffloadKind) const + 3331
  16 clang0x000108475541 
clang::driver::Driver::BuildJobsForAction(clang::driver::Compilation&, 
clang::driver::Action const*, clang::driver::ToolChain const*, llvm::StringRef, 
bool, bool, char const*, std::__1::map, 
std::__1::allocator > >, clang::driver::InputInfo, 
std::__1::less, 
std::__1::allocator > > >, 
std::__1::allocator, 
std::__1::allocator > > const, clang::driver::InputInfo> > >&, 
clang::driver::Action::OffloadKind) const + 1393
  17 clang0x0001084765e3 
clang::driver::Driver::BuildJobsForActionNoCache(clang::driver::Compilation&, 
clang::driver::Action const*, clang::driver::ToolChain const*, llvm::StringRef, 
bool, bool, char const*, std::__1::map, 
std::__1::allocator > >, clang::driver::InputInfo, 
std::__1::less, 
std::__1::allocator > > >, 
std::__1::allocator, 
std::__1::allocator > > const, clang::dr

[PATCH] D36584: Implemented P0704R1 - Fixing const-qualified pointers to members

2017-08-10 Thread Hamza Sood via Phabricator via cfe-commits
hamzasood created this revision.

This patch provides an implementation for P0704R1 .

I also made it work pre-C++2a as an extension (with a warning) since that's how 
Clang seems to deal with small additions like this. Hopefully someone more 
knowledgable on the matter can clarify whether that's appropriate.


https://reviews.llvm.org/D36584

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaExprCXX.cpp
  test/CXX/expr/expr.mptr.oper/p6-0x.cpp
  test/CXX/expr/expr.mptr.oper/p6-2a.cpp
  www/cxx_status.html

Index: www/cxx_status.html
===
--- www/cxx_status.html
+++ www/cxx_status.html
@@ -777,13 +777,12 @@
 
 C++2a implementation status
 
-Clang does not yet support any of the proposed features of
-
+Clang has experimental support for some proposed features of
 the C++ standard following C++17, provisionally named C++2a.
 Note that support for these features may change or be removed without notice,
 as the draft C++2a standard evolves.
 
-
+You can use Clang in C++2a mode with the -std=c++2a option.
 
 
 List of features and minimum Clang version with support
@@ -803,7 +802,7 @@
 
   const&-qualified pointers to members
   http://wg21.link/p0704r1";>P0704R1
-  No
+  SVN
 
 
   Allow lambda-capture [=, this]
Index: test/CXX/expr/expr.mptr.oper/p6-2a.cpp
===
--- test/CXX/expr/expr.mptr.oper/p6-2a.cpp
+++ test/CXX/expr/expr.mptr.oper/p6-2a.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -std=c++2a -verify %s
+// expected-no-diagnostics
+
+struct X { void foo() const&; };
+
+void test() {
+  // Example from P0704R1.
+  X{}.foo();
+  (X{}.*&X::foo)();
+}
Index: test/CXX/expr/expr.mptr.oper/p6-0x.cpp
===
--- test/CXX/expr/expr.mptr.oper/p6-0x.cpp
+++ test/CXX/expr/expr.mptr.oper/p6-0x.cpp
@@ -12,14 +12,20 @@
 // expression whose object expression is an lvalue, the program is
 // ill-formed if the second operand is a pointer to member function
 // with ref-qualifier &&.
-void test(X *xp, int (X::*pmf)(int), int (X::*l_pmf)(int) &, 
-  int (X::*r_pmf)(int) &&) {
+void test(X *xp, int (X::*pmf)(int), int (X::*const_l_pmf)(int) const&,
+  int (X::*l_pmf)(int) &, int (X::*r_pmf)(int) &&) {
   // No ref-qualifier.
   (lvalue().*pmf)(17);
   (xvalue().*pmf)(17);
   (prvalue().*pmf)(17);
   (xp->*pmf)(17);
 
+  // Const Lvalue ref-qualifier.
+  (lvalue().*const_l_pmf)(17);
+  (xvalue().*const_l_pmf)(17); // expected-warning {{C++2a extension}}
+  (prvalue().*const_l_pmf)(17); // expected-warning {{C++2a extension}}
+  (xp->*const_l_pmf)(17);
+
   // Lvalue ref-qualifier.
   (lvalue().*l_pmf)(17);
   (xvalue().*l_pmf)(17); // expected-error-re{{pointer-to-member function type 'int (X::*)(int){{( __attribute__\(\(thiscall\)\))?}} &' can only be called on an lvalue}}
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -5162,22 +5162,32 @@
   QualType Result = MemPtr->getPointeeType();
   Result = Context.getCVRQualifiedType(Result, LHSType.getCVRQualifiers());
 
-  // C++0x [expr.mptr.oper]p6:
+  // C++2a [expr.mptr.oper]p6:
   //   In a .* expression whose object expression is an rvalue, the program is
-  //   ill-formed if the second operand is a pointer to member function with
-  //   ref-qualifier &. In a ->* expression or in a .* expression whose object
-  //   expression is an lvalue, the program is ill-formed if the second operand
-  //   is a pointer to member function with ref-qualifier &&.
+  //   ill-formed if the second operand is a pointer to member function whose
+  //   ref-qualifier is &, unless its cv-qualifier-seq is const. In an ->*
+  //   expression or in a .* expression whose object expression is an lvalue,
+  //   the program is ill-formed if the second operand is a pointer to member
+  //   function with ref-qualifier &&.
   if (const FunctionProtoType *Proto = Result->getAs()) {
 switch (Proto->getRefQualifier()) {
 case RQ_None:
   // Do nothing
   break;
 
 case RQ_LValue:
-  if (!isIndirect && !LHS.get()->Classify(Context).isLValue())
-Diag(Loc, diag::err_pointer_to_member_oper_value_classify)
-  << RHSType << 1 << LHS.get()->getSourceRange();
+  if (!isIndirect && !LHS.get()->Classify(Context).isLValue()) {
+if (Proto->isConst() && !Proto->isVolatile())
+  Diag(Loc,
+   !getLangOpts().CPlusPlus2a
+   ? diag::
+ ext_const_amp_pointer_to_member_on_rvalue_cxx2a
+   : diag::
+ warn_cxx1z_compat_const_amp_pointer_to_member_on_rvalue);
+else
+  Diag(Loc, diag::err_pointer_to_member_oper_value_classify)
+<< RHSTyp

[PATCH] D36251: [analyzer] Suppress warning when bug path contains noreturn function or return from main in MagentaHandleChecker

2017-08-10 Thread Haowei Wu via Phabricator via cfe-commits
haowei added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/MagentaHandleChecker.cpp:483-498
+void MagentaHandleChecker::checkPreStmt(const ReturnStmt *RS,
+CheckerContext &Ctx) const {
+  ProgramStateRef State = Ctx.getState();
+  const StackFrameContext *SFCtx = Ctx.getStackFrame();
+  if (!SFCtx || !SFCtx->inTopFrame())
+return;
+  const FunctionDecl *FD = dyn_cast_or_null(SFCtx->getDecl());

NoQ wrote:
> xazax.hun wrote:
> > NoQ wrote:
> > > I think the analyzer core should do this. This code already has a global 
> > > effect on the analysis - it's enough for one checker to generate the 
> > > sink. Additionally, there's also the CFG-based variant of 
> > > suppress-on-sink, which would need to be extended to support this as well 
> > > - this other variant kicks in when the analysis was interrupted before 
> > > reaching the sink (see D35673 and D35674).
> > Do we want to do this unconditionally? Are all of the resources cleaned up 
> > on all of the supported OSes, or maybe for some leak issues it still makes 
> > sense to warn in these cases? Or we simply favor false negatives over false 
> > positives in this case (might make sense)? 
> We could add a flag to `setSuppressOnSink()` as an orthogonal change if it 
> turns out that we need it; i'm not aware of any stuff that badly needs to be 
> cleaned up before normal program termination in the existing checkers.
I also think this should be done in a separate checker like 
NoReturnFunctionChecker or within the analyzer as some other resource leak 
checkers might need this. I am also thinking D36475 should be in a separate 
checker as well. That annotation support really helps us a lot in analyzing 
unit test code and it might be useful for others if someone run into similar 
situation like us. But I cannot decide if we should use the annotate attribute 
or define a new attribute just for the analyzer.


https://reviews.llvm.org/D36251



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


[PATCH] D35955: clang-format: Add preprocessor directive indentation

2017-08-10 Thread Erik Uhlmann via Phabricator via cfe-commits
euhlmann updated this revision to Diff 110602.
euhlmann edited the summary of this revision.
euhlmann added a comment.

The patch now uses `PPBranchLevel` to track indent level. It allows 
`PPBranchLevel` to go back down to -1. The existing `PPBranchLevel >= 0` checks 
appear to prevent indexing into structures when `PPBranchLevel` is -1.


https://reviews.llvm.org/D35955

Files:
  docs/ClangFormatStyleOptions.rst
  include/clang/Format/Format.h
  lib/Format/ContinuationIndenter.cpp
  lib/Format/Format.cpp
  lib/Format/UnwrappedLineFormatter.cpp
  lib/Format/UnwrappedLineParser.cpp
  lib/Format/UnwrappedLineParser.h
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -2286,8 +2286,158 @@
getLLVMStyleWithColumns(11));
 }
 
-TEST_F(FormatTest, IndentPreprocessorDirectivesAtZero) {
-  EXPECT_EQ("{\n  {\n#define A\n  }\n}", format("{{\n#define A\n}}"));
+TEST_F(FormatTest, IndentPreprocessorDirectives) {
+  FormatStyle Style = getLLVMStyle();
+  Style.IndentPPDirectives = FormatStyle::PPDIS_None;
+  verifyFormat("#ifdef _WIN32\n"
+   "#define A 0\n"
+   "#ifdef VAR2\n"
+   "#define B 1\n"
+   "#include \n"
+   "#define MACRO  "
+   "\\\n"
+   "  some_very_long_func_a"
+   "a();\n"
+   "#endif\n"
+   "#else\n"
+   "#define A 1\n"
+   "#endif",
+   Style);
+
+  Style.IndentPPDirectives = FormatStyle::PPDIS_AfterHash;
+  verifyFormat("#ifdef _WIN32\n"
+   "#  define A 0\n"
+   "#  ifdef VAR2\n"
+   "#define B 1\n"
+   "#include \n"
+   "#define MACRO  "
+   "\\\n"
+   "  some_very_long_func_a"
+   "a();\n"
+   "#  endif\n"
+   "#else\n"
+   "#  define A 1\n"
+   "#endif",
+   Style);
+  // Test with include guards.
+  EXPECT_EQ("#ifndef _SOMEFILE_H\n"
+"#define _SOMEFILE_H\n"
+"code();\n"
+"#endif",
+format("#ifndef _SOMEFILE_H\n"
+   "#define _SOMEFILE_H\n"
+   "code();\n"
+   "#endif",
+   Style));
+  // Include guards must have a #define with the same variable immediately
+  // after #ifndef.
+  EXPECT_EQ("#ifndef NOT_GUARD\n"
+"#  define FOO\n"
+"code();\n"
+"#endif",
+format("#ifndef NOT_GUARD\n"
+   "#  define FOO\n"
+   "code();\n"
+   "#endif",
+   Style));
+
+  // Include guards must cover the entire file.
+  EXPECT_EQ("code();\n"
+"#ifndef NOT_GUARD\n"
+"#  define NOT_GUARD\n"
+"code();\n"
+"#endif",
+format("code();\n"
+   "#ifndef NOT_GUARD\n"
+   "#  define NOT_GUARD\n"
+   "code();\n"
+   "#endif",
+   Style));
+  EXPECT_EQ("#ifndef NOT_GUARD\n"
+"#  define NOT_GUARD\n"
+"code();\n"
+"#endif\n"
+"code();",
+format("#ifndef NOT_GUARD\n"
+   "#  define NOT_GUARD\n"
+   "code();\n"
+   "#endif\n"
+   "code();",
+   Style));
+  // Include guards don't have #else.
+  EXPECT_EQ("#ifndef NOT_GUARD\n"
+"#  define NOT_GUARD\n"
+"code();\n"
+"#else\n"
+"#endif",
+format("#ifndef NOT_GUARD\n"
+   "#  define NOT_GUARD\n"
+   "code();\n"
+   "#else\n"
+   "#endif",
+   Style));
+  EXPECT_EQ("#ifndef NOT_GUARD\n"
+"#  define NOT_GUARD\n"
+"code();\n"
+"#elif FOO\n"
+"#endif",
+format("#ifndef NOT_GUARD\n"
+   "#  define NOT_GUARD\n"
+   "code();\n"
+   "#elif FOO\n"
+   "#endif",
+   Style));
+  // Defect: We currently do not deal with the case where there's code between
+  // the #ifndef and #define but all other conditions hold. This is because when
+  // the #define line is parsed, UnwrappedLineParser::Lines doesn't hold the
+  // previous code line yet, so we can't detect it.
+  EXPECT_NE("#ifndef NOT_GUARD\n"
+"code();\n"
+"#  define NOT_GUARD\n"
+"code();\n"
+"#endif",
+  

[PATCH] D29660: [OpenMP] Add flag for overwriting default PTX version for OpenMP targets

2017-08-10 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added a comment.

In https://reviews.llvm.org/D29660#838185, @alekseyshl wrote:

> In https://reviews.llvm.org/D29660#838150, @gtbercea wrote:
>
> > First of all, I apologize if I've upset you with my previous post. I am 
> > actively working on understanding what is causing these issues. It is not 
> > my intention to write tests that work on local configurations only. I am 
> > upset to see that these tests keep failing for your and maybe other 
> > configurations. Without knowing the actual reason of the failures I can 
> > only speculate what is going wrong with them hence the flurry of changes.
>
>
> Thank you, apology accepted. That was exactly my point, not to start a fight, 
> but to emphasize that depending on local configuration is never going to 
> work, you will never be able to see and test all of them. Please disable the 
> test ASAP and until the better way to handle it is determined.


I have disabled all the offloading tests apart from the ones that pertain to 
the patch previous to the one introducing Cubin integration into host bin.
Please let me know if you see any more failures on your side. If you do feel 
free to revert all the patches up to and including: 
https://reviews.llvm.org/D29654

310625


Repository:
  rL LLVM

https://reviews.llvm.org/D29660



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


r310627 - [Parse] Document Parser::SkipFunctionBodies

2017-08-10 Thread Brian Gesiak via cfe-commits
Author: modocache
Date: Thu Aug 10 10:02:04 2017
New Revision: 310627

URL: http://llvm.org/viewvc/llvm-project?rev=310627&view=rev
Log:
[Parse] Document Parser::SkipFunctionBodies

Reviewers: erikjv, doug.gregor

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/Parse/Parser.h

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=310627&r1=310626&r2=310627&view=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Thu Aug 10 10:02:04 2017
@@ -253,6 +253,10 @@ class Parser : public CodeCompletionHand
   /// be NULL.
   bool ParsingInObjCContainer;
 
+  /// Whether to skip parsing of function bodies.
+  ///
+  /// This option can be used, for example, to speed up searches for
+  /// delcarations/definitions when indexing.
   bool SkipFunctionBodies;
 
   /// The location of the expression statement that is being parsed right now.


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


  1   2   >