[PATCH] D62476: [clangd] Support offsets for parameters in signatureHelp

2019-06-05 Thread Mikael Holmén via Phabricator via cfe-commits
uabelho added inline comments.



Comment at: clang-tools-extra/trunk/clangd/CodeComplete.cpp:925
+// FIXME: this should only be set on CK_CurrentParameter.
+Signal.ContainsActiveParameter = true;
+  }

Hi!

gcc (7.4) warns on this code:

```
error: parameter 'Signal' set but not used [-Werror=unused-but-set-parameter]
  SignatureQualitySignals Signal) const {
  ^~
```
Should Signal be a reference? Or is it specifically not a reference right now 
due to the FIXME?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D62476



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


Re: r362551 - Convert MemberExpr creation and serialization to work the same way as

2019-06-05 Thread Martin Storsjö via cfe-commits
This broke building of Qt when using PCH. Selfcontained repro is a bit 
hard to make though...


// Martin

On Tue, 4 Jun 2019, Richard Smith via cfe-commits wrote:


Author: rsmith
Date: Tue Jun  4 14:29:28 2019
New Revision: 362551

URL: http://llvm.org/viewvc/llvm-project?rev=362551&view=rev
Log:
Convert MemberExpr creation and serialization to work the same way as
most / all other Expr subclasses.

Modified:
   cfe/trunk/include/clang/AST/Expr.h
   cfe/trunk/include/clang/AST/Stmt.h
   cfe/trunk/lib/AST/DeclBase.cpp
   cfe/trunk/lib/AST/Expr.cpp
   cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp
   cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp
   cfe/trunk/lib/Sema/SemaExprCXX.cpp
   cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
   cfe/trunk/lib/Serialization/ASTWriterStmt.cpp

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=362551&r1=362550&r2=362551&view=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Tue Jun  4 14:29:28 2019
@@ -2735,6 +2735,7 @@ class MemberExpr final
ASTTemplateKWAndArgsInfo,
TemplateArgumentLoc> {
  friend class ASTReader;
+  friend class ASTStmtReader;
  friend class ASTStmtWriter;
  friend TrailingObjects;

@@ -2769,49 +2770,38 @@ class MemberExpr final
return MemberExprBits.HasTemplateKWAndArgsInfo;
  }

-public:
-  MemberExpr(Expr *base, bool isarrow, SourceLocation operatorloc,
- ValueDecl *memberdecl, const DeclarationNameInfo &NameInfo,
- QualType ty, ExprValueKind VK, ExprObjectKind OK)
-  : Expr(MemberExprClass, ty, VK, OK, base->isTypeDependent(),
- base->isValueDependent(), base->isInstantiationDependent(),
- base->containsUnexpandedParameterPack()),
-Base(base), MemberDecl(memberdecl), MemberDNLoc(NameInfo.getInfo()),
-MemberLoc(NameInfo.getLoc()) {
-assert(memberdecl->getDeclName() == NameInfo.getName());
-MemberExprBits.IsArrow = isarrow;
-MemberExprBits.HasQualifierOrFoundDecl = false;
-MemberExprBits.HasTemplateKWAndArgsInfo = false;
-MemberExprBits.HadMultipleCandidates = false;
-MemberExprBits.OperatorLoc = operatorloc;
-  }
-
-  // NOTE: this constructor should be used only when it is known that
-  // the member name can not provide additional syntactic info
-  // (i.e., source locations for C++ operator names or type source info
-  // for constructors, destructors and conversion operators).
-  MemberExpr(Expr *base, bool isarrow, SourceLocation operatorloc,
- ValueDecl *memberdecl, SourceLocation l, QualType ty,
- ExprValueKind VK, ExprObjectKind OK)
-  : Expr(MemberExprClass, ty, VK, OK, base->isTypeDependent(),
- base->isValueDependent(), base->isInstantiationDependent(),
- base->containsUnexpandedParameterPack()),
-Base(base), MemberDecl(memberdecl), MemberDNLoc(), MemberLoc(l) {
-MemberExprBits.IsArrow = isarrow;
-MemberExprBits.HasQualifierOrFoundDecl = false;
-MemberExprBits.HasTemplateKWAndArgsInfo = false;
-MemberExprBits.HadMultipleCandidates = false;
-MemberExprBits.OperatorLoc = operatorloc;
-  }
+  MemberExpr(Expr *Base, bool IsArrow, SourceLocation OperatorLoc,
+ ValueDecl *MemberDecl, const DeclarationNameInfo &NameInfo,
+ QualType T, ExprValueKind VK, ExprObjectKind OK);
+  MemberExpr(EmptyShell Empty)
+  : Expr(MemberExprClass, Empty), Base(), MemberDecl() {}

-  static MemberExpr *Create(const ASTContext &C, Expr *base, bool isarrow,
+public:
+  static MemberExpr *Create(const ASTContext &C, Expr *Base, bool IsArrow,
SourceLocation OperatorLoc,
NestedNameSpecifierLoc QualifierLoc,
-SourceLocation TemplateKWLoc, ValueDecl 
*memberdecl,
-DeclAccessPair founddecl,
+SourceLocation TemplateKWLoc, ValueDecl 
*MemberDecl,
+DeclAccessPair FoundDecl,
DeclarationNameInfo MemberNameInfo,
-const TemplateArgumentListInfo *targs, QualType ty,
-ExprValueKind VK, ExprObjectKind OK);
+const TemplateArgumentListInfo *TemplateArgs,
+QualType T, ExprValueKind VK, ExprObjectKind OK);
+
+  /// Create an implicit MemberExpr, with no location, qualifier, template
+  /// arguments, and so on.
+  static MemberExpr *CreateImplicit(const ASTContext &C, Expr *Base,
+bool IsArrow, ValueDecl *MemberDecl,
+QualType T, ExprValueKind VK,
+ExprObjectKind OK) {
+return Create(C, Base, IsArro

r362587 - [clang] [test] Add a (xfailing) test for PR41027

2019-06-05 Thread Michal Gorny via cfe-commits
Author: mgorny
Date: Wed Jun  5 01:21:42 2019
New Revision: 362587

URL: http://llvm.org/viewvc/llvm-project?rev=362587&view=rev
Log:
[clang] [test] Add a (xfailing) test for PR41027

Add a test for tracking PR41027 (8.0 regression breaking assembly code
relying on __builtin_constant_p() to identify compile-time constants).
Mark it as expected to fail everywhere.

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

Added:
cfe/trunk/test/Sema/pr41027.c

Added: cfe/trunk/test/Sema/pr41027.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/pr41027.c?rev=362587&view=auto
==
--- cfe/trunk/test/Sema/pr41027.c (added)
+++ cfe/trunk/test/Sema/pr41027.c Wed Jun  5 01:21:42 2019
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple x86_64 -fsyntax-only %s
+// XFAIL: *
+
+inline void pr41027(unsigned a, unsigned b) {
+  if (__builtin_constant_p(a)) {
+__asm__ volatile("outl %0,%w1" : : "a"(b), "n"(a));
+  } else {
+__asm__ volatile("outl %0,%w1" : : "a"(b), "d"(a));
+  }
+}


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


[PATCH] D60728: [clang] [test] Add a (xfailing) test for PR41027

2019-06-05 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL362587: [clang] [test] Add a (xfailing) test for PR41027 
(authored by mgorny, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D60728?vs=195518&id=203097#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D60728

Files:
  cfe/trunk/test/Sema/pr41027.c


Index: cfe/trunk/test/Sema/pr41027.c
===
--- cfe/trunk/test/Sema/pr41027.c
+++ cfe/trunk/test/Sema/pr41027.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple x86_64 -fsyntax-only %s
+// XFAIL: *
+
+inline void pr41027(unsigned a, unsigned b) {
+  if (__builtin_constant_p(a)) {
+__asm__ volatile("outl %0,%w1" : : "a"(b), "n"(a));
+  } else {
+__asm__ volatile("outl %0,%w1" : : "a"(b), "d"(a));
+  }
+}


Index: cfe/trunk/test/Sema/pr41027.c
===
--- cfe/trunk/test/Sema/pr41027.c
+++ cfe/trunk/test/Sema/pr41027.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple x86_64 -fsyntax-only %s
+// XFAIL: *
+
+inline void pr41027(unsigned a, unsigned b) {
+  if (__builtin_constant_p(a)) {
+__asm__ volatile("outl %0,%w1" : : "a"(b), "n"(a));
+  } else {
+__asm__ volatile("outl %0,%w1" : : "a"(b), "d"(a));
+  }
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62885: [analyzer] Add werror flag for analyzer warnings

2019-06-05 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

The only problem I see with this approach is that it is an all or nothing thing 
at the moment. Most of the checks in CSA can have false positives and people 
usually do not want to fail a build due to a false positive finding. This would 
force the users to do two separate passes with the static analyzer, one with 
the checks as errors enabled and one with the rest of the checks. The former 
run should not include any path sensitive checks as they are never free of 
false positives (due to the infeasible path problem).


Repository:
  rC Clang

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

https://reviews.llvm.org/D62885



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


[PATCH] D62556: [analyzer] NFC: CallDescription: Implement describing C library functions.

2019-06-05 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.
This revision is now accepted and ready to land.

Once Aleksei's comments are resolved it is good to go. My comments are notes 
and not requests.




Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:1052
+  /// number of arguments.
+  CDF_MaybeBuiltin = 1 << 0,
+};

I wonder if this is the right name. Do checker authors know the relationship 
between a standard library function and builtins? Maybe something like 
CDF_IsCStandardLibFunc would be more prescriptive when to set this? Or do we 
have non standard library builtins that we might want to match using this 
facility? The comment above is great, I just wonder if checker authors will 
read that. In case it does show up in the doxygen feel free to leave the name 
as is.




Comment at: clang/lib/StaticAnalyzer/Core/CallEvent.cpp:368
+  if (CD.Flags & CDF_MaybeBuiltin) {
+return CheckerContext::isCLibraryFunction(FD, CD.getFunctionName()) &&
+   (CD.RequiredArgs == CallDescription::NoArgRequirement ||

In case this happens to be a performance problem we could cache the builtin id 
in the future. This is just a note, do not need to optimize this prematurely.


Repository:
  rC Clang

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

https://reviews.llvm.org/D62556



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


[PATCH] D62557: [analyzer] Modernize CStringChecker to use CallDescriptions.

2019-06-05 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.

Nice one :)


Repository:
  rC Clang

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

https://reviews.llvm.org/D62557



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


[PATCH] D62441: [analyzer] NFC: Introduce a convenient CallDescriptionMap class.

2019-06-05 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun requested changes to this revision.
xazax.hun added inline comments.
This revision now requires changes to proceed.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:1088
+  // descriptions (eg., the ones for C functions that just match the name).
+  const std::vector> LinearMap;
+

Will the move constructor work as intended with const members?



Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:1097
+  // we don't do redundant copies.
+  CallDescriptionMap(const CallDescriptionMap &) = delete;
+

I think in this case copy assignment should also be deleted. Or is it deleted 
automatically in this case?


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

https://reviews.llvm.org/D62441



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


[PATCH] D62619: [analyzer][Dominators] Add a control dependency tree builder + a new debug checker

2019-06-05 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

I did not check the algorithm as you planned changes to that. I only did a 
quick review of the interface which might also be rendered obsolete once you 
update this patch.




Comment at: clang/include/clang/Analysis/Analyses/Dominators.h:191
+
+  CFGDomTree &getCFGDomTree() { return DomTree; }
+  const CFGDomTree &getCFGDomTree() const { return DomTree; }

Is it sensible to have a non-const reference to the DomTree? Why would the user 
want to modify this? I think do not really do transformations on the CFG once 
it is built.



Comment at: clang/include/clang/Analysis/Analyses/Dominators.h:193
+  const CFGDomTree &getCFGDomTree() const { return DomTree; }
+  CFGPostDomTree &getCFGPostDomTree() { return PostDomTree; }
+  const CFGPostDomTree &getCFGPostDomTree() const { return PostDomTree; }

Same as above.


Repository:
  rC Clang

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

https://reviews.llvm.org/D62619



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


[PATCH] D62893: [Analyzer] Iterator Checkers - Make range errors and invalidated access fatal

2019-06-05 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware created this revision.
baloghadamsoftware added reviewers: NoQ, Szelethus.
baloghadamsoftware added a project: clang.
Herald added subscribers: Charusso, gamesh411, donat.nagy, mikhail.ramalho, 
a.sidorin, rnkovacs, szepet, xazax.hun, whisperity.

Range errors (dereferencing or incrementing the past-the-end iterator or 
decrementing the iterator of the first element of the range) and access of 
invalidated iterators lead to undefined behavior. There is no point to continue 
the analysis after such an error on the same execution path, but terminate it 
by a sink node (fatal error). This also improves the performance and helps 
avoiding double reports (e.g. in case of nested iterators).


Repository:
  rC Clang

https://reviews.llvm.org/D62893

Files:
  lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
  test/Analysis/Inputs/system-header-simulator-cxx.h
  test/Analysis/diagnostics/explicit-suppression.cpp
  test/Analysis/invalidated-iterator.cpp

Index: test/Analysis/invalidated-iterator.cpp
===
--- test/Analysis/invalidated-iterator.cpp
+++ test/Analysis/invalidated-iterator.cpp
@@ -3,397 +3,759 @@
 
 #include "Inputs/system-header-simulator-cxx.h"
 
-void bad_copy_assign_operator_list1(std::list &L1,
+void bad_copy_assign_operator1_list(std::list &L1,
 const std::list &L2) {
   auto i0 = L1.cbegin();
   L1 = L2;
   *i0; // expected-warning{{Invalidated iterator accessed}}
 }
 
-void bad_copy_assign_operator_vector1(std::vector &V1,
+void bad_copy_assign_operator1_vector(std::vector &V1,
   const std::vector &V2) {
   auto i0 = V1.cbegin();
   V1 = V2;
   *i0; // expected-warning{{Invalidated iterator accessed}}
 }
 
-void bad_copy_assign_operator_deque1(std::deque &D1,
+void bad_copy_assign_operator1_deque(std::deque &D1,
  const std::deque &D2) {
   auto i0 = D1.cbegin();
   D1 = D2;
   *i0; // expected-warning{{Invalidated iterator accessed}}
 }
 
-void bad_copy_assign_operator_forward_list1(std::forward_list &FL1,
+void bad_copy_assign_operator1_forward_list(std::forward_list &FL1,
 const std::forward_list &FL2) {
   auto i0 = FL1.cbegin();
   FL1 = FL2;
   *i0; // expected-warning{{Invalidated iterator accessed}}
 }
 
-void bad_assign_list1(std::list &L, int n) {
+void bad_assign1_list(std::list &L, int n) {
   auto i0 = L.cbegin();
   L.assign(10, n);
   *i0; // expected-warning{{Invalidated iterator accessed}}
 }
 
-void bad_assign_vector1(std::vector &V, int n) {
+void bad_assign1_vector(std::vector &V, int n) {
   auto i0 = V.cbegin();
   V.assign(10, n);
   *i0; // expected-warning{{Invalidated iterator accessed}}
 }
 
-void bad_assign_deque1(std::deque &D, int n) {
+void bad_assign1_deque(std::deque &D, int n) {
   auto i0 = D.cbegin();
   D.assign(10, n);
   *i0; // expected-warning{{Invalidated iterator accessed}}
 }
 
-void bad_assign_forward_list1(std::forward_list &FL, int n) {
+void bad_assign1_forward_list(std::forward_list &FL, int n) {
   auto i0 = FL.cbegin();
   FL.assign(10, n);
   *i0; // expected-warning{{Invalidated iterator accessed}}
 }
 
-void good_clear_list1(std::list &L) {
+void good_clear1_list(std::list &L) {
   auto i0 = L.cend();
   L.clear();
   --i0; // no-warning
 }
 
-void bad_clear_list1(std::list &L) {
+void bad_clear1_list(std::list &L) {
   auto i0 = L.cbegin(), i1 = L.cend();
   L.clear();
   *i0; // expected-warning{{Invalidated iterator accessed}}
 }
 
-void bad_clear_vector1(std::vector &V) {
+void bad_clear1_vector(std::vector &V) {
   auto i0 = V.cbegin(), i1 = V.cend();
   V.clear();
   *i0; // expected-warning{{Invalidated iterator accessed}}
+}
+
+void bad_clear1_vector_decr(std::vector &V) {
+  auto i0 = V.cbegin(), i1 = V.cend();
+  V.clear();
   --i1; // expected-warning{{Invalidated iterator accessed}}
 }
 
-void bad_clear_deque1(std::deque &D) {
+void bad_clear1_deque(std::deque &D) {
   auto i0 = D.cbegin(), i1 = D.cend();
   D.clear();
   *i0; // expected-warning{{Invalidated iterator accessed}}
+}
+
+void bad_clear1_deque_decr(std::deque &D) {
+  auto i0 = D.cbegin(), i1 = D.cend();
+  D.clear();
   --i1; // expected-warning{{Invalidated iterator accessed}}
 }
 
-void good_push_back_list1(std::list &L, int n) {
+void good_push_back1_list(std::list &L, int n) {
   auto i0 = L.cbegin(), i1 = L.cend();
   L.push_back(n);
   *i0; // no-warning
   --i1; // no-warning
 }
 
-void good_push_back_vector1(std::vector &V, int n) {
+void good_push_back1_vector(std::vector &V, int n) {
   auto i0 = V.cbegin(), i1 = V.cend();
   V.push_back(n);
   *i0; // no-warning
 }
 
-void bad_push_back_vector1(std::vector &V, int n) {
+void bad_push_back1_vector(std::vector &V, int n) {
   auto i0 = V.cbegin(), i1 = V.cend();
   V.push_back(n);
   --i1; // expected-warning{{Invalidated iterator accessed}}
 }
 
-void bad_push_back_deque1(std::d

[PATCH] D62893: [Analyzer] Iterator Checkers - Make range errors and invalidated access fatal

2019-06-05 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

I left errors caused by mismatched iterators non-fatal for now. This is 
debatable because passing a function expecting a range iterators for two 
different containers or applying a container modifier using a mismatched 
iterator also leads to undefined behavior. However, comparing two iterators of 
different containers always returns false thus it is non-fatal. Maybe we should 
separate these two cases and report the first one as fatal, the second one as 
non-fatal errors.


Repository:
  rC Clang

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

https://reviews.llvm.org/D62893



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


[PATCH] D62611: [analyzer][Dominators] Add unittests

2019-06-05 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

Oh, I realized later that code I commented on were only moved from somewhere 
else. If you feel like tackling these comments feel free to do so in a separate 
patch so this one stays clean (no changes to moved code).




Comment at: clang/unittests/Analysis/CFGBuilder.h:18
+public:
+  enum Status {
+ToolFailed,

Is it actually sensible to write tests where the tool failed? I can imagine 
these status codes being helpful for debugging but they has little to do with 
the tests. I wonder if we actually need all these or a nullable pointer as a 
result is sufficient.



Comment at: clang/unittests/Analysis/CFGBuilder.h:54
+
+inline BuildResult BuildCFG(const char *Code) {
+  CFGCallback Callback;

Do you expect the code to only contain one function? If so, you should enforce 
it.



Comment at: clang/unittests/Analysis/CFGBuilder.h:65
+return BuildResult::ToolFailed;
+  return std::move(Callback.TheBuildResult);
+}

Do you need the std::move here?


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

https://reviews.llvm.org/D62611



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


[PATCH] D62895: [Analyzer] Iterator Checkers - Check and simulate `std::advance`, `std::prev` and `std::next`

2019-06-05 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware created this revision.
baloghadamsoftware added reviewers: NoQ, Szelethus.
baloghadamsoftware added a project: clang.
Herald added subscribers: Charusso, gamesh411, donat.nagy, mikhail.ramalho, 
a.sidorin, rnkovacs, szepet, xazax.hun, whisperity.
baloghadamsoftware added a parent revision: D62893: [Analyzer] Iterator 
Checkers - Make range errors and invalidated access fatal.

In case of invoking `std::advance`, `std::prev` and `std::next` range errors 
should be reported in the invoker and not inside the STL implementation code. 
Another problem is if the analyzer budget runs out just at the point these 
functions are invoked. This results in strange behavior such as 
`std::prev(v.end())` equals `v.end()`. To prevent this simulate these functions 
if they were not inlined.


Repository:
  rC Clang

https://reviews.llvm.org/D62895

Files:
  lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
  test/Analysis/Inputs/system-header-simulator-cxx.h
  test/Analysis/iterator-range.cpp

Index: test/Analysis/iterator-range.cpp
===
--- test/Analysis/iterator-range.cpp
+++ test/Analysis/iterator-range.cpp
@@ -116,6 +116,17 @@
   }
 }
 
+void good_advance(std::vector &vec) {
+  auto i = vec.end();
+  std::advance(i, -1);
+  *i; // no-warning
+}
+
+void good_prev(std::vector &vec) {
+  auto i = vec.end();
+  *std::prev(i); // no-warning
+}
+
 void good_push_back(std::list &L, int n) {
   auto i0 = --L.cend();
   L.push_back(n);
@@ -195,11 +206,31 @@
   --i0; // no-warning
 }
 
+void good_decr_end_advance(const std::list &L) {
+  auto i0 = L.end();
+  std::advance(i0, -1); // no-warning
+}
+
+void good_decr_end_prev(const std::list &L) {
+  auto i0 = L.end();
+  auto i1 = std::prev(i0); // no-warning
+}
+
 void bad_incr_end(const std::list &L) {
   auto i0 = L.end();
   ++i0;  // expected-warning{{Iterator incremented behind the past-the-end iterator}}
 }
 
+void bad_decr_end_advance(const std::list &L) {
+  auto i0 = L.end();
+  std::advance(i0, 1);  // expected-warning{{Iterator incremented behind the past-the-end }}
+}
+
+void bad_decr_end_next(const std::list &L) {
+  auto i0 = L.end();
+  auto i1 = std::next(i0);  // expected-warning{{Iterator incremented behind the past-the-end }}
+}
+
 struct simple_iterator_base {
   simple_iterator_base();
   simple_iterator_base(const simple_iterator_base& rhs);
Index: test/Analysis/Inputs/system-header-simulator-cxx.h
===
--- test/Analysis/Inputs/system-header-simulator-cxx.h
+++ test/Analysis/Inputs/system-header-simulator-cxx.h
@@ -768,6 +768,15 @@
 return it;
   }
 
+  template 
+  ForwardIterator
+  next (ForwardIterator it,
+typename iterator_traits::difference_type n =
+1) {
+advance(it, n);
+return it;
+  }
+
   template 
   InputIterator find(InputIterator first, InputIterator last, const T &val);
 
Index: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
+++ lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
@@ -287,6 +287,9 @@
 bool isEraseCall(const FunctionDecl *Func);
 bool isEraseAfterCall(const FunctionDecl *Func);
 bool isEmplaceCall(const FunctionDecl *Func);
+bool isStdAdvanceCall(const FunctionDecl *Func);
+bool isStdPrevCall(const FunctionDecl *Func);
+bool isStdNextCall(const FunctionDecl *Func);
 bool isAssignmentOperator(OverloadedOperatorKind OK);
 bool isSimpleComparisonOperator(OverloadedOperatorKind OK);
 bool isAccessOperator(OverloadedOperatorKind OK);
@@ -473,6 +476,12 @@
   verifyMatch(C, Call.getArgSVal(0),
   InstCall->getCXXThisVal().getAsRegion());
 }
+  } else if (ChecksEnabled[CK_IteratorRangeChecker] &&
+ (isStdAdvanceCall(Func) || isStdNextCall(Func))) {
+verifyRandomIncrOrDecr(C, OO_Plus, Call.getArgSVal(0), Call.getArgSVal(1));
+  } else if (ChecksEnabled[CK_IteratorRangeChecker] &&
+ isStdPrevCall(Func)) {
+verifyRandomIncrOrDecr(C, OO_Minus, Call.getArgSVal(0), Call.getArgSVal(1));
   } else if (isa(&Call)) {
 // Check match of first-last iterator pair in a constructor of a container
 if (Call.getNumArgs() < 2)
@@ -685,6 +694,24 @@
   }
 }
 
+if (!C.wasInlined) {
+  if (isStdAdvanceCall(Func)) {
+handleRandomIncrOrDecr(C, OO_PlusEqual, UndefinedVal(),
+   Call.getArgSVal(0), Call.getArgSVal(1));
+return;
+  }
+  if (isStdPrevCall(Func)) {
+handleRandomIncrOrDecr(C, OO_Minus, Call.getReturnValue(),
+   Call.getArgSVal(0), Call.getArgSVal(1));
+return;
+  }
+  if (isStdNextCall(Func)) {
+handleRandomIncrOrDecr(C, OO_Plus, Call.getReturnValue(),
+   Call.getArgSVal(0), Call.getArgSVal(1));
+return;
+  }
+}
+
 const auto 

[PATCH] D62883: [analyzer] Track conditions of terminator statements on which the reported node depends on

2019-06-05 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun requested changes to this revision.
xazax.hun added inline comments.
This revision now requires changes to proceed.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h:176
+  const ExplodedNode *Origin;
+  CFGControlDependencyTree ControlDepTree;
+  llvm::SmallSet VisitedBlocks;

I think we should make clear that this visitor only operates within one 
function and does not track controll dependencies across functions. 



Comment at: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:680
 
+} // end of anonymous namespace
+

What was the reason of adding these begin/ends? I prefer to keep such 
refactorings separate, also it might be controversial whether this change is 
desired.



Comment at: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:1863-1864
+
+case Stmt::ObjCForCollectionStmtClass:
+  return cast(S)->getCollection();
+

NoQ wrote:
> Szelethus wrote:
> > @NoQ Any feelings on this?
> This makes some sense in the long run but i think you should give up here for 
> now. Unlike `CXXForRangeStmt`, its Objective-C counterpart doesn't mock up 
> the AST that would have made it look like a regular for-loop, so there just 
> isn't an AST node that would represent the part of it that corresponds to 
> "`__begin != __end`".
> 
> Even in the C++ case, i'm not sure your current behavior would make much 
> sense. We should probably delegate this work to a checker that knows how 
> collections work and what makes them empty or have a certain size, something 
> similar to what the `IteratorChecker` seems to be becoming :)
> 
> Should we give mark the report as invalid when we give up here? I've no idea, 
> i guess i'll have to gather more empirical evidence on that.
I vaguely recall some problem with the results of getTerminatorStmt for logical 
operators like &&. I believe what we really want is the last expression we 
evaluated in the basic block which will be the last Stmt of the basic block. So 
if we can settle with the last stmt we can get rid of this code. 



Comment at: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:1899-1901
+  CFGBlock *NB = GetRelevantBlock(N);
+  if (!VisitedBlocks.insert(NB).second)
+return nullptr;

NoQ wrote:
> I didn't really understand this part.
I guess detecting control depdendency only makes sense for the last statement 
of the basic block (which is the first one we see in the visitor order). But 
instead of maintaining a state with the visited nodes we could also check if 
the statement is the last one of its basic block. 


Repository:
  rC Clang

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

https://reviews.llvm.org/D62883



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


[PATCH] D60763: Prototype OpenCL BIFs using Tablegen

2019-06-05 Thread Pierre via Phabricator via cfe-commits
Pierre added a comment.

In D60763#1529279 , @Nicola wrote:

> A bit late to the review, but I've noticed a couple of issues with some of 
> the implemented builtins:
>
> - The fmin/fmax builtins are defined twice for scalar types, does this create 
> problems in overload resolution when using them?
> - The convert_ builtins don't have support for half types (which is present 
> in the opencl-c.h header. Is that intended?


Both your comments are rights. Some builtin functions are currently a 
faulty/missing. I am currently updating the functions so that they match the 
OpenCL C specification. 
convert_half will be present, and the way builtin functions are defined in the 
.td file will change a bit.
The new version should be available by the end of the week.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D60763



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


[PATCH] D61552: [clang] Adapt ASTMatcher to explicit(bool) specifier

2019-06-05 Thread Tyker via Phabricator via cfe-commits
Tyker updated this revision to Diff 203115.
Tyker marked an inline comment as done.
Tyker edited the summary of this revision.
Tyker added a comment.

changed as requested.

hasExplicitSpecifier now gives access to the expression if present.


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

https://reviews.llvm.org/D61552

Files:
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -1735,6 +1735,56 @@
 llvm::make_unique>("x", 3)));
 }
 
+TEST(Declaration, HasExplicitExpr) {
+  EXPECT_TRUE(matchesConditionally(
+  "void f();", functionDecl(hasExplicitExpr(constantExpr())), false,
+  "-std=c++2a"));
+  EXPECT_TRUE(matchesConditionally(
+  "template struct S { explicit operator int(); };",
+  cxxConversionDecl(hasExplicitExpr(constantExpr(has(cxxBoolLiteral(),
+  false, "-std=c++2a"));
+  EXPECT_TRUE(matchesConditionally(
+  "template struct S { explicit(b) operator int(); };",
+  cxxConversionDecl(hasExplicitExpr(constantExpr(has(cxxBoolLiteral(),
+  false, "-std=c++2a"));
+  EXPECT_TRUE(matchesConditionally(
+  "struct S { explicit(true) operator int(); };",
+  cxxConversionDecl(hasExplicitExpr(constantExpr(has(cxxBoolLiteral(),
+  true, "-std=c++2a"));
+  EXPECT_TRUE(matchesConditionally(
+  "struct S { explicit(false) operator int(); };",
+  cxxConversionDecl(hasExplicitExpr(constantExpr(has(cxxBoolLiteral(),
+  true, "-std=c++2a"));
+  EXPECT_TRUE(matchesConditionally(
+  "template struct S { explicit(b) S(int); };",
+  cxxConstructorDecl(hasExplicitExpr(constantExpr(has(cxxBoolLiteral(),
+  false, "-std=c++2a"));
+  EXPECT_TRUE(matchesConditionally(
+  "struct S { explicit(true) S(int); };",
+  cxxConstructorDecl(hasExplicitExpr(constantExpr(has(cxxBoolLiteral(),
+  true, "-std=c++2a"));
+  EXPECT_TRUE(matchesConditionally(
+  "struct S { explicit(false) S(int); };",
+  cxxConstructorDecl(hasExplicitExpr(constantExpr(has(cxxBoolLiteral(),
+  true, "-std=c++2a"));
+  EXPECT_TRUE(matchesConditionally(
+  "template struct S { S(int); };"
+  "template explicit(b) S(int) -> S;",
+  cxxDeductionGuideDecl(
+  hasExplicitExpr(constantExpr(has(cxxBoolLiteral(),
+  false, "-std=c++2a"));
+  EXPECT_TRUE(matchesConditionally("template struct S { S(int); };"
+   "explicit(true) S(int) -> S;",
+   cxxDeductionGuideDecl(hasExplicitExpr(
+   constantExpr(has(cxxBoolLiteral(),
+   true, "-std=c++2a"));
+  EXPECT_TRUE(matchesConditionally("template struct S { S(int); };"
+   "explicit(false) S(int) -> S;",
+   cxxDeductionGuideDecl(hasExplicitExpr(
+   constantExpr(has(cxxBoolLiteral(),
+   true, "-std=c++2a"));
+}
+
 TEST(ForEachConstructorInitializer, MatchesInitializers) {
   EXPECT_TRUE(matches(
 "struct X { X() : i(42), j(42) {} int i, j; };",
Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -810,6 +810,15 @@
   cxxConversionDecl(isExplicit(;
   EXPECT_TRUE(notMatches("struct S { operator int(); };",
  cxxConversionDecl(isExplicit(;
+  EXPECT_TRUE(matchesConditionally(
+  "template struct S { explicit(b) operator int(); };",
+  cxxConversionDecl(isExplicit()), false, "-std=c++2a"));
+  EXPECT_TRUE(matchesConditionally(
+  "struct S { explicit(true) operator int(); };",
+  cxxConversionDecl(isExplicit()), true, "-std=c++2a"));
+  EXPECT_TRUE(matchesConditionally(
+  "struct S { explicit(false) operator int(); };",
+  cxxConversionDecl(isExplicit()), false, "-std=c++2a"));
 }
 
 TEST(Matcher, ArgumentCount) {
@@ -1129,6 +1138,38 @@
   cxxConstructorDecl(isExplicit(;
   EXPECT_TRUE(notMatches("struct S { S(int); };",
  cxxConstructorDecl(isExplicit(;
+  EXPECT_TRUE(matchesConditionally(
+  "template struct S { explicit(b) S(int);};",
+  cxxConstructorDecl(isExplicit()), false, "-std=c++2a"));
+  EXPECT_TRUE(matchesConditionally("struct S { explicit(true) S(int);};",
+  

[PATCH] D60697: [ARM] Allow "-march=foo+fp" to vary with foo.

2019-06-05 Thread Oliver Stannard (Linaro) via Phabricator via cfe-commits
ostannard accepted this revision.
ostannard added a comment.
This revision is now accepted and ready to land.

Fair enough, I don't think we currently try to diagnose any other invalid 
combinations of features. LGTM.


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

https://reviews.llvm.org/D60697



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


[PATCH] D48116: [libclang] Allow skipping warnings from all included files

2019-06-05 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan accepted this revision.
yvvan added a comment.
This revision is now accepted and ready to land.

libclang part is quite small here and looks ok. I would just accept it


Repository:
  rC Clang

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

https://reviews.llvm.org/D48116



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


[PATCH] D62895: [Analyzer] Iterator Checkers - Check and simulate `std::advance`, `std::prev` and `std::next`

2019-06-05 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

This patch definitely reduces the number of false positives, but may not be 
enough. The problem is that `std::advance()` may call another function that 
does the actual incremention or decremention, in the `gcc` implementation it is 
`__advance()`. If the `std::advance()` is inlined but `__advance()` not then we 
still get false positive. The obvious way would be to simulate `__advance()` as 
well but it is an implementation dependent internal function and may be totally 
different for other implementations. Another idea is that instead of querying 
the `CheckerContext` whether `advance()` was inlined we go up the exploded 
graph and find its "precall" state and compare the values of the first 
parameter related to the second one in the two states. This is a bit more 
complex and more expensive but this for me this seems to be the correct 
solution.


Repository:
  rC Clang

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

https://reviews.llvm.org/D62895



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


[PATCH] D62127: [Hexagon] driver uses out-of-date option name and binary name

2019-06-05 Thread A. Skrobov via Phabricator via cfe-commits
t.yomitch added a comment.

Ping?


Repository:
  rC Clang

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

https://reviews.llvm.org/D62127



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


[PATCH] D62899: [analyzer][UninitializedObjectChecker] Mark uninitialized regions as interesting.

2019-06-05 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus created this revision.
Szelethus added reviewers: NoQ, xazax.hun, dcoughlin, baloghadamsoftware, 
rnkovacs.
Szelethus added a project: clang.
Herald added subscribers: cfe-commits, Charusso, gamesh411, dkrupp, donat.nagy, 
mikhail.ramalho, a.sidorin, szepet, whisperity.

Repository:
  rC Clang

https://reviews.llvm.org/D62899

Files:
  
clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
  clang/test/Analysis/cxx-uninitialized-object-unguarded-access.cpp


Index: clang/test/Analysis/cxx-uninitialized-object-unguarded-access.cpp
===
--- clang/test/Analysis/cxx-uninitialized-object-unguarded-access.cpp
+++ clang/test/Analysis/cxx-uninitialized-object-unguarded-access.cpp
@@ -1,6 +1,7 @@
 // RUN: %clang_analyze_cc1 
-analyzer-checker=core,optin.cplusplus.UninitializedObject \
 // RUN:   -analyzer-config optin.cplusplus.UninitializedObject:Pedantic=true 
-DPEDANTIC \
 // RUN:   -analyzer-config 
optin.cplusplus.UninitializedObject:IgnoreGuardedFields=true \
+// RUN:   -analyzer-output=text \
 // RUN:   -std=c++11 -verify  %s
 
 
//===--===//
@@ -158,15 +159,16 @@
 
 public:
   UnguardedFieldThroughMethodTest(Kind K) : K(K) {
-switch (K) {
+switch (K) { // expected-note{{Control jumps to 'case A:'  at line}}
 case V:
   Volume = 0;
   break;
 case A:
-  Area = 0; // expected-warning {{1 uninitialized field}}
-  break;
+  Area = 0;
+  break; // expected-note{{Execution jumps to the end of the function}}
 }
-  }
+  } // expected-warning{{1 uninitialized field}}
+  // expected-note@-1{{1 uninitialized field}}
 
   void operator-() {
 assert(K == Kind::A);
@@ -180,6 +182,7 @@
 
 void fUnguardedFieldThroughMethodTest() {
   UnguardedFieldThroughMethodTest T1(UnguardedFieldThroughMethodTest::Kind::A);
+  // expected-note@-1{{Calling constructor for 
'UnguardedFieldThroughMethodTest'}}
 }
 
 class UnguardedPublicFieldsTest {
@@ -196,15 +199,16 @@
 
 public:
   UnguardedPublicFieldsTest(Kind K) : K(K) {
-switch (K) {
+switch (K) { // expected-note{{Control jumps to 'case A:'  at line}}
 case V:
   Volume = 0;
   break;
 case A:
-  Area = 0; // expected-warning {{1 uninitialized field}}
-  break;
+  Area = 0;
+  break; // expected-note{{Execution jumps to the end of the function}}
 }
-  }
+  } // expected-warning {{1 uninitialized field}}
+  // expected-note@-1{{1 uninitialized field}}
 
   void operator-() {
 assert(K == Kind::A);
@@ -219,6 +223,7 @@
 
 void fUnguardedPublicFieldsTest() {
   UnguardedPublicFieldsTest T1(UnguardedPublicFieldsTest::Kind::A);
+  // expected-note@-1{{Calling constructor for 'UnguardedPublicFieldsTest'}}
 }
 
 
//===--===//
Index: 
clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
===
--- 
clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
+++ 
clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
@@ -209,6 +209,7 @@
 Report->addNote(Pair.second,
 PathDiagnosticLocation::create(Pair.first->getDecl(),

Context.getSourceManager()));
+Report->markInteresting(Pair.first);
   }
   Context.emitReport(std::move(Report));
 }


Index: clang/test/Analysis/cxx-uninitialized-object-unguarded-access.cpp
===
--- clang/test/Analysis/cxx-uninitialized-object-unguarded-access.cpp
+++ clang/test/Analysis/cxx-uninitialized-object-unguarded-access.cpp
@@ -1,6 +1,7 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=core,optin.cplusplus.UninitializedObject \
 // RUN:   -analyzer-config optin.cplusplus.UninitializedObject:Pedantic=true -DPEDANTIC \
 // RUN:   -analyzer-config optin.cplusplus.UninitializedObject:IgnoreGuardedFields=true \
+// RUN:   -analyzer-output=text \
 // RUN:   -std=c++11 -verify  %s
 
 //===--===//
@@ -158,15 +159,16 @@
 
 public:
   UnguardedFieldThroughMethodTest(Kind K) : K(K) {
-switch (K) {
+switch (K) { // expected-note{{Control jumps to 'case A:'  at line}}
 case V:
   Volume = 0;
   break;
 case A:
-  Area = 0; // expected-warning {{1 uninitialized field}}
-  break;
+  Area = 0;
+  break; // expected-note{{Execution jumps to the end of the function}}
 }
-  }
+  } // expected-warning{{1 uninitialized field}}
+  // expected-note@-1{{1 uninitialized field}}
 
   void operator-() {
 assert(K == Kind::A);
@@ -180,6 +182,7 @@
 
 void fUnguardedFieldThroughMethodTest() {
   UnguardedFieldThroughMethodTest T1(UnguardedFieldThroughMethodTest::Ki

[PATCH] D62619: [analyzer][Dominators] Add a control dependency tree builder + a new debug checker

2019-06-05 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

While I managed to create a version of `llvm::IDFCalculator` that both compiles 
and works well with `clang::CFGBlock *`, I'm a little unsure about the 
specifics. I sent out a mail to reach a wider audience about the next steps: 
http://lists.llvm.org/pipermail/llvm-dev/2019-June/132786.html


Repository:
  rC Clang

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

https://reviews.llvm.org/D62619



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


r362597 - Revert "Factor out duplicated code building a MemberExpr and marking it" and "Convert MemberExpr creation and serialization to work the same way as"

2019-06-05 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Wed Jun  5 04:46:57 2019
New Revision: 362597

URL: http://llvm.org/viewvc/llvm-project?rev=362597&view=rev
Log:
Revert "Factor out duplicated code building a MemberExpr and marking it" and 
"Convert MemberExpr creation and serialization to work the same way as"

This reverts commits r362551 and r362563. Crashes during modules selfhost.

Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp
cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaExprMember.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=362597&r1=362596&r2=362597&view=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Wed Jun  5 04:46:57 2019
@@ -2735,7 +2735,6 @@ class MemberExpr final
 ASTTemplateKWAndArgsInfo,
 TemplateArgumentLoc> {
   friend class ASTReader;
-  friend class ASTStmtReader;
   friend class ASTStmtWriter;
   friend TrailingObjects;
 
@@ -2770,38 +2769,49 @@ class MemberExpr final
 return MemberExprBits.HasTemplateKWAndArgsInfo;
   }
 
-  MemberExpr(Expr *Base, bool IsArrow, SourceLocation OperatorLoc,
- ValueDecl *MemberDecl, const DeclarationNameInfo &NameInfo,
- QualType T, ExprValueKind VK, ExprObjectKind OK);
-  MemberExpr(EmptyShell Empty)
-  : Expr(MemberExprClass, Empty), Base(), MemberDecl() {}
-
 public:
-  static MemberExpr *Create(const ASTContext &C, Expr *Base, bool IsArrow,
+  MemberExpr(Expr *base, bool isarrow, SourceLocation operatorloc,
+ ValueDecl *memberdecl, const DeclarationNameInfo &NameInfo,
+ QualType ty, ExprValueKind VK, ExprObjectKind OK)
+  : Expr(MemberExprClass, ty, VK, OK, base->isTypeDependent(),
+ base->isValueDependent(), base->isInstantiationDependent(),
+ base->containsUnexpandedParameterPack()),
+Base(base), MemberDecl(memberdecl), MemberDNLoc(NameInfo.getInfo()),
+MemberLoc(NameInfo.getLoc()) {
+assert(memberdecl->getDeclName() == NameInfo.getName());
+MemberExprBits.IsArrow = isarrow;
+MemberExprBits.HasQualifierOrFoundDecl = false;
+MemberExprBits.HasTemplateKWAndArgsInfo = false;
+MemberExprBits.HadMultipleCandidates = false;
+MemberExprBits.OperatorLoc = operatorloc;
+  }
+
+  // NOTE: this constructor should be used only when it is known that
+  // the member name can not provide additional syntactic info
+  // (i.e., source locations for C++ operator names or type source info
+  // for constructors, destructors and conversion operators).
+  MemberExpr(Expr *base, bool isarrow, SourceLocation operatorloc,
+ ValueDecl *memberdecl, SourceLocation l, QualType ty,
+ ExprValueKind VK, ExprObjectKind OK)
+  : Expr(MemberExprClass, ty, VK, OK, base->isTypeDependent(),
+ base->isValueDependent(), base->isInstantiationDependent(),
+ base->containsUnexpandedParameterPack()),
+Base(base), MemberDecl(memberdecl), MemberDNLoc(), MemberLoc(l) {
+MemberExprBits.IsArrow = isarrow;
+MemberExprBits.HasQualifierOrFoundDecl = false;
+MemberExprBits.HasTemplateKWAndArgsInfo = false;
+MemberExprBits.HadMultipleCandidates = false;
+MemberExprBits.OperatorLoc = operatorloc;
+  }
+
+  static MemberExpr *Create(const ASTContext &C, Expr *base, bool isarrow,
 SourceLocation OperatorLoc,
 NestedNameSpecifierLoc QualifierLoc,
-SourceLocation TemplateKWLoc, ValueDecl 
*MemberDecl,
-DeclAccessPair FoundDecl,
+SourceLocation TemplateKWLoc, ValueDecl 
*memberdecl,
+DeclAccessPair founddecl,
 DeclarationNameInfo MemberNameInfo,
-const TemplateArgumentListInfo *TemplateArgs,
-QualType T, ExprValueKind VK, ExprObjectKind OK);
-
-  /// Create an implicit MemberExpr, with no location, qualifier, template
-  /// arguments, and so on.
-  static MemberExpr *CreateImplicit(const ASTContext &C, Expr *Base,
-bool IsArrow, ValueDecl *MemberDecl,
-QualType T, ExprValueKind VK,
-ExprObjectKind OK) {
-return Create(C, Base, IsArrow, SourceLocation(), NestedNameSpecifierLoc(),
-   

Re: r362551 - Convert MemberExpr creation and serialization to work the same way as

2019-06-05 Thread Benjamin Kramer via cfe-commits
It also crashes during clang selfhost with modules and libc++. Let me know
if you need a precise reproducer command.

I reverted this change and the dependent r362563 in r362597.

On Wed, Jun 5, 2019 at 9:37 AM Martin Storsjö via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> This broke building of Qt when using PCH. Selfcontained repro is a bit
> hard to make though...
>
> // Martin
>
> On Tue, 4 Jun 2019, Richard Smith via cfe-commits wrote:
>
> > Author: rsmith
> > Date: Tue Jun  4 14:29:28 2019
> > New Revision: 362551
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=362551&view=rev
> > Log:
> > Convert MemberExpr creation and serialization to work the same way as
> > most / all other Expr subclasses.
> >
> > Modified:
> >cfe/trunk/include/clang/AST/Expr.h
> >cfe/trunk/include/clang/AST/Stmt.h
> >cfe/trunk/lib/AST/DeclBase.cpp
> >cfe/trunk/lib/AST/Expr.cpp
> >cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp
> >cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp
> >cfe/trunk/lib/Sema/SemaExprCXX.cpp
> >cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
> >cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
> >
> > Modified: cfe/trunk/include/clang/AST/Expr.h
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=362551&r1=362550&r2=362551&view=diff
> >
> ==
> > --- cfe/trunk/include/clang/AST/Expr.h (original)
> > +++ cfe/trunk/include/clang/AST/Expr.h Tue Jun  4 14:29:28 2019
> > @@ -2735,6 +2735,7 @@ class MemberExpr final
> > ASTTemplateKWAndArgsInfo,
> > TemplateArgumentLoc> {
> >   friend class ASTReader;
> > +  friend class ASTStmtReader;
> >   friend class ASTStmtWriter;
> >   friend TrailingObjects;
> >
> > @@ -2769,49 +2770,38 @@ class MemberExpr final
> > return MemberExprBits.HasTemplateKWAndArgsInfo;
> >   }
> >
> > -public:
> > -  MemberExpr(Expr *base, bool isarrow, SourceLocation operatorloc,
> > - ValueDecl *memberdecl, const DeclarationNameInfo &NameInfo,
> > - QualType ty, ExprValueKind VK, ExprObjectKind OK)
> > -  : Expr(MemberExprClass, ty, VK, OK, base->isTypeDependent(),
> > - base->isValueDependent(), base->isInstantiationDependent(),
> > - base->containsUnexpandedParameterPack()),
> > -Base(base), MemberDecl(memberdecl),
> MemberDNLoc(NameInfo.getInfo()),
> > -MemberLoc(NameInfo.getLoc()) {
> > -assert(memberdecl->getDeclName() == NameInfo.getName());
> > -MemberExprBits.IsArrow = isarrow;
> > -MemberExprBits.HasQualifierOrFoundDecl = false;
> > -MemberExprBits.HasTemplateKWAndArgsInfo = false;
> > -MemberExprBits.HadMultipleCandidates = false;
> > -MemberExprBits.OperatorLoc = operatorloc;
> > -  }
> > -
> > -  // NOTE: this constructor should be used only when it is known that
> > -  // the member name can not provide additional syntactic info
> > -  // (i.e., source locations for C++ operator names or type source info
> > -  // for constructors, destructors and conversion operators).
> > -  MemberExpr(Expr *base, bool isarrow, SourceLocation operatorloc,
> > - ValueDecl *memberdecl, SourceLocation l, QualType ty,
> > - ExprValueKind VK, ExprObjectKind OK)
> > -  : Expr(MemberExprClass, ty, VK, OK, base->isTypeDependent(),
> > - base->isValueDependent(), base->isInstantiationDependent(),
> > - base->containsUnexpandedParameterPack()),
> > -Base(base), MemberDecl(memberdecl), MemberDNLoc(), MemberLoc(l)
> {
> > -MemberExprBits.IsArrow = isarrow;
> > -MemberExprBits.HasQualifierOrFoundDecl = false;
> > -MemberExprBits.HasTemplateKWAndArgsInfo = false;
> > -MemberExprBits.HadMultipleCandidates = false;
> > -MemberExprBits.OperatorLoc = operatorloc;
> > -  }
> > +  MemberExpr(Expr *Base, bool IsArrow, SourceLocation OperatorLoc,
> > + ValueDecl *MemberDecl, const DeclarationNameInfo &NameInfo,
> > + QualType T, ExprValueKind VK, ExprObjectKind OK);
> > +  MemberExpr(EmptyShell Empty)
> > +  : Expr(MemberExprClass, Empty), Base(), MemberDecl() {}
> >
> > -  static MemberExpr *Create(const ASTContext &C, Expr *base, bool
> isarrow,
> > +public:
> > +  static MemberExpr *Create(const ASTContext &C, Expr *Base, bool
> IsArrow,
> > SourceLocation OperatorLoc,
> > NestedNameSpecifierLoc QualifierLoc,
> > -SourceLocation TemplateKWLoc, ValueDecl
> *memberdecl,
> > -DeclAccessPair founddecl,
> > +SourceLocation TemplateKWLoc, ValueDecl
> *MemberDecl,
> > +DeclAccessPair FoundDecl,
> > DeclarationNameInfo MemberNameInfo,
> > -const TemplateArgumentListInfo *targ

[PATCH] D62621: [LibTooling] Add insert/remove convenience functions for creating `ASTEdit`s.

2019-06-05 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 203122.
ymandel marked an inline comment as done.
ymandel added a comment.

adjusted API comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62621

Files:
  clang/include/clang/Tooling/Refactoring/Transformer.h
  clang/unittests/Tooling/TransformerTest.cpp


Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- clang/unittests/Tooling/TransformerTest.cpp
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -349,6 +349,64 @@
Input, Expected);
 }
 
+TEST_F(TransformerTest, InsertBeforeEdit) {
+  std::string Input = R"cc(
+int f() {
+  return 7;
+}
+  )cc";
+  std::string Expected = R"cc(
+int f() {
+  int y = 3;
+  return 7;
+}
+  )cc";
+
+  StringRef Ret = "return";
+  testRule(makeRule(returnStmt().bind(Ret),
+insertBefore(statement(Ret), text("int y = 3;"))),
+   Input, Expected);
+}
+
+TEST_F(TransformerTest, InsertAfterEdit) {
+  std::string Input = R"cc(
+int f() {
+  int x = 5;
+  return 7;
+}
+  )cc";
+  std::string Expected = R"cc(
+int f() {
+  int x = 5;
+  int y = 3;
+  return 7;
+}
+  )cc";
+
+  StringRef Decl = "decl";
+  testRule(makeRule(declStmt().bind(Decl),
+insertAfter(statement(Decl), text("int y = 3;"))),
+   Input, Expected);
+}
+
+TEST_F(TransformerTest, RemoveEdit) {
+  std::string Input = R"cc(
+int f() {
+  int x = 5;
+  return 7;
+}
+  )cc";
+  std::string Expected = R"cc(
+int f() {
+  return 7;
+}
+  )cc";
+
+  StringRef Decl = "decl";
+  testRule(makeRule(declStmt().bind(Decl), remove(statement(Decl))), Input,
+   Expected);
+}
+
 TEST_F(TransformerTest, MultiChange) {
   std::string Input = R"cc(
 void foo() {
Index: clang/include/clang/Tooling/Refactoring/Transformer.h
===
--- clang/include/clang/Tooling/Refactoring/Transformer.h
+++ clang/include/clang/Tooling/Refactoring/Transformer.h
@@ -193,6 +193,23 @@
   return change(node(RewriteRule::RootID), std::move(Replacement));
 }
 
+/// Inserts \p Replacement before \p S, leaving the source selected by \S
+/// unchanged.
+inline ASTEdit insertBefore(RangeSelector S, TextGenerator Replacement) {
+  return change(before(std::move(S)), std::move(Replacement));
+}
+
+/// Inserts \p Replacement after \p S, leaving the source selected by \S
+/// unchanged.
+inline ASTEdit insertAfter(RangeSelector S, TextGenerator Replacement) {
+  return change(after(std::move(S)), std::move(Replacement));
+}
+
+/// Removes the source selected by \p S.
+inline ASTEdit remove(RangeSelector S) {
+  return change(std::move(S), text(""));
+}
+
 /// The following three functions are a low-level part of the RewriteRule
 /// API. We expose them for use in implementing the fixtures that interpret
 /// RewriteRule, like Transformer and TransfomerTidy, or for more advanced


Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- clang/unittests/Tooling/TransformerTest.cpp
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -349,6 +349,64 @@
Input, Expected);
 }
 
+TEST_F(TransformerTest, InsertBeforeEdit) {
+  std::string Input = R"cc(
+int f() {
+  return 7;
+}
+  )cc";
+  std::string Expected = R"cc(
+int f() {
+  int y = 3;
+  return 7;
+}
+  )cc";
+
+  StringRef Ret = "return";
+  testRule(makeRule(returnStmt().bind(Ret),
+insertBefore(statement(Ret), text("int y = 3;"))),
+   Input, Expected);
+}
+
+TEST_F(TransformerTest, InsertAfterEdit) {
+  std::string Input = R"cc(
+int f() {
+  int x = 5;
+  return 7;
+}
+  )cc";
+  std::string Expected = R"cc(
+int f() {
+  int x = 5;
+  int y = 3;
+  return 7;
+}
+  )cc";
+
+  StringRef Decl = "decl";
+  testRule(makeRule(declStmt().bind(Decl),
+insertAfter(statement(Decl), text("int y = 3;"))),
+   Input, Expected);
+}
+
+TEST_F(TransformerTest, RemoveEdit) {
+  std::string Input = R"cc(
+int f() {
+  int x = 5;
+  return 7;
+}
+  )cc";
+  std::string Expected = R"cc(
+int f() {
+  return 7;
+}
+  )cc";
+
+  StringRef Decl = "decl";
+  testRule(makeRule(declStmt().bind(Decl), remove(statement(Decl))), Input,
+   Expected);
+}
+
 TEST_F(TransformerTest, MultiChange) {
   std::string Input = R"cc(
 void foo() {
Index: clang/include/clang/Tooling/Refactoring/Transformer.h
===
--- clang/include/clang/Tooling/Refactoring/Transformer.h
+++ clang/include/clang/Tooling/Refactoring/Transformer.h
@@ -193,6 +193,23 @@
   return change(node(RewriteRule::RootID), std::move(Replacement));
 }
 
+/// Insert

[PATCH] D62850: [X86] Fix builtins-x86.c test where it wasn't using immediates. NFC

2019-06-05 Thread Russell Gallop via Phabricator via cfe-commits
russell.gallop updated this revision to Diff 203124.
russell.gallop added a comment.

Re-added test cases using variables and added comment. This now tests both 
formats.


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

https://reviews.llvm.org/D62850

Files:
  clang/test/CodeGen/builtins-x86.c


Index: clang/test/CodeGen/builtins-x86.c
===
--- clang/test/CodeGen/builtins-x86.c
+++ clang/test/CodeGen/builtins-x86.c
@@ -399,6 +399,17 @@
 #ifndef OPENCL
   (void) _mm_pause();
 #endif
+
+  tmp_V4s = __builtin_ia32_psllwi(tmp_V4s, imm_i_0_8);
+  tmp_V2i = __builtin_ia32_pslldi(tmp_V2i, imm_i_0_8);
+  tmp_V1LLi = __builtin_ia32_psllqi(tmp_V1LLi, imm_i_0_8);
+  tmp_V4s = __builtin_ia32_psrawi(tmp_V4s, imm_i_0_8);
+  tmp_V2i = __builtin_ia32_psradi(tmp_V2i, imm_i_0_8);
+  tmp_V4s = __builtin_ia32_psrlwi(tmp_V4s, imm_i_0_8);
+  tmp_V2i = __builtin_ia32_psrldi(tmp_V2i, imm_i_0_8);
+  tmp_V1LLi = __builtin_ia32_psrlqi(tmp_V1LLi, imm_i_0_8);
+
+  // Using non-immediate argument supported for gcc compatibility
   tmp_V4s = __builtin_ia32_psllwi(tmp_V4s, tmp_i);
   tmp_V2i = __builtin_ia32_pslldi(tmp_V2i, tmp_i);
   tmp_V1LLi = __builtin_ia32_psllqi(tmp_V1LLi, tmp_i);
@@ -407,6 +418,7 @@
   tmp_V4s = __builtin_ia32_psrlwi(tmp_V4s, tmp_i);
   tmp_V2i = __builtin_ia32_psrldi(tmp_V2i, tmp_i);
   tmp_V1LLi = __builtin_ia32_psrlqi(tmp_V1LLi, tmp_i);
+
   tmp_V1LLi = __builtin_ia32_pmuludq(tmp_V2i, tmp_V2i);
   tmp_V2LLi = __builtin_ia32_pmuludq128(tmp_V4i, tmp_V4i);
   tmp_V8s = __builtin_ia32_psraw128(tmp_V8s, tmp_V8s);
@@ -417,6 +429,17 @@
   tmp_V8s = __builtin_ia32_psllw128(tmp_V8s, tmp_V8s);
   tmp_V4i = __builtin_ia32_pslld128(tmp_V4i, tmp_V4i);
   tmp_V2LLi = __builtin_ia32_psllq128(tmp_V2LLi, tmp_V2LLi);
+
+  tmp_V8s = __builtin_ia32_psllwi128(tmp_V8s, imm_i_0_8);
+  tmp_V4i = __builtin_ia32_pslldi128(tmp_V4i, imm_i_0_8);
+  tmp_V2LLi = __builtin_ia32_psllqi128(tmp_V2LLi, imm_i_0_8);
+  tmp_V8s = __builtin_ia32_psrlwi128(tmp_V8s, imm_i_0_8);
+  tmp_V4i = __builtin_ia32_psrldi128(tmp_V4i, imm_i_0_8);
+  tmp_V2LLi = __builtin_ia32_psrlqi128(tmp_V2LLi, imm_i_0_8);
+  tmp_V8s = __builtin_ia32_psrawi128(tmp_V8s, imm_i_0_8);
+  tmp_V4i = __builtin_ia32_psradi128(tmp_V4i, imm_i_0_8);
+
+  // Using non-immediate argument supported for gcc compatibility
   tmp_V8s = __builtin_ia32_psllwi128(tmp_V8s, tmp_i);
   tmp_V4i = __builtin_ia32_pslldi128(tmp_V4i, tmp_i);
   tmp_V2LLi = __builtin_ia32_psllqi128(tmp_V2LLi, tmp_i);
@@ -425,6 +448,7 @@
   tmp_V2LLi = __builtin_ia32_psrlqi128(tmp_V2LLi, tmp_i);
   tmp_V8s = __builtin_ia32_psrawi128(tmp_V8s, tmp_i);
   tmp_V4i = __builtin_ia32_psradi128(tmp_V4i, tmp_i);
+
   tmp_V4i = __builtin_ia32_pmaddwd128(tmp_V8s, tmp_V8s);
   (void) __builtin_ia32_monitor(tmp_vp, tmp_Ui, tmp_Ui);
   (void) __builtin_ia32_mwait(tmp_Ui, tmp_Ui);


Index: clang/test/CodeGen/builtins-x86.c
===
--- clang/test/CodeGen/builtins-x86.c
+++ clang/test/CodeGen/builtins-x86.c
@@ -399,6 +399,17 @@
 #ifndef OPENCL
   (void) _mm_pause();
 #endif
+
+  tmp_V4s = __builtin_ia32_psllwi(tmp_V4s, imm_i_0_8);
+  tmp_V2i = __builtin_ia32_pslldi(tmp_V2i, imm_i_0_8);
+  tmp_V1LLi = __builtin_ia32_psllqi(tmp_V1LLi, imm_i_0_8);
+  tmp_V4s = __builtin_ia32_psrawi(tmp_V4s, imm_i_0_8);
+  tmp_V2i = __builtin_ia32_psradi(tmp_V2i, imm_i_0_8);
+  tmp_V4s = __builtin_ia32_psrlwi(tmp_V4s, imm_i_0_8);
+  tmp_V2i = __builtin_ia32_psrldi(tmp_V2i, imm_i_0_8);
+  tmp_V1LLi = __builtin_ia32_psrlqi(tmp_V1LLi, imm_i_0_8);
+
+  // Using non-immediate argument supported for gcc compatibility
   tmp_V4s = __builtin_ia32_psllwi(tmp_V4s, tmp_i);
   tmp_V2i = __builtin_ia32_pslldi(tmp_V2i, tmp_i);
   tmp_V1LLi = __builtin_ia32_psllqi(tmp_V1LLi, tmp_i);
@@ -407,6 +418,7 @@
   tmp_V4s = __builtin_ia32_psrlwi(tmp_V4s, tmp_i);
   tmp_V2i = __builtin_ia32_psrldi(tmp_V2i, tmp_i);
   tmp_V1LLi = __builtin_ia32_psrlqi(tmp_V1LLi, tmp_i);
+
   tmp_V1LLi = __builtin_ia32_pmuludq(tmp_V2i, tmp_V2i);
   tmp_V2LLi = __builtin_ia32_pmuludq128(tmp_V4i, tmp_V4i);
   tmp_V8s = __builtin_ia32_psraw128(tmp_V8s, tmp_V8s);
@@ -417,6 +429,17 @@
   tmp_V8s = __builtin_ia32_psllw128(tmp_V8s, tmp_V8s);
   tmp_V4i = __builtin_ia32_pslld128(tmp_V4i, tmp_V4i);
   tmp_V2LLi = __builtin_ia32_psllq128(tmp_V2LLi, tmp_V2LLi);
+
+  tmp_V8s = __builtin_ia32_psllwi128(tmp_V8s, imm_i_0_8);
+  tmp_V4i = __builtin_ia32_pslldi128(tmp_V4i, imm_i_0_8);
+  tmp_V2LLi = __builtin_ia32_psllqi128(tmp_V2LLi, imm_i_0_8);
+  tmp_V8s = __builtin_ia32_psrlwi128(tmp_V8s, imm_i_0_8);
+  tmp_V4i = __builtin_ia32_psrldi128(tmp_V4i, imm_i_0_8);
+  tmp_V2LLi = __builtin_ia32_psrlqi128(tmp_V2LLi, imm_i_0_8);
+  tmp_V8s = __builtin_ia32_psrawi128(tmp_V8s, imm_i_0_8);
+  tmp_V4i = __builtin_ia32_psradi128(tmp_V4i, imm_i_0_8);
+
+  // Using non-immediate argument supported for gcc compatibility
   tmp_V8s = __builtin_ia32_psllwi128(tmp_V8s, tmp_i);
   tmp_V4i = __buil

r362601 - [ARM] Allow "-march=foo+fp" to vary with foo

2019-06-05 Thread Sjoerd Meijer via cfe-commits
Author: sjoerdmeijer
Date: Wed Jun  5 06:12:01 2019
New Revision: 362601

URL: http://llvm.org/viewvc/llvm-project?rev=362601&view=rev
Log:
[ARM] Allow "-march=foo+fp" to vary with foo

Now, when clang processes an argument of the form "-march=foo+x+y+z",
then instead of calling getArchExtFeature() for each of the extension
names "x", "y", "z" and appending the returned string to its list of
low-level subtarget features, it will call appendArchExtFeatures()
which does the appending itself.

The difference is that appendArchExtFeatures can add _more_ than one
low-level feature name to the output feature list if it has to, and
also, it gets told some information about what base architecture and
CPU the extension is going to go with, which means that "+fp" can now
mean something different for different CPUs. Namely, "+fp" now selects
whatever the _default_ FPU is for the selected CPU and/or
architecture, as defined in the ARM_ARCH or ARM_CPU_NAME macros in
ARMTargetParser.def.

On the clang side, I adjust DecodeARMFeatures to call the new
appendArchExtFeatures function in place of getArchExtFeature. This
means DecodeARMFeatures needs to be passed a CPU name and an ArchKind,
which meant changing its call sites to make those available, and also
sawing getLLVMArchSuffixForARM in half so that you can get an ArchKind
enum value out of it instead of a string.

Also, I add support here for the extension name "+fp.dp", which will
automatically look through the FPU list for something that looks just
like the default FPU except for also supporting double precision.

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp
cfe/trunk/lib/Driver/ToolChains/Arch/ARM.h
cfe/trunk/test/Driver/armv8.1m.main.c
cfe/trunk/test/Driver/armv8.1m.main.s

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp?rev=362601&r1=362600&r2=362601&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp Wed Jun  5 06:12:01 2019
@@ -72,15 +72,13 @@ static void getARMFPUFeatures(const Driv
 
 // Decode ARM features from string like +[no]featureA+[no]featureB+...
 static bool DecodeARMFeatures(const Driver &D, StringRef text,
+  StringRef CPU, llvm::ARM::ArchKind ArchKind,
   std::vector &Features) {
   SmallVector Split;
   text.split(Split, StringRef("+"), -1, false);
 
   for (StringRef Feature : Split) {
-StringRef FeatureName = llvm::ARM::getArchExtFeature(Feature);
-if (!FeatureName.empty())
-  Features.push_back(FeatureName);
-else
+if (!appendArchExtFeatures(CPU, ArchKind, Feature, Features))
   return false;
   }
   return true;
@@ -100,14 +98,16 @@ static void DecodeARMFeaturesFromCPU(con
 // getARMArch is used here instead of just checking the -march value in order
 // to handle -march=native correctly.
 static void checkARMArchName(const Driver &D, const Arg *A, const ArgList 
&Args,
- llvm::StringRef ArchName,
+ llvm::StringRef ArchName, llvm::StringRef CPUName,
  std::vector &Features,
  const llvm::Triple &Triple) {
   std::pair Split = ArchName.split("+");
 
   std::string MArch = arm::getARMArch(ArchName, Triple);
-  if (llvm::ARM::parseArch(MArch) == llvm::ARM::ArchKind::INVALID ||
-  (Split.second.size() && !DecodeARMFeatures(D, Split.second, Features)))
+  llvm::ARM::ArchKind ArchKind = llvm::ARM::parseArch(MArch);
+  if (ArchKind == llvm::ARM::ArchKind::INVALID ||
+  (Split.second.size() && !DecodeARMFeatures(
+D, Split.second, CPUName, ArchKind, Features)))
 D.Diag(clang::diag::err_drv_clang_unsupported) << A->getAsString(Args);
 }
 
@@ -119,8 +119,11 @@ static void checkARMCPUName(const Driver
   std::pair Split = CPUName.split("+");
 
   std::string CPU = arm::getARMTargetCPU(CPUName, ArchName, Triple);
-  if (arm::getLLVMArchSuffixForARM(CPU, ArchName, Triple).empty() ||
-  (Split.second.size() && !DecodeARMFeatures(D, Split.second, Features)))
+  llvm::ARM::ArchKind ArchKind =
+arm::getLLVMArchKindForARM(CPU, ArchName, Triple);
+  if (ArchKind == llvm::ARM::ArchKind::INVALID ||
+  (Split.second.size() && !DecodeARMFeatures(
+D, Split.second, CPU, ArchKind, Features)))
 D.Diag(clang::diag::err_drv_clang_unsupported) << A->getAsString(Args);
 }
 
@@ -327,25 +330,12 @@ void arm::getARMTargetFeatures(const Too
   if (ThreadPointer == arm::ReadTPMode::Cp15)
 Features.push_back("+read-tp-hard");
 
-  // Check -march. ClangAs gives preference to -Wa,-march=.
   const Arg *ArchArg = Args.getLastArg(options::OPT_march_EQ);
+  const Arg *CPUArg = Args.getLastArg(options::OPT_mcpu_EQ);
   StringRef Arch

[PATCH] D60697: [ARM] Allow "-march=foo+fp" to vary with foo.

2019-06-05 Thread Sjoerd Meijer via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL362600: [ARM] Allow "-march=foo+fp" to vary with 
foo (authored by SjoerdMeijer, committed by ).
Herald added a subscriber: kristina.

Changed prior to commit:
  https://reviews.llvm.org/D60697?vs=202934&id=203129#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D60697

Files:
  llvm/trunk/include/llvm/Support/ARMTargetParser.h
  llvm/trunk/lib/Support/ARMTargetParser.cpp

Index: llvm/trunk/include/llvm/Support/ARMTargetParser.h
===
--- llvm/trunk/include/llvm/Support/ARMTargetParser.h
+++ llvm/trunk/include/llvm/Support/ARMTargetParser.h
@@ -240,6 +240,8 @@
 StringRef getSubArch(ArchKind AK);
 StringRef getArchExtName(unsigned ArchExtKind);
 StringRef getArchExtFeature(StringRef ArchExt);
+bool appendArchExtFeatures(StringRef CPU, ARM::ArchKind AK, StringRef ArchExt,
+   std::vector &Features);
 StringRef getHWDivName(unsigned HWDivKind);
 
 // Information by Name
Index: llvm/trunk/lib/Support/ARMTargetParser.cpp
===
--- llvm/trunk/lib/Support/ARMTargetParser.cpp
+++ llvm/trunk/lib/Support/ARMTargetParser.cpp
@@ -485,22 +485,85 @@
   return StringRef();
 }
 
-StringRef ARM::getArchExtFeature(StringRef ArchExt) {
-  if (ArchExt.startswith("no")) {
-StringRef ArchExtBase(ArchExt.substr(2));
-for (const auto AE : ARCHExtNames) {
-  if (AE.NegFeature && ArchExtBase == AE.getName())
-return StringRef(AE.NegFeature);
-}
+static bool stripNegationPrefix(StringRef &Name) {
+  if (Name.startswith("no")) {
+Name = Name.substr(2);
+return true;
   }
+  return false;
+}
+
+StringRef ARM::getArchExtFeature(StringRef ArchExt) {
+  bool Negated = stripNegationPrefix(ArchExt);
   for (const auto AE : ARCHExtNames) {
 if (AE.Feature && ArchExt == AE.getName())
-  return StringRef(AE.Feature);
+  return StringRef(Negated ? AE.NegFeature : AE.Feature);
   }
 
   return StringRef();
 }
 
+static unsigned findDoublePrecisionFPU(unsigned InputFPUKind) {
+  const ARM::FPUName &InputFPU = ARM::FPUNames[InputFPUKind];
+
+  // If the input FPU already supports double-precision, then there
+  // isn't any different FPU we can return here.
+  //
+  // The current available FPURestriction values are None (no
+  // restriction), D16 (only 16 d-regs) and SP_D16 (16 d-regs
+  // and single precision only); there's no value representing
+  // SP restriction without D16. So this test just means 'is it
+  // SP only?'.
+  if (InputFPU.Restriction != ARM::FPURestriction::SP_D16)
+return ARM::FK_INVALID;
+
+  // Otherwise, look for an FPU entry with all the same fields, except
+  // that SP_D16 has been replaced with just D16, representing adding
+  // double precision and not changing anything else.
+  for (const ARM::FPUName &CandidateFPU : ARM::FPUNames) {
+if (CandidateFPU.FPUVer == InputFPU.FPUVer &&
+CandidateFPU.NeonSupport == InputFPU.NeonSupport &&
+CandidateFPU.Restriction == ARM::FPURestriction::D16) {
+  return CandidateFPU.ID;
+}
+  }
+
+  // nothing found
+  return ARM::FK_INVALID;
+}
+
+bool ARM::appendArchExtFeatures(
+  StringRef CPU, ARM::ArchKind AK, StringRef ArchExt,
+  std::vector &Features) {
+  StringRef StandardFeature = getArchExtFeature(ArchExt);
+  if (!StandardFeature.empty()) {
+Features.push_back(StandardFeature);
+return true;
+  }
+
+  const bool Negated = stripNegationPrefix(ArchExt);
+
+  if (CPU == "")
+CPU = "generic";
+
+  if (ArchExt == "fp" || ArchExt == "fp.dp") {
+unsigned FPUKind;
+if (ArchExt == "fp.dp") {
+  if (Negated) {
+Features.push_back("-fp64");
+return true;
+  }
+  FPUKind = findDoublePrecisionFPU(getDefaultFPU(CPU, AK));
+} else if (Negated) {
+  FPUKind = ARM::FK_NONE;
+} else {
+  FPUKind = getDefaultFPU(CPU, AK);
+}
+return ARM::getFPUFeatures(FPUKind, Features);
+  }
+  return false;
+}
+
 StringRef ARM::getHWDivName(unsigned HWDivKind) {
   for (const auto D : HWDivNames) {
 if (HWDivKind == D.ID)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r362604 - [Sema] Prevent binding incompatible addr space ref to temporaries

2019-06-05 Thread Anastasia Stulova via cfe-commits
Author: stulova
Date: Wed Jun  5 07:03:34 2019
New Revision: 362604

URL: http://llvm.org/viewvc/llvm-project?rev=362604&view=rev
Log:
[Sema] Prevent binding incompatible addr space ref to temporaries

References to arbitrary address spaces can't always be bound to
temporaries. This change extends the reference binding logic to
check that the address space of a temporary can be implicitly
converted to the address space in a reference when temporary
materialization is performed.

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


Added:
cfe/trunk/test/SemaOpenCLCXX/address-space-references.cl
Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Initialization.h
cfe/trunk/lib/Sema/SemaInit.cpp

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=362604&r1=362603&r2=362604&view=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Wed Jun  5 07:03:34 2019
@@ -460,21 +460,25 @@ public:
 Mask |= qs.Mask;
   }
 
-  /// Returns true if this address space is a superset of the other one.
+  /// Returns true if address space A is equal to or a superset of B.
   /// OpenCL v2.0 defines conversion rules (OpenCLC v2.0 s6.5.5) and notion of
   /// overlapping address spaces.
   /// CL1.1 or CL1.2:
   ///   every address space is a superset of itself.
   /// CL2.0 adds:
   ///   __generic is a superset of any address space except for __constant.
+  static bool isAddressSpaceSupersetOf(LangAS A, LangAS B) {
+// Address spaces must match exactly.
+return A == B ||
+   // Otherwise in OpenCLC v2.0 s6.5.5: every address space except
+   // for __constant can be used as __generic.
+   (A == LangAS::opencl_generic && B != LangAS::opencl_constant);
+  }
+
+  /// Returns true if the address space in these qualifiers is equal to or
+  /// a superset of the address space in the argument qualifiers.
   bool isAddressSpaceSupersetOf(Qualifiers other) const {
-return
-// Address spaces must match exactly.
-getAddressSpace() == other.getAddressSpace() ||
-// Otherwise in OpenCLC v2.0 s6.5.5: every address space except
-// for __constant can be used as __generic.
-(getAddressSpace() == LangAS::opencl_generic &&
- other.getAddressSpace() != LangAS::opencl_constant);
+return isAddressSpaceSupersetOf(getAddressSpace(), 
other.getAddressSpace());
   }
 
   /// Determines if these qualifiers compatibly include another set.

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=362604&r1=362603&r2=362604&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Jun  5 07:03:34 
2019
@@ -1857,6 +1857,9 @@ def err_reference_bind_failed : Error<
   "reference %diff{to %select{type|incomplete type}1 $ could not bind to an "
   "%select{rvalue|lvalue}2 of type $|could not bind to %select{rvalue|lvalue}2 
of "
   "incompatible type}0,3">;
+def err_reference_bind_temporary_addrspace : Error<
+  "reference of type %0 cannot bind to a temporary object because of "
+  "address space mismatch">;
 def err_reference_bind_init_list : Error<
   "reference to type %0 cannot bind to an initializer list">;
 def err_init_list_bad_dest_type : Error<

Modified: cfe/trunk/include/clang/Sema/Initialization.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Initialization.h?rev=362604&r1=362603&r2=362604&view=diff
==
--- cfe/trunk/include/clang/Sema/Initialization.h (original)
+++ cfe/trunk/include/clang/Sema/Initialization.h Wed Jun  5 07:03:34 2019
@@ -1012,6 +1012,9 @@ public:
 /// Reference binding drops qualifiers.
 FK_ReferenceInitDropsQualifiers,
 
+/// Reference with mismatching address space binding to temporary.
+FK_ReferenceAddrspaceMismatchTemporary,
+
 /// Reference binding failed.
 FK_ReferenceInitFailed,
 

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=362604&r1=362603&r2=362604&view=diff
==
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Wed Jun  5 07:03:34 2019
@@ -3344,6 +3344,7 @@ bool InitializationSequence::isAmbiguous
   case FK_NonConstLValueReferenceBindingToVectorElement:
   case FK_NonConstLValueReferenceBindingToUnrelated:
   case FK_RValueReferenceBindingToLValue:
+  case FK_ReferenceAddrspaceMis

[PATCH] D61318: [Sema] Prevent binding references with mismatching address spaces to temporaries

2019-06-05 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL362604: [Sema] Prevent binding incompatible addr space ref 
to temporaries (authored by stulova, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D61318?vs=197940&id=203140#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D61318

Files:
  cfe/trunk/include/clang/AST/Type.h
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/include/clang/Sema/Initialization.h
  cfe/trunk/lib/Sema/SemaInit.cpp
  cfe/trunk/test/SemaOpenCLCXX/address-space-references.cl

Index: cfe/trunk/lib/Sema/SemaInit.cpp
===
--- cfe/trunk/lib/Sema/SemaInit.cpp
+++ cfe/trunk/lib/Sema/SemaInit.cpp
@@ -3344,6 +3344,7 @@
   case FK_NonConstLValueReferenceBindingToVectorElement:
   case FK_NonConstLValueReferenceBindingToUnrelated:
   case FK_RValueReferenceBindingToLValue:
+  case FK_ReferenceAddrspaceMismatchTemporary:
   case FK_ReferenceInitDropsQualifiers:
   case FK_ReferenceInitFailed:
   case FK_ConversionFailed:
@@ -4837,9 +4838,16 @@
 
   Sequence.AddReferenceBindingStep(cv1T1IgnoreAS, /*bindingTemporary=*/true);
 
-  if (T1Quals.hasAddressSpace())
+  if (T1Quals.hasAddressSpace()) {
+if (!Qualifiers::isAddressSpaceSupersetOf(T1Quals.getAddressSpace(),
+  LangAS::Default)) {
+  Sequence.SetFailed(
+  InitializationSequence::FK_ReferenceAddrspaceMismatchTemporary);
+  return;
+}
 Sequence.AddQualificationConversionStep(cv1T1, isLValueRef ? VK_LValue
: VK_XValue);
+  }
 }
 
 /// Attempt character array initialization from a string literal
@@ -8516,6 +8524,11 @@
   << Args[0]->getSourceRange();
 break;
 
+  case FK_ReferenceAddrspaceMismatchTemporary:
+S.Diag(Kind.getLocation(), diag::err_reference_bind_temporary_addrspace)
+<< DestType << Args[0]->getSourceRange();
+break;
+
   case FK_ReferenceInitDropsQualifiers: {
 QualType SourceType = OnlyArg->getType();
 QualType NonRefType = DestType.getNonReferenceType();
@@ -8851,6 +8864,10 @@
   OS << "reference initialization drops qualifiers";
   break;
 
+case FK_ReferenceAddrspaceMismatchTemporary:
+  OS << "reference with mismatching address space bound to temporary";
+  break;
+
 case FK_ReferenceInitFailed:
   OS << "reference initialization failed";
   break;
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1857,6 +1857,9 @@
   "reference %diff{to %select{type|incomplete type}1 $ could not bind to an "
   "%select{rvalue|lvalue}2 of type $|could not bind to %select{rvalue|lvalue}2 of "
   "incompatible type}0,3">;
+def err_reference_bind_temporary_addrspace : Error<
+  "reference of type %0 cannot bind to a temporary object because of "
+  "address space mismatch">;
 def err_reference_bind_init_list : Error<
   "reference to type %0 cannot bind to an initializer list">;
 def err_init_list_bad_dest_type : Error<
Index: cfe/trunk/include/clang/AST/Type.h
===
--- cfe/trunk/include/clang/AST/Type.h
+++ cfe/trunk/include/clang/AST/Type.h
@@ -460,21 +460,25 @@
 Mask |= qs.Mask;
   }
 
-  /// Returns true if this address space is a superset of the other one.
+  /// Returns true if address space A is equal to or a superset of B.
   /// OpenCL v2.0 defines conversion rules (OpenCLC v2.0 s6.5.5) and notion of
   /// overlapping address spaces.
   /// CL1.1 or CL1.2:
   ///   every address space is a superset of itself.
   /// CL2.0 adds:
   ///   __generic is a superset of any address space except for __constant.
+  static bool isAddressSpaceSupersetOf(LangAS A, LangAS B) {
+// Address spaces must match exactly.
+return A == B ||
+   // Otherwise in OpenCLC v2.0 s6.5.5: every address space except
+   // for __constant can be used as __generic.
+   (A == LangAS::opencl_generic && B != LangAS::opencl_constant);
+  }
+
+  /// Returns true if the address space in these qualifiers is equal to or
+  /// a superset of the address space in the argument qualifiers.
   bool isAddressSpaceSupersetOf(Qualifiers other) const {
-return
-// Address spaces must match exactly.
-getAddressSpace() == other.getAddressSpace() ||
-// Otherwise in OpenCLC v2.0 s6.5.5: every address space except
-// for __constant can be used as __generic.
-(getAddressSpace() == LangAS::opencl_generic &&
- other.getAddressSpace() != LangAS::opencl_constant);
+retur

r362607 - Avoid using NoThrow Exception Specifier in non-C++ Modes.

2019-06-05 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Wed Jun  5 07:10:39 2019
New Revision: 362607

URL: http://llvm.org/viewvc/llvm-project?rev=362607&view=rev
Log:
Avoid using NoThrow Exception Specifier in non-C++ Modes.

As reported in https://bugs.llvm.org/show_bug.cgi?id=42113, there are a
number of locations in Clang where it is assumed that exception
specifications are only valid in C++ mode. Since the original
justification for the NoThrow Exception Specifier Type was C++ related,
this patch just makes C mode use the attribute-based nothrow handling.

Additionally, I noticed that the handling of non-prototype functions
regressed the behavior of the nothrow attribute, in part because it is
was listed in the function type macro(which I did in the previous
patch).  In reality, it should only be doing so in a conditional nature,
so this patch removes it there and puts it directly in the switch to be
handled correctly.

Added:
cfe/trunk/test/Sema/attr-nothrow.c   (with props)
Modified:
cfe/trunk/include/clang/Sema/ParsedAttr.h
cfe/trunk/lib/Sema/SemaType.cpp

Modified: cfe/trunk/include/clang/Sema/ParsedAttr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ParsedAttr.h?rev=362607&r1=362606&r2=362607&view=diff
==
--- cfe/trunk/include/clang/Sema/ParsedAttr.h (original)
+++ cfe/trunk/include/clang/Sema/ParsedAttr.h Wed Jun  5 07:10:39 2019
@@ -440,7 +440,7 @@ public:
   }
 
   bool isUsedAsTypeAttr() const { return UsedAsTypeAttr; }
-  void setUsedAsTypeAttr() { UsedAsTypeAttr = true; }
+  void setUsedAsTypeAttr(bool Used = true) { UsedAsTypeAttr = Used; }
 
   /// True if the attribute is specified using '#pragma clang attribute'.
   bool isPragmaClangAttribute() const { return IsPragmaClangAttribute; }

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=362607&r1=362606&r2=362607&view=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Wed Jun  5 07:10:39 2019
@@ -130,7 +130,6 @@ static void diagnoseBadTypeAttribute(Sem
   case ParsedAttr::AT_Regparm: 
\
   case ParsedAttr::AT_AnyX86NoCallerSavedRegisters:
\
   case ParsedAttr::AT_AnyX86NoCfCheck: 
\
-  case ParsedAttr::AT_NoThrow: 
\
 CALLING_CONV_ATTRS_CASELIST
 
 // Microsoft-specific type qualifiers.
@@ -6947,23 +6946,17 @@ static bool handleFunctionTypeAttr(TypeP
   }
 
   if (attr.getKind() == ParsedAttr::AT_NoThrow) {
-if (S.CheckAttrNoArgs(attr))
-  return true;
-
 // Delay if this is not a function type.
 if (!unwrapped.isFunctionType())
   return false;
 
-// Otherwise we can process right away.
-auto *Proto = unwrapped.get()->getAs();
-
-// In the case where this is a FunctionNoProtoType instead of a
-// FunctionProtoType, let the existing NoThrowAttr implementation do its
-// thing.
-if (!Proto)
-  return false;
+if (S.CheckAttrNoArgs(attr)) {
+  attr.setInvalid();
+  return true;
+}
 
-attr.setUsedAsTypeAttr();
+// Otherwise we can process right away.
+auto *Proto = unwrapped.get()->castAs();
 
 // MSVC ignores nothrow if it is in conflict with an explicit exception
 // specification.
@@ -7668,6 +7661,12 @@ static void processTypeAttrs(TypeProcess
 attr.setInvalid();
   break;
 
+case ParsedAttr::AT_NoThrow:
+// Exception Specifications aren't generally supported in C mode throughout
+// clang, so revert to attribute-based handling for C.
+  if (!state.getSema().getLangOpts().CPlusPlus)
+break;
+  LLVM_FALLTHROUGH;
 FUNCTION_TYPE_ATTRS_CASELIST:
   attr.setUsedAsTypeAttr();
 

Added: cfe/trunk/test/Sema/attr-nothrow.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-nothrow.c?rev=362607&view=auto
==
--- cfe/trunk/test/Sema/attr-nothrow.c (added)
+++ cfe/trunk/test/Sema/attr-nothrow.c Wed Jun  5 07:10:39 2019
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 %s -verify
+// RUN: %clang_cc1 %s -ast-dump | FileCheck %s
+// expected-no-diagnostics
+
+// PR42113: The following caused an assertion in mergeFunctionTypes
+// because it causes one side to have an exception specification, which
+// isn't typically supported in C.
+void PR42113a();
+void PR42113a(void) __attribute__((nothrow));
+// CHECK: FunctionDecl {{.*}} PR42113a
+// CHECK: FunctionDecl {{.*}} PR42113a
+// CHECK: NoThrowAttr
+void PR42113b() __attribute__((nothrow));
+// CHECK: FunctionDecl {{.*}} PR42113b
+// CHECK: NoThrowAttr
+ __attribute__((nothrow)) void PR42113c();
+// CHECK: FunctionDecl {{.*}} PR42113c
+// CHECK: NoThrowAttr

Propchang

[PATCH] D33841: [clang-tidy] redundant keyword check

2019-06-05 Thread Daniel Kolozsvari via Phabricator via cfe-commits
koldaniel updated this revision to Diff 203154.
koldaniel added a comment.

Updating warnings.


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

https://reviews.llvm.org/D33841

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/readability/RedundantExternCheck.cpp
  clang-tidy/readability/RedundantExternCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/readability-redundant-extern.rst
  test/clang-tidy/readability-redundant-extern.cpp

Index: test/clang-tidy/readability-redundant-extern.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-redundant-extern.cpp
@@ -0,0 +1,74 @@
+// RUN: %check_clang_tidy %s readability-redundant-extern %t
+
+extern int f();
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: redundant 'extern' keyword [readability-redundant-extern]
+// CHECK-FIXES: int f();
+
+int extern f() { return 0; }
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: redundant 'extern' keyword [readability-redundant-extern]
+// CHECK-FIXES: int f() { return 0; }
+
+extern "C" int g();
+// CHECK-FIXES: extern "C" int g();
+
+extern "C" int g() { return 0; }
+// CHECK-FIXES: extern "C" int g() { return 0; }
+
+extern "C++" int h();
+// CHECK-FIXES: extern "C++" int h();
+
+extern "C++" int h() { return 0; }
+// CHECK-FIXES: extern "C++" int h() { return 0; }
+
+inline extern void foo_inline();
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: redundant 'extern' keyword [readability-redundant-extern]
+// CHECK-FIXES: inline void foo_inline();
+
+#define FOO_EXTERN extern
+FOO_EXTERN void foo_macro_1();
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: redundant 'extern' keyword [readability-redundant-extern]
+// CHECK-FIXES: FOO_EXTERN void foo_macro_1();
+
+#define FOO_INLINE inline
+FOO_INLINE extern void foo_macro_2();
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: redundant 'extern' keyword [readability-redundant-extern]
+// CHECK-FIXES: FOO_INLINE extern void foo_macro_2();
+
+#define FOO_EXTERN_INLINE inline extern
+FOO_EXTERN_INLINE void foo_macro_3();
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: redundant 'extern' keyword [readability-redundant-extern]
+// CHECK-FIXES: FOO_EXTERN_INLINE void foo_macro_3();
+
+void file_scope();
+// CHECK-FIXES: void file_scope();
+
+void another_file_scope(int _extern);
+// CHECK-FIXES: void another_file_scope(int _extern);
+
+namespace {
+extern void namespace_1();
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: 'extern' keyword has no effect [readability-redundant-extern]
+// CHECK-FIXES: void namespace_1();
+}
+
+namespace a {
+namespace {
+namespace b {
+extern void namespace_2();
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: 'extern' keyword has no effect [readability-redundant-extern]
+// CHECK-FIXES: void namespace_2();
+}
+}
+}
+
+namespace {
+extern "C" void namespace_3();
+// CHECK-FIXES: extern "C" void namespace_3();
+}
+
+#define FOO_EXTERN extern
+typedef int extern_int;
+
+extern_int FOO_EXTERN typedef_extern_foo();
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: redundant 'extern' keyword [readability-redundant-extern]
+// CHECK-FIXES: extern_int FOO_EXTERN typedef_extern_foo();
Index: docs/clang-tidy/checks/readability-redundant-extern.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/readability-redundant-extern.rst
@@ -0,0 +1,15 @@
+.. title:: clang-tidy - readability-redundant-extern
+
+readability-redundant-extern
+
+
+Removes the redundant or unnecessary ``extern`` keywords from code.
+
+``extern`` is redundant in function declarations, and has no effect in namespaces
+
+The default language linkage is C++, so without any additional parameters it is redundant (extern "C++" can also be redundant, but it depends on the context). In C context (extern "C") the situation is the same, extern keyword is redundant for function declarations
+
+.. code-block:: c++
+
+  extern void h();
+
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -207,6 +207,11 @@
   but either don't specify it or the clause is specified but with the kind
   other than ``none``, and suggests to use the ``default(none)`` clause.
 
+- New :doc:`readability-redundant-extern
+  ` check.
+
+  Removes the redundant ``extern`` keywords.
+
 Improvements to clang-include-fixer
 ---
 
Index: clang-tidy/readability/RedundantExternCheck.h
===
--- /dev/null
+++ clang-tidy/readability/RedundantExternCheck.h
@@ -0,0 +1,34 @@
+//===--- RedundantExternCheck.h - clang-tidy *- 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

r362611 - [OpenCL][PR42031] Prevent deducing addr space in type alias.

2019-06-05 Thread Anastasia Stulova via cfe-commits
Author: stulova
Date: Wed Jun  5 07:50:01 2019
New Revision: 362611

URL: http://llvm.org/viewvc/llvm-project?rev=362611&view=rev
Log:
[OpenCL][PR42031] Prevent deducing addr space in type alias.
 
Similar to typedefs we shouldn't deduce addr space in
type alias.
 
Differential Revision: https://reviews.llvm.org/D62591


Modified:
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/SemaOpenCLCXX/address-space-deduction.cl

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=362611&r1=362610&r2=362611&view=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Wed Jun  5 07:50:01 2019
@@ -7401,6 +7401,9 @@ static void deduceOpenCLImplicitAddrSpac
   (D.getContext() == DeclaratorContext::MemberContext &&
(!IsPointee &&
 D.getDeclSpec().getStorageClassSpec() != DeclSpec::SCS_static)) ||
+  // Do not deduce addr space of non-pointee in type alias because it
+  // doesn't define any object.
+  (D.getContext() == DeclaratorContext::AliasDeclContext && !IsPointee) ||
   // Do not deduce addr space for types used to define a typedef and the
   // typedef itself, except the pointee type of a pointer type which is 
used
   // to define the typedef.

Modified: cfe/trunk/test/SemaOpenCLCXX/address-space-deduction.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCLCXX/address-space-deduction.cl?rev=362611&r1=362610&r2=362611&view=diff
==
--- cfe/trunk/test/SemaOpenCLCXX/address-space-deduction.cl (original)
+++ cfe/trunk/test/SemaOpenCLCXX/address-space-deduction.cl Wed Jun  5 07:50:01 
2019
@@ -1,12 +1,26 @@
-//RUN: %clang_cc1 %s -cl-std=c++ -pedantic -ast-dump -verify
+//RUN: %clang_cc1 %s -cl-std=c++ -pedantic -ast-dump -verify | FileCheck %s
 
 //expected-no-diagnostics
 
-//CHECK: |-VarDecl  foo {{.*}} 'const __global int' constexpr cinit
+//CHECK: |-VarDecl {{.*}} foo 'const __global int'
 constexpr int foo = 0;
 
 class c {
 public:
-  //CHECK: `-VarDecl {{.*}} foo2 'const __global int' static constexpr cinit
+  //CHECK: `-VarDecl {{.*}} foo2 'const __global int'
   static constexpr int foo2 = 0;
 };
+
+struct c1 {};
+
+// We only deduce addr space in type alias in pointer types.
+//CHECK: TypeAliasDecl {{.*}} alias_c1 'c1'
+using alias_c1 = c1;
+//CHECK: TypeAliasDecl {{.*}} alias_c1_ptr '__generic c1 *'
+using alias_c1_ptr = c1 *;
+
+struct c2 {
+  alias_c1 y;
+  alias_c1_ptr ptr = &y;
+};
+


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


[PATCH] D62591: [OpenCL][PR42031] Prevent deducing addr space in type alias.

2019-06-05 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL362611: [OpenCL][PR42031] Prevent deducing addr space in 
type alias. (authored by stulova, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D62591?vs=202721&id=203156#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D62591

Files:
  cfe/trunk/lib/Sema/SemaType.cpp
  cfe/trunk/test/SemaOpenCLCXX/address-space-deduction.cl


Index: cfe/trunk/lib/Sema/SemaType.cpp
===
--- cfe/trunk/lib/Sema/SemaType.cpp
+++ cfe/trunk/lib/Sema/SemaType.cpp
@@ -7401,6 +7401,9 @@
   (D.getContext() == DeclaratorContext::MemberContext &&
(!IsPointee &&
 D.getDeclSpec().getStorageClassSpec() != DeclSpec::SCS_static)) ||
+  // Do not deduce addr space of non-pointee in type alias because it
+  // doesn't define any object.
+  (D.getContext() == DeclaratorContext::AliasDeclContext && !IsPointee) ||
   // Do not deduce addr space for types used to define a typedef and the
   // typedef itself, except the pointee type of a pointer type which is 
used
   // to define the typedef.
Index: cfe/trunk/test/SemaOpenCLCXX/address-space-deduction.cl
===
--- cfe/trunk/test/SemaOpenCLCXX/address-space-deduction.cl
+++ cfe/trunk/test/SemaOpenCLCXX/address-space-deduction.cl
@@ -1,12 +1,26 @@
-//RUN: %clang_cc1 %s -cl-std=c++ -pedantic -ast-dump -verify
+//RUN: %clang_cc1 %s -cl-std=c++ -pedantic -ast-dump -verify | FileCheck %s
 
 //expected-no-diagnostics
 
-//CHECK: |-VarDecl  foo {{.*}} 'const __global int' constexpr cinit
+//CHECK: |-VarDecl {{.*}} foo 'const __global int'
 constexpr int foo = 0;
 
 class c {
 public:
-  //CHECK: `-VarDecl {{.*}} foo2 'const __global int' static constexpr cinit
+  //CHECK: `-VarDecl {{.*}} foo2 'const __global int'
   static constexpr int foo2 = 0;
 };
+
+struct c1 {};
+
+// We only deduce addr space in type alias in pointer types.
+//CHECK: TypeAliasDecl {{.*}} alias_c1 'c1'
+using alias_c1 = c1;
+//CHECK: TypeAliasDecl {{.*}} alias_c1_ptr '__generic c1 *'
+using alias_c1_ptr = c1 *;
+
+struct c2 {
+  alias_c1 y;
+  alias_c1_ptr ptr = &y;
+};
+


Index: cfe/trunk/lib/Sema/SemaType.cpp
===
--- cfe/trunk/lib/Sema/SemaType.cpp
+++ cfe/trunk/lib/Sema/SemaType.cpp
@@ -7401,6 +7401,9 @@
   (D.getContext() == DeclaratorContext::MemberContext &&
(!IsPointee &&
 D.getDeclSpec().getStorageClassSpec() != DeclSpec::SCS_static)) ||
+  // Do not deduce addr space of non-pointee in type alias because it
+  // doesn't define any object.
+  (D.getContext() == DeclaratorContext::AliasDeclContext && !IsPointee) ||
   // Do not deduce addr space for types used to define a typedef and the
   // typedef itself, except the pointee type of a pointer type which is used
   // to define the typedef.
Index: cfe/trunk/test/SemaOpenCLCXX/address-space-deduction.cl
===
--- cfe/trunk/test/SemaOpenCLCXX/address-space-deduction.cl
+++ cfe/trunk/test/SemaOpenCLCXX/address-space-deduction.cl
@@ -1,12 +1,26 @@
-//RUN: %clang_cc1 %s -cl-std=c++ -pedantic -ast-dump -verify
+//RUN: %clang_cc1 %s -cl-std=c++ -pedantic -ast-dump -verify | FileCheck %s
 
 //expected-no-diagnostics
 
-//CHECK: |-VarDecl  foo {{.*}} 'const __global int' constexpr cinit
+//CHECK: |-VarDecl {{.*}} foo 'const __global int'
 constexpr int foo = 0;
 
 class c {
 public:
-  //CHECK: `-VarDecl {{.*}} foo2 'const __global int' static constexpr cinit
+  //CHECK: `-VarDecl {{.*}} foo2 'const __global int'
   static constexpr int foo2 = 0;
 };
+
+struct c1 {};
+
+// We only deduce addr space in type alias in pointer types.
+//CHECK: TypeAliasDecl {{.*}} alias_c1 'c1'
+using alias_c1 = c1;
+//CHECK: TypeAliasDecl {{.*}} alias_c1_ptr '__generic c1 *'
+using alias_c1_ptr = c1 *;
+
+struct c2 {
+  alias_c1 y;
+  alias_c1_ptr ptr = &y;
+};
+
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[Diffusion] rL358949: [PowerPC] [Clang] Port MMX intrinsics and basic test cases to Power

2019-06-05 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

> I think the name `ppc_wrappers` is accurate to describe its meaning that 
> wrapping the headers under standard library path or standard header search 
> path.

Thanks for clarifying this for me. In the case where all of the headers are 
expected to be present somewhere in the usual search path, I agree that the 
current directory structure would be okay given proper guards within the 
headers themselves.

> [ ... ] which I also prefer to use because it's easier to maintain headers 
> instead of modifying cpp code about toolchain class such as PPCLinuxToolChain 
> .



> We will use better way described above to guard those headers only in 64-bit 
> mode soon after other headers have been upstreamed.

That (controlling within the headers) sounds good to me. When that lands, then 
my understanding is that the `PPCLinuxToolChain` code would be adjusted to 
include `ppc_wrappers` in the search path in the general case. Please let me 
know if that's not the case. Thanks.


https://reviews.llvm.org/rL358949



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


[PATCH] D33841: [clang-tidy] redundant 'extern' keyword check

2019-06-05 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: clang-tidy/readability/RedundantExternCheck.cpp:30
+
+  if (FD->getStorageClass() != SC_Extern)
+return;

Can you do that in `registerMatchers()`?



Comment at: clang-tidy/readability/RedundantExternCheck.cpp:43-44
+
+  if (FD->getBeginLoc().isMacroID())
+return;
+

Similarly, do this in `registerMatchers()`



Comment at: clang-tidy/readability/RedundantExternCheck.cpp:49
+   *Result.SourceManager, getLangOpts());
+
+  int Offset = Text.find("extern");

`StringLiteral Extern = StringLiteral("extern");`



Comment at: clang-tidy/readability/RedundantExternCheck.cpp:50
+
+  int Offset = Text.find("extern");
+

Extern



Comment at: clang-tidy/readability/RedundantExternCheck.cpp:53
+  SourceRange ExternRange(BeginLoc.getLocWithOffset(Offset),
+  BeginLoc.getLocWithOffset(Offset + 
strlen("extern")));
+

Extern.size()



Comment at: clang-tidy/readability/RedundantExternCheck.cpp:59
+
+  if (!ExternText.equals("extern")) // Final check: typedefs, etc.
+return;

Extern



Comment at: docs/clang-tidy/checks/readability-redundant-extern.rst:10
+
+The default language linkage is C++, so without any additional parameters it 
is redundant (extern "C++" can also be redundant, but it depends on the 
context). In C context (extern "C") the situation is the same, extern keyword 
is redundant for function declarations
+

Please 80-char wrap



Comment at: docs/clang-tidy/checks/readability-redundant-extern.rst:14
+
+  extern void h();
+

More examples? A namespace one?


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

https://reviews.llvm.org/D33841



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


Re: r362551 - Convert MemberExpr creation and serialization to work the same way as

2019-06-05 Thread Richard Smith via cfe-commits
On Wed, 5 Jun 2019, 04:44 Benjamin Kramer via cfe-commits, <
cfe-commits@lists.llvm.org> wrote:

> It also crashes during clang selfhost with modules and libc++. Let me know
> if you need a precise reproducer command.
>

Yes, please.

I reverted this change and the dependent r362563 in r362597.
>

Thanks!

On Wed, Jun 5, 2019 at 9:37 AM Martin Storsjö via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> This broke building of Qt when using PCH. Selfcontained repro is a bit
>> hard to make though...
>>
>> // Martin
>>
>> On Tue, 4 Jun 2019, Richard Smith via cfe-commits wrote:
>>
>> > Author: rsmith
>> > Date: Tue Jun  4 14:29:28 2019
>> > New Revision: 362551
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=362551&view=rev
>> > Log:
>> > Convert MemberExpr creation and serialization to work the same way as
>> > most / all other Expr subclasses.
>> >
>> > Modified:
>> >cfe/trunk/include/clang/AST/Expr.h
>> >cfe/trunk/include/clang/AST/Stmt.h
>> >cfe/trunk/lib/AST/DeclBase.cpp
>> >cfe/trunk/lib/AST/Expr.cpp
>> >cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp
>> >cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp
>> >cfe/trunk/lib/Sema/SemaExprCXX.cpp
>> >cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
>> >cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
>> >
>> > Modified: cfe/trunk/include/clang/AST/Expr.h
>> > URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=362551&r1=362550&r2=362551&view=diff
>> >
>> ==
>> > --- cfe/trunk/include/clang/AST/Expr.h (original)
>> > +++ cfe/trunk/include/clang/AST/Expr.h Tue Jun  4 14:29:28 2019
>> > @@ -2735,6 +2735,7 @@ class MemberExpr final
>> > ASTTemplateKWAndArgsInfo,
>> > TemplateArgumentLoc> {
>> >   friend class ASTReader;
>> > +  friend class ASTStmtReader;
>> >   friend class ASTStmtWriter;
>> >   friend TrailingObjects;
>> >
>> > @@ -2769,49 +2770,38 @@ class MemberExpr final
>> > return MemberExprBits.HasTemplateKWAndArgsInfo;
>> >   }
>> >
>> > -public:
>> > -  MemberExpr(Expr *base, bool isarrow, SourceLocation operatorloc,
>> > - ValueDecl *memberdecl, const DeclarationNameInfo
>> &NameInfo,
>> > - QualType ty, ExprValueKind VK, ExprObjectKind OK)
>> > -  : Expr(MemberExprClass, ty, VK, OK, base->isTypeDependent(),
>> > - base->isValueDependent(),
>> base->isInstantiationDependent(),
>> > - base->containsUnexpandedParameterPack()),
>> > -Base(base), MemberDecl(memberdecl),
>> MemberDNLoc(NameInfo.getInfo()),
>> > -MemberLoc(NameInfo.getLoc()) {
>> > -assert(memberdecl->getDeclName() == NameInfo.getName());
>> > -MemberExprBits.IsArrow = isarrow;
>> > -MemberExprBits.HasQualifierOrFoundDecl = false;
>> > -MemberExprBits.HasTemplateKWAndArgsInfo = false;
>> > -MemberExprBits.HadMultipleCandidates = false;
>> > -MemberExprBits.OperatorLoc = operatorloc;
>> > -  }
>> > -
>> > -  // NOTE: this constructor should be used only when it is known that
>> > -  // the member name can not provide additional syntactic info
>> > -  // (i.e., source locations for C++ operator names or type source info
>> > -  // for constructors, destructors and conversion operators).
>> > -  MemberExpr(Expr *base, bool isarrow, SourceLocation operatorloc,
>> > - ValueDecl *memberdecl, SourceLocation l, QualType ty,
>> > - ExprValueKind VK, ExprObjectKind OK)
>> > -  : Expr(MemberExprClass, ty, VK, OK, base->isTypeDependent(),
>> > - base->isValueDependent(),
>> base->isInstantiationDependent(),
>> > - base->containsUnexpandedParameterPack()),
>> > -Base(base), MemberDecl(memberdecl), MemberDNLoc(),
>> MemberLoc(l) {
>> > -MemberExprBits.IsArrow = isarrow;
>> > -MemberExprBits.HasQualifierOrFoundDecl = false;
>> > -MemberExprBits.HasTemplateKWAndArgsInfo = false;
>> > -MemberExprBits.HadMultipleCandidates = false;
>> > -MemberExprBits.OperatorLoc = operatorloc;
>> > -  }
>> > +  MemberExpr(Expr *Base, bool IsArrow, SourceLocation OperatorLoc,
>> > + ValueDecl *MemberDecl, const DeclarationNameInfo
>> &NameInfo,
>> > + QualType T, ExprValueKind VK, ExprObjectKind OK);
>> > +  MemberExpr(EmptyShell Empty)
>> > +  : Expr(MemberExprClass, Empty), Base(), MemberDecl() {}
>> >
>> > -  static MemberExpr *Create(const ASTContext &C, Expr *base, bool
>> isarrow,
>> > +public:
>> > +  static MemberExpr *Create(const ASTContext &C, Expr *Base, bool
>> IsArrow,
>> > SourceLocation OperatorLoc,
>> > NestedNameSpecifierLoc QualifierLoc,
>> > -SourceLocation TemplateKWLoc, ValueDecl
>> *memberdecl,
>> > -DeclAccessPair founddecl,
>> > +SourceLoc

[PATCH] D62363: [X86] Enable intrinsics that convert float and bf16 data to each other

2019-06-05 Thread Kan Shengchen via Phabricator via cfe-commits
skan updated this revision to Diff 203170.
skan added a comment.

When target feature `avx512bf16` is enabled, `avx512vl` is not enabled 
implicity for some reasons by now. But `_mm_cvtness_sbh`, `_mm256_cvtpbh_ps` , 
`_mm256_maskz_cvtpbh_ps` , `_mm256_mask_cvtpbh_ps` need `avx512vl` feature. So 
I move their definition from `avx512bf16intrin` to `avx512vlbf16intrin.h`, and 
move corresponding test cases from `avx512bf16-builtins.c` to 
`avx512vlbf16-builtins.c`.

And the test for `_mm_cvtness_sbh` is fixed in the new patch.


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

https://reviews.llvm.org/D62363

Files:
  include/clang/Basic/BuiltinsX86.def
  lib/CodeGen/CGBuiltin.cpp
  lib/Headers/avx512bf16intrin.h
  lib/Headers/avx512vlbf16intrin.h
  test/CodeGen/avx512bf16-builtins.c
  test/CodeGen/avx512vlbf16-builtins.c

Index: test/CodeGen/avx512vlbf16-builtins.c
===
--- test/CodeGen/avx512vlbf16-builtins.c
+++ test/CodeGen/avx512vlbf16-builtins.c
@@ -161,3 +161,39 @@
   // CHECK: ret <8 x float> %{{.*}}
   return _mm256_mask_dpbf16_ps(D, U, A, B);
 }
+
+__bfloat16 test_mm_cvtness_sbh(float A) {
+  // CHECK-LABEL: @test_mm_cvtness_sbh
+  // CHECK: @llvm.x86.avx512bf16.mask.cvtneps2bf16.128
+  // CHECK: ret i16 %{{.*}}
+  return _mm_cvtness_sbh(A);
+}
+
+__m256 test_mm256_cvtpbh_ps(__m128bh A) {
+  // CHECK-LABEL: @test_mm256_cvtpbh_ps
+  // CHECK: sext <8 x i16> %{{.*}} to <8 x i32>
+  // CHECK: @llvm.x86.avx2.pslli.d
+  // CHECK: bitcast <4 x i64> %{{.*}} to <8 x float>
+  // CHECK: ret <8 x float> %{{.*}}
+  return _mm256_cvtpbh_ps(A);
+}
+
+__m256 test_mm256_maskz_cvtpbh_ps(__mmask8 M, __m128bh A) {
+  // CHECK-LABEL: @test_mm256_maskz_cvtpbh_ps
+  // CHECK: sext <8 x i16> %{{.*}} to <8 x i32>
+  // CHECK: select <8 x i1> %{{.*}}, <8 x i32> %{{.*}}, <8 x i32> %{{.*}}
+  // CHECK: @llvm.x86.avx2.pslli.d
+  // CHECK: bitcast <4 x i64> %{{.*}} to <8 x float>
+  // CHECK: ret <8 x float> %{{.*}}
+  return _mm256_maskz_cvtpbh_ps(M, A);
+}
+
+__m256 test_mm256_mask_cvtpbh_ps(__m256 S, __mmask8 M, __m128bh A) {
+  // CHECK-LABEL: @test_mm256_mask_cvtpbh_ps
+  // CHECK: sext <8 x i16> %{{.*}} to <8 x i32>
+  // CHECK: @llvm.x86.avx2.pslli.d
+  // CHECK: select <8 x i1> %{{.*}}, <8 x i32> %{{.*}}, <8 x i32> %{{.*}}
+  // CHECK: bitcast <4 x i64> %{{.*}} to <8 x float>
+  // CHECK: ret <8 x float> %{{.*}}
+  return _mm256_mask_cvtpbh_ps(S, M, A);
+}
Index: test/CodeGen/avx512bf16-builtins.c
===
--- test/CodeGen/avx512bf16-builtins.c
+++ test/CodeGen/avx512bf16-builtins.c
@@ -4,46 +4,55 @@
 
 #include 
 
-__m512bh test_mm512_cvtne2ps2bf16(__m512 A, __m512 B) {
-  // CHECK-LABEL: @test_mm512_cvtne2ps2bf16
+float test_mm_cvtsbh_ss(__bfloat16 A) {
+  // CHECK-LABEL: @test_mm_cvtsbh_ss
+  // CHECK: zext i16 %{{.*}} to i32
+  // CHECK: shl i32 %{{.*}}, 16
+  // CHECK: bitcast i32 %{{.*}} to float
+  // CHECK: ret float %{{.*}}
+  return _mm_cvtsbh_ss(A);
+}
+
+__m512bh test_mm512_cvtne2ps_pbh(__m512 A, __m512 B) {
+  // CHECK-LABEL: @test_mm512_cvtne2ps_pbh
   // CHECK: @llvm.x86.avx512bf16.cvtne2ps2bf16.512
   // CHECK: ret <32 x i16> %{{.*}}
   return _mm512_cvtne2ps_pbh(A, B);
 }
 
-__m512bh test_mm512_maskz_cvtne2ps2bf16(__m512 A, __m512 B, __mmask32 U) {
-  // CHECK-LABEL: @test_mm512_maskz_cvtne2ps2bf16
+__m512bh test_mm512_maskz_cvtne2ps_pbh(__m512 A, __m512 B, __mmask32 U) {
+  // CHECK-LABEL: @test_mm512_maskz_cvtne2ps_pbh
   // CHECK: @llvm.x86.avx512bf16.cvtne2ps2bf16.512
   // CHECK: select <32 x i1> %{{.*}}, <32 x i16> %{{.*}}, <32 x i16> %{{.*}}
   // CHECK: ret <32 x i16> %{{.*}}
   return _mm512_maskz_cvtne2ps_pbh(U, A, B);
 }
 
-__m512bh test_mm512_mask_cvtne2ps2bf16(__m512bh C, __mmask32 U, __m512 A, __m512 B) {
-  // CHECK-LABEL: @test_mm512_mask_cvtne2ps2bf16
+__m512bh test_mm512_mask_cvtne2ps_pbh(__m512bh C, __mmask32 U, __m512 A, __m512 B) {
+  // CHECK-LABEL: @test_mm512_mask_cvtne2ps_pbh
   // CHECK: @llvm.x86.avx512bf16.cvtne2ps2bf16.512
   // CHECK: select <32 x i1> %{{.*}}, <32 x i16> %{{.*}}, <32 x i16> %{{.*}}
   // CHECK: ret <32 x i16> %{{.*}}
   return _mm512_mask_cvtne2ps_pbh(C, U, A, B);
 }
 
-__m256bh test_mm512_cvtneps2bf16(__m512 A) {
-  // CHECK-LABEL: @test_mm512_cvtneps2bf16
+__m256bh test_mm512_cvtneps_pbh(__m512 A) {
+  // CHECK-LABEL: @test_mm512_cvtneps_pbh
   // CHECK: @llvm.x86.avx512bf16.cvtneps2bf16.512
   // CHECK: ret <16 x i16> %{{.*}}
   return _mm512_cvtneps_pbh(A);
 }
 
-__m256bh test_mm512_mask_cvtneps2bf16(__m256bh C, __mmask16 U, __m512 A) {
-  // CHECK-LABEL: @test_mm512_mask_cvtneps2bf16
+__m256bh test_mm512_mask_cvtneps_pbh(__m256bh C, __mmask16 U, __m512 A) {
+  // CHECK-LABEL: @test_mm512_mask_cvtneps_pbh
   // CHECK: @llvm.x86.avx512bf16.cvtneps2bf16.512
   // CHECK: select <16 x i1> %{{.*}}, <16 x i16> %{{.*}}, <16 x i16> %{{.*}}
   // CHECK: ret <16 x i16> %{{.*}}
   return _mm512_mask_cvtneps_pbh(C, U, A);
 }
 

[PATCH] D60828: [ARM] Fix armv8 features tree and add fp16fml

2019-06-05 Thread Diogo N. Sampaio via Phabricator via cfe-commits
dnsampaio abandoned this revision.
dnsampaio added a comment.

Fixed.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60828



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


[PATCH] D58060: Fix diagnostic for addr spaces in reference binding

2019-06-05 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia abandoned this revision.
Anastasia added a comment.

Due to my recent commits I had to changed this slightly so it is now under a 
new review: https://reviews.llvm.org/D62914


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

https://reviews.llvm.org/D58060



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


[PATCH] D62914: [Sema] Fix diagnostic for addr spaces in reference binding

2019-06-05 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia created this revision.
Anastasia added a reviewer: rjmccall.
Herald added subscribers: ebevhan, javed.absar.

Extend reference binding behavior to account for address spaces. This change 
also fixes the diagnostic wording (for qualifier mismatch in reference binding) 
and simplifies it by using Qualifiers print method.

This patch is rebased from https://reviews.llvm.org/D58060 that got lost 
somehow.


https://reviews.llvm.org/D62914

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaInit.cpp
  test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp
  test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-var.cpp
  test/CXX/expr/expr.post/expr.static.cast/p3-p4-0x.cpp
  test/CXX/expr/expr.prim/expr.prim.lambda/p16.cpp
  test/Misc/diag-template-diffing.cpp
  test/SemaCXX/builtins-arm.cpp
  test/SemaCXX/err_reference_bind_drops_quals.cpp
  test/SemaCXX/references.cpp
  test/SemaOpenCLCXX/address-space-references.cl

Index: test/SemaOpenCLCXX/address-space-references.cl
===
--- test/SemaOpenCLCXX/address-space-references.cl
+++ test/SemaOpenCLCXX/address-space-references.cl
@@ -3,3 +3,13 @@
 __global const int& f(__global float &ref) {
   return ref; // expected-error{{reference of type 'const __global int &' cannot bind to a temporary object because of address space mismatch}}
 }
+
+int bar(const __global unsigned int &i); // expected-note{{passing argument to parameter 'i' here}}
+//FIXME: With the overload below the call should be resolved
+// successfully. However, current overload resolution logic
+// can't detect this case and therefore fails.
+int bar(const unsigned int &i);
+
+void foo() {
+  bar(1) // expected-error{{binding reference of type 'const __global unsigned int' to value of type 'int' changes address space}}
+}
Index: test/SemaCXX/references.cpp
===
--- test/SemaCXX/references.cpp
+++ test/SemaCXX/references.cpp
@@ -55,13 +55,13 @@
 void test5() {
   //  const double& rcd2 = 2; // rcd2 refers to temporary with value 2.0
   const volatile int cvi = 1;
-  const int& r = cvi; // expected-error{{binding value of type 'const volatile int' to reference to type 'const int' drops 'volatile' qualifier}}
+  const int& r = cvi; // expected-error{{binding reference of type 'const int' to value of type 'const volatile int' drops 'volatile' qualifier}}
 
 #if __cplusplus >= 201103L
-  const int& r2{cvi}; // expected-error{{binding value of type 'const volatile int' to reference to type 'const int' drops 'volatile' qualifier}}
+  const int& r2{cvi}; // expected-error{{binding reference of type 'const int' to value of type 'const volatile int' drops 'volatile' qualifier}}
 
   const int a = 2;
-  int& r3{a}; // expected-error{{binding value of type 'const int' to reference to type 'int' drops 'const'}}
+  int& r3{a}; // expected-error{{binding reference of type 'int' to value of type 'const int' drops 'const' qualifier}}
 
   const int&& r4{a}; // expected-error{{rvalue reference to type 'const int' cannot bind to lvalue of type 'const int'}}
 
Index: test/SemaCXX/err_reference_bind_drops_quals.cpp
===
--- test/SemaCXX/err_reference_bind_drops_quals.cpp
+++ test/SemaCXX/err_reference_bind_drops_quals.cpp
@@ -6,31 +6,31 @@
volatile ptr vp, const volatile ptr cvp, restrict volatile ptr rvp,
const restrict volatile ptr crvp) {
   ptr& p1 = p;
-  ptr& p2 = cp; // expected-error {{drops 'const' qualifier}}
-  ptr& p3 = rp; // expected-error {{drops 'restrict' qualifier}}
-  ptr& p4 = crp; // expected-error {{drops 'const' and 'restrict' qualifiers}}
-  ptr& p5 = vp; // expected-error {{drops 'volatile' qualifier}}
-  ptr& p6 = cvp; // expected-error {{drops 'const' and 'volatile' qualifiers}}
-  ptr& p7 = rvp; // expected-error {{drops 'restrict' and 'volatile' qualifiers}}
-  ptr& p8 = crvp; // expected-error {{drops 'const', 'restrict', and 'volatile' qualifiers}}
+  ptr& p2 = cp;   // expected-error {{drops 'const' qualifier}}
+  ptr& p3 = rp;   // expected-error {{drops '__restrict' qualifier}}
+  ptr& p4 = crp;  // expected-error {{drops 'const __restrict' qualifiers}}
+  ptr& p5 = vp;   // expected-error {{drops 'volatile' qualifier}}
+  ptr& p6 = cvp;  // expected-error {{drops 'const volatile' qualifiers}}
+  ptr& p7 = rvp;  // expected-error {{drops 'volatile __restrict' qualifiers}}
+  ptr& p8 = crvp; // expected-error {{drops 'const volatile __restrict' qualifiers}}
 
   const ptr& cp1 = p;
   const ptr& cp2 = cp;
-  const ptr& cp3 = rp; // expected-error {{drops 'restrict' qualifier}}
-  const ptr& cp4 = crp; // expected-error {{drops 'restrict' qualifier}}
-  const ptr& cp5 = vp; // expected-error {{drops 'volatile' qualifier}}
-  const ptr& cp6 = cvp; // expected-error {{drops 'volatile' qualifier}}
-  const ptr& cp7 = rvp; // expected-error {{drops 'restrict' and 'volatile' 

[PATCH] D60193: [OpenCL] Added addrspace_cast operator

2019-06-05 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

Ping! I would appreciate any feedback to this change please. Thanks you!


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

https://reviews.llvm.org/D60193



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


[PATCH] D59673: [Clang] Harmonize Split DWARF options with llc

2019-06-05 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

In D59673#1527487 , @aaronpuchert 
wrote:

> In D59673#1521413 , @dblaikie wrote:
>
> > Might be easier as a few patches - renaming the existing option, adding the 
> > new one, then removing the single split dwarf flag handling in favor of 
> > implying that by the absence of an output file name.
>
>
> No problem, makes sense to me. I'll see if it's possible to separate these 
> changes.


I have managed to split this into commits that build and test fine own their 
own, but there are temporary inconsistencies. If I rename `-split-dwarf-file` 
to `-split-dwarf-output` first, then I have to use that option for 
`-enable-split-dwarf=single`, and then I reintroduce `-split-dwarf-file` and 
have to change it back. It's not a huge problem, but it might feel a bit weird. 
On the other hand, the changes are indeed smaller and easier to review. I will 
push them later today (hopefully).


Repository:
  rC Clang

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

https://reviews.llvm.org/D59673



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


[PATCH] D62915: git-clang-format: Remove trailing whitespace in docstring. NFC.

2019-06-05 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 created this revision.
Herald added subscribers: cfe-commits, aheejin.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62915

Files:
  clang/tools/clang-format/git-clang-format


Index: clang/tools/clang-format/git-clang-format
===
--- clang/tools/clang-format/git-clang-format
+++ clang/tools/clang-format/git-clang-format
@@ -8,19 +8,19 @@
 #
 
#======#
 
-r"""   
  
-clang-format git integration   
  
-   
  
-   
  
-This file provides a clang-format integration for git. Put it somewhere in 
your  
-path and ensure that it is executable. Then, "git clang-format" will invoke
  
-clang-format on the changes in current files or a specific commit. 
  
-   
  
-For further details, run:  
  
-git clang-format -h
  
-   
  
-Requires Python 2.7 or Python 3
  
-"""   
+r"""
+clang-format git integration
+
+
+This file provides a clang-format integration for git. Put it somewhere in your
+path and ensure that it is executable. Then, "git clang-format" will invoke
+clang-format on the changes in current files or a specific commit.
+
+For further details, run:
+git clang-format -h
+
+Requires Python 2.7 or Python 3
+"""
 
 from __future__ import absolute_import, division, print_function
 import argparse


Index: clang/tools/clang-format/git-clang-format
===
--- clang/tools/clang-format/git-clang-format
+++ clang/tools/clang-format/git-clang-format
@@ -8,19 +8,19 @@
 #
 #======#
 
-r""" 
-clang-format git integration 
- 
- 
-This file provides a clang-format integration for git. Put it somewhere in your  
-path and ensure that it is executable. Then, "git clang-format" will invoke  
-clang-format on the changes in current files or a specific commit.   
- 
-For further details, run:
-git clang-format -h  
- 
-Requires Python 2.7 or Python 3  
-"""   
+r"""
+clang-format git integration
+
+
+This file provides a clang-format integration for git. Put it somewhere in your
+path and ensure that it is executable. Then, "git clang-format" will invoke
+clang-format on the changes in current files or a specific commit.
+
+For further details, run:
+git clang-format -h
+
+Requires Python 2.7 or Python 3
+"""
 
 from __future__ import absolute_import, division, print_function
 import argparse
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61446: Generalize the pass registration mechanism used by Polly to any third-party tool

2019-06-05 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

This fails with Polly/Linux regression tests:

  
  FAIL: Polly :: Simplify/gemm.ll (1148 of 1149)
   TEST 'Polly :: Simplify/gemm.ll' FAILED 

  Script:
  --
  : 'RUN: at line 1';   opt  -polly-process-unprofitable  
-polly-remarks-minimal  -polly-use-llvm-names  
-polly-import-jscop-dir=/home/meinersbur/src/llvm/tools/polly/test/Simplify  
-polly-codegen-verify  -polly-import-jscop
-polly-import-jscop-postfix=transformed -polly-simplify -analyze < 
/home/meinersbur/src/llvm/tools/polly/test/Simplify/gemm.ll| FileCheck 
/home/meinersbur/src/llvm/tools/polly/test/Simplify/gemm.ll
  --
  Exit Code: 2
  
  Command Output (stderr):
  --
  opt: for the   -o option: may not occur within a group!
  opt: Unknown command line argument '-polly-import-jscop'.  Try: 'opt --help'
  opt: Did you mean '  -o'?
  opt: for the   -p option: may only occur zero or one times!
  opt: for the   -o option: may not occur within a group!
  opt: Unknown command line argument '-polly-simplify'.  Try: 'opt --help'
  opt: Did you mean '  -o'?
  FileCheck error: '-' is empty.
  FileCheck command line:  FileCheck 
/home/meinersbur/src/llvm/tools/polly/test/Simplify/gemm.ll

I think this means that the Polly passes have not been registered 
(`initializePollyPasses` must be called someway in opt/clang_cc1/bugpoint). 
Linking from static libraries will NOT include `Polly.o` (and run its static 
initializers) unless it is needed to resolve at least one symbol.

PLEASE run `make/ninja check-polly` before uploading a patch.




Comment at: llvm/tools/opt/opt.cpp:533
-#ifdef LINK_POLLY_INTO_TOOLS
-  polly::initializePollyPasses(Registry);
-#endif

Where is the equivalent for this in your change? I see it's been done for 
`clang_cc1`, but not for `opt`/`bugpoint`.



Comment at: polly/CMakeLists.txt:210
 set_target_properties(polly-update-format PROPERTIES FOLDER "Polly")
-

[nit] Whitespace change



Comment at: polly/lib/CMakeLists.txt:27
 add_library(PollyCore OBJECT
+  Polly.cpp
   Analysis/DependenceInfo.cpp

Why this change? `Polly.cpp` should only be necessary for the loadable module, 
but not for `LLVM_LINK_POLLY_INTO_TOOLS`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61446



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


[PATCH] D62225: [clang][NewPM] Fixing -O0 tests that are broken under new PM

2019-06-05 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

In D62225#1519394 , @efriedma wrote:

> Are the behavior differences between the newpm alwaysinliner and the oldpm 
> alwaysinliner intentional?  Specifically, the differences in pass remarks, 
> and the differences in the treatment of the alwaysinline attribute seem 
> suspect.  (I'm not that interested in the different bitcasts and different 
> order of inline allocas, although that might be nice to fix if it's a small 
> change.)


This is something for @chandlerc to answer, but I think based off D23299 
 the different treatment of `alwaysinline` was 
intentional and the other aspects of it that this patch addresses like the 
`AddAlignmentAssumptions` are probably things that were overlooked at the time.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62225



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


[PATCH] D61446: Generalize the pass registration mechanism used by Polly to any third-party tool

2019-06-05 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

Sorry, you might have tested it with `LLVM_LINK_POLLY_INTO_TOOLS=OFF` and/or 
`BUILD_SHARED_LIBS`/`LLVM_LINK_LLVM_DYLIV` where it might work, but 
unfortunately not with the default configuration using static component 
libraries.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61446



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


r362623 - [Clang] Fix pretty printing of CUDA address spaces

2019-06-05 Thread Anastasia Stulova via cfe-commits
Author: stulova
Date: Wed Jun  5 10:29:00 2019
New Revision: 362623

URL: http://llvm.org/viewvc/llvm-project?rev=362623&view=rev
Log:
[Clang] Fix pretty printing of CUDA address spaces

Patch by richardmembarth (Richard Membarth)!

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


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

Modified: cfe/trunk/lib/AST/TypePrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TypePrinter.cpp?rev=362623&r1=362622&r2=362623&view=diff
==
--- cfe/trunk/lib/AST/TypePrinter.cpp (original)
+++ cfe/trunk/lib/AST/TypePrinter.cpp Wed Jun  5 10:29:00 2019
@@ -1805,17 +1805,19 @@ void Qualifiers::print(raw_ostream &OS,
   case LangAS::opencl_private:
 break;
   case LangAS::opencl_constant:
-  case LangAS::cuda_constant:
 OS << "__constant";
 break;
   case LangAS::opencl_generic:
 OS << "__generic";
 break;
   case LangAS::cuda_device:
-OS << "__device";
+OS << "__device__";
+break;
+  case LangAS::cuda_constant:
+OS << "__constant__";
 break;
   case LangAS::cuda_shared:
-OS << "__shared";
+OS << "__shared__";
 break;
   default:
 OS << "__attribute__((address_space(";


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


[PATCH] D54258: [Clang] Fix pretty printing of CUDA address spaces

2019-06-05 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL362623: [Clang] Fix pretty printing of CUDA address spaces 
(authored by stulova, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D54258?vs=173154&id=203195#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D54258

Files:
  cfe/trunk/lib/AST/TypePrinter.cpp


Index: cfe/trunk/lib/AST/TypePrinter.cpp
===
--- cfe/trunk/lib/AST/TypePrinter.cpp
+++ cfe/trunk/lib/AST/TypePrinter.cpp
@@ -1805,17 +1805,19 @@
   case LangAS::opencl_private:
 break;
   case LangAS::opencl_constant:
-  case LangAS::cuda_constant:
 OS << "__constant";
 break;
   case LangAS::opencl_generic:
 OS << "__generic";
 break;
   case LangAS::cuda_device:
-OS << "__device";
+OS << "__device__";
+break;
+  case LangAS::cuda_constant:
+OS << "__constant__";
 break;
   case LangAS::cuda_shared:
-OS << "__shared";
+OS << "__shared__";
 break;
   default:
 OS << "__attribute__((address_space(";


Index: cfe/trunk/lib/AST/TypePrinter.cpp
===
--- cfe/trunk/lib/AST/TypePrinter.cpp
+++ cfe/trunk/lib/AST/TypePrinter.cpp
@@ -1805,17 +1805,19 @@
   case LangAS::opencl_private:
 break;
   case LangAS::opencl_constant:
-  case LangAS::cuda_constant:
 OS << "__constant";
 break;
   case LangAS::opencl_generic:
 OS << "__generic";
 break;
   case LangAS::cuda_device:
-OS << "__device";
+OS << "__device__";
+break;
+  case LangAS::cuda_constant:
+OS << "__constant__";
 break;
   case LangAS::cuda_shared:
-OS << "__shared";
+OS << "__shared__";
 break;
   default:
 OS << "__attribute__((address_space(";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61446: Generalize the pass registration mechanism used by Polly to any third-party tool

2019-06-05 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added inline comments.



Comment at: llvm/cmake/modules/AddLLVM.cmake:820
+
+set(LLVM_ALL_EXTENSION_TARGETS clang;bugpoint;opt)
+foreach(tool ${LLVM_ALL_EXTENSION_TARGETS})

I don't think we should hard code this list. It would be much better if we add 
an option to `llvm_add_executable` so that extension targets denote themselves.



Comment at: llvm/cmake/modules/AddLLVM.cmake:822
+foreach(tool ${LLVM_ALL_EXTENSION_TARGETS})
+if(TARGET ${tool})
+set_property(TARGET ${tool} APPEND PROPERTY 
LLVM_COMPILER_EXTENSIONS ${llvm_extension_project})

`if(TARGET ...)` is order dependent. That's why you need to change 
tools/CMakeLists.txt, which you won't need to do if you change this to work how 
I suggested in my earlier comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61446



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


[PATCH] D54258: [Clang] Fix pretty printing of CUDA address spaces

2019-06-05 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D54258#1528872 , @richardmembarth 
wrote:

> Merging in two weeks is fine for me.


No worries. I have just committed this.

> My assumption was that accepted patches are merged into upstream in a timely 
> manner.
>  Maybe this is not how it works?

No this is a manual process. The author is expected to commit unless he/she 
doesn't have commit rights. Then it has to be requested explicitly.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D54258



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


r362624 - Use LTO capable linker

2019-06-05 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Wed Jun  5 10:35:38 2019
New Revision: 362624

URL: http://llvm.org/viewvc/llvm-project?rev=362624&view=rev
Log:
Use LTO capable linker

Summary:
In DistributionExample.cmake be sure we use a LTO
capable linker, the easiest to choose is lld.

Reviewers: beanz

Reviewed By: beanz

Patch By: winksaville

Subscribers: mgorny, mehdi_amini, inglorion, dexonsmith, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/cmake/caches/DistributionExample-stage2.cmake
cfe/trunk/cmake/caches/DistributionExample.cmake

Modified: cfe/trunk/cmake/caches/DistributionExample-stage2.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/DistributionExample-stage2.cmake?rev=362624&r1=362623&r2=362624&view=diff
==
--- cfe/trunk/cmake/caches/DistributionExample-stage2.cmake (original)
+++ cfe/trunk/cmake/caches/DistributionExample-stage2.cmake Wed Jun  5 10:35:38 
2019
@@ -2,7 +2,7 @@
 # bootstrap build.
 
 set(LLVM_ENABLE_PROJECTS "clang;clang-tools-extra;lld" CACHE STRING "")
-set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx" CACHE STRING "")
+set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi" CACHE STRING "")
 
 set(LLVM_TARGETS_TO_BUILD X86;ARM;AArch64 CACHE STRING "")
 

Modified: cfe/trunk/cmake/caches/DistributionExample.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/DistributionExample.cmake?rev=362624&r1=362623&r2=362624&view=diff
==
--- cfe/trunk/cmake/caches/DistributionExample.cmake (original)
+++ cfe/trunk/cmake/caches/DistributionExample.cmake Wed Jun  5 10:35:38 2019
@@ -2,7 +2,7 @@
 
 #Enable LLVM projects and runtimes
 set(LLVM_ENABLE_PROJECTS "clang;clang-tools-extra;lld" CACHE STRING "")
-set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx" CACHE STRING "")
+set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi" CACHE STRING "")
 
 # Only build the native target in stage1 since it is a throwaway build.
 set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "")
@@ -17,6 +17,11 @@ set(PACKAGE_VENDOR LLVM.org CACHE STRING
 # the proper LTO library dependencies can be connected.
 set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
 
+if (NOT APPLE)
+  # Since LLVM_ENABLE_LTO is ON we need a LTO capable linker
+  set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
+endif()
+
 # Expose stage2 targets through the stage1 build configuration.
 set(CLANG_BOOTSTRAP_TARGETS
   check-all


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


[PATCH] D62279: Use LTO capable linker

2019-06-05 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL362624: Use LTO capable linker (authored by cbieneman, 
committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D62279?vs=201288&id=203198#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D62279

Files:
  cfe/trunk/cmake/caches/DistributionExample-stage2.cmake
  cfe/trunk/cmake/caches/DistributionExample.cmake


Index: cfe/trunk/cmake/caches/DistributionExample-stage2.cmake
===
--- cfe/trunk/cmake/caches/DistributionExample-stage2.cmake
+++ cfe/trunk/cmake/caches/DistributionExample-stage2.cmake
@@ -2,7 +2,7 @@
 # bootstrap build.
 
 set(LLVM_ENABLE_PROJECTS "clang;clang-tools-extra;lld" CACHE STRING "")
-set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx" CACHE STRING "")
+set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi" CACHE STRING "")
 
 set(LLVM_TARGETS_TO_BUILD X86;ARM;AArch64 CACHE STRING "")
 
Index: cfe/trunk/cmake/caches/DistributionExample.cmake
===
--- cfe/trunk/cmake/caches/DistributionExample.cmake
+++ cfe/trunk/cmake/caches/DistributionExample.cmake
@@ -2,7 +2,7 @@
 
 #Enable LLVM projects and runtimes
 set(LLVM_ENABLE_PROJECTS "clang;clang-tools-extra;lld" CACHE STRING "")
-set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx" CACHE STRING "")
+set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi" CACHE STRING "")
 
 # Only build the native target in stage1 since it is a throwaway build.
 set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "")
@@ -17,6 +17,11 @@
 # the proper LTO library dependencies can be connected.
 set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
 
+if (NOT APPLE)
+  # Since LLVM_ENABLE_LTO is ON we need a LTO capable linker
+  set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
+endif()
+
 # Expose stage2 targets through the stage1 build configuration.
 set(CLANG_BOOTSTRAP_TARGETS
   check-all


Index: cfe/trunk/cmake/caches/DistributionExample-stage2.cmake
===
--- cfe/trunk/cmake/caches/DistributionExample-stage2.cmake
+++ cfe/trunk/cmake/caches/DistributionExample-stage2.cmake
@@ -2,7 +2,7 @@
 # bootstrap build.
 
 set(LLVM_ENABLE_PROJECTS "clang;clang-tools-extra;lld" CACHE STRING "")
-set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx" CACHE STRING "")
+set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi" CACHE STRING "")
 
 set(LLVM_TARGETS_TO_BUILD X86;ARM;AArch64 CACHE STRING "")
 
Index: cfe/trunk/cmake/caches/DistributionExample.cmake
===
--- cfe/trunk/cmake/caches/DistributionExample.cmake
+++ cfe/trunk/cmake/caches/DistributionExample.cmake
@@ -2,7 +2,7 @@
 
 #Enable LLVM projects and runtimes
 set(LLVM_ENABLE_PROJECTS "clang;clang-tools-extra;lld" CACHE STRING "")
-set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx" CACHE STRING "")
+set(LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi" CACHE STRING "")
 
 # Only build the native target in stage1 since it is a throwaway build.
 set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "")
@@ -17,6 +17,11 @@
 # the proper LTO library dependencies can be connected.
 set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
 
+if (NOT APPLE)
+  # Since LLVM_ENABLE_LTO is ON we need a LTO capable linker
+  set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
+endif()
+
 # Expose stage2 targets through the stage1 build configuration.
 set(CLANG_BOOTSTRAP_TARGETS
   check-all
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62831: [CodeGen][ObjC] Add attribute "arc_retain_agnostic" to ObjC globals that are retain-agnostic

2019-06-05 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added inline comments.



Comment at: lib/CodeGen/CGBlocks.cpp:1441
 
+  cast(literal)->addAttribute("arc_retain_agnostic");
+

Can't you just declare `literal` as a GlobalVariable instead of immediately 
casting it?



Comment at: lib/CodeGen/CodeGenModule.cpp:4654
 llvm::GlobalVariable::PrivateLinkage);
+  cast(GV)->addAttribute("arc_retain_agnostic");
   switch (Triple.getObjectFormat()) {

`cast` seems unnecessary. 



Comment at: test/CodeGenObjC/local-static-block.m:5
 
+// CHECK: @{{.*}} = internal constant { i8**, i32, i32, i8*, 
%struct.__block_descriptor* } { i8** @_NSConcreteGlobalBlock, i32 1342177280, 
i32 0, i8* bitcast (%0* (i8*, %0*, i64)* @{{.*}} to i8*), %{{.*}}* bitcast ({ 
i64, i64, i8*, i8* }* @{{.*}} to %{{.*}}) }, align 8 #[[ATTRNUM0:.*]]
+

I believe FileCheck ignores CHECK lines when there is a custom check-prefix, so 
this should be CHECK-LP64. I think this makes more sense regardless in its own 
file though, its weird to piggyback on an unrelated test IMO. 



Comment at: test/CodeGenObjC/local-static-block.m:59-60
 // CHECK-LABEL-LP64: define void @FUNC2(
 // CHECK: define internal void @_block_invoke{{.*}}(
 // CHECK: call void %{{.*}}(i8* bitcast ({ i8**, i32, i32, i8*, 
%struct.__block_descriptor* }* @__block_literal_global{{.*}} to i8*), i32 
%{{.*}})
 

(Likewise, these should be CHECK-LP64, or this test shouldn't be using a 
check-prefix. Would you mind updating this?)


Repository:
  rC Clang

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

https://reviews.llvm.org/D62831



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


[PATCH] D54258: [Clang] Fix pretty printing of CUDA address spaces

2019-06-05 Thread Richard Membarth via Phabricator via cfe-commits
richardmembarth added a comment.

Thanks for clarification and merging!


Repository:
  rL LLVM

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

https://reviews.llvm.org/D54258



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


r362632 - [analyzer] PathDiagnosticPopUpPiece: working with CharSourceRange

2019-06-05 Thread Csaba Dabis via cfe-commits
Author: charusso
Date: Wed Jun  5 11:55:39 2019
New Revision: 362632

URL: http://llvm.org/viewvc/llvm-project?rev=362632&view=rev
Log:
[analyzer] PathDiagnosticPopUpPiece: working with CharSourceRange

Summary: Sometimes we are at character boundaries so past the token-range.

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp?rev=362632&r1=362631&r2=362632&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp Wed Jun  5 11:55:39 
2019
@@ -612,7 +612,7 @@ HandlePopUpPieceStartTag(Rewriter &R,
   for (const auto &Range : PopUpRanges) {
 html::HighlightRange(R, Range.getBegin(), Range.getEnd(), "",
  "",
- /*IsTokenRange=*/true);
+ /*IsTokenRange=*/false);
   }
 }
 
@@ -644,12 +644,12 @@ static void HandlePopUpPieceEndTag(Rewri
 Out << "";
 html::HighlightRange(R, Range.getBegin(), Range.getEnd(),
  "", Buf.c_str(),
- /*IsTokenRange=*/true);
+ /*IsTokenRange=*/false);
 
   // Otherwise inject just the new row at the end of the range.
   } else {
 html::HighlightRange(R, Range.getBegin(), Range.getEnd(), "", Buf.c_str(),
- /*IsTokenRange=*/true);
+ /*IsTokenRange=*/false);
   }
 }
 


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


[PATCH] D60670: [analyzer] [NFC] PathDiagnostic: Create PathDiagnosticPopUpPiece

2019-06-05 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment.

Fix a nit in rL362632 .


Repository:
  rC Clang

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

https://reviews.llvm.org/D60670



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


[PATCH] D62924: [cmake] Remove duplicate TestingSupport library for linking

2019-06-05 Thread Pengxuan Zheng via Phabricator via cfe-commits
pzheng created this revision.
Herald added subscribers: cfe-commits, mgorny.
Herald added a project: clang.

This patch cleans up a duplicate use of TestingSupport library.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62924

Files:
  clang/unittests/Tooling/CMakeLists.txt


Index: clang/unittests/Tooling/CMakeLists.txt
===
--- clang/unittests/Tooling/CMakeLists.txt
+++ clang/unittests/Tooling/CMakeLists.txt
@@ -1,7 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   ${LLVM_TARGETS_TO_BUILD}
   Support
-  TestingSupport
   )
 
 # By default MSVC has a 2^16 limit on the number of sections in an object file,


Index: clang/unittests/Tooling/CMakeLists.txt
===
--- clang/unittests/Tooling/CMakeLists.txt
+++ clang/unittests/Tooling/CMakeLists.txt
@@ -1,7 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   ${LLVM_TARGETS_TO_BUILD}
   Support
-  TestingSupport
   )
 
 # By default MSVC has a 2^16 limit on the number of sections in an object file,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61446: Generalize the pass registration mechanism used by Polly to any third-party tool

2019-06-05 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

@Meinersbur Itested with the following configuration

  cmake3 ../llvm -DLLVM_EXTERNAL_PROJECTS=bye -DBUILD_SHARED_LIBS=ON 
-DCMAKE_BUILD_TYPE=Release  -DLLVM_TARGETS_TO_BUILD=X86
  
  cmake3 ../llvm -DLLVM_EXTERNAL_PROJECTS=bye -DBUILD_SHARED_LIBS=ON 
-DCMAKE_BUILD_TYPE=Release  -DLLVM_TARGETS_TO_BUILD=X86 
-DLLVM_POLLY_LINK_INTO_TOOLS=OFF

with old and mono repo layout. I'll test with BUILD_SHARED_LIBS=OFF too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61446



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


[PATCH] D62333: Fix unresolved symbols when linking tools/clang/unittests/Tooling/ToolingTests

2019-06-05 Thread Pengxuan Zheng via Phabricator via cfe-commits
pzheng added inline comments.



Comment at: cfe/trunk/unittests/Tooling/CMakeLists.txt:4
   Support
   TestingSupport
   )

quantum wrote:
> thakis wrote:
> > The library is already up here. Why do we need it twice?
> We don't. It's removed in the code that's merged.
Pushed a patch to remove the duplicate. https://reviews.llvm.org/D62924


Repository:
  rL LLVM

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

https://reviews.llvm.org/D62333



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


[PATCH] D62926: [analyzer] ReturnVisitor: Bypass everything to see inlined calls

2019-06-05 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso created this revision.
Charusso added reviewers: NoQ, xazax.hun, ravikandhadai, baloghadamsoftware, 
Szelethus.
Charusso added a project: clang.
Herald added subscribers: cfe-commits, dkrupp, donat.nagy, mikhail.ramalho, 
a.sidorin, rnkovacs, szepet.

When we traversed backwards on ExplodedNodes to see where we processed the
given statement we `break` too early. With the current approach we do not
miss the CallExitEnd ProgramPoint which stands for an inlined call.


Repository:
  rC Clang

https://reviews.llvm.org/D62926

Files:
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  clang/test/Analysis/new-ctor-null-throw.cpp
  clang/test/Analysis/new-ctor-null.cpp


Index: clang/test/Analysis/new-ctor-null.cpp
===
--- clang/test/Analysis/new-ctor-null.cpp
+++ clang/test/Analysis/new-ctor-null.cpp
@@ -1,4 +1,6 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection 
-analyzer-config c++-allocator-inlining=true -std=c++11 -verify %s
+// RUN: %clang_analyze_cc1 \
+// RUN:  -analyzer-checker=core,debug.ExprInspection \
+// RUN:  -std=c++11 -verify %s
 
 void clang_analyzer_eval(bool);
 void clang_analyzer_warnIfReached();
@@ -24,7 +26,7 @@
 
 void testArrays() {
   S *s = new S[10]; // no-crash
-  s[0].x = 2; // expected-warning{{Dereference of null pointer}}
+  s[0].x = 2;
 }
 
 int global;
Index: clang/test/Analysis/new-ctor-null-throw.cpp
===
--- clang/test/Analysis/new-ctor-null-throw.cpp
+++ clang/test/Analysis/new-ctor-null-throw.cpp
@@ -1,4 +1,6 @@
-// RUN: %clang_analyze_cc1 -w -analyzer-checker=core,debug.ExprInspection 
-analyzer-config c++-allocator-inlining=true -std=c++11 -verify %s
+// RUN: %clang_analyze_cc1 \
+// RUN:  -analyzer-checker=core,debug.ExprInspection \
+// RUN:  -std=c++11 -verify %s
 
 void clang_analyzer_eval(bool);
 
@@ -9,9 +11,11 @@
 // operator new.
 void *operator new(size_t size) {
   return nullptr;
+  // expected-warning@-1 {{'operator new' should not return a null pointer 
unless it is declared 'throw()' or 'noexcept'}}
 }
 void *operator new[](size_t size) {
   return nullptr;
+  // expected-warning@-1 {{'operator new[]' should not return a null pointer 
unless it is declared 'throw()' or 'noexcept'}}
 }
 
 struct S {
@@ -22,5 +26,5 @@
 
 void testArrays() {
   S *s = new S[10]; // no-crash
-  s[0].x = 2; // expected-warning{{Dereference of null pointer}}
+  s[0].x = 2;
 }
Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -837,9 +837,6 @@
   if (auto CEE = Node->getLocationAs())
 if (CEE->getCalleeContext()->getCallSite() == S)
   break;
-  if (auto SP = Node->getLocationAs())
-if (SP->getStmt() == S)
-  break;
 
   Node = Node->getFirstPred();
 } while (Node);


Index: clang/test/Analysis/new-ctor-null.cpp
===
--- clang/test/Analysis/new-ctor-null.cpp
+++ clang/test/Analysis/new-ctor-null.cpp
@@ -1,4 +1,6 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config c++-allocator-inlining=true -std=c++11 -verify %s
+// RUN: %clang_analyze_cc1 \
+// RUN:  -analyzer-checker=core,debug.ExprInspection \
+// RUN:  -std=c++11 -verify %s
 
 void clang_analyzer_eval(bool);
 void clang_analyzer_warnIfReached();
@@ -24,7 +26,7 @@
 
 void testArrays() {
   S *s = new S[10]; // no-crash
-  s[0].x = 2; // expected-warning{{Dereference of null pointer}}
+  s[0].x = 2;
 }
 
 int global;
Index: clang/test/Analysis/new-ctor-null-throw.cpp
===
--- clang/test/Analysis/new-ctor-null-throw.cpp
+++ clang/test/Analysis/new-ctor-null-throw.cpp
@@ -1,4 +1,6 @@
-// RUN: %clang_analyze_cc1 -w -analyzer-checker=core,debug.ExprInspection -analyzer-config c++-allocator-inlining=true -std=c++11 -verify %s
+// RUN: %clang_analyze_cc1 \
+// RUN:  -analyzer-checker=core,debug.ExprInspection \
+// RUN:  -std=c++11 -verify %s
 
 void clang_analyzer_eval(bool);
 
@@ -9,9 +11,11 @@
 // operator new.
 void *operator new(size_t size) {
   return nullptr;
+  // expected-warning@-1 {{'operator new' should not return a null pointer unless it is declared 'throw()' or 'noexcept'}}
 }
 void *operator new[](size_t size) {
   return nullptr;
+  // expected-warning@-1 {{'operator new[]' should not return a null pointer unless it is declared 'throw()' or 'noexcept'}}
 }
 
 struct S {
@@ -22,5 +26,5 @@
 
 void testArrays() {
   S *s = new S[10]; // no-crash
-  s[0].x = 2; // expected-warning{{Dereference of null pointer}}
+  s[0].x = 2;
 }
Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===

[PATCH] D62924: [cmake] Remove duplicate TestingSupport library for linking

2019-06-05 Thread Pengxuan Zheng via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe34d1a4e07b8: [cmake] Remove duplicate TestingSupport 
library for linking (authored by pzheng).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62924

Files:
  clang/unittests/Tooling/CMakeLists.txt


Index: clang/unittests/Tooling/CMakeLists.txt
===
--- clang/unittests/Tooling/CMakeLists.txt
+++ clang/unittests/Tooling/CMakeLists.txt
@@ -1,7 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   ${LLVM_TARGETS_TO_BUILD}
   Support
-  TestingSupport
   )
 
 # By default MSVC has a 2^16 limit on the number of sections in an object file,


Index: clang/unittests/Tooling/CMakeLists.txt
===
--- clang/unittests/Tooling/CMakeLists.txt
+++ clang/unittests/Tooling/CMakeLists.txt
@@ -1,7 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   ${LLVM_TARGETS_TO_BUILD}
   Support
-  TestingSupport
   )
 
 # By default MSVC has a 2^16 limit on the number of sections in an object file,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D59744: Fix i386 ABI "__m64" type bug

2019-06-05 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added a comment.

I think MMX code is obscure enough at this point that it doesn't matter much 
either way. Even less across DSO boundaries. That's why I don't really care 
either way.


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

https://reviews.llvm.org/D59744



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


[PATCH] D61729: [docs] Fix example for Allman brace breaking style

2019-06-05 Thread Owen Pan via Phabricator via cfe-commits
owenpan accepted this revision.
owenpan added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D61729



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


r362646 - [clang-format][NFC] Fix BS_Allman style example in the header docs are generated from

2019-06-05 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Wed Jun  5 13:59:48 2019
New Revision: 362646

URL: http://llvm.org/viewvc/llvm-project?rev=362646&view=rev
Log:
[clang-format][NFC] Fix BS_Allman style example in the header docs are 
generated from

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

Modified:
cfe/trunk/docs/ClangFormatStyleOptions.rst
cfe/trunk/include/clang/Format/Format.h

Modified: cfe/trunk/docs/ClangFormatStyleOptions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangFormatStyleOptions.rst?rev=362646&r1=362645&r2=362646&view=diff
==
--- cfe/trunk/docs/ClangFormatStyleOptions.rst (original)
+++ cfe/trunk/docs/ClangFormatStyleOptions.rst Wed Jun  5 13:59:48 2019
@@ -1059,19 +1059,28 @@ the configuration (without a prefix: ``A
 
 .. code-block:: c++
 
-  try {
+  try
+  {
 foo();
   }
-  catch () {
+  catch ()
+  {
   }
   void foo() { bar(); }
-  class foo {
+  class foo
+  {
   };
-  if (foo()) {
+  if (foo())
+  {
   }
-  else {
+  else
+  {
   }
-  enum X : int { A, B };
+  enum X : int
+  {
+A,
+B
+  };
 
   * ``BS_GNU`` (in configuration: ``GNU``)
 Always break before braces and add an extra level of indentation to

Modified: cfe/trunk/include/clang/Format/Format.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=362646&r1=362645&r2=362646&view=diff
==
--- cfe/trunk/include/clang/Format/Format.h (original)
+++ cfe/trunk/include/clang/Format/Format.h Wed Jun  5 13:59:48 2019
@@ -642,19 +642,28 @@ struct FormatStyle {
 BS_Stroustrup,
 /// Always break before braces.
 /// \code
-///   try {
+///   try
+///   {
 /// foo();
 ///   }
-///   catch () {
+///   catch ()
+///   {
 ///   }
 ///   void foo() { bar(); }
-///   class foo {
+///   class foo
+///   {
 ///   };
-///   if (foo()) {
+///   if (foo())
+///   {
 ///   }
-///   else {
+///   else
+///   {
 ///   }
-///   enum X : int { A, B };
+///   enum X : int
+///   {
+/// A,
+/// B
+///   };
 /// \endcode
 BS_Allman,
 /// Always break before braces and add an extra level of indentation to


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


[PATCH] D61729: [docs] Fix example for Allman brace breaking style

2019-06-05 Thread Jan Korous via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL362646: [clang-format][NFC] Fix BS_Allman style example in 
the header docs are… (authored by jkorous, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D61729?vs=202827&id=203243#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D61729

Files:
  cfe/trunk/docs/ClangFormatStyleOptions.rst
  cfe/trunk/include/clang/Format/Format.h


Index: cfe/trunk/docs/ClangFormatStyleOptions.rst
===
--- cfe/trunk/docs/ClangFormatStyleOptions.rst
+++ cfe/trunk/docs/ClangFormatStyleOptions.rst
@@ -1059,19 +1059,28 @@
 
 .. code-block:: c++
 
-  try {
+  try
+  {
 foo();
   }
-  catch () {
+  catch ()
+  {
   }
   void foo() { bar(); }
-  class foo {
+  class foo
+  {
   };
-  if (foo()) {
+  if (foo())
+  {
   }
-  else {
+  else
+  {
   }
-  enum X : int { A, B };
+  enum X : int
+  {
+A,
+B
+  };
 
   * ``BS_GNU`` (in configuration: ``GNU``)
 Always break before braces and add an extra level of indentation to
Index: cfe/trunk/include/clang/Format/Format.h
===
--- cfe/trunk/include/clang/Format/Format.h
+++ cfe/trunk/include/clang/Format/Format.h
@@ -642,19 +642,28 @@
 BS_Stroustrup,
 /// Always break before braces.
 /// \code
-///   try {
+///   try
+///   {
 /// foo();
 ///   }
-///   catch () {
+///   catch ()
+///   {
 ///   }
 ///   void foo() { bar(); }
-///   class foo {
+///   class foo
+///   {
 ///   };
-///   if (foo()) {
+///   if (foo())
+///   {
 ///   }
-///   else {
+///   else
+///   {
 ///   }
-///   enum X : int { A, B };
+///   enum X : int
+///   {
+/// A,
+/// B
+///   };
 /// \endcode
 BS_Allman,
 /// Always break before braces and add an extra level of indentation to


Index: cfe/trunk/docs/ClangFormatStyleOptions.rst
===
--- cfe/trunk/docs/ClangFormatStyleOptions.rst
+++ cfe/trunk/docs/ClangFormatStyleOptions.rst
@@ -1059,19 +1059,28 @@
 
 .. code-block:: c++
 
-  try {
+  try
+  {
 foo();
   }
-  catch () {
+  catch ()
+  {
   }
   void foo() { bar(); }
-  class foo {
+  class foo
+  {
   };
-  if (foo()) {
+  if (foo())
+  {
   }
-  else {
+  else
+  {
   }
-  enum X : int { A, B };
+  enum X : int
+  {
+A,
+B
+  };
 
   * ``BS_GNU`` (in configuration: ``GNU``)
 Always break before braces and add an extra level of indentation to
Index: cfe/trunk/include/clang/Format/Format.h
===
--- cfe/trunk/include/clang/Format/Format.h
+++ cfe/trunk/include/clang/Format/Format.h
@@ -642,19 +642,28 @@
 BS_Stroustrup,
 /// Always break before braces.
 /// \code
-///   try {
+///   try
+///   {
 /// foo();
 ///   }
-///   catch () {
+///   catch ()
+///   {
 ///   }
 ///   void foo() { bar(); }
-///   class foo {
+///   class foo
+///   {
 ///   };
-///   if (foo()) {
+///   if (foo())
+///   {
 ///   }
-///   else {
+///   else
+///   {
 ///   }
-///   enum X : int { A, B };
+///   enum X : int
+///   {
+/// A,
+/// B
+///   };
 /// \endcode
 BS_Allman,
 /// Always break before braces and add an extra level of indentation to
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r362651 - Fix FileCheck prefixes in test case.

2019-06-05 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Wed Jun  5 14:11:06 2019
New Revision: 362651

URL: http://llvm.org/viewvc/llvm-project?rev=362651&view=rev
Log:
Fix FileCheck prefixes in test case.

Modified:
cfe/trunk/test/CodeGenObjC/local-static-block.m

Modified: cfe/trunk/test/CodeGenObjC/local-static-block.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/local-static-block.m?rev=362651&r1=362650&r2=362651&view=diff
==
--- cfe/trunk/test/CodeGenObjC/local-static-block.m (original)
+++ cfe/trunk/test/CodeGenObjC/local-static-block.m Wed Jun  5 14:11:06 2019
@@ -1,7 +1,11 @@
-// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin 
-fobjc-runtime=macosx-fragile-10.5 -emit-llvm %s -o %t-64.ll
-// RUN: FileCheck -check-prefix CHECK-LP64 --input-file=%t-64.ll %s
+// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin 
-fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck %s
 // rdar: // 8390455
 
+// CHECK: @ArrayRecurs = internal global
+// CHECK: @FUNC.ArrayRecurs = internal global
+// CHECK: @FUNC.ArrayRecurs.1 = internal global
+// CHECK: @FUNC1.ArrayRecurs = internal global
+
 @class NSArray;
 
 static  NSArray *(^ArrayRecurs)(NSArray *addresses, unsigned long level) = 
^(NSArray *addresses, unsigned long level) {
@@ -53,7 +57,7 @@ void FUNC2() {
   };
 }
 
-// CHECK-LABEL-LP64: define void @FUNC2(
+// CHECK-LABEL: define void @FUNC2(
 // CHECK: define internal void @_block_invoke{{.*}}(
 // CHECK: call void %{{.*}}(i8* bitcast ({ i8**, i32, i32, i8*, 
%struct.__block_descriptor* }* @__block_literal_global{{.*}} to i8*), i32 
%{{.*}})
 
@@ -70,7 +74,3 @@ void FUNC1()
  };
  ArrayRecurs(address, level);
 }
-// CHECK-LP64: @ArrayRecurs = internal global
-// CHECK-LP64: @FUNC.ArrayRecurs = internal global
-// CHECK-LP64: @FUNC.ArrayRecurs.1 = internal global
-// CHECK-LP64: @FUNC1.ArrayRecurs = internal global


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


[PATCH] D62831: [CodeGen][ObjC] Add attribute "arc_retain_agnostic" to ObjC globals that are retain-agnostic

2019-06-05 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak marked 2 inline comments as done.
ahatanak added inline comments.



Comment at: test/CodeGenObjC/local-static-block.m:59-60
 // CHECK-LABEL-LP64: define void @FUNC2(
 // CHECK: define internal void @_block_invoke{{.*}}(
 // CHECK: call void %{{.*}}(i8* bitcast ({ i8**, i32, i32, i8*, 
%struct.__block_descriptor* }* @__block_literal_global{{.*}} to i8*), i32 
%{{.*}})
 

erik.pilkington wrote:
> (Likewise, these should be CHECK-LP64, or this test shouldn't be using a 
> check-prefix. Would you mind updating this?)
Fixed in r362651.


Repository:
  rC Clang

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

https://reviews.llvm.org/D62831



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


[PATCH] D62831: [CodeGen][ObjC] Add attribute "arc_retain_agnostic" to ObjC globals that are retain-agnostic

2019-06-05 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 203247.
ahatanak marked 5 inline comments as done.
ahatanak added a comment.

Address review comments.


Repository:
  rC Clang

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

https://reviews.llvm.org/D62831

Files:
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CodeGenModule.cpp
  test/CodeGenObjC/attr-retain-agnostic.m


Index: test/CodeGenObjC/attr-retain-agnostic.m
===
--- /dev/null
+++ test/CodeGenObjC/attr-retain-agnostic.m
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fblocks -emit-llvm -o - %s | 
FileCheck %s
+
+// CHECK: @{{.*}} = private global %{{.*}} { i32* getelementptr inbounds ([0 x 
i32], [0 x i32]* @__CFConstantStringClassReference, i32 0, i32 0), i32 1992, 
i8* getelementptr inbounds ([4 x i8], [4 x i8]* @{{.*}}, i32 0, i32 0), i64 3 
}, section "__DATA,__cfstring", align 8 #[[ATTRNUM0:[0-9]+]]
+// CHECK: @{{.*}} = internal constant { i8**, i32, i32, i8*, %{{.*}}* } { i8** 
@_NSConcreteGlobalBlock, i32 1342177280, i32 0, i8* bitcast (i32 (i8*)* @{{.*}} 
to i8*), %{{.*}}* bitcast ({ i64, i64, i8*, i8* }* @{{.*}} to %{{.*}}*) }, 
align 8 #[[ATTRNUM0]]
+
+@class NSString;
+
+NSString *testStringLiteral(void) {
+  return @"abc";
+}
+
+int testGlobalBlock(int a) {
+  return ^{ return 123; }();
+}
+
+// CHECK: attributes #[[ATTRNUM0]] = { "arc_retain_agnostic" }
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -4651,6 +4651,7 @@
   GV = Fields.finishAndCreateGlobal("_unnamed_cfstring_", Alignment,
 /*isConstant=*/false,
 llvm::GlobalVariable::PrivateLinkage);
+  GV->addAttribute("arc_retain_agnostic");
   switch (Triple.getObjectFormat()) {
   case llvm::Triple::UnknownObjectFormat:
 llvm_unreachable("unknown file format");
Index: lib/CodeGen/CGBlocks.cpp
===
--- lib/CodeGen/CGBlocks.cpp
+++ lib/CodeGen/CGBlocks.cpp
@@ -1434,10 +1434,12 @@
   if (CGM.getContext().getLangOpts().OpenCL)
 AddrSpace = CGM.getContext().getTargetAddressSpace(LangAS::opencl_global);
 
-  llvm::Constant *literal = fields.finishAndCreateGlobal(
+  llvm::GlobalVariable *literal = fields.finishAndCreateGlobal(
   "__block_literal_global", blockInfo.BlockAlign,
   /*constant*/ !IsWindows, llvm::GlobalVariable::InternalLinkage, 
AddrSpace);
 
+  literal->addAttribute("arc_retain_agnostic");
+
   // Windows does not allow globals to be initialised to point to globals in
   // different DLLs.  Any such variables must run code to initialise them.
   if (IsWindows) {


Index: test/CodeGenObjC/attr-retain-agnostic.m
===
--- /dev/null
+++ test/CodeGenObjC/attr-retain-agnostic.m
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fblocks -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: @{{.*}} = private global %{{.*}} { i32* getelementptr inbounds ([0 x i32], [0 x i32]* @__CFConstantStringClassReference, i32 0, i32 0), i32 1992, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @{{.*}}, i32 0, i32 0), i64 3 }, section "__DATA,__cfstring", align 8 #[[ATTRNUM0:[0-9]+]]
+// CHECK: @{{.*}} = internal constant { i8**, i32, i32, i8*, %{{.*}}* } { i8** @_NSConcreteGlobalBlock, i32 1342177280, i32 0, i8* bitcast (i32 (i8*)* @{{.*}} to i8*), %{{.*}}* bitcast ({ i64, i64, i8*, i8* }* @{{.*}} to %{{.*}}*) }, align 8 #[[ATTRNUM0]]
+
+@class NSString;
+
+NSString *testStringLiteral(void) {
+  return @"abc";
+}
+
+int testGlobalBlock(int a) {
+  return ^{ return 123; }();
+}
+
+// CHECK: attributes #[[ATTRNUM0]] = { "arc_retain_agnostic" }
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -4651,6 +4651,7 @@
   GV = Fields.finishAndCreateGlobal("_unnamed_cfstring_", Alignment,
 /*isConstant=*/false,
 llvm::GlobalVariable::PrivateLinkage);
+  GV->addAttribute("arc_retain_agnostic");
   switch (Triple.getObjectFormat()) {
   case llvm::Triple::UnknownObjectFormat:
 llvm_unreachable("unknown file format");
Index: lib/CodeGen/CGBlocks.cpp
===
--- lib/CodeGen/CGBlocks.cpp
+++ lib/CodeGen/CGBlocks.cpp
@@ -1434,10 +1434,12 @@
   if (CGM.getContext().getLangOpts().OpenCL)
 AddrSpace = CGM.getContext().getTargetAddressSpace(LangAS::opencl_global);
 
-  llvm::Constant *literal = fields.finishAndCreateGlobal(
+  llvm::GlobalVariable *literal = fields.finishAndCreateGlobal(
   "__block_literal_global", blockInfo.BlockAlign,
   /*constant*/ !IsWindows, llvm::GlobalVariable::InternalLinkage, AddrSpace);

[PATCH] D62831: [CodeGen][ObjC] Add attribute "arc_retain_agnostic" to ObjC globals that are retain-agnostic

2019-06-05 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: test/CodeGenObjC/local-static-block.m:5
 
+// CHECK: @{{.*}} = internal constant { i8**, i32, i32, i8*, 
%struct.__block_descriptor* } { i8** @_NSConcreteGlobalBlock, i32 1342177280, 
i32 0, i8* bitcast (%0* (i8*, %0*, i64)* @{{.*}} to i8*), %{{.*}}* bitcast ({ 
i64, i64, i8*, i8* }* @{{.*}} to %{{.*}}) }, align 8 #[[ATTRNUM0:.*]]
+

erik.pilkington wrote:
> I believe FileCheck ignores CHECK lines when there is a custom check-prefix, 
> so this should be CHECK-LP64. I think this makes more sense regardless in its 
> own file though, its weird to piggyback on an unrelated test IMO. 
I added a file that just tests this attribute.


Repository:
  rC Clang

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

https://reviews.llvm.org/D62831



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


[PATCH] D62831: [CodeGen][ObjC] Add attribute "arc_retain_agnostic" to ObjC globals that are retain-agnostic

2019-06-05 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a comment.

I think this looks good from a clang perspective. No reason to land it before 
the dust settles on D62433  though.

Do you think we can also add this attribute (or something like it) onto allocas 
of `_NSConcreteStackBlock`s? They also have this retain-swallowing behaviour.


Repository:
  rC Clang

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

https://reviews.llvm.org/D62831



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


[PATCH] D62926: [analyzer] ReturnVisitor: Bypass everything to see inlined calls

2019-06-05 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: clang/test/Analysis/new-ctor-null-throw.cpp:1-3
+// RUN: %clang_analyze_cc1 \
+// RUN:  -analyzer-checker=core,debug.ExprInspection \
+// RUN:  -std=c++11 -verify %s

Hmm, how come you removed `-analyzer-config c++-allocator-inlining=true`?


Repository:
  rC Clang

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

https://reviews.llvm.org/D62926



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


[PATCH] D62883: [analyzer] Track conditions of terminator statements on which the reported node depends on

2019-06-05 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

> I think we should make clear that this visitor only operates within one 
> function and does not track controll dependencies across functions.

Hmm, maybe it's worth investigating whether if we pop the call stack, does the 
bug report improve if we update the visitor to build control dependencies for 
the recent function, and update the origin block to be the one where the 
function call was located.


Repository:
  rC Clang

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

https://reviews.llvm.org/D62883



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


[PATCH] D62636: Driver, IRGen: Set partitions on GlobalValues according to -fsymbol-partition flag.

2019-06-05 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62636



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


r362667 - [WebAssembly] Support Leak Sanitizer on Emscripten

2019-06-05 Thread Thomas Lively via cfe-commits
Author: tlively
Date: Wed Jun  5 18:38:12 2019
New Revision: 362667

URL: http://llvm.org/viewvc/llvm-project?rev=362667&view=rev
Log:
[WebAssembly] Support Leak Sanitizer on Emscripten

Summary:
LSan is currently being ported to Emscripten and mostly works.

Enabling the support in upstream would simplify testing.

Patch by Guanzhong Chen.

Reviewers: tlively, aheejin

Reviewed By: aheejin

Subscribers: dschuff, sbc100, jgravelle-google, sunfish, cfe-commits

Tags: #clang

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

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

Modified: cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp?rev=362667&r1=362666&r2=362667&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp Wed Jun  5 18:38:12 2019
@@ -211,7 +211,7 @@ void WebAssembly::AddCXXStdlibLibArgs(co
 SanitizerMask WebAssembly::getSupportedSanitizers() const {
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   if (getTriple().isOSEmscripten()) {
-Res |= SanitizerKind::Vptr;
+Res |= SanitizerKind::Vptr | SanitizerKind::Leak;
   }
   return Res;
 }


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


[PATCH] D62830: [WebAssembly] Support Leak Sanitizer on Emscripten

2019-06-05 Thread Thomas Lively via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL362667: [WebAssembly] Support Leak Sanitizer on Emscripten 
(authored by tlively, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D62830?vs=202817&id=203273#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D62830

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


Index: cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
+++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
@@ -211,7 +211,7 @@
 SanitizerMask WebAssembly::getSupportedSanitizers() const {
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   if (getTriple().isOSEmscripten()) {
-Res |= SanitizerKind::Vptr;
+Res |= SanitizerKind::Vptr | SanitizerKind::Leak;
   }
   return Res;
 }


Index: cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
+++ cfe/trunk/lib/Driver/ToolChains/WebAssembly.cpp
@@ -211,7 +211,7 @@
 SanitizerMask WebAssembly::getSupportedSanitizers() const {
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   if (getTriple().isOSEmscripten()) {
-Res |= SanitizerKind::Vptr;
+Res |= SanitizerKind::Vptr | SanitizerKind::Leak;
   }
   return Res;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61989: [clang-tidy] enable modernize-concat-nested-namespaces on header files

2019-06-05 Thread Xiao Shi via Phabricator via cfe-commits
shixiao updated this revision to Diff 203275.
shixiao added a comment.

rebase, fix comments, enable for c++2a, add report for running the check on llvm


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61989

Files:
  clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.cpp
  clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/modernize-concat-nested-namespaces.rst
  clang-tools-extra/test/clang-tidy/modernize-concat-nested-namespaces.cpp
  clang-tools-extra/test/clang-tidy/modernize-concat-nested-namespaces.h
  clang-tools-extra/test/clang-tidy/modernize-concat-nested-namespaces2.h

Index: clang-tools-extra/test/clang-tidy/modernize-concat-nested-namespaces2.h
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/modernize-concat-nested-namespaces2.h
@@ -0,0 +1,9 @@
+#pragma once
+
+namespace foo {
+namespace bar {
+namespace baz {
+struct S2 {};
+} // namespace baz
+} // namespace bar
+} // namespace foo
Index: clang-tools-extra/test/clang-tidy/modernize-concat-nested-namespaces.h
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/modernize-concat-nested-namespaces.h
@@ -0,0 +1,11 @@
+#pragma once
+
+#include "modernize-concat-nested-namespaces2.h"
+
+namespace foo {
+namespace bar {
+namespace baz {
+struct S {};
+} // namespace baz
+} // namespace bar
+} // namespace foo
Index: clang-tools-extra/test/clang-tidy/modernize-concat-nested-namespaces.cpp
===
--- clang-tools-extra/test/clang-tidy/modernize-concat-nested-namespaces.cpp
+++ clang-tools-extra/test/clang-tidy/modernize-concat-nested-namespaces.cpp
@@ -1,4 +1,12 @@
-// RUN: %check_clang_tidy -std=c++17-or-later %s modernize-concat-nested-namespaces %t
+// Note: since this check fixes instances in the headers, we need to copy the
+// headers before each run (for a mode that supports this check).
+//
+// RUN: cp %S/modernize-concat-nested-namespaces*.h %T
+// RUN: %check_clang_tidy -std=c++17 %s modernize-concat-nested-namespaces %t -- -header-filter="concat" -- -I %T
+// RUN: cp %S/modernize-concat-nested-namespaces*.h %T
+// RUN: %check_clang_tidy -std=c++2a %s modernize-concat-nested-namespaces %t -- -header-filter="concat" -- -I %T
+
+#include "modernize-concat-nested-namespaces.h"
 
 namespace n1 {}
 
@@ -159,3 +167,8 @@
 
   return 0;
 }
+
+// Checks for header file:
+
+// CHECK-MESSAGES: modernize-concat-nested-namespaces.h:{{.*}} warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
+// CHECK-MESSAGES: modernize-concat-nested-namespaces2.h:{{.*}} warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
Index: clang-tools-extra/docs/clang-tidy/checks/modernize-concat-nested-namespaces.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/modernize-concat-nested-namespaces.rst
+++ clang-tools-extra/docs/clang-tidy/checks/modernize-concat-nested-namespaces.rst
@@ -47,3 +47,13 @@
   }
   }
 
+Options
+---
+
+.. option:: HeaderFileExtensions
+
+   A comma-separated list of filename extensions of header files (the filename
+   extensions should not contain "." prefix). Default is `h,hh,hpp,hxx`.
+   For header files without an extension, use an empty string (if there are no
+   other desired extensions) or leave an empty element in the list. e.g.,
+   `h,hh,hpp,hxx,` (note the trailing comma).
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -163,6 +163,11 @@
   :doc:`objc-property-declaration `
   check have been removed.
 
+- The :doc:`modernize-concat-nested-namespaces
+  ` now supports the
+  `HeaderFileExtensions` option and issues warnings for transitively included
+  header files that pass the header filter.
+
 - The :doc:`modernize-use-override
   ` now supports `OverrideSpelling`
   and `FinalSpelling` options.
Index: clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.h
===
--- clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.h
+++ clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.h
@@ -10,6 +10,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_CONCATNESTEDNAMESPACESCHECK_H
 
 #include "../ClangTidyCheck.h"
+#include "../utils/HeaderFileExtensionsUtils.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
 
@@ -17,10 +18,16 @@
 namespace tidy {
 namespace modernize {
 
+/// The check supports these options:
+///   - `HeaderFileExt

[PATCH] D61989: [clang-tidy] enable modernize-concat-nested-namespaces on header files

2019-06-05 Thread Xiao Shi via Phabricator via cfe-commits
shixiao updated this revision to Diff 203276.
shixiao edited the summary of this revision.
shixiao added a comment.
Herald added subscribers: sunfish, aheejin, kristof.beyls, tpr, javed.absar.

update commit summary


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61989

Files:
  clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.cpp
  clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/modernize-concat-nested-namespaces.rst
  clang-tools-extra/test/clang-tidy/modernize-concat-nested-namespaces.cpp
  clang-tools-extra/test/clang-tidy/modernize-concat-nested-namespaces.h
  clang-tools-extra/test/clang-tidy/modernize-concat-nested-namespaces2.h

Index: clang-tools-extra/test/clang-tidy/modernize-concat-nested-namespaces2.h
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/modernize-concat-nested-namespaces2.h
@@ -0,0 +1,9 @@
+#pragma once
+
+namespace foo {
+namespace bar {
+namespace baz {
+struct S2 {};
+} // namespace baz
+} // namespace bar
+} // namespace foo
Index: clang-tools-extra/test/clang-tidy/modernize-concat-nested-namespaces.h
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/modernize-concat-nested-namespaces.h
@@ -0,0 +1,11 @@
+#pragma once
+
+#include "modernize-concat-nested-namespaces2.h"
+
+namespace foo {
+namespace bar {
+namespace baz {
+struct S {};
+} // namespace baz
+} // namespace bar
+} // namespace foo
Index: clang-tools-extra/test/clang-tidy/modernize-concat-nested-namespaces.cpp
===
--- clang-tools-extra/test/clang-tidy/modernize-concat-nested-namespaces.cpp
+++ clang-tools-extra/test/clang-tidy/modernize-concat-nested-namespaces.cpp
@@ -1,4 +1,12 @@
-// RUN: %check_clang_tidy -std=c++17-or-later %s modernize-concat-nested-namespaces %t
+// Note: since this check fixes instances in the headers, we need to copy the
+// headers before each run (for a mode that supports this check).
+//
+// RUN: cp %S/modernize-concat-nested-namespaces*.h %T
+// RUN: %check_clang_tidy -std=c++17 %s modernize-concat-nested-namespaces %t -- -header-filter="concat" -- -I %T
+// RUN: cp %S/modernize-concat-nested-namespaces*.h %T
+// RUN: %check_clang_tidy -std=c++2a %s modernize-concat-nested-namespaces %t -- -header-filter="concat" -- -I %T
+
+#include "modernize-concat-nested-namespaces.h"
 
 namespace n1 {}
 
@@ -159,3 +167,8 @@
 
   return 0;
 }
+
+// Checks for header file:
+
+// CHECK-MESSAGES: modernize-concat-nested-namespaces.h:{{.*}} warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
+// CHECK-MESSAGES: modernize-concat-nested-namespaces2.h:{{.*}} warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
Index: clang-tools-extra/docs/clang-tidy/checks/modernize-concat-nested-namespaces.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/modernize-concat-nested-namespaces.rst
+++ clang-tools-extra/docs/clang-tidy/checks/modernize-concat-nested-namespaces.rst
@@ -47,3 +47,13 @@
   }
   }
 
+Options
+---
+
+.. option:: HeaderFileExtensions
+
+   A comma-separated list of filename extensions of header files (the filename
+   extensions should not contain "." prefix). Default is `h,hh,hpp,hxx`.
+   For header files without an extension, use an empty string (if there are no
+   other desired extensions) or leave an empty element in the list. e.g.,
+   `h,hh,hpp,hxx,` (note the trailing comma).
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -163,6 +163,11 @@
   :doc:`objc-property-declaration `
   check have been removed.
 
+- The :doc:`modernize-concat-nested-namespaces
+  ` now supports the
+  `HeaderFileExtensions` option and issues warnings for transitively included
+  header files that pass the header filter.
+
 - The :doc:`modernize-use-override
   ` now supports `OverrideSpelling`
   and `FinalSpelling` options.
Index: clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.h
===
--- clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.h
+++ clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.h
@@ -10,6 +10,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_CONCATNESTEDNAMESPACESCHECK_H
 
 #include "../ClangTidyCheck.h"
+#include "../utils/HeaderFileExtensionsUtils.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
 
@@ -17,10 +18,16 @@
 namespace tidy {
 namespace modernize {
 

[Diffusion] rL358949: [PowerPC] [Clang] Port MMX intrinsics and basic test cases to Power

2019-06-05 Thread Zixuan Wu via Phabricator via cfe-commits
wuzish added a comment.

> That (controlling within the headers) sounds good to me. When that lands, 
> then my understanding is that the `PPCLinuxToolChain` code would be adjusted 
> to include `ppc_wrappers` in the search path in the general case. Please let 
> me know if that's not the case. Thanks.

Yes, I 'd like to include `ppc_wrappers` in the search path directly not 
conditionally later.


https://reviews.llvm.org/rL358949



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


[PATCH] D62926: [analyzer] ReturnVisitor: Bypass everything to see inlined calls

2019-06-05 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Aha, that's something! And nice to see we've already had this bug covered with 
tests. Because, of course, i added these tests a year ago without even thinking 
about what the correct behavior should look like :/




Comment at: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:835-842
 // First, find when we processed the statement.
 do {
   if (auto CEE = Node->getLocationAs())
 if (CEE->getCalleeContext()->getCallSite() == S)
   break;
-  if (auto SP = Node->getLocationAs())
-if (SP->getStmt() == S)
-  break;
 
   Node = Node->getFirstPred();

This iteration may now take us straight to the root of the graph. I don't think 
it's supposed to be that slow; i think it's supposed to only skip within maybe 
a full-expression at most.

Which statements in the AST are getting peeled off here that weren't before? 
Which statements are supposed to get peeled off?

Might it be that we should simply add one more case to `peelOffOuterExpr()` or 
something like that?



Comment at: clang/test/Analysis/new-ctor-null-throw.cpp:1-3
+// RUN: %clang_analyze_cc1 \
+// RUN:  -analyzer-checker=core,debug.ExprInspection \
+// RUN:  -std=c++11 -verify %s

Szelethus wrote:
> Hmm, how come you removed `-analyzer-config c++-allocator-inlining=true`?
It's on by default these days.



Comment at: clang/test/Analysis/new-ctor-null-throw.cpp:29
   S *s = new S[10]; // no-crash
-  s[0].x = 2; // expected-warning{{Dereference of null pointer}}
+  s[0].x = 2;
 }

Let's add a `// no-warning` here, probably with a comment that this the warning 
is intentionally suppressed.



Comment at: clang/test/Analysis/new-ctor-null.cpp:29
   S *s = new S[10]; // no-crash
-  s[0].x = 2; // expected-warning{{Dereference of null pointer}}
+  s[0].x = 2;
 }

Let's add a `// no-warning` here as well.


Repository:
  rC Clang

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

https://reviews.llvm.org/D62926



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


[clang-tools-extra] r362672 - android: add a close-on-exec check on pipe2()

2019-06-05 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Wed Jun  5 22:21:39 2019
New Revision: 362672

URL: http://llvm.org/viewvc/llvm-project?rev=362672&view=rev
Log:
android: add a close-on-exec check on pipe2()

On Android, pipe2() is better to set O_CLOEXEC flag to avoid file
descriptor leakage.

Patch by Jian Cai!

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

Added:
clang-tools-extra/trunk/clang-tidy/android/CloexecPipe2Check.cpp
clang-tools-extra/trunk/clang-tidy/android/CloexecPipe2Check.h
clang-tools-extra/trunk/docs/clang-tidy/checks/android-cloexec-pipe2.rst
clang-tools-extra/trunk/test/clang-tidy/android-cloexec-pipe2.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp?rev=362672&r1=362671&r2=362672&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp Wed Jun  5 
22:21:39 2019
@@ -20,6 +20,7 @@
 #include "CloexecInotifyInitCheck.h"
 #include "CloexecMemfdCreateCheck.h"
 #include "CloexecOpenCheck.h"
+#include "CloexecPipe2Check.h"
 #include "CloexecSocketCheck.h"
 #include "ComparisonInTempFailureRetryCheck.h"
 
@@ -49,6 +50,7 @@ public:
 CheckFactories.registerCheck(
 "android-cloexec-memfd-create");
 CheckFactories.registerCheck("android-cloexec-open");
+CheckFactories.registerCheck("android-cloexec-pipe2");
 CheckFactories.registerCheck("android-cloexec-socket");
 CheckFactories.registerCheck(
 "android-comparison-in-temp-failure-retry");

Modified: clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt?rev=362672&r1=362671&r2=362672&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt Wed Jun  5 
22:21:39 2019
@@ -14,6 +14,7 @@ add_clang_library(clangTidyAndroidModule
   CloexecInotifyInitCheck.cpp
   CloexecMemfdCreateCheck.cpp
   CloexecOpenCheck.cpp
+  CloexecPipe2Check.cpp
   CloexecSocketCheck.cpp
   ComparisonInTempFailureRetryCheck.cpp
 

Added: clang-tools-extra/trunk/clang-tidy/android/CloexecPipe2Check.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/android/CloexecPipe2Check.cpp?rev=362672&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/android/CloexecPipe2Check.cpp (added)
+++ clang-tools-extra/trunk/clang-tidy/android/CloexecPipe2Check.cpp Wed Jun  5 
22:21:39 2019
@@ -0,0 +1,33 @@
+//===--- CloexecPipe2Check.cpp - 
clang-tidy===//
+//
+// 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
+//
+//===--===//
+
+#include "CloexecPipe2Check.h"
+#include "../utils/ASTUtils.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace android {
+
+void CloexecPipe2Check::registerMatchers(MatchFinder *Finder) {
+  registerMatchersImpl(Finder,
+   functionDecl(returns(isInteger()), hasName("pipe2"),
+hasParameter(0, 
hasType(pointsTo(isInteger(,
+hasParameter(1, hasType(isInteger();
+}
+
+void CloexecPipe2Check::check(const MatchFinder::MatchResult &Result) {
+  insertMacroFlag(Result, /*MacroFlag=*/"O_CLOEXEC", /*ArgPos=*/1);
+}
+
+} // namespace android
+} // namespace tidy
+} // namespace clang

Added: clang-tools-extra/trunk/clang-tidy/android/CloexecPipe2Check.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/android/CloexecPipe2Check.h?rev=362672&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/android/CloexecPipe2Check.h (added)
+++ clang-tools-extra/trunk/clang-tidy/android/CloexecPipe2Check.h Wed Jun  5 
22:21:39 2019
@@ -0,0 +1,34 @@
+//===--- CloexecPipe2Check.h - clang-tidy*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license in

[clang-tools-extra] r362673 - android: add a close-on-exec check on pipe()

2019-06-05 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Wed Jun  5 22:21:45 2019
New Revision: 362673

URL: http://llvm.org/viewvc/llvm-project?rev=362673&view=rev
Log:
android: add a close-on-exec check on pipe()

On Android, pipe() is better to be replaced by pipe2() with O_CLOEXEC
flag to avoid file descriptor leakage.

Patch by Jian Cai!

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

Added:
clang-tools-extra/trunk/clang-tidy/android/CloexecPipeCheck.cpp
clang-tools-extra/trunk/clang-tidy/android/CloexecPipeCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/android-cloexec-pipe.rst
clang-tools-extra/trunk/test/clang-tidy/android-cloexec-pipe.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp?rev=362673&r1=362672&r2=362673&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp Wed Jun  5 
22:21:45 2019
@@ -20,6 +20,7 @@
 #include "CloexecInotifyInitCheck.h"
 #include "CloexecMemfdCreateCheck.h"
 #include "CloexecOpenCheck.h"
+#include "CloexecPipeCheck.h"
 #include "CloexecPipe2Check.h"
 #include "CloexecSocketCheck.h"
 #include "ComparisonInTempFailureRetryCheck.h"
@@ -50,6 +51,7 @@ public:
 CheckFactories.registerCheck(
 "android-cloexec-memfd-create");
 CheckFactories.registerCheck("android-cloexec-open");
+CheckFactories.registerCheck("android-cloexec-pipe");
 CheckFactories.registerCheck("android-cloexec-pipe2");
 CheckFactories.registerCheck("android-cloexec-socket");
 CheckFactories.registerCheck(

Modified: clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt?rev=362673&r1=362672&r2=362673&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt Wed Jun  5 
22:21:45 2019
@@ -14,6 +14,7 @@ add_clang_library(clangTidyAndroidModule
   CloexecInotifyInitCheck.cpp
   CloexecMemfdCreateCheck.cpp
   CloexecOpenCheck.cpp
+  CloexecPipeCheck.cpp
   CloexecPipe2Check.cpp
   CloexecSocketCheck.cpp
   ComparisonInTempFailureRetryCheck.cpp

Added: clang-tools-extra/trunk/clang-tidy/android/CloexecPipeCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/android/CloexecPipeCheck.cpp?rev=362673&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/android/CloexecPipeCheck.cpp (added)
+++ clang-tools-extra/trunk/clang-tidy/android/CloexecPipeCheck.cpp Wed Jun  5 
22:21:45 2019
@@ -0,0 +1,37 @@
+//===--- CloexecPipeCheck.cpp - 
clang-tidy-===//
+//
+// 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
+//
+//===--===//
+
+#include "CloexecPipeCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace android {
+
+void CloexecPipeCheck::registerMatchers(MatchFinder *Finder) {
+  registerMatchersImpl(Finder,
+   functionDecl(returns(isInteger()), hasName("pipe"),
+hasParameter(0, 
hasType(pointsTo(isInteger());
+}
+
+void CloexecPipeCheck::check(const MatchFinder::MatchResult &Result) {
+  std::string ReplacementText =
+  (Twine("pipe2(") + getSpellingArg(Result, 0) + ", O_CLOEXEC)").str();
+
+  replaceFunc(
+  Result,
+  "prefer pipe2() with O_CLOEXEC to avoid leaking file descriptors to 
child processes",
+  ReplacementText);
+}
+
+} // namespace android
+} // namespace tidy
+} // namespace clang

Added: clang-tools-extra/trunk/clang-tidy/android/CloexecPipeCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/android/CloexecPipeCheck.h?rev=362673&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/android/CloexecPipeCheck.h (added)
+++ clang-tools-extra/trunk/clang-tidy/android/CloexecPipeCheck.h Wed Jun  5 
22:21:45 2019
@@ -0,0 +1,34 @@
+//===--- CloexecPipeCheck.h - clang-tidy-*- C++ 

[PATCH] D61967: [clang-tidy] Add a close-on-exec check on pipe() in Android module.

2019-06-05 Thread George Burgess IV via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL362673: android: add a close-on-exec check on pipe() 
(authored by gbiv, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D61967?vs=202984&id=203283#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D61967

Files:
  clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
  clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/android/CloexecPipeCheck.cpp
  clang-tools-extra/trunk/clang-tidy/android/CloexecPipeCheck.h
  clang-tools-extra/trunk/docs/ReleaseNotes.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/android-cloexec-pipe.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  clang-tools-extra/trunk/test/clang-tidy/android-cloexec-pipe.cpp

Index: clang-tools-extra/trunk/clang-tidy/android/CloexecPipeCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/android/CloexecPipeCheck.h
+++ clang-tools-extra/trunk/clang-tidy/android/CloexecPipeCheck.h
@@ -0,0 +1,34 @@
+//===--- CloexecPipeCheck.h - clang-tidy-*- 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 LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_PIPE_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_PIPE_H
+
+#include "CloexecCheck.h"
+
+namespace clang {
+namespace tidy {
+namespace android {
+
+/// Suggests to replace calls to pipe() with calls to pipe2().
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/android-cloexec-pipe.html
+class CloexecPipeCheck : public CloexecCheck {
+public:
+  CloexecPipeCheck(StringRef Name, ClangTidyContext *Context)
+  : CloexecCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace android
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_PIPE_H
Index: clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
===
--- clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
+++ clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
@@ -20,6 +20,7 @@
 #include "CloexecInotifyInitCheck.h"
 #include "CloexecMemfdCreateCheck.h"
 #include "CloexecOpenCheck.h"
+#include "CloexecPipeCheck.h"
 #include "CloexecPipe2Check.h"
 #include "CloexecSocketCheck.h"
 #include "ComparisonInTempFailureRetryCheck.h"
@@ -50,6 +51,7 @@
 CheckFactories.registerCheck(
 "android-cloexec-memfd-create");
 CheckFactories.registerCheck("android-cloexec-open");
+CheckFactories.registerCheck("android-cloexec-pipe");
 CheckFactories.registerCheck("android-cloexec-pipe2");
 CheckFactories.registerCheck("android-cloexec-socket");
 CheckFactories.registerCheck(
Index: clang-tools-extra/trunk/clang-tidy/android/CloexecPipeCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/android/CloexecPipeCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/android/CloexecPipeCheck.cpp
@@ -0,0 +1,37 @@
+//===--- CloexecPipeCheck.cpp - clang-tidy-===//
+//
+// 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
+//
+//===--===//
+
+#include "CloexecPipeCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace android {
+
+void CloexecPipeCheck::registerMatchers(MatchFinder *Finder) {
+  registerMatchersImpl(Finder,
+   functionDecl(returns(isInteger()), hasName("pipe"),
+hasParameter(0, hasType(pointsTo(isInteger());
+}
+
+void CloexecPipeCheck::check(const MatchFinder::MatchResult &Result) {
+  std::string ReplacementText =
+  (Twine("pipe2(") + getSpellingArg(Result, 0) + ", O_CLOEXEC)").str();
+
+  replaceFunc(
+  Result,
+  "prefer pipe2() with O_CLOEXEC to avoid leaking file descriptors to child processes",
+  ReplacementText);
+}
+
+} // namespace android
+} // namespace tidy
+} // namespace clang
Index: clang-tools-extra/tru

[PATCH] D62049: [clang-tidy] Add a close-on-exec check on pipe2() in Android module.

2019-06-05 Thread George Burgess IV via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL362672: android: add a close-on-exec check on pipe2() 
(authored by gbiv, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D62049?vs=203050&id=203282#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D62049

Files:
  clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
  clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/android/CloexecPipe2Check.cpp
  clang-tools-extra/trunk/clang-tidy/android/CloexecPipe2Check.h
  clang-tools-extra/trunk/docs/ReleaseNotes.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/android-cloexec-pipe2.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  clang-tools-extra/trunk/test/clang-tidy/android-cloexec-pipe2.cpp

Index: clang-tools-extra/trunk/clang-tidy/android/CloexecPipe2Check.cpp
===
--- clang-tools-extra/trunk/clang-tidy/android/CloexecPipe2Check.cpp
+++ clang-tools-extra/trunk/clang-tidy/android/CloexecPipe2Check.cpp
@@ -0,0 +1,33 @@
+//===--- CloexecPipe2Check.cpp - clang-tidy===//
+//
+// 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
+//
+//===--===//
+
+#include "CloexecPipe2Check.h"
+#include "../utils/ASTUtils.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace android {
+
+void CloexecPipe2Check::registerMatchers(MatchFinder *Finder) {
+  registerMatchersImpl(Finder,
+   functionDecl(returns(isInteger()), hasName("pipe2"),
+hasParameter(0, hasType(pointsTo(isInteger(,
+hasParameter(1, hasType(isInteger();
+}
+
+void CloexecPipe2Check::check(const MatchFinder::MatchResult &Result) {
+  insertMacroFlag(Result, /*MacroFlag=*/"O_CLOEXEC", /*ArgPos=*/1);
+}
+
+} // namespace android
+} // namespace tidy
+} // namespace clang
Index: clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
===
--- clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
+++ clang-tools-extra/trunk/clang-tidy/android/AndroidTidyModule.cpp
@@ -20,6 +20,7 @@
 #include "CloexecInotifyInitCheck.h"
 #include "CloexecMemfdCreateCheck.h"
 #include "CloexecOpenCheck.h"
+#include "CloexecPipe2Check.h"
 #include "CloexecSocketCheck.h"
 #include "ComparisonInTempFailureRetryCheck.h"
 
@@ -49,6 +50,7 @@
 CheckFactories.registerCheck(
 "android-cloexec-memfd-create");
 CheckFactories.registerCheck("android-cloexec-open");
+CheckFactories.registerCheck("android-cloexec-pipe2");
 CheckFactories.registerCheck("android-cloexec-socket");
 CheckFactories.registerCheck(
 "android-comparison-in-temp-failure-retry");
Index: clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt
===
--- clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt
+++ clang-tools-extra/trunk/clang-tidy/android/CMakeLists.txt
@@ -14,6 +14,7 @@
   CloexecInotifyInitCheck.cpp
   CloexecMemfdCreateCheck.cpp
   CloexecOpenCheck.cpp
+  CloexecPipe2Check.cpp
   CloexecSocketCheck.cpp
   ComparisonInTempFailureRetryCheck.cpp
 
Index: clang-tools-extra/trunk/clang-tidy/android/CloexecPipe2Check.h
===
--- clang-tools-extra/trunk/clang-tidy/android/CloexecPipe2Check.h
+++ clang-tools-extra/trunk/clang-tidy/android/CloexecPipe2Check.h
@@ -0,0 +1,34 @@
+//===--- CloexecPipe2Check.h - clang-tidy*- 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 LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_PIPE2_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_PIPE2_H
+
+#include "CloexecCheck.h"
+
+namespace clang {
+namespace tidy {
+namespace android {
+
+/// Finds code that uses pipe2() without using the O_CLOEXEC flag.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/android-cloexec-pipe2.html
+class CloexecPipe2Check : public CloexecCheck {
+public:
+  CloexecPipe2Check(StringRef Name, ClangTidyContext *Context