r354549 - Revert r354546

2019-02-20 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Wed Feb 20 22:59:21 2019
New Revision: 354549

URL: http://llvm.org/viewvc/llvm-project?rev=354549=rev
Log:
Revert r354546

This triggers an ICE on gcc 7, see 
http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/17598/steps/build%20stage%201/logs/stdio

Modified:
cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h

Modified: cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h?rev=354549=354548=354549=diff
==
--- cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h (original)
+++ cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h Wed Feb 20 22:59:21 2019
@@ -111,13 +111,14 @@ private:
   }
 
   ABIArgInfo(Kind K)
-  : TypeData(nullptr), PaddingType(nullptr), DirectOffset(0), TheKind(K),
-PaddingInReg(false), InAllocaSRet(false), IndirectByVal(false),
-IndirectRealign(false), SRetAfterThis(false), InReg(false),
-CanBeFlattened(false), SignExt(false), SuppressSRet(false) {}
+  : TheKind(K), PaddingInReg(false), InReg(false), SuppressSRet(false) {
+  }
 
-public : ABIArgInfo()
-: ABIArgInfo(Direct) {}
+public:
+  ABIArgInfo()
+  : TypeData(nullptr), PaddingType(nullptr), DirectOffset(0),
+TheKind(Direct), PaddingInReg(false), InReg(false),
+SuppressSRet(false) {}
 
   static ABIArgInfo getDirect(llvm::Type *T = nullptr, unsigned Offset = 0,
   llvm::Type *Padding = nullptr,


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


r354548 - Fix typo in r354546

2019-02-20 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Wed Feb 20 22:12:41 2019
New Revision: 354548

URL: http://llvm.org/viewvc/llvm-project?rev=354548=rev
Log:
Fix typo in r354546

Modified:
cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h

Modified: cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h?rev=354548=354547=354548=diff
==
--- cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h (original)
+++ cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h Wed Feb 20 22:12:41 2019
@@ -115,11 +115,9 @@ private:
 PaddingInReg(false), InAllocaSRet(false), IndirectByVal(false),
 IndirectRealign(false), SRetAfterThis(false), InReg(false),
 CanBeFlattened(false), SignExt(false), SuppressSRet(false) {}
-}
 
 public : ABIArgInfo()
-: ABIArgInfo(Direct) {
-}
+: ABIArgInfo(Direct) {}
 
   static ABIArgInfo getDirect(llvm::Type *T = nullptr, unsigned Offset = 0,
   llvm::Type *Padding = nullptr,


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


RE: [clang-tools-extra] r354517 - [clang-tidy] refactor ExceptionAnalyzer further to give ternary answer

2019-02-20 Thread via cfe-commits
Hi Jonas,

I've committed what I think should be a fix for the build issue in r354545.

Douglas Yung

-Original Message-
From: cfe-commits  On Behalf Of via 
cfe-commits
Sent: Wednesday, February 20, 2019 16:57
To: jonas.t...@gmail.com
Cc: cfe-commits@lists.llvm.org
Subject: RE: [clang-tools-extra] r354517 - [clang-tidy] refactor 
ExceptionAnalyzer further to give ternary answer

Hi Jonas,

Your commit seems to hit a compilation error on our internal build bot when 
built on Windows using Visual Studio 2015. Can you take a look?

  ExceptionAnalyzer.cpp
c:\src\upstream\llvm_clean\tools\clang\tools\extra\clang-tidy\utils\ExceptionAnalyzer.h(112):
 error C3431: 'State': a scoped enumeration cannot be redeclared as an unscoped 
enumeration 
[C:\src\upstream\354517-win32-Release\tools\clang\tools\extra\clang-tidy\utils\clangTidyUtils.vcxproj]

Douglas Yung

-Original Message-
From: cfe-commits  On Behalf Of Jonas Toth 
via cfe-commits
Sent: Wednesday, February 20, 2019 13:05
To: cfe-commits@lists.llvm.org
Subject: [clang-tools-extra] r354517 - [clang-tidy] refactor ExceptionAnalyzer 
further to give ternary answer

Author: jonastoth
Date: Wed Feb 20 13:04:36 2019
New Revision: 354517

URL: http://llvm.org/viewvc/llvm-project?rev=354517=rev
Log:
[clang-tidy] refactor ExceptionAnalyzer further to give ternary answer

Summary:
The analsis on the throwing behvaiour on functions and statements gave only a 
binary answer whether an exception could occur and if yes which types are 
thrown.
This refactoring allows keeping track if there is a unknown factor, because the 
code calls to some functions with unavailable source code with no `noexcept` 
information.
This 'potential Unknown' information is propagated properly and can be queried 
separately.

Reviewers: lebedev.ri, aaron.ballman, baloghadamsoftware, alexfh

Reviewed By: lebedev.ri, baloghadamsoftware

Subscribers: xazax.hun, rnkovacs, a.sidorin, Szelethus, donat.nagy, dkrupp, 
cfe-commits

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clang-tidy/bugprone/ExceptionEscapeCheck.cpp
clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.cpp
clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.h

Modified: clang-tools-extra/trunk/clang-tidy/bugprone/ExceptionEscapeCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/ExceptionEscapeCheck.cpp?rev=354517=354516=354517=diff
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/ExceptionEscapeCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/ExceptionEscapeCheck.cpp
+++ Wed Feb 20 13:04:36 2019
@@ -42,6 +42,7 @@ ExceptionEscapeCheck::ExceptionEscapeChe
   IgnoredExceptions.insert(IgnoredExceptionsVec.begin(),
IgnoredExceptionsVec.end());
   Tracer.ignoreExceptions(std::move(IgnoredExceptions));
+  Tracer.ignoreBadAlloc(true);
 }
 
 void ExceptionEscapeCheck::storeOptions(ClangTidyOptions::OptionMap ) { 
@@ -70,7 +71,8 @@ void ExceptionEscapeCheck::check(const M
   if (!MatchedDecl)
 return;
 
-  if (Tracer.throwsException(MatchedDecl))
+  if (Tracer.analyze(MatchedDecl).getBehaviour() ==
+  utils::ExceptionAnalyzer::State::Throwing)
 // FIXME: We should provide more information about the exact location where
 // the exception is thrown, maybe the full path the exception escapes
 diag(MatchedDecl->getLocation(),

Modified: clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.cpp?rev=354517=354516=354517=diff
==
--- clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.cpp Wed 
+++ Feb 20 13:04:36 2019
@@ -8,10 +8,44 @@
 
 #include "ExceptionAnalyzer.h"
 
-#include "clang/AST/ASTContext.h"
-#include "clang/ASTMatchers/ASTMatchFinder.h"
-
 namespace clang {
+namespace tidy {
+namespace utils {
+
+void ExceptionAnalyzer::ExceptionInfo::registerException(
+const Type *ExceptionType) {
+  assert(ExceptionType != nullptr && "Only valid types are accepted");
+  Behaviour = State::Throwing;
+  ThrownExceptions.insert(ExceptionType);
+}
+
+void ExceptionAnalyzer::ExceptionInfo::registerExceptions(
+const Throwables ) {
+  if (Exceptions.size() == 0)
+return;
+  Behaviour = State::Throwing;
+  ThrownExceptions.insert(Exceptions.begin(), Exceptions.end()); }
+
+ExceptionAnalyzer::ExceptionInfo ::ExceptionInfo::merge(
+const ExceptionAnalyzer::ExceptionInfo ) {
+  // Only the following two cases require an update to the local
+  // 'Behaviour'. If the local entity is already throwing there will be 
+no
+  // change and if the other entity is throwing the merged entity will 

[PATCH] D57523: Fix uninitialized value in ABIArgInfo

2019-02-20 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354546: [NFC] Always initialize all members in ABIArgInfo 
(authored by serge_sans_paille, committed by ).
Herald added a project: LLVM.

Changed prior to commit:
  https://reviews.llvm.org/D57523?vs=184529=187724#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57523/new/

https://reviews.llvm.org/D57523

Files:
  cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h


Index: cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h
===
--- cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h
+++ cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h
@@ -111,14 +111,15 @@
   }
 
   ABIArgInfo(Kind K)
-  : TheKind(K), PaddingInReg(false), InReg(false), SuppressSRet(false) {
-  }
-
-public:
-  ABIArgInfo()
-  : TypeData(nullptr), PaddingType(nullptr), DirectOffset(0),
-TheKind(Direct), PaddingInReg(false), InReg(false),
-SuppressSRet(false) {}
+  : TypeData(nullptr), PaddingType(nullptr), DirectOffset(0), TheKind(K),
+PaddingInReg(false), InAllocaSRet(false), IndirectByVal(false),
+IndirectRealign(false), SRetAfterThis(false), InReg(false),
+CanBeFlattened(false), SignExt(false), SuppressSRet(false) {}
+}
+
+public : ABIArgInfo()
+: ABIArgInfo(Direct) {
+}
 
   static ABIArgInfo getDirect(llvm::Type *T = nullptr, unsigned Offset = 0,
   llvm::Type *Padding = nullptr,


Index: cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h
===
--- cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h
+++ cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h
@@ -111,14 +111,15 @@
   }
 
   ABIArgInfo(Kind K)
-  : TheKind(K), PaddingInReg(false), InReg(false), SuppressSRet(false) {
-  }
-
-public:
-  ABIArgInfo()
-  : TypeData(nullptr), PaddingType(nullptr), DirectOffset(0),
-TheKind(Direct), PaddingInReg(false), InReg(false),
-SuppressSRet(false) {}
+  : TypeData(nullptr), PaddingType(nullptr), DirectOffset(0), TheKind(K),
+PaddingInReg(false), InAllocaSRet(false), IndirectByVal(false),
+IndirectRealign(false), SRetAfterThis(false), InReg(false),
+CanBeFlattened(false), SignExt(false), SuppressSRet(false) {}
+}
+
+public : ABIArgInfo()
+: ABIArgInfo(Direct) {
+}
 
   static ABIArgInfo getDirect(llvm::Type *T = nullptr, unsigned Offset = 0,
   llvm::Type *Padding = nullptr,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r354545 - Attempt to fix VS2015 build breakage from r354517. NFCI.

2019-02-20 Thread Douglas Yung via cfe-commits
Author: dyung
Date: Wed Feb 20 20:55:31 2019
New Revision: 354545

URL: http://llvm.org/viewvc/llvm-project?rev=354545=rev
Log:
Attempt to fix VS2015 build breakage from r354517. NFCI.

Modified:
clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.h

Modified: clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.h?rev=354545=354544=354545=diff
==
--- clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.h (original)
+++ clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.h Wed Feb 20 
20:55:31 2019
@@ -109,7 +109,7 @@ public:
 
 /// Keep track if the entity related to this 'ExceptionInfo' can in 
princple
 /// throw, if it's unknown or if it won't throw.
-enum State Behaviour : 2;
+State Behaviour : 2;
 
 /// Keep track if the entity contains any unknown elements to keep track
 /// of the certainty of decisions and/or correct 'Behaviour' transition


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


r354546 - [NFC] Always initialize all members in ABIArgInfo

2019-02-20 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Wed Feb 20 20:55:50 2019
New Revision: 354546

URL: http://llvm.org/viewvc/llvm-project?rev=354546=rev
Log:
[NFC] Always initialize all members in ABIArgInfo

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

Modified:
cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h

Modified: cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h?rev=354546=354545=354546=diff
==
--- cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h (original)
+++ cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h Wed Feb 20 20:55:50 2019
@@ -111,14 +111,15 @@ private:
   }
 
   ABIArgInfo(Kind K)
-  : TheKind(K), PaddingInReg(false), InReg(false), SuppressSRet(false) {
-  }
+  : TypeData(nullptr), PaddingType(nullptr), DirectOffset(0), TheKind(K),
+PaddingInReg(false), InAllocaSRet(false), IndirectByVal(false),
+IndirectRealign(false), SRetAfterThis(false), InReg(false),
+CanBeFlattened(false), SignExt(false), SuppressSRet(false) {}
+}
 
-public:
-  ABIArgInfo()
-  : TypeData(nullptr), PaddingType(nullptr), DirectOffset(0),
-TheKind(Direct), PaddingInReg(false), InReg(false),
-SuppressSRet(false) {}
+public : ABIArgInfo()
+: ABIArgInfo(Direct) {
+}
 
   static ABIArgInfo getDirect(llvm::Type *T = nullptr, unsigned Offset = 0,
   llvm::Type *Padding = nullptr,


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


[PATCH] D57523: Fix uninitialized value in ABIArgInfo

2019-02-20 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

@hans agreed; Thanks for taking the time to try to reproduce the original issue 
o/


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57523/new/

https://reviews.llvm.org/D57523



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


[PATCH] D58367: [analyzer] NFC: Improve upon the concept of BugReporterVisitor.

2019-02-20 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Thx!~

In D58368#1404747 , @Charusso wrote:

> This is a cool approach, but it is difficult to use this API in other 
> checkers. If you do not out-chain D58367  I 
> would like to see something like that here:
>
>   SmallString<64> Str;
>   llvm::raw_svector_ostream OS(Str);
>   OS << "Deallocating object passed through parameter '" << PVD->getName()
>  << '\'';
>  
>   C.addNote(C.getState()->set(true), OS.str());
>


The idea to //allow// passing a raw std::string instead of a lambda that 
generates a string sounds like a great improvement, i'll do this.

I don't think i want to //disallow// lambdas entirely, because

- Some dynamic logic is definitely often necessary - eg., the MallocChecker 
example above. Essentially, in most cases we don't know what message should we 
produce (or even whether we should produce it at all) until the bug report is 
actually emitted. This specific checker is very lucky in that regard: every 
transition produced by this checker on the execution path does deserve a 
message, and this message doesn't depend on the bug report in any manner, but 
only on the event that caused it to appear.
- I want to make the API flexible enough to avoid performance problems. 
Generating the string is usually cheap, but transitions are made much more 
often than warnings are issued (simply because most code doesn't cause us to 
produce a bug), so producing the message every time we make a transition is a 
much higher multiplier for the cost of generating the string than producing the 
message every time we make a transition-that-leads-to-a-bug.



Adding a comfy wrapper around `addTransition` that constructs the tag 
automatically is also a great idea, i'll do this, but i'd like to delay this a 
little bit because, well, `addTransition` API is generally a large source of 
pain for checker developers and could use a rework in order to make it more 
understandable.

In particular, the implementation you propose does a lot more than adding a 
note: it also adds, well, a transition. Namely, the reader would most likely 
expect the following code

  State1 = State->set(Value1);
  C.addNote(State1, "Message 1");
  State2 = State1->set(Value2);
  C.addNote(State2, "Message 2");

to make two updates to the state and display a note for each of them:

  /-\
  | Predecessor |
  | State   |
  \-/
||
\/
  /-\
  | Node1   |
  | State1  |
  | "Message 1" |
  \-/
||
\/
  /-\
  | Node2   |
  | State2  |
  | "Message 2" |
  \-/

The actual behavior, however, would be to split the execution path in two 
parallel paths, analyze them separately later, and mark each of them with the 
respective message:

   /-\
   | Predecessor |
   | State   |
   \-/
 ||   ||
 \/   \/
  /-\   /-\
  | Node1   |   | Node2   |
  | State1  |   | State2  |
  | "Message 1" |   | "Message 2" |
  \-/   \-/

We already have this problem with `generateNonFatalErrorNode()`: even though it 
explicitly states that it will generate a node, it's very unobvious that 
generating two error nodes not only allows you to report two bugs, but also 
causes an accidental state split. Additionally, such accidental state splits 
are hard to notice because most of the time it doesn't cause any visible 
differences apart from a 2x slowdown of the remaining analysis on that 
execution path. In case of `addNote()` it should be a bit better because you'd 
be able to notice that one of the state updates isn't taking place, leading to 
false positives, but in case of `generateNonFatalErrorNode()` there are often 
no state updates being made (which is bad on its own, but for a separate 
reason).

I do have one idea on how to make this less confusing, but it's a bigger piece 
of work.

In D58367#1404722 , @Charusso wrote:

> we do not care that much about the core `BugReporterVisitors` as they do 
> their job enough well.


If only that was so :)

In D58367#1404722 , @Charusso wrote:

> So with that, I would out-chain this patch from the MIG-patches because it is 
> a lot more serious problem-set. I also would like to ask you to take it more 
> serious, as all your mentioned benefits will rely on this simple and cool 
> approach, so it has to be flexible as possible.


I've been thinking for about a month about this until now, and i'm actually 
very surprised that i see no obvious flexibility issues here. Stateful visitors 
(eg., the ones that only highlight the *last* interesting event) can be easily 
implemented by keeping via lambdas as a private state data in the bug reporter. 
Mutually recursive 

[PATCH] D58477: [Driver] Fix float ABI default for Android ARMv8.

2019-02-20 Thread Stephen Hines via Phabricator via cfe-commits
srhines accepted this revision.
srhines added a comment.

Dan, this seems pretty important for the NDK. If you submit this, would you 
want it cherry-picked ASAP?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58477/new/

https://reviews.llvm.org/D58477



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


[PATCH] D56900: [Fixed Point Arithmetic] Fixed Point and Integer Conversions

2019-02-20 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan marked an inline comment as done.
leonardchan added inline comments.



Comment at: clang/test/Frontend/fixed_point_conversions.c:437
+  // DEFAULT-NEXT: [[RES:%[a-z0-9]+]] = trunc i39 [[SATMIN]] to i16
+  // DEFAULT-NEXT: store i16 [[RES]], i16* %sat_sa, align 2
+

leonardchan wrote:
> ebevhan wrote:
> > leonardchan wrote:
> > > leonardchan wrote:
> > > > ebevhan wrote:
> > > > > leonardchan wrote:
> > > > > > ebevhan wrote:
> > > > > > > Conversions like this are a bit odd. There shouldn't be a need to 
> > > > > > > upsize/upscale the container before the saturation, should there?
> > > > > > I see. You're saying that we can just check directly if the value 
> > > > > > exceeds 255 (or goes under -256) since the range of target values 
> > > > > > can always fit in the range of source values. Therefore we do not 
> > > > > > need to cast up since the only reason we would need to is if 
> > > > > > converting to a type with a greater source range.
> > > > > > 
> > > > > > In this case, we could technically have a special case for integers 
> > > > > > where I think we can perform the saturation checks without the 
> > > > > > initial sign extension. I think it might be simpler though if in 
> > > > > > `EmitFixedPointConversion`, we treat an integer as a 'zero-scale 
> > > > > > fixed point number'. I think the reason the upsizing occurs in the 
> > > > > > first place is so that we satisfy the first FX conversion rule of 
> > > > > > calculating the result with full precision of both operands.
> > > > > > I see. You're saying that we can just check directly if the value 
> > > > > > exceeds 255 (or goes under -256) since the range of target values 
> > > > > > can always fit in the range of source values. Therefore we do not 
> > > > > > need to cast up since the only reason we would need to is if 
> > > > > > converting to a type with a greater source range.
> > > > > 
> > > > > That's right. Though, for integer to fixed-point conversion, I don't 
> > > > > think you ever need to upcast first; either the integer is larger 
> > > > > than or equal to the integral part of the fixed-point type, in which 
> > > > > case we can check the magnitude in the type as is, or it's smaller, 
> > > > > and we don't have to do any saturation.
> > > > > 
> > > > > > I think it might be simpler though if in 
> > > > > > `EmitFixedPointConversion`, we treat an integer as a 'zero-scale 
> > > > > > fixed point number'.
> > > > > 
> > > > > Isn't this already the case? The semantics for an integer type are 
> > > > > fetched as a zero scale fixed-point type and used that way (except 
> > > > > when the target is an integer due to the rounding requirement).
> > > > > That's right. Though, for integer to fixed-point conversion, I don't 
> > > > > think you ever need to upcast first; either the integer is larger 
> > > > > than or equal to the integral part of the fixed-point type, in which 
> > > > > case we can check the magnitude in the type as is, or it's smaller, 
> > > > > and we don't have to do any saturation.
> > > > 
> > > > I see. I think this would be more of a matter then of when checking for 
> > > > saturation, we either should check against the source value after 
> > > > resizing and scaling (container), or the source by itself before 
> > > > resizing and scaling. Actually, I think that when comparing saturation 
> > > > against the source value, we could save an instruction since we can 
> > > > just generate a constant  to compare the source against instead of 
> > > > comparing against a potentially shifted value. I think this could work 
> > > > when converting from fixed point types as well.
> > > > 
> > > > With saturation conversion, (if the target scale >= src scale) 
> > > > currently we could generate up to 7 instructions:
> > > > - 1 resize + 1 shift on the result if target scale > src scale
> > > > - 1 cmp gt + 1 select for clamping to max
> > > > - 1 cmp lt + 1 select for clamping to min
> > > > - 1 resize if container width != target width
> > > > 
> > > > I think we don't need either the first or last resize if the constants 
> > > > that we check against are the respective max's/min's of the target type 
> > > > against the source. I think this deserves a patch on it's own though 
> > > > since it could change a bunch of tests that depend on 
> > > > `EmitFixedPointConversion`.
> > > > 
> > > > >Isn't this already the case? The semantics for an integer type are 
> > > > >fetched as a zero scale fixed-point type and used that way (except 
> > > > >when the target is an integer due to the rounding requirement).
> > > > 
> > > > What I meant by this was that we are already doing the right thing in 
> > > > that we calculate the result with the full precision of both operands.
> > > Added this change in D57553 and made it a child of this patch. 
> > I think the patch demonstrated to me that this emission can't be optimized 
> > in general without 

[PATCH] D56900: [Fixed Point Arithmetic] Fixed Point and Integer Conversions

2019-02-20 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added inline comments.



Comment at: clang/test/Frontend/fixed_point_conversions.c:437
+  // DEFAULT-NEXT: [[RES:%[a-z0-9]+]] = trunc i39 [[SATMIN]] to i16
+  // DEFAULT-NEXT: store i16 [[RES]], i16* %sat_sa, align 2
+

ebevhan wrote:
> leonardchan wrote:
> > leonardchan wrote:
> > > ebevhan wrote:
> > > > leonardchan wrote:
> > > > > ebevhan wrote:
> > > > > > Conversions like this are a bit odd. There shouldn't be a need to 
> > > > > > upsize/upscale the container before the saturation, should there?
> > > > > I see. You're saying that we can just check directly if the value 
> > > > > exceeds 255 (or goes under -256) since the range of target values can 
> > > > > always fit in the range of source values. Therefore we do not need to 
> > > > > cast up since the only reason we would need to is if converting to a 
> > > > > type with a greater source range.
> > > > > 
> > > > > In this case, we could technically have a special case for integers 
> > > > > where I think we can perform the saturation checks without the 
> > > > > initial sign extension. I think it might be simpler though if in 
> > > > > `EmitFixedPointConversion`, we treat an integer as a 'zero-scale 
> > > > > fixed point number'. I think the reason the upsizing occurs in the 
> > > > > first place is so that we satisfy the first FX conversion rule of 
> > > > > calculating the result with full precision of both operands.
> > > > > I see. You're saying that we can just check directly if the value 
> > > > > exceeds 255 (or goes under -256) since the range of target values can 
> > > > > always fit in the range of source values. Therefore we do not need to 
> > > > > cast up since the only reason we would need to is if converting to a 
> > > > > type with a greater source range.
> > > > 
> > > > That's right. Though, for integer to fixed-point conversion, I don't 
> > > > think you ever need to upcast first; either the integer is larger than 
> > > > or equal to the integral part of the fixed-point type, in which case we 
> > > > can check the magnitude in the type as is, or it's smaller, and we 
> > > > don't have to do any saturation.
> > > > 
> > > > > I think it might be simpler though if in `EmitFixedPointConversion`, 
> > > > > we treat an integer as a 'zero-scale fixed point number'.
> > > > 
> > > > Isn't this already the case? The semantics for an integer type are 
> > > > fetched as a zero scale fixed-point type and used that way (except when 
> > > > the target is an integer due to the rounding requirement).
> > > > That's right. Though, for integer to fixed-point conversion, I don't 
> > > > think you ever need to upcast first; either the integer is larger than 
> > > > or equal to the integral part of the fixed-point type, in which case we 
> > > > can check the magnitude in the type as is, or it's smaller, and we 
> > > > don't have to do any saturation.
> > > 
> > > I see. I think this would be more of a matter then of when checking for 
> > > saturation, we either should check against the source value after 
> > > resizing and scaling (container), or the source by itself before resizing 
> > > and scaling. Actually, I think that when comparing saturation against the 
> > > source value, we could save an instruction since we can just generate a 
> > > constant  to compare the source against instead of comparing against a 
> > > potentially shifted value. I think this could work when converting from 
> > > fixed point types as well.
> > > 
> > > With saturation conversion, (if the target scale >= src scale) currently 
> > > we could generate up to 7 instructions:
> > > - 1 resize + 1 shift on the result if target scale > src scale
> > > - 1 cmp gt + 1 select for clamping to max
> > > - 1 cmp lt + 1 select for clamping to min
> > > - 1 resize if container width != target width
> > > 
> > > I think we don't need either the first or last resize if the constants 
> > > that we check against are the respective max's/min's of the target type 
> > > against the source. I think this deserves a patch on it's own though 
> > > since it could change a bunch of tests that depend on 
> > > `EmitFixedPointConversion`.
> > > 
> > > >Isn't this already the case? The semantics for an integer type are 
> > > >fetched as a zero scale fixed-point type and used that way (except when 
> > > >the target is an integer due to the rounding requirement).
> > > 
> > > What I meant by this was that we are already doing the right thing in 
> > > that we calculate the result with the full precision of both operands.
> > Added this change in D57553 and made it a child of this patch. 
> I think the patch demonstrated to me that this emission can't be optimized in 
> general without breaking the minmax pattern on the saturation, and that is 
> very useful in some cases.
> 
> What I think I'm concerned about is conversions like `int -> _Sat _Fract`, 
> where there really is no point to upscaling at all, since the 

[PATCH] D56900: [Fixed Point Arithmetic] Fixed Point and Integer Conversions

2019-02-20 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 187706.
leonardchan marked an inline comment as done.
Herald added a subscriber: jdoerfert.

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56900/new/

https://reviews.llvm.org/D56900

Files:
  clang/include/clang/AST/OperationKinds.def
  clang/include/clang/Basic/FixedPoint.h
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Basic/FixedPoint.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CGExprComplex.cpp
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/Edit/RewriteObjCFoundationAPI.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
  clang/test/Frontend/fixed_point_conversions.c
  clang/test/Frontend/fixed_point_errors.c
  clang/test/Frontend/fixed_point_unknown_conversions.c

Index: clang/test/Frontend/fixed_point_unknown_conversions.c
===
--- clang/test/Frontend/fixed_point_unknown_conversions.c
+++ clang/test/Frontend/fixed_point_unknown_conversions.c
@@ -22,28 +22,19 @@
   _Fract fract = accum; // ok
   _Accum *accum_ptr;
 
-  accum = b;   // expected-error{{conversion between fixed point and '_Bool' is not yet supported}}
-  accum = i;   // expected-error{{conversion between fixed point and 'int' is not yet supported}}
-  accum = i;   // expected-error{{conversion between fixed point and 'int' is not yet supported}}
   accum = f;   // expected-error{{conversion between fixed point and 'float' is not yet supported}}
   accum = d;   // expected-error{{conversion between fixed point and 'double' is not yet supported}}
   accum = dc;  // expected-error{{conversion between fixed point and '_Complex double' is not yet supported}}
   accum = ic;  // expected-error{{conversion between fixed point and '_Complex int' is not yet supported}}
   accum = s;   // expected-error{{assigning to '_Accum' from incompatible type 'struct S'}}
-  accum = e;   // expected-error{{conversion between fixed point and 'enum E' is not yet supported}}
   accum = ptr; // expected-error{{assigning to '_Accum' from incompatible type 'int *'}}
   accum_ptr = ptr; // expected-warning{{incompatible pointer types assigning to '_Accum *' from 'int *'}}
-  accum = i2;  // expected-error{{conversion between fixed point and 'int_t' (aka 'int') is not yet supported}}
 
-  c = accum;   // expected-error{{conversion between fixed point and 'char' is not yet supported}}
-  i = accum;   // expected-error{{conversion between fixed point and 'int' is not yet supported}}
   f = accum;   // expected-error{{conversion between fixed point and 'float' is not yet supported}}
   d = accum;   // expected-error{{conversion between fixed point and 'double' is not yet supported}}
   dc = accum;  // expected-error{{conversion between fixed point and '_Complex double' is not yet supported}}
   ic = accum;  // expected-error{{conversion between fixed point and '_Complex int' is not yet supported}}
   s = accum;   // expected-error{{assigning to 'struct S' from incompatible type '_Accum'}}
-  e = accum;   // expected-error{{conversion between fixed point and 'enum E' is not yet supported}}
   ptr = accum; // expected-error{{assigning to 'int *' from incompatible type '_Accum'}}
   ptr = accum_ptr; // expected-warning{{incompatible pointer types assigning to 'int *' from '_Accum *'}}
-  i2 = accum;  // expected-error{{conversion between fixed point and 'int' is not yet supported}}
 }
Index: clang/test/Frontend/fixed_point_errors.c
===
--- clang/test/Frontend/fixed_point_errors.c
+++ clang/test/Frontend/fixed_point_errors.c
@@ -233,8 +233,20 @@
  // expected-warning@-1{{type specifier missing, defaults to 'int'}}
 }
 
+// Ok conversions
+int i_const = -2.5hk;
+_Sat short _Accum sat_sa_const2 = 256.0k;
+_Sat unsigned short _Accum sat_usa_const = -1.0hk;
+short _Accum sa_const3 = 2;
+short _Accum sa_const4 = -2;
+
 // Overflow
 short _Accum sa_const = 256.0k;   // expected-warning{{implicit conversion from 256.0 cannot fit within the range of values for 'short _Accum'}}
 short _Fract sf_const = 1.0hk;// expected-warning{{implicit conversion from 1.0 cannot fit within the range of values for 'short _Fract'}}
 unsigned _Accum ua_const = -1.0k; // expected-warning{{implicit conversion from -1.0 cannot fit within the range of values for 'unsigned _Accum'}}
 short _Accum sa_const2 = 128.0k + 128.0k; // expected-warning{{implicit conversion from 256.0 cannot fit within the range of values for 'short _Accum'}}
+short s_const = 65536.0lk;// expected-warning{{implicit conversion from 65536.0 cannot fit within the range of values for 'short'}}
+unsigned u_const = -2.5hk;// 

[PATCH] D50488: [Analyzer] Checker for non-determinism caused by sorting of pointer-like elements

2019-02-20 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang added a comment.

So I was able compile a couple of C++ code bases through csa-testbench. I built 
cppcheck and tinyxml2 without any problems. cppcheck has one invocation 
std::sort but the keys are not pointers whereas tinyxml2 does not use 
std::sort. I tried bitcoin, rtags, xerces but run into a lot of configure/build 
errors.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D50488/new/

https://reviews.llvm.org/D50488



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


[PATCH] D58317: [clang] Add install targets for library headers

2019-02-20 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai updated this revision to Diff 187698.
smeenai retitled this revision from "[clang] Add install targets for 
development headers" to "[clang] Add install targets for library headers".
smeenai edited the summary of this revision.
smeenai added a comment.

Update description


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58317/new/

https://reviews.llvm.org/D58317

Files:
  clang/CMakeLists.txt


Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -388,6 +388,7 @@
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
   install(DIRECTORY include/clang include/clang-c
 DESTINATION include
+COMPONENT clang-library-headers
 FILES_MATCHING
 PATTERN "*.def"
 PATTERN "*.h"
@@ -397,12 +398,23 @@
 
   install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/clang
 DESTINATION include
+COMPONENT clang-library-headers
 FILES_MATCHING
 PATTERN "CMakeFiles" EXCLUDE
 PATTERN "*.inc"
 PATTERN "*.h"
 )
 
+  # Installing the headers needs to depend on generating any public
+  # tablegen'd headers.
+  add_custom_target(clang-library-headers DEPENDS clang-tablegen-targets)
+  set_target_properties(clang-library-headers PROPERTIES FOLDER "Misc")
+  if(NOT LLVM_ENABLE_IDE)
+add_llvm_install_targets(install-clang-library-headers
+ DEPENDS clang-library-headers
+ COMPONENT clang-library-headers)
+  endif()
+
   install(PROGRAMS utils/bash-autocomplete.sh
 DESTINATION share/clang
 )


Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -388,6 +388,7 @@
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
   install(DIRECTORY include/clang include/clang-c
 DESTINATION include
+COMPONENT clang-library-headers
 FILES_MATCHING
 PATTERN "*.def"
 PATTERN "*.h"
@@ -397,12 +398,23 @@
 
   install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/clang
 DESTINATION include
+COMPONENT clang-library-headers
 FILES_MATCHING
 PATTERN "CMakeFiles" EXCLUDE
 PATTERN "*.inc"
 PATTERN "*.h"
 )
 
+  # Installing the headers needs to depend on generating any public
+  # tablegen'd headers.
+  add_custom_target(clang-library-headers DEPENDS clang-tablegen-targets)
+  set_target_properties(clang-library-headers PROPERTIES FOLDER "Misc")
+  if(NOT LLVM_ENABLE_IDE)
+add_llvm_install_targets(install-clang-library-headers
+ DEPENDS clang-library-headers
+ COMPONENT clang-library-headers)
+  endif()
+
   install(PROGRAMS utils/bash-autocomplete.sh
 DESTINATION share/clang
 )
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58317: [clang] Add install targets for library headers

2019-02-20 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai updated this revision to Diff 187697.
smeenai added a comment.

Switch to clang-library-headers pending cfe-dev discussion


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58317/new/

https://reviews.llvm.org/D58317

Files:
  clang/CMakeLists.txt


Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -388,6 +388,7 @@
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
   install(DIRECTORY include/clang include/clang-c
 DESTINATION include
+COMPONENT clang-library-headers
 FILES_MATCHING
 PATTERN "*.def"
 PATTERN "*.h"
@@ -397,12 +398,23 @@
 
   install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/clang
 DESTINATION include
+COMPONENT clang-library-headers
 FILES_MATCHING
 PATTERN "CMakeFiles" EXCLUDE
 PATTERN "*.inc"
 PATTERN "*.h"
 )
 
+  # Installing the headers needs to depend on generating any public
+  # tablegen'd headers.
+  add_custom_target(clang-library-headers DEPENDS clang-tablegen-targets)
+  set_target_properties(clang-library-headers PROPERTIES FOLDER "Misc")
+  if(NOT LLVM_ENABLE_IDE)
+add_llvm_install_targets(install-clang-library-headers
+ DEPENDS clang-library-headers
+ COMPONENT clang-library-headers)
+  endif()
+
   install(PROGRAMS utils/bash-autocomplete.sh
 DESTINATION share/clang
 )


Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -388,6 +388,7 @@
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
   install(DIRECTORY include/clang include/clang-c
 DESTINATION include
+COMPONENT clang-library-headers
 FILES_MATCHING
 PATTERN "*.def"
 PATTERN "*.h"
@@ -397,12 +398,23 @@
 
   install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/clang
 DESTINATION include
+COMPONENT clang-library-headers
 FILES_MATCHING
 PATTERN "CMakeFiles" EXCLUDE
 PATTERN "*.inc"
 PATTERN "*.h"
 )
 
+  # Installing the headers needs to depend on generating any public
+  # tablegen'd headers.
+  add_custom_target(clang-library-headers DEPENDS clang-tablegen-targets)
+  set_target_properties(clang-library-headers PROPERTIES FOLDER "Misc")
+  if(NOT LLVM_ENABLE_IDE)
+add_llvm_install_targets(install-clang-library-headers
+ DEPENDS clang-library-headers
+ COMPONENT clang-library-headers)
+  endif()
+
   install(PROGRAMS utils/bash-autocomplete.sh
 DESTINATION share/clang
 )
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58306: [AArch64] Change size suffix for FP16FML intrinsics.

2019-02-20 Thread Ahmed Bougacha via Phabricator via cfe-commits
ab added a comment.

Thanks for checking, much appreciated!


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58306/new/

https://reviews.llvm.org/D58306



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


[PATCH] D58306: [AArch64] Change size suffix for FP16FML intrinsics.

2019-02-20 Thread Ahmed Bougacha via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354538: [AArch64] Change size suffix for FP16FML intrinsics. 
(authored by ab, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58306?vs=187083=187696#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58306/new/

https://reviews.llvm.org/D58306

Files:
  cfe/trunk/include/clang/Basic/arm_neon.td
  cfe/trunk/test/CodeGen/aarch64-neon-fp16fml.c

Index: cfe/trunk/include/clang/Basic/arm_neon.td
===
--- cfe/trunk/include/clang/Basic/arm_neon.td
+++ cfe/trunk/include/clang/Basic/arm_neon.td
@@ -1651,18 +1651,18 @@
 
 // v8.2-A FP16 fused multiply-add long instructions.
 let ArchGuard = "defined(__ARM_FEATURE_FP16FML) && defined(__aarch64__)" in {
-  def VFMLAL_LOW  : SInst<"vfmlal_low", "ffHH", "UiQUi">;
-  def VFMLSL_LOW  : SInst<"vfmlsl_low", "ffHH", "UiQUi">;
-  def VFMLAL_HIGH : SInst<"vfmlal_high", "ffHH", "UiQUi">;
-  def VFMLSL_HIGH : SInst<"vfmlsl_high", "ffHH", "UiQUi">;
-
-  def VFMLAL_LANE_LOW  : SOpInst<"vfmlal_lane_low", "ffH0i", "UiQUi", OP_FMLAL_LN>;
-  def VFMLSL_LANE_LOW  : SOpInst<"vfmlsl_lane_low", "ffH0i", "UiQUi", OP_FMLSL_LN>;
-  def VFMLAL_LANE_HIGH : SOpInst<"vfmlal_lane_high", "ffH0i", "UiQUi", OP_FMLAL_LN_Hi>;
-  def VFMLSL_LANE_HIGH : SOpInst<"vfmlsl_lane_high", "ffH0i", "UiQUi", OP_FMLSL_LN_Hi>;
-
-  def VFMLAL_LANEQ_LOW  : SOpInst<"vfmlal_laneq_low", "ffH1i", "UiQUi", OP_FMLAL_LN>;
-  def VFMLSL_LANEQ_LOW  : SOpInst<"vfmlsl_laneq_low", "ffH1i", "UiQUi", OP_FMLSL_LN>;
-  def VFMLAL_LANEQ_HIGH : SOpInst<"vfmlal_laneq_high", "ffH1i", "UiQUi", OP_FMLAL_LN_Hi>;
-  def VFMLSL_LANEQ_HIGH : SOpInst<"vfmlsl_laneq_high", "ffH1i", "UiQUi", OP_FMLSL_LN_Hi>;
+  def VFMLAL_LOW  : SInst<"vfmlal_low",  "ffHH", "hQh">;
+  def VFMLSL_LOW  : SInst<"vfmlsl_low",  "ffHH", "hQh">;
+  def VFMLAL_HIGH : SInst<"vfmlal_high", "ffHH", "hQh">;
+  def VFMLSL_HIGH : SInst<"vfmlsl_high", "ffHH", "hQh">;
+
+  def VFMLAL_LANE_LOW  : SOpInst<"vfmlal_lane_low",  "ffH0i", "hQh", OP_FMLAL_LN>;
+  def VFMLSL_LANE_LOW  : SOpInst<"vfmlsl_lane_low",  "ffH0i", "hQh", OP_FMLSL_LN>;
+  def VFMLAL_LANE_HIGH : SOpInst<"vfmlal_lane_high", "ffH0i", "hQh", OP_FMLAL_LN_Hi>;
+  def VFMLSL_LANE_HIGH : SOpInst<"vfmlsl_lane_high", "ffH0i", "hQh", OP_FMLSL_LN_Hi>;
+
+  def VFMLAL_LANEQ_LOW  : SOpInst<"vfmlal_laneq_low",  "ffH1i", "hQh", OP_FMLAL_LN>;
+  def VFMLSL_LANEQ_LOW  : SOpInst<"vfmlsl_laneq_low",  "ffH1i", "hQh", OP_FMLSL_LN>;
+  def VFMLAL_LANEQ_HIGH : SOpInst<"vfmlal_laneq_high", "ffH1i", "hQh", OP_FMLAL_LN_Hi>;
+  def VFMLSL_LANEQ_HIGH : SOpInst<"vfmlsl_laneq_high", "ffH1i", "hQh", OP_FMLSL_LN_Hi>;
 }
Index: cfe/trunk/test/CodeGen/aarch64-neon-fp16fml.c
===
--- cfe/trunk/test/CodeGen/aarch64-neon-fp16fml.c
+++ cfe/trunk/test/CodeGen/aarch64-neon-fp16fml.c
@@ -9,188 +9,188 @@
 
 // Vector form
 
-float32x2_t test_vfmlal_low_u32(float32x2_t a, float16x4_t b, float16x4_t c) {
-// CHECK-LABEL: define <2 x float> @test_vfmlal_low_u32(<2 x float> %a, <4 x half> %b, <4 x half> %c)
+float32x2_t test_vfmlal_low_f16(float32x2_t a, float16x4_t b, float16x4_t c) {
+// CHECK-LABEL: define <2 x float> @test_vfmlal_low_f16(<2 x float> %a, <4 x half> %b, <4 x half> %c)
 // CHECK: [[RESULT:%.*]] = call <2 x float> @llvm.aarch64.neon.fmlal.v2f32.v4f16(<2 x float> %a, <4 x half> %b, <4 x half> %c)
 // CHECK: ret <2 x float> [[RESULT]]
-  return vfmlal_low_u32(a, b, c);
+  return vfmlal_low_f16(a, b, c);
 }
 
-float32x2_t test_vfmlsl_low_u32(float32x2_t a, float16x4_t b, float16x4_t c) {
-// CHECK-LABEL: define <2 x float> @test_vfmlsl_low_u32(<2 x float> %a, <4 x half> %b, <4 x half> %c)
+float32x2_t test_vfmlsl_low_f16(float32x2_t a, float16x4_t b, float16x4_t c) {
+// CHECK-LABEL: define <2 x float> @test_vfmlsl_low_f16(<2 x float> %a, <4 x half> %b, <4 x half> %c)
 // CHECK: [[RESULT:%.*]] = call <2 x float> @llvm.aarch64.neon.fmlsl.v2f32.v4f16(<2 x float> %a, <4 x half> %b, <4 x half> %c)
 // CHECK: ret <2 x float> [[RESULT]]
-  return vfmlsl_low_u32(a, b, c);
+  return vfmlsl_low_f16(a, b, c);
 }
 
-float32x2_t test_vfmlal_high_u32(float32x2_t a, float16x4_t b, float16x4_t c) {
-// CHECK-LABEL: define <2 x float> @test_vfmlal_high_u32(<2 x float> %a, <4 x half> %b, <4 x half> %c)
+float32x2_t test_vfmlal_high_f16(float32x2_t a, float16x4_t b, float16x4_t c) {
+// CHECK-LABEL: define <2 x float> @test_vfmlal_high_f16(<2 x float> %a, <4 x half> %b, <4 x half> %c)
 // CHECK: [[RESULT:%.*]] = call <2 x float> @llvm.aarch64.neon.fmlal2.v2f32.v4f16(<2 x float> %a, <4 x half> %b, <4 x half> %c)
 // CHECK: ret <2 x float> [[RESULT]]
-  return vfmlal_high_u32(a, b, c);
+  return vfmlal_high_f16(a, b, c);
 }
 
-float32x2_t test_vfmlsl_high_u32(float32x2_t a, float16x4_t b, float16x4_t c) {
-// CHECK-LABEL: 

r354538 - [AArch64] Change size suffix for FP16FML intrinsics.

2019-02-20 Thread Ahmed Bougacha via cfe-commits
Author: ab
Date: Wed Feb 20 17:13:27 2019
New Revision: 354538

URL: http://llvm.org/viewvc/llvm-project?rev=354538=rev
Log:
[AArch64] Change size suffix for FP16FML intrinsics.

These currently use _u32, but they should instead use _f16, the
types of the multiplication (matching the various integer vmlal
variants).

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

Modified:
cfe/trunk/include/clang/Basic/arm_neon.td
cfe/trunk/test/CodeGen/aarch64-neon-fp16fml.c

Modified: cfe/trunk/include/clang/Basic/arm_neon.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/arm_neon.td?rev=354538=354537=354538=diff
==
--- cfe/trunk/include/clang/Basic/arm_neon.td (original)
+++ cfe/trunk/include/clang/Basic/arm_neon.td Wed Feb 20 17:13:27 2019
@@ -1651,18 +1651,18 @@ let ArchGuard = "defined(__ARM_FEATURE_D
 
 // v8.2-A FP16 fused multiply-add long instructions.
 let ArchGuard = "defined(__ARM_FEATURE_FP16FML) && defined(__aarch64__)" in {
-  def VFMLAL_LOW  : SInst<"vfmlal_low", "ffHH", "UiQUi">;
-  def VFMLSL_LOW  : SInst<"vfmlsl_low", "ffHH", "UiQUi">;
-  def VFMLAL_HIGH : SInst<"vfmlal_high", "ffHH", "UiQUi">;
-  def VFMLSL_HIGH : SInst<"vfmlsl_high", "ffHH", "UiQUi">;
+  def VFMLAL_LOW  : SInst<"vfmlal_low",  "ffHH", "hQh">;
+  def VFMLSL_LOW  : SInst<"vfmlsl_low",  "ffHH", "hQh">;
+  def VFMLAL_HIGH : SInst<"vfmlal_high", "ffHH", "hQh">;
+  def VFMLSL_HIGH : SInst<"vfmlsl_high", "ffHH", "hQh">;
 
-  def VFMLAL_LANE_LOW  : SOpInst<"vfmlal_lane_low", "ffH0i", "UiQUi", 
OP_FMLAL_LN>;
-  def VFMLSL_LANE_LOW  : SOpInst<"vfmlsl_lane_low", "ffH0i", "UiQUi", 
OP_FMLSL_LN>;
-  def VFMLAL_LANE_HIGH : SOpInst<"vfmlal_lane_high", "ffH0i", "UiQUi", 
OP_FMLAL_LN_Hi>;
-  def VFMLSL_LANE_HIGH : SOpInst<"vfmlsl_lane_high", "ffH0i", "UiQUi", 
OP_FMLSL_LN_Hi>;
+  def VFMLAL_LANE_LOW  : SOpInst<"vfmlal_lane_low",  "ffH0i", "hQh", 
OP_FMLAL_LN>;
+  def VFMLSL_LANE_LOW  : SOpInst<"vfmlsl_lane_low",  "ffH0i", "hQh", 
OP_FMLSL_LN>;
+  def VFMLAL_LANE_HIGH : SOpInst<"vfmlal_lane_high", "ffH0i", "hQh", 
OP_FMLAL_LN_Hi>;
+  def VFMLSL_LANE_HIGH : SOpInst<"vfmlsl_lane_high", "ffH0i", "hQh", 
OP_FMLSL_LN_Hi>;
 
-  def VFMLAL_LANEQ_LOW  : SOpInst<"vfmlal_laneq_low", "ffH1i", "UiQUi", 
OP_FMLAL_LN>;
-  def VFMLSL_LANEQ_LOW  : SOpInst<"vfmlsl_laneq_low", "ffH1i", "UiQUi", 
OP_FMLSL_LN>;
-  def VFMLAL_LANEQ_HIGH : SOpInst<"vfmlal_laneq_high", "ffH1i", "UiQUi", 
OP_FMLAL_LN_Hi>;
-  def VFMLSL_LANEQ_HIGH : SOpInst<"vfmlsl_laneq_high", "ffH1i", "UiQUi", 
OP_FMLSL_LN_Hi>;
+  def VFMLAL_LANEQ_LOW  : SOpInst<"vfmlal_laneq_low",  "ffH1i", "hQh", 
OP_FMLAL_LN>;
+  def VFMLSL_LANEQ_LOW  : SOpInst<"vfmlsl_laneq_low",  "ffH1i", "hQh", 
OP_FMLSL_LN>;
+  def VFMLAL_LANEQ_HIGH : SOpInst<"vfmlal_laneq_high", "ffH1i", "hQh", 
OP_FMLAL_LN_Hi>;
+  def VFMLSL_LANEQ_HIGH : SOpInst<"vfmlsl_laneq_high", "ffH1i", "hQh", 
OP_FMLSL_LN_Hi>;
 }

Modified: cfe/trunk/test/CodeGen/aarch64-neon-fp16fml.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aarch64-neon-fp16fml.c?rev=354538=354537=354538=diff
==
--- cfe/trunk/test/CodeGen/aarch64-neon-fp16fml.c (original)
+++ cfe/trunk/test/CodeGen/aarch64-neon-fp16fml.c Wed Feb 20 17:13:27 2019
@@ -9,188 +9,188 @@
 
 // Vector form
 
-float32x2_t test_vfmlal_low_u32(float32x2_t a, float16x4_t b, float16x4_t c) {
-// CHECK-LABEL: define <2 x float> @test_vfmlal_low_u32(<2 x float> %a, <4 x 
half> %b, <4 x half> %c)
+float32x2_t test_vfmlal_low_f16(float32x2_t a, float16x4_t b, float16x4_t c) {
+// CHECK-LABEL: define <2 x float> @test_vfmlal_low_f16(<2 x float> %a, <4 x 
half> %b, <4 x half> %c)
 // CHECK: [[RESULT:%.*]] = call <2 x float> 
@llvm.aarch64.neon.fmlal.v2f32.v4f16(<2 x float> %a, <4 x half> %b, <4 x half> 
%c)
 // CHECK: ret <2 x float> [[RESULT]]
-  return vfmlal_low_u32(a, b, c);
+  return vfmlal_low_f16(a, b, c);
 }
 
-float32x2_t test_vfmlsl_low_u32(float32x2_t a, float16x4_t b, float16x4_t c) {
-// CHECK-LABEL: define <2 x float> @test_vfmlsl_low_u32(<2 x float> %a, <4 x 
half> %b, <4 x half> %c)
+float32x2_t test_vfmlsl_low_f16(float32x2_t a, float16x4_t b, float16x4_t c) {
+// CHECK-LABEL: define <2 x float> @test_vfmlsl_low_f16(<2 x float> %a, <4 x 
half> %b, <4 x half> %c)
 // CHECK: [[RESULT:%.*]] = call <2 x float> 
@llvm.aarch64.neon.fmlsl.v2f32.v4f16(<2 x float> %a, <4 x half> %b, <4 x half> 
%c)
 // CHECK: ret <2 x float> [[RESULT]]
-  return vfmlsl_low_u32(a, b, c);
+  return vfmlsl_low_f16(a, b, c);
 }
 
-float32x2_t test_vfmlal_high_u32(float32x2_t a, float16x4_t b, float16x4_t c) {
-// CHECK-LABEL: define <2 x float> @test_vfmlal_high_u32(<2 x float> %a, <4 x 
half> %b, <4 x half> %c)
+float32x2_t test_vfmlal_high_f16(float32x2_t a, float16x4_t b, float16x4_t c) {
+// CHECK-LABEL: define <2 x float> @test_vfmlal_high_f16(<2 x float> %a, <4 x 
half> %b, <4 x half> %c)
 // CHECK: [[RESULT:%.*]] = 

[PATCH] D58368: [analyzer] MIGChecker: Implement bug reporter visitors.

2019-02-20 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ marked 3 inline comments as done.
NoQ added a comment.

Thx!




Comment at: clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp:109
+llvm::raw_svector_ostream OS(Str);
+OS << "Deallocating object passed through parameter '" << PVD->getName()
+   << '\'';

dcoughlin wrote:
> Could we just have the note say "'name' is deallocated"?
> 
> Or "Value passed through parameter 'name' is deallocated"
> 
> The ".. is ... " construction matches our other checkers. (Like "Memory is 
> released" from the Malloc Checker.)
Great point! I'd pick the latter because it's important to point out that the 
value is loaded from the parameter.

Hmm, btw, we should probably add more "visitors" in order to explain that the 
value is indeed copied from the parameter.



Comment at: clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp:113
+  });
+  C.addTransition(C.getState()->set(true), T);
 }

Charusso wrote:
> This is a cool approach, but it is difficult to use this API in other 
> checkers. If you do not out-chain D58367 I would like to see something like 
> that here:
> 
> ```
>   SmallString<64> Str;
>   llvm::raw_svector_ostream OS(Str);
>   OS << "Deallocating object passed through parameter '" << PVD->getName()
>  << '\'';
> 
>   C.addNote(C.getState()->set(true), OS.str());
> ```
I'll reply in D58367 because it seems to be universally relevant :)



Comment at: clang/test/Analysis/mig.mm:52
+kern_return_t release_twice(mach_port_name_t port, vm_address_t addr1, 
vm_address_t addr2, vm_size_t size) {
+  kern_return_t ret = KERN_ERROR; // expected-note{{'ret' initialized to 1}}
+  vm_deallocate(port, addr1, size); // expected-note{{Deallocating object 
passed through parameter 'addr1'}}

dcoughlin wrote:
> A nice QoI improvement here (for a later patch, perhaps) would be to have 
> this note use the macro name: "'ret initialized to KERN_ERROR'".
> 
> Users probably won't know that KERN_ERROR is 1.
Yup, but that's a separate story, because this message is produced by a 
generic, checker-inspecific visitor. We'll have to teach 
~~`trackNullOrUndefValue()`~~ `trackExpressionValue()` to be aware of macros, 
and it might turn out that we'd also want to mention macro names in messages 
that correspond to the subsequent copies of the same value (which, in turn, is 
tricky as it causes time paradoxes due to visiting order).


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58368/new/

https://reviews.llvm.org/D58368



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


RE: [clang-tools-extra] r354517 - [clang-tidy] refactor ExceptionAnalyzer further to give ternary answer

2019-02-20 Thread via cfe-commits
Hi Jonas,

Your commit seems to hit a compilation error on our internal build bot when 
built on Windows using Visual Studio 2015. Can you take a look?

  ExceptionAnalyzer.cpp
c:\src\upstream\llvm_clean\tools\clang\tools\extra\clang-tidy\utils\ExceptionAnalyzer.h(112):
 error C3431: 'State': a scoped enumeration cannot be redeclared as an unscoped 
enumeration 
[C:\src\upstream\354517-win32-Release\tools\clang\tools\extra\clang-tidy\utils\clangTidyUtils.vcxproj]

Douglas Yung

-Original Message-
From: cfe-commits  On Behalf Of Jonas Toth 
via cfe-commits
Sent: Wednesday, February 20, 2019 13:05
To: cfe-commits@lists.llvm.org
Subject: [clang-tools-extra] r354517 - [clang-tidy] refactor ExceptionAnalyzer 
further to give ternary answer

Author: jonastoth
Date: Wed Feb 20 13:04:36 2019
New Revision: 354517

URL: http://llvm.org/viewvc/llvm-project?rev=354517=rev
Log:
[clang-tidy] refactor ExceptionAnalyzer further to give ternary answer

Summary:
The analsis on the throwing behvaiour on functions and statements gave only a 
binary answer whether an exception could occur and if yes which types are 
thrown.
This refactoring allows keeping track if there is a unknown factor, because the 
code calls to some functions with unavailable source code with no `noexcept` 
information.
This 'potential Unknown' information is propagated properly and can be queried 
separately.

Reviewers: lebedev.ri, aaron.ballman, baloghadamsoftware, alexfh

Reviewed By: lebedev.ri, baloghadamsoftware

Subscribers: xazax.hun, rnkovacs, a.sidorin, Szelethus, donat.nagy, dkrupp, 
cfe-commits

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clang-tidy/bugprone/ExceptionEscapeCheck.cpp
clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.cpp
clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.h

Modified: clang-tools-extra/trunk/clang-tidy/bugprone/ExceptionEscapeCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/ExceptionEscapeCheck.cpp?rev=354517=354516=354517=diff
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/ExceptionEscapeCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/ExceptionEscapeCheck.cpp 
+++ Wed Feb 20 13:04:36 2019
@@ -42,6 +42,7 @@ ExceptionEscapeCheck::ExceptionEscapeChe
   IgnoredExceptions.insert(IgnoredExceptionsVec.begin(),
IgnoredExceptionsVec.end());
   Tracer.ignoreExceptions(std::move(IgnoredExceptions));
+  Tracer.ignoreBadAlloc(true);
 }
 
 void ExceptionEscapeCheck::storeOptions(ClangTidyOptions::OptionMap ) { 
@@ -70,7 +71,8 @@ void ExceptionEscapeCheck::check(const M
   if (!MatchedDecl)
 return;
 
-  if (Tracer.throwsException(MatchedDecl))
+  if (Tracer.analyze(MatchedDecl).getBehaviour() ==
+  utils::ExceptionAnalyzer::State::Throwing)
 // FIXME: We should provide more information about the exact location where
 // the exception is thrown, maybe the full path the exception escapes
 diag(MatchedDecl->getLocation(),

Modified: clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.cpp?rev=354517=354516=354517=diff
==
--- clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.cpp Wed 
+++ Feb 20 13:04:36 2019
@@ -8,10 +8,44 @@
 
 #include "ExceptionAnalyzer.h"
 
-#include "clang/AST/ASTContext.h"
-#include "clang/ASTMatchers/ASTMatchFinder.h"
-
 namespace clang {
+namespace tidy {
+namespace utils {
+
+void ExceptionAnalyzer::ExceptionInfo::registerException(
+const Type *ExceptionType) {
+  assert(ExceptionType != nullptr && "Only valid types are accepted");
+  Behaviour = State::Throwing;
+  ThrownExceptions.insert(ExceptionType);
+}
+
+void ExceptionAnalyzer::ExceptionInfo::registerExceptions(
+const Throwables ) {
+  if (Exceptions.size() == 0)
+return;
+  Behaviour = State::Throwing;
+  ThrownExceptions.insert(Exceptions.begin(), Exceptions.end()); }
+
+ExceptionAnalyzer::ExceptionInfo ::ExceptionInfo::merge(
+const ExceptionAnalyzer::ExceptionInfo ) {
+  // Only the following two cases require an update to the local
+  // 'Behaviour'. If the local entity is already throwing there will be 
+no
+  // change and if the other entity is throwing the merged entity will 
+throw
+  // as well.
+  // If one of both entities is 'Unknown' and the other one does not 
+throw
+  // the merged entity is 'Unknown' as well.
+  if (Other.Behaviour == State::Throwing)
+Behaviour = State::Throwing;
+  else if (Other.Behaviour == State::Unknown && Behaviour == 
State::NotThrowing)
+Behaviour = State::Unknown;
+
+  ContainsUnknown = ContainsUnknown || 

[PATCH] D50488: [Analyzer] Checker for non-determinism caused by sorting of pointer-like elements

2019-02-20 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang added a comment.

In D50488#1403653 , @Szelethus wrote:

> In D50488#1403197 , @mgrang wrote:
>
> > > It's because it invokes CodeChecker, which by default enables 
> > > valist.Uninitialized, but not ValistBase. Do you have assert failures 
> > > after my hotfix?
> >
> > @Szelethus Thanks. I run into this assert when run through CodeChecker:
> >
> >   Assertion `CheckerTags.count(tag) != 0 && "Requested checker is not 
> > registered! Maybe you should add it as a " "dependency in Checkers.td?"'
> >
> >
> > Is there a workaround?
>
>
> Uhh, I'm afraid the only way out is to actually fix the problem :) couple 
> questions:
>
> 1. Are you *sure* that you rebased to rC354235 
>  (which is the hotfix I mentioned), 
> CodeChecker runs *that* clang when the assert failure happens?


I guess, I totally missed your hotfix. After sync'ing to the latest sources I 
no longer hit the assert. Thanks!

> 2. Can you provide a stacktrace? Luckily, that would for sure point me to the 
> problematic checker.
> 
> In D50488#1403199 , @mgrang wrote:
> 
>> Also I don't see the helptext for PointerSorting when I run:
>>
>>   clang -cc1 -analyzer-checker-help | grep Pointer
>>  
>> alpha.core.PointerArithmCheck for pointer arithmetic on 
>> locations other than array elements
>> alpha.core.PointerSub   Check for pointer subtractions on two 
>> pointers pointing to different memory chunks
>> alpha.nondeterminism.PointerSorting
>> cplusplus.InnerPointer  Check for inner pointers of C++ 
>> containers used after re/deallocation
>>
> 
> 
> How about `clang -cc1 -analyzer-checker-help | grep Pointer -A3`? There could 
> be a linebreak after the ckecker's name (raises the question though whether 
> it should be there).

Yep, line break it was. I see the help text with -A1.

> In D50488#1403212 , @mgrang wrote:
> 
>> > There is a revision to solve this problem here: D58065 
>> > . I guess your input, as someone who 
>> > didn't participate in the checker dependency related patch reviews would 
>> > be invaluable, in terms of whether my description is understandable enough.
>>
>> Thanks. I took a look at the documentation and it looks fine to me (modulo 
>> the comments from other reviewers and a couple of minor typos). I feel the 
>> csa-testbench documentation (https://github.com/Xazax-hun/csa-testbench) is 
>> very minimal and does not document a lot of intricacies which I had to 
>> figure out by trial-and-error.
> 
> 
> Due to an upcoming conference, I didn't bother with it much, i just used 
> CodeChecker on its own, which is fairly well documented.
>  I'm trying to move my checker out of alpha, and my testing goes as follows:
> 
> 1. Clone LLVM+Clang, cppcheck, rtags, bitcoin, xerces (~~you could throw in 
> vim, tmux, as your checker isnt C++ exclusive~~ (see edit), or whatever else)
> 2. Create compile_commands.json either with CMake 
> (-DCANE_GENERATE_COMPILE_COMMANDS, or smt similar), or `CodeChecker log`
> 3. `CodeChecker analyze` projects, paying attention to not forgetting the 
> CodeChecker flag `--verbose debug_analyzer` (and enabling your checker ofc), 
> and piping the output to a file
> 4. Create a `CodeChecker server`, `CodeChecker store` the results, and stare 
> at the web gui for hours. Its very pretty btw ;)
> 
>   Csa-testbench is a work in progress, so I guess you can expect more in the 
> future :)
> 
>   Thanks for your work, even through a few annoyances, very much appreciated!
> 
>   Edit: Since your checker **is** C++ exclusive, please return true only if 
> `LangOpts.CPlusPlus` is true in the `shouldRegister` function. Didn't catch 
> my eye at first.

Done.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D50488/new/

https://reviews.llvm.org/D50488



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


[PATCH] D58292: Add support for importing ChooseExpr AST nodes.

2019-02-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: lib/AST/ASTImporter.cpp:6140
+ExpectedStmt ASTNodeImporter::VisitChooseExpr(ChooseExpr *E) {
+  auto Imp = importSeq(E->getCond(), E->getLHS(), E->getRHS(),
+   E->getBuiltinLoc(), E->getRParenLoc(), E->getType());

aaron.ballman wrote:
> a_sidorin wrote:
> > aaron.ballman wrote:
> > > Please don't use `auto` here; the type isn't spelled out in the 
> > > initialization.
> > Hi Aaron,
> > importSeq() is a helper targeted to simplify a lot of imports done during 
> > AST node import and related error handling. The type of this `importSeq()` 
> > expression is `Expected > SourceLocation, QualType>>`, so I think it's better to leave it as `auto`.
> Wow. I really dislike that we basically *have* to hide the type information 
> because it's just too ugly to spell. I understand why we're using `auto` 
> based on your explanation, but it basically means I can't understand what 
> this code is doing without a lot more effort.
> 
> Let's keep the `auto`, but let's please stop using type compositions that 
> make it considerably harder to review the code. This feel like a misuse of 
> `std::tuple`.
After staring at this for longer, I no longer think it's a misuse of 
`std::tuple`, just... an unfortunate side-effect of the design of 
`importSeq()`. I don't have a good idea for how to make this easier on 
reviewers and other people who aren't frequently looking at the AST importing 
code. :-(


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58292/new/

https://reviews.llvm.org/D58292



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


[PATCH] D50488: [Analyzer] Checker for non-determinism caused by sorting of pointer-like elements

2019-02-20 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang updated this revision to Diff 187695.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D50488/new/

https://reviews.llvm.org/D50488

Files:
  docs/analyzer/checkers.rst
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp
  test/Analysis/ptr-sort.cpp
  www/analyzer/alpha_checks.html

Index: www/analyzer/alpha_checks.html
===
--- www/analyzer/alpha_checks.html
+++ www/analyzer/alpha_checks.html
@@ -33,6 +33,7 @@
 OS X Alpha Checkers
 Security Alpha Checkers
 Unix Alpha Checkers
+Non-determinism Alpha Checkers
 
 
 
@@ -1174,6 +1175,28 @@
 
 
 
+
+Non-determinism Alpha Checkers
+
+
+Name, DescriptionExample
+
+
+
+alpha.nondeterminism.PointerSorting
+(C++)
+Check for non-determinism caused by sorting of pointers.
+
+
+// C++
+void test() {
+ int a = 1, b = 2;
+ std::vector V = {, };
+ std::sort(V.begin(), V.end()); // warn
+}
+
+
+
  
  
 
Index: test/Analysis/ptr-sort.cpp
===
--- /dev/null
+++ test/Analysis/ptr-sort.cpp
@@ -0,0 +1,57 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.nondeterminism.PointerSorting %s -analyzer-output=text -verify
+
+#include "Inputs/system-header-simulator-cxx.h"
+namespace std {
+  template
+  bool is_sorted(ForwardIt first, ForwardIt last);
+
+  template 
+  void nth_element(RandomIt first, RandomIt nth, RandomIt last);
+
+  template
+  void partial_sort(RandomIt first, RandomIt middle, RandomIt last);
+
+  template
+  void sort (RandomIt first, RandomIt last);
+
+  template
+  void stable_sort(RandomIt first, RandomIt last);
+
+  template
+  BidirIt partition(BidirIt first, BidirIt last, UnaryPredicate p);
+
+  template
+  BidirIt stable_partition(BidirIt first, BidirIt last, UnaryPredicate p);
+}
+
+bool f (int x) { return true; }
+bool g (int *x) { return true; }
+
+void PointerSorting() {
+  int a = 1, b = 2, c = 3;
+  std::vector V1 = {a, b};
+  std::vector V2 = {, };
+
+  std::is_sorted(V1.begin(), V1.end());// no-warning
+  std::nth_element(V1.begin(), V1.begin() + 1, V1.end());  // no-warning
+  std::partial_sort(V1.begin(), V1.begin() + 1, V1.end()); // no-warning
+  std::sort(V1.begin(), V1.end()); // no-warning
+  std::stable_sort(V1.begin(), V1.end());  // no-warning
+  std::partition(V1.begin(), V1.end(), f); // no-warning
+  std::stable_partition(V1.begin(), V1.end(), g);  // no-warning
+
+  std::is_sorted(V2.begin(), V2.end()); // expected-warning {{Sorting pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerSorting]
+  // expected-note@-1 {{Sorting pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerSorting]
+  std::nth_element(V2.begin(), V2.begin() + 1, V2.end()); // expected-warning {{Sorting pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerSorting]
+  // expected-note@-1 {{Sorting pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerSorting]
+  std::partial_sort(V2.begin(), V2.begin() + 1, V2.end()); // expected-warning {{Sorting pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerSorting]
+  // expected-note@-1 {{Sorting pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerSorting]
+  std::sort(V2.begin(), V2.end()); // expected-warning {{Sorting pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerSorting]
+  // expected-note@-1 {{Sorting pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerSorting]
+  std::stable_sort(V2.begin(), V2.end()); // expected-warning {{Sorting pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerSorting]
+  // expected-note@-1 {{Sorting pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerSorting]
+  std::partition(V2.begin(), V2.end(), f); // expected-warning {{Sorting pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerSorting]
+  // expected-note@-1 {{Sorting pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerSorting]
+  std::stable_partition(V2.begin(), V2.end(), g); // expected-warning {{Sorting pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerSorting]
+  // expected-note@-1 {{Sorting pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerSorting]
+}
Index: lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp
===
--- /dev/null
+++ 

[PATCH] D58095: [clang-tidy] Make google-objc-function-naming ignore implicit functions 

2019-02-20 Thread Stephane Moore via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
stephanemoore marked an inline comment as done.
Closed by commit rCTE354534: [clang-tidy] Make google-objc-function-naming 
ignore implicit functions  (authored by stephanemoore, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D58095?vs=187512=187693#toc

Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58095/new/

https://reviews.llvm.org/D58095

Files:
  clang-tidy/google/FunctionNamingCheck.cpp
  test/clang-tidy/Inputs/Headers/stdio.h
  test/clang-tidy/google-objc-function-naming.m


Index: clang-tidy/google/FunctionNamingCheck.cpp
===
--- clang-tidy/google/FunctionNamingCheck.cpp
+++ clang-tidy/google/FunctionNamingCheck.cpp
@@ -93,12 +93,16 @@
   if (!getLangOpts().ObjC)
 return;
 
-  // Match function declarations that are not in system headers and are not
-  // main.
+  // Enforce Objective-C function naming conventions on all functions except:
+  // • Functions defined in system headers.
+  // • C++ member functions.
+  // • Namespaced functions.
+  // • Implicitly defined functions.
+  // • The main function.
   Finder->addMatcher(
   functionDecl(
   unless(anyOf(isExpansionInSystemHeader(), cxxMethodDecl(),
-   hasAncestor(namespaceDecl()), isMain(),
+   hasAncestor(namespaceDecl()), isMain(), isImplicit(),
matchesName(validFunctionNameRegex(true)),
allOf(isStaticStorageClass(),
  matchesName(validFunctionNameRegex(false))
Index: test/clang-tidy/google-objc-function-naming.m
===
--- test/clang-tidy/google-objc-function-naming.m
+++ test/clang-tidy/google-objc-function-naming.m
@@ -1,4 +1,12 @@
-// RUN: %check_clang_tidy %s google-objc-function-naming %t
+// RUN: %check_clang_tidy %s google-objc-function-naming %t -- -- -isystem 
%S/Inputs/Headers
+
+#include 
+
+static void TestImplicitFunctionDeclaration(int a) {
+  // Call a builtin function so that the compiler generates an implicit
+  // function declaration.
+  printf("%d", a);
+}
 
 typedef _Bool bool;
 
Index: test/clang-tidy/Inputs/Headers/stdio.h
===
--- test/clang-tidy/Inputs/Headers/stdio.h
+++ test/clang-tidy/Inputs/Headers/stdio.h
@@ -0,0 +1,18 @@
+//===--- stdio.h - Stub header for tests *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _STDIO_H_
+#define _STDIO_H_
+
+// A header intended to contain C standard input and output library
+// declarations.
+
+int printf(const char *, ...);
+
+#endif // _STDIO_H_
+


Index: clang-tidy/google/FunctionNamingCheck.cpp
===
--- clang-tidy/google/FunctionNamingCheck.cpp
+++ clang-tidy/google/FunctionNamingCheck.cpp
@@ -93,12 +93,16 @@
   if (!getLangOpts().ObjC)
 return;
 
-  // Match function declarations that are not in system headers and are not
-  // main.
+  // Enforce Objective-C function naming conventions on all functions except:
+  // • Functions defined in system headers.
+  // • C++ member functions.
+  // • Namespaced functions.
+  // • Implicitly defined functions.
+  // • The main function.
   Finder->addMatcher(
   functionDecl(
   unless(anyOf(isExpansionInSystemHeader(), cxxMethodDecl(),
-   hasAncestor(namespaceDecl()), isMain(),
+   hasAncestor(namespaceDecl()), isMain(), isImplicit(),
matchesName(validFunctionNameRegex(true)),
allOf(isStaticStorageClass(),
  matchesName(validFunctionNameRegex(false))
Index: test/clang-tidy/google-objc-function-naming.m
===
--- test/clang-tidy/google-objc-function-naming.m
+++ test/clang-tidy/google-objc-function-naming.m
@@ -1,4 +1,12 @@
-// RUN: %check_clang_tidy %s google-objc-function-naming %t
+// RUN: %check_clang_tidy %s google-objc-function-naming %t -- -- -isystem %S/Inputs/Headers
+
+#include 
+
+static void TestImplicitFunctionDeclaration(int a) {
+  // Call a builtin function so that the compiler generates an implicit
+  // function declaration.
+  printf("%d", a);
+}
 
 typedef _Bool bool;
 
Index: test/clang-tidy/Inputs/Headers/stdio.h
===
--- test/clang-tidy/Inputs/Headers/stdio.h
+++ test/clang-tidy/Inputs/Headers/stdio.h
@@ -0,0 +1,18 @@
+//===--- 

[PATCH] D58292: Add support for importing ChooseExpr AST nodes.

2019-02-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: lib/AST/ASTImporter.cpp:6140
+ExpectedStmt ASTNodeImporter::VisitChooseExpr(ChooseExpr *E) {
+  auto Imp = importSeq(E->getCond(), E->getLHS(), E->getRHS(),
+   E->getBuiltinLoc(), E->getRParenLoc(), E->getType());

a_sidorin wrote:
> aaron.ballman wrote:
> > Please don't use `auto` here; the type isn't spelled out in the 
> > initialization.
> Hi Aaron,
> importSeq() is a helper targeted to simplify a lot of imports done during AST 
> node import and related error handling. The type of this `importSeq()` 
> expression is `Expected SourceLocation, QualType>>`, so I think it's better to leave it as `auto`.
Wow. I really dislike that we basically *have* to hide the type information 
because it's just too ugly to spell. I understand why we're using `auto` based 
on your explanation, but it basically means I can't understand what this code 
is doing without a lot more effort.

Let's keep the `auto`, but let's please stop using type compositions that make 
it considerably harder to review the code. This feel like a misuse of 
`std::tuple`.



Comment at: lib/AST/ASTImporter.cpp:6160
+  // condition-dependent.
+  bool CondIsTrue = false;
+  if (!E->isConditionDependent())

a_sidorin wrote:
> aaron.ballman wrote:
> > `bool CondIsTrue = E->isConditionDependent() ? false : 
> > E->isConditionTrue();`
> `bool CondIsTrue = E->isConditionDependent() && E->isConditionTrue();`?
I like that even better than my suggestion. :-)


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58292/new/

https://reviews.llvm.org/D58292



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


[PATCH] D58478: [index-while-building] FileIndexRecord

2019-02-20 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang/include/clang/Index/DeclOccurrence.h:1
+//===--- DeclOccurrence.h - An occurrence of a decl within a file 
-===//
+//

Missing C++ tag. See other headers as example.



Comment at: clang/include/clang/Index/DeclOccurrence.h:5
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.

License should be updated.



Comment at: clang/include/clang/Index/DeclOccurrence.h:42
+
+#endif

Missing comment with header guard.



Comment at: clang/lib/Index/FileIndexRecord.cpp:45
+  for (auto  : Decls) {
+auto D = DclInfo.Dcl;
+SourceManager  = D->getASTContext().getSourceManager();

Type is not obvious, so auto should not be used.



Comment at: clang/lib/Index/FileIndexRecord.h:1
+//===--- FileIndexRecord.h - Index data per file 
--===//
+//

Missing C++ tag. See other headers as example.



Comment at: clang/lib/Index/FileIndexRecord.h:5
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.

License should be updated.



Comment at: clang/lib/Index/FileIndexRecord.h:58
+
+#endif

Missing comment with header guard.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58478/new/

https://reviews.llvm.org/D58478



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


[PATCH] D58292: Add support for importing ChooseExpr AST nodes.

2019-02-20 Thread Aleksei Sidorin via Phabricator via cfe-commits
a_sidorin added a comment.

Hi Tom,

Thank for the fixes, now the patch looks almost fine. I have a small nit 
inline, but I think the patch can land after this fix.




Comment at: lib/AST/ASTImporter.cpp:6140
+ExpectedStmt ASTNodeImporter::VisitChooseExpr(ChooseExpr *E) {
+  auto Imp = importSeq(E->getCond(), E->getLHS(), E->getRHS(),
+   E->getBuiltinLoc(), E->getRParenLoc(), E->getType());

aaron.ballman wrote:
> Please don't use `auto` here; the type isn't spelled out in the 
> initialization.
Hi Aaron,
importSeq() is a helper targeted to simplify a lot of imports done during AST 
node import and related error handling. The type of this `importSeq()` 
expression is `Expected>`, so I think it's better to leave it as `auto`.



Comment at: lib/AST/ASTImporter.cpp:6160
+  // condition-dependent.
+  bool CondIsTrue = false;
+  if (!E->isConditionDependent())

aaron.ballman wrote:
> `bool CondIsTrue = E->isConditionDependent() ? false : E->isConditionTrue();`
`bool CondIsTrue = E->isConditionDependent() && E->isConditionTrue();`?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58292/new/

https://reviews.llvm.org/D58292



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


r354531 - [attributes] Fix buildbot after r354530.

2019-02-20 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Wed Feb 20 16:19:24 2019
New Revision: 354531

URL: http://llvm.org/viewvc/llvm-project?rev=354531=rev
Log:
[attributes] Fix buildbot after r354530.

Update the test after adding more attribute subjects.

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

Modified:
cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test

Modified: cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test?rev=354531=354530=354531=diff
==
--- cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test 
(original)
+++ cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test Wed Feb 
20 16:19:24 2019
@@ -61,7 +61,7 @@
 // CHECK-NEXT: InternalLinkage (SubjectMatchRule_variable, 
SubjectMatchRule_function, SubjectMatchRule_record)
 // CHECK-NEXT: LTOVisibilityPublic (SubjectMatchRule_record)
 // CHECK-NEXT: Lockable (SubjectMatchRule_record)
-// CHECK-NEXT: MIGServerRoutine (SubjectMatchRule_function)
+// CHECK-NEXT: MIGServerRoutine (SubjectMatchRule_function, 
SubjectMatchRule_objc_method, SubjectMatchRule_block)
 // CHECK-NEXT: MSStruct (SubjectMatchRule_record)
 // CHECK-NEXT: MicroMips (SubjectMatchRule_function)
 // CHECK-NEXT: MinSize (SubjectMatchRule_function, 
SubjectMatchRule_objc_method)


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


LLVM buildmaster will be updated and restarted tonight

2019-02-20 Thread Galina Kistanova via cfe-commits
 Hello everyone,

LLVM buildmaster will be updated and restarted after 7PM Pacific time today.

Thanks

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


[PATCH] D58365: [attributes] Add a MIG server routine attribute.

2019-02-20 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354530: [attributes] Add an attribute for server routines in 
Mach kernel and extensions. (authored by dergachev, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58365?vs=187656=187691#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58365/new/

https://reviews.llvm.org/D58365

Files:
  cfe/trunk/include/clang/Basic/Attr.td
  cfe/trunk/include/clang/Basic/AttrDocs.td
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test
  cfe/trunk/test/Sema/attr-mig.c
  cfe/trunk/test/Sema/attr-mig.cpp
  cfe/trunk/test/Sema/attr-mig.m

Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8706,6 +8706,11 @@
 def ext_opencl_ext_vector_type_rgba_selector: ExtWarn<
   "vector component name '%0' is an OpenCL version 2.2 feature">,
   InGroup;
+
+// MIG routine annotations.
+def warn_mig_server_routine_does_not_return_kern_return_t : Warning<
+  "'mig_server_routine' attribute only applies to routines that return a kern_return_t">,
+  InGroup;
 } // end of sema category
 
 let CategoryName = "OpenMP Issue" in {
Index: cfe/trunk/include/clang/Basic/AttrDocs.td
===
--- cfe/trunk/include/clang/Basic/AttrDocs.td
+++ cfe/trunk/include/clang/Basic/AttrDocs.td
@@ -4095,3 +4095,24 @@
 
 When compiled without ``-fobjc-arc``, this attribute is ignored.
 }]; }
+
+def MIGConventionDocs : Documentation {
+  let Category = DocCatType;
+  let Content = [{
+  The Mach Interface Generator release-on-success convention dictates
+functions that follow it to only release arguments passed to them when they
+return "success" (a ``kern_return_t`` error code that indicates that
+no errors have occured). Otherwise the release is performed by the MIG client
+that called the function. The annotation ``__attribute__((mig_server_routine))``
+is applied in order to specify which functions are expected to follow the
+convention. This allows the Static Analyzer to find bugs caused by violations of
+that convention. The attribute would normally appear on the forward declaration
+of the actual server routine in the MIG server header, but it may also be
+added to arbitrary functions that need to follow the same convention - for
+example, a user can add them to auxiliary functions called by the server routine
+that have their return value of type ``kern_return_t`` unconditionally returned
+from the routine. The attribute can be applied to C++ methods, and in this case
+it will be automatically applied to overrides if the method is virtual. The
+attribute can also be written using C++11 syntax: ``[[mig::server_routine]]``.
+}];
+}
Index: cfe/trunk/include/clang/Basic/Attr.td
===
--- cfe/trunk/include/clang/Basic/Attr.td
+++ cfe/trunk/include/clang/Basic/Attr.td
@@ -1300,6 +1300,12 @@
   let Documentation = [Undocumented];
 }
 
+def MIGServerRoutine : InheritableAttr {
+  let Spellings = [Clang<"mig_server_routine">];
+  let Subjects = SubjectList<[Function, ObjCMethod, Block]>;
+  let Documentation = [MIGConventionDocs];
+}
+
 def MSABI : DeclOrTypeAttr {
   let Spellings = [GCC<"ms_abi">];
 //  let Subjects = [Function, ObjCMethod];
Index: cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test
+++ cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -61,6 +61,7 @@
 // CHECK-NEXT: InternalLinkage (SubjectMatchRule_variable, SubjectMatchRule_function, SubjectMatchRule_record)
 // CHECK-NEXT: LTOVisibilityPublic (SubjectMatchRule_record)
 // CHECK-NEXT: Lockable (SubjectMatchRule_record)
+// CHECK-NEXT: MIGServerRoutine (SubjectMatchRule_function)
 // CHECK-NEXT: MSStruct (SubjectMatchRule_record)
 // CHECK-NEXT: MicroMips (SubjectMatchRule_function)
 // CHECK-NEXT: MinSize (SubjectMatchRule_function, SubjectMatchRule_objc_method)
Index: cfe/trunk/test/Sema/attr-mig.cpp
===
--- cfe/trunk/test/Sema/attr-mig.cpp
+++ cfe/trunk/test/Sema/attr-mig.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef int kern_return_t;
+typedef kern_return_t IOReturn;
+#define KERN_SUCCESS 0
+#define kIOReturnSuccess KERN_SUCCESS
+
+class MyServer {
+public:
+  virtual __attribute__((mig_server_routine)) IOReturn externalMethod();
+  virtual __attribute__((mig_server_routine)) void 

r354530 - [attributes] Add an attribute for server routines in Mach kernel and extensions.

2019-02-20 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Wed Feb 20 16:01:02 2019
New Revision: 354530

URL: http://llvm.org/viewvc/llvm-project?rev=354530=rev
Log:
[attributes] Add an attribute for server routines in Mach kernel and extensions.

The new __attribute__ ((mig_server_routine)) is going to be used for annotating
Mach Interface Generator (MIG) callback functions as such, so that additional
static analysis could be applied to their implementations. It can also be
applied to regular functions behavior of which is supposed to be identical to
that of a MIG server routine.

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

Added:
cfe/trunk/test/Sema/attr-mig.c
cfe/trunk/test/Sema/attr-mig.cpp
cfe/trunk/test/Sema/attr-mig.m
Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=354530=354529=354530=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Wed Feb 20 16:01:02 2019
@@ -1300,6 +1300,12 @@ def MayAlias : InheritableAttr {
   let Documentation = [Undocumented];
 }
 
+def MIGServerRoutine : InheritableAttr {
+  let Spellings = [Clang<"mig_server_routine">];
+  let Subjects = SubjectList<[Function, ObjCMethod, Block]>;
+  let Documentation = [MIGConventionDocs];
+}
+
 def MSABI : DeclOrTypeAttr {
   let Spellings = [GCC<"ms_abi">];
 //  let Subjects = [Function, ObjCMethod];

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=354530=354529=354530=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Wed Feb 20 16:01:02 2019
@@ -4095,3 +4095,24 @@ Likewise, when applied to a strong local
 
 When compiled without ``-fobjc-arc``, this attribute is ignored.
 }]; }
+
+def MIGConventionDocs : Documentation {
+  let Category = DocCatType;
+  let Content = [{
+  The Mach Interface Generator release-on-success convention dictates
+functions that follow it to only release arguments passed to them when they
+return "success" (a ``kern_return_t`` error code that indicates that
+no errors have occured). Otherwise the release is performed by the MIG client
+that called the function. The annotation 
``__attribute__((mig_server_routine))``
+is applied in order to specify which functions are expected to follow the
+convention. This allows the Static Analyzer to find bugs caused by violations 
of
+that convention. The attribute would normally appear on the forward declaration
+of the actual server routine in the MIG server header, but it may also be
+added to arbitrary functions that need to follow the same convention - for
+example, a user can add them to auxiliary functions called by the server 
routine
+that have their return value of type ``kern_return_t`` unconditionally returned
+from the routine. The attribute can be applied to C++ methods, and in this case
+it will be automatically applied to overrides if the method is virtual. The
+attribute can also be written using C++11 syntax: ``[[mig::server_routine]]``.
+}];
+}

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=354530=354529=354530=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Feb 20 16:01:02 
2019
@@ -8706,6 +8706,11 @@ def err_opencl_builtin_expected_type : E
 def ext_opencl_ext_vector_type_rgba_selector: ExtWarn<
   "vector component name '%0' is an OpenCL version 2.2 feature">,
   InGroup;
+
+// MIG routine annotations.
+def warn_mig_server_routine_does_not_return_kern_return_t : Warning<
+  "'mig_server_routine' attribute only applies to routines that return a 
kern_return_t">,
+  InGroup;
 } // end of sema category
 
 let CategoryName = "OpenMP Issue" in {

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=354530=354529=354530=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Wed Feb 20 16:01:02 2019
@@ -6458,6 +6458,28 @@ static void handleFortifyStdLib(Sema ,
   AL.getAttributeSpellingListIndex()));
 }
 
+static void handleMIGServerRoutineAttr(Sema , Decl *D, const ParsedAttr ) 
{
+  // Check that 

[PATCH] D18360: Add AIX Target/ToolChain to Clang Driver

2019-02-20 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.
Herald added subscribers: jdoerfert, arphaman.

@apaprocki, as mentioned in our recent RFC ( 
http://lists.llvm.org/pipermail/llvm-dev/2019-February/130175.html ), IBM is 
working on AIX support for Clang and LLVM. We would like to continue the work 
on this patch; however, as you may be aware, LLVM is undergoing relicensing ( 
https://llvm.org/docs/DeveloperPolicy.html#relicensing ). As such, we would 
like to know whether this patch is available under the terms of the Apache 2.0 
License with LLVM exceptions. Thanks.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D18360/new/

https://reviews.llvm.org/D18360



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


[PATCH] D58317: [clang] Add install targets for development headers

2019-02-20 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

In D58317#1404966 , @smeenai wrote:

> In D58317#1404961 , @phosek wrote:
>
> > In D58317#1400223 , @smeenai wrote:
> >
> > > I'm not entirely happy with the name clang-dev-headers, and am open to 
> > > suggestions. It's unfortunate clang-headers was already taken for 
> > > something different, but renaming that target or increasing its scope 
> > > seems bad for existing users. Other possibilities I thought of include 
> > > clang-tooling-headers, though that might be confused with the headers for 
> > > libTooling specifically, and clang-library-headers. I'm open to 
> > > suggestions.
> >
> >
> > We could consider renaming `clang-headers` to e.g. `clang-resource-headers` 
> > and then reusing the name which would match `llvm-headers`. What do you 
> > think about that?
>
>
> I like that, but I'm worried about breaking existing users of the 
> clang-headers target (e.g. in their build scripts or distributions). I could 
> post on cfe-dev and wait for dissent/consensus, I guess, but if there's an 
> option which doesn't involve breaking backward compatibility, maybe that's 
> preferable.


I'd give it a try, if there's a pushback then I'd prefer to go with 
`clang-library-headers`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58317/new/

https://reviews.llvm.org/D58317



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


[PATCH] D58365: [attributes] Add a MIG server routine attribute.

2019-02-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM with a minor documentation nit.




Comment at: clang/include/clang/Basic/AttrDocs.td:4049
+it will be automatically applied to overrides if the method is virtual. The
+attribute can be written using C++11 syntax: ``[[mig::server_routine]]``.
+}];

can be written -> can also be written


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58365/new/

https://reviews.llvm.org/D58365



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


[PATCH] D58480: [clang] Add CMake target for installing clang's CMake exports

2019-02-20 Thread Shoaib Meenai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354527: [clang] Add CMake target for installing clangs 
CMake exports (authored by smeenai, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58480?vs=187684=187688#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58480/new/

https://reviews.llvm.org/D58480

Files:
  cfe/trunk/cmake/modules/CMakeLists.txt


Index: cfe/trunk/cmake/modules/CMakeLists.txt
===
--- cfe/trunk/cmake/modules/CMakeLists.txt
+++ cfe/trunk/cmake/modules/CMakeLists.txt
@@ -55,10 +55,19 @@
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
   get_property(clang_has_exports GLOBAL PROPERTY CLANG_HAS_EXPORTS)
   if(clang_has_exports)
-install(EXPORT ClangTargets DESTINATION ${CLANG_INSTALL_PACKAGE_DIR})
+install(EXPORT ClangTargets DESTINATION ${CLANG_INSTALL_PACKAGE_DIR}
+COMPONENT clang-cmake-exports)
   endif()
 
   install(FILES
 ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/ClangConfig.cmake
-DESTINATION ${CLANG_INSTALL_PACKAGE_DIR})
+DESTINATION ${CLANG_INSTALL_PACKAGE_DIR}
+COMPONENT clang-cmake-exports)
+
+  if(NOT LLVM_ENABLE_IDE)
+# Add a dummy target so this can be used with LLVM_DISTRIBUTION_COMPONENTS
+add_custom_target(clang-cmake-exports)
+add_llvm_install_targets(install-clang-cmake-exports
+ COMPONENT clang-cmake-exports)
+  endif()
 endif()


Index: cfe/trunk/cmake/modules/CMakeLists.txt
===
--- cfe/trunk/cmake/modules/CMakeLists.txt
+++ cfe/trunk/cmake/modules/CMakeLists.txt
@@ -55,10 +55,19 @@
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
   get_property(clang_has_exports GLOBAL PROPERTY CLANG_HAS_EXPORTS)
   if(clang_has_exports)
-install(EXPORT ClangTargets DESTINATION ${CLANG_INSTALL_PACKAGE_DIR})
+install(EXPORT ClangTargets DESTINATION ${CLANG_INSTALL_PACKAGE_DIR}
+COMPONENT clang-cmake-exports)
   endif()
 
   install(FILES
 ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/ClangConfig.cmake
-DESTINATION ${CLANG_INSTALL_PACKAGE_DIR})
+DESTINATION ${CLANG_INSTALL_PACKAGE_DIR}
+COMPONENT clang-cmake-exports)
+
+  if(NOT LLVM_ENABLE_IDE)
+# Add a dummy target so this can be used with LLVM_DISTRIBUTION_COMPONENTS
+add_custom_target(clang-cmake-exports)
+add_llvm_install_targets(install-clang-cmake-exports
+ COMPONENT clang-cmake-exports)
+  endif()
 endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58317: [clang] Add install targets for development headers

2019-02-20 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

In D58317#1404961 , @phosek wrote:

> In D58317#1400223 , @smeenai wrote:
>
> > I'm not entirely happy with the name clang-dev-headers, and am open to 
> > suggestions. It's unfortunate clang-headers was already taken for something 
> > different, but renaming that target or increasing its scope seems bad for 
> > existing users. Other possibilities I thought of include 
> > clang-tooling-headers, though that might be confused with the headers for 
> > libTooling specifically, and clang-library-headers. I'm open to suggestions.
>
>
> We could consider renaming `clang-headers` to e.g. `clang-resource-headers` 
> and then reusing the name which would match `llvm-headers`. What do you think 
> about that?


I like that, but I'm worried about breaking existing users of the clang-headers 
target (e.g. in their build scripts or distributions). I could post on cfe-dev 
and wait for dissent/consensus, I guess, but if there's an option which doesn't 
involve breaking backward compatibility, maybe that's preferable.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58317/new/

https://reviews.llvm.org/D58317



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


r354527 - [clang] Add CMake target for installing clang's CMake exports

2019-02-20 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Wed Feb 20 15:16:15 2019
New Revision: 354527

URL: http://llvm.org/viewvc/llvm-project?rev=354527=rev
Log:
[clang] Add CMake target for installing clang's CMake exports

This mirrors LLVM's install-cmake-exports target.

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

Modified:
cfe/trunk/cmake/modules/CMakeLists.txt

Modified: cfe/trunk/cmake/modules/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/modules/CMakeLists.txt?rev=354527=354526=354527=diff
==
--- cfe/trunk/cmake/modules/CMakeLists.txt (original)
+++ cfe/trunk/cmake/modules/CMakeLists.txt Wed Feb 20 15:16:15 2019
@@ -55,10 +55,19 @@ set(CLANG_CONFIG_EXPORTS_FILE)
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
   get_property(clang_has_exports GLOBAL PROPERTY CLANG_HAS_EXPORTS)
   if(clang_has_exports)
-install(EXPORT ClangTargets DESTINATION ${CLANG_INSTALL_PACKAGE_DIR})
+install(EXPORT ClangTargets DESTINATION ${CLANG_INSTALL_PACKAGE_DIR}
+COMPONENT clang-cmake-exports)
   endif()
 
   install(FILES
 ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/ClangConfig.cmake
-DESTINATION ${CLANG_INSTALL_PACKAGE_DIR})
+DESTINATION ${CLANG_INSTALL_PACKAGE_DIR}
+COMPONENT clang-cmake-exports)
+
+  if(NOT LLVM_ENABLE_IDE)
+# Add a dummy target so this can be used with LLVM_DISTRIBUTION_COMPONENTS
+add_custom_target(clang-cmake-exports)
+add_llvm_install_targets(install-clang-cmake-exports
+ COMPONENT clang-cmake-exports)
+  endif()
 endif()


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


[PATCH] D58317: [clang] Add install targets for development headers

2019-02-20 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

In D58317#1400223 , @smeenai wrote:

> I'm not entirely happy with the name clang-dev-headers, and am open to 
> suggestions. It's unfortunate clang-headers was already taken for something 
> different, but renaming that target or increasing its scope seems bad for 
> existing users. Other possibilities I thought of include 
> clang-tooling-headers, though that might be confused with the headers for 
> libTooling specifically, and clang-library-headers. I'm open to suggestions.


We could consider renaming `clang-headers` to e.g. `clang-resource-headers` and 
then reusing the name which would match `llvm-headers`. What do you think about 
that?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58317/new/

https://reviews.llvm.org/D58317



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


[PATCH] D58284: [clang] Switch to LLVM_ENABLE_IDE

2019-02-20 Thread Shoaib Meenai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354525: [clang] Switch to LLVM_ENABLE_IDE (authored by 
smeenai, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58284?vs=187020=187686#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58284/new/

https://reviews.llvm.org/D58284

Files:
  cfe/trunk/CMakeLists.txt
  cfe/trunk/cmake/modules/AddClang.cmake
  cfe/trunk/lib/Headers/CMakeLists.txt
  cfe/trunk/tools/c-index-test/CMakeLists.txt
  cfe/trunk/tools/diagtool/CMakeLists.txt
  cfe/trunk/tools/libclang/CMakeLists.txt

Index: cfe/trunk/cmake/modules/AddClang.cmake
===
--- cfe/trunk/cmake/modules/AddClang.cmake
+++ cfe/trunk/cmake/modules/AddClang.cmake
@@ -103,7 +103,7 @@
 ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
 RUNTIME DESTINATION bin)
 
-  if (NOT CMAKE_CONFIGURATION_TYPES)
+  if (NOT LLVM_ENABLE_IDE)
 add_llvm_install_targets(install-${name}
  DEPENDS ${name}
  COMPONENT ${name})
@@ -147,7 +147,7 @@
   RUNTIME DESTINATION bin
   COMPONENT ${name})
 
-if(NOT CMAKE_CONFIGURATION_TYPES)
+if(NOT LLVM_ENABLE_IDE)
   add_llvm_install_targets(install-${name}
DEPENDS ${name}
COMPONENT ${name})
Index: cfe/trunk/CMakeLists.txt
===
--- cfe/trunk/CMakeLists.txt
+++ cfe/trunk/CMakeLists.txt
@@ -552,7 +552,7 @@
 add_custom_target(clang-libraries)
 set_target_properties(clang-libraries PROPERTIES FOLDER "Misc")
 
-if(NOT CMAKE_CONFIGURATION_TYPES)
+if(NOT LLVM_ENABLE_IDE)
   add_llvm_install_targets(install-clang-libraries
DEPENDS clang-libraries
COMPONENT clang-libraries)
@@ -563,7 +563,7 @@
   list(REMOVE_DUPLICATES CLANG_LIBS)
   foreach(lib ${CLANG_LIBS})
 add_dependencies(clang-libraries ${lib})
-if(NOT CMAKE_CONFIGURATION_TYPES)
+if(NOT LLVM_ENABLE_IDE)
   add_dependencies(install-clang-libraries install-${lib})
 endif()
   endforeach()
Index: cfe/trunk/lib/Headers/CMakeLists.txt
===
--- cfe/trunk/lib/Headers/CMakeLists.txt
+++ cfe/trunk/lib/Headers/CMakeLists.txt
@@ -178,7 +178,7 @@
   PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
   DESTINATION lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include/cuda_wrappers)
 
-if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's.
+if (NOT LLVM_ENABLE_IDE)
   add_llvm_install_targets(install-clang-headers
DEPENDS clang-headers
COMPONENT clang-headers)
Index: cfe/trunk/tools/libclang/CMakeLists.txt
===
--- cfe/trunk/tools/libclang/CMakeLists.txt
+++ cfe/trunk/tools/libclang/CMakeLists.txt
@@ -149,7 +149,7 @@
 add_custom_target(libclang-headers)
 set_target_properties(libclang-headers PROPERTIES FOLDER "Misc")
 
-if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's.
+if (NOT LLVM_ENABLE_IDE)
   add_llvm_install_targets(install-libclang-headers
COMPONENT libclang-headers)
 endif()
@@ -165,7 +165,7 @@
   DESTINATION
 "lib${LLVM_LIBDIR_SUFFIX}/python${PythonVersion}/site-packages")
 endforeach()
-if(NOT CMAKE_CONFIGURATION_TYPES)
+if(NOT LLVM_ENABLE_IDE)
   add_custom_target(libclang-python-bindings)
   add_llvm_install_targets(install-libclang-python-bindings
COMPONENT
Index: cfe/trunk/tools/c-index-test/CMakeLists.txt
===
--- cfe/trunk/tools/c-index-test/CMakeLists.txt
+++ cfe/trunk/tools/c-index-test/CMakeLists.txt
@@ -61,7 +61,7 @@
 RUNTIME DESTINATION "${INSTALL_DESTINATION}"
 COMPONENT c-index-test)
 
-  if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's.
+  if (NOT LLVM_ENABLE_IDE)
 add_llvm_install_targets(install-c-index-test
  DEPENDS c-index-test
  COMPONENT c-index-test)
Index: cfe/trunk/tools/diagtool/CMakeLists.txt
===
--- cfe/trunk/tools/diagtool/CMakeLists.txt
+++ cfe/trunk/tools/diagtool/CMakeLists.txt
@@ -23,7 +23,7 @@
 COMPONENT diagtool
 RUNTIME DESTINATION bin)
 
-  if (NOT CMAKE_CONFIGURATION_TYPES)
+  if (NOT LLVM_ENABLE_IDE)
 add_llvm_install_targets(install-diagtool
   DEPENDS diagtool
   COMPONENT diagtool)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58284: [clang] Switch to LLVM_ENABLE_IDE

2019-02-20 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58284/new/

https://reviews.llvm.org/D58284



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


r354525 - [clang] Switch to LLVM_ENABLE_IDE

2019-02-20 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Wed Feb 20 15:08:43 2019
New Revision: 354525

URL: http://llvm.org/viewvc/llvm-project?rev=354525=rev
Log:
[clang] Switch to LLVM_ENABLE_IDE

r344555 switched LLVM to guarding install targets with LLVM_ENABLE_IDE
instead of CMAKE_CONFIGURATION_TYPES, which expresses the intent more
directly and can be overridden by a user. Make the corresponding change
in clang. LLVM_ENABLE_IDE is computed by HandleLLVMOptions, so it should
be available for both standalone and integrated builds.

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

Modified:
cfe/trunk/CMakeLists.txt
cfe/trunk/cmake/modules/AddClang.cmake
cfe/trunk/lib/Headers/CMakeLists.txt
cfe/trunk/tools/c-index-test/CMakeLists.txt
cfe/trunk/tools/diagtool/CMakeLists.txt
cfe/trunk/tools/libclang/CMakeLists.txt

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=354525=354524=354525=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Wed Feb 20 15:08:43 2019
@@ -552,7 +552,7 @@ endif()
 add_custom_target(clang-libraries)
 set_target_properties(clang-libraries PROPERTIES FOLDER "Misc")
 
-if(NOT CMAKE_CONFIGURATION_TYPES)
+if(NOT LLVM_ENABLE_IDE)
   add_llvm_install_targets(install-clang-libraries
DEPENDS clang-libraries
COMPONENT clang-libraries)
@@ -563,7 +563,7 @@ if(CLANG_LIBS)
   list(REMOVE_DUPLICATES CLANG_LIBS)
   foreach(lib ${CLANG_LIBS})
 add_dependencies(clang-libraries ${lib})
-if(NOT CMAKE_CONFIGURATION_TYPES)
+if(NOT LLVM_ENABLE_IDE)
   add_dependencies(install-clang-libraries install-${lib})
 endif()
   endforeach()

Modified: cfe/trunk/cmake/modules/AddClang.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/modules/AddClang.cmake?rev=354525=354524=354525=diff
==
--- cfe/trunk/cmake/modules/AddClang.cmake (original)
+++ cfe/trunk/cmake/modules/AddClang.cmake Wed Feb 20 15:08:43 2019
@@ -103,7 +103,7 @@ macro(add_clang_library name)
 ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
 RUNTIME DESTINATION bin)
 
-  if (NOT CMAKE_CONFIGURATION_TYPES)
+  if (NOT LLVM_ENABLE_IDE)
 add_llvm_install_targets(install-${name}
  DEPENDS ${name}
  COMPONENT ${name})
@@ -147,7 +147,7 @@ macro(add_clang_tool name)
   RUNTIME DESTINATION bin
   COMPONENT ${name})
 
-if(NOT CMAKE_CONFIGURATION_TYPES)
+if(NOT LLVM_ENABLE_IDE)
   add_llvm_install_targets(install-${name}
DEPENDS ${name}
COMPONENT ${name})

Modified: cfe/trunk/lib/Headers/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/CMakeLists.txt?rev=354525=354524=354525=diff
==
--- cfe/trunk/lib/Headers/CMakeLists.txt (original)
+++ cfe/trunk/lib/Headers/CMakeLists.txt Wed Feb 20 15:08:43 2019
@@ -178,7 +178,7 @@ install(
   PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
   DESTINATION 
lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include/cuda_wrappers)
 
-if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's.
+if (NOT LLVM_ENABLE_IDE)
   add_llvm_install_targets(install-clang-headers
DEPENDS clang-headers
COMPONENT clang-headers)

Modified: cfe/trunk/tools/c-index-test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/CMakeLists.txt?rev=354525=354524=354525=diff
==
--- cfe/trunk/tools/c-index-test/CMakeLists.txt (original)
+++ cfe/trunk/tools/c-index-test/CMakeLists.txt Wed Feb 20 15:08:43 2019
@@ -61,7 +61,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
 RUNTIME DESTINATION "${INSTALL_DESTINATION}"
 COMPONENT c-index-test)
 
-  if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's.
+  if (NOT LLVM_ENABLE_IDE)
 add_llvm_install_targets(install-c-index-test
  DEPENDS c-index-test
  COMPONENT c-index-test)

Modified: cfe/trunk/tools/diagtool/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/diagtool/CMakeLists.txt?rev=354525=354524=354525=diff
==
--- cfe/trunk/tools/diagtool/CMakeLists.txt (original)
+++ cfe/trunk/tools/diagtool/CMakeLists.txt Wed Feb 20 15:08:43 2019
@@ -23,7 +23,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
 COMPONENT diagtool
 RUNTIME DESTINATION bin)
 
-  if (NOT CMAKE_CONFIGURATION_TYPES)
+  if (NOT LLVM_ENABLE_IDE)
 add_llvm_install_targets(install-diagtool
   DEPENDS diagtool
   

[PATCH] D58480: [clang] Add CMake target for installing clang's CMake exports

2019-02-20 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58480/new/

https://reviews.llvm.org/D58480



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


[PATCH] D58480: [clang] Add CMake target for installing clang's CMake exports

2019-02-20 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai created this revision.
smeenai added reviewers: beanz, phosek.
Herald added a subscriber: mgorny.
Herald added a project: clang.
smeenai retitled this revision from "[clang] Add CMake target for clang's CMake 
exports" to "[clang] Add CMake target for installing clang's CMake exports".

This mirrors LLVM's install-cmake-exports target.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D58480

Files:
  clang/cmake/modules/CMakeLists.txt


Index: clang/cmake/modules/CMakeLists.txt
===
--- clang/cmake/modules/CMakeLists.txt
+++ clang/cmake/modules/CMakeLists.txt
@@ -55,10 +55,19 @@
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
   get_property(clang_has_exports GLOBAL PROPERTY CLANG_HAS_EXPORTS)
   if(clang_has_exports)
-install(EXPORT ClangTargets DESTINATION ${CLANG_INSTALL_PACKAGE_DIR})
+install(EXPORT ClangTargets DESTINATION ${CLANG_INSTALL_PACKAGE_DIR}
+COMPONENT clang-cmake-exports)
   endif()
 
   install(FILES
 ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/ClangConfig.cmake
-DESTINATION ${CLANG_INSTALL_PACKAGE_DIR})
+DESTINATION ${CLANG_INSTALL_PACKAGE_DIR}
+COMPONENT clang-cmake-exports)
+
+  if(NOT LLVM_ENABLE_IDE)
+# Add a dummy target so this can be used with LLVM_DISTRIBUTION_COMPONENTS
+add_custom_target(clang-cmake-exports)
+add_llvm_install_targets(install-clang-cmake-exports
+ COMPONENT clang-cmake-exports)
+  endif()
 endif()


Index: clang/cmake/modules/CMakeLists.txt
===
--- clang/cmake/modules/CMakeLists.txt
+++ clang/cmake/modules/CMakeLists.txt
@@ -55,10 +55,19 @@
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
   get_property(clang_has_exports GLOBAL PROPERTY CLANG_HAS_EXPORTS)
   if(clang_has_exports)
-install(EXPORT ClangTargets DESTINATION ${CLANG_INSTALL_PACKAGE_DIR})
+install(EXPORT ClangTargets DESTINATION ${CLANG_INSTALL_PACKAGE_DIR}
+COMPONENT clang-cmake-exports)
   endif()
 
   install(FILES
 ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/ClangConfig.cmake
-DESTINATION ${CLANG_INSTALL_PACKAGE_DIR})
+DESTINATION ${CLANG_INSTALL_PACKAGE_DIR}
+COMPONENT clang-cmake-exports)
+
+  if(NOT LLVM_ENABLE_IDE)
+# Add a dummy target so this can be used with LLVM_DISTRIBUTION_COMPONENTS
+add_custom_target(clang-cmake-exports)
+add_llvm_install_targets(install-clang-cmake-exports
+ COMPONENT clang-cmake-exports)
+  endif()
 endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58478: [index-while-building] FileIndexRecord

2019-02-20 Thread Jan Korous via Phabricator via cfe-commits
jkorous created this revision.
jkorous added reviewers: dexonsmith, nathawes, akyrtzi, arphaman, ioeric, 
malaperle.
Herald added subscribers: cfe-commits, jdoerfert, mgorny.
Herald added a project: clang.

Basic data structures for index

Tests are missing from this patch - will be covered properly by tests for the 
whole feature.
I'm just trying to split it into smaller patches to make it easier for 
reviewers.

This (with minor changes) was LGTM'ed here https://reviews.llvm.org/D39050. 
Adding original reviewers.


Repository:
  rC Clang

https://reviews.llvm.org/D58478

Files:
  clang/include/clang/Index/DeclOccurrence.h
  clang/lib/Index/CMakeLists.txt
  clang/lib/Index/FileIndexRecord.cpp
  clang/lib/Index/FileIndexRecord.h

Index: clang/lib/Index/FileIndexRecord.h
===
--- /dev/null
+++ clang/lib/Index/FileIndexRecord.h
@@ -0,0 +1,58 @@
+//===--- FileIndexRecord.h - Index data per file --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_INDEX_FILEINDEXRECORD_H
+#define LLVM_CLANG_LIB_INDEX_FILEINDEXRECORD_H
+
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Index/DeclOccurrence.h"
+#include "clang/Index/IndexSymbol.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/SmallVector.h"
+#include 
+
+namespace clang {
+class IdentifierInfo;
+
+namespace index {
+
+/// Stores the declaration occurrences seen in a particular source or header
+/// file of a translation unit
+class FileIndexRecord {
+private:
+  FileID FID;
+  bool IsSystem;
+  std::vector Decls;
+
+public:
+  FileIndexRecord(FileID FID, bool IsSystem) : FID(FID), IsSystem(IsSystem) {}
+
+  ArrayRef getDeclOccurrencesSortedByOffset() const {
+return Decls;
+  }
+
+  FileID getFileID() const { return FID; }
+  bool isSystem() const { return IsSystem; }
+
+  /// Adds an occurrence of the canonical declaration \c D at the supplied
+  /// \c Offset
+  ///
+  /// \param Roles the roles the occurrence fulfills in this position.
+  /// \param Offset the offset in the file of this occurrence.
+  /// \param D the canonical declaration this is an occurrence of.
+  /// \param Relations the set of symbols related to this occurrence.
+  void addDeclOccurence(SymbolRoleSet Roles, unsigned Offset, const Decl *D,
+ArrayRef Relations);
+  void print(llvm::raw_ostream ) const;
+};
+
+} // end namespace index
+} // end namespace clang
+
+#endif
Index: clang/lib/Index/FileIndexRecord.cpp
===
--- /dev/null
+++ clang/lib/Index/FileIndexRecord.cpp
@@ -0,0 +1,59 @@
+//===--- FileIndexRecord.cpp - Index data per file ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "FileIndexRecord.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/DeclTemplate.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/Support/Path.h"
+
+using namespace clang;
+using namespace clang::index;
+
+void FileIndexRecord::addDeclOccurence(SymbolRoleSet Roles, unsigned Offset,
+   const Decl *D,
+   ArrayRef Relations) {
+  assert(D->isCanonicalDecl() &&
+ "Occurrences should be associated with their canonical decl");
+
+  auto IsNextOccurence = [&]() -> bool {
+if (Decls.empty())
+  return true;
+auto  = Decls.back();
+return Last.Offset < Offset;
+  };
+
+  if (IsNextOccurence()) {
+Decls.emplace_back(Roles, Offset, D, Relations);
+return;
+  }
+
+  DeclOccurrence NewInfo(Roles, Offset, D, Relations);
+  auto It = std::upper_bound(Decls.begin(), Decls.end(), NewInfo);
+  Decls.insert(It, std::move(NewInfo));
+}
+
+void FileIndexRecord::print(llvm::raw_ostream ) const {
+  OS << "DECLS BEGIN ---\n";
+  for (auto  : Decls) {
+auto D = DclInfo.Dcl;
+SourceManager  = D->getASTContext().getSourceManager();
+SourceLocation Loc = SM.getFileLoc(D->getLocation());
+PresumedLoc PLoc = SM.getPresumedLoc(Loc);
+OS << llvm::sys::path::filename(PLoc.getFilename()) << ':' << PLoc.getLine()
+   << ':' << PLoc.getColumn();
+
+if (auto ND = dyn_cast(D)) {
+  OS << ' ' << ND->getNameAsString();
+}
+
+OS << '\n';
+  }
+  OS << "DECLS END ---\n";
+}
Index: clang/lib/Index/CMakeLists.txt
===
--- clang/lib/Index/CMakeLists.txt
+++ clang/lib/Index/CMakeLists.txt
@@ -6,6 +6,7 @@
 add_clang_library(clangIndex
   

[PATCH] D58477: [Driver] Fix float ABI default for Android ARMv8.

2019-02-20 Thread Dan Albert via Phabricator via cfe-commits
danalbert created this revision.
danalbert added reviewers: srhines, pirama.
Herald added subscribers: kristof.beyls, javed.absar.
Herald added a project: clang.

Android doesn't regress back to soft float after ARMv7 :)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D58477

Files:
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/test/Driver/arm-float-abi.c


Index: clang/test/Driver/arm-float-abi.c
===
--- clang/test/Driver/arm-float-abi.c
+++ clang/test/Driver/arm-float-abi.c
@@ -4,3 +4,13 @@
 
 // ARMV7-ERROR: unsupported option '-mfloat-abi=hard' for target 'thumbv7'
 // NOERROR-NOT: unsupported option
+
+// RUN: %clang -target armv7-linux-androideabi21 %s -### -c 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM7-ANDROID %s
+// CHECK-ARM7-ANDROID-NOT: "-target-feature" "+soft-float"
+// CHECK-ARM7-ANDROID: "-target-feature" "+soft-float-abi"
+
+// RUN: %clang -target armv8-linux-androideabi21 %s -### -c 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM8-ANDROID %s
+// CHECK-ARM8-ANDROID-NOT: "-target-feature" "+soft-float"
+// CHECK-ARM8-ANDROID: "-target-feature" "+soft-float-abi"
Index: clang/lib/Driver/ToolChains/Arch/ARM.cpp
===
--- clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -248,7 +248,7 @@
 ABI = FloatABI::SoftFP;
 break;
   case llvm::Triple::Android:
-ABI = (SubArch == 7) ? FloatABI::SoftFP : FloatABI::Soft;
+ABI = (SubArch >= 7) ? FloatABI::SoftFP : FloatABI::Soft;
 break;
   default:
 // Assume "soft", but warn the user we are guessing.


Index: clang/test/Driver/arm-float-abi.c
===
--- clang/test/Driver/arm-float-abi.c
+++ clang/test/Driver/arm-float-abi.c
@@ -4,3 +4,13 @@
 
 // ARMV7-ERROR: unsupported option '-mfloat-abi=hard' for target 'thumbv7'
 // NOERROR-NOT: unsupported option
+
+// RUN: %clang -target armv7-linux-androideabi21 %s -### -c 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM7-ANDROID %s
+// CHECK-ARM7-ANDROID-NOT: "-target-feature" "+soft-float"
+// CHECK-ARM7-ANDROID: "-target-feature" "+soft-float-abi"
+
+// RUN: %clang -target armv8-linux-androideabi21 %s -### -c 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM8-ANDROID %s
+// CHECK-ARM8-ANDROID-NOT: "-target-feature" "+soft-float"
+// CHECK-ARM8-ANDROID: "-target-feature" "+soft-float-abi"
Index: clang/lib/Driver/ToolChains/Arch/ARM.cpp
===
--- clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -248,7 +248,7 @@
 ABI = FloatABI::SoftFP;
 break;
   case llvm::Triple::Android:
-ABI = (SubArch == 7) ? FloatABI::SoftFP : FloatABI::Soft;
+ABI = (SubArch >= 7) ? FloatABI::SoftFP : FloatABI::Soft;
 break;
   default:
 // Assume "soft", but warn the user we are guessing.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58463: [CUDA]Delayed diagnostics for the asm instructions.

2019-02-20 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

Thank you.




Comment at: lib/Sema/Sema.cpp:1494-1496
+if (getLangOpts().CUDAIsDevice)
+  return CUDADiagIfDeviceCode(Loc, DiagID);
+return CUDADiagIfHostCode(Loc, DiagID);

Nit: i'd use ternary op here or explicit if/else to indicate that 
CUDADiagIfDeviceCode/CUDADiagIfHostCode are treated the same and that 
CUDADiagIfHostCode() is *not* a catch-all of some kind.

```
return getLangOpts().CUDAIsDevice 
   ? CUDADiagIfDeviceCode(Loc, DiagID) 
   : CUDADiagIfHostCode(Loc, DiagID)

```


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58463/new/

https://reviews.llvm.org/D58463



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


[PATCH] D58314: [Driver] Sync ARM behavior between clang-as and gas.

2019-02-20 Thread Dan Albert via Phabricator via cfe-commits
danalbert added inline comments.



Comment at: clang/lib/Driver/ToolChains/Arch/ARM.cpp:277
+  }
+  return "";
+}

peter.smith wrote:
> I'm a bit worried that we've changed the default behaviour for gnueabi[hf] 
> targets here. 
> For example with:
> ```
> .text
> vmov.32 d13[1], r6 ; Needs VFPv2
> vadd.i32 d0, d0, d0 ; Needs Neon
> ```
> I get with --target=armv7a-linux (no environment, -mfloat-abi will disable 
> floating point, and neon)
> ```
> clang: warning: unknown platform, assuming -mfloat-abi=soft
> neon.s:2:9: error: instruction requires: VFP2
> vmov.32 d13[1],r6
> ^
> neon.s:3:9: error: instruction requires: NEON
> vadd.i32 d0, d0, d0
> ^
> ```
> With the target=armv7a-linux-gnueabi armv7a-linux-gnueabihf or explicitly 
> adding -mfloat-abi=softfp the integrated assembler will happily assemble it.
> GNU needs -mfpu=neon to assemble the file:
> 
> ```
> arm-linux-gnueabihf-as -march=armv7-a neon.s 
> neon.s: Assembler messages:
> neon.s:2: Error: selected processor does not support ARM mode `vmov.32 
> d13[1],r6'
> neon.s:3: Error: selected processor does not support ARM mode `vadd.i32 
> d0,d0,d0'
> ```
> It is a similar story for armv8 and crypto.
> 
> I think we should have something like:
> ```
> if (Triple.isLinux() && getARMSubArchVersionNumber(Triple) >= 8)
>return "crypto-neon-fp-armv8";
> if (Triple.isAndroid() || Triple.isLinux() && 
> getARMSubArchVersionNumber(Triple) >= 7)
> return "neon";
> return "";
> ```
I suppose it depends on which direction you want the behavior change to go. I 
assumed those samples _shouldn't_ assemble since they're not enabling NEON. The 
fact that the direct `arm-linux-gnueabihf-as` doesn't enable NEON by default 
makes me assume that NEON is not an assumed feature of the gnueabihf 
environment.

It's not up to me whether NEON is available by default for ARMv7 for 
non-Android, but I do think that the behavior should be consistent regardless 
of the assembler being used. Right now we have no FPU by default with the 
integrated assembler and NEON by default with GAS. This change makes GAS have 
the same behavior as the integrated assembler, since I assume that is the 
better traveled path and afaict is the one that has had more effort put in to 
it.

If that's not right, I can change this so that the integrated assembler _also_ 
gets FPU features that are not necessarily available for the given 
architecture, but I wanted to clarify that that is what you're asking for first.



Comment at: clang/lib/Driver/ToolChains/Arch/ARM.cpp:389
+std::string DefaultFPU = getDefaultFPUName(Triple);
+if (DefaultFPU != "") {
+  if (!llvm::ARM::getFPUFeatures(llvm::ARM::parseFPU(DefaultFPU), 
Features))

peter.smith wrote:
> I'm wondering whether you need this bit of code anymore? In D53121 there 
> needed to be a switch between vfpv3-d16 and neon based on Android version. 
> With --target=armv7a-linux-android or --target=arm-linux-android 
> -march=armv7a or any v7a -mcpu applicable to Android then you'll get feature 
> Neon by default and won't need to do this? We could then move 
> getDefaultFPUName out of ARM.cpp
I don't understand. This bit of code is the piece that provides the NEON 
default. If I remove this then Android ARMv7 targets revert to no FPU features.



Comment at: clang/lib/Driver/ToolChains/Gnu.cpp:692
+}
+if (!hasMOrWaMArg(Args, options::OPT_mfpu_EQ, "-mfpu=")) {
+std::string DefaultFPU = arm::getDefaultFPUName(Triple);

peter.smith wrote:
> I think we'd not want to do this for -mfloat-abi=soft as this disables the 
> FPU in the integrated assembler. It seems like -mfloat-abi has no effect at 
> all on the gnu assembler, it will happily assemble neon instructions with 
> -mfloat-abi=soft -mfpu=neon.
>  
Added a check for soft float ABI and added a test to match.



Comment at: clang/test/Driver/linux-as.c:3
 //
 // RUN: %clang -target arm-linux -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \

peter.smith wrote:
> the target arm-linux (effectively arm-linux-unknown) defaults to 
> -mfloat-abi=soft which disables the FPU for the integrated assembler. While 
> these test cases are not wrong, the number of v7a + linux targets without an 
> FPU using entirely software floating point is likely to be very small. We 
> should have some more that have arm-linux-gnueabi and arm-linux-gnueabihf.
Added a handful. Not really sure what needs to be tested here, but I covered 
the basic cases.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58314/new/

https://reviews.llvm.org/D58314



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


[PATCH] D58314: [Driver] Sync ARM behavior between clang-as and gas.

2019-02-20 Thread Dan Albert via Phabricator via cfe-commits
danalbert updated this revision to Diff 187670.
danalbert marked 6 inline comments as done.
danalbert added a comment.

Updated to address some review comments:

- Additional tests for gnueabi/gnueabihf
- Fixed behavior for `-mfpu=neon -mfloat-abi=soft`, added test.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58314/new/

https://reviews.llvm.org/D58314

Files:
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/lib/Driver/ToolChains/Arch/ARM.h
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/linux-as.c

Index: clang/test/Driver/linux-as.c
===
--- clang/test/Driver/linux-as.c
+++ clang/test/Driver/linux-as.c
@@ -3,17 +3,17 @@
 // RUN: %clang -target arm-linux -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ARM %s
-// CHECK-ARM: as{{(.exe)?}}" "-EL" "-mfloat-abi=soft"
+// CHECK-ARM: as{{(.exe)?}}" "-EL" "-march=armv4t" "-mfloat-abi=soft"
 //
 // RUN: %clang -target arm-linux -mcpu=cortex-a8 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ARM-MCPU %s
-// CHECK-ARM-MCPU: as{{(.exe)?}}" "-EL" "-mfloat-abi=soft" "-mcpu=cortex-a8"
+// CHECK-ARM-MCPU: as{{(.exe)?}}" "-EL" "-march=armv7" "-mfloat-abi=soft" "-mcpu=cortex-a8"
 //
 // RUN: %clang -target arm-linux -mfpu=neon -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ARM-MFPU %s
-// CHECK-ARM-MFPU: as{{(.exe)?}}" "-EL" "-mfloat-abi=soft" "-mfpu=neon"
+// CHECK-ARM-MFPU: as{{(.exe)?}}" "-EL" "-march=armv4t" "-mfloat-abi=soft" "-mfpu=neon"
 //
 // RUN: %clang -target arm-linux -march=armv7-a -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
@@ -63,62 +63,97 @@
 // RUN: %clang -target armv7-linux -mcpu=cortex-a8 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ARM-TARGET %s
-// CHECK-ARM-TARGET: as{{(.exe)?}}" "-EL" "-mfpu=neon" "-mfloat-abi=soft" "-mcpu=cortex-a8"
+// CHECK-ARM-TARGET: as{{(.exe)?}}" "-EL" "-march=armv7" "-mfloat-abi=soft" "-mcpu=cortex-a8"
 //
 // RUN: %clang -target armebv7-linux -mcpu=cortex-a8 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ARMEB-TARGET %s
-// CHECK-ARMEB-TARGET: as{{(.exe)?}}" "-EB" "-mfpu=neon" "-mfloat-abi=soft" "-mcpu=cortex-a8"
+// CHECK-ARMEB-TARGET: as{{(.exe)?}}" "-EB" "-march=armebv7" "-mfloat-abi=soft" "-mcpu=cortex-a8"
 //
 // RUN: %clang -target thumbv7-linux -mcpu=cortex-a8 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-THUMB-TARGET %s
-// CHECK-THUMB-TARGET: as{{(.exe)?}}" "-EL" "-mfpu=neon" "-mfloat-abi=soft" "-mcpu=cortex-a8"
+// CHECK-THUMB-TARGET: as{{(.exe)?}}" "-EL" "-march=armv7" "-mfloat-abi=soft" "-mcpu=cortex-a8"
 //
 // RUN: %clang -target thumbebv7-linux -mcpu=cortex-a8 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-THUMBEB-TARGET %s
-// CHECK-THUMBEB-TARGET: as{{(.exe)?}}" "-EB" "-mfpu=neon" "-mfloat-abi=soft" "-mcpu=cortex-a8"
+// CHECK-THUMBEB-TARGET: as{{(.exe)?}}" "-EB" "-march=armebv7" "-mfloat-abi=soft" "-mcpu=cortex-a8"
 //
 // RUN: %clang -target armv8-linux -mcpu=cortex-a53 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ARM-TARGET-V8 %s
-// CHECK-ARM-TARGET-V8: as{{(.exe)?}}" "-EL" "-mfpu=crypto-neon-fp-armv8" "-mfloat-abi=soft" "-mcpu=cortex-a53"
+// CHECK-ARM-TARGET-V8: as{{(.exe)?}}" "-EL" "-march=armv8" "-mfloat-abi=soft" "-mcpu=cortex-a53"
 //
 // RUN: %clang -target armebv8-linux -mcpu=cortex-a53 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ARMEB-TARGET-V8 %s
-// CHECK-ARMEB-TARGET-V8: as{{(.exe)?}}" "-EB" "-mfpu=crypto-neon-fp-armv8" "-mfloat-abi=soft" "-mcpu=cortex-a53"
+// CHECK-ARMEB-TARGET-V8: as{{(.exe)?}}" "-EB" "-march=armebv8" "-mfloat-abi=soft" "-mcpu=cortex-a53"
 //
 // RUN: %clang -target thumbv8-linux -mcpu=cortex-a53 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-THUMB-TARGET-V8 %s
-// CHECK-THUMB-TARGET-V8: as{{(.exe)?}}" "-EL" "-mfpu=crypto-neon-fp-armv8" "-mfloat-abi=soft" "-mcpu=cortex-a53"
+// CHECK-THUMB-TARGET-V8: as{{(.exe)?}}" "-EL" "-march=armv8" "-mfloat-abi=soft" "-mcpu=cortex-a53"
 //
 // RUN: %clang -target thumbebv8-linux -mcpu=cortex-a53 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-THUMBEB-TARGET-V8 %s
-// CHECK-THUMBEB-TARGET-V8: as{{(.exe)?}}" "-EB" "-mfpu=crypto-neon-fp-armv8" "-mfloat-abi=soft" "-mcpu=cortex-a53"
+// CHECK-THUMBEB-TARGET-V8: as{{(.exe)?}}" "-EB" "-march=armebv8" "-mfloat-abi=soft" "-mcpu=cortex-a53"
 //
 // RUN: %clang -target arm-linux -mfloat-abi=hard -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ARM-MFLOAT-ABI %s
-// CHECK-ARM-MFLOAT-ABI: as{{(.exe)?}}" "-EL" "-mfloat-abi=hard"
+// 

[PATCH] D58368: [analyzer] MIGChecker: Implement bug reporter visitors.

2019-02-20 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp:47
 
 REGISTER_TRAIT_WITH_PROGRAMSTATE(ReleasedParameter, bool);
 

`;` is not necessary.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58368/new/

https://reviews.llvm.org/D58368



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


[PATCH] D53076: [analyzer] Enhance ConditionBRVisitor to write out more information

2019-02-20 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment.

In D53076#1403436 , @NoQ wrote:

> I'll take a closer look in a few days, sorry for the delays! The progress 
> you're making is fantastic and i really appreciate your work, but i have an 
> urgent piece of work of my own to deal with this week.


@NoQ, please take your time, that new bug-report logic is the end of my work on 
reporting business (as I mentioned I wanted to create the same patch), so that 
is more important than this.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D53076/new/

https://reviews.llvm.org/D53076



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


[clang-tools-extra] r354517 - [clang-tidy] refactor ExceptionAnalyzer further to give ternary answer

2019-02-20 Thread Jonas Toth via cfe-commits
Author: jonastoth
Date: Wed Feb 20 13:04:36 2019
New Revision: 354517

URL: http://llvm.org/viewvc/llvm-project?rev=354517=rev
Log:
[clang-tidy] refactor ExceptionAnalyzer further to give ternary answer

Summary:
The analsis on the throwing behvaiour on functions and statements gave only
a binary answer whether an exception could occur and if yes which types are
thrown.
This refactoring allows keeping track if there is a unknown factor, because the
code calls to some functions with unavailable source code with no `noexcept`
information.
This 'potential Unknown' information is propagated properly and can be queried
separately.

Reviewers: lebedev.ri, aaron.ballman, baloghadamsoftware, alexfh

Reviewed By: lebedev.ri, baloghadamsoftware

Subscribers: xazax.hun, rnkovacs, a.sidorin, Szelethus, donat.nagy, dkrupp, 
cfe-commits

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clang-tidy/bugprone/ExceptionEscapeCheck.cpp
clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.cpp
clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.h

Modified: clang-tools-extra/trunk/clang-tidy/bugprone/ExceptionEscapeCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/ExceptionEscapeCheck.cpp?rev=354517=354516=354517=diff
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/ExceptionEscapeCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/ExceptionEscapeCheck.cpp Wed 
Feb 20 13:04:36 2019
@@ -42,6 +42,7 @@ ExceptionEscapeCheck::ExceptionEscapeChe
   IgnoredExceptions.insert(IgnoredExceptionsVec.begin(),
IgnoredExceptionsVec.end());
   Tracer.ignoreExceptions(std::move(IgnoredExceptions));
+  Tracer.ignoreBadAlloc(true);
 }
 
 void ExceptionEscapeCheck::storeOptions(ClangTidyOptions::OptionMap ) {
@@ -70,7 +71,8 @@ void ExceptionEscapeCheck::check(const M
   if (!MatchedDecl)
 return;
 
-  if (Tracer.throwsException(MatchedDecl))
+  if (Tracer.analyze(MatchedDecl).getBehaviour() ==
+  utils::ExceptionAnalyzer::State::Throwing)
 // FIXME: We should provide more information about the exact location where
 // the exception is thrown, maybe the full path the exception escapes
 diag(MatchedDecl->getLocation(),

Modified: clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.cpp?rev=354517=354516=354517=diff
==
--- clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/utils/ExceptionAnalyzer.cpp Wed Feb 20 
13:04:36 2019
@@ -8,10 +8,44 @@
 
 #include "ExceptionAnalyzer.h"
 
-#include "clang/AST/ASTContext.h"
-#include "clang/ASTMatchers/ASTMatchFinder.h"
-
 namespace clang {
+namespace tidy {
+namespace utils {
+
+void ExceptionAnalyzer::ExceptionInfo::registerException(
+const Type *ExceptionType) {
+  assert(ExceptionType != nullptr && "Only valid types are accepted");
+  Behaviour = State::Throwing;
+  ThrownExceptions.insert(ExceptionType);
+}
+
+void ExceptionAnalyzer::ExceptionInfo::registerExceptions(
+const Throwables ) {
+  if (Exceptions.size() == 0)
+return;
+  Behaviour = State::Throwing;
+  ThrownExceptions.insert(Exceptions.begin(), Exceptions.end());
+}
+
+ExceptionAnalyzer::ExceptionInfo ::ExceptionInfo::merge(
+const ExceptionAnalyzer::ExceptionInfo ) {
+  // Only the following two cases require an update to the local
+  // 'Behaviour'. If the local entity is already throwing there will be no
+  // change and if the other entity is throwing the merged entity will throw
+  // as well.
+  // If one of both entities is 'Unknown' and the other one does not throw
+  // the merged entity is 'Unknown' as well.
+  if (Other.Behaviour == State::Throwing)
+Behaviour = State::Throwing;
+  else if (Other.Behaviour == State::Unknown && Behaviour == 
State::NotThrowing)
+Behaviour = State::Unknown;
+
+  ContainsUnknown = ContainsUnknown || Other.ContainsUnknown;
+  ThrownExceptions.insert(Other.ThrownExceptions.begin(),
+  Other.ThrownExceptions.end());
+  return *this;
+}
+
 static bool isBaseOf(const Type *DerivedType, const Type *BaseType) {
   const auto *DerivedClass = DerivedType->getAsCXXRecordDecl();
   const auto *BaseClass = BaseType->getAsCXXRecordDecl();
@@ -22,36 +56,87 @@ static bool isBaseOf(const Type *Derived
   [BaseClass](const CXXRecordDecl *Cur) { return Cur != BaseClass; });
 }
 
-namespace tidy {
-namespace utils {
+bool ExceptionAnalyzer::ExceptionInfo::filterByCatch(const Type *BaseClass) {
+  llvm::SmallVector TypesToDelete;
+  for (const Type *T : ThrownExceptions) {
+if (T == BaseClass || isBaseOf(T, BaseClass))
+  TypesToDelete.push_back(T);
+  

[PATCH] D57883: [clang-tidy] refactor ExceptionAnalyzer further to give ternary answer

2019-02-20 Thread Jonas Toth via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE354517: [clang-tidy] refactor ExceptionAnalyzer further to 
give ternary answer (authored by JonasToth, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D57883?vs=187635=187662#toc

Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57883/new/

https://reviews.llvm.org/D57883

Files:
  clang-tidy/bugprone/ExceptionEscapeCheck.cpp
  clang-tidy/utils/ExceptionAnalyzer.cpp
  clang-tidy/utils/ExceptionAnalyzer.h

Index: clang-tidy/utils/ExceptionAnalyzer.h
===
--- clang-tidy/utils/ExceptionAnalyzer.h
+++ clang-tidy/utils/ExceptionAnalyzer.h
@@ -10,6 +10,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_EXCEPTION_ANALYZER_H
 
 #include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/StringSet.h"
 
@@ -17,29 +18,131 @@
 namespace tidy {
 namespace utils {
 
-/// This class analysis if a `FunctionDecl` can in principle throw an exception,
-/// either directly or indirectly.
-/// It can be configured to ignore custom exception types.
+/// This class analysis if a `FunctionDecl` can in principle throw an
+/// exception, either directly or indirectly. It can be configured to ignore
+/// custom exception types.
 class ExceptionAnalyzer {
 public:
+  enum class State : std::int8_t {
+Throwing = 0,///< The function can definitly throw given an AST.
+NotThrowing = 1, ///< This function can not throw, given an AST.
+Unknown = 2, ///< This can happen for extern functions without available
+ ///< definition.
+  };
+
+  /// Bundle the gathered information about an entity like a function regarding
+  /// it's exception behaviour. The 'NonThrowing'-state can be considered as the
+  /// neutral element in terms of information propagation.
+  /// In the case of 'Throwing' state it is possible that 'getExceptionTypes'
+  /// does not include *ALL* possible types as there is the possibility that
+  /// an 'Unknown' function is called that might throw a previously unknown
+  /// exception at runtime.
+  class ExceptionInfo {
+  public:
+using Throwables = llvm::SmallSet;
+static ExceptionInfo createUnknown() {
+  return ExceptionInfo(State::Unknown);
+}
+static ExceptionInfo createNonThrowing() {
+  return ExceptionInfo(State::Throwing);
+}
+
+/// By default the exception situation is unknown and must be
+/// clarified step-wise.
+ExceptionInfo() : Behaviour(State::NotThrowing), ContainsUnknown(false) {}
+ExceptionInfo(State S)
+: Behaviour(S), ContainsUnknown(S == State::Unknown) {}
+
+ExceptionInfo(const ExceptionInfo &) = default;
+ExceptionInfo =(const ExceptionInfo &) = default;
+ExceptionInfo(ExceptionInfo &&) = default;
+ExceptionInfo =(ExceptionInfo &&) = default;
+
+State getBehaviour() const { return Behaviour; }
+
+/// Register a single exception type as recognized potential exception to be
+/// thrown.
+void registerException(const Type *ExceptionType);
+
+/// Registers a `SmallVector` of exception types as recognized potential
+/// exceptions to be thrown.
+void registerExceptions(const Throwables );
+
+/// Updates the local state according to the other state. That means if
+/// for example a function contains multiple statements the 'ExceptionInfo'
+/// for the final function is the merged result of each statement.
+/// If one of these statements throws the whole function throws and if one
+/// part is unknown and the rest is non-throwing the result will be
+/// unknown.
+ExceptionInfo (const ExceptionInfo );
+
+/// This method is useful in case 'catch' clauses are analyzed as it is
+/// possible to catch multiple exception types by one 'catch' if they
+/// are a subclass of the 'catch'ed exception type.
+/// Returns 'true' if some exceptions were filtered, otherwise 'false'.
+bool filterByCatch(const Type *BaseClass);
+
+/// Filter the set of thrown exception type against a set of ignored
+/// types that shall not be considered in the exception analysis.
+/// This includes explicit `std::bad_alloc` ignoring as separate option.
+ExceptionInfo &
+filterIgnoredExceptions(const llvm::StringSet<> ,
+bool IgnoreBadAlloc);
+
+/// Clear the state to 'NonThrowing' to make the corresponding entity
+/// neutral.
+void clear();
+
+/// References the set of known exception types that can escape from the
+/// corresponding entity.
+const Throwables () const { return ThrownExceptions; }
+
+/// Signal if the there is any 'Unknown' element within the scope of
+/// the related entity. This might be relevant if the entity is 'Throwing'
+/// and to ensure that no other 

[PATCH] D58368: [analyzer] MIGChecker: Implement bug reporter visitors.

2019-02-20 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a reviewer: Charusso.
Charusso requested changes to this revision.
Charusso added inline comments.
This revision now requires changes to proceed.



Comment at: clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp:113
+  });
+  C.addTransition(C.getState()->set(true), T);
 }

This is a cool approach, but it is difficult to use this API in other checkers. 
If you do not out-chain D58367 I would like to see something like that here:

```
  SmallString<64> Str;
  llvm::raw_svector_ostream OS(Str);
  OS << "Deallocating object passed through parameter '" << PVD->getName()
 << '\'';

  C.addNote(C.getState()->set(true), OS.str());
```


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58368/new/

https://reviews.llvm.org/D58368



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


[PATCH] D58367: [analyzer] NFC: Improve upon the concept of BugReporterVisitor.

2019-02-20 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso requested changes to this revision.
Charusso added a comment.
This revision now requires changes to proceed.

First of all, thanks you for working on this, as I wanted to do the same, but I 
did not know how to. I did not know also that 15 of the checkers already 
implements `BugReporterVisitors`, but I completely shocked it took 10 years of 
pain to rewrite it. It feels like this patch a little-bit brute-force, and I 
believe this should be the future direction of reporting. Also I believe in 
that we could hook a lot more useful information from *all* the checkers, and 
we do not care that much about the core `BugReporterVisitors` as they do their 
job enough well. So with that, I would out-chain this patch from the 
MIG-patches because it is a lot more serious problem-set. I also would like to 
ask you to take it more serious, as all your mentioned benefits will rely on 
this simple and cool approach, so it has to be flexible as possible. I am not 
into the internal stuff that much, so I cannot argue about the lack of 
`CheckerContext` functions, but I think this is a huge problem and breaks the 
flexibility a lot.

I tried out the patch and saw the very recommended source code of 
`MallocChecker`'s so lightweight `BugReporterVisitor` implementation and I 
think your API is too strict about having a lambda function, so here is my 
ideas:

- `CheckerContext.h`: As I see we only work with a `string`, nothing else, so I 
would extend that class:

  ExplodedNode *addNote(ProgramStateRef State, StringRef Message) {
return addTransitionImpl(State, false, nullptr, setNoteTag(Message)); // 
Note the 'setNoteTag()'
  }

`getNoteTag()`: you could differentiate a setter with the true getter what you 
only use in `TagVisitor::VisitNode()` (where you truly hook your `Callback` to 
get extra information later on):

  const NoteTag *setNoteTag(StringRef Message) {
return Eng.getNoteTags().setNoteTag(Message);
  }



- `BugReporterVisitors.h`: basically a `NoteTag` is a string, nothing else, I 
think you would like to hook the `Callback` only when you are about to obtain 
the message:

  class NoteTag {
std::string Msg;
NoteTag(StringRef Message) : ProgramPointTag(), Msg(Message)
  
class Factory {
  const NoteTag *getNoteTag(Callback &)
  const NoteTag *setNoteTag(StringRef Message)
};
  };



- Documentation: if we are about the rewrite the entire bug-reporting business, 
it worth some long doxygen comments.

The outcome is that cool I have to be the reviewer in two patches, and I hope 
it helps you creating a better API, even if I got something wrong.




Comment at: 
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h:364
+
+  Optional getNote(BugReporterContext , BugReport ) const {
+std::string Note = Cb(BRC, R);

It feels like it returns the `NoteTag`, so I would rename it as `getMessage()`.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h:223
+  /// Produce a program point tag that displays an additional path note
+  /// to the user. This is a lightweirght alternative to the
+  /// BugReporterVisitor mechanism: instead of visiting the bug report

It is very randomly spaced, `lightweight`.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58367/new/

https://reviews.llvm.org/D58367



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


[PATCH] D58365: [attributes] Add a MIG server routine attribute.

2019-02-20 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/test/Sema/attr-mig.c:6
+
+__attribute__((mig_server_routine)) kern_return_t var = KERN_SUCCESS; // 
expected-warning-re{{'mig_server_routine' attribute only applies to functions, 
Objective-C methods, and blocks{{$
+

aaron.ballman wrote:
> What's the purpose of the `{{$}}`?
Hmm, right. In the previous, emm, revision of this revision i felt the urge to 
force the end-ofline check in order to discriminate between the two warnings 
that i introduced, out of which one is an initial segment of the other. But 
now, given that we have ", and", i guess it's no longer necessary.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58365/new/

https://reviews.llvm.org/D58365



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


[PATCH] D58365: [attributes] Add a MIG server routine attribute.

2019-02-20 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 187656.
NoQ marked 5 inline comments as done.
NoQ added a comment.

Fxd.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58365/new/

https://reviews.llvm.org/D58365

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/attr-mig.c
  clang/test/Sema/attr-mig.cpp
  clang/test/Sema/attr-mig.m

Index: clang/test/Sema/attr-mig.m
===
--- /dev/null
+++ clang/test/Sema/attr-mig.m
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -fsyntax-only -fblocks -verify %s
+
+typedef int kern_return_t;
+#define KERN_SUCCESS 0
+
+@interface NSObject
+@end
+
+@interface I: NSObject
+- (kern_return_t)foo __attribute__((mig_server_routine)); // no-warning
+- (void) bar_void __attribute__((mig_server_routine)); // expected-warning{{'mig_server_routine' attribute only applies to routines that return a kern_return_t}}
+- (int) bar_int __attribute__((mig_server_routine)); // expected-warning{{'mig_server_routine' attribute only applies to routines that return a kern_return_t}}
+@end
+
+@implementation I
+- (kern_return_t)foo {
+  kern_return_t (^block)() = ^ __attribute__((mig_server_routine)) { // no-warning
+return KERN_SUCCESS;
+  };
+
+  // FIXME: Warn that this block doesn't return a kern_return_t.
+  void (^invalid_block)() = ^ __attribute__((mig_server_routine)) {};
+
+  return block();
+}
+- (void)bar_void {
+}
+- (int)bar_int {
+  return 0;
+}
+@end
Index: clang/test/Sema/attr-mig.cpp
===
--- /dev/null
+++ clang/test/Sema/attr-mig.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef int kern_return_t;
+typedef kern_return_t IOReturn;
+#define KERN_SUCCESS 0
+#define kIOReturnSuccess KERN_SUCCESS
+
+class MyServer {
+public:
+  virtual __attribute__((mig_server_routine)) IOReturn externalMethod();
+  virtual __attribute__((mig_server_routine)) void anotherMethod(); // expected-warning{{'mig_server_routine' attribute only applies to routines that return a kern_return_t}}
+  virtual __attribute__((mig_server_routine)) int yetAnotherMethod(); // expected-warning{{'mig_server_routine' attribute only applies to routines that return a kern_return_t}}
+  [[clang::mig_server_routine]] virtual IOReturn cppAnnotatedMethod();
+  [[clang::mig_server_routine("arg")]] virtual IOReturn cppAnnotatedMethodWithInvalidArgs(); // expected-error{{'mig_server_routine' attribute takes no arguments}}
+  [[clang::mig_server_routine]] virtual int cppInvalidAnnotatedMethod(); // expected-warning{{'mig_server_routine' attribute only applies to routines that return a kern_return_t}}
+};
+
+IOReturn MyServer::externalMethod() {
+  return kIOReturnSuccess;
+}
Index: clang/test/Sema/attr-mig.c
===
--- /dev/null
+++ clang/test/Sema/attr-mig.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef int kern_return_t;
+#define KERN_SUCCESS 0
+
+__attribute__((mig_server_routine)) kern_return_t var = KERN_SUCCESS; // expected-warning{{'mig_server_routine' attribute only applies to functions, Objective-C methods, and blocks}}
+
+__attribute__((mig_server_routine)) void foo_void(); // expected-warning{{'mig_server_routine' attribute only applies to routines that return a kern_return_t}}
+__attribute__((mig_server_routine)) int foo_int(); // expected-warning{{'mig_server_routine' attribute only applies to routines that return a kern_return_t}}
+
+__attribute__((mig_server_routine)) kern_return_t bar_extern(); // no-warning
+__attribute__((mig_server_routine)) kern_return_t bar_forward(); // no-warning
+
+__attribute__((mig_server_routine)) kern_return_t bar_definition() { // no-warning
+  return KERN_SUCCESS;
+}
+
+kern_return_t bar_forward() { // no-warning
+  return KERN_SUCCESS;
+}
+
+__attribute__((mig_server_routine(123))) kern_return_t bar_with_argument(); // expected-error{{'mig_server_routine' attribute takes no arguments}}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -60,6 +60,7 @@
 // CHECK-NEXT: InternalLinkage (SubjectMatchRule_variable, SubjectMatchRule_function, SubjectMatchRule_record)
 // CHECK-NEXT: LTOVisibilityPublic (SubjectMatchRule_record)
 // CHECK-NEXT: Lockable (SubjectMatchRule_record)
+// CHECK-NEXT: MIGServerRoutine (SubjectMatchRule_function)
 // CHECK-NEXT: MSStruct (SubjectMatchRule_record)
 // CHECK-NEXT: MicroMips (SubjectMatchRule_function)
 // CHECK-NEXT: MinSize (SubjectMatchRule_function, SubjectMatchRule_objc_method)
Index: 

r354512 - Make predefined FLT16 macros conditional on support for the type

2019-02-20 Thread Nemanja Ivanovic via cfe-commits
Author: nemanjai
Date: Wed Feb 20 12:27:33 2019
New Revision: 354512

URL: http://llvm.org/viewvc/llvm-project?rev=354512=rev
Log:
Make predefined FLT16 macros conditional on support for the type

We unconditionally predefine these macros. However, they may be used to
determine if the type is supported. In that case, there are unnecessary
failures to compile the code.

This is the proposed fix for https://bugs.llvm.org/show_bug.cgi?id=40559

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

Modified:
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/test/Headers/float16.c
cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=354512=354511=354512=diff
==
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Wed Feb 20 12:27:33 2019
@@ -830,7 +830,8 @@ static void InitializePredefinedMacros(c
   DefineFmt("__UINTPTR", TI.getUIntPtrType(), TI, Builder);
   DefineTypeWidth("__UINTPTR_WIDTH__", TI.getUIntPtrType(), TI, Builder);
 
-  DefineFloatMacros(Builder, "FLT16", (), "F16");
+  if (TI.hasFloat16Type())
+DefineFloatMacros(Builder, "FLT16", (), "F16");
   DefineFloatMacros(Builder, "FLT", (), "F");
   DefineFloatMacros(Builder, "DBL", (), "");
   DefineFloatMacros(Builder, "LDBL", (), "L");

Modified: cfe/trunk/test/Headers/float16.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/float16.c?rev=354512=354511=354512=diff
==
--- cfe/trunk/test/Headers/float16.c (original)
+++ cfe/trunk/test/Headers/float16.c Wed Feb 20 12:27:33 2019
@@ -1,7 +1,11 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c89 -ffreestanding %s
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c99 -ffreestanding %s
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c11 -ffreestanding %s
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -x c++ -ffreestanding %s
+// RUN: %clang_cc1 -triple=aarch64-none-none -fsyntax-only -verify -std=c89 \
+// RUN:   -ffreestanding %s
+// RUN: %clang_cc1 -triple=aarch64-none-none -fsyntax-only -verify \
+// RUN:   -std=c99 -ffreestanding %s
+// RUN: %clang_cc1 -triple=aarch64-none-none -fsyntax-only -verify -std=c11 \
+// RUN:   -ffreestanding %s
+// RUN: %clang_cc1 -triple=aarch64-none-none -fsyntax-only -verify \
+// RUN:   -std=c++11 -x c++ -ffreestanding %s
 // expected-no-diagnostics
 
 #define __STDC_WANT_IEC_60559_TYPES_EXT__

Modified: cfe/trunk/test/Preprocessor/init.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=354512=354511=354512=diff
==
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Wed Feb 20 12:27:33 2019
@@ -9166,20 +9166,20 @@
 // WEBASSEMBLY-NOT:#define __ELF__
 // WEBASSEMBLY-NEXT:#define __FINITE_MATH_ONLY__ 0
 // WEBASSEMBLY-NEXT:#define __FLOAT128__ 1
-// WEBASSEMBLY-NEXT:#define __FLT16_DECIMAL_DIG__ 5
-// WEBASSEMBLY-NEXT:#define __FLT16_DENORM_MIN__ 5.9604644775390625e-8F16
-// WEBASSEMBLY-NEXT:#define __FLT16_DIG__ 3
-// WEBASSEMBLY-NEXT:#define __FLT16_EPSILON__ 9.765625e-4F16
-// WEBASSEMBLY-NEXT:#define __FLT16_HAS_DENORM__ 1
-// WEBASSEMBLY-NEXT:#define __FLT16_HAS_INFINITY__ 1
-// WEBASSEMBLY-NEXT:#define __FLT16_HAS_QUIET_NAN__ 1
-// WEBASSEMBLY-NEXT:#define __FLT16_MANT_DIG__ 11
-// WEBASSEMBLY-NEXT:#define __FLT16_MAX_10_EXP__ 4
-// WEBASSEMBLY-NEXT:#define __FLT16_MAX_EXP__ 15
-// WEBASSEMBLY-NEXT:#define __FLT16_MAX__ 6.5504e+4F16
-// WEBASSEMBLY-NEXT:#define __FLT16_MIN_10_EXP__ (-13)
-// WEBASSEMBLY-NEXT:#define __FLT16_MIN_EXP__ (-14)
-// WEBASSEMBLY-NEXT:#define __FLT16_MIN__ 6.103515625e-5F16
+// WEBASSEMBLY-NOT:#define __FLT16_DECIMAL_DIG__
+// WEBASSEMBLY-NOT:#define __FLT16_DENORM_MIN__
+// WEBASSEMBLY-NOT:#define __FLT16_DIG__
+// WEBASSEMBLY-NOT:#define __FLT16_EPSILON__
+// WEBASSEMBLY-NOT:#define __FLT16_HAS_DENORM__
+// WEBASSEMBLY-NOT:#define __FLT16_HAS_INFINITY__
+// WEBASSEMBLY-NOT:#define __FLT16_HAS_QUIET_NAN__
+// WEBASSEMBLY-NOT:#define __FLT16_MANT_DIG__
+// WEBASSEMBLY-NOT:#define __FLT16_MAX_10_EXP__
+// WEBASSEMBLY-NOT:#define __FLT16_MAX_EXP__
+// WEBASSEMBLY-NOT:#define __FLT16_MAX__
+// WEBASSEMBLY-NOT:#define __FLT16_MIN_10_EXP__
+// WEBASSEMBLY-NOT:#define __FLT16_MIN_EXP__
+// WEBASSEMBLY-NOT:#define __FLT16_MIN__
 // WEBASSEMBLY-NEXT:#define __FLT_DECIMAL_DIG__ 9
 // WEBASSEMBLY-NEXT:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // WEBASSEMBLY-NEXT:#define __FLT_DIG__ 6


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


[PATCH] D57577: Make predefined FLT16 macros conditional on support for the type

2019-02-20 Thread Nemanja Ivanovic via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354512: Make predefined FLT16 macros conditional on support 
for the type (authored by nemanjai, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D57577?vs=185088=187648#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57577/new/

https://reviews.llvm.org/D57577

Files:
  cfe/trunk/lib/Frontend/InitPreprocessor.cpp
  cfe/trunk/test/Headers/float16.c
  cfe/trunk/test/Preprocessor/init.c


Index: cfe/trunk/test/Preprocessor/init.c
===
--- cfe/trunk/test/Preprocessor/init.c
+++ cfe/trunk/test/Preprocessor/init.c
@@ -9166,20 +9166,20 @@
 // WEBASSEMBLY-NOT:#define __ELF__
 // WEBASSEMBLY-NEXT:#define __FINITE_MATH_ONLY__ 0
 // WEBASSEMBLY-NEXT:#define __FLOAT128__ 1
-// WEBASSEMBLY-NEXT:#define __FLT16_DECIMAL_DIG__ 5
-// WEBASSEMBLY-NEXT:#define __FLT16_DENORM_MIN__ 5.9604644775390625e-8F16
-// WEBASSEMBLY-NEXT:#define __FLT16_DIG__ 3
-// WEBASSEMBLY-NEXT:#define __FLT16_EPSILON__ 9.765625e-4F16
-// WEBASSEMBLY-NEXT:#define __FLT16_HAS_DENORM__ 1
-// WEBASSEMBLY-NEXT:#define __FLT16_HAS_INFINITY__ 1
-// WEBASSEMBLY-NEXT:#define __FLT16_HAS_QUIET_NAN__ 1
-// WEBASSEMBLY-NEXT:#define __FLT16_MANT_DIG__ 11
-// WEBASSEMBLY-NEXT:#define __FLT16_MAX_10_EXP__ 4
-// WEBASSEMBLY-NEXT:#define __FLT16_MAX_EXP__ 15
-// WEBASSEMBLY-NEXT:#define __FLT16_MAX__ 6.5504e+4F16
-// WEBASSEMBLY-NEXT:#define __FLT16_MIN_10_EXP__ (-13)
-// WEBASSEMBLY-NEXT:#define __FLT16_MIN_EXP__ (-14)
-// WEBASSEMBLY-NEXT:#define __FLT16_MIN__ 6.103515625e-5F16
+// WEBASSEMBLY-NOT:#define __FLT16_DECIMAL_DIG__
+// WEBASSEMBLY-NOT:#define __FLT16_DENORM_MIN__
+// WEBASSEMBLY-NOT:#define __FLT16_DIG__
+// WEBASSEMBLY-NOT:#define __FLT16_EPSILON__
+// WEBASSEMBLY-NOT:#define __FLT16_HAS_DENORM__
+// WEBASSEMBLY-NOT:#define __FLT16_HAS_INFINITY__
+// WEBASSEMBLY-NOT:#define __FLT16_HAS_QUIET_NAN__
+// WEBASSEMBLY-NOT:#define __FLT16_MANT_DIG__
+// WEBASSEMBLY-NOT:#define __FLT16_MAX_10_EXP__
+// WEBASSEMBLY-NOT:#define __FLT16_MAX_EXP__
+// WEBASSEMBLY-NOT:#define __FLT16_MAX__
+// WEBASSEMBLY-NOT:#define __FLT16_MIN_10_EXP__
+// WEBASSEMBLY-NOT:#define __FLT16_MIN_EXP__
+// WEBASSEMBLY-NOT:#define __FLT16_MIN__
 // WEBASSEMBLY-NEXT:#define __FLT_DECIMAL_DIG__ 9
 // WEBASSEMBLY-NEXT:#define __FLT_DENORM_MIN__ 1.40129846e-45F
 // WEBASSEMBLY-NEXT:#define __FLT_DIG__ 6
Index: cfe/trunk/test/Headers/float16.c
===
--- cfe/trunk/test/Headers/float16.c
+++ cfe/trunk/test/Headers/float16.c
@@ -1,7 +1,11 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c89 -ffreestanding %s
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c99 -ffreestanding %s
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c11 -ffreestanding %s
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -x c++ -ffreestanding %s
+// RUN: %clang_cc1 -triple=aarch64-none-none -fsyntax-only -verify -std=c89 \
+// RUN:   -ffreestanding %s
+// RUN: %clang_cc1 -triple=aarch64-none-none -fsyntax-only -verify \
+// RUN:   -std=c99 -ffreestanding %s
+// RUN: %clang_cc1 -triple=aarch64-none-none -fsyntax-only -verify -std=c11 \
+// RUN:   -ffreestanding %s
+// RUN: %clang_cc1 -triple=aarch64-none-none -fsyntax-only -verify \
+// RUN:   -std=c++11 -x c++ -ffreestanding %s
 // expected-no-diagnostics
 
 #define __STDC_WANT_IEC_60559_TYPES_EXT__
Index: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
===
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp
@@ -830,7 +830,8 @@
   DefineFmt("__UINTPTR", TI.getUIntPtrType(), TI, Builder);
   DefineTypeWidth("__UINTPTR_WIDTH__", TI.getUIntPtrType(), TI, Builder);
 
-  DefineFloatMacros(Builder, "FLT16", (), "F16");
+  if (TI.hasFloat16Type())
+DefineFloatMacros(Builder, "FLT16", (), "F16");
   DefineFloatMacros(Builder, "FLT", (), "F");
   DefineFloatMacros(Builder, "DBL", (), "");
   DefineFloatMacros(Builder, "LDBL", (), "L");


Index: cfe/trunk/test/Preprocessor/init.c
===
--- cfe/trunk/test/Preprocessor/init.c
+++ cfe/trunk/test/Preprocessor/init.c
@@ -9166,20 +9166,20 @@
 // WEBASSEMBLY-NOT:#define __ELF__
 // WEBASSEMBLY-NEXT:#define __FINITE_MATH_ONLY__ 0
 // WEBASSEMBLY-NEXT:#define __FLOAT128__ 1
-// WEBASSEMBLY-NEXT:#define __FLT16_DECIMAL_DIG__ 5
-// WEBASSEMBLY-NEXT:#define __FLT16_DENORM_MIN__ 5.9604644775390625e-8F16
-// WEBASSEMBLY-NEXT:#define __FLT16_DIG__ 3
-// WEBASSEMBLY-NEXT:#define __FLT16_EPSILON__ 9.765625e-4F16
-// WEBASSEMBLY-NEXT:#define __FLT16_HAS_DENORM__ 1
-// WEBASSEMBLY-NEXT:#define __FLT16_HAS_INFINITY__ 1
-// WEBASSEMBLY-NEXT:#define __FLT16_HAS_QUIET_NAN__ 1
-// WEBASSEMBLY-NEXT:#define __FLT16_MANT_DIG__ 11
-// 

r354509 - [OPENMP] Use targetDiag for diagnostics of unsupported exceptions, NFC.

2019-02-20 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Feb 20 11:37:17 2019
New Revision: 354509

URL: http://llvm.org/viewvc/llvm-project?rev=354509=rev
Log:
[OPENMP] Use targetDiag for diagnostics of unsupported exceptions, NFC.

Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaStmt.cpp

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=354509=354508=354509=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Wed Feb 20 11:37:17 2019
@@ -752,10 +752,7 @@ ExprResult Sema::BuildCXXThrow(SourceLoc
   if (!getLangOpts().CXXExceptions &&
   !getSourceManager().isInSystemHeader(OpLoc)) {
 // Delay error emission for the OpenMP device code.
-if (LangOpts.OpenMP && LangOpts.OpenMPIsDevice)
-  diagIfOpenMPDeviceCode(OpLoc, diag::err_exceptions_disabled) << "throw";
-else
-  Diag(OpLoc, diag::err_exceptions_disabled) << "throw";
+targetDiag(OpLoc, diag::err_exceptions_disabled) << "throw";
   }
 
   // Exceptions aren't allowed in CUDA device code.

Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=354509=354508=354509=diff
==
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Wed Feb 20 11:37:17 2019
@@ -3995,10 +3995,7 @@ StmtResult Sema::ActOnCXXTryBlock(Source
   if (!getLangOpts().CXXExceptions &&
   !getSourceManager().isInSystemHeader(TryLoc)) {
 // Delay error emission for the OpenMP device code.
-if (LangOpts.OpenMP && LangOpts.OpenMPIsDevice)
-  diagIfOpenMPDeviceCode(TryLoc, diag::err_exceptions_disabled) << "try";
-else
-  Diag(TryLoc, diag::err_exceptions_disabled) << "try";
+targetDiag(TryLoc, diag::err_exceptions_disabled) << "try";
   }
 
   // Exceptions aren't allowed in CUDA device code.


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


[PATCH] D57883: [clang-tidy] refactor ExceptionAnalyzer further to give ternary answer

2019-02-20 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 187635.
JonasToth marked an inline comment as done.
JonasToth added a comment.

- be explicit about the State enumerator values


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57883/new/

https://reviews.llvm.org/D57883

Files:
  clang-tidy/bugprone/ExceptionEscapeCheck.cpp
  clang-tidy/utils/ExceptionAnalyzer.cpp
  clang-tidy/utils/ExceptionAnalyzer.h

Index: clang-tidy/utils/ExceptionAnalyzer.h
===
--- clang-tidy/utils/ExceptionAnalyzer.h
+++ clang-tidy/utils/ExceptionAnalyzer.h
@@ -10,6 +10,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_EXCEPTION_ANALYZER_H
 
 #include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/StringSet.h"
 
@@ -17,29 +18,131 @@
 namespace tidy {
 namespace utils {
 
-/// This class analysis if a `FunctionDecl` can in principle throw an exception,
-/// either directly or indirectly.
-/// It can be configured to ignore custom exception types.
+/// This class analysis if a `FunctionDecl` can in principle throw an
+/// exception, either directly or indirectly. It can be configured to ignore
+/// custom exception types.
 class ExceptionAnalyzer {
 public:
+  enum class State : std::int8_t {
+Throwing = 0,///< The function can definitly throw given an AST.
+NotThrowing = 1, ///< This function can not throw, given an AST.
+Unknown = 2, ///< This can happen for extern functions without available
+ ///< definition.
+  };
+
+  /// Bundle the gathered information about an entity like a function regarding
+  /// it's exception behaviour. The 'NonThrowing'-state can be considered as the
+  /// neutral element in terms of information propagation.
+  /// In the case of 'Throwing' state it is possible that 'getExceptionTypes'
+  /// does not include *ALL* possible types as there is the possibility that
+  /// an 'Unknown' function is called that might throw a previously unknown
+  /// exception at runtime.
+  class ExceptionInfo {
+  public:
+using Throwables = llvm::SmallSet;
+static ExceptionInfo createUnknown() {
+  return ExceptionInfo(State::Unknown);
+}
+static ExceptionInfo createNonThrowing() {
+  return ExceptionInfo(State::Throwing);
+}
+
+/// By default the exception situation is unknown and must be
+/// clarified step-wise.
+ExceptionInfo() : Behaviour(State::NotThrowing), ContainsUnknown(false) {}
+ExceptionInfo(State S)
+: Behaviour(S), ContainsUnknown(S == State::Unknown) {}
+
+ExceptionInfo(const ExceptionInfo &) = default;
+ExceptionInfo =(const ExceptionInfo &) = default;
+ExceptionInfo(ExceptionInfo &&) = default;
+ExceptionInfo =(ExceptionInfo &&) = default;
+
+State getBehaviour() const { return Behaviour; }
+
+/// Register a single exception type as recognized potential exception to be
+/// thrown.
+void registerException(const Type *ExceptionType);
+
+/// Registers a `SmallVector` of exception types as recognized potential
+/// exceptions to be thrown.
+void registerExceptions(const Throwables );
+
+/// Updates the local state according to the other state. That means if
+/// for example a function contains multiple statements the 'ExceptionInfo'
+/// for the final function is the merged result of each statement.
+/// If one of these statements throws the whole function throws and if one
+/// part is unknown and the rest is non-throwing the result will be
+/// unknown.
+ExceptionInfo (const ExceptionInfo );
+
+/// This method is useful in case 'catch' clauses are analyzed as it is
+/// possible to catch multiple exception types by one 'catch' if they
+/// are a subclass of the 'catch'ed exception type.
+/// Returns 'true' if some exceptions were filtered, otherwise 'false'.
+bool filterByCatch(const Type *BaseClass);
+
+/// Filter the set of thrown exception type against a set of ignored
+/// types that shall not be considered in the exception analysis.
+/// This includes explicit `std::bad_alloc` ignoring as separate option.
+ExceptionInfo &
+filterIgnoredExceptions(const llvm::StringSet<> ,
+bool IgnoreBadAlloc);
+
+/// Clear the state to 'NonThrowing' to make the corresponding entity
+/// neutral.
+void clear();
+
+/// References the set of known exception types that can escape from the
+/// corresponding entity.
+const Throwables () const { return ThrownExceptions; }
+
+/// Signal if the there is any 'Unknown' element within the scope of
+/// the related entity. This might be relevant if the entity is 'Throwing'
+/// and to ensure that no other exception then 'getExceptionTypes' can
+/// occur. If there is an 'Unknown' element this can not be guaranteed.
+bool 

[PATCH] D57883: [clang-tidy] refactor ExceptionAnalyzer further to give ternary answer

2019-02-20 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth marked 3 inline comments as done.
JonasToth added a comment.

all comments resolved. I will land this now.




Comment at: clang-tidy/utils/ExceptionAnalyzer.h:26-31
+  enum class State : std::int8_t {
+Throwing,///< The function can definitly throw given an AST.
+NotThrowing, ///< This function can not throw, given an AST.
+Unknown, ///< This can happen for extern functions without available
+ ///< definition.
+  };

lebedev.ri wrote:
> Since this is later used in a bit field, it might be better to be explicit 
> ```
>   enum class State : std::int8_t {
> Throwing = 0,///< The function can definitly throw given an AST.
> NotThrowing = 1, ///< This function can not throw, given an AST.
> Unknown = 2, ///< This can happen for extern functions without 
> available
>  ///< definition.
>   };
> ```
> and indeed, only 2 bits needed.
Done.



Comment at: clang-tidy/utils/ExceptionAnalyzer.h:128
+/// throw, if it's unknown or if it won't throw.
+enum State Behaviour : 4;
+

baloghadamsoftware wrote:
> Why 4 bits, not just 2? Can we expect additional states?
True, math not so strong in me :D


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57883/new/

https://reviews.llvm.org/D57883



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


[PATCH] D57883: [clang-tidy] refactor ExceptionAnalyzer further to give ternary answer

2019-02-20 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 187634.
JonasToth marked 2 inline comments as done.
JonasToth added a comment.

- [Refactor] move support classes into the analyzer
- [Refactor] move bigger methods into implementation file
- minor adjustments


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57883/new/

https://reviews.llvm.org/D57883

Files:
  clang-tidy/bugprone/ExceptionEscapeCheck.cpp
  clang-tidy/utils/ExceptionAnalyzer.cpp
  clang-tidy/utils/ExceptionAnalyzer.h

Index: clang-tidy/utils/ExceptionAnalyzer.h
===
--- clang-tidy/utils/ExceptionAnalyzer.h
+++ clang-tidy/utils/ExceptionAnalyzer.h
@@ -10,6 +10,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_EXCEPTION_ANALYZER_H
 
 #include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/StringSet.h"
 
@@ -17,29 +18,131 @@
 namespace tidy {
 namespace utils {
 
-/// This class analysis if a `FunctionDecl` can in principle throw an exception,
-/// either directly or indirectly.
-/// It can be configured to ignore custom exception types.
+/// This class analysis if a `FunctionDecl` can in principle throw an
+/// exception, either directly or indirectly. It can be configured to ignore
+/// custom exception types.
 class ExceptionAnalyzer {
 public:
+  enum class State : std::int8_t {
+Throwing,///< The function can definitly throw given an AST.
+NotThrowing, ///< This function can not throw, given an AST.
+Unknown, ///< This can happen for extern functions without available
+ ///< definition.
+  };
+
+  /// Bundle the gathered information about an entity like a function regarding
+  /// it's exception behaviour. The 'NonThrowing'-state can be considered as the
+  /// neutral element in terms of information propagation.
+  /// In the case of 'Throwing' state it is possible that 'getExceptionTypes'
+  /// does not include *ALL* possible types as there is the possibility that
+  /// an 'Unknown' function is called that might throw a previously unknown
+  /// exception at runtime.
+  class ExceptionInfo {
+  public:
+using Throwables = llvm::SmallSet;
+static ExceptionInfo createUnknown() {
+  return ExceptionInfo(State::Unknown);
+}
+static ExceptionInfo createNonThrowing() {
+  return ExceptionInfo(State::Throwing);
+}
+
+/// By default the exception situation is unknown and must be
+/// clarified step-wise.
+ExceptionInfo() : Behaviour(State::NotThrowing), ContainsUnknown(false) {}
+ExceptionInfo(State S)
+: Behaviour(S), ContainsUnknown(S == State::Unknown) {}
+
+ExceptionInfo(const ExceptionInfo &) = default;
+ExceptionInfo =(const ExceptionInfo &) = default;
+ExceptionInfo(ExceptionInfo &&) = default;
+ExceptionInfo =(ExceptionInfo &&) = default;
+
+State getBehaviour() const { return Behaviour; }
+
+/// Register a single exception type as recognized potential exception to be
+/// thrown.
+void registerException(const Type *ExceptionType);
+
+/// Registers a `SmallVector` of exception types as recognized potential
+/// exceptions to be thrown.
+void registerExceptions(const Throwables );
+
+/// Updates the local state according to the other state. That means if
+/// for example a function contains multiple statements the 'ExceptionInfo'
+/// for the final function is the merged result of each statement.
+/// If one of these statements throws the whole function throws and if one
+/// part is unknown and the rest is non-throwing the result will be
+/// unknown.
+ExceptionInfo (const ExceptionInfo );
+
+/// This method is useful in case 'catch' clauses are analyzed as it is
+/// possible to catch multiple exception types by one 'catch' if they
+/// are a subclass of the 'catch'ed exception type.
+/// Returns 'true' if some exceptions were filtered, otherwise 'false'.
+bool filterByCatch(const Type *BaseClass);
+
+/// Filter the set of thrown exception type against a set of ignored
+/// types that shall not be considered in the exception analysis.
+/// This includes explicit `std::bad_alloc` ignoring as separate option.
+ExceptionInfo &
+filterIgnoredExceptions(const llvm::StringSet<> ,
+bool IgnoreBadAlloc);
+
+/// Clear the state to 'NonThrowing' to make the corresponding entity
+/// neutral.
+void clear();
+
+/// References the set of known exception types that can escape from the
+/// corresponding entity.
+const Throwables () const { return ThrownExceptions; }
+
+/// Signal if the there is any 'Unknown' element within the scope of
+/// the related entity. This might be relevant if the entity is 'Throwing'
+/// and to ensure that no other exception then 'getExceptionTypes' can
+/// occur. If there is an 

[PATCH] D58418: [clang][DirectoryWatcher] Upstream DirectoryWatcher

2019-02-20 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Also, don't forget that `inotify()` is not 100% reliable on Linux, and it can 
miss events under high loads. So technically you should probably include 
periodic directory scans if you are going to rely on this actually reporting 
every file added.




Comment at: clang/lib/DirectoryWatcher/DirectoryWatcher-linux.inc.h:101
+if (numRead == -1) {
+  return; // watcher is stopped.
+}

Looks like you're not handling `EINTR`.



Comment at: clang/lib/DirectoryWatcher/DirectoryWatcher-linux.inc.h:106
+for (char *p = buf; p < buf + numRead;) {
+  struct inotify_event *ievt = (struct inotify_event *)p;
+  p += sizeof(struct inotify_event) + ievt->len;

Maybe use C++ casts.

Also, I'd add some asserts for whether you've got enough data read.



Comment at: clang/lib/DirectoryWatcher/DirectoryWatcher-linux.inc.h:116
+
+  DirectoryWatcher::EventKind K = DirectoryWatcher::EventKind::Added;
+  if (ievt->mask & IN_MODIFY) {

I don't think I understand this assumption. Have you any specific event in mind 
that is supposed to be treated as added here? If not, maybe it'd be better to 
have no default and instead assert that one of the conditions below matched.



Comment at: clang/lib/DirectoryWatcher/DirectoryWatcher-linux.inc.h:135
+if (!statusOpt.hasValue())
+  K = DirectoryWatcher::EventKind::Removed;
+  }

Why? I suppose this deserves a comment.



Comment at: clang/lib/DirectoryWatcher/DirectoryWatcher-linux.inc.h:154
+errorMsg += llvm::sys::StrError();
+return true;
+  };

The return values seem to be confusing. Any reason not to use `true` for 
success?



Comment at: clang/lib/DirectoryWatcher/DirectoryWatcher-linux.inc.h:193
+return;
+  close(inotifyFD);
+  inotifyFD = -1;

You're ignoring return value.



Comment at: clang/lib/DirectoryWatcher/DirectoryWatcher.cpp:95
+
+#if !defined(__has_include)
+#define __has_include(x) 0

Why not use CMake checks? You're already partially using them for frameworks.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58418/new/

https://reviews.llvm.org/D58418



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


[clang-tools-extra] r354507 - [clangd] Fix a crash in Selection

2019-02-20 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Wed Feb 20 11:26:39 2019
New Revision: 354507

URL: http://llvm.org/viewvc/llvm-project?rev=354507=rev
Log:
[clangd] Fix a crash in Selection

Summary:
The assertion checking that a range of a node is a token range does
not hold in case of "split" tokens, e.g. between two closing template
argument lists (`vector>`).

Reviewers: kadircet, sammccall

Reviewed By: kadircet

Subscribers: ioeric, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clangd/Selection.cpp
clang-tools-extra/trunk/unittests/clangd/SelectionTests.cpp

Modified: clang-tools-extra/trunk/clangd/Selection.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Selection.cpp?rev=354507=354506=354507=diff
==
--- clang-tools-extra/trunk/clangd/Selection.cpp (original)
+++ clang-tools-extra/trunk/clangd/Selection.cpp Wed Feb 20 11:26:39 2019
@@ -198,11 +198,10 @@ private:
   auto E = SM.getDecomposedLoc(R.getEnd());
   if (B.first != SelFile || E.first != SelFile)
 continue;
-  assert(R.isTokenRange());
   // Try to cover up to the next token, spaces between children don't 
count.
   if (auto Tok = Lexer::findNextToken(R.getEnd(), SM, LangOpts))
 E.second = SM.getFileOffset(Tok->getLocation());
-  else
+  else if (R.isTokenRange())
 E.second += Lexer::MeasureTokenLength(R.getEnd(), SM, LangOpts);
   ChildRanges.push_back({B.second, E.second});
 }

Modified: clang-tools-extra/trunk/unittests/clangd/SelectionTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/SelectionTests.cpp?rev=354507=354506=354507=diff
==
--- clang-tools-extra/trunk/unittests/clangd/SelectionTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/SelectionTests.cpp Wed Feb 20 
11:26:39 2019
@@ -232,6 +232,11 @@ TEST(SelectionTest, Selected) {
   }
 }
   )cpp",
+  R"cpp(
+  template 
+  struct unique_ptr {};
+  void foo(^$C[[unique_ptr>]]^ a) {}
+  )cpp",
   };
   for (const char *C : Cases) {
 Annotations Test(C);


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


[PATCH] D58447: [clangd] Fix a crash in Selection

2019-02-20 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354507: [clangd] Fix a crash in Selection (authored by 
ibiryukov, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58447?vs=187569=187632#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58447/new/

https://reviews.llvm.org/D58447

Files:
  clang-tools-extra/trunk/clangd/Selection.cpp
  clang-tools-extra/trunk/unittests/clangd/SelectionTests.cpp


Index: clang-tools-extra/trunk/unittests/clangd/SelectionTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/SelectionTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/SelectionTests.cpp
@@ -232,6 +232,11 @@
   }
 }
   )cpp",
+  R"cpp(
+  template 
+  struct unique_ptr {};
+  void foo(^$C[[unique_ptr>]]^ a) {}
+  )cpp",
   };
   for (const char *C : Cases) {
 Annotations Test(C);
Index: clang-tools-extra/trunk/clangd/Selection.cpp
===
--- clang-tools-extra/trunk/clangd/Selection.cpp
+++ clang-tools-extra/trunk/clangd/Selection.cpp
@@ -198,11 +198,10 @@
   auto E = SM.getDecomposedLoc(R.getEnd());
   if (B.first != SelFile || E.first != SelFile)
 continue;
-  assert(R.isTokenRange());
   // Try to cover up to the next token, spaces between children don't 
count.
   if (auto Tok = Lexer::findNextToken(R.getEnd(), SM, LangOpts))
 E.second = SM.getFileOffset(Tok->getLocation());
-  else
+  else if (R.isTokenRange())
 E.second += Lexer::MeasureTokenLength(R.getEnd(), SM, LangOpts);
   ChildRanges.push_back({B.second, E.second});
 }


Index: clang-tools-extra/trunk/unittests/clangd/SelectionTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/SelectionTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/SelectionTests.cpp
@@ -232,6 +232,11 @@
   }
 }
   )cpp",
+  R"cpp(
+  template 
+  struct unique_ptr {};
+  void foo(^$C[[unique_ptr>]]^ a) {}
+  )cpp",
   };
   for (const char *C : Cases) {
 Annotations Test(C);
Index: clang-tools-extra/trunk/clangd/Selection.cpp
===
--- clang-tools-extra/trunk/clangd/Selection.cpp
+++ clang-tools-extra/trunk/clangd/Selection.cpp
@@ -198,11 +198,10 @@
   auto E = SM.getDecomposedLoc(R.getEnd());
   if (B.first != SelFile || E.first != SelFile)
 continue;
-  assert(R.isTokenRange());
   // Try to cover up to the next token, spaces between children don't count.
   if (auto Tok = Lexer::findNextToken(R.getEnd(), SM, LangOpts))
 E.second = SM.getFileOffset(Tok->getLocation());
-  else
+  else if (R.isTokenRange())
 E.second += Lexer::MeasureTokenLength(R.getEnd(), SM, LangOpts);
   ChildRanges.push_back({B.second, E.second});
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58320: [Darwin] Introduce a new flag, -flink-builtins-rt that forces linking of the builtins library.

2019-02-20 Thread Amara Emerson via Phabricator via cfe-commits
aemerson abandoned this revision.
aemerson added a comment.

After discussion on the thread, we can implement this requirement with -nolibc 
-nostdlib++ -nostartfiles


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58320/new/

https://reviews.llvm.org/D58320



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


[PATCH] D58345: [clangd] Using symbol name to map includes for STL symbols.

2019-02-20 Thread Haojian Wu via Phabricator via cfe-commits
hokein marked 2 inline comments as done.
hokein added inline comments.



Comment at: clangd/index/CanonicalIncludes.cpp:47
+  // headers (e.g. std::move from  and ), using
+  // qualified name can not disambiguate headers. Instead we should return all
+  // headers and do the disambiguation in clangd side.

sammccall wrote:
> Looking at the actual data, I'm not sure this is the right strategy. (and 
> it's not clear what "the clangd side" is :-)
> 
> The ambiguous cases seem to break down into:
>  - cases where we should just pick one, e.g. cstdlib vs cmath for std::abs
>  - cases where a function is overloaded for a particular type (e.g. complex), 
> where passing more information in here (strawman: "the signature as a 
> string") would let us get this correct. Alternatively (and easier), I believe 
> always using the "primary" version of this function is going to be correct if 
> not *strictly* iwyu, as the type comes from the same header. So In the short 
> term I'd suggest just blacklisting the variants.
>  - cases like std::move and... maybe one or two more? In the short term 
> always returning `` seems good enough. In the long term, passing in 
> the signature again would let us disambiguate here.
> Looking at the actual data, I'm not sure this is the right strategy. (and 
> it's not clear what "the clangd side" is :-)

`clangd side` I mean the consumer side.

> cases where we should just pick one, e.g. cstdlib vs cmath for std::abs

For these cases, I think we can address them in generator side by using a 
hardcoded whitelist.

> cases where a function is overloaded for a particular type (e.g. complex), 
> where passing more information in here (strawman: "the signature as a 
> string") would let us get this correct. Alternatively (and easier), I believe 
> always using the "primary" version of this function is going to be correct if 
> not *strictly* iwyu, as the type comes from the same header. So In the short 
> term I'd suggest just blacklisting the variants.

Using primary version seems promising, and our indexer doesn't index the 
template specification symbols.

> cases like std::move and... maybe one or two more? In the short term always 
> returning  seems good enough. In the long term, passing in the 
> signature again would let us disambiguate here.

For std::move this particular case, I don't think using signature (as a string) 
really helps to disambiguate, since both of them are templates, the signature 
string doesn't contain any word specific to the header names 
/. The best way to disambiguate them is to use the number 
of parameters IMO.

I'm +1 on returning `utility`, since `std::move` in `utility` is more 
widely-used.


Or another way to disambiguate: use symbol name => header for symbols with 
unique headers; otherwise fallback to use header  mapping.



Comment at: clangd/index/CanonicalIncludes.cpp:123
 
   static const std::vector>
   SystemHeaderMap = {

sammccall wrote:
> hokein wrote:
> > ioeric wrote:
> > > Can we remove the suffix header mapping now? Is it for the 
> > > `std::chrono::` symbols? What are the reasons not to include them in this 
> > > patch? 
> > Ideally, we could remove it once we get a perfect symbol mapping but I'd 
> > prefer to keep it (it serves as a fallback when we don't find symbols in 
> > the symbol mapping), so that we could add new symbol mapping increasingly 
> > without changing the current behavior.
> > 
> > Removing it should be done carefully without introducing regression, and is 
> > outside the scope of this patch.
> We do need fallback heuristics. We should conisder cases:
>  - for known `std::` symbols mapped to one system header, we don't need a 
> fallback
>  - for known `std::` mapped to multiple system headers (`std::move`), we need 
> some fallback. There are probably few enough of these that it doesn't justify 
> listing *all* system header paths.
>  - for known `std::` symbols with a primary template in one file and 
> specializations/overloads in another (swap?) always inserting the primary 
> seems fine 
>  - For "random" unknown symbols from system header `foo/bits/_bar.h`, we can 
> not insert, correct to ``, or use the full path name. I don't have a 
> strong preference here, maybe we should do what's easiest.
>  - for c standard library (`::printf` --> `` etc) we probably want 
> mappings just like in this patch, I think cppreference has them.
>  - other "standardish" headers (POSIX etc) - hmm, unclear.
> 
> Thinking about all these cases, I'm thinking the nicest solution would be 
> having the symbol -> header mapping, having a small (symbol,header) -> header 
> mapping **only** for ambiguous cases, and not inserting "system" headers that 
> aren't in the main mapping at all. Then we can improve coverage of posix, 
> windows etc headers over time.
> Question is, how can we recognize "system" headers?
I think we were talking about C++ std symbols.


[PATCH] D58307: [Clang Driver] Add support for "-static-pie" argument to the Clang driver.

2019-02-20 Thread Siva Chandra via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354502: [Clang Driver] Add support for 
-static-pie argument to the Clang driver. (authored by sivachandra, 
committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58307?vs=187091=187628#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58307/new/

https://reviews.llvm.org/D58307

Files:
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
  cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
  cfe/trunk/test/Driver/linux-ld.c

Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -2508,6 +2508,7 @@
 def no_pthread : Flag<["-"], "no-pthread">, Flags<[CC1Option]>;
 def p : Flag<["-"], "p">;
 def pie : Flag<["-"], "pie">;
+def static_pie : Flag<["-"], "static-pie">;
 def read__only__relocs : Separate<["-"], "read_only_relocs">;
 def remap : Flag<["-"], "remap">;
 def rewrite_objc : Flag<["-"], "rewrite-objc">, Flags<[DriverOption,CC1Option]>,
Index: cfe/trunk/test/Driver/linux-ld.c
===
--- cfe/trunk/test/Driver/linux-ld.c
+++ cfe/trunk/test/Driver/linux-ld.c
@@ -176,6 +176,19 @@
 // CHECK-CLANG-NO-LIBGCC-STATIC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
 // CHECK-CLANG-NO-LIBGCC-STATIC: "--start-group" "-lgcc" "-lgcc_eh" "-lc" "--end-group"
 //
+// RUN: %clang -static-pie -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=x86_64-unknown-linux -rtlib=platform \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANG-LD-STATIC-PIE %s
+// CHECK-CLANG-LD-STATIC-PIE: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-CLANG-LD-STATIC-PIE: "-static"
+// CHECK-CLANG-LD-STATIC-PIE: "-pie"
+// CHECK-CLANG-LD-STATIC-PIE: "--no-dynamic-linker"
+// CHECK-CLANG-LD-STATIC-PIE: "-m" "elf_x86_64"
+// CHECK-CLANG-LD-STATIC-PIE: "{{.*}}rcrt1.o"
+// CHECK-CLANG-LD-STATIC-PIE: "--start-group" "-lgcc" "-lgcc_eh" "-lc" "--end-group"
+//
 // RUN: %clang -dynamic -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: --target=x86_64-unknown-linux -rtlib=platform \
 // RUN: --gcc-toolchain="" \
Index: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
@@ -333,6 +333,7 @@
   const bool isAndroid = ToolChain.getTriple().isAndroid();
   const bool IsIAMCU = ToolChain.getTriple().isOSIAMCU();
   const bool IsPIE = getPIE(Args, ToolChain);
+  const bool IsStaticPIE = Args.hasArg(options::OPT_static_pie);
   const bool HasCRTBeginEndFiles =
   ToolChain.getTriple().hasEnvironment() ||
   (ToolChain.getTriple().getVendor() != llvm::Triple::MipsTechnologies);
@@ -353,6 +354,12 @@
   if (IsPIE)
 CmdArgs.push_back("-pie");
 
+  if (IsStaticPIE) {
+CmdArgs.push_back("-static");
+CmdArgs.push_back("-pie");
+CmdArgs.push_back("--no-dynamic-linker");
+  }
+
   if (Args.hasArg(options::OPT_rdynamic))
 CmdArgs.push_back("-export-dynamic");
 
@@ -402,7 +409,7 @@
 if (Args.hasArg(options::OPT_rdynamic))
   CmdArgs.push_back("-export-dynamic");
 
-if (!Args.hasArg(options::OPT_shared)) {
+if (!Args.hasArg(options::OPT_shared) && !IsStaticPIE) {
   const std::string Loader =
   D.DyldPrefix + ToolChain.getDynamicLinker(Args);
   CmdArgs.push_back("-dynamic-linker");
@@ -421,6 +428,8 @@
   crt1 = "gcrt1.o";
 else if (IsPIE)
   crt1 = "Scrt1.o";
+else if (IsStaticPIE)
+  crt1 = "rcrt1.o";
 else
   crt1 = "crt1.o";
   }
@@ -438,14 +447,14 @@
 crtbegin = isAndroid ? "crtbegin_static.o" : "crtbeginT.o";
   else if (Args.hasArg(options::OPT_shared))
 crtbegin = isAndroid ? "crtbegin_so.o" : "crtbeginS.o";
-  else if (IsPIE)
+  else if (IsPIE || IsStaticPIE)
 crtbegin = isAndroid ? "crtbegin_dynamic.o" : "crtbeginS.o";
   else
 crtbegin = isAndroid ? "crtbegin_dynamic.o" : "crtbegin.o";
 
   if (HasCRTBeginEndFiles)
 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crtbegin)));
-}
+	}
 
 // Add crtfastmath.o if available and fast math is enabled.
 ToolChain.AddFastMathRuntimeIfAvailable(Args, CmdArgs);
@@ -489,7 +498,7 @@
 
   if (!Args.hasArg(options::OPT_nostdlib)) {
 if (!Args.hasArg(options::OPT_nodefaultlibs)) {
-  if (Args.hasArg(options::OPT_static))
+  if (Args.hasArg(options::OPT_static) || IsStaticPIE)
 CmdArgs.push_back("--start-group");
 
   if (NeedsSanitizerDeps)
@@ -525,7 +534,7 @@
   if (IsIAMCU)

[PATCH] D58440: [clangd] Store index in '.clangd/index' instead of '.clangd-index'

2019-02-20 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354505: [clangd] Store index in .clangd/index 
instead of .clangd-index (authored by ibiryukov, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D58440?vs=187627=187629#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58440/new/

https://reviews.llvm.org/D58440

Files:
  clang-tools-extra/trunk/clangd/index/Background.h
  clang-tools-extra/trunk/clangd/index/BackgroundIndexStorage.cpp
  clang-tools-extra/trunk/test/clangd/background-index.test
  llvm/trunk/.gitignore


Index: llvm/trunk/.gitignore
===
--- llvm/trunk/.gitignore
+++ llvm/trunk/.gitignore
@@ -72,8 +72,8 @@
 # VS2017 and VSCode config files.
 .vscode
 .vs
-# clangd background index
-.clangd-index
+# clangd index
+.clangd
 
 
#==#
 # Files created in tree by the Go bindings.
Index: clang-tools-extra/trunk/clangd/index/BackgroundIndexStorage.cpp
===
--- clang-tools-extra/trunk/clangd/index/BackgroundIndexStorage.cpp
+++ clang-tools-extra/trunk/clangd/index/BackgroundIndexStorage.cpp
@@ -63,19 +63,19 @@
 }
 
 // Uses disk as a storage for index shards. Creates a directory called
-// ".clangd-index/" under the path provided during construction.
+// ".clangd/index/" under the path provided during construction.
 class DiskBackedIndexStorage : public BackgroundIndexStorage {
   std::string DiskShardRoot;
 
 public:
-  // Sets DiskShardRoot to (Directory + ".clangd-index/") which is the base
+  // Sets DiskShardRoot to (Directory + ".clangd/index/") which is the base
   // directory for all shard files.
   DiskBackedIndexStorage(llvm::StringRef Directory) {
 llvm::SmallString<128> CDBDirectory(Directory);
-llvm::sys::path::append(CDBDirectory, ".clangd-index/");
+llvm::sys::path::append(CDBDirectory, ".clangd", "index");
 DiskShardRoot = CDBDirectory.str();
 std::error_code OK;
-std::error_code EC = llvm::sys::fs::create_directory(DiskShardRoot);
+std::error_code EC = llvm::sys::fs::create_directories(DiskShardRoot);
 if (EC != OK) {
   elog("Failed to create directory {0} for index storage: {1}",
DiskShardRoot, EC.message());
Index: clang-tools-extra/trunk/clangd/index/Background.h
===
--- clang-tools-extra/trunk/clangd/index/Background.h
+++ clang-tools-extra/trunk/clangd/index/Background.h
@@ -54,7 +54,7 @@
   llvm::unique_function;
 
   // Creates an Index Storage that saves shards into disk. Index storage uses
-  // CDBDirectory + ".clangd-index/" as the folder to save shards.
+  // CDBDirectory + ".clangd/index/" as the folder to save shards.
   static Factory createDiskBackedStorageFactory();
 };
 
Index: clang-tools-extra/trunk/test/clangd/background-index.test
===
--- clang-tools-extra/trunk/test/clangd/background-index.test
+++ clang-tools-extra/trunk/test/clangd/background-index.test
@@ -13,7 +13,7 @@
 # RUN: clangd -background-index -background-index-rebuild-period=0 -lit-test < 
%t/definition.jsonrpc | FileCheck %t/definition.jsonrpc
 
 # Test that the index is writing files in the expected location.
-# RUN: ls %t/.clangd-index/foo.cpp.*.idx
+# RUN: ls %t/.clangd/index/foo.cpp.*.idx
 
 # Test the index is read from disk: delete code and restart clangd.
 # RUN: rm %t/foo.cpp


Index: llvm/trunk/.gitignore
===
--- llvm/trunk/.gitignore
+++ llvm/trunk/.gitignore
@@ -72,8 +72,8 @@
 # VS2017 and VSCode config files.
 .vscode
 .vs
-# clangd background index
-.clangd-index
+# clangd index
+.clangd
 
 #==#
 # Files created in tree by the Go bindings.
Index: clang-tools-extra/trunk/clangd/index/BackgroundIndexStorage.cpp
===
--- clang-tools-extra/trunk/clangd/index/BackgroundIndexStorage.cpp
+++ clang-tools-extra/trunk/clangd/index/BackgroundIndexStorage.cpp
@@ -63,19 +63,19 @@
 }
 
 // Uses disk as a storage for index shards. Creates a directory called
-// ".clangd-index/" under the path provided during construction.
+// ".clangd/index/" under the path provided during construction.
 class DiskBackedIndexStorage : public BackgroundIndexStorage {
   std::string DiskShardRoot;
 
 public:
-  // Sets DiskShardRoot to (Directory + ".clangd-index/") which is the base
+  // Sets DiskShardRoot to (Directory + ".clangd/index/") which is the base
   // directory for all shard files.
   DiskBackedIndexStorage(llvm::StringRef Directory) {
 llvm::SmallString<128> CDBDirectory(Directory);
-llvm::sys::path::append(CDBDirectory, 

[clang-tools-extra] r354505 - [clangd] Store index in '.clangd/index' instead of '.clangd-index'

2019-02-20 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Wed Feb 20 11:08:06 2019
New Revision: 354505

URL: http://llvm.org/viewvc/llvm-project?rev=354505=rev
Log:
[clangd] Store index in '.clangd/index' instead of '.clangd-index'

Summary: To take up the .clangd folder for other potential uses in the future.

Reviewers: kadircet, sammccall

Reviewed By: kadircet

Subscribers: ioeric, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clangd/index/Background.h
clang-tools-extra/trunk/clangd/index/BackgroundIndexStorage.cpp
clang-tools-extra/trunk/test/clangd/background-index.test

Modified: clang-tools-extra/trunk/clangd/index/Background.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Background.h?rev=354505=354504=354505=diff
==
--- clang-tools-extra/trunk/clangd/index/Background.h (original)
+++ clang-tools-extra/trunk/clangd/index/Background.h Wed Feb 20 11:08:06 2019
@@ -54,7 +54,7 @@ public:
   llvm::unique_function;
 
   // Creates an Index Storage that saves shards into disk. Index storage uses
-  // CDBDirectory + ".clangd-index/" as the folder to save shards.
+  // CDBDirectory + ".clangd/index/" as the folder to save shards.
   static Factory createDiskBackedStorageFactory();
 };
 

Modified: clang-tools-extra/trunk/clangd/index/BackgroundIndexStorage.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/BackgroundIndexStorage.cpp?rev=354505=354504=354505=diff
==
--- clang-tools-extra/trunk/clangd/index/BackgroundIndexStorage.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/BackgroundIndexStorage.cpp Wed Feb 20 
11:08:06 2019
@@ -63,19 +63,19 @@ writeAtomically(llvm::StringRef OutPath,
 }
 
 // Uses disk as a storage for index shards. Creates a directory called
-// ".clangd-index/" under the path provided during construction.
+// ".clangd/index/" under the path provided during construction.
 class DiskBackedIndexStorage : public BackgroundIndexStorage {
   std::string DiskShardRoot;
 
 public:
-  // Sets DiskShardRoot to (Directory + ".clangd-index/") which is the base
+  // Sets DiskShardRoot to (Directory + ".clangd/index/") which is the base
   // directory for all shard files.
   DiskBackedIndexStorage(llvm::StringRef Directory) {
 llvm::SmallString<128> CDBDirectory(Directory);
-llvm::sys::path::append(CDBDirectory, ".clangd-index/");
+llvm::sys::path::append(CDBDirectory, ".clangd", "index");
 DiskShardRoot = CDBDirectory.str();
 std::error_code OK;
-std::error_code EC = llvm::sys::fs::create_directory(DiskShardRoot);
+std::error_code EC = llvm::sys::fs::create_directories(DiskShardRoot);
 if (EC != OK) {
   elog("Failed to create directory {0} for index storage: {1}",
DiskShardRoot, EC.message());

Modified: clang-tools-extra/trunk/test/clangd/background-index.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/background-index.test?rev=354505=354504=354505=diff
==
--- clang-tools-extra/trunk/test/clangd/background-index.test (original)
+++ clang-tools-extra/trunk/test/clangd/background-index.test Wed Feb 20 
11:08:06 2019
@@ -13,7 +13,7 @@
 # RUN: clangd -background-index -background-index-rebuild-period=0 -lit-test < 
%t/definition.jsonrpc | FileCheck %t/definition.jsonrpc
 
 # Test that the index is writing files in the expected location.
-# RUN: ls %t/.clangd-index/foo.cpp.*.idx
+# RUN: ls %t/.clangd/index/foo.cpp.*.idx
 
 # Test the index is read from disk: delete code and restart clangd.
 # RUN: rm %t/foo.cpp


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


r354503 - Fix remaining semicolon pedantic errors for intel

2019-02-20 Thread Gabor Marton via cfe-commits
Author: martong
Date: Wed Feb 20 11:07:36 2019
New Revision: 354503

URL: http://llvm.org/viewvc/llvm-project?rev=354503=rev
Log:
Fix remaining semicolon pedantic errors for intel

Modified:
cfe/trunk/unittests/AST/ASTImporterTest.cpp

Modified: cfe/trunk/unittests/AST/ASTImporterTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/ASTImporterTest.cpp?rev=354503=354502=354503=diff
==
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp (original)
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp Wed Feb 20 11:07:36 2019
@@ -4240,10 +4240,10 @@ ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
 ImportPrototypeAfterImportedDefinition)
 
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, Function, ,
-ImportPrototypes);
+ImportPrototypes)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, Class, , ImportPrototypes)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, Variable, ,
-ImportPrototypes);
+ImportPrototypes)
 // FIXME Enable this test, once we import function templates chains correctly.
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, FunctionTemplate,
 DISABLED_, ImportPrototypes)


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


r354502 - [Clang Driver] Add support for "-static-pie" argument to the Clang driver.

2019-02-20 Thread Siva Chandra via cfe-commits
Author: sivachandra
Date: Wed Feb 20 11:07:04 2019
New Revision: 354502

URL: http://llvm.org/viewvc/llvm-project?rev=354502=rev
Log:
[Clang Driver] Add support for "-static-pie" argument to the Clang driver.

Summary: This change mimics GCC's support for the "-static-pie" argument.

Subscribers: cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
cfe/trunk/test/Driver/linux-ld.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=354502=354501=354502=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Feb 20 11:07:04 2019
@@ -2508,6 +2508,7 @@ def pthread : Flag<["-"], "pthread">, Fl
 def no_pthread : Flag<["-"], "no-pthread">, Flags<[CC1Option]>;
 def p : Flag<["-"], "p">;
 def pie : Flag<["-"], "pie">;
+def static_pie : Flag<["-"], "static-pie">;
 def read__only__relocs : Separate<["-"], "read_only_relocs">;
 def remap : Flag<["-"], "remap">;
 def rewrite_objc : Flag<["-"], "rewrite-objc">, 
Flags<[DriverOption,CC1Option]>,

Modified: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp?rev=354502=354501=354502=diff
==
--- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp Wed Feb 20 11:07:04 2019
@@ -1137,19 +1137,22 @@ static void AddLibgcc(const llvm::Triple
   bool isCygMing = Triple.isOSCygMing();
   bool IsIAMCU = Triple.isOSIAMCU();
   bool StaticLibgcc = Args.hasArg(options::OPT_static_libgcc) ||
-  Args.hasArg(options::OPT_static);
+  Args.hasArg(options::OPT_static) ||
+  Args.hasArg(options::OPT_static_pie);
 
   bool SharedLibgcc = Args.hasArg(options::OPT_shared_libgcc);
   bool UnspecifiedLibgcc = !StaticLibgcc && !SharedLibgcc;
 
   // Gcc adds libgcc arguments in various ways:
   //
-  // gcc : -lgcc --as-needed -lgcc_s --no-as-needed
-  // g++ :   -lgcc_s   -lgcc
-  // gcc shared:   -lgcc_s   -lgcc
-  // g++ shared:   -lgcc_s   -lgcc
-  // gcc static: -lgcc -lgcc_eh
-  // g++ static: -lgcc -lgcc_eh
+  // gcc : -lgcc --as-needed -lgcc_s --no-as-needed
+  // g++ :   -lgcc_s   -lgcc
+  // gcc shared:   -lgcc_s   -lgcc
+  // g++ shared:   -lgcc_s   -lgcc
+  // gcc static: -lgcc -lgcc_eh
+  // g++ static: -lgcc -lgcc_eh
+  // gcc static-pie: -lgcc -lgcc_eh
+  // g++ static-pie: -lgcc -lgcc_eh
   //
   // Also, certain targets need additional adjustments.
 

Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=354502=354501=354502=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Wed Feb 20 11:07:04 2019
@@ -333,6 +333,7 @@ void tools::gnutools::Linker::ConstructJ
   const bool isAndroid = ToolChain.getTriple().isAndroid();
   const bool IsIAMCU = ToolChain.getTriple().isOSIAMCU();
   const bool IsPIE = getPIE(Args, ToolChain);
+  const bool IsStaticPIE = Args.hasArg(options::OPT_static_pie);
   const bool HasCRTBeginEndFiles =
   ToolChain.getTriple().hasEnvironment() ||
   (ToolChain.getTriple().getVendor() != llvm::Triple::MipsTechnologies);
@@ -353,6 +354,12 @@ void tools::gnutools::Linker::ConstructJ
   if (IsPIE)
 CmdArgs.push_back("-pie");
 
+  if (IsStaticPIE) {
+CmdArgs.push_back("-static");
+CmdArgs.push_back("-pie");
+CmdArgs.push_back("--no-dynamic-linker");
+  }
+
   if (Args.hasArg(options::OPT_rdynamic))
 CmdArgs.push_back("-export-dynamic");
 
@@ -402,7 +409,7 @@ void tools::gnutools::Linker::ConstructJ
 if (Args.hasArg(options::OPT_rdynamic))
   CmdArgs.push_back("-export-dynamic");
 
-if (!Args.hasArg(options::OPT_shared)) {
+if (!Args.hasArg(options::OPT_shared) && !IsStaticPIE) {
   const std::string Loader =
   D.DyldPrefix + ToolChain.getDynamicLinker(Args);
   CmdArgs.push_back("-dynamic-linker");
@@ -421,6 +428,8 @@ void tools::gnutools::Linker::ConstructJ
   crt1 = "gcrt1.o";
 else if (IsPIE)
   crt1 = "Scrt1.o";
+else if (IsStaticPIE)
+  crt1 = "rcrt1.o";
 else
   crt1 = "crt1.o";
   }
@@ -438,14 

[PATCH] D58440: [clangd] Store index in '.clangd/index' instead of '.clangd-index'

2019-02-20 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 187627.
ilya-biryukov added a comment.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

- Update .gitignore


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58440/new/

https://reviews.llvm.org/D58440

Files:
  clang-tools-extra/clangd/index/Background.h
  clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
  clang-tools-extra/test/clangd/background-index.test
  llvm/.gitignore


Index: llvm/.gitignore
===
--- llvm/.gitignore
+++ llvm/.gitignore
@@ -72,8 +72,8 @@
 # VS2017 and VSCode config files.
 .vscode
 .vs
-# clangd background index
-.clangd-index
+# clangd index
+.clangd
 
 
#==#
 # Files created in tree by the Go bindings.
Index: clang-tools-extra/test/clangd/background-index.test
===
--- clang-tools-extra/test/clangd/background-index.test
+++ clang-tools-extra/test/clangd/background-index.test
@@ -13,7 +13,7 @@
 # RUN: clangd -background-index -background-index-rebuild-period=0 -lit-test < 
%t/definition.jsonrpc | FileCheck %t/definition.jsonrpc
 
 # Test that the index is writing files in the expected location.
-# RUN: ls %t/.clangd-index/foo.cpp.*.idx
+# RUN: ls %t/.clangd/index/foo.cpp.*.idx
 
 # Test the index is read from disk: delete code and restart clangd.
 # RUN: rm %t/foo.cpp
Index: clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
===
--- clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
+++ clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
@@ -63,19 +63,19 @@
 }
 
 // Uses disk as a storage for index shards. Creates a directory called
-// ".clangd-index/" under the path provided during construction.
+// ".clangd/index/" under the path provided during construction.
 class DiskBackedIndexStorage : public BackgroundIndexStorage {
   std::string DiskShardRoot;
 
 public:
-  // Sets DiskShardRoot to (Directory + ".clangd-index/") which is the base
+  // Sets DiskShardRoot to (Directory + ".clangd/index/") which is the base
   // directory for all shard files.
   DiskBackedIndexStorage(llvm::StringRef Directory) {
 llvm::SmallString<128> CDBDirectory(Directory);
-llvm::sys::path::append(CDBDirectory, ".clangd-index/");
+llvm::sys::path::append(CDBDirectory, ".clangd", "index");
 DiskShardRoot = CDBDirectory.str();
 std::error_code OK;
-std::error_code EC = llvm::sys::fs::create_directory(DiskShardRoot);
+std::error_code EC = llvm::sys::fs::create_directories(DiskShardRoot);
 if (EC != OK) {
   elog("Failed to create directory {0} for index storage: {1}",
DiskShardRoot, EC.message());
Index: clang-tools-extra/clangd/index/Background.h
===
--- clang-tools-extra/clangd/index/Background.h
+++ clang-tools-extra/clangd/index/Background.h
@@ -54,7 +54,7 @@
   llvm::unique_function;
 
   // Creates an Index Storage that saves shards into disk. Index storage uses
-  // CDBDirectory + ".clangd-index/" as the folder to save shards.
+  // CDBDirectory + ".clangd/index/" as the folder to save shards.
   static Factory createDiskBackedStorageFactory();
 };
 


Index: llvm/.gitignore
===
--- llvm/.gitignore
+++ llvm/.gitignore
@@ -72,8 +72,8 @@
 # VS2017 and VSCode config files.
 .vscode
 .vs
-# clangd background index
-.clangd-index
+# clangd index
+.clangd
 
 #==#
 # Files created in tree by the Go bindings.
Index: clang-tools-extra/test/clangd/background-index.test
===
--- clang-tools-extra/test/clangd/background-index.test
+++ clang-tools-extra/test/clangd/background-index.test
@@ -13,7 +13,7 @@
 # RUN: clangd -background-index -background-index-rebuild-period=0 -lit-test < %t/definition.jsonrpc | FileCheck %t/definition.jsonrpc
 
 # Test that the index is writing files in the expected location.
-# RUN: ls %t/.clangd-index/foo.cpp.*.idx
+# RUN: ls %t/.clangd/index/foo.cpp.*.idx
 
 # Test the index is read from disk: delete code and restart clangd.
 # RUN: rm %t/foo.cpp
Index: clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
===
--- clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
+++ clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
@@ -63,19 +63,19 @@
 }
 
 // Uses disk as a storage for index shards. Creates a directory called
-// ".clangd-index/" under the path provided during construction.
+// ".clangd/index/" under the path provided during construction.
 class DiskBackedIndexStorage : public 

[PATCH] D58418: [clang][DirectoryWatcher] Upstream DirectoryWatcher

2019-02-20 Thread Jan Korous via Phabricator via cfe-commits
jkorous updated this revision to Diff 187623.
jkorous added a comment.

[DirectoryWatcher] Fix detection of FSEvents for iOS
[DirectoryWatcher][NFC] Doxygen


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58418/new/

https://reviews.llvm.org/D58418

Files:
  clang/include/clang/DirectoryWatcher/DirectoryWatcher.h
  clang/lib/CMakeLists.txt
  clang/lib/DirectoryWatcher/CMakeLists.txt
  clang/lib/DirectoryWatcher/DirectoryWatcher-linux.inc.h
  clang/lib/DirectoryWatcher/DirectoryWatcher-mac.inc.h
  clang/lib/DirectoryWatcher/DirectoryWatcher.cpp
  clang/unittests/CMakeLists.txt
  clang/unittests/DirectoryWatcher/CMakeLists.txt
  clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp

Index: clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
===
--- /dev/null
+++ clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
@@ -0,0 +1,333 @@
+//===- unittests/DirectoryWatcher/DirectoryWatcherTest.cpp ===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/DirectoryWatcher/DirectoryWatcher.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+#include 
+
+using namespace llvm;
+using namespace llvm::sys;
+using namespace llvm::sys::fs;
+using namespace clang;
+
+namespace {
+
+class EventCollection {
+  SmallVector Events;
+
+public:
+  EventCollection() = default;
+  explicit EventCollection(ArrayRef events) {
+append(events);
+  }
+
+  void append(ArrayRef events) {
+Events.append(events.begin(), events.end());
+  }
+
+  bool empty() const { return Events.empty(); }
+  size_t size() const { return Events.size(); }
+  void clear() { Events.clear(); }
+
+  bool hasEvents(ArrayRef filenames,
+ ArrayRef kinds,
+ ArrayRef stats) const {
+assert(filenames.size() == kinds.size());
+assert(filenames.size() == stats.size());
+SmallVector evts = Events;
+bool hadError = false;
+for (unsigned i = 0, e = filenames.size(); i < e; ++i) {
+  StringRef fname = filenames[i];
+  DirectoryWatcher::EventKind kind = kinds[i];
+  file_status stat = stats[i];
+  auto it = std::find_if(evts.begin(), evts.end(),
+ [&](const DirectoryWatcher::Event ) -> bool {
+   return path::filename(evt.Filename) == fname;
+ });
+  if (it == evts.end()) {
+hadError = err(Twine("expected filename '" + fname + "' not found"));
+continue;
+  }
+  if (it->Kind != kind) {
+hadError = err(Twine("filename '" + fname + "' has event kind " +
+ std::to_string((int)it->Kind) + ", expected ") +
+   std::to_string((int)kind));
+  }
+  if (it->Kind != DirectoryWatcher::EventKind::Removed &&
+  it->ModTime != stat.getLastModificationTime())
+hadError =
+err(Twine("filename '" + fname + "' has different mod time"));
+  evts.erase(it);
+}
+for (const auto  : evts) {
+  hadError = err(Twine("unexpected filename '" +
+   path::filename(evt.Filename) + "' found"));
+}
+return !hadError;
+  }
+
+  bool hasAdded(ArrayRef filenames,
+ArrayRef stats) const {
+std::vector kinds{
+filenames.size(), DirectoryWatcher::EventKind::Added};
+return hasEvents(filenames, kinds, stats);
+  }
+
+  bool hasRemoved(ArrayRef filenames) const {
+std::vector kinds{
+filenames.size(), DirectoryWatcher::EventKind::Removed};
+std::vector stats{filenames.size(), file_status{}};
+return hasEvents(filenames, kinds, stats);
+  }
+
+private:
+  bool err(Twine msg) const {
+SmallString<128> buf;
+llvm::errs() << msg.toStringRef(buf) << '\n';
+return true;
+  }
+};
+
+struct EventOccurrence {
+  std::vector Events;
+  bool IsInitial;
+};
+
+class DirectoryWatcherTest
+: public std::enable_shared_from_this {
+  std::string WatchedDir;
+  std::string TempDir;
+  std::unique_ptr DirWatcher;
+
+  std::condition_variable Condition;
+  std::mutex Mutex;
+  std::deque EvtOccurs;
+
+public:
+  void init() {
+SmallString<128> pathBuf;
+std::error_code EC = createUniqueDirectory("dirwatcher", pathBuf);
+ASSERT_FALSE(EC);
+TempDir = pathBuf.str();
+path::append(pathBuf, "watch");
+WatchedDir = pathBuf.str();
+EC = create_directory(WatchedDir);
+ASSERT_FALSE(EC);
+  }
+
+  ~DirectoryWatcherTest() {
+stopWatching();
+remove_directories(TempDir);
+  }
+
+public:
+  StringRef getWatchedDir() const { return WatchedDir; }
+
+  void addFile(StringRef filename, file_status ) {
+

[PATCH] D58440: [clangd] Store index in '.clangd/index' instead of '.clangd-index'

2019-02-20 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp:75
 llvm::SmallString<128> CDBDirectory(Directory);
-llvm::sys::path::append(CDBDirectory, ".clangd-index/");
+llvm::sys::path::append(CDBDirectory, ".clangd", "index/");
 DiskShardRoot = CDBDirectory.str();

kadircet wrote:
> NIT: it looks like we don't need the "/" at the end of "index/"
Done.
I was not sure if it is important or not. Everything appears to work without 
it, so removing it now.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58440/new/

https://reviews.llvm.org/D58440



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


[PATCH] D58440: [clangd] Store index in '.clangd/index' instead of '.clangd-index'

2019-02-20 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 187622.
ilya-biryukov marked an inline comment as done.
ilya-biryukov added a comment.

- Remove trailing slash from the path


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58440/new/

https://reviews.llvm.org/D58440

Files:
  clang-tools-extra/clangd/index/Background.h
  clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
  clang-tools-extra/test/clangd/background-index.test


Index: clang-tools-extra/test/clangd/background-index.test
===
--- clang-tools-extra/test/clangd/background-index.test
+++ clang-tools-extra/test/clangd/background-index.test
@@ -13,7 +13,7 @@
 # RUN: clangd -background-index -background-index-rebuild-period=0 -lit-test < 
%t/definition.jsonrpc | FileCheck %t/definition.jsonrpc
 
 # Test that the index is writing files in the expected location.
-# RUN: ls %t/.clangd-index/foo.cpp.*.idx
+# RUN: ls %t/.clangd/index/foo.cpp.*.idx
 
 # Test the index is read from disk: delete code and restart clangd.
 # RUN: rm %t/foo.cpp
Index: clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
===
--- clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
+++ clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
@@ -63,19 +63,19 @@
 }
 
 // Uses disk as a storage for index shards. Creates a directory called
-// ".clangd-index/" under the path provided during construction.
+// ".clangd/index/" under the path provided during construction.
 class DiskBackedIndexStorage : public BackgroundIndexStorage {
   std::string DiskShardRoot;
 
 public:
-  // Sets DiskShardRoot to (Directory + ".clangd-index/") which is the base
+  // Sets DiskShardRoot to (Directory + ".clangd/index/") which is the base
   // directory for all shard files.
   DiskBackedIndexStorage(llvm::StringRef Directory) {
 llvm::SmallString<128> CDBDirectory(Directory);
-llvm::sys::path::append(CDBDirectory, ".clangd-index/");
+llvm::sys::path::append(CDBDirectory, ".clangd", "index");
 DiskShardRoot = CDBDirectory.str();
 std::error_code OK;
-std::error_code EC = llvm::sys::fs::create_directory(DiskShardRoot);
+std::error_code EC = llvm::sys::fs::create_directories(DiskShardRoot);
 if (EC != OK) {
   elog("Failed to create directory {0} for index storage: {1}",
DiskShardRoot, EC.message());
Index: clang-tools-extra/clangd/index/Background.h
===
--- clang-tools-extra/clangd/index/Background.h
+++ clang-tools-extra/clangd/index/Background.h
@@ -54,7 +54,7 @@
   llvm::unique_function;
 
   // Creates an Index Storage that saves shards into disk. Index storage uses
-  // CDBDirectory + ".clangd-index/" as the folder to save shards.
+  // CDBDirectory + ".clangd/index/" as the folder to save shards.
   static Factory createDiskBackedStorageFactory();
 };
 


Index: clang-tools-extra/test/clangd/background-index.test
===
--- clang-tools-extra/test/clangd/background-index.test
+++ clang-tools-extra/test/clangd/background-index.test
@@ -13,7 +13,7 @@
 # RUN: clangd -background-index -background-index-rebuild-period=0 -lit-test < %t/definition.jsonrpc | FileCheck %t/definition.jsonrpc
 
 # Test that the index is writing files in the expected location.
-# RUN: ls %t/.clangd-index/foo.cpp.*.idx
+# RUN: ls %t/.clangd/index/foo.cpp.*.idx
 
 # Test the index is read from disk: delete code and restart clangd.
 # RUN: rm %t/foo.cpp
Index: clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
===
--- clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
+++ clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
@@ -63,19 +63,19 @@
 }
 
 // Uses disk as a storage for index shards. Creates a directory called
-// ".clangd-index/" under the path provided during construction.
+// ".clangd/index/" under the path provided during construction.
 class DiskBackedIndexStorage : public BackgroundIndexStorage {
   std::string DiskShardRoot;
 
 public:
-  // Sets DiskShardRoot to (Directory + ".clangd-index/") which is the base
+  // Sets DiskShardRoot to (Directory + ".clangd/index/") which is the base
   // directory for all shard files.
   DiskBackedIndexStorage(llvm::StringRef Directory) {
 llvm::SmallString<128> CDBDirectory(Directory);
-llvm::sys::path::append(CDBDirectory, ".clangd-index/");
+llvm::sys::path::append(CDBDirectory, ".clangd", "index");
 DiskShardRoot = CDBDirectory.str();
 std::error_code OK;
-std::error_code EC = llvm::sys::fs::create_directory(DiskShardRoot);
+std::error_code EC = llvm::sys::fs::create_directories(DiskShardRoot);
 if (EC != OK) {
   elog("Failed to create directory {0} for index storage: {1}",

[PATCH] D58463: [CUDA]Delayed diagnostics for the asm instructions.

2019-02-20 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added reviewers: tra, jlebar.
Herald added a subscriber: jdoerfert.
Herald added a project: clang.

Adapted targetDiag for the CUDA and used for the delayed diagnostics in
asm constructs. Works for both host and device compilation sides.


Repository:
  rC Clang

https://reviews.llvm.org/D58463

Files:
  lib/Sema/Sema.cpp
  lib/Sema/SemaStmtAsm.cpp
  test/SemaCUDA/asm_delayed_diags.cu

Index: test/SemaCUDA/asm_delayed_diags.cu
===
--- /dev/null
+++ test/SemaCUDA/asm_delayed_diags.cu
@@ -0,0 +1,118 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DHOST -triple x86_64-unknown-linux-gnu
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DHOST -DHOST_USED -triple x86_64-unknown-linux-gnu
+// RUN: %clang_cc1 -fsyntax-only -fcuda-is-device -verify %s -DDEVICE_NOT_USED -triple nvptx-unknown-cuda
+// RUN: %clang_cc1 -fsyntax-only -fcuda-is-device -verify %s -DDEVICE -triple nvptx-unknown-cuda
+// RUN: %clang_cc1 -fsyntax-only -fcuda-is-device -verify %s -DDEVICE -DDEVICE_USED -triple nvptx-unknown-cuda
+
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+#if (defined(HOST) && !defined(HOST_USED)) || defined(DEVICE_NOT_USED)
+// expected-no-diagnostics
+#endif
+
+#include "Inputs/cuda.h"
+
+static __device__ __host__ void t1(int r) {
+  __asm__("PR3908 %[lf] %[xx] %[li] %[r]"
+  : [ r ] "+r"(r)
+  : [ lf ] "mx"(0), [ li ] "mr"(0), [ xx ] "x"((double)(0)));
+}
+
+static __device__ __host__ unsigned t2(signed char input) {
+  unsigned output;
+  __asm__("xyz"
+  : "=a"(output)
+  : "0"(input));
+  return output;
+}
+
+static __device__ __host__ double t3(double x) {
+  register long double result;
+  __asm __volatile("frndint"
+   : "=t"(result)
+   : "0"(x));
+  return result;
+}
+
+static __device__ __host__ unsigned char t4(unsigned char a, unsigned char b) {
+  unsigned int la = a;
+  unsigned int lb = b;
+  unsigned int bigres;
+  unsigned char res;
+  __asm__("0:\n1:\n"
+  : [ bigres ] "=la"(bigres)
+  : [ la ] "0"(la), [ lb ] "c"(lb)
+  : "edx", "cc");
+  res = bigres;
+  return res;
+}
+
+static __device__ __host__ void t5(void) {
+  __asm__ __volatile__(
+  "finit"
+  :
+  :
+  : "st", "st(1)", "st(2)", "st(3)",
+"st(4)", "st(5)", "st(6)", "st(7)",
+"fpsr", "fpcr");
+}
+
+typedef long long __m256i __attribute__((__vector_size__(32)));
+static __device__ __host__ void t6(__m256i *p) {
+  __asm__ volatile("vmovaps  %0, %%ymm0" ::"m"(*(__m256i *)p)
+   : "ymm0");
+}
+
+static __device__ __host__ void t7(__m256i *p) {
+  __asm__ volatile("vmovaps  %0, %%ymm0" ::"m"(*(__m256i *)p)
+   : "r0");
+}
+
+#ifdef DEVICE
+__device__ int m() {
+  t1(0);
+  t2(0);
+  t3(0);
+  t4(0, 0);
+  t5();
+  t6(0);
+#ifdef DEVICE_USED
+  t7(0);
+#endif // DEVICE_USED
+  return 0;
+}
+#endif // DEVICE
+
+#ifdef HOST
+__host__ int main() {
+  t1(0);
+  t2(0);
+  t3(0);
+  t4(0, 0);
+  t5();
+  t6(0);
+#ifdef HOST_USED
+  t7(0);
+#endif // HOST_USED
+  return 0;
+}
+#endif // HOST
+
+#if defined(HOST_USED)
+// expected-error@69 {{unknown register name 'r0' in asm}}
+// expected-note@96 {{called by 'main'}}
+#elif defined(DEVICE)
+// expected-error@19 {{invalid input constraint 'mx' in asm}}
+// expected-error@25 {{invalid output constraint '=a' in asm}}
+// expected-error@33 {{invalid output constraint '=t' in asm}}
+// expected-error@44 {{invalid output constraint '=la' in asm}}
+// expected-error@56 {{unknown register name 'st' in asm}}
+// expected-error@64 {{unknown register name 'ymm0' in asm}}
+// expected-note@74 {{called by 'm'}}
+// expected-note@75 {{called by 'm'}}
+// expected-note@76 {{called by 'm'}}
+// expected-note@77 {{called by 'm'}}
+// expected-note@78 {{called by 'm'}}
+// expected-note@79 {{called by 'm'}}
+#endif
Index: lib/Sema/SemaStmtAsm.cpp
===
--- lib/Sema/SemaStmtAsm.cpp
+++ lib/Sema/SemaStmtAsm.cpp
@@ -253,15 +253,6 @@
   // The parser verifies that there is a string literal here.
   assert(AsmString->isAscii());
 
-  // If we're compiling CUDA file and function attributes indicate that it's not
-  // for this compilation side, skip all the checks.
-  if (!DeclAttrsMatchCUDAMode(getLangOpts(), getCurFunctionDecl())) {
-GCCAsmStmt *NS = new (Context) GCCAsmStmt(
-Context, AsmLoc, IsSimple, IsVolatile, NumOutputs, NumInputs, Names,
-Constraints, Exprs.data(), AsmString, NumClobbers, Clobbers, RParenLoc);
-return NS;
-  }
-
   for (unsigned i = 0; i != NumOutputs; i++) {
 StringLiteral *Literal = Constraints[i];
 assert(Literal->isAscii());
Index: lib/Sema/Sema.cpp
===
--- lib/Sema/Sema.cpp
+++ lib/Sema/Sema.cpp
@@ -1487,10 +1487,14 @@
   }
 }
 
-Sema::DeviceDiagBuilder 

[PATCH] D58365: [attributes] Add a MIG server routine attribute.

2019-02-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:8702
+def warn_mig_server_routine_does_not_return_kern_return_t : Warning<
+  "'%0' attribute only applies to functions that return a kernel return code">,
+  InGroup;

NoQ wrote:
> aaron.ballman wrote:
> > Will users understand "kernel return code"? Should this say `kern_return_t` 
> > explicitly?
> > 
> > No need to use %0 here, just spell out the attribute name directly (unless 
> > you expect this to be used by multiple attributes, in which case the name 
> > of the diagnostic should be changed).
> It should say either `kern_return_t` or `IOReturn` depending on the specific 
> framework that's being used (the latter is a typedef for the former). I guess 
> i could scan the AST to for a `typedef kern_return_t IOReturn` and display 
> the appropriate message, but this sort of stuff always sounds like an 
> overkill. For now i change the wording to an exact "a kern_return_t". I could 
> also say "a kern_return_t or an IOReturn", do you have any preference here?
Yeah, I think that scanning the AST would be overkill. This seems sufficiently 
clear, and we can always improve it if users wind up being confused in practice.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:6407
+ASTContext  = S.getASTContext();
+QualType T = AnyCall::forDecl(D)->getReturnType(ACtx);
+bool IsKernReturnT = false;

I'd prefer this to use `getFunctionOrMethodResultType()`.



Comment at: clang/test/Sema/attr-mig.c:6
+
+__attribute__((mig_server_routine)) kern_return_t var = KERN_SUCCESS; // 
expected-warning-re{{'mig_server_routine' attribute only applies to functions, 
Objective-C methods, and blocks{{$
+

What's the purpose of the `{{$}}`?



Comment at: clang/test/Sema/attr-mig.c:17
+}
+
+kern_return_t bar_forward() { // no-warning

NoQ wrote:
> aaron.ballman wrote:
> > Here's an edge case to consider:
> > ```
> > __attribute__((mig_server_routine)) int foo(void);
> > 
> > typedef int kern_return_t;
> > 
> > kern_return_t foo(void) { ... }
> > ```
> > Do you have to care about situations like that?
> > Do you have to care about situations like that?
> 
> I hope i not :) `kern_return_t` is available pretty much everywhere and most 
> likely it's not a problem to update the first declaration of `foo()` with 
> `kern_return_t`. Ok if i add a relaxing code later if it turns out that i 
> have to?
That's what I was hoping to hear. :-)



Comment at: clang/test/Sema/attr-mig.cpp:10
+public:
+  virtual __attribute__((mig_server_routine)) IOReturn externalMethod();
+  virtual __attribute__((mig_server_routine)) void anotherMethod(); // 
expected-warning{{'mig_server_routine' attribute only applies to functions that 
return a kernel return code}}

NoQ wrote:
> aaron.ballman wrote:
> > Can you use the C++ spelling for the attribute, so we have a bit of 
> > coverage for that?
> Is there a vision that i should also provide a namespaced C++ attribute, eg. 
> `[[mig::server_routine]]`?
I think this should continue to use `[[clang::mig_server_routine]]`.



Comment at: clang/test/Sema/attr-mig.m:21
+
+  // TODO: Warn that this block doesn't return a kern_return_t.
+  void (^invalid_block)() = ^ __attribute__((mig_server_routine)) {};

I'd change this to use FIXME instead of TODO.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58365/new/

https://reviews.llvm.org/D58365



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


[PATCH] D58292: Add support for importing ChooseExpr AST nodes.

2019-02-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: lib/AST/ASTImporter.cpp:6140
+ExpectedStmt ASTNodeImporter::VisitChooseExpr(ChooseExpr *E) {
+  auto Imp = importSeq(E->getCond(), E->getLHS(), E->getRHS(),
+   E->getBuiltinLoc(), E->getRParenLoc(), E->getType());

Please don't use `auto` here; the type isn't spelled out in the initialization.



Comment at: lib/AST/ASTImporter.cpp:6160-6162
+  bool CondIsTrue = false;
+  if (!E->isConditionDependent())
+CondIsTrue = E->isConditionTrue();

`bool CondIsTrue = E->isConditionDependent() ? false : E->isConditionTrue();`


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58292/new/

https://reviews.llvm.org/D58292



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


[PATCH] D53701: [Analyzer] Record and process comparison of symbols instead of iterator positions in interator checkers

2019-02-20 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 187611.
baloghadamsoftware added a comment.

Instead of recording comparisons do an eager state split if the result is a 
symbolic value.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D53701/new/

https://reviews.llvm.org/D53701

Files:
  lib/StaticAnalyzer/Checkers/IteratorChecker.cpp

Index: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
+++ lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
@@ -133,8 +133,6 @@
   }
 };
 
-typedef llvm::PointerUnion RegionOrSymbol;
-
 // Structure to record the symbolic begin and end position of a container
 struct ContainerData {
 private:
@@ -172,41 +170,21 @@
   }
 };
 
-// Structure fo recording iterator comparisons. We needed to retrieve the
-// original comparison expression in assumptions.
-struct IteratorComparison {
-private:
-  RegionOrSymbol Left, Right;
-  bool Equality;
-
-public:
-  IteratorComparison(RegionOrSymbol L, RegionOrSymbol R, bool Eq)
-  : Left(L), Right(R), Equality(Eq) {}
-
-  RegionOrSymbol getLeft() const { return Left; }
-  RegionOrSymbol getRight() const { return Right; }
-  bool isEquality() const { return Equality; }
-  bool operator==(const IteratorComparison ) const {
-return Left == X.Left && Right == X.Right && Equality == X.Equality;
-  }
-  bool operator!=(const IteratorComparison ) const {
-return Left != X.Left || Right != X.Right || Equality != X.Equality;
-  }
-  void Profile(llvm::FoldingSetNodeID ) const { ID.AddInteger(Equality); }
-};
-
 class IteratorChecker
 : public Checker, check::Bind,
- check::LiveSymbols, check::DeadSymbols,
- eval::Assume> {
+ check::LiveSymbols, check::DeadSymbols> {
 
   std::unique_ptr OutOfRangeBugType;
   std::unique_ptr MismatchedBugType;
   std::unique_ptr InvalidatedBugType;
 
-  void handleComparison(CheckerContext , const SVal , const SVal ,
-const SVal , OverloadedOperatorKind Op) const;
+  void handleComparison(CheckerContext , const Expr *CE, const SVal ,
+const SVal , const SVal ,
+OverloadedOperatorKind Op) const;
+  void processComparison(CheckerContext , ProgramStateRef State,
+ SymbolRef Sym1, SymbolRef Sym2, const SVal ,
+ OverloadedOperatorKind Op) const;
   void verifyAccess(CheckerContext , const SVal ) const;
   void verifyDereference(CheckerContext , const SVal ) const;
   void handleIncrement(CheckerContext , const SVal , const SVal ,
@@ -281,8 +259,6 @@
  CheckerContext ) const;
   void checkLiveSymbols(ProgramStateRef State, SymbolReaper ) const;
   void checkDeadSymbols(SymbolReaper , CheckerContext ) const;
-  ProgramStateRef evalAssume(ProgramStateRef State, SVal Cond,
- bool Assumption) const;
 };
 } // namespace
 
@@ -292,9 +268,6 @@
 
 REGISTER_MAP_WITH_PROGRAMSTATE(ContainerMap, const MemRegion *, ContainerData)
 
-REGISTER_MAP_WITH_PROGRAMSTATE(IteratorComparisonMap, const SymExpr *,
-   IteratorComparison)
-
 namespace {
 
 bool isIteratorType(const QualType );
@@ -324,16 +297,6 @@
 bool hasSubscriptOperator(ProgramStateRef State, const MemRegion *Reg);
 bool frontModifiable(ProgramStateRef State, const MemRegion *Reg);
 bool backModifiable(ProgramStateRef State, const MemRegion *Reg);
-BinaryOperator::Opcode getOpcode(const SymExpr *SE);
-const RegionOrSymbol getRegionOrSymbol(const SVal );
-const ProgramStateRef processComparison(ProgramStateRef State,
-RegionOrSymbol LVal,
-RegionOrSymbol RVal, bool Equal);
-const ProgramStateRef saveComparison(ProgramStateRef State,
- const SymExpr *Condition, const SVal ,
- const SVal , bool Eq);
-const IteratorComparison *loadComparison(ProgramStateRef State,
- const SymExpr *Condition);
 SymbolRef getContainerBegin(ProgramStateRef State, const MemRegion *Cont);
 SymbolRef getContainerEnd(ProgramStateRef State, const MemRegion *Cont);
 ProgramStateRef createContainerBegin(ProgramStateRef State,
@@ -343,21 +306,9 @@
const SymbolRef Sym);
 const IteratorPosition *getIteratorPosition(ProgramStateRef State,
 const SVal );
-const IteratorPosition *getIteratorPosition(ProgramStateRef State,
-RegionOrSymbol RegOrSym);
 ProgramStateRef setIteratorPosition(ProgramStateRef State, const SVal ,
 const IteratorPosition );
-ProgramStateRef setIteratorPosition(ProgramStateRef State,
-RegionOrSymbol RegOrSym,
-   

[PATCH] D58095: [clang-tidy] Make google-objc-function-naming ignore implicit functions 

2019-02-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Still LGTM, thanks for adding the license snippet!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58095/new/

https://reviews.llvm.org/D58095



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


[PATCH] D58243: [OPENMP] Delay emission of the asm target-specific error messages.

2019-02-20 Thread Alexey Bataev via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354486: [OPENMP] Delay emission of the asm target-specific 
error messages. (authored by ABataev, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58243/new/

https://reviews.llvm.org/D58243

Files:
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/Sema/Sema.cpp
  cfe/trunk/lib/Sema/SemaStmtAsm.cpp
  cfe/trunk/test/OpenMP/nvptx_asm_delayed_diags.c

Index: cfe/trunk/include/clang/Sema/Sema.h
===
--- cfe/trunk/include/clang/Sema/Sema.h
+++ cfe/trunk/include/clang/Sema/Sema.h
@@ -10275,6 +10275,8 @@
   ///  // Otherwise, continue parsing as normal.
   DeviceDiagBuilder diagIfOpenMPDeviceCode(SourceLocation Loc, unsigned DiagID);
 
+  DeviceDiagBuilder targetDiag(SourceLocation Loc, unsigned DiagID);
+
   enum CUDAFunctionTarget {
 CFT_Device,
 CFT_Global,
Index: cfe/trunk/test/OpenMP/nvptx_asm_delayed_diags.c
===
--- cfe/trunk/test/OpenMP/nvptx_asm_delayed_diags.c
+++ cfe/trunk/test/OpenMP/nvptx_asm_delayed_diags.c
@@ -0,0 +1,118 @@
+// RUN: %clang_cc1 -fopenmp -x c -triple i386-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -fsyntax-only
+// RUN: %clang_cc1 -verify -DDIAGS -DIMMEDIATE -fopenmp -x c -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -fsyntax-only
+// RUN: %clang_cc1 -verify -DDIAGS -DDELAYED -fopenmp -x c -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -fsyntax-only
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+#ifndef DIAGS
+// expected-no-diagnostics
+#endif // DIAGS
+
+#ifdef IMMEDIATE
+#pragma omp declare target
+#endif //IMMEDIATE
+void t1(int r) {
+#ifdef DIAGS
+// expected-error@+4 {{invalid input constraint 'mx' in asm}}
+#endif // DIAGS
+  __asm__("PR3908 %[lf] %[xx] %[li] %[r]"
+  : [ r ] "+r"(r)
+  : [ lf ] "mx"(0), [ li ] "mr"(0), [ xx ] "x"((double)(0)));
+}
+
+unsigned t2(signed char input) {
+  unsigned output;
+#ifdef DIAGS
+// expected-error@+3 {{invalid output constraint '=a' in asm}}
+#endif // DIAGS
+  __asm__("xyz"
+  : "=a"(output)
+  : "0"(input));
+  return output;
+}
+
+double t3(double x) {
+  register long double result;
+#ifdef DIAGS
+// expected-error@+3 {{invalid output constraint '=t' in asm}}
+#endif // DIAGS
+  __asm __volatile("frndint"
+   : "=t"(result)
+   : "0"(x));
+  return result;
+}
+
+unsigned char t4(unsigned char a, unsigned char b) {
+  unsigned int la = a;
+  unsigned int lb = b;
+  unsigned int bigres;
+  unsigned char res;
+#ifdef DIAGS
+// expected-error@+3 {{invalid output constraint '=la' in asm}}
+#endif // DIAGS
+  __asm__("0:\n1:\n"
+  : [ bigres ] "=la"(bigres)
+  : [ la ] "0"(la), [ lb ] "c"(lb)
+  : "edx", "cc");
+  res = bigres;
+  return res;
+}
+
+void t5(void) {
+#ifdef DIAGS
+// expected-error@+6 {{unknown register name 'st' in asm}}
+#endif // DIAGS
+  __asm__ __volatile__(
+  "finit"
+  :
+  :
+  : "st", "st(1)", "st(2)", "st(3)",
+"st(4)", "st(5)", "st(6)", "st(7)",
+"fpsr", "fpcr");
+}
+
+typedef long long __m256i __attribute__((__vector_size__(32)));
+void t6(__m256i *p) {
+#ifdef DIAGS
+// expected-error@+3 {{unknown register name 'ymm0' in asm}}
+#endif // DIAGS
+  __asm__ volatile("vmovaps  %0, %%ymm0" ::"m"(*(__m256i *)p)
+   : "ymm0");
+}
+#ifdef IMMEDIATE
+#pragma omp end declare target
+#endif //IMMEDIATE
+
+int main() {
+#ifdef DELAYED
+#pragma omp target
+#endif // DELAYED
+  {
+#ifdef DELAYED
+// expected-note@+2 {{called by 'main'}}
+#endif // DELAYED
+t1(0);
+#ifdef DELAYED
+// expected-note@+2 {{called by 'main'}}
+#endif // DELAYED
+t2(0);
+#ifdef DELAYED
+// expected-note@+2 {{called by 'main'}}
+#endif // DELAYED
+t3(0);
+#ifdef DELAYED
+// expected-note@+2 {{called by 'main'}}
+#endif // DELAYED
+t4(0, 0);
+#ifdef DELAYED
+// expected-note@+2 {{called by 'main'}}
+#endif // DELAYED
+t5();
+#ifdef DELAYED
+// expected-note@+2 {{called by 'main'}}
+#endif // DELAYED
+t6(0);
+  }
+  return 0;
+}
Index: cfe/trunk/lib/Sema/Sema.cpp
===
--- cfe/trunk/lib/Sema/Sema.cpp
+++ cfe/trunk/lib/Sema/Sema.cpp
@@ -1487,6 +1487,14 @@
   }
 }
 
+Sema::DeviceDiagBuilder 

r354486 - [OPENMP] Delay emission of the asm target-specific error messages.

2019-02-20 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Feb 20 09:42:57 2019
New Revision: 354486

URL: http://llvm.org/viewvc/llvm-project?rev=354486=rev
Log:
[OPENMP] Delay emission of the asm target-specific error messages.

Summary:
Added the ability to emit target-specific builtin assembler error
messages only in case if the function is really is going to be emitted
for the device.

Reviewers: rjmccall

Subscribers: guansong, jdoerfert, cfe-commits

Tags: #clang

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

Added:
cfe/trunk/test/OpenMP/nvptx_asm_delayed_diags.c
Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaStmtAsm.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=354486=354485=354486=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Feb 20 09:42:57 2019
@@ -10275,6 +10275,8 @@ public:
   ///  // Otherwise, continue parsing as normal.
   DeviceDiagBuilder diagIfOpenMPDeviceCode(SourceLocation Loc, unsigned 
DiagID);
 
+  DeviceDiagBuilder targetDiag(SourceLocation Loc, unsigned DiagID);
+
   enum CUDAFunctionTarget {
 CFT_Device,
 CFT_Global,

Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=354486=354485=354486=diff
==
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Wed Feb 20 09:42:57 2019
@@ -1487,6 +1487,14 @@ void Sema::markKnownEmitted(
   }
 }
 
+Sema::DeviceDiagBuilder Sema::targetDiag(SourceLocation Loc,
+ unsigned DiagID) {
+  if (LangOpts.OpenMP && LangOpts.OpenMPIsDevice)
+return diagIfOpenMPDeviceCode(Loc, DiagID);
+  return DeviceDiagBuilder(DeviceDiagBuilder::K_Immediate, Loc, DiagID,
+   getCurFunctionDecl(), *this);
+}
+
 /// Looks through the macro-expansion chain for the given
 /// location, looking for a macro expansion with the given name.
 /// If one is found, returns true and sets the location to that

Modified: cfe/trunk/lib/Sema/SemaStmtAsm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmtAsm.cpp?rev=354486=354485=354486=diff
==
--- cfe/trunk/lib/Sema/SemaStmtAsm.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmtAsm.cpp Wed Feb 20 09:42:57 2019
@@ -272,9 +272,9 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceL
 
 TargetInfo::ConstraintInfo Info(Literal->getString(), OutputName);
 if (!Context.getTargetInfo().validateOutputConstraint(Info))
-  return StmtError(
-  Diag(Literal->getBeginLoc(), diag::err_asm_invalid_output_constraint)
-  << Info.getConstraintStr());
+  return StmtResult(targetDiag(Literal->getBeginLoc(),
+   diag::err_asm_invalid_output_constraint)
+<< Info.getConstraintStr());
 
 ExprResult ER = CheckPlaceholderExpr(Exprs[i]);
 if (ER.isInvalid())
@@ -327,11 +327,10 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceL
 }
 
 unsigned Size = Context.getTypeSize(OutputExpr->getType());
-if (!Context.getTargetInfo().validateOutputSize(Literal->getString(),
-Size))
-  return StmtError(
-  Diag(OutputExpr->getBeginLoc(), diag::err_asm_invalid_output_size)
-  << Info.getConstraintStr());
+if (!Context.getTargetInfo().validateOutputSize(Literal->getString(), 
Size))
+  return StmtResult(targetDiag(OutputExpr->getBeginLoc(),
+   diag::err_asm_invalid_output_size)
+<< Info.getConstraintStr());
   }
 
   SmallVector InputConstraintInfos;
@@ -347,9 +346,9 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceL
 TargetInfo::ConstraintInfo Info(Literal->getString(), InputName);
 if (!Context.getTargetInfo().validateInputConstraint(OutputConstraintInfos,
  Info)) {
-  return StmtError(
-  Diag(Literal->getBeginLoc(), diag::err_asm_invalid_input_constraint)
-  << Info.getConstraintStr());
+  return StmtResult(targetDiag(Literal->getBeginLoc(),
+   diag::err_asm_invalid_input_constraint)
+<< Info.getConstraintStr());
 }
 
 ExprResult ER = CheckPlaceholderExpr(Exprs[i]);
@@ -421,8 +420,8 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceL
 unsigned Size = Context.getTypeSize(Ty);
 if (!Context.getTargetInfo().validateInputSize(Literal->getString(),
Size))
-  return StmtError(
-  Diag(InputExpr->getBeginLoc(), diag::err_asm_invalid_input_size)
+  return StmtResult(

[PATCH] D56896: Update property prefix regex to allow numbers.

2019-02-20 Thread Yan Zhang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE354485: Update property prefix regex to allow numbers. 
(authored by Wizard, committed by ).
Herald added a subscriber: jdoerfert.
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D56896?vs=182439=187599#toc

Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56896/new/

https://reviews.llvm.org/D56896

Files:
  clang-tidy/objc/PropertyDeclarationCheck.cpp
  test/clang-tidy/objc-property-declaration.m


Index: clang-tidy/objc/PropertyDeclarationCheck.cpp
===
--- clang-tidy/objc/PropertyDeclarationCheck.cpp
+++ clang-tidy/objc/PropertyDeclarationCheck.cpp
@@ -80,7 +80,8 @@
 }
 
 bool hasCategoryPropertyPrefix(llvm::StringRef PropertyName) {
-  auto RegexExp = llvm::Regex("^[a-zA-Z]+_[a-zA-Z0-9][a-zA-Z0-9_]+$");
+  auto RegexExp =
+  llvm::Regex("^[a-zA-Z][a-zA-Z0-9]*_[a-zA-Z0-9][a-zA-Z0-9_]+$");
   return RegexExp.match(PropertyName);
 }
 
@@ -91,8 +92,7 @@
   if (Prefix.lower() != Prefix) {
 return false;
   }
-  auto RegexExp =
-  llvm::Regex(llvm::StringRef(validPropertyNameRegex(false)));
+  auto RegexExp = llvm::Regex(llvm::StringRef(validPropertyNameRegex(false)));
   return RegexExp.match(PropertyName.substr(Start + 1));
 }
 }  // namespace
@@ -101,13 +101,12 @@
   // this check should only be applied to ObjC sources.
   if (!getLangOpts().ObjC) return;
 
-  Finder->addMatcher(
-  objcPropertyDecl(
-  // the property name should be in Lower Camel Case like
-  // 'lowerCamelCase'
-  unless(matchesName(validPropertyNameRegex(true
-  .bind("property"),
-  this);
+  Finder->addMatcher(objcPropertyDecl(
+ // the property name should be in Lower Camel Case 
like
+ // 'lowerCamelCase'
+ unless(matchesName(validPropertyNameRegex(true
+ .bind("property"),
+ this);
 }
 
 void PropertyDeclarationCheck::check(const MatchFinder::MatchResult ) {
Index: test/clang-tidy/objc-property-declaration.m
===
--- test/clang-tidy/objc-property-declaration.m
+++ test/clang-tidy/objc-property-declaration.m
@@ -46,9 +46,10 @@
 @property(strong, nonatomic) NSString *URLStr;
 @property(assign, nonatomic) int abc_camelCase;
 @property(strong, nonatomic) NSString *abc_URL;
+@property(strong, nonatomic) NSString *opac2_sourceComponent;
 @end
 
 @interface Foo ()
 @property(assign, nonatomic) int abc_inClassExtension;
 // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: property name 
'abc_inClassExtension' not using lowerCamelCase style or not prefixed in a 
category, according to the Apple Coding Guidelines [objc-property-declaration]
 @end
\ No newline at end of file


Index: clang-tidy/objc/PropertyDeclarationCheck.cpp
===
--- clang-tidy/objc/PropertyDeclarationCheck.cpp
+++ clang-tidy/objc/PropertyDeclarationCheck.cpp
@@ -80,7 +80,8 @@
 }
 
 bool hasCategoryPropertyPrefix(llvm::StringRef PropertyName) {
-  auto RegexExp = llvm::Regex("^[a-zA-Z]+_[a-zA-Z0-9][a-zA-Z0-9_]+$");
+  auto RegexExp =
+  llvm::Regex("^[a-zA-Z][a-zA-Z0-9]*_[a-zA-Z0-9][a-zA-Z0-9_]+$");
   return RegexExp.match(PropertyName);
 }
 
@@ -91,8 +92,7 @@
   if (Prefix.lower() != Prefix) {
 return false;
   }
-  auto RegexExp =
-  llvm::Regex(llvm::StringRef(validPropertyNameRegex(false)));
+  auto RegexExp = llvm::Regex(llvm::StringRef(validPropertyNameRegex(false)));
   return RegexExp.match(PropertyName.substr(Start + 1));
 }
 }  // namespace
@@ -101,13 +101,12 @@
   // this check should only be applied to ObjC sources.
   if (!getLangOpts().ObjC) return;
 
-  Finder->addMatcher(
-  objcPropertyDecl(
-  // the property name should be in Lower Camel Case like
-  // 'lowerCamelCase'
-  unless(matchesName(validPropertyNameRegex(true
-  .bind("property"),
-  this);
+  Finder->addMatcher(objcPropertyDecl(
+ // the property name should be in Lower Camel Case like
+ // 'lowerCamelCase'
+ unless(matchesName(validPropertyNameRegex(true
+ .bind("property"),
+ this);
 }
 
 void PropertyDeclarationCheck::check(const MatchFinder::MatchResult ) {
Index: test/clang-tidy/objc-property-declaration.m
===
--- test/clang-tidy/objc-property-declaration.m
+++ test/clang-tidy/objc-property-declaration.m
@@ -46,9 +46,10 @@
 @property(strong, nonatomic) NSString *URLStr;
 @property(assign, nonatomic) int abc_camelCase;
 @property(strong, nonatomic) NSString *abc_URL;
+@property(strong, nonatomic) NSString 

[clang-tools-extra] r354485 - Update property prefix regex to allow numbers.

2019-02-20 Thread Yan Zhang via cfe-commits
Author: wizard
Date: Wed Feb 20 09:32:41 2019
New Revision: 354485

URL: http://llvm.org/viewvc/llvm-project?rev=354485=rev
Log:
Update property prefix regex to allow numbers.

Subscribers: jfb, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m

Modified: clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp?rev=354485=354484=354485=diff
==
--- clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp Wed 
Feb 20 09:32:41 2019
@@ -80,7 +80,8 @@ std::string validPropertyNameRegex(bool
 }
 
 bool hasCategoryPropertyPrefix(llvm::StringRef PropertyName) {
-  auto RegexExp = llvm::Regex("^[a-zA-Z]+_[a-zA-Z0-9][a-zA-Z0-9_]+$");
+  auto RegexExp =
+  llvm::Regex("^[a-zA-Z][a-zA-Z0-9]*_[a-zA-Z0-9][a-zA-Z0-9_]+$");
   return RegexExp.match(PropertyName);
 }
 
@@ -91,8 +92,7 @@ bool prefixedPropertyNameValid(llvm::Str
   if (Prefix.lower() != Prefix) {
 return false;
   }
-  auto RegexExp =
-  llvm::Regex(llvm::StringRef(validPropertyNameRegex(false)));
+  auto RegexExp = llvm::Regex(llvm::StringRef(validPropertyNameRegex(false)));
   return RegexExp.match(PropertyName.substr(Start + 1));
 }
 }  // namespace
@@ -101,13 +101,12 @@ void PropertyDeclarationCheck::registerM
   // this check should only be applied to ObjC sources.
   if (!getLangOpts().ObjC) return;
 
-  Finder->addMatcher(
-  objcPropertyDecl(
-  // the property name should be in Lower Camel Case like
-  // 'lowerCamelCase'
-  unless(matchesName(validPropertyNameRegex(true
-  .bind("property"),
-  this);
+  Finder->addMatcher(objcPropertyDecl(
+ // the property name should be in Lower Camel Case 
like
+ // 'lowerCamelCase'
+ unless(matchesName(validPropertyNameRegex(true
+ .bind("property"),
+ this);
 }
 
 void PropertyDeclarationCheck::check(const MatchFinder::MatchResult ) {

Modified: clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m?rev=354485=354484=354485=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m Wed Feb 
20 09:32:41 2019
@@ -46,6 +46,7 @@ typedef void *CGColorRef;
 @property(strong, nonatomic) NSString *URLStr;
 @property(assign, nonatomic) int abc_camelCase;
 @property(strong, nonatomic) NSString *abc_URL;
+@property(strong, nonatomic) NSString *opac2_sourceComponent;
 @end
 
 @interface Foo ()


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


r354482 - Fix compile error with Intel's compiler (-Werror=pedantic)

2019-02-20 Thread Gabor Marton via cfe-commits
Author: martong
Date: Wed Feb 20 08:57:41 2019
New Revision: 354482

URL: http://llvm.org/viewvc/llvm-project?rev=354482=rev
Log:
Fix compile error with Intel's compiler (-Werror=pedantic)

An extra semicolon at the end of macro invocations caused a build bot
failure for Intel's compiler when pedantic is turned on.

Modified:
cfe/trunk/unittests/AST/ASTImporterTest.cpp

Modified: cfe/trunk/unittests/AST/ASTImporterTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/ASTImporterTest.cpp?rev=354482=354481=354482=diff
==
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp (original)
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp Wed Feb 20 08:57:41 2019
@@ -4156,175 +4156,175 @@ struct RedeclChain : ASTImporterOptionSp
 
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
 RedeclChain, Function, ,
-PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition);
+PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
 RedeclChain, Class, ,
-PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition);
+PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
 RedeclChain, Variable, ,
-PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition);
+PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition)
 // FIXME Enable this test, once we import function templates chains correctly.
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
 RedeclChain, FunctionTemplate, DISABLED_,
-PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition);
+PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
 RedeclChain, ClassTemplate, ,
-PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition);
+PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
 RedeclChain, FunctionTemplateSpec, ,
-PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition);
+PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition)
 
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
-RedeclChain, Function, , DefinitionShouldBeImportedAsADefinition);
+RedeclChain, Function, , DefinitionShouldBeImportedAsADefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
-RedeclChain, Class, , DefinitionShouldBeImportedAsADefinition);
+RedeclChain, Class, , DefinitionShouldBeImportedAsADefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
-RedeclChain, Variable, , DefinitionShouldBeImportedAsADefinition);
+RedeclChain, Variable, , DefinitionShouldBeImportedAsADefinition)
 // FIXME Enable this test, once we import function templates chains correctly.
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
 RedeclChain, FunctionTemplate, DISABLED_,
-DefinitionShouldBeImportedAsADefinition);
+DefinitionShouldBeImportedAsADefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
-RedeclChain, ClassTemplate, , DefinitionShouldBeImportedAsADefinition);
+RedeclChain, ClassTemplate, , DefinitionShouldBeImportedAsADefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
 RedeclChain, FunctionTemplateSpec, ,
-DefinitionShouldBeImportedAsADefinition);
+DefinitionShouldBeImportedAsADefinition)
 
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, Function, ,
-ImportPrototypeAfterImportedPrototype);
+ImportPrototypeAfterImportedPrototype)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, Class, ,
-ImportPrototypeAfterImportedPrototype);
+ImportPrototypeAfterImportedPrototype)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, Variable, ,
-ImportPrototypeAfterImportedPrototype);
+ImportPrototypeAfterImportedPrototype)
 // FIXME Enable this test, once we import function templates chains correctly.
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, FunctionTemplate,
 DISABLED_,
-ImportPrototypeAfterImportedPrototype);
+ImportPrototypeAfterImportedPrototype)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, ClassTemplate, ,
-ImportPrototypeAfterImportedPrototype);
+ImportPrototypeAfterImportedPrototype)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, FunctionTemplateSpec, ,
-ImportPrototypeAfterImportedPrototype);
+ImportPrototypeAfterImportedPrototype)
 
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, Function, ,
-

[PATCH] D58429: [CodeGen] Enable the complex-math test for arm

2019-02-20 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354481: [CodeGen] Enable the complex-math test for arm 
(authored by phosek, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58429?vs=187524=187593#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58429/new/

https://reviews.llvm.org/D58429

Files:
  cfe/trunk/test/CodeGen/complex-math.c


Index: cfe/trunk/test/CodeGen/complex-math.c
===
--- cfe/trunk/test/CodeGen/complex-math.c
+++ cfe/trunk/test/CodeGen/complex-math.c
@@ -2,7 +2,7 @@
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple x86_64-pc-win64 -o - | FileCheck 
%s --check-prefix=X86
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple i686-unknown-unknown -o - | 
FileCheck %s --check-prefix=X86
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple powerpc-unknown-unknown -o - | 
FileCheck %s --check-prefix=PPC
-// RUN %clang_cc1 %s -O1 -emit-llvm -triple armv7-none-linux-gnueabi -o - | 
FileCheck %s --check-prefix=ARM
+// RUN: %clang_cc1 %s -O1 -emit-llvm -triple armv7-none-linux-gnueabi -o - | 
FileCheck %s --check-prefix=ARM
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple armv7-none-linux-gnueabihf -o - | 
FileCheck %s --check-prefix=ARMHF
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple thumbv7k-apple-watchos2.0 -o - 
-target-abi aapcs16 | FileCheck %s --check-prefix=ARM7K
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple aarch64-unknown-unknown 
-ffast-math -o - | FileCheck %s --check-prefix=AARCH64-FASTMATH
@@ -621,7 +621,7 @@
   // use the base AAPCS.
 
   // ARM-LABEL: @foo(
-  // ARM: call void { double, double } @__muldc3
+  // ARM: call void @__muldc3
 
   // ARMHF-LABEL: @foo(
   // ARMHF: call { double, double } @__muldc3


Index: cfe/trunk/test/CodeGen/complex-math.c
===
--- cfe/trunk/test/CodeGen/complex-math.c
+++ cfe/trunk/test/CodeGen/complex-math.c
@@ -2,7 +2,7 @@
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple x86_64-pc-win64 -o - | FileCheck %s --check-prefix=X86
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple i686-unknown-unknown -o - | FileCheck %s --check-prefix=X86
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple powerpc-unknown-unknown -o - | FileCheck %s --check-prefix=PPC
-// RUN %clang_cc1 %s -O1 -emit-llvm -triple armv7-none-linux-gnueabi -o - | FileCheck %s --check-prefix=ARM
+// RUN: %clang_cc1 %s -O1 -emit-llvm -triple armv7-none-linux-gnueabi -o - | FileCheck %s --check-prefix=ARM
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple armv7-none-linux-gnueabihf -o - | FileCheck %s --check-prefix=ARMHF
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple thumbv7k-apple-watchos2.0 -o - -target-abi aapcs16 | FileCheck %s --check-prefix=ARM7K
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple aarch64-unknown-unknown -ffast-math -o - | FileCheck %s --check-prefix=AARCH64-FASTMATH
@@ -621,7 +621,7 @@
   // use the base AAPCS.
 
   // ARM-LABEL: @foo(
-  // ARM: call void { double, double } @__muldc3
+  // ARM: call void @__muldc3
 
   // ARMHF-LABEL: @foo(
   // ARMHF: call { double, double } @__muldc3
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r354481 - [CodeGen] Enable the complex-math test for arm

2019-02-20 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Wed Feb 20 08:53:08 2019
New Revision: 354481

URL: http://llvm.org/viewvc/llvm-project?rev=354481=rev
Log:
[CodeGen] Enable the complex-math test for arm

This test wasn't running due to a missing : after the RUN statement.
Enabling this test revealed that it's actually broken.

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

Modified:
cfe/trunk/test/CodeGen/complex-math.c

Modified: cfe/trunk/test/CodeGen/complex-math.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/complex-math.c?rev=354481=354480=354481=diff
==
--- cfe/trunk/test/CodeGen/complex-math.c (original)
+++ cfe/trunk/test/CodeGen/complex-math.c Wed Feb 20 08:53:08 2019
@@ -2,7 +2,7 @@
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple x86_64-pc-win64 -o - | FileCheck 
%s --check-prefix=X86
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple i686-unknown-unknown -o - | 
FileCheck %s --check-prefix=X86
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple powerpc-unknown-unknown -o - | 
FileCheck %s --check-prefix=PPC
-// RUN %clang_cc1 %s -O1 -emit-llvm -triple armv7-none-linux-gnueabi -o - | 
FileCheck %s --check-prefix=ARM
+// RUN: %clang_cc1 %s -O1 -emit-llvm -triple armv7-none-linux-gnueabi -o - | 
FileCheck %s --check-prefix=ARM
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple armv7-none-linux-gnueabihf -o - | 
FileCheck %s --check-prefix=ARMHF
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple thumbv7k-apple-watchos2.0 -o - 
-target-abi aapcs16 | FileCheck %s --check-prefix=ARM7K
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple aarch64-unknown-unknown 
-ffast-math -o - | FileCheck %s --check-prefix=AARCH64-FASTMATH
@@ -621,7 +621,7 @@ _Complex double foo(_Complex double a, _
   // use the base AAPCS.
 
   // ARM-LABEL: @foo(
-  // ARM: call void { double, double } @__muldc3
+  // ARM: call void @__muldc3
 
   // ARMHF-LABEL: @foo(
   // ARMHF: call { double, double } @__muldc3


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


[PATCH] D58440: [clangd] Store index in '.clangd/index' instead of '.clangd-index'

2019-02-20 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

Thanks!




Comment at: clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp:75
 llvm::SmallString<128> CDBDirectory(Directory);
-llvm::sys::path::append(CDBDirectory, ".clangd-index/");
+llvm::sys::path::append(CDBDirectory, ".clangd", "index/");
 DiskShardRoot = CDBDirectory.str();

NIT: it looks like we don't need the "/" at the end of "index/"


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58440/new/

https://reviews.llvm.org/D58440



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


[PATCH] D58388: [OpenCL] Simplify LLVM IR generated for OpenCL blocks

2019-02-20 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Great! Thanks!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58388/new/

https://reviews.llvm.org/D58388



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


[PATCH] D58449: Junk: Add assert to find GCCBuiltins with constant arguments missing

2019-02-20 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm created this revision.
arsenm added a reviewer: atanasyan.
Herald added subscribers: jdoerfert, fedor.sergeev, aheejin, wdng, dschuff.

Don't bother reviewing this, I have no intention of committing this hack to 
find builtins missing immarg


https://reviews.llvm.org/D58449

Files:
  lib/Sema/SemaChecking.cpp

Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -85,6 +85,10 @@
 #include "llvm/Support/Locale.h"
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/raw_ostream.h"
+
+#include "llvm/IR/Intrinsics.h"
+#include "llvm/IR/Module.h"
+
 #include 
 #include 
 #include 
@@ -965,15 +969,178 @@
   if (Error != ASTContext::GE_None)
 ICEArguments = 0;  // Don't diagnose previously diagnosed errors.
 
-  // If any arguments are required to be ICE's, check and diagnose.
-  for (unsigned ArgNo = 0; ICEArguments != 0; ++ArgNo) {
-// Skip arguments not required to be ICE's.
-if ((ICEArguments & (1 << ArgNo)) == 0) continue;
+  static bool Once = false;
 
-llvm::APSInt Result;
-if (SemaBuiltinConstantArg(TheCall, ArgNo, Result))
-  return true;
-ICEArguments &= ~(1 << ArgNo);
+  if (!Once) {
+Once = true;
+unsigned Start = -1;
+unsigned End = -1;
+switch (Context.getTargetInfo().getTriple().getArch()) {
+case llvm::Triple::x86: {
+  Start = X86::LastTIBuiltin + 1;
+  End = X86::LastX86CommonBuiltin;
+  break;
+}
+case llvm::Triple::x86_64: {
+  Start = X86::LastTIBuiltin + 1;
+  //Start = X86::FirstX86_64Builtin;
+  End = X86::LastTSBuiltin;
+  break;
+}
+case llvm::Triple::mips:
+case llvm::Triple::mipsel:
+case llvm::Triple::mips64:
+case llvm::Triple::mips64el: {
+  Start = Mips::LastTIBuiltin + 1;
+  End = Mips::LastTSBuiltin;
+  break;
+}
+case llvm::Triple::hexagon: {
+  Start = Hexagon::LastTIBuiltin + 1;
+  End = Hexagon::LastTSBuiltin;
+  break;
+}
+case llvm::Triple::systemz: {
+  Start = SystemZ::LastTIBuiltin + 1;
+  End = SystemZ::LastTSBuiltin;
+  break;
+}
+case llvm::Triple::ppc:
+case llvm::Triple::ppc64:
+case llvm::Triple::ppc64le: {
+  Start = PPC::LastTIBuiltin + 1;
+  End = PPC::LastTSBuiltin;
+  break;
+}
+case llvm::Triple::aarch64:
+case llvm::Triple::aarch64_be: {
+  Start = AArch64::LastTIBuiltin + 1;
+  End = AArch64::LastTSBuiltin;
+  break;
+}
+case llvm::Triple::arm:
+case llvm::Triple::armeb:
+case llvm::Triple::thumb:
+case llvm::Triple::thumbeb: {
+  Start = ARM::LastTIBuiltin + 1;
+  End = ARM::LastTSBuiltin;
+  break;
+}
+case llvm::Triple::amdgcn:
+case llvm::Triple::r600: {
+  Start = AMDGPU::LastTIBuiltin + 1;
+  End = AMDGPU::LastTSBuiltin;
+  break;
+}
+case llvm::Triple::nvptx:
+case llvm::Triple::nvptx64: {
+  Start = NVPTX::LastTIBuiltin + 1;
+  End = NVPTX::LastTSBuiltin;
+  break;
+}
+case llvm::Triple::wasm32:
+case llvm::Triple::wasm64: {
+  Start = WebAssembly::LastTIBuiltin + 1;
+  End = WebAssembly::LastTSBuiltin;
+  break;
+}
+case llvm::Triple::riscv32:
+case llvm::Triple::riscv64: {
+#if 0
+  Start = RISCV::LastTIBuiltin + 1;
+  End = RISCV::LastTSBuiltin;
+#endif
+  Start = 0;
+  End = 0;
+  break;
+}
+case llvm::Triple::xcore: {
+  Start = XCore::LastTIBuiltin + 1;
+  End = XCore::LastTSBuiltin;
+  break;
+}
+case llvm::Triple::msp430:
+case llvm::Triple::sparc:
+case llvm::Triple::sparcv9:
+case llvm::Triple::sparcel:
+case llvm::Triple::spir:
+case llvm::Triple::spir64:
+  Start = 0;
+  End = 0;
+  break;
+default:
+  llvm_unreachable("todo");
+}
+
+unsigned MissingCount = 0;
+unsigned ExtraImmArg = 0;
+
+for (unsigned BuiltinID = Start; BuiltinID != End; ++BuiltinID) {
+  unsigned ICEArguments = 0;
+  ASTContext::GetBuiltinTypeError Error;
+  Context.GetBuiltinType(BuiltinID, Error, );
+
+
+  const char *Name = getASTContext().BuiltinInfo.getName(BuiltinID);
+  llvm::Intrinsic::ID IntrinsicID = llvm::Intrinsic::not_intrinsic;
+  StringRef Prefix =
+llvm::Triple::getArchTypePrefix(Context.getTargetInfo().getTriple().getArch());
+  if (!Prefix.empty()) {
+IntrinsicID = llvm::Intrinsic::getIntrinsicForGCCBuiltin(Prefix.data(), Name);
+// NOTE we don't need to perform a compatibility flag check here since the
+// intrinsics are declared in Builtins*.def via LANGBUILTIN which filter the
+// MS builtins via ALL_MS_LANGUAGES and are filtered earlier.
+if (IntrinsicID == llvm::Intrinsic::not_intrinsic)
+  IntrinsicID = llvm::Intrinsic::getIntrinsicForMSBuiltin(Prefix.data(), Name);
+  }
+
+
+  llvm::LLVMContext Ctx;
+  

[PATCH] D57914: [Driver] Allow enum SanitizerOrdinal to represent more than 64 different sanitizer checks, NFC.

2019-02-20 Thread pierre gousseau via Phabricator via cfe-commits
pgousseau added a comment.

In D57914#1404053 , @riccibruno wrote:

> Wait no, can you really define the `SanitizerMask`s in the header ? Isn't 
> that an odr violation ?


A yes I better move the definitions, thanks!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57914/new/

https://reviews.llvm.org/D57914



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


[PATCH] D58186: Sync some doc changes ClangFormatStyleOptions.rst with doc comments in `Format.h`

2019-02-20 Thread Ronald Wampler via Phabricator via cfe-commits
rdwampler added a comment.

Ping?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58186/new/

https://reviews.llvm.org/D58186



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


[PATCH] D58091: Customize warnings for missing built-in type

2019-02-20 Thread Brian Cain via Phabricator via cfe-commits
bcain accepted this revision.
bcain added a comment.
This revision is now accepted and ready to land.

I can confirm that this fix is effective at addressing the problem we 
experienced.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58091/new/

https://reviews.llvm.org/D58091



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


[PATCH] D58388: [OpenCL] Simplify LLVM IR generated for OpenCL blocks

2019-02-20 Thread Alexey Sotkin via Phabricator via cfe-commits
AlexeySotkin marked an inline comment as done.
AlexeySotkin added inline comments.



Comment at: lib/CodeGen/CGOpenCLRuntime.cpp:131
+static const BlockExpr *getBlockExpr(const Expr *E) {
+  if (auto Cast = dyn_cast(E)) {
+E = Cast->getSubExpr();

Anastasia wrote:
> Btw, does this handle the case when we assign a variable multiple time? I was 
> just wondering if we need a loop somewhere?
> 
> I.e. does something like this work now:
> 
> ```
> typedef void (^bl_t)(local void *);
> 
> bl_t a = ...;
> bl_t b = a;
> bl_t c = b;
> 
> c();
> enqueue_kernel(... c, ...);
> ```
> 
> 
You are right, we need a loop. Now it works.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58388/new/

https://reviews.llvm.org/D58388



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


[PATCH] D58388: [OpenCL] Simplify LLVM IR generated for OpenCL blocks

2019-02-20 Thread Alexey Sotkin via Phabricator via cfe-commits
AlexeySotkin updated this revision to Diff 187575.
AlexeySotkin added a comment.

Fix resolving of block invoke function in case of sequence of assignments.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58388/new/

https://reviews.llvm.org/D58388

Files:
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGOpenCLRuntime.cpp
  lib/CodeGen/CGOpenCLRuntime.h
  test/CodeGenOpenCL/blocks.cl
  test/CodeGenOpenCL/cl20-device-side-enqueue.cl

Index: test/CodeGenOpenCL/cl20-device-side-enqueue.cl
===
--- test/CodeGenOpenCL/cl20-device-side-enqueue.cl
+++ test/CodeGenOpenCL/cl20-device-side-enqueue.cl
@@ -312,9 +312,7 @@
   };
 
   // Uses global block literal [[BLG8]] and invoke function [[INVG8]].
-  // COMMON: [[r1:%.*]] = load i8 addrspace(4)*, i8 addrspace(4)* addrspace(4)* getelementptr inbounds (%struct.__opencl_block_literal_generic, %struct.__opencl_block_literal_generic addrspace(4)* addrspacecast (%struct.__opencl_block_literal_generic addrspace(1)* bitcast ({ i32, i32, i8 addrspace(4)* } addrspace(1)* [[BLG8]] to %struct.__opencl_block_literal_generic addrspace(1)*) to %struct.__opencl_block_literal_generic addrspace(4)*), i32 0, i32 2)
-  // COMMON: [[r2:%.*]] = addrspacecast i8 addrspace(4)* [[r1]] to void (i8 addrspace(4)*)*
-  // COMMON: call spir_func void [[r2]](i8 addrspace(4)* addrspacecast (i8 addrspace(1)* bitcast ({ i32, i32, i8 addrspace(4)* } addrspace(1)* [[BLG8]] to i8 addrspace(1)*) to i8 addrspace(4)*))
+  // COMMON: call spir_func void @__device_side_enqueue_block_invoke_11(i8 addrspace(4)* addrspacecast (i8 addrspace(1)* bitcast ({ i32, i32, i8 addrspace(4)* } addrspace(1)* [[BLG8]] to i8 addrspace(1)*) to i8 addrspace(4)*))
   block_A();
 
   // Emits global block literal [[BLG8]] and block kernel [[INVGK8]]. [[INVGK8]] calls [[INVG8]].
@@ -333,15 +331,35 @@
   unsigned size = get_kernel_work_group_size(block_A);
 
   // Uses global block literal [[BLG8]] and invoke function [[INVG8]]. Make sure no redundant block literal and invoke functions are emitted.
-  // COMMON: [[r1:%.*]] = load i8 addrspace(4)*, i8 addrspace(4)* addrspace(4)* getelementptr inbounds (%struct.__opencl_block_literal_generic, %struct.__opencl_block_literal_generic addrspace(4)* addrspacecast (%struct.__opencl_block_literal_generic addrspace(1)* bitcast ({ i32, i32, i8 addrspace(4)* } addrspace(1)* [[BLG8]] to %struct.__opencl_block_literal_generic addrspace(1)*) to %struct.__opencl_block_literal_generic addrspace(4)*), i32 0, i32 2)
-  // COMMON: [[r2:%.*]] = addrspacecast i8 addrspace(4)* [[r1]] to void (i8 addrspace(4)*)*
-  // COMMON: call spir_func void [[r2]](i8 addrspace(4)* addrspacecast (i8 addrspace(1)* bitcast ({ i32, i32, i8 addrspace(4)* } addrspace(1)* [[BLG8]] to i8 addrspace(1)*) to i8 addrspace(4)*))
+  // COMMON: call spir_func void @__device_side_enqueue_block_invoke_11(i8 addrspace(4)* addrspacecast (i8 addrspace(1)* bitcast ({ i32, i32, i8 addrspace(4)* } addrspace(1)* [[BLG8]] to i8 addrspace(1)*) to i8 addrspace(4)*))
   block_A();
 
+  // Make sure that block invoke function is resolved correctly after sequence of assignements.
+  // COMMON: store %struct.__opencl_block_literal_generic addrspace(4)*
+  // COMMON-SAME: addrspacecast (%struct.__opencl_block_literal_generic addrspace(1)*
+  // COMMON-SAME: bitcast ({ i32, i32, i8 addrspace(4)* } addrspace(1)* [[BL_GLOBAL]] to %struct.__opencl_block_literal_generic addrspace(1)*)
+  // COMMON-SAME: to %struct.__opencl_block_literal_generic addrspace(4)*),
+  // COMMON-SAME: %struct.__opencl_block_literal_generic addrspace(4)** %b1,
+  bl_t b1 = block_G;
+  // COMMON: store %struct.__opencl_block_literal_generic addrspace(4)*
+  // COMMON-SAME: addrspacecast (%struct.__opencl_block_literal_generic addrspace(1)*
+  // COMMON-SAME: bitcast ({ i32, i32, i8 addrspace(4)* } addrspace(1)* [[BL_GLOBAL]] to %struct.__opencl_block_literal_generic addrspace(1)*)
+  // COMMON-SAME: to %struct.__opencl_block_literal_generic addrspace(4)*),
+  // COMMON-SAME: %struct.__opencl_block_literal_generic addrspace(4)** %b2,
+  bl_t b2 = b1;
+  // COMMON: call spir_func void @block_G_block_invoke(i8 addrspace(4)* addrspacecast (i8 addrspace(1)*
+  // COMMON-SAME: bitcast ({ i32, i32, i8 addrspace(4)* } addrspace(1)* [[BL_GLOBAL]] to i8 addrspace(1)*)
+  // COOMON-SAME: to i8 addrspace(4)*), i8 addrspace(3)* null)
+  b2(0);
+  // Uses global block literal [[BL_GLOBAL]] and block kernel [[INV_G_K]]. [[INV_G_K]] calls [[INV_G]].
+  // COMMON: call i32 @__get_kernel_preferred_work_group_size_multiple_impl(
+  // COMMON-SAME: i8 addrspace(4)* addrspacecast (i8* bitcast ({{.*}} [[INV_G_K:[^ ]+_kernel]] to i8*) to i8 addrspace(4)*),
+  // COMMON-SAME: i8 addrspace(4)* addrspacecast (i8 addrspace(1)* bitcast ({ i32, i32, i8 addrspace(4)* } addrspace(1)* [[BL_GLOBAL]] to i8 addrspace(1)*) to i8 addrspace(4)*))
+  size = get_kernel_preferred_work_group_size_multiple(b2);
+
   void (^block_C)(void) = ^{
 

[PATCH] D58346: [Sema] Change addr space diagnostics in casts to follow C++ style

2019-02-20 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 187573.
Anastasia added a comment.

Added a CodeGen test to cover address space of reference in `reinterpret_cast`.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58346/new/

https://reviews.llvm.org/D58346

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaCast.cpp
  test/CodeGenOpenCLCXX/address-space-castoperators.cpp
  test/SemaCXX/address-space-conversion.cpp
  test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
  test/SemaOpenCL/address-spaces.cl

Index: test/SemaOpenCL/address-spaces.cl
===
--- test/SemaOpenCL/address-spaces.cl
+++ test/SemaOpenCL/address-spaces.cl
@@ -26,24 +26,96 @@
 }
 
 void explicit_cast(__global int *g, __local int *l, __constant int *c, __private int *p, const __constant int *cc) {
-  g = (__global int *)l;  // expected-error {{casting '__local int *' to type '__global int *' changes address space of pointer}}
-  g = (__global int *)c;  // expected-error {{casting '__constant int *' to type '__global int *' changes address space of pointer}}
-  g = (__global int *)cc; // expected-error {{casting 'const __constant int *' to type '__global int *' changes address space of pointer}}
-  g = (__global int *)p;  // expected-error {{casting 'int *' to type '__global int *' changes address space of pointer}}
-
-  l = (__local int *)g;  // expected-error {{casting '__global int *' to type '__local int *' changes address space of pointer}}
-  l = (__local int *)c;  // expected-error {{casting '__constant int *' to type '__local int *' changes address space of pointer}}
-  l = (__local int *)cc; // expected-error {{casting 'const __constant int *' to type '__local int *' changes address space of pointer}}
-  l = (__local int *)p;  // expected-error {{casting 'int *' to type '__local int *' changes address space of pointer}}
-
-  c = (__constant int *)g; // expected-error {{casting '__global int *' to type '__constant int *' changes address space of pointer}}
-  c = (__constant int *)l; // expected-error {{casting '__local int *' to type '__constant int *' changes address space of pointer}}
-  c = (__constant int *)p; // expected-error {{casting 'int *' to type '__constant int *' changes address space of pointer}}
-
-  p = (__private int *)g;  // expected-error {{casting '__global int *' to type 'int *' changes address space of pointer}}
-  p = (__private int *)l;  // expected-error {{casting '__local int *' to type 'int *' changes address space of pointer}}
-  p = (__private int *)c;  // expected-error {{casting '__constant int *' to type 'int *' changes address space of pointer}}
-  p = (__private int *)cc; // expected-error {{casting 'const __constant int *' to type 'int *' changes address space of pointer}}
+  g = (__global int *)l;
+#if !__OPENCL_CPP_VERSION__
+// expected-error@-2 {{casting '__local int *' to type '__global int *' changes address space of pointer}}
+#else
+// expected-error@-4 {{C-style cast from '__local int *' to '__global int *' converts between mismatching address spaces}}
+#endif
+  g = (__global int *)c;
+#if !__OPENCL_CPP_VERSION__
+// expected-error@-2 {{casting '__constant int *' to type '__global int *' changes address space of pointer}}
+#else
+// expected-error@-4 {{C-style cast from '__constant int *' to '__global int *' converts between mismatching address spaces}}
+#endif
+  g = (__global int *)cc;
+#if !__OPENCL_CPP_VERSION__
+// expected-error@-2 {{casting 'const __constant int *' to type '__global int *' changes address space of pointer}}
+#else
+// expected-error@-4 {{C-style cast from 'const __constant int *' to '__global int *' converts between mismatching address spaces}}
+#endif
+  g = (__global int *)p;
+#if !__OPENCL_CPP_VERSION__
+// expected-error@-2 {{casting 'int *' to type '__global int *' changes address space of pointer}}
+#else
+// expected-error@-4 {{C-style cast from 'int *' to '__global int *' converts between mismatching address spaces}}
+#endif
+  l = (__local int *)g;
+#if !__OPENCL_CPP_VERSION__
+// expected-error@-2 {{casting '__global int *' to type '__local int *' changes address space of pointer}}
+#else
+// expected-error@-4 {{C-style cast from '__global int *' to '__local int *' converts between mismatching address spaces}}
+#endif
+  l = (__local int *)c;
+#if !__OPENCL_CPP_VERSION__
+// expected-error@-2 {{casting '__constant int *' to type '__local int *' changes address space of pointer}}
+#else
+// expected-error@-4 {{C-style cast from '__constant int *' to '__local int *' converts between mismatching address spaces}}
+#endif
+  l = (__local int *)cc;
+#if !__OPENCL_CPP_VERSION__
+// expected-error@-2 {{casting 'const __constant int *' to type '__local int *' changes address space of pointer}}
+#else
+// expected-error@-4 {{C-style cast from 'const __constant int *' to '__local int *' converts between mismatching address spaces}}
+#endif
+  l = (__local int *)p;
+#if 

[PATCH] D58447: [clangd] Fix a crash in Selection

2019-02-20 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58447/new/

https://reviews.llvm.org/D58447



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


[PATCH] D57914: [Driver] Allow enum SanitizerOrdinal to represent more than 64 different sanitizer checks, NFC.

2019-02-20 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno requested changes to this revision.
riccibruno added a comment.
This revision now requires changes to proceed.

Wait no, can you really define the `SanitizerMask`s in the header ? Isn't that 
an odr violation ?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57914/new/

https://reviews.llvm.org/D57914



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


[PATCH] D58447: [clangd] Fix a crash in Selection

2019-02-20 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 187569.
ilya-biryukov added a comment.

- Fix a syntax error in the test


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58447/new/

https://reviews.llvm.org/D58447

Files:
  clang-tools-extra/clangd/Selection.cpp
  clang-tools-extra/unittests/clangd/SelectionTests.cpp


Index: clang-tools-extra/unittests/clangd/SelectionTests.cpp
===
--- clang-tools-extra/unittests/clangd/SelectionTests.cpp
+++ clang-tools-extra/unittests/clangd/SelectionTests.cpp
@@ -232,6 +232,11 @@
   }
 }
   )cpp",
+  R"cpp(
+  template 
+  struct unique_ptr {};
+  void foo(^$C[[unique_ptr>]]^ a) {}
+  )cpp",
   };
   for (const char *C : Cases) {
 Annotations Test(C);
Index: clang-tools-extra/clangd/Selection.cpp
===
--- clang-tools-extra/clangd/Selection.cpp
+++ clang-tools-extra/clangd/Selection.cpp
@@ -198,11 +198,10 @@
   auto E = SM.getDecomposedLoc(R.getEnd());
   if (B.first != SelFile || E.first != SelFile)
 continue;
-  assert(R.isTokenRange());
   // Try to cover up to the next token, spaces between children don't 
count.
   if (auto Tok = Lexer::findNextToken(R.getEnd(), SM, LangOpts))
 E.second = SM.getFileOffset(Tok->getLocation());
-  else
+  else if (R.isTokenRange())
 E.second += Lexer::MeasureTokenLength(R.getEnd(), SM, LangOpts);
   ChildRanges.push_back({B.second, E.second});
 }


Index: clang-tools-extra/unittests/clangd/SelectionTests.cpp
===
--- clang-tools-extra/unittests/clangd/SelectionTests.cpp
+++ clang-tools-extra/unittests/clangd/SelectionTests.cpp
@@ -232,6 +232,11 @@
   }
 }
   )cpp",
+  R"cpp(
+  template 
+  struct unique_ptr {};
+  void foo(^$C[[unique_ptr>]]^ a) {}
+  )cpp",
   };
   for (const char *C : Cases) {
 Annotations Test(C);
Index: clang-tools-extra/clangd/Selection.cpp
===
--- clang-tools-extra/clangd/Selection.cpp
+++ clang-tools-extra/clangd/Selection.cpp
@@ -198,11 +198,10 @@
   auto E = SM.getDecomposedLoc(R.getEnd());
   if (B.first != SelFile || E.first != SelFile)
 continue;
-  assert(R.isTokenRange());
   // Try to cover up to the next token, spaces between children don't count.
   if (auto Tok = Lexer::findNextToken(R.getEnd(), SM, LangOpts))
 E.second = SM.getFileOffset(Tok->getLocation());
-  else
+  else if (R.isTokenRange())
 E.second += Lexer::MeasureTokenLength(R.getEnd(), SM, LangOpts);
   ChildRanges.push_back({B.second, E.second});
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >