[PATCH] D61817: [analyzer] Add a prunable note for skipping virtual base initializers in subclasses.

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

This is how it looks:

F8864205: Screen Shot 2019-05-10 at 8.23.34 PM.png 



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

https://reviews.llvm.org/D61817



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


[PATCH] D61817: [analyzer] Add a prunable note for skipping virtual base initializers in subclasses.

2019-05-10 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, a_sidorin, rnkovacs, 
mikhail.ramalho, Szelethus, baloghadamsoftware, Charusso.
Herald added subscribers: cfe-commits, dkrupp, donat.nagy, a.sidorin, szepet.
Herald added a project: clang.
NoQ updated this revision to Diff 199121.
NoQ added a comment.
NoQ added a parent revision: D61816: [CFG] [analyzer] pr41300: Add a branch to 
skip virtual base initializers when they are handled by the superclass..

Fix formatting in tests.


When initialization of base classes is skipped as in D61816 
, we might as well tell the user about it, 
because this aspect of C++ isn't very well-known.

I used the new note tags feature (D58367 ) in 
order to implement it. In order to make use of it, i had to allow note tags to 
produce prunable notes, and i also moved the note tag factory to `CoreEngine`.


https://reviews.llvm.org/D61817

Files:
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
  clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
  clang/test/Analysis/diagnostics/initializer.cpp

Index: clang/test/Analysis/diagnostics/initializer.cpp
===
--- /dev/null
+++ clang/test/Analysis/diagnostics/initializer.cpp
@@ -0,0 +1,44 @@
+// RUN: %clang_analyze_cc1 -w -analyzer-checker=core -analyzer-output=text \
+// RUN:   -verify %s
+
+namespace note_on_skipped_vbases {
+struct A {
+  int x;
+  A() : x(0) {} // expected-note{{The value 0 is assigned to 'c.x'}}
+  A(int x) : x(x) {}
+};
+
+struct B : virtual A {
+  int y;
+  // This note appears only once, when this constructor is called from C.
+  // When this constructor is called from D, this note is still correct but
+  // it doesn't appear because it's pruned out because it's irrelevant to the
+  // bug report.
+  B(): // expected-note{{Virtual base initializer is skipped because it has already been initialized by the superclass}}
+A(1),
+y(1 / x) // expected-warning{{Division by zero}}
+ // expected-note@-1{{Division by zero}}
+  {}
+};
+
+struct C : B {
+  C(): // expected-note{{Calling default constructor for 'A'}}
+   // expected-note@-1{{Returning from default constructor for 'A'}}
+B() // expected-note{{Calling default constructor for 'B'}}
+  {}
+};
+
+void test_note() {
+  C c; // expected-note{{Calling default constructor for 'C'}}
+}
+
+struct D: B {
+  D() : A(1), B() {}
+};
+
+void test_prunability() {
+  D d;
+  1 / 0; // expected-warning{{Division by zero}}
+ // expected-note@-1{{Division by zero}}
+}
+} // namespace note_on_skipped_vbases
Index: clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
===
--- clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
+++ clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
@@ -724,7 +724,15 @@
   const Stmt* S = nullptr;
   if (Optional BE = P.getAs()) {
 const CFGBlock *BSrc = BE->getSrc();
-S = BSrc->getTerminatorCondition();
+if (BSrc->getTerminator().getKind() == CFGTerminator::VirtualBasesBranch) {
+  // TODO: VirtualBaseBranches should also appear for destructors.
+  // In this case we should put the diagnostic at the end of decl.
+  return PathDiagnosticLocation::createBegin(
+  P.getLocationContext()->getDecl(), SMng);
+
+} else {
+  S = BSrc->getTerminatorCondition();
+}
   } else if (Optional SP = P.getAs()) {
 S = SP->getStmt();
 if (P.getAs())
Index: clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
===
--- clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
@@ -216,6 +216,26 @@
LC->getDecl(),
LC->getCFG()->getNumBlockIDs());
 
+  // Display a prunable path note to the user if it's a virtual bases branch.
+  if (L.getSrc()->getTerminator().getKind() ==
+  CFGTerminator::VirtualBasesBranch) {
+// But only if we're actually skipping the virtual constructors.
+if (L.getDst() == *L.getSrc()->succ_begin()) {
+  ProgramPoint P = L.withTag(getNoteTags().makeNoteTag(
+  [](BugReporterContext &, BugReport &) -> std::string {
+return "Virtual base initializer is skipped because "
+   "it has already been initialized by the superclass";
+  },
+  /*IsPrunable=*/true));
+  // Perform the transition.
+  ExplodedNodeSet Dst;
+  NodeBuilder Bldr(Pred, Dst, BuilderCtx);
+  Pred = Bldr.generateNode(P, Pred->getState(), Pred);
+  if (!Pred)
+return;
+}
+ 

[PATCH] D61817: [analyzer] Add a prunable note for skipping virtual base initializers in subclasses.

2019-05-10 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 199121.
NoQ added a comment.

Fix formatting in tests.


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

https://reviews.llvm.org/D61817

Files:
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
  clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
  clang/test/Analysis/diagnostics/initializer.cpp

Index: clang/test/Analysis/diagnostics/initializer.cpp
===
--- /dev/null
+++ clang/test/Analysis/diagnostics/initializer.cpp
@@ -0,0 +1,44 @@
+// RUN: %clang_analyze_cc1 -w -analyzer-checker=core -analyzer-output=text \
+// RUN:   -verify %s
+
+namespace note_on_skipped_vbases {
+struct A {
+  int x;
+  A() : x(0) {} // expected-note{{The value 0 is assigned to 'c.x'}}
+  A(int x) : x(x) {}
+};
+
+struct B : virtual A {
+  int y;
+  // This note appears only once, when this constructor is called from C.
+  // When this constructor is called from D, this note is still correct but
+  // it doesn't appear because it's pruned out because it's irrelevant to the
+  // bug report.
+  B(): // expected-note{{Virtual base initializer is skipped because it has already been initialized by the superclass}}
+A(1),
+y(1 / x) // expected-warning{{Division by zero}}
+ // expected-note@-1{{Division by zero}}
+  {}
+};
+
+struct C : B {
+  C(): // expected-note{{Calling default constructor for 'A'}}
+   // expected-note@-1{{Returning from default constructor for 'A'}}
+B() // expected-note{{Calling default constructor for 'B'}}
+  {}
+};
+
+void test_note() {
+  C c; // expected-note{{Calling default constructor for 'C'}}
+}
+
+struct D: B {
+  D() : A(1), B() {}
+};
+
+void test_prunability() {
+  D d;
+  1 / 0; // expected-warning{{Division by zero}}
+ // expected-note@-1{{Division by zero}}
+}
+} // namespace note_on_skipped_vbases
Index: clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
===
--- clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
+++ clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
@@ -724,7 +724,15 @@
   const Stmt* S = nullptr;
   if (Optional BE = P.getAs()) {
 const CFGBlock *BSrc = BE->getSrc();
-S = BSrc->getTerminatorCondition();
+if (BSrc->getTerminator().getKind() == CFGTerminator::VirtualBasesBranch) {
+  // TODO: VirtualBaseBranches should also appear for destructors.
+  // In this case we should put the diagnostic at the end of decl.
+  return PathDiagnosticLocation::createBegin(
+  P.getLocationContext()->getDecl(), SMng);
+
+} else {
+  S = BSrc->getTerminatorCondition();
+}
   } else if (Optional SP = P.getAs()) {
 S = SP->getStmt();
 if (P.getAs())
Index: clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
===
--- clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
@@ -216,6 +216,26 @@
LC->getDecl(),
LC->getCFG()->getNumBlockIDs());
 
+  // Display a prunable path note to the user if it's a virtual bases branch.
+  if (L.getSrc()->getTerminator().getKind() ==
+  CFGTerminator::VirtualBasesBranch) {
+// But only if we're actually skipping the virtual constructors.
+if (L.getDst() == *L.getSrc()->succ_begin()) {
+  ProgramPoint P = L.withTag(getNoteTags().makeNoteTag(
+  [](BugReporterContext &, BugReport &) -> std::string {
+return "Virtual base initializer is skipped because "
+   "it has already been initialized by the superclass";
+  },
+  /*IsPrunable=*/true));
+  // Perform the transition.
+  ExplodedNodeSet Dst;
+  NodeBuilder Bldr(Pred, Dst, BuilderCtx);
+  Pred = Bldr.generateNode(P, Pred->getState(), Pred);
+  if (!Pred)
+return;
+}
+  }
+
   // Check if we are entering the EXIT block.
   if (Blk == &(L.getLocationContext()->getCFG()->getExit())) {
 assert(L.getLocationContext()->getCFG()->getExit().empty() &&
Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -2501,7 +2501,9 @@
   if (Optional Msg = T->generateMessage(BRC, R)) {
 PathDiagnosticLocation Loc =
 PathDiagnosticLocation::create(PP, BRC.getSourceManager());
-return std::make_shared(Loc, *Msg);
+auto Piece = std::make_shared(Loc, *Msg);
+Piece->setPrunable(T->isPrunable());
+return Piece;
   }
 
   return 

[PATCH] D61816: [CFG] [analyzer] pr41300: Add a branch to skip virtual base initializers when they are handled by the superclass.

2019-05-10 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, a_sidorin, rnkovacs, 
mikhail.ramalho, Szelethus, baloghadamsoftware, Charusso.
Herald added subscribers: cfe-commits, dkrupp, donat.nagy, a.sidorin, szepet.
Herald added a project: clang.

A copy-paste from https://bugs.llvm.org/show_bug.cgi?id=41300#c4:

> A cleaner repro:
> 
>   #include 
>   
>   struct S {
> S() { std::cout << "  Calling S()" << std::endl; }
>   };
>   
>   struct A {
> A() { std::cout << "  Calling A()" << std::endl; }
> A(S s) { std::cout << "  Calling A(S)" << std::endl; }
>   };
>   
>   struct B : virtual A {
> B() : A(S()) { std::cout << "  Calling B()" << std::endl; }
>   };
>   
>   struct C : B {
> C() { std::cout << "  Calling C()" << std::endl; }
>   };
>   
>   int main() {
> std::cout << "Constructing 'b':" << std::endl;
> B b;
>   
> std::cout << "Constructing 'c':" << std::endl;
> C c;
> return 0;
>   }
> 
> 
> The output of this program if you run it:
> 
> Constructing 'b':
> 
>   Calling S()
>   Calling A(S)
>   Calling B()
> 
> Constructing 'c':
> 
>   Calling A()
>   Calling B()
>   Calling C()
>
> 
> So, like, when calling the constructor for class `B` from class `C`, we 
> silently (even under -Weverything) ignore the initializer `A(S())`. That is, 
> we don't even compute `S()`, we just ignore it the whole initializer. But 
> when we invoke `B()` directly, we do compute `S()`.
> 
> This behavior implemented by compiling two versions of `B()`: one with the 
> initializer for `A` and one without it, as can be seen in 
> https://godbolt.org/z/8Sc-Re
> 
> However in the AST there's only one constructor for `B()`, so we should 
> probably implement a runtime branch while modeling a `CXXCtorInitializer` in 
> an inlined constructor call.

This patch adds the run-time CFG branch that would skip initialization of 
virtual base classes depending on whether the constructor is called from a 
superclass constructor or not. Previously the Static Analyzer was already 
skipping virtual base-class initializers in such constructors, but it wasn't 
skipping its arguments and their potential side effects, which was causing a 
crash (and was generally incorrect). The previous skipping behavior is replaced 
with a hard assertion that we're not even getting there due to how our CFG 
works.

The new CFG element is under a CFG build option so that not to break other 
consumers of the CFG by this change. Static Analyzer support for this change is 
implemented.

I've no idea how to write `CFGBuilder` code correctly because it's confusing 
because everything depends on the global mutable state of `Block` and `Succ` in 
the CFGBuilder. But i hope that `initializers-cfg-output.cpp`, together with 
the newly added test, provides some basic test coverage for my code.

Note that a similar functionality is necessary for destructors of virtual 
bases, but it remains to be done for now. We should be able to re-use the same 
terminator kind.


Repository:
  rC Clang

https://reviews.llvm.org/D61816

Files:
  clang/include/clang/Analysis/AnalysisDeclContext.h
  clang/include/clang/Analysis/CFG.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
  clang/lib/Analysis/AnalysisDeclContext.cpp
  clang/lib/Analysis/CFG.cpp
  clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp
  clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  clang/test/Analysis/initializer.cpp
  clang/test/Analysis/initializers-cfg-output.cpp

Index: clang/test/Analysis/initializers-cfg-output.cpp
===
--- clang/test/Analysis/initializers-cfg-output.cpp
+++ clang/test/Analysis/initializers-cfg-output.cpp
@@ -30,21 +30,25 @@
 class B : public virtual A {
 public:
   // CHECK:   B()
-  // CHECK:[B2 (ENTRY)]
-  // CHECK-NEXT: Succs (1): B1
+  // CHECK:[B3 (ENTRY)]
+  // CHECK-NEXT: Succs (1): B2
   // CHECK:[B1]
   // WARNINGS-NEXT: 1:  (CXXConstructExpr, class A)
   // ANALYZER-NEXT: 1:  (CXXConstructExpr, A() (Base initializer), class A)
   // CHECK-NEXT: 2: A([B1.1]) (Base initializer)
   // CHECK-NEXT: Preds (1): B2
   // CHECK-NEXT: Succs (1): B0
+  // CHECK:[B2]
+  // CHECK-NEXT: T: (See if superclass ctor has already initialized vbases)
+  // CHECK-NEXT: Preds (1): B3
+  // CHECK-NEXT: Succs (2): B0 B1
   // CHECK:[B0 (EXIT)]
-  // CHECK-NEXT: Preds (1): B1
+  // CHECK-NEXT: Preds (2): B1 B2
   B() {}
 
   // CHECK:   B(int i)
-  // CHECK:[B2 (ENTRY)]
-  // CHECK-NEXT: Succs (1): B1
+  // CHECK:[B3 (ENTRY)]
+  // CHECK-NEXT: Succs (1): B2
   // CHECK:[B1]
   // CHECK-NEXT: 1: i
   // CHECK-NEXT: 2: [B1.1] (ImplicitCastExpr, LValueToRValue, int)
@@ -53,29 +57,37 @@
   // CHECK-NEXT: 4: A([B1.3]) (Base initializer)
   // CHECK-NEXT: Preds (1): B2
   // 

[PATCH] D61814: [CFG] NFC: Remove implicit conversion from CFGTerminator to Stmt *, make it a variant class instead.

2019-05-10 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, a_sidorin, rnkovacs, 
mikhail.ramalho, Szelethus, baloghadamsoftware, Charusso.
Herald added subscribers: cfe-commits, zzheng, whisperity.
Herald added a project: clang.

This conversion does indeed save some code, but i plan to add support for more 
kinds of terminators that aren't necessarily based on statements, and as i do, 
it becomes more and more confusing to have it implicitly convertible to a `Stmt 
*`.


Repository:
  rC Clang

https://reviews.llvm.org/D61814

Files:
  clang/include/clang/Analysis/CFG.h
  clang/include/clang/Analysis/ProgramPoint.h
  clang/lib/Analysis/CFG.cpp
  clang/lib/Analysis/CFGStmtMap.cpp
  clang/lib/Analysis/Consumed.cpp
  clang/lib/Analysis/LiveVariables.cpp
  clang/lib/Analysis/ProgramPoint.cpp
  clang/lib/Analysis/ReachableCode.cpp
  clang/lib/Analysis/ThreadSafety.cpp
  clang/lib/Analysis/UninitializedValues.cpp
  clang/lib/Sema/AnalysisBasedWarnings.cpp
  clang/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp
  clang/lib/StaticAnalyzer/Core/BugReporter.cpp
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
  clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp

Index: clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
===
--- clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
+++ clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
@@ -794,7 +794,7 @@
   if (auto SP = P.getAs())
 return SP->getStmt();
   if (auto BE = P.getAs())
-return BE->getSrc()->getTerminator();
+return BE->getSrc()->getTerminatorStmt();
   if (auto CE = P.getAs())
 return CE->getCallExpr();
   if (auto CEE = P.getAs())
Index: clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
===
--- clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
+++ clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
@@ -234,7 +234,7 @@
 
 ProgramPoint P = N->getLocation();
 if (Optional BE = P.getAs())
-  S = BE->getBlock()->getTerminator();
+  S = BE->getBlock()->getTerminatorStmt();
 
 if (S == LoopStmt)
   return false;
Index: clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -1861,7 +1861,7 @@
   // other constraints) then consider completely unrolling it.
   if(AMgr.options.ShouldUnrollLoops) {
 unsigned maxBlockVisitOnPath = AMgr.options.maxBlockVisitOnPath;
-const Stmt *Term = nodeBuilder.getContext().getBlock()->getTerminator();
+const Stmt *Term = nodeBuilder.getContext().getBlock()->getTerminatorStmt();
 if (Term) {
   ProgramStateRef NewState = updateLoopStack(Term, AMgr.getASTContext(),
  Pred, maxBlockVisitOnPath);
@@ -1882,7 +1882,7 @@
   unsigned int BlockCount = nodeBuilder.getContext().blockCount();
   if (BlockCount == AMgr.options.maxBlockVisitOnPath - 1 &&
   AMgr.options.ShouldWidenLoops) {
-const Stmt *Term = nodeBuilder.getContext().getBlock()->getTerminator();
+const Stmt *Term = nodeBuilder.getContext().getBlock()->getTerminatorStmt();
 if (!(Term &&
   (isa(Term) || isa(Term) || isa(Term
   return;
@@ -2007,8 +2007,8 @@
   if (!BO || !BO->isLogicalOp())
 return Condition;
 
-  assert(!B->getTerminator().isTemporaryDtorsBranch() &&
- "Temporary destructor branches handled by processBindTemporary.");
+  assert(B->getTerminator().getKind() == CFGTerminator::StmtBranch &&
+ "Other kinds of branches are handled separately!");
 
   // For logical operations, we still have the case where some branches
   // use the traditional "merge" approach and others sink the branch
Index: clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
===
--- clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
@@ -275,14 +275,14 @@
 }
 
 void CoreEngine::HandleBlockExit(const CFGBlock * B, ExplodedNode *Pred) {
-  if (const Stmt *Term = B->getTerminator()) {
+  if (const Stmt *Term = B->getTerminatorStmt()) {
 switch (Term->getStmtClass()) {
   default:
 llvm_unreachable("Analysis for this terminator not implemented.");
 
   case Stmt::CXXBindTemporaryExprClass:
 HandleCleanupTemporaryBranch(
-cast(B->getTerminator().getStmt()), B, Pred);
+cast(Term), B, Pred);
 return;
 
   // Model static initializers.
Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ 

r360499 - Reject attempts to call non-static member functions on objects outside

2019-05-10 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri May 10 19:00:06 2019
New Revision: 360499

URL: http://llvm.org/viewvc/llvm-project?rev=360499=rev
Log:
Reject attempts to call non-static member functions on objects outside
their lifetime in constant expressions.

This is undefined behavior per [class.cdtor]p2.

We continue to allow this for objects whose values are not visible
within the constant evaluation, because there's no way we can tell
whether the access is defined or not, existing code relies on the
ability to make such calls, and every other compiler allows such
calls.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/CXX/expr/expr.const/p2-0x.cpp
cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td?rev=360499=360498=360499=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td Fri May 10 19:00:06 2019
@@ -67,13 +67,13 @@ def note_constexpr_past_end : Note<
   "%select{temporary|%2}1 is not a constant expression">;
 def note_constexpr_past_end_subobject : Note<
   "cannot %select{access base class of|access derived class of|access field 
of|"
-  "access array element of|ERROR|call member function on|"
+  "access array element of|ERROR|"
   "access real component of|access imaginary component of}0 "
   "pointer past the end of object">;
 def note_constexpr_null_subobject : Note<
   "cannot %select{access base class of|access derived class of|access field 
of|"
   "access array element of|perform pointer arithmetic on|"
-  "call member function on|access real component of|"
+  "access real component of|"
   "access imaginary component of}0 null pointer">;
 def note_constexpr_var_init_non_constant : Note<
   "initializer of %0 is not a constant expression">;
@@ -96,10 +96,10 @@ def note_constexpr_this : Note<
   "%select{|implicit }0use of 'this' pointer is only allowed within the "
   "evaluation of a call to a 'constexpr' member function">;
 def note_constexpr_lifetime_ended : Note<
-  "%select{read of|assignment to|increment of|decrement of}0 "
+  "%select{read of|assignment to|increment of|decrement of|member call on}0 "
   "%select{temporary|variable}1 whose lifetime has ended">;
 def note_constexpr_access_uninit : Note<
-  "%select{read of|assignment to|increment of|decrement of}0 "
+  "%select{read of|assignment to|increment of|decrement of|member call on}0 "
   "object outside its lifetime is not allowed in a constant expression">;
 def note_constexpr_use_uninit_reference : Note<
   "use of reference outside its lifetime "
@@ -108,10 +108,10 @@ def note_constexpr_modify_const_type : N
   "modification of object of const-qualified type %0 is not allowed "
   "in a constant expression">;
 def note_constexpr_access_volatile_type : Note<
-  "%select{read of|assignment to|increment of|decrement of}0 "
+  "%select{read of|assignment to|increment of|decrement of|}0 "
   "volatile-qualified type %1 is not allowed in a constant expression">;
 def note_constexpr_access_volatile_obj : Note<
-  "%select{read of|assignment to|increment of|decrement of}0 volatile "
+  "%select{read of|assignment to|increment of|decrement of|}0 volatile "
   "%select{temporary|object %2|member %2}1 is not allowed in "
   "a constant expression">;
 def note_constexpr_volatile_here : Note<
@@ -125,21 +125,21 @@ def note_constexpr_ltor_non_constexpr :
 def note_constexpr_ltor_incomplete_type : Note<
   "read of incomplete type %0 is not allowed in a constant expression">;
 def note_constexpr_access_null : Note<
-  "%select{read of|assignment to|increment of|decrement of}0 "
+  "%select{read of|assignment to|increment of|decrement of|member call on}0 "
   "dereferenced null pointer is not allowed in a constant expression">;
 def note_constexpr_access_past_end : Note<
-  "%select{read of|assignment to|increment of|decrement of}0 "
+  "%select{read of|assignment to|increment of|decrement of|member call on}0 "
   "dereferenced one-past-the-end pointer is not allowed in a constant 
expression">;
 def note_constexpr_access_unsized_array : Note<
-  "%select{read of|assignment to|increment of|decrement of}0 "
-  "pointer to element of array without known bound "
+  "%select{read of|assignment to|increment of|decrement of|member call on}0 "
+  "element of array without known bound "
   "is not allowed in a constant expression">;
 def note_constexpr_access_inactive_union_member : Note<
-  "%select{read of|assignment to|increment of|decrement of}0 "
+  "%select{read of|assignment to|increment of|decrement of|member call on}0 "
   "member %1 of union with %select{active member %3|no active member}2 "
   "is not allowed in a constant expression">;
 def 

[PATCH] D61809: [BPF] Preserve original struct/union type name/access index and array subscripts

2019-05-10 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

> The size you allocate here will presumably need to vary as the struct layout 
> changes, and you have no way of knowing which allocas will need their sizes 
> to be changed.

Your example is just a pointer; the size of a pointer won't change.

That said, yes, address computation isn't the only place C cares about the 
layout of a struct.  In particular variables (local or global) of struct type, 
sizeof(), and offsetof() need different handling.  But I'm not sure how much 
any of those matter for BPF.

> If this call is supposed to somehow represent that the %6 GEP is computed 
> from %5 by way of a struct field access, this will not be robust against any 
> kind of optimization: optimizations will happily rewrite uses of %6 to use %5 
> or some other form directly, and you will have lost track of the pointers you 
> need to update.

I think actually, the idea is that the intrinsic represents the computation of 
some additional adjustment, and so the following instructions use %7, the 
result of the call, not %6.  So I think the existing formulation is sound.

That said, it's awkward to have both an instruction and an intrinsic 
representing parts of the same offset computation; it probably makes sense to 
emit just the intrinsic, instead of both the intrinsic and the GEP, like you 
suggest.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61809



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


[PATCH] D61788: Make getObjCEncodingForTypeImpl() take a bitmask instead of 8 bools

2019-05-10 Thread Nico Weber via Phabricator via cfe-commits
thakis added inline comments.



Comment at: clang/include/clang/AST/ASTContext.h:2877
+OCET_EncodePointerToObjCTypedef = 1 << 7,
+  };
+  void getObjCEncodingForTypeImpl(QualType t, std::string , unsigned Options,

rjmccall wrote:
> thakis wrote:
> > rjmccall wrote:
> > > I like the idea of doing this, but can you add some boilerplate? :)  I 
> > > think it'd be better if this were a struct with some nice accessors, 
> > > factories, transformations, and so on.
> > > 
> > > This example isn't from Clang, but something like this (without the 
> > > templating, of course): 
> > > https://github.com/apple/swift/blob/14a20eea03e9115e2c5cf91bccc86e6cd5334df9/include/swift/ABI/MetadataValues.h#L118
> > Done. It got pretty wordy (+30 lines instead of -30 before), so I x-macro'd 
> > it a bit.
> That looks good, but please `camelCase` the method names.  Also, the method 
> names sound like they mutate `this` rather than returning a value with the 
> mutation in effect.
Made them mutate this, except for keepOnly() which I renamed keepingOnly() and 
marked LLVM_NODISCARD, and clear which is now forComponentType() and also 
LLVM_NODISCARD.

Made all methods except the accessors camelCase. (Making the first letter lower 
case as-is is tricky with the xmacro, and isExpandPointedToStructures sounds 
strange. hasExpandPointedToStructures sounds better, but hasIsStructField is 
weird.)


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

https://reviews.llvm.org/D61788



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


[PATCH] D61788: Make getObjCEncodingForTypeImpl() take a bitmask instead of 8 bools

2019-05-10 Thread Nico Weber via Phabricator via cfe-commits
thakis updated this revision to Diff 199116.
thakis marked 4 inline comments as done.
thakis added a comment.

comments


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

https://reviews.llvm.org/D61788

Files:
  clang/include/clang/AST/ASTContext.h
  clang/lib/AST/ASTContext.cpp

Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -6303,13 +6303,13 @@
   // Encode type qualifer, 'in', 'inout', etc. for the parameter.
   getObjCEncodingForTypeQualifier(QT, S);
   // Encode parameter type.
-  getObjCEncodingForTypeImpl(T, S, /*ExpandPointedToStructures=*/true,
- /*ExpandStructures=*/true, /*Field=*/nullptr,
- /*OutermostType=*/true,
- /*EncodingProperty=*/false,
- /*StructField=*/false,
- /*EncodeBlockParameters=*/Extended,
- /*EncodeClassNames=*/Extended);
+  ObjCEncOptions Options = ObjCEncOptions()
+   .setExpandPointedToStructures()
+   .setExpandStructures()
+   .setIsOutermostType();
+  if (Extended)
+Options.setEncodeBlockParameters().setEncodeClassNames();
+  getObjCEncodingForTypeImpl(T, S, Options, /*Field=*/nullptr);
 }
 
 /// getObjCEncodingForMethodDecl - Return the encoded type for this method
@@ -6501,13 +6501,12 @@
   // directly pointed to, and expanding embedded structures. Note that
   // these rules are sufficient to prevent recursive encoding of the
   // same type.
-  getObjCEncodingForTypeImpl(T, S, /*ExpandPointedToStructures=*/true,
- /*ExpandStructures=*/true, Field,
- /*OutermostType=*/true, /*EncodingProperty=*/false,
- /*StructField=*/false,
- /*EncodeBlockParameters=*/false,
- /*EncodeClassNames=*/false,
- /*EncodePointerToObjCTypedef=*/false, NotEncodedT);
+  getObjCEncodingForTypeImpl(T, S,
+ ObjCEncOptions()
+ .setExpandPointedToStructures()
+ .setExpandStructures()
+ .setIsOutermostType(),
+ Field, NotEncodedT);
 }
 
 void ASTContext::getObjCEncodingForPropertyType(QualType T,
@@ -6515,9 +6514,13 @@
   // Encode result type.
   // GCC has some special rules regarding encoding of properties which
   // closely resembles encoding of ivars.
-  getObjCEncodingForTypeImpl(
-  T, S, /*ExpandPointedToStructures=*/true, /*ExpandStructures=*/true,
-  /*Field=*/nullptr, /*OutermostType=*/true, /*EncodingProperty=*/true);
+  getObjCEncodingForTypeImpl(T, S,
+ ObjCEncOptions()
+ .setExpandPointedToStructures()
+ .setExpandStructures()
+ .setIsOutermostType()
+ .setEncodingProperty(),
+ /*Field=*/nullptr);
 }
 
 static char getObjCEncodingForPrimitiveKind(const ASTContext *C,
@@ -6664,16 +6667,9 @@
 }
 
 // FIXME: Use SmallString for accumulating string.
-void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
-bool ExpandPointedToStructures,
-bool ExpandStructures,
+void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string ,
+ObjCEncOptions Options,
 const FieldDecl *FD,
-bool OutermostType,
-bool EncodingProperty,
-bool StructField,
-bool EncodeBlockParameters,
-bool EncodeClassNames,
-bool EncodePointerToObjCTypedef,
 QualType *NotEncodedT) const {
   CanQualType CT = getCanonicalType(T);
   switch (CT->getTypeClass()) {
@@ -6690,18 +6686,16 @@
   case Type::Complex: {
 const auto *CT = T->castAs();
 S += 'j';
-getObjCEncodingForTypeImpl(CT->getElementType(), S,
-   /*ExpandPointedToStructures=*/false,
-   /*ExpandStructures=*/false, /*Field=*/nullptr);
+getObjCEncodingForTypeImpl(CT->getElementType(), S, ObjCEncOptions(),
+   /*Field=*/nullptr);
 return;
   }
 
   case Type::Atomic: {
 const auto *AT = T->castAs();
 S += 'A';
-getObjCEncodingForTypeImpl(AT->getValueType(), S,
-   

[PATCH] D61777: [cc1as] Change -compress-debug-sections= to use --

2019-05-10 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay abandoned this revision.
MaskRay added a comment.

Sorry, I have to commit this rC360495  now 
to unbreak our internal builds. Not sure whether the single dash form is 
necessary, but rC360495  keeps it.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61777



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


r360495 - [cc1as] Change -compress-debug-sections= to use --

2019-05-10 Thread Fangrui Song via cfe-commits
Author: maskray
Date: Fri May 10 18:14:50 2019
New Revision: 360495

URL: http://llvm.org/viewvc/llvm-project?rev=360495=rev
Log:
[cc1as] Change -compress-debug-sections= to use --

The double dash form is documented by GNU as, used by gcc, and accepted by 
llvm-mc.

Modified:
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
cfe/trunk/test/Driver/compress-noias.c
cfe/trunk/test/Driver/compress.c

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=360495=360494=360495=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Fri May 10 18:14:50 2019
@@ -178,7 +178,7 @@ def record_command_line : Separate<["-"]
   HelpText<"The string to embed in the .LLVM.command.line section.">;
 def compress_debug_sections : Flag<["-", "--"], "compress-debug-sections">,
 HelpText<"DWARF debug sections compression">;
-def compress_debug_sections_EQ : Joined<["-"], "compress-debug-sections=">,
+def compress_debug_sections_EQ : Joined<["-", "--"], 
"compress-debug-sections=">,
 HelpText<"DWARF debug sections compression type">;
 def mno_exec_stack : Flag<["-"], "mnoexecstack">,
   HelpText<"Mark the file as not needing an executable stack">;

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=360495=360494=360495=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Fri May 10 18:14:50 2019
@@ -1007,7 +1007,7 @@ static void RenderDebugInfoCompressionAr
   if (checkDebugInfoOption(A, Args, D, TC)) {
 if (A->getOption().getID() == options::OPT_gz) {
   if (llvm::zlib::isAvailable())
-CmdArgs.push_back("-compress-debug-sections");
+CmdArgs.push_back("--compress-debug-sections");
   else
 D.Diag(diag::warn_debug_compression_unavailable);
   return;
@@ -1015,11 +1015,11 @@ static void RenderDebugInfoCompressionAr
 
 StringRef Value = A->getValue();
 if (Value == "none") {
-  CmdArgs.push_back("-compress-debug-sections=none");
+  CmdArgs.push_back("--compress-debug-sections=none");
 } else if (Value == "zlib" || Value == "zlib-gnu") {
   if (llvm::zlib::isAvailable()) {
 CmdArgs.push_back(
-Args.MakeArgString("-compress-debug-sections=" + Twine(Value)));
+Args.MakeArgString("--compress-debug-sections=" + Twine(Value)));
   } else {
 D.Diag(diag::warn_debug_compression_unavailable);
   }

Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=360495=360494=360495=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Fri May 10 18:14:50 2019
@@ -627,14 +627,12 @@ void tools::gnutools::Assembler::Constru
 
   if (const Arg *A = Args.getLastArg(options::OPT_gz, options::OPT_gz_EQ)) {
 if (A->getOption().getID() == options::OPT_gz) {
-  CmdArgs.push_back("-compress-debug-sections");
+  CmdArgs.push_back("--compress-debug-sections");
 } else {
   StringRef Value = A->getValue();
-  if (Value == "none") {
-CmdArgs.push_back("-compress-debug-sections=none");
-  } else if (Value == "zlib" || Value == "zlib-gnu") {
+  if (Value == "none" || Value == "zlib" || Value == "zlib-gnu") {
 CmdArgs.push_back(
-Args.MakeArgString("-compress-debug-sections=" + Twine(Value)));
+Args.MakeArgString("--compress-debug-sections=" + Twine(Value)));
   } else {
 D.Diag(diag::err_drv_unsupported_option_argument)
 << A->getOption().getName() << Value;

Modified: cfe/trunk/test/Driver/compress-noias.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/compress-noias.c?rev=360495=360494=360495=diff
==
--- cfe/trunk/test/Driver/compress-noias.c (original)
+++ cfe/trunk/test/Driver/compress-noias.c Fri May 10 18:14:50 2019
@@ -17,19 +17,19 @@
 
 // RUN: %clang -### -target i686-unknown-linux-gnu -fno-integrated-as -gz -x 
assembler -c %s 2>&1 | FileCheck -check-prefix CHECK-OPT_GZ %s
 // RUN: %clang -### -target i686-unknown-linux-gnu -fno-integrated-as -gz -c 
%s 2>&1 | FileCheck -check-prefix CHECK-OPT_GZ %s
-// CHECK-OPT_GZ: "-compress-debug-sections"
+// CHECK-OPT_GZ: "--compress-debug-sections"
 
 // RUN: %clang -### -target i686-unknown-linux-gnu -fno-integrated-as -gz=none 
-x assembler -c %s 2>&1 | FileCheck 

[PATCH] D59919: [Attributor] Deduce "returned" argument attribute

2019-05-10 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 199114.
jdoerfert added a comment.

Rebase on newest Attributor design


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59919

Files:
  clang/test/CodeGenOpenCL/as_type.cl
  llvm/include/llvm/Transforms/IPO/Attributor.h
  llvm/lib/Transforms/IPO/Attributor.cpp
  llvm/test/Transforms/FunctionAttrs/arg_nocapture.ll
  llvm/test/Transforms/FunctionAttrs/arg_returned.ll
  llvm/test/Transforms/FunctionAttrs/read_write_returned_arguments_scc.ll

Index: llvm/test/Transforms/FunctionAttrs/read_write_returned_arguments_scc.ll
===
--- llvm/test/Transforms/FunctionAttrs/read_write_returned_arguments_scc.ll
+++ llvm/test/Transforms/FunctionAttrs/read_write_returned_arguments_scc.ll
@@ -30,7 +30,7 @@
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 
 ; CHECK: Function Attrs: nounwind
-; CHECK-NEXT: define i32* @external_ret2_nrw(i32* %n0, i32* %r0, i32* %w0)
+; CHECK-NEXT: define i32* @external_ret2_nrw(i32* %n0, i32* %r0, i32* returned %w0)
 define i32* @external_ret2_nrw(i32* %n0, i32* %r0, i32* %w0) {
 entry:
   %call = call i32* @internal_ret0_nw(i32* %n0, i32* %w0)
@@ -41,7 +41,7 @@
 }
 
 ; CHECK: Function Attrs: nounwind
-; CHECK-NEXT: define internal i32* @internal_ret0_nw(i32* %n0, i32* %w0)
+; CHECK-NEXT: define internal i32* @internal_ret0_nw(i32* returned %n0, i32* %w0)
 define internal i32* @internal_ret0_nw(i32* %n0, i32* %w0) {
 entry:
   %r0 = alloca i32, align 4
@@ -70,7 +70,7 @@
 }
 
 ; CHECK: Function Attrs: nounwind
-; CHECK-NEXT: define internal i32* @internal_ret1_rrw(i32* %r0, i32* %r1, i32* %w0)
+; CHECK-NEXT: define internal i32* @internal_ret1_rrw(i32* %r0, i32* returned %r1, i32* %w0)
 define internal i32* @internal_ret1_rrw(i32* %r0, i32* %r1, i32* %w0) {
 entry:
   %0 = load i32, i32* %r0, align 4
@@ -121,7 +121,7 @@
 }
 
 ; CHECK: Function Attrs: nounwind
-; CHECK-NEXT: define internal i32* @internal_ret1_rw(i32* %r0, i32* %w0)
+; CHECK-NEXT: define internal i32* @internal_ret1_rw(i32* %r0, i32* returned %w0)
 define internal i32* @internal_ret1_rw(i32* %r0, i32* %w0) {
 entry:
   %0 = load i32, i32* %r0, align 4
@@ -147,7 +147,7 @@
 }
 
 ; CHECK: Function Attrs: nounwind
-; CHECK-NEXT: define i32* @external_source_ret2_nrw(i32* %n0, i32* %r0, i32* %w0)
+; CHECK-NEXT: define i32* @external_source_ret2_nrw(i32* %n0, i32* %r0, i32* returned %w0)
 define i32* @external_source_ret2_nrw(i32* %n0, i32* %r0, i32* %w0) {
 entry:
   %call = call i32* @external_sink_ret2_nrw(i32* %n0, i32* %r0, i32* %w0)
Index: llvm/test/Transforms/FunctionAttrs/arg_returned.ll
===
--- llvm/test/Transforms/FunctionAttrs/arg_returned.ll
+++ llvm/test/Transforms/FunctionAttrs/arg_returned.ll
@@ -1,4 +1,8 @@
-; RUN: opt -functionattrs -attributor -S < %s | FileCheck %s
+; RUN: opt -functionattrs -S < %s | FileCheck %s --check-prefix=FNATTR
+; RUN: opt -attributor -S < %s | FileCheck %s --check-prefix=ATTRIBUTOR
+; RUN: opt -attributor -functionattrs -S < %s | FileCheck %s --check-prefix=BOTH
+; RUN: opt -attributor -attributor-max-iterations=18 -S < %s | FileCheck %s --check-prefix=FEW_IT
+; RUN: opt -attributor -attributor-max-iterations=19 -functionattrs -S < %s | FileCheck %s --check-prefix=BOTH
 ;
 ; Test cases specifically designed for the "returned" argument attribute.
 ; We use FIXME's to indicate problems and missing attributes.
@@ -6,16 +10,26 @@
 
 ; TEST SCC test returning an integer value argument
 ;
-; CHECK: Function Attrs: noinline norecurse nounwind readnone uwtable
-; CHECK: define i32 @sink_r0(i32 returned %r)
-;
-; FIXME: returned on %r missing:
-; CHECK: Function Attrs: noinline nounwind readnone uwtable
-; CHECK: define i32 @scc_r1(i32 %a, i32 %r, i32 %b)
-;
-; FIXME: returned on %r missing:
-; CHECK: Function Attrs: noinline nounwind readnone uwtable
-; CHECK: define i32 @scc_r2(i32 %a, i32 %b, i32 %r)
+; BOTH: Function Attrs: noinline norecurse nounwind readnone uwtable
+; BOTH: define i32 @sink_r0(i32 returned %r)
+; BOTH: Function Attrs: noinline norecurse nounwind readnone uwtable
+; BOTH: define i32 @sink_r0(i32 returned %r)
+; BOTH: Function Attrs: noinline norecurse nounwind readnone uwtable
+; BOTH: define i32 @scc_r1(i32 %a, i32 returned %r, i32 %b)
+; BOTH: Function Attrs: noinline norecurse nounwind readnone uwtable
+; BOTH: define i32 @scc_r2(i32 %a, i32 %b, i32 returned %r)
+; BOTH: Function Attrs: noinline norecurse nounwind readnone uwtable
+; BOTH: define i32 @scc_rX(i32 %a, i32 %b, i32 %r)
+;
+; FNATTR: define i32 @sink_r0(i32 returned %r)
+; FNATTR: define i32 @scc_r1(i32 %a, i32 %r, i32 %b)
+; FNATTR: define i32 @scc_r2(i32 %a, i32 %b, i32 %r)
+; FNATTR: define i32 @scc_rX(i32 %a, i32 %b, i32 %r)
+;
+; ATTRIBUTOR: define i32 @sink_r0(i32 returned %r)
+; ATTRIBUTOR: define i32 @scc_r1(i32 %a, i32 returned %r, i32 %b)
+; 

[PATCH] D60974: Clang IFSO driver action.

2019-05-10 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi updated this revision to Diff 199112.
plotfi added a comment.

Adding lit test cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60974

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/Types.def
  clang/include/clang/Frontend/FrontendActions.h
  clang/include/clang/Frontend/FrontendOptions.h
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CMakeLists.txt
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
  clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  clang/test/InterfaceStubs/bad-format.cpp
  clang/test/InterfaceStubs/class-template-specialization.cpp
  clang/test/InterfaceStubs/function-template-specialization.cpp
  clang/test/InterfaceStubs/inline.cpp
  clang/test/InterfaceStubs/inline.h
  clang/test/InterfaceStubs/object.cpp
  clang/test/InterfaceStubs/template-namespace-function.cpp
  clang/test/InterfaceStubs/visibility.cpp
  clang/test/InterfaceStubs/weak.cpp

Index: clang/test/InterfaceStubs/weak.cpp
===
--- /dev/null
+++ clang/test/InterfaceStubs/weak.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang -target x86_64-linux-gnu -o - -emit-interface-stubs \
+// RUN: -interface-stub-version=experimental-tapi-elf-v1 %s | \
+// RUN: FileCheck %s
+
+// RUN: %clang -target x86_64-linux-gnu -o - -emit-interface-stubs \
+// RUN: -interface-stub-version=experimental-yaml-elf-v1 %s | \
+// RUN: FileCheck --check-prefix=CHECK-YAML %s
+
+// CHECK: Symbols:
+// CHECK-NEXT:  _Z8weakFuncv: { Type: Func, Weak: true }
+// CHECK-NEXT:  _Z10strongFuncv: { Type: Func }
+
+// CHECK-YAML: Symbols:
+// CHECK-YAML-NEXT:   - Name:_Z8weakFuncv
+// CHECK-YAML-NEXT: Type:STT_FUNC
+// CHECK-YAML-NEXT: Binding: STB_WEAK
+// CHECK-YAML-NEXT:   - Name:_Z10strongFuncv
+// CHECK-YAML-NEXT: Type:STT_FUNC
+// CHECK-YAML-NEXT: Binding: STB_GLOBAL
+
+__attribute__((weak)) void weakFunc() {}
+int strongFunc() {}
+
Index: clang/test/InterfaceStubs/visibility.cpp
===
--- /dev/null
+++ clang/test/InterfaceStubs/visibility.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang -target x86_64-linux-gnu -o - -emit-interface-stubs \
+// RUN: -interface-stub-version=experimental-tapi-elf-v1 -fvisibility=hidden \
+// RUN: %s | FileCheck --check-prefix=CHECK-CMD-HIDDEN %s
+
+// RUN: %clang -target x86_64-linux-gnu -o - -emit-interface-stubs \
+// RUN: -interface-stub-version=experimental-yaml-elf-v1 -fvisibility=hidden \
+// RUN: %s | FileCheck --check-prefix=CHECK-CMD-HIDDEN %s
+
+// RUN: %clang -target x86_64-linux-gnu -o - -emit-interface-stubs \
+// RUN: -interface-stub-version=experimental-tapi-elf-v1 %s | FileCheck %s
+
+// RUN: %clang -target x86_64-linux-gnu -o - -emit-interface-stubs \
+// RUN: -interface-stub-version=experimental-yaml-elf-v1 %s | FileCheck %s
+
+// Always Be Hidden:
+// CHECK-CMD-HIDDEN-NOT: _Z6hiddenv
+// CHECK-NOT: _Z6hiddenv
+__attribute__((visibility("hidden"))) void hidden() {}
+
+// Always Be Visible:
+// CHECK-CMD-HIDDEN: _Z9nothiddenv
+// CHECK: _Z9nothiddenv
+__attribute__((visibility("default"))) void nothidden() {}
+
+// Do Whatever -fvisibility says:
+// CHECK-CMD-HIDDEN-NOT: _Z10cmdVisiblev
+// CHECK: _Z10cmdVisiblev
+void cmdVisible() {}
+
Index: clang/test/InterfaceStubs/template-namespace-function.cpp
===
--- /dev/null
+++ clang/test/InterfaceStubs/template-namespace-function.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang -target x86_64-linux-gnu -o - -emit-interface-stubs \
+// RUN: -interface-stub-version=experimental-tapi-elf-v1 %s | \
+// RUN: FileCheck %s
+
+// CHECK: Symbols:
+// CHECK-NEXT:  _ZN3qux3barEii: { Type: Func }
+// CHECK-NEXT:  _ZN3baz3addIiEET_S1_S1_: { Type: Func }
+// CHECK-NEXT:  _Z4fbarff: { Type: Func }
+// CHECK-NEXT:  _ZN3baz3addIfEET_S1_S1_: { Type: Func }
+
+namespace baz {
+template 
+T add(T a, T b) {
+  return a + b;
+}
+} // namespace baz
+
+namespace qux {
+int bar(int a, int b) { return baz::add(a, b); }
+} // namespace qux
+
+float fbar(float a, float b) { return baz::add(a, b); }
+
Index: clang/test/InterfaceStubs/object.cpp
===
--- /dev/null
+++ clang/test/InterfaceStubs/object.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang -target x86_64-linux-gnu -o - -emit-interface-stubs \
+// RUN: -interface-stub-version=experimental-tapi-elf-v1 %s | \
+// RUN: FileCheck %s
+
+// CHECK: data: { Type: Object, Size: 4 }
+int data = 1844;
+
Index: clang/test/InterfaceStubs/inline.h
===
--- /dev/null
+++ clang/test/InterfaceStubs/inline.h
@@ -0,0 +1,6 @@
+
+inline int fvih() {
+static int fortytwo = 42;
+  return fortytwo;

[PATCH] D61756: Add a __FILE_NAME__ macro.

2019-05-10 Thread Kristina Brooks via Phabricator via cfe-commits
kristina added a comment.

Need @rsmith to bless this as it's introducing a nonstandard extension, however 
small it may be. The original diff did have a consensus on it, so I didn't 
really put up a formal RFC on `cfe-dev`.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61756



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


[PATCH] D61809: [BPF] Preserve original struct/union type name/access index and array subscripts

2019-05-10 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

If I understand correctly, you want to be able to compile a program against 
some `struct` and `union` layouts, and then at load time "update" the program 
to cope with the actual layouts for those types being something else, but 
containing (at least) the set of members you know about. And your proposed 
approach is to add intrinsics into the IR that identify the GEPs that we 
emitted to model struct field accesses, but to otherwise not change the emitted 
IR. If so, I don't see how this approach to that problem can work. There seem 
to be a couple of problems:

>   %2 = alloca %struct.sk_buff*, align 8

The size you allocate here will presumably need to vary as the struct layout 
changes, and you have no way of knowing which `alloca`s will need their sizes 
to be changed.

>   %6 = getelementptr inbounds %struct.sk_buff, %struct.sk_buff* %5, i32 0, 
> i32 2, !dbg !54
>   %7 = call [10 x %union.anon]*
>   
> @llvm.preserve.di.access.index.p0a10s_union.anons.p0a10s_union.anons.p0s_struct.sk_buffs(
>   [10 x %union.anon]* %6, %struct.sk_buff* %5,
>   i8* getelementptr inbounds ([8 x i8], [8 x i8]* @0, i32 0, i32 0), i32 
> 3), !dbg !54

If this call is supposed to somehow represent that the `%6` GEP is computed 
from `%5` by way of a struct field access, this will not be robust against any 
kind of optimization: optimizations will happily rewrite uses of `%6` to use 
`%5` or some other form directly, and you will have lost track of the pointers 
you need to update.

It would seem better to me to represent a relocateable GEP directly: that is, 
instead of emitting a regular GEP and some fixup intrinsic, you could emit an 
intrinsic call //instead of// the GEP, and have the intrinsic compute the field 
offset. (And you'll need to do something about your `alloca`s, such as using an 
intrinsic to get the struct size and emitting a dynamic alloca of that size.) 
For example, instead of the above, you could emit

>   %6 = call i8* @llvm.preserve.di.access.gep.2(i8* %5, i32 0, i32 2, 
> !typeinfo)

(where `!typeinfo` is whatever information you need to identify `struct 
sk_buff` later on, when generating your relocations, and the indices you pass 
in are whichever ones you need to identify the subobject within that type 
information). Does that make sense?


Repository:
  rC Clang

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

https://reviews.llvm.org/D61809



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


r360483 - [Darwin] Introduce a new flag, -fapple-link-rtlib that forces linking of the builtins library.

2019-05-10 Thread Amara Emerson via cfe-commits
Author: aemerson
Date: Fri May 10 16:24:20 2019
New Revision: 360483

URL: http://llvm.org/viewvc/llvm-project?rev=360483=rev
Log:
[Darwin] Introduce a new flag, -fapple-link-rtlib that forces linking of the 
builtins library.

This driver flag is useful when users want to link against the compiler's
builtins, but nothing else, and so use flags like -nostdlib.

Darwin can't use -nolibc & nostdlib++ like other platforms on because we
disable all runtime lib linking with -static, which we still want to have
an option to link with the builtins.

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

Added:
cfe/trunk/test/Driver/darwin-fapple-link-rtlib.c
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
cfe/trunk/lib/Driver/ToolChains/Darwin.h

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=360483=360482=360483=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Fri May 10 16:24:20 2019
@@ -1248,6 +1248,8 @@ def fno_fine_grained_bitfield_accesses :
 def flat__namespace : Flag<["-"], "flat_namespace">;
 def flax_vector_conversions : Flag<["-"], "flax-vector-conversions">, 
Group;
 def flimited_precision_EQ : Joined<["-"], "flimited-precision=">, 
Group;
+def fapple_link_rtlib : Flag<["-"], "fapple-link-rtlib">, Group,
+  HelpText<"Force linking the clang builtins runtime library">;
 def flto_EQ : Joined<["-"], "flto=">, Flags<[CoreOption, CC1Option]>, 
Group,
   HelpText<"Set LTO mode to either 'full' or 'thin'">, Values<"thin,full">;
 def flto : Flag<["-"], "flto">, Flags<[CoreOption, CC1Option]>, Group,

Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=360483=360482=360483=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Fri May 10 16:24:20 2019
@@ -593,15 +593,26 @@ void darwin::Linker::ConstructJob(Compil
 
   if (getToolChain().ShouldLinkCXXStdlib(Args))
 getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
-// link_ssp spec is empty.
 
-// Let the tool chain choose which runtime library to link.
-getMachOToolChain().AddLinkRuntimeLibArgs(Args, CmdArgs);
+  bool NoStdOrDefaultLibs =
+  Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs);
+  bool ForceLinkBuiltins = Args.hasArg(options::OPT_fapple_link_rtlib);
+  if (!NoStdOrDefaultLibs || ForceLinkBuiltins) {
+// link_ssp spec is empty.
 
-// No need to do anything for pthreads. Claim argument to avoid warning.
-Args.ClaimAllArgs(options::OPT_pthread);
-Args.ClaimAllArgs(options::OPT_pthreads);
+// If we have both -nostdlib/nodefaultlibs and -fapple-link-rtlib then
+// we just want to link the builtins, not the other libs like libSystem.
+if (NoStdOrDefaultLibs && ForceLinkBuiltins) {
+  getMachOToolChain().AddLinkRuntimeLib(Args, CmdArgs, "builtins");
+} else {
+  // Let the tool chain choose which runtime library to link.
+  getMachOToolChain().AddLinkRuntimeLibArgs(Args, CmdArgs,
+ForceLinkBuiltins);
+
+  // No need to do anything for pthreads. Claim argument to avoid warning.
+  Args.ClaimAllArgs(options::OPT_pthread);
+  Args.ClaimAllArgs(options::OPT_pthreads);
+}
   }
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
@@ -1128,7 +1139,8 @@ ToolChain::RuntimeLibType DarwinClang::G
 }
 
 void DarwinClang::AddLinkRuntimeLibArgs(const ArgList ,
-ArgStringList ) const {
+ArgStringList ,
+bool ForceLinkBuiltinRT) const {
   // Call once to ensure diagnostic is printed if wrong value was specified
   GetRuntimeLibType(Args);
 
@@ -1136,8 +1148,11 @@ void DarwinClang::AddLinkRuntimeLibArgs(
   // libraries with -static.
   if (Args.hasArg(options::OPT_static) ||
   Args.hasArg(options::OPT_fapple_kext) ||
-  Args.hasArg(options::OPT_mkernel))
+  Args.hasArg(options::OPT_mkernel)) {
+if (ForceLinkBuiltinRT)
+  AddLinkRuntimeLib(Args, CmdArgs, "builtins");
 return;
+  }
 
   // Reject -static-libgcc for now, we can deal with this when and if someone
   // cares. This is useful in situations where someone wants to statically link
@@ -2106,7 +2121,8 @@ DerivedArgList *MachO::TranslateArgs(con
 }
 
 void MachO::AddLinkRuntimeLibArgs(const ArgList ,
-  ArgStringList ) const {
+  ArgStringList ,
+   

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

2019-05-10 Thread Amara Emerson via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL360483: [Darwin] Introduce a new flag, -fapple-link-rtlib 
that forces linking of the… (authored by aemerson, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58320?vs=189237=199106#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D58320

Files:
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
  cfe/trunk/lib/Driver/ToolChains/Darwin.h
  cfe/trunk/test/Driver/darwin-fapple-link-rtlib.c

Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -1248,6 +1248,8 @@
 def flat__namespace : Flag<["-"], "flat_namespace">;
 def flax_vector_conversions : Flag<["-"], "flax-vector-conversions">, Group;
 def flimited_precision_EQ : Joined<["-"], "flimited-precision=">, Group;
+def fapple_link_rtlib : Flag<["-"], "fapple-link-rtlib">, Group,
+  HelpText<"Force linking the clang builtins runtime library">;
 def flto_EQ : Joined<["-"], "flto=">, Flags<[CoreOption, CC1Option]>, Group,
   HelpText<"Set LTO mode to either 'full' or 'thin'">, Values<"thin,full">;
 def flto : Flag<["-"], "flto">, Flags<[CoreOption, CC1Option]>, Group,
Index: cfe/trunk/test/Driver/darwin-fapple-link-rtlib.c
===
--- cfe/trunk/test/Driver/darwin-fapple-link-rtlib.c
+++ cfe/trunk/test/Driver/darwin-fapple-link-rtlib.c
@@ -0,0 +1,6 @@
+// RUN: %clang -target arm64-apple-ios12.0 %s -nostdlib -fapple-link-rtlib -resource-dir=%S/Inputs/resource_dir -### 2>&1 | FileCheck %s
+// RUN: %clang -target arm64-apple-ios12.0 %s -static -fapple-link-rtlib -resource-dir=%S/Inputs/resource_dir -### 2>&1 | FileCheck %s
+// RUN: %clang -target arm64-apple-ios12.0 %s -fapple-link-rtlib -resource-dir=%S/Inputs/resource_dir -### 2>&1 | FileCheck %s --check-prefix=DEFAULT
+// CHECK-NOT: "-lSystem"
+// DEFAULT: "-lSystem"
+// CHECK: libclang_rt.ios.a
Index: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
@@ -593,15 +593,26 @@
 
   if (getToolChain().ShouldLinkCXXStdlib(Args))
 getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
-// link_ssp spec is empty.
 
-// Let the tool chain choose which runtime library to link.
-getMachOToolChain().AddLinkRuntimeLibArgs(Args, CmdArgs);
+  bool NoStdOrDefaultLibs =
+  Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs);
+  bool ForceLinkBuiltins = Args.hasArg(options::OPT_fapple_link_rtlib);
+  if (!NoStdOrDefaultLibs || ForceLinkBuiltins) {
+// link_ssp spec is empty.
 
-// No need to do anything for pthreads. Claim argument to avoid warning.
-Args.ClaimAllArgs(options::OPT_pthread);
-Args.ClaimAllArgs(options::OPT_pthreads);
+// If we have both -nostdlib/nodefaultlibs and -fapple-link-rtlib then
+// we just want to link the builtins, not the other libs like libSystem.
+if (NoStdOrDefaultLibs && ForceLinkBuiltins) {
+  getMachOToolChain().AddLinkRuntimeLib(Args, CmdArgs, "builtins");
+} else {
+  // Let the tool chain choose which runtime library to link.
+  getMachOToolChain().AddLinkRuntimeLibArgs(Args, CmdArgs,
+ForceLinkBuiltins);
+
+  // No need to do anything for pthreads. Claim argument to avoid warning.
+  Args.ClaimAllArgs(options::OPT_pthread);
+  Args.ClaimAllArgs(options::OPT_pthreads);
+}
   }
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
@@ -1128,7 +1139,8 @@
 }
 
 void DarwinClang::AddLinkRuntimeLibArgs(const ArgList ,
-ArgStringList ) const {
+ArgStringList ,
+bool ForceLinkBuiltinRT) const {
   // Call once to ensure diagnostic is printed if wrong value was specified
   GetRuntimeLibType(Args);
 
@@ -1136,8 +1148,11 @@
   // libraries with -static.
   if (Args.hasArg(options::OPT_static) ||
   Args.hasArg(options::OPT_fapple_kext) ||
-  Args.hasArg(options::OPT_mkernel))
+  Args.hasArg(options::OPT_mkernel)) {
+if (ForceLinkBuiltinRT)
+  AddLinkRuntimeLib(Args, CmdArgs, "builtins");
 return;
+  }
 
   // Reject -static-libgcc for now, we can deal with this when and if someone
   // cares. This is useful in situations where someone wants to statically link
@@ -2106,7 +2121,8 @@
 }
 
 void 

[PATCH] D60593: [GwpAsan] Introduce GWP-ASan.

2019-05-10 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse added a comment.

This diff is helpful to get an overall idea of how things fit together, but it 
is very difficult to review thoroughly.  Let's start splicing off pieces for 
individual review.

I suggest:

- Individual reviews for each prereq (mutex, random, etc.)
- Review for base GPA + unit tests
- Review for "optional" options parsing, etc.
- Review for documentation
- Review for Scudo integration + e2e tests

Submitting this in pieces (especially the Scudo integration) will also make 
things simpler if we need to revert something.




Comment at: compiler-rt/lib/gwp_asan/guarded_pool_allocator.h:97
+  // Return whether the allocation should be randomly chosen for sampling.
+  ALWAYS_INLINE bool shouldSample() {
+// NextSampleCounter == 0 means we "should regenerate the counter".

hctim wrote:
> morehouse wrote:
> > The assembly you posted for this function looks way too slow.  Is it 
> > actually optimized with `-O2`?
> > 
> > - The fast path (counter > 1) has *two* branches that check if 
> > `NextSampleCounter`'s TLS init function has run and one actual call to the 
> > TLS init function.  Ouch!  We shouldn't need these.
> >   - Maybe we need to make the counter function-local or use `__thread` 
> > instead of `thread_local`.
> > - The counter decrement of `NextSampleCounter` requires 4 instructions?  
> > Load TLS offset from global, read TLS, increment, write TLS.  Yikes.  For 
> > reference, TCMalloc does this operation in 1 instruction.
> > - The `+ 1` operation on the `NextSampleCounter == 0` branch is done with a 
> > mov-add, rather than an lea.
> > 
> > Again, please triple-check that the binary you compiled is actually 
> > optimized.  Make sure it is compiled with `clang++ -O2 ...`.
> > 
> > 
> As per offline discussion, declaring `NextSampleCounter` with `__thread` 
> instead of `thread_local` fixed this. Also added a note in `definitions.h`.
What is the assembly now?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60593



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


[PATCH] D61756: Add a __FILE_NAME__ macro.

2019-05-10 Thread Kristina Brooks via Phabricator via cfe-commits
kristina updated this revision to Diff 199104.
kristina edited the summary of this revision.
kristina added a comment.

Actually I got it wrong, the path is normalized to use regular slashes at that 
point, so there is no point in handling backslashes in paths at all even with 
Microsoft extensions.

After running it with a hack to dump the paths to stderr they seem to be the 
same regardless.

  [FILENAME] 
/llvm-tainted/tools/clang/test/Preprocessor/Inputs/include-subdir/subdir1/hdr1.h
  [FILENAME] 
/llvm-tainted/tools/clang/test/Preprocessor/Inputs/include-subdir/subdir1/hdr2.h

I've also extended the tests to cover scenarios with mixed slashes in MS 
compatibility mode and removed the unnecessary check.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61756

Files:
  include/clang/Lex/Preprocessor.h
  lib/Lex/PPMacroExpansion.cpp
  test/Preprocessor/Inputs/include-subdir/file_name_macro_include.h
  test/Preprocessor/Inputs/include-subdir/h
  test/Preprocessor/Inputs/include-subdir/subdir1/hdr1.h
  test/Preprocessor/Inputs/include-subdir/subdir1/hdr2.h
  test/Preprocessor/file_name_macro.c

Index: test/Preprocessor/file_name_macro.c
===
--- test/Preprocessor/file_name_macro.c
+++ test/Preprocessor/file_name_macro.c
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -E %s -I%S/Inputs | FileCheck -strict-whitespace %s
+// RUN: %clang_cc1 -fms-compatibility -DMS -E %s -I%S/Inputs | FileCheck -check-prefix=CHECK-MS -strict-whitespace %s 
+// RUN: %clang_cc1 -E %s -I%S/Inputs -DBADINC -verify
+
+#ifdef BADINC
+
+// Paranoia.
+
+__FILE_NAME__
+#include  // expected-error {{file not found}}
+__FILE_NAME__
+
+#else
+
+// Reference.
+1: "file_name_macro.c"
+
+// Ensure it expands correctly for this file.
+2: __FILE_NAME__
+
+// CHECK: {{^}}1: "file_name_macro.c"
+// CHECK: {{^}}2: "file_name_macro.c"
+
+// Test if inclusion works right.
+#ifdef MS
+#include 
+// MS compatibility allows for mixed separators in paths.
+#include 
+#include 
+#else
+#include 
+#endif
+
+#include 
+
+// CHECK: {{^}}3: "file_name_macro_include.h"
+// CHECK: {{^}}4: "file_name_macro_include.h"
+// CHECK-NOT: {{^}}5: "file_name_macro_include.h"
+// CHECK-MS: {{^}}5: "file_name_macro_include.h"
+// CHECK: {{^}}6: "h"
+// CHECK-MS: {{^}}7: "hdr1.h"
+// CHECK-MS: {{^}}8: "hdr2.h"
+
+#endif
Index: test/Preprocessor/Inputs/include-subdir/subdir1/hdr2.h
===
--- test/Preprocessor/Inputs/include-subdir/subdir1/hdr2.h
+++ test/Preprocessor/Inputs/include-subdir/subdir1/hdr2.h
@@ -0,0 +1 @@
+8: __FILE_NAME__
Index: test/Preprocessor/Inputs/include-subdir/subdir1/hdr1.h
===
--- test/Preprocessor/Inputs/include-subdir/subdir1/hdr1.h
+++ test/Preprocessor/Inputs/include-subdir/subdir1/hdr1.h
@@ -0,0 +1 @@
+7: __FILE_NAME__
Index: test/Preprocessor/Inputs/include-subdir/h
===
--- test/Preprocessor/Inputs/include-subdir/h
+++ test/Preprocessor/Inputs/include-subdir/h
@@ -0,0 +1 @@
+6: __FILE_NAME__
Index: test/Preprocessor/Inputs/include-subdir/file_name_macro_include.h
===
--- test/Preprocessor/Inputs/include-subdir/file_name_macro_include.h
+++ test/Preprocessor/Inputs/include-subdir/file_name_macro_include.h
@@ -0,0 +1,6 @@
+3: __FILE_NAME__
+4: "file_name_macro_include.h"
+#ifdef MS
+// Should be the same even when included with backslash.
+5: __FILE_NAME__
+#endif
Index: lib/Lex/PPMacroExpansion.cpp
===
--- lib/Lex/PPMacroExpansion.cpp
+++ lib/Lex/PPMacroExpansion.cpp
@@ -363,6 +363,7 @@
   }
 
   // Clang Extensions.
+  Ident__FILE_NAME__  = RegisterBuiltinMacro(*this, "__FILE_NAME__");
   Ident__has_feature  = RegisterBuiltinMacro(*this, "__has_feature");
   Ident__has_extension= RegisterBuiltinMacro(*this, "__has_extension");
   Ident__has_builtin  = RegisterBuiltinMacro(*this, "__has_builtin");
@@ -1474,7 +1475,8 @@
 // __LINE__ expands to a simple numeric value.
 OS << (PLoc.isValid()? PLoc.getLine() : 1);
 Tok.setKind(tok::numeric_constant);
-  } else if (II == Ident__FILE__ || II == Ident__BASE_FILE__) {
+  } else if (II == Ident__FILE__ || II == Ident__BASE_FILE__ ||
+ II == Ident__FILE_NAME__) {
 // C99 6.10.8: "__FILE__: The presumed name of the current source file (a
 // character string literal)". This can be affected by #line.
 PresumedLoc PLoc = SourceMgr.getPresumedLoc(Tok.getLocation());
@@ -1495,7 +1497,21 @@
 // Escape this filename.  Turn '\' -> '\\' '"' -> '\"'
 SmallString<128> FN;
 if (PLoc.isValid()) {
-  FN += PLoc.getFilename();
+  // __FILE_NAME__ is a Clang-specific extension that expands to the
+  // the last 

[PATCH] D61809: [BPF] Preserve original struct/union type name/access index and array subscripts

2019-05-10 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song added a comment.

@lebedev.ri Thanks for the comment. This patch is not ready to land yet. Yes, 
tests are missing and I am going to add tests later.
More importantly, I want to get a sense whether what I am implementing here is 
the right direction or not.
The following two other patches are also related to describe our end goal:

  https://reviews.llvm.org/D61810
  https://reviews.llvm.org/D61524  


Repository:
  rC Clang

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

https://reviews.llvm.org/D61809



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


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

2019-05-10 Thread Amara Emerson via Phabricator via cfe-commits
aemerson marked an inline comment as done.
aemerson added inline comments.



Comment at: clang/lib/Driver/ToolChains/Darwin.cpp:2084
 
   AddLinkRuntimeLib(Args, CmdArgs, CompilerRT, RLO_IsEmbedded);
 }

ab wrote:
> This is different from 'builtins'.  Are you OK with the difference?  
> Otherwise maybe this should be an error for now;  I wouldn't be surprised if 
> we never hit this path (this part, I'm not familiar with)
I'm ok with it because we'll just ignore the option for the ARM embedded case, 
if that ever changes we can implement it later. I don't think we'll need to 
though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58320



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


[PATCH] D61809: [BPF] Preserve original struct/union type name/access index and array subscripts

2019-05-10 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Tests seems to be missing?


Repository:
  rC Clang

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

https://reviews.llvm.org/D61809



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


[PATCH] D61809: [BPF] Preserve original struct/union type name/access index and array subscripts

2019-05-10 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song created this revision.
yonghong-song added reviewers: eli.friedman, ast.
Herald added subscribers: cfe-commits, arphaman, kosarev.
Herald added a project: clang.

For background of BPF CO-RE project, please refer to

  http://vger.kernel.org/bpfconf2019.html

In summary, BPF CO-RE intends to compile bpf programs
adjustable on struct/union layout change so the same
program can run on multiple kernels with adjustment
before loading based on native kernel structures.

In order to do this, we need keep track of GEP(getelementptr)
instruction base and result debuginfo types, so we
can adjust on the host based on kernel BTF info.
Capturing such information as an IR optimization is hard
as various optimization may have tweaked GEP and also
union is replaced by structure it is impossible to track
fieldindex for union member accesses.

An intrinsic function, preserve_di_access_index, is introducted.

  naddr = preserve_di_access_index(addr, base, type_name, access_index)

here,

  addr: the previous getelementptr result, used as the result value do
program semantics are kept intact.
  base: the base of previous getelementptr, used for later
code generation with new relocatable access offset.
  type_name: the struct/union type name if available, can be used to
match corresponding types in debuginfo.
  access_index: the access index based on user/debuginfo types.
  naddr: the result, having the same type as "addr".

For example, for the following example,

  $ cat test.c
  struct sk_buff {
int i;
int b1:1;
int b2:2;
union {
  struct {
int o1;
int o2;
  } o;
  struct {
char flags;
char dev_id;
  } dev;
  int netid;
} u[10];
  };
  
  static int (*bpf_probe_read)(void *dst, int size, void *unsafe_ptr)
  = (void *) 4;
  
  int bpf_prog(struct sk_buff *ctx) {
char dev_id;
bpf_probe_read(_id, sizeof(char), >u[5].dev.dev_id);
return dev_id;
  }
  
  $ clang -target bpf -O2 -g -emit-llvm -S -mllvm -print-before-all test.c >& 
log

The generated IR looks like below:

  ...

define dso_local i32 @bpf_prog(%struct.sk_buff*) #0 !dbg !15 {

  %2 = alloca %struct.sk_buff*, align 8
  %3 = alloca i8, align 1
  store %struct.sk_buff* %0, %struct.sk_buff** %2, align 8, !tbaa !45
  call void @llvm.dbg.declare(metadata %struct.sk_buff** %2, metadata !43, 
metadata !DIExpression()), !dbg !49
  call void @llvm.lifetime.start.p0i8(i64 1, i8* %3) #4, !dbg !50
  call void @llvm.dbg.declare(metadata i8* %3, metadata !44, metadata 
!DIExpression()), !dbg !51
  %4 = load i32 (i8*, i32, i8*)*, i32 (i8*, i32, i8*)** @bpf_probe_read, align 
8, !dbg !52, !tbaa !45
  %5 = load %struct.sk_buff*, %struct.sk_buff** %2, align 8, !dbg !53, !tbaa !45
  %6 = getelementptr inbounds %struct.sk_buff, %struct.sk_buff* %5, i32 0, i32 
2, !dbg !54
  %7 = call [10 x %union.anon]*
   
@llvm.preserve.di.access.index.p0a10s_union.anons.p0a10s_union.anons.p0s_struct.sk_buffs(
   [10 x %union.anon]* %6, %struct.sk_buff* %5,
   i8* getelementptr inbounds ([8 x i8], [8 x i8]* @0, i32 0, i32 0), i32 
3), !dbg !54
  %8 = getelementptr inbounds [10 x %union.anon], [10 x %union.anon]* %7, i64 
0, i64 5, !dbg !53
  %9 = call %union.anon* 
@llvm.preserve.di.access.index.p0s_union.anons.p0s_union.anons.p0a10s_union.anons(
   %union.anon* %8, [10 x %union.anon]* %7,
   i8* getelementptr inbounds ([1 x i8], [1 x i8]* @1, i32 0, i32 0), i32 
5), !dbg !53
  %10 = call %union.anon* 
@llvm.preserve.di.access.index.p0s_union.anons.p0s_union.anons.p0s_union.anons(
%union.anon* %9, %union.anon* %9, i8* getelementptr inbounds ([1 x i8], 
[1 x i8]* @2, i32 0, i32 0), i32 1), !dbg !55
  %11 = bitcast %union.anon* %10 to %struct.anon.0*, !dbg !55
  %12 = getelementptr inbounds %struct.anon.0, %struct.anon.0* %11, i32 0, i32 
1, !dbg !56
  %13 = call i8* 
@llvm.preserve.di.access.index.p0i8.p0i8.p0s_struct.anon.0s(i8* %12, 
%struct.anon.0* %11,
i8* getelementptr inbounds ([1 x i8], [1 x i8]* @3, i32 0, i32 0), i32 
1), !dbg !56
  %14 = call i32 %4(i8* %3, i32 1, i8* %13), !dbg !52
  %15 = load i8, i8* %3, align 1, !dbg !57, !tbaa !58
  %16 = sext i8 %15 to i32, !dbg !57
  call void @llvm.lifetime.end.p0i8(i64 1, i8* %3) #4, !dbg !59
  ret i32 %16, !dbg !60

}

For >u[5].dev.dev_id,

  . The first getelementptr (%6 = ...) has index 2 based on IR layout, and 
subsequent
preserve_di_access_index (%7 = ...) has index 3 which reflects the 
debuginfo type layout.
  . The second getelementptr (%8 = ...) has index 5 which is the same as 
preserve_di_access_index
(%9 = ...) for array subscript.
  . The instruction "%10 ..." is a call to preserve_di_access_index, which 
encodes the union member
access index "1". Such information is lost in the original IR.
  . The third getelementptr (%12 = ...) has index 1 anonymous struct member 
"dev_id". The
subsequent preserve_di_access_index also has the index "1".

Basically, 

r360474 - [CodeGen][ObjC] Emit invoke instead of call to call `objc_release` when

2019-05-10 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Fri May 10 14:54:16 2019
New Revision: 360474

URL: http://llvm.org/viewvc/llvm-project?rev=360474=rev
Log:
[CodeGen][ObjC] Emit invoke instead of call to call `objc_release` when
necessary.

Prior to r349952, clang used to call objc_msgSend when sending a release
messages, emitting an invoke instruction instead of a call instruction
when it was necessary to catch an exception. That changed in r349952
because runtime function objc_release is called as a nounwind function,
which broke programs that were overriding the dealloc method and
throwing an exception from it. This patch restores the behavior prior to
r349952.

rdar://problem/50253394

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

Modified:
cfe/trunk/lib/CodeGen/CGObjC.cpp
cfe/trunk/test/CodeGenObjC/convert-messages-to-runtime-calls.m

Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=360474=360473=360474=diff
==
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Fri May 10 14:54:16 2019
@@ -2631,7 +2631,7 @@ void CodeGenFunction::EmitObjCRelease(ll
   value = Builder.CreateBitCast(value, Int8PtrTy);
 
   // Call objc_release.
-  llvm::CallInst *call = EmitNounwindRuntimeCall(fn, value);
+  llvm::CallBase *call = EmitCallOrInvoke(fn, value);
 
   if (precise == ARCImpreciseLifetime) {
 call->setMetadata("clang.imprecise_release",

Modified: cfe/trunk/test/CodeGenObjC/convert-messages-to-runtime-calls.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/convert-messages-to-runtime-calls.m?rev=360474=360473=360474=diff
==
--- cfe/trunk/test/CodeGenObjC/convert-messages-to-runtime-calls.m (original)
+++ cfe/trunk/test/CodeGenObjC/convert-messages-to-runtime-calls.m Fri May 10 
14:54:16 2019
@@ -175,3 +175,14 @@ float test_cannot_message_return_float(C
 
 @end
 
+@class Ety;
+
+// CHECK-LABEL: define {{.*}}void @testException
+void testException(NSObject *a) {
+  // MSGS: {{invoke.*@objc_msgSend}}
+  // CALLS: invoke{{.*}}void @objc_release(i8* %
+  @try {
+[a release];
+  } @catch (Ety *e) {
+  }
+}


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


[PATCH] D61803: [CodeGen][ObjC] Emit invoke instead of call to call `objc_release` when necessary.

2019-05-10 Thread Akira Hatanaka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL360474: [CodeGen][ObjC] Emit invoke instead of call to call 
`objc_release` when (authored by ahatanak, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D61803?vs=199081=199090#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D61803

Files:
  cfe/trunk/lib/CodeGen/CGObjC.cpp
  cfe/trunk/test/CodeGenObjC/convert-messages-to-runtime-calls.m


Index: cfe/trunk/lib/CodeGen/CGObjC.cpp
===
--- cfe/trunk/lib/CodeGen/CGObjC.cpp
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp
@@ -2631,7 +2631,7 @@
   value = Builder.CreateBitCast(value, Int8PtrTy);
 
   // Call objc_release.
-  llvm::CallInst *call = EmitNounwindRuntimeCall(fn, value);
+  llvm::CallBase *call = EmitCallOrInvoke(fn, value);
 
   if (precise == ARCImpreciseLifetime) {
 call->setMetadata("clang.imprecise_release",
Index: cfe/trunk/test/CodeGenObjC/convert-messages-to-runtime-calls.m
===
--- cfe/trunk/test/CodeGenObjC/convert-messages-to-runtime-calls.m
+++ cfe/trunk/test/CodeGenObjC/convert-messages-to-runtime-calls.m
@@ -175,3 +175,14 @@
 
 @end
 
+@class Ety;
+
+// CHECK-LABEL: define {{.*}}void @testException
+void testException(NSObject *a) {
+  // MSGS: {{invoke.*@objc_msgSend}}
+  // CALLS: invoke{{.*}}void @objc_release(i8* %
+  @try {
+[a release];
+  } @catch (Ety *e) {
+  }
+}


Index: cfe/trunk/lib/CodeGen/CGObjC.cpp
===
--- cfe/trunk/lib/CodeGen/CGObjC.cpp
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp
@@ -2631,7 +2631,7 @@
   value = Builder.CreateBitCast(value, Int8PtrTy);
 
   // Call objc_release.
-  llvm::CallInst *call = EmitNounwindRuntimeCall(fn, value);
+  llvm::CallBase *call = EmitCallOrInvoke(fn, value);
 
   if (precise == ARCImpreciseLifetime) {
 call->setMetadata("clang.imprecise_release",
Index: cfe/trunk/test/CodeGenObjC/convert-messages-to-runtime-calls.m
===
--- cfe/trunk/test/CodeGenObjC/convert-messages-to-runtime-calls.m
+++ cfe/trunk/test/CodeGenObjC/convert-messages-to-runtime-calls.m
@@ -175,3 +175,14 @@
 
 @end
 
+@class Ety;
+
+// CHECK-LABEL: define {{.*}}void @testException
+void testException(NSObject *a) {
+  // MSGS: {{invoke.*@objc_msgSend}}
+  // CALLS: invoke{{.*}}void @objc_release(i8* %
+  @try {
+[a release];
+  } @catch (Ety *e) {
+  }
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57858: [analyzer] Add a new frontend flag to display all checker options

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

Also, for CodeChecker purposes wouldn't you rather have a machine-readable dump?


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

https://reviews.llvm.org/D57858



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


[PATCH] D61765: [OpenMP][Clang][BugFix] Split declares and math functions inclusion.

2019-05-10 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: lib/Headers/__clang_cuda_math_forward_declares.h:30-38
+#ifndef _OPENMP
+__DEVICE__ long abs(long);
+__DEVICE__ long long abs(long long);
+#else
+#ifndef __cplusplus
 __DEVICE__ long abs(long);
 __DEVICE__ long long abs(long long);

gtbercea wrote:
> tra wrote:
> > tra wrote:
> > > gtbercea wrote:
> > > > jdoerfert wrote:
> > > > > gtbercea wrote:
> > > > > > tra wrote:
> > > > > > > I'm not quite sure what's the idea here. It may be worth adding a 
> > > > > > > comment.
> > > > > > > 
> > > > > > > It could also be expressed somewhat simpler:
> > > > > > > 
> > > > > > > ```
> > > > > > > #if !(defined(_OPENMP) && defined(__cplusplus))
> > > > > > > ...
> > > > > > > #endif
> > > > > > > ```
> > > > > > > 
> > > > > > When these two functions definitions are here or in the 
> > > > > > __clang_cuda_cmath.h header then I get the following error (adapted 
> > > > > > for the __clang_cuda_cmath.h case):
> > > > > > 
> > > > > > 
> > > > > > ```
> > > > > > /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:166:3:
> > > > > >  error: declaration conflicts with target of using declaration 
> > > > > > already in scope
> > > > > >   abs(long __i) { return __builtin_labs(__i); }
> > > > > >   ^
> > > > > > /autofs/home/gbercea/patch-compiler/obj-release/lib/clang/9.0.0/include/__clang_cuda_cmath.h:40:17:
> > > > > >  note: target of using declaration
> > > > > > __DEVICE__ long abs(long __n) { return ::labs(__n); }
> > > > > > ^
> > > > > > /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:122:11:
> > > > > >  note: using declaration
> > > > > >   using ::abs;
> > > > > >   ^
> > > > > > /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:174:3:
> > > > > >  error: declaration conflicts with target of using declaration 
> > > > > > already in scope
> > > > > >   abs(long long __x) { return __builtin_llabs (__x); }
> > > > > >   ^
> > > > > > /autofs/home/gbercea/patch-compiler/obj-release/lib/clang/9.0.0/include/__clang_cuda_cmath.h:39:22:
> > > > > >  note: target of using declaration
> > > > > > __DEVICE__ long long abs(long long __n) { return ::llabs(__n); }
> > > > > >  ^
> > > > > > /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:122:11:
> > > > > >  note: using declaration
> > > > > >   using ::abs;
> > > > > > ```
> > > > > > 
> > > > > > 
> > > > > Long story short, we currently cannot use the overload trick through 
> > > > > `__device__` and therefore *replace* (not augment) host math headers 
> > > > > with the cuda versions which unfortunately mix std math functions 
> > > > > with other functions that we don't want/need.
> > > > This doesn't seem to be happening in the CUDA case. My suspicion is 
> > > > it's because of the __device__ attribute.
> > > It looks like until OpenMP supports some sort of target-based overloading 
> > > this will not play nicely with libstdc++. 
> > > Did you, by any chance, check if the header works with libc++ ? I wonder 
> > > if we may encounter more conflicts like these.
> > Correct. `__device__` functions overload whatever `(implicitly)__host__` 
> > functions declared by the standard library, so they coexist w/o problems. 
> > Usually. host/device implementation nuances are still observable.
> > 
> Just did a few quick tests with libstdc++ and it was all good. 
How about `libc++`? The idea is to make sure the change works with both 
libraries.




Repository:
  rC Clang

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

https://reviews.llvm.org/D61765



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


[PATCH] D57858: [analyzer] Add a new frontend flag to display all checker options

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

Let's land this together with @Szelethus's proposed solution of hiding hidden 
options (like checkers in D60925 ). I'm still 
in favor of hiding alpha checkers (as they are for development only, much like 
debug flags; i'd recommend hiding them in the CodeChecker UI as well) and we 
should probably automatically hide options of checker that are hidden. Let's 
also, indeed, remove the USAGE thingy as it doesn't add much.

So, like, the global picture is as follows. In our case the Driver (i.e., 
--analyze) is not much more user facing than frontend flags. It's still fairly 
unusable directly, as our Static Analyzer is generally not a command-line tool. 
The real user-facing stuff is the GUIs such as scan-build or CodeChecker. These 
GUIs decide themselves on what options they want to expose. For instance, you 
have a right to decide that CodeChecker shouldn't support the aggressive mode 
of the move-checker and don't expose it as an option in your GUI. In this sense 
it's not really useful to provide a centralized `-help` of all user-facing 
options.

But it sounds as if you want to change this situation and provide a single 
source of truth on what are the user-facing options. Particular GUIs can still 
ignore them, but you don't want to hardcode flags in CodeChecker, but instead 
you want to rely on clang to provide the list of supported options for you and, 
as a side effect, for scan-build users (if you also add a scan-build help 
flag). I'm totally in favor of crystallizing such list of user-facing flags, 
and this patch sounds like a good step in that direction, assuming that 
non-user-facing options are hidden.

Now, why do we care about frontend/driver flags when they're unusable by 
definition? That's because we have a mental trauma after seeing a few 
powerusers actively explore those flags, observe that they don't work, and then 
tell everybody that the Analyzer is broken. So there's a threshold, based on a 
tiny but painful bit of practical experience, that says that documentation of 
developer-only features on llvm.org or in code comments is fine, but 
documentation printed by the released binary itself is not fine.


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

https://reviews.llvm.org/D57858



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


[PATCH] D61765: [OpenMP][Clang][BugFix] Split declares and math functions inclusion.

2019-05-10 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea marked an inline comment as done.
gtbercea added inline comments.



Comment at: lib/Headers/__clang_cuda_math_forward_declares.h:30-38
+#ifndef _OPENMP
+__DEVICE__ long abs(long);
+__DEVICE__ long long abs(long long);
+#else
+#ifndef __cplusplus
 __DEVICE__ long abs(long);
 __DEVICE__ long long abs(long long);

tra wrote:
> tra wrote:
> > gtbercea wrote:
> > > jdoerfert wrote:
> > > > gtbercea wrote:
> > > > > tra wrote:
> > > > > > I'm not quite sure what's the idea here. It may be worth adding a 
> > > > > > comment.
> > > > > > 
> > > > > > It could also be expressed somewhat simpler:
> > > > > > 
> > > > > > ```
> > > > > > #if !(defined(_OPENMP) && defined(__cplusplus))
> > > > > > ...
> > > > > > #endif
> > > > > > ```
> > > > > > 
> > > > > When these two functions definitions are here or in the 
> > > > > __clang_cuda_cmath.h header then I get the following error (adapted 
> > > > > for the __clang_cuda_cmath.h case):
> > > > > 
> > > > > 
> > > > > ```
> > > > > /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:166:3:
> > > > >  error: declaration conflicts with target of using declaration 
> > > > > already in scope
> > > > >   abs(long __i) { return __builtin_labs(__i); }
> > > > >   ^
> > > > > /autofs/home/gbercea/patch-compiler/obj-release/lib/clang/9.0.0/include/__clang_cuda_cmath.h:40:17:
> > > > >  note: target of using declaration
> > > > > __DEVICE__ long abs(long __n) { return ::labs(__n); }
> > > > > ^
> > > > > /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:122:11:
> > > > >  note: using declaration
> > > > >   using ::abs;
> > > > >   ^
> > > > > /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:174:3:
> > > > >  error: declaration conflicts with target of using declaration 
> > > > > already in scope
> > > > >   abs(long long __x) { return __builtin_llabs (__x); }
> > > > >   ^
> > > > > /autofs/home/gbercea/patch-compiler/obj-release/lib/clang/9.0.0/include/__clang_cuda_cmath.h:39:22:
> > > > >  note: target of using declaration
> > > > > __DEVICE__ long long abs(long long __n) { return ::llabs(__n); }
> > > > >  ^
> > > > > /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:122:11:
> > > > >  note: using declaration
> > > > >   using ::abs;
> > > > > ```
> > > > > 
> > > > > 
> > > > Long story short, we currently cannot use the overload trick through 
> > > > `__device__` and therefore *replace* (not augment) host math headers 
> > > > with the cuda versions which unfortunately mix std math functions with 
> > > > other functions that we don't want/need.
> > > This doesn't seem to be happening in the CUDA case. My suspicion is it's 
> > > because of the __device__ attribute.
> > It looks like until OpenMP supports some sort of target-based overloading 
> > this will not play nicely with libstdc++. 
> > Did you, by any chance, check if the header works with libc++ ? I wonder if 
> > we may encounter more conflicts like these.
> Correct. `__device__` functions overload whatever `(implicitly)__host__` 
> functions declared by the standard library, so they coexist w/o problems. 
> Usually. host/device implementation nuances are still observable.
> 
Just did a few quick tests with libstdc++ and it was all good. 


Repository:
  rC Clang

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

https://reviews.llvm.org/D61765



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


[PATCH] D60593: [GwpAsan] Introduce GWP-ASan.

2019-05-10 Thread Mitch Phillips via Phabricator via cfe-commits
hctim added a comment.

In D60593#1495428 , @gribozavr wrote:

> What does GWP stand for?


Google Wide Profiling 
.

We use the name GWP-ASan, even though it's "technically neither GWP nor ASan", 
but because it describes well what the outcome is (sampled allocations with 
memory detection capabilities). It also mirrors the name used for the identical 
mechanism implemented in Chromium 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60593



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


[PATCH] D60593: [GwpAsan] Introduce GWP-ASan.

2019-05-10 Thread Mitch Phillips via Phabricator via cfe-commits
hctim updated this revision to Diff 199083.
hctim marked an inline comment as done.
hctim added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

- Updated tests to use unittests rather than expose a public interface and 
exercise that. Minor perf improvements to shouldSample().


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60593

Files:
  clang/runtime/CMakeLists.txt
  compiler-rt/cmake/config-ix.cmake
  compiler-rt/lib/gwp_asan/CMakeLists.txt
  compiler-rt/lib/gwp_asan/definitions.h
  compiler-rt/lib/gwp_asan/guarded_pool_allocator.cpp
  compiler-rt/lib/gwp_asan/guarded_pool_allocator.h
  compiler-rt/lib/gwp_asan/guarded_pool_allocator_posix.cpp
  compiler-rt/lib/gwp_asan/mutex.h
  compiler-rt/lib/gwp_asan/optional/options_parser.cpp
  compiler-rt/lib/gwp_asan/optional/options_parser.h
  compiler-rt/lib/gwp_asan/options.h
  compiler-rt/lib/gwp_asan/options.inc
  compiler-rt/lib/gwp_asan/random.cpp
  compiler-rt/lib/gwp_asan/random.h
  compiler-rt/lib/gwp_asan/tests/CMakeLists.txt
  compiler-rt/lib/gwp_asan/tests/alignment.cpp
  compiler-rt/lib/gwp_asan/tests/basic.cpp
  compiler-rt/lib/gwp_asan/tests/driver.cpp
  compiler-rt/lib/gwp_asan/tests/harness.h
  compiler-rt/lib/gwp_asan/tests/slot_reuse.cpp
  compiler-rt/lib/gwp_asan/tests/thread_contention.cpp
  compiler-rt/lib/scudo/CMakeLists.txt
  compiler-rt/lib/scudo/scudo_allocator.cpp
  compiler-rt/test/gwp_asan/CMakeLists.txt
  compiler-rt/test/gwp_asan/allocation_methods.cpp
  compiler-rt/test/gwp_asan/allocator_fallback.cpp
  compiler-rt/test/gwp_asan/double_delete.cpp
  compiler-rt/test/gwp_asan/double_deletea.cpp
  compiler-rt/test/gwp_asan/double_free.cpp
  compiler-rt/test/gwp_asan/heap_buffer_overflow.cpp
  compiler-rt/test/gwp_asan/heap_buffer_underflow.cpp
  compiler-rt/test/gwp_asan/invalid_free_left.cpp
  compiler-rt/test/gwp_asan/invalid_free_right.cpp
  compiler-rt/test/gwp_asan/lit.cfg
  compiler-rt/test/gwp_asan/lit.site.cfg.in
  compiler-rt/test/gwp_asan/page_size.h
  compiler-rt/test/gwp_asan/repeated_alloc.cpp
  compiler-rt/test/gwp_asan/unit/lit.site.cfg.in
  compiler-rt/test/gwp_asan/use_after_delete.cpp
  compiler-rt/test/gwp_asan/use_after_deletea.cpp
  compiler-rt/test/gwp_asan/use_after_free.cpp
  compiler-rt/test/lit.common.cfg
  compiler-rt/test/lit.common.configured.in
  compiler-rt/test/scudo/lit.cfg
  llvm/docs/GwpAsan.rst

Index: llvm/docs/GwpAsan.rst
===
--- /dev/null
+++ llvm/docs/GwpAsan.rst
@@ -0,0 +1,189 @@
+
+GWP-ASan
+
+
+.. contents::
+   :local:
+   :depth: 2
+
+Introduction
+
+
+GWP-ASan is a sampled allocator framework that assists in finding use-after-free
+and heap-buffer-overflow bugs in production environments. It informally is a
+recursive acronym, "**G**\WP-ASan **W**\ill **P**\rovide **A**\llocation
+**SAN**\ity".
+
+GWP-ASan is based on the classic
+`Electric Fence Malloc Debugger `_, with a
+key adaptation. Notably, we only choose a very small percentage of allocations
+to sample, and apply guard pages to these sampled allocations only. The sampling
+is small enough to allow us to have very low performance overhead.
+
+There is a small, tunable memory overhead that is fixed for the lifetime of the
+process. This is approximately ~60KiB per process using the default settings,
+depending on the average size of your allocations. Future improvements should
+drastically reduce this amount.
+
+GWP-ASan vs. ASan
+=
+
+Unlike `AddressSanitizer `_,
+GWP-ASan does not induce a significant performance overhead. ASan often requires
+the use of dedicated canaries to be viable in production environments, and as
+such is often impractical.
+
+GWP-ASan is only capable of finding a subset of the memory issues detected by
+ASan. Furthermore, GWP-ASan's bug detection capabilities are only probabilistic.
+As such, we recommend using ASan over GWP-ASan in testing, as well as anywhere
+else that guaranteed error detection is more valuable than the 2x execution
+slowdown/binary size bloat. For the majority of production environments, this
+impact is too high, and GWP-ASan proves extremely useful.
+
+Design
+==
+
+**Please note:** The implementation of GWP-ASan is largely in-flux, and these
+details are subject to change. There are currently other implementations of
+GWP-ASan, such as the implementation featured in
+`Chromium `_. The
+long-term support goal is to ensure feature-parity where reasonble, and to
+support compiler-rt as the reference implementation.
+
+Allocator Support
+-
+
+GWP-ASan is not a replacement for a traditional allocator. Instead, it works by
+inserting stubs into an existing allocator to redirect allocations when 

[PATCH] D61743: New clang option -MD-filter=prefix to filter files from make dependencies

2019-05-10 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 199082.
mibintc added a comment.

respond to suggestion from @xbolva00 (thanks).  Added a test case where prefix 
fails to match


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

https://reviews.llvm.org/D61743

Files:
  docs/ClangCommandLineReference.rst
  include/clang/Driver/Options.td
  include/clang/Frontend/DependencyOutputOptions.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/DependencyFile.cpp
  test/Frontend/dependency-gen.c

Index: test/Frontend/dependency-gen.c
===
--- test/Frontend/dependency-gen.c
+++ test/Frontend/dependency-gen.c
@@ -5,6 +5,11 @@
 // RUN: cd %t.dir
 // RUN: %clang -MD -MF - %s -fsyntax-only -I a/b | FileCheck -check-prefix=CHECK-ONE %s
 // CHECK-ONE: {{ }}a{{[/\\]}}b{{[/\\]}}x.h
+// RUN: %clang -MD -MF - %s -fsyntax-only -I a/b -MD-filter="a/b" | FileCheck -check-prefix=CHECK-FILTER %s
+// CHECK-FILTER-NOT: {{ }}a{{[/\\]}}b{{[/\\]}}x.h
+// RUN: %clang -MD -MF - %s -fsyntax-only -I a/b -MD-filter="a/b" | FileCheck -check-prefix=CHECK-WS %s
+// RUN: %clang -MD -MF - %s -fsyntax-only -I a/b -MD-filter="fail" | FileCheck -check-prefix=CHECK-ONE %s
+// CHECK-WS: {{^ *$}}
 
 // PR8974 (-include flag)
 // RUN: %clang -MD -MF - %s -fsyntax-only -include a/b/x.h -DINCLUDE_FLAG_TEST | FileCheck -check-prefix=CHECK-TWO %s
Index: lib/Frontend/DependencyFile.cpp
===
--- lib/Frontend/DependencyFile.cpp
+++ lib/Frontend/DependencyFile.cpp
@@ -154,6 +154,7 @@
   llvm::StringSet<> FilesSet;
   const Preprocessor *PP;
   std::string OutputFile;
+  std::string DependencyFilter;
   std::vector Targets;
   bool IncludeSystemHeaders;
   bool PhonyTarget;
@@ -170,7 +171,8 @@
 
 public:
   DFGImpl(const Preprocessor *_PP, const DependencyOutputOptions )
-: PP(_PP), OutputFile(Opts.OutputFile), Targets(Opts.Targets),
+: PP(_PP), OutputFile(Opts.OutputFile),
+  DependencyFilter(Opts.DependencyFilter), Targets(Opts.Targets),
   IncludeSystemHeaders(Opts.IncludeSystemHeaders),
   PhonyTarget(Opts.UsePhonyTargets),
   AddMissingHeaderDeps(Opts.AddMissingHeaderDeps),
@@ -273,6 +275,12 @@
   if (isSpecialFilename(Filename))
 return false;
 
+  if (DependencyFilter.size() &&
+  DependencyFilter.compare(0, DependencyFilter.size(), Filename,
+   DependencyFilter.size()) == 0)
+// Remove dependencies that are prefixed by the Filter string.
+return false;
+
   if (IncludeSystemHeaders)
 return true;
 
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1340,6 +1340,7 @@
 static void ParseDependencyOutputArgs(DependencyOutputOptions ,
   ArgList ) {
   Opts.OutputFile = Args.getLastArgValue(OPT_dependency_file);
+  Opts.DependencyFilter = Args.getLastArgValue(OPT_dependency_filter);
   Opts.Targets = Args.getAllArgValues(OPT_MT);
   Opts.IncludeSystemHeaders = Args.hasArg(OPT_sys_header_deps);
   Opts.IncludeModuleFiles = Args.hasArg(OPT_module_file_deps);
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -1118,6 +1118,11 @@
   CmdArgs.push_back("-module-file-deps");
   }
 
+  if (Arg *MD_Filter = Args.getLastArg(options::OPT_MD_filter)) {
+CmdArgs.push_back("-dependency-filter");
+CmdArgs.push_back(MD_Filter->getValue());
+  }
+
   if (Args.hasArg(options::OPT_MG)) {
 if (!A || A->getOption().matches(options::OPT_MD) ||
 A->getOption().matches(options::OPT_MMD))
Index: include/clang/Frontend/DependencyOutputOptions.h
===
--- include/clang/Frontend/DependencyOutputOptions.h
+++ include/clang/Frontend/DependencyOutputOptions.h
@@ -41,6 +41,10 @@
   /// The file to write dependency output to.
   std::string OutputFile;
 
+  /// Dependency output which is prefixed with this string is filtered
+  /// from the dependency output.
+  std::string DependencyFilter;
+
   /// The file to write header include output to. This is orthogonal to
   /// ShowHeaderIncludes (-H) and will include headers mentioned in the
   /// predefines buffer. If the output file is "-", output will be sent to
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -368,6 +368,8 @@
 HelpText<"Like -MD, but also implies -E and writes to stdout by default">;
 def MM : Flag<["-"], "MM">, Group,
 HelpText<"Like -MMD, but also implies -E and writes to stdout by default">;
+def MD_filter : Joined<["-"], "MD-filter=">, Group,
+

[PATCH] D61803: [CodeGen][ObjC] Emit invoke instead of call to call `objc_release` when necessary.

2019-05-10 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington accepted this revision.
erik.pilkington added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


Repository:
  rC Clang

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

https://reviews.llvm.org/D61803



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


[PATCH] D61803: [CodeGen][ObjC] Emit invoke instead of call to call `objc_release` when necessary.

2019-05-10 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 199081.
ahatanak marked an inline comment as done.
ahatanak added a comment.

Just call `EmitCallOrInvoke`.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61803

Files:
  lib/CodeGen/CGObjC.cpp
  test/CodeGenObjC/convert-messages-to-runtime-calls.m


Index: test/CodeGenObjC/convert-messages-to-runtime-calls.m
===
--- test/CodeGenObjC/convert-messages-to-runtime-calls.m
+++ test/CodeGenObjC/convert-messages-to-runtime-calls.m
@@ -175,3 +175,14 @@
 
 @end
 
+@class Ety;
+
+// CHECK-LABEL: define {{.*}}void @testException
+void testException(NSObject *a) {
+  // MSGS: {{invoke.*@objc_msgSend}}
+  // CALLS: invoke{{.*}}void @objc_release(i8* %
+  @try {
+[a release];
+  } @catch (Ety *e) {
+  }
+}
Index: lib/CodeGen/CGObjC.cpp
===
--- lib/CodeGen/CGObjC.cpp
+++ lib/CodeGen/CGObjC.cpp
@@ -2631,7 +2631,7 @@
   value = Builder.CreateBitCast(value, Int8PtrTy);
 
   // Call objc_release.
-  llvm::CallInst *call = EmitNounwindRuntimeCall(fn, value);
+  llvm::CallBase *call = EmitCallOrInvoke(fn, value);
 
   if (precise == ARCImpreciseLifetime) {
 call->setMetadata("clang.imprecise_release",


Index: test/CodeGenObjC/convert-messages-to-runtime-calls.m
===
--- test/CodeGenObjC/convert-messages-to-runtime-calls.m
+++ test/CodeGenObjC/convert-messages-to-runtime-calls.m
@@ -175,3 +175,14 @@
 
 @end
 
+@class Ety;
+
+// CHECK-LABEL: define {{.*}}void @testException
+void testException(NSObject *a) {
+  // MSGS: {{invoke.*@objc_msgSend}}
+  // CALLS: invoke{{.*}}void @objc_release(i8* %
+  @try {
+[a release];
+  } @catch (Ety *e) {
+  }
+}
Index: lib/CodeGen/CGObjC.cpp
===
--- lib/CodeGen/CGObjC.cpp
+++ lib/CodeGen/CGObjC.cpp
@@ -2631,7 +2631,7 @@
   value = Builder.CreateBitCast(value, Int8PtrTy);
 
   // Call objc_release.
-  llvm::CallInst *call = EmitNounwindRuntimeCall(fn, value);
+  llvm::CallBase *call = EmitCallOrInvoke(fn, value);
 
   if (precise == ARCImpreciseLifetime) {
 call->setMetadata("clang.imprecise_release",
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60974: Clang IFSO driver action.

2019-05-10 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi added a comment.

In D60974#1498604 , @compnerd wrote:

> This really needs more tests.  Please add a positive/negative test for the 
> driver argument.  Please try to organise the tests a bit to show what it is 
> that they are testing, emission of public functions, not of protected 
> functions or hidden functions.  Behaviour with C++ classes.  Behaviour with 
> templates.  I don't see any test for the vtable for classes that are 
> public/private.


Agreed. Adding.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60974



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


[PATCH] D60974: Clang IFSO driver action.

2019-05-10 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added a comment.

This really needs more tests.  Please add a positive/negative test for the 
driver argument.  Please try to organise the tests a bit to show what it is 
that they are testing, emission of public functions, not of protected functions 
or hidden functions.  Behaviour with C++ classes.  Behaviour with templates.  I 
don't see any test for the vtable for classes that are public/private.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60974



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


[PATCH] D60974: Clang IFSO driver action.

2019-05-10 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi added a comment.

In D60974#1498240 , @jakehehrlich 
wrote:

> This shouldn't emit the .tbe format at all, the .tbe format is meant to be in 
> near 1-1 correspondence with .so files, not with .o files. It has things like 
> DT_NEEDED, and DT_SONAME related information that don't make sense for .o 
> files for instance.
>
> If we put things under an --experimental flags, minimize what we add in the 
> first patch, and try and make each additional field added need based, I'm ok 
> with whatever being added to Clang assuming it doesn't interfere with other 
> parts of the compiler.


So my latest diff addresses this. The schema resembles the tbe format but it is 
marked with experimental and will not load with the current llvm-elfabi tool. 
Should generate something resembling:

  --- !experimental-tapi-elf-v1
  Arch: x86_64
  Symbols:
__Z16foo_default_visiii: { Type: Func }
__Z6fvih_1ii: { Type: Func }
__ZZ4fvihvE8fortytwo: { Type: Object, Size: 4 }
__Z12someWeakFuncv: { Type: Func, Weak: true }
  ...

How does this look to you?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60974



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


[PATCH] D61765: [OpenMP][Clang][BugFix] Split declares and math functions inclusion.

2019-05-10 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: lib/Headers/__clang_cuda_math_forward_declares.h:30-38
+#ifndef _OPENMP
+__DEVICE__ long abs(long);
+__DEVICE__ long long abs(long long);
+#else
+#ifndef __cplusplus
 __DEVICE__ long abs(long);
 __DEVICE__ long long abs(long long);

gtbercea wrote:
> jdoerfert wrote:
> > gtbercea wrote:
> > > tra wrote:
> > > > I'm not quite sure what's the idea here. It may be worth adding a 
> > > > comment.
> > > > 
> > > > It could also be expressed somewhat simpler:
> > > > 
> > > > ```
> > > > #if !(defined(_OPENMP) && defined(__cplusplus))
> > > > ...
> > > > #endif
> > > > ```
> > > > 
> > > When these two functions definitions are here or in the 
> > > __clang_cuda_cmath.h header then I get the following error (adapted for 
> > > the __clang_cuda_cmath.h case):
> > > 
> > > 
> > > ```
> > > /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:166:3:
> > >  error: declaration conflicts with target of using declaration already in 
> > > scope
> > >   abs(long __i) { return __builtin_labs(__i); }
> > >   ^
> > > /autofs/home/gbercea/patch-compiler/obj-release/lib/clang/9.0.0/include/__clang_cuda_cmath.h:40:17:
> > >  note: target of using declaration
> > > __DEVICE__ long abs(long __n) { return ::labs(__n); }
> > > ^
> > > /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:122:11:
> > >  note: using declaration
> > >   using ::abs;
> > >   ^
> > > /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:174:3:
> > >  error: declaration conflicts with target of using declaration already in 
> > > scope
> > >   abs(long long __x) { return __builtin_llabs (__x); }
> > >   ^
> > > /autofs/home/gbercea/patch-compiler/obj-release/lib/clang/9.0.0/include/__clang_cuda_cmath.h:39:22:
> > >  note: target of using declaration
> > > __DEVICE__ long long abs(long long __n) { return ::llabs(__n); }
> > >  ^
> > > /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:122:11:
> > >  note: using declaration
> > >   using ::abs;
> > > ```
> > > 
> > > 
> > Long story short, we currently cannot use the overload trick through 
> > `__device__` and therefore *replace* (not augment) host math headers with 
> > the cuda versions which unfortunately mix std math functions with other 
> > functions that we don't want/need.
> This doesn't seem to be happening in the CUDA case. My suspicion is it's 
> because of the __device__ attribute.
It looks like until OpenMP supports some sort of target-based overloading this 
will not play nicely with libstdc++. 
Did you, by any chance, check if the header works with libc++ ? I wonder if we 
may encounter more conflicts like these.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61765



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


[PATCH] D61765: [OpenMP][Clang][BugFix] Split declares and math functions inclusion.

2019-05-10 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 199080.
gtbercea added a comment.

- Error if not in OpenMP.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61765

Files:
  lib/Driver/ToolChains/Clang.cpp
  lib/Headers/CMakeLists.txt
  lib/Headers/__clang_cuda_cmath.h
  lib/Headers/__clang_cuda_math_forward_declares.h
  lib/Headers/openmp_wrappers/__clang_openmp_math.h
  lib/Headers/openmp_wrappers/__clang_openmp_math_declares.h
  lib/Headers/openmp_wrappers/cmath
  lib/Headers/openmp_wrappers/math.h
  test/Headers/Inputs/include/cstdlib
  test/Headers/nvptx_device_cmath_functions.c
  test/Headers/nvptx_device_cmath_functions.cpp
  test/Headers/nvptx_device_math_functions.c
  test/Headers/nvptx_device_math_functions.cpp

Index: test/Headers/nvptx_device_math_functions.cpp
===
--- test/Headers/nvptx_device_math_functions.cpp
+++ test/Headers/nvptx_device_math_functions.cpp
@@ -4,9 +4,11 @@
 // REQUIRES: nvptx-registered-target
 
 // RUN: %clang_cc1 -internal-isystem %S/Inputs/include -include math.h -x c++ -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
-// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_math.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include math.h -internal-isystem %S/Inputs/include -include stdlib.h -include limits -x c++ -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck -check-prefix CHECK-YES %s
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_math_declares.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include math.h -internal-isystem %S/Inputs/include -include stdlib.h -include limits -include cstdlib -x c++ -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck -check-prefix CHECK-YES %s
 
+//#include 
 #include 
+#include 
 
 void test_sqrt(double a1) {
   #pragma omp target
Index: test/Headers/nvptx_device_math_functions.c
===
--- test/Headers/nvptx_device_math_functions.c
+++ test/Headers/nvptx_device_math_functions.c
@@ -4,7 +4,7 @@
 // REQUIRES: nvptx-registered-target
 
 // RUN: %clang_cc1 -internal-isystem %S/Inputs/include -include math.h -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
-// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_math.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include math.h -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck -check-prefix CHECK-YES %s
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_math_declares.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include math.h -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck -check-prefix CHECK-YES %s
 
 #include 
 
Index: test/Headers/nvptx_device_cmath_functions.cpp
===
--- test/Headers/nvptx_device_cmath_functions.cpp
+++ test/Headers/nvptx_device_cmath_functions.cpp
@@ -4,9 +4,10 @@
 // REQUIRES: nvptx-registered-target
 
 // RUN: %clang_cc1 -internal-isystem %S/Inputs/include -include cmath -x c++ -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
-// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_math.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include cmath -internal-isystem %S/Inputs/include -include stdlib.h -x c++ -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck -check-prefix CHECK-YES %s
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_math_declares.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include cmath -internal-isystem %S/Inputs/include -include stdlib.h -x c++ -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device 

[PATCH] D61765: [OpenMP][Clang][BugFix] Split declares and math functions inclusion.

2019-05-10 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: lib/Headers/__clang_cuda_math_forward_declares.h:30-38
+#ifndef _OPENMP
+__DEVICE__ long abs(long);
+__DEVICE__ long long abs(long long);
+#else
+#ifndef __cplusplus
 __DEVICE__ long abs(long);
 __DEVICE__ long long abs(long long);

tra wrote:
> gtbercea wrote:
> > jdoerfert wrote:
> > > gtbercea wrote:
> > > > tra wrote:
> > > > > I'm not quite sure what's the idea here. It may be worth adding a 
> > > > > comment.
> > > > > 
> > > > > It could also be expressed somewhat simpler:
> > > > > 
> > > > > ```
> > > > > #if !(defined(_OPENMP) && defined(__cplusplus))
> > > > > ...
> > > > > #endif
> > > > > ```
> > > > > 
> > > > When these two functions definitions are here or in the 
> > > > __clang_cuda_cmath.h header then I get the following error (adapted for 
> > > > the __clang_cuda_cmath.h case):
> > > > 
> > > > 
> > > > ```
> > > > /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:166:3:
> > > >  error: declaration conflicts with target of using declaration already 
> > > > in scope
> > > >   abs(long __i) { return __builtin_labs(__i); }
> > > >   ^
> > > > /autofs/home/gbercea/patch-compiler/obj-release/lib/clang/9.0.0/include/__clang_cuda_cmath.h:40:17:
> > > >  note: target of using declaration
> > > > __DEVICE__ long abs(long __n) { return ::labs(__n); }
> > > > ^
> > > > /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:122:11:
> > > >  note: using declaration
> > > >   using ::abs;
> > > >   ^
> > > > /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:174:3:
> > > >  error: declaration conflicts with target of using declaration already 
> > > > in scope
> > > >   abs(long long __x) { return __builtin_llabs (__x); }
> > > >   ^
> > > > /autofs/home/gbercea/patch-compiler/obj-release/lib/clang/9.0.0/include/__clang_cuda_cmath.h:39:22:
> > > >  note: target of using declaration
> > > > __DEVICE__ long long abs(long long __n) { return ::llabs(__n); }
> > > >  ^
> > > > /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:122:11:
> > > >  note: using declaration
> > > >   using ::abs;
> > > > ```
> > > > 
> > > > 
> > > Long story short, we currently cannot use the overload trick through 
> > > `__device__` and therefore *replace* (not augment) host math headers with 
> > > the cuda versions which unfortunately mix std math functions with other 
> > > functions that we don't want/need.
> > This doesn't seem to be happening in the CUDA case. My suspicion is it's 
> > because of the __device__ attribute.
> It looks like until OpenMP supports some sort of target-based overloading 
> this will not play nicely with libstdc++. 
> Did you, by any chance, check if the header works with libc++ ? I wonder if 
> we may encounter more conflicts like these.
Correct. `__device__` functions overload whatever `(implicitly)__host__` 
functions declared by the standard library, so they coexist w/o problems. 
Usually. host/device implementation nuances are still observable.



Repository:
  rC Clang

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

https://reviews.llvm.org/D61765



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


[PATCH] D57860: [analyzer] Validate checker option names and values

2019-05-10 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.

In D57860#1432728 , @dcoughlin wrote:

> Setting compatibility mode to be true in the driver is not sufficient since 
> many build systems call the frontend directly.


This doesn't seem to be the case; all build systems i'm aware of would pick up 
the driver flag.

We've seen really bad problems due to lack of compatibility in the past, but 
this time i don't foresee any, as we've already tested this for non-checker 
flags. Let's land this and i'll ask for a revert if it ever causes any problems.

Note that even if we revert the driver hack and keep compatibility mode on by 
default, we can still disable compatibility mode in LIT substitutions (i.e., in 
`%clang_analyze_cc1`), so that we still had checking in our tests and were sure 
that they test something.


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

https://reviews.llvm.org/D57860



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


[PATCH] D61765: [OpenMP][Clang][BugFix] Split declares and math functions inclusion.

2019-05-10 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea marked an inline comment as done.
gtbercea added inline comments.



Comment at: lib/Headers/__clang_cuda_math_forward_declares.h:30-38
+#ifndef _OPENMP
+__DEVICE__ long abs(long);
+__DEVICE__ long long abs(long long);
+#else
+#ifndef __cplusplus
 __DEVICE__ long abs(long);
 __DEVICE__ long long abs(long long);

jdoerfert wrote:
> gtbercea wrote:
> > tra wrote:
> > > I'm not quite sure what's the idea here. It may be worth adding a comment.
> > > 
> > > It could also be expressed somewhat simpler:
> > > 
> > > ```
> > > #if !(defined(_OPENMP) && defined(__cplusplus))
> > > ...
> > > #endif
> > > ```
> > > 
> > When these two functions definitions are here or in the 
> > __clang_cuda_cmath.h header then I get the following error (adapted for the 
> > __clang_cuda_cmath.h case):
> > 
> > 
> > ```
> > /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:166:3:
> >  error: declaration conflicts with target of using declaration already in 
> > scope
> >   abs(long __i) { return __builtin_labs(__i); }
> >   ^
> > /autofs/home/gbercea/patch-compiler/obj-release/lib/clang/9.0.0/include/__clang_cuda_cmath.h:40:17:
> >  note: target of using declaration
> > __DEVICE__ long abs(long __n) { return ::labs(__n); }
> > ^
> > /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:122:11:
> >  note: using declaration
> >   using ::abs;
> >   ^
> > /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:174:3:
> >  error: declaration conflicts with target of using declaration already in 
> > scope
> >   abs(long long __x) { return __builtin_llabs (__x); }
> >   ^
> > /autofs/home/gbercea/patch-compiler/obj-release/lib/clang/9.0.0/include/__clang_cuda_cmath.h:39:22:
> >  note: target of using declaration
> > __DEVICE__ long long abs(long long __n) { return ::llabs(__n); }
> >  ^
> > /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:122:11:
> >  note: using declaration
> >   using ::abs;
> > ```
> > 
> > 
> Long story short, we currently cannot use the overload trick through 
> `__device__` and therefore *replace* (not augment) host math headers with the 
> cuda versions which unfortunately mix std math functions with other functions 
> that we don't want/need.
This doesn't seem to be happening in the CUDA case. My suspicion is it's 
because of the __device__ attribute.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61765



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


[PATCH] D61765: [OpenMP][Clang][BugFix] Split declares and math functions inclusion.

2019-05-10 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

Last issue I have (in addition to the check @tra suggested) is the order in 
which we include math.h and cstdlib. can you flip it in one of the test cases?




Comment at: lib/Headers/__clang_cuda_math_forward_declares.h:30-38
+#ifndef _OPENMP
+__DEVICE__ long abs(long);
+__DEVICE__ long long abs(long long);
+#else
+#ifndef __cplusplus
 __DEVICE__ long abs(long);
 __DEVICE__ long long abs(long long);

gtbercea wrote:
> tra wrote:
> > I'm not quite sure what's the idea here. It may be worth adding a comment.
> > 
> > It could also be expressed somewhat simpler:
> > 
> > ```
> > #if !(defined(_OPENMP) && defined(__cplusplus))
> > ...
> > #endif
> > ```
> > 
> When these two functions definitions are here or in the __clang_cuda_cmath.h 
> header then I get the following error (adapted for the __clang_cuda_cmath.h 
> case):
> 
> 
> ```
> /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:166:3:
>  error: declaration conflicts with target of using declaration already in 
> scope
>   abs(long __i) { return __builtin_labs(__i); }
>   ^
> /autofs/home/gbercea/patch-compiler/obj-release/lib/clang/9.0.0/include/__clang_cuda_cmath.h:40:17:
>  note: target of using declaration
> __DEVICE__ long abs(long __n) { return ::labs(__n); }
> ^
> /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:122:11:
>  note: using declaration
>   using ::abs;
>   ^
> /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:174:3:
>  error: declaration conflicts with target of using declaration already in 
> scope
>   abs(long long __x) { return __builtin_llabs (__x); }
>   ^
> /autofs/home/gbercea/patch-compiler/obj-release/lib/clang/9.0.0/include/__clang_cuda_cmath.h:39:22:
>  note: target of using declaration
> __DEVICE__ long long abs(long long __n) { return ::llabs(__n); }
>  ^
> /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:122:11:
>  note: using declaration
>   using ::abs;
> ```
> 
> 
Long story short, we currently cannot use the overload trick through 
`__device__` and therefore *replace* (not augment) host math headers with the 
cuda versions which unfortunately mix std math functions with other functions 
that we don't want/need.



Comment at: lib/Headers/openmp_wrappers/__clang_openmp_math_declares.h:10
+
+#if defined(__NVPTX__) && defined(_OPENMP)
+

tra wrote:
> You may want to add include guards.
> 
> I'd also make inclusion of the file in non-openmp compilation an error, if it 
> makes sense for OpenMP. It does for CUDA.
That is something we should be able to do, error out if _OPENMP is not defined 
I mean.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61765



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


[PATCH] D61803: [CodeGen][ObjC] Emit invoke instead of call to call `objc_release` when necessary.

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



Comment at: lib/CodeGen/CGObjC.cpp:2634-2646
+  ASTContext  = getContext();
+  const ImplicitParamDecl *paramDecl =
+  ImplicitParamDecl::Create(Ctx, nullptr, SourceLocation(), nullptr,
+Ctx.VoidPtrTy, ImplicitParamDecl::Other);
+  FunctionArgList funcArgs;
+  funcArgs.push_back(paramDecl);
+  const CGFunctionInfo  =

Can't you just write `EmitCallOrInvoke(fn, value)`? See what we do in 
`emitObjCValueOperation`, which can handle this case.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61803



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


[PATCH] D61749: [clang-tidy] initial version of readability-static-const-method

2019-05-10 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D61749#1498541 , @mgehre wrote:

> ...


Still, this is two separate checks, logically.
You can put the `FindUsageOfThis` e.g. into a new file in `clang-tidy/utils`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61749



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


[PATCH] D61804: Support building shared and static libraries simultaneously

2019-05-10 Thread Wink Saville via Phabricator via cfe-commits
winksaville created this revision.
winksaville added reviewers: tstellar, morehouse, gottesmm, chapuni.
Herald added subscribers: llvm-commits, cfe-commits, mgorny.
Herald added projects: clang, LLVM.

I ran into the need for both while trying to compile zig (https://ziglang.org)
on my Arch Linux system and it fails. The problem is that the Arch Linux
clang package only provides shared libraries using the following cmake
command:

  cmake .. -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
-DPYTHON_EXECUTABLE=/usr/bin/python \
-DBUILD_SHARED_LIBS=ON \
-DLLVM_LINK_LLVM_DYLIB=ON \
-DLLVM_ENABLE_RTTI=ON \
-DLLVM_BUILD_TESTS=ON \
-DLLVM_INCLUDE_DOCS=ON \
-DLLVM_BUILD_DOCS=ON \
-DLLVM_ENABLE_SPHINX=ON \
-DSPHINX_WARNINGS_AS_ERRORS=OFF \
-DLLVM_EXTERNAL_LIT=/usr/bin/lit \
-DLLVM_MAIN_SRC_DIR="$srcdir/llvm-$pkgver.src"

In particular, it uses "BUILD_SHARED_LIBS=ON" to get the shared
libraries. This works but there are no static libraries and further
a note in the documentation says,
https://llvm.org/docs/CMake.html#llvm-specific-variables :

  "BUILD_SHARED_LIBS is only recommended for use by LLVM developers.
  If you want to build LLVM as a shared library, you should use the
  LLVM_BUILD_LLVM_DYLIB option."

So it seemed to me it a solution would be to provide an easy way to build
clang or other llvm subprojects with both static and shared libraries.

As it turns out on small number modifications were needed:

  clang/CMAkeLists.txt:
  
   - Add options CLANG_ENABLE_STATIC_LIBRARIES and CLANG_ENABLE_SHARED_LIBRARIES
 These are defaulted to ON so libclang* libraries are built as
 static and shared.  As these are options they can be overridden on the
 cmake command line.
  
  clang/cmake/modules/AddClang.cmake add_clang_library:
  
   - Add support for STATIC, SHARED or both
   - Add support for OUTPUT_NAME which defaults to the ${name} passed to
 add_clang_library
  
  llvm/cmake/modules/AddLLVM.cmake llvm_add_library:
  
   - Changed so when both SHARED and STATIC are passed SHARED is built
 first as cmake object ${name}_shared.
  
 Without this change llvm_add_library causes the shared libraries to
 be linked to clang rather than the static library and clang fails
 when run with:
  
   $ ./bin/clang-9 --version
   : CommandLine Error: Option 'use-dbg-addr' registered more than once!
   LLVM ERROR: inconsistency in registered CommandLine options


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D61804

Files:
  clang/CMakeLists.txt
  clang/cmake/modules/AddClang.cmake
  llvm/cmake/modules/AddLLVM.cmake


Index: llvm/cmake/modules/AddLLVM.cmake
===
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -442,20 +442,20 @@
   endif()
 
   if(ARG_SHARED AND ARG_STATIC)
-# static
-set(name_static "${name}_static")
+# Do shared first
+set(name_shared "${name}_shared")
 if(ARG_OUTPUT_NAME)
   set(output_name OUTPUT_NAME "${ARG_OUTPUT_NAME}")
 endif()
 # DEPENDS has been appended to LLVM_COMMON_LIBS.
-llvm_add_library(${name_static} STATIC
+llvm_add_library(${name_shared} SHARED
   ${output_name}
   OBJLIBS ${ALL_FILES} # objlib
   LINK_LIBS ${ARG_LINK_LIBS}
   LINK_COMPONENTS ${ARG_LINK_COMPONENTS}
   )
-# FIXME: Add name_static to anywhere in TARGET ${name}'s PROPERTY.
-set(ARG_STATIC)
+# FIXME: Add name_shared to anywhere in TARGET ${name}'s PROPERTY.
+set(ARG_SHARED)
   endif()
 
   if(ARG_MODULE)
Index: clang/cmake/modules/AddClang.cmake
===
--- clang/cmake/modules/AddClang.cmake
+++ clang/cmake/modules/AddClang.cmake
@@ -44,8 +44,8 @@
 
 macro(add_clang_library name)
   cmake_parse_arguments(ARG
-"SHARED"
-""
+"SHARED;STATIC"
+"OUTPUT_NAME"
 "ADDITIONAL_HEADERS"
 ${ARGN})
   set(srcs)
@@ -80,10 +80,20 @@
   ${ARG_ADDITIONAL_HEADERS} # It may contain unparsed unknown args.
   )
   endif()
-  if(ARG_SHARED)
+  if(ARG_SHARED OR CLANG_ENABLE_SHARED_LIBRARIES)
 set(ARG_ENABLE_SHARED SHARED)
   endif()
-  llvm_add_library(${name} ${ARG_ENABLE_SHARED} ${ARG_UNPARSED_ARGUMENTS} 
${srcs})
+  if(ARG_STATIC OR CLANG_ENABLE_STATIC_LIBRARIES)
+set(ARG_ENABLE_STATIC STATIC)
+  endif()
+  if(ARG_OUTPUT_NAME)
+set(NAME_OUTPUT OUTPUT_NAME ${ARG_OUTPUT_NAME})
+  elseif(ARG_SHARED AND ARG_STATIC)
+set(NAME_OUTPUT OUTPUT_NAME ${name})
+  else()
+set(NAME_OUTPUT)
+  endif()
+  llvm_add_library(${name} ${NAME_OUTPUT} ${ARG_ENABLE_SHARED} 
${ARG_ENABLE_STATIC} ${ARG_UNPARSED_ARGUMENTS} ${srcs})
 
   if(TARGET ${name})
 target_link_libraries(${name} INTERFACE ${LLVM_COMMON_LIBS})
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ 

[PATCH] D61749: [clang-tidy] initial version of readability-static-const-method

2019-05-10 Thread Matthias Gehre via Phabricator via cfe-commits
mgehre added a comment.

I have thought about splitting the check into separate `static` & `const`, but 
kept it together because
the analysis for both cases is very similar, i.e. finding the usage of `this`.

Also, both checks share many preconditions, e.g. not applying them to virtual 
methods or methods
on class with a template base class, not applying them to constructor, not 
applying them to operators, etc
(and those preconditons are not shared with D54943 
).

I had a look at D54943 . Nice change! It will 
be very valuable to have the `const` analysis for variables!
Note, though, that the hard part of of making methods
`const` is not the detailed usage analysis as its done by the 
`ExprMutationAnalyzer`. Instead, the hard part
is to avoid false-positives that make the check unusable.
I had a version of this check that made a very detailed analysis just like 
`ExprMutationAnalyzer`
(restricted to `this`). But then most of the functions it flagged as `const`
(technically correct) on the LLVM code base we would not want to make const 
(logically). Examples:

  class S {
// Technically const (the pointer Pimp itself is not modified), but 
logically should not be const
//  because we want to consider *Pimp as part of the data.
void setFlag() {
  *Pimp = 4;
}
  
int* Pimp;
  };



  class S {
void modify() {
   // Technically const because we call a const method
  // "pointer unique_ptr::operator->() const;"
  // but logically not const.
  U->modify();
}
  
std::unique_ptr U;
  };



  // Real-world code, see clang::ObjCInterfaceDecl.
  class DataPattern {
int& data() const;
  public:
  
int& get() { // Must not be const, even though it only calls const methods
  return data();
}
  
const int& get() const {
  return const_cast(this)->get();
}
  
void set() { // Must not be const, even though it only calls const methods
  data() = 42;
}
  };

and many more.

So the hard thing for the `const` check was to actually remove the 
sophisticated analysis I had, and come up with
something much simpler that would have no false positive (otherwise users will 
just disable the check) while
still finding something. I fear that the same could happen when we apply D54943 
 to `this` directly. It might
be easier to keep those two cases separate.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61749



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


[PATCH] D61765: [OpenMP][Clang][BugFix] Split declares and math functions inclusion.

2019-05-10 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea marked an inline comment as done.
gtbercea added inline comments.



Comment at: lib/Headers/__clang_cuda_math_forward_declares.h:30-38
+#ifndef _OPENMP
+__DEVICE__ long abs(long);
+__DEVICE__ long long abs(long long);
+#else
+#ifndef __cplusplus
 __DEVICE__ long abs(long);
 __DEVICE__ long long abs(long long);

tra wrote:
> I'm not quite sure what's the idea here. It may be worth adding a comment.
> 
> It could also be expressed somewhat simpler:
> 
> ```
> #if !(defined(_OPENMP) && defined(__cplusplus))
> ...
> #endif
> ```
> 
When these two functions definitions are here or in the __clang_cuda_cmath.h 
header then I get the following error (adapted for the __clang_cuda_cmath.h 
case):


```
/usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:166:3:
 error: declaration conflicts with target of using declaration already in scope
  abs(long __i) { return __builtin_labs(__i); }
  ^
/autofs/home/gbercea/patch-compiler/obj-release/lib/clang/9.0.0/include/__clang_cuda_cmath.h:40:17:
 note: target of using declaration
__DEVICE__ long abs(long __n) { return ::labs(__n); }
^
/usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:122:11:
 note: using declaration
  using ::abs;
  ^
/usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:174:3:
 error: declaration conflicts with target of using declaration already in scope
  abs(long long __x) { return __builtin_llabs (__x); }
  ^
/autofs/home/gbercea/patch-compiler/obj-release/lib/clang/9.0.0/include/__clang_cuda_cmath.h:39:22:
 note: target of using declaration
__DEVICE__ long long abs(long long __n) { return ::llabs(__n); }
 ^
/usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:122:11:
 note: using declaration
  using ::abs;
```




Repository:
  rC Clang

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

https://reviews.llvm.org/D61765



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


[PATCH] D61765: [OpenMP][Clang][BugFix] Split declares and math functions inclusion.

2019-05-10 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 199075.
gtbercea added a comment.

- Simplify conditions. Add guards.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61765

Files:
  lib/Driver/ToolChains/Clang.cpp
  lib/Headers/CMakeLists.txt
  lib/Headers/__clang_cuda_cmath.h
  lib/Headers/__clang_cuda_math_forward_declares.h
  lib/Headers/openmp_wrappers/__clang_openmp_math.h
  lib/Headers/openmp_wrappers/__clang_openmp_math_declares.h
  lib/Headers/openmp_wrappers/cmath
  lib/Headers/openmp_wrappers/math.h
  test/Headers/Inputs/include/cstdlib
  test/Headers/nvptx_device_cmath_functions.c
  test/Headers/nvptx_device_cmath_functions.cpp
  test/Headers/nvptx_device_math_functions.c
  test/Headers/nvptx_device_math_functions.cpp

Index: test/Headers/nvptx_device_math_functions.cpp
===
--- test/Headers/nvptx_device_math_functions.cpp
+++ test/Headers/nvptx_device_math_functions.cpp
@@ -4,9 +4,11 @@
 // REQUIRES: nvptx-registered-target
 
 // RUN: %clang_cc1 -internal-isystem %S/Inputs/include -include math.h -x c++ -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
-// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_math.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include math.h -internal-isystem %S/Inputs/include -include stdlib.h -include limits -x c++ -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck -check-prefix CHECK-YES %s
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_math_declares.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include math.h -internal-isystem %S/Inputs/include -include stdlib.h -include limits -include cstdlib -x c++ -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck -check-prefix CHECK-YES %s
 
+//#include 
 #include 
+#include 
 
 void test_sqrt(double a1) {
   #pragma omp target
Index: test/Headers/nvptx_device_math_functions.c
===
--- test/Headers/nvptx_device_math_functions.c
+++ test/Headers/nvptx_device_math_functions.c
@@ -4,7 +4,7 @@
 // REQUIRES: nvptx-registered-target
 
 // RUN: %clang_cc1 -internal-isystem %S/Inputs/include -include math.h -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
-// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_math.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include math.h -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck -check-prefix CHECK-YES %s
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_math_declares.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include math.h -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck -check-prefix CHECK-YES %s
 
 #include 
 
Index: test/Headers/nvptx_device_cmath_functions.cpp
===
--- test/Headers/nvptx_device_cmath_functions.cpp
+++ test/Headers/nvptx_device_cmath_functions.cpp
@@ -4,9 +4,10 @@
 // REQUIRES: nvptx-registered-target
 
 // RUN: %clang_cc1 -internal-isystem %S/Inputs/include -include cmath -x c++ -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
-// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_math.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include cmath -internal-isystem %S/Inputs/include -include stdlib.h -x c++ -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck -check-prefix CHECK-YES %s
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_math_declares.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include cmath -internal-isystem %S/Inputs/include -include stdlib.h -x c++ -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device 

r360468 - [ThinLTO] Clang test changes for new CanAutoHide flag

2019-05-10 Thread Teresa Johnson via cfe-commits
Author: tejohnson
Date: Fri May 10 13:38:31 2019
New Revision: 360468

URL: http://llvm.org/viewvc/llvm-project?rev=360468=rev
Log:
[ThinLTO] Clang test changes for new CanAutoHide flag

Modified:
cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll
cfe/trunk/test/CodeGen/thinlto-distributed-cfi.ll

Modified: cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll?rev=360468=360467=360468=diff
==
--- cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll (original)
+++ cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll Fri May 10 
13:38:31 2019
@@ -35,7 +35,7 @@
 ; Round trip it through llvm-as
 ; RUN: llvm-dis %t.o.thinlto.bc -o - | llvm-as -o - | llvm-dis -o - | 
FileCheck %s --check-prefix=CHECK-DIS
 ; CHECK-DIS: ^0 = module: (path: 
"{{.*}}thinlto-distributed-cfi-devirt.ll.tmp.o", hash: ({{.*}}, {{.*}}, {{.*}}, 
{{.*}}, {{.*}}))
-; CHECK-DIS: ^1 = gv: (guid: 8346051122425466633, summaries: (function: 
(module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 1, 
dsoLocal: 0), insts: 18, typeIdInfo: (typeTests: (^2), typeCheckedLoadVCalls: 
(vFuncId: (^2, offset: 8), vFuncId: (^2, offset: 0))
+; CHECK-DIS: ^1 = gv: (guid: 8346051122425466633, summaries: (function: 
(module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 1, 
dsoLocal: 0, canAutoHide: 0), insts: 18, typeIdInfo: (typeTests: (^2), 
typeCheckedLoadVCalls: (vFuncId: (^2, offset: 8), vFuncId: (^2, offset: 0))
 ; CHECK-DIS: ^2 = typeid: (name: "_ZTS1A", summary: (typeTestRes: (kind: 
allOnes, sizeM1BitWidth: 7), wpdResolutions: ((offset: 0, wpdRes: (kind: 
branchFunnel)), (offset: 8, wpdRes: (kind: singleImpl, singleImplName: 
"_ZN1A1nEi") ; guid = 7004155349499253778
 
 ; RUN: %clang_cc1 -triple x86_64-grtev4-linux-gnu \

Modified: cfe/trunk/test/CodeGen/thinlto-distributed-cfi.ll
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/thinlto-distributed-cfi.ll?rev=360468=360467=360468=diff
==
--- cfe/trunk/test/CodeGen/thinlto-distributed-cfi.ll (original)
+++ cfe/trunk/test/CodeGen/thinlto-distributed-cfi.ll Fri May 10 13:38:31 2019
@@ -24,7 +24,7 @@
 ; Round trip it through llvm-as
 ; RUN: llvm-dis %t.o.thinlto.bc -o - | llvm-as -o - | llvm-dis -o - | 
FileCheck %s --check-prefix=CHECK-DIS
 ; CHECK-DIS: ^0 = module: (path: "{{.*}}thinlto-distributed-cfi.ll.tmp.o", 
hash: ({{.*}}, {{.*}}, {{.*}}, {{.*}}, {{.*}}))
-; CHECK-DIS: ^1 = gv: (guid: 8346051122425466633, summaries: (function: 
(module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 1, 
dsoLocal: 0), insts: 7, typeIdInfo: (typeTests: (^2)
+; CHECK-DIS: ^1 = gv: (guid: 8346051122425466633, summaries: (function: 
(module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 1, 
dsoLocal: 0, canAutoHide: 0), insts: 7, typeIdInfo: (typeTests: (^2)
 ; CHECK-DIS: ^2 = typeid: (name: "_ZTS1A", summary: (typeTestRes: (kind: 
single, sizeM1BitWidth: 0))) ; guid = 7004155349499253778
 
 ; RUN: %clang_cc1 -triple x86_64-grtev4-linux-gnu \


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


[PATCH] D61350: [clang-tidy] New check calling out uses of +new in Objective-C code

2019-05-10 Thread Michael Wyman via Phabricator via cfe-commits
mwyman accepted this revision.
mwyman added a comment.

I don't have commit access, so if somebody could submit them that would be 
wonderful!


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

https://reviews.llvm.org/D61350



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


[PATCH] D61803: [CodeGen][ObjC] Emit invoke instead of call to call `objc_release` when necessary.

2019-05-10 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision.
ahatanak added reviewers: pete, rjmccall.
ahatanak added a project: clang.
Herald added subscribers: dexonsmith, jkorous.

Prior to r349952, clang used to call `objc_msgSend` when sending a release 
messages, emitting an invoke instruction instead of a call instruction when it 
was necessary to catch an exception. That changed in r349952 because runtime 
function `objc_release` is called as a nounwind function, which broke programs 
that were overriding the `dealloc` method and throwing an exception from it. 
This patch restores the behavior prior to r349952.

rdar://problem/50253394


Repository:
  rC Clang

https://reviews.llvm.org/D61803

Files:
  lib/CodeGen/CGObjC.cpp
  test/CodeGenObjC/convert-messages-to-runtime-calls.m


Index: test/CodeGenObjC/convert-messages-to-runtime-calls.m
===
--- test/CodeGenObjC/convert-messages-to-runtime-calls.m
+++ test/CodeGenObjC/convert-messages-to-runtime-calls.m
@@ -175,3 +175,14 @@
 
 @end
 
+@class Ety;
+
+// CHECK-LABEL: define {{.*}}void @testException
+void testException(NSObject *a) {
+  // MSGS: {{invoke.*@objc_msgSend}}
+  // CALLS: invoke{{.*}}void @objc_release(i8* %
+  @try {
+[a release];
+  } @catch (Ety *e) {
+  }
+}
Index: lib/CodeGen/CGObjC.cpp
===
--- lib/CodeGen/CGObjC.cpp
+++ lib/CodeGen/CGObjC.cpp
@@ -2631,7 +2631,19 @@
   value = Builder.CreateBitCast(value, Int8PtrTy);
 
   // Call objc_release.
-  llvm::CallInst *call = EmitNounwindRuntimeCall(fn, value);
+  ASTContext  = getContext();
+  const ImplicitParamDecl *paramDecl =
+  ImplicitParamDecl::Create(Ctx, nullptr, SourceLocation(), nullptr,
+Ctx.VoidPtrTy, ImplicitParamDecl::Other);
+  FunctionArgList funcArgs;
+  funcArgs.push_back(paramDecl);
+  const CGFunctionInfo  =
+  CGM.getTypes().arrangeBuiltinFunctionDeclaration(Ctx.VoidTy, funcArgs);
+  CallArgList args;
+  args.add(RValue::get(value), Ctx.VoidPtrTy);
+  llvm::CallBase *call;
+  EmitCall(fnInfo, CGCallee::forDirect(cast(fn.getCallee())),
+   ReturnValueSlot(), args, );
 
   if (precise == ARCImpreciseLifetime) {
 call->setMetadata("clang.imprecise_release",


Index: test/CodeGenObjC/convert-messages-to-runtime-calls.m
===
--- test/CodeGenObjC/convert-messages-to-runtime-calls.m
+++ test/CodeGenObjC/convert-messages-to-runtime-calls.m
@@ -175,3 +175,14 @@
 
 @end
 
+@class Ety;
+
+// CHECK-LABEL: define {{.*}}void @testException
+void testException(NSObject *a) {
+  // MSGS: {{invoke.*@objc_msgSend}}
+  // CALLS: invoke{{.*}}void @objc_release(i8* %
+  @try {
+[a release];
+  } @catch (Ety *e) {
+  }
+}
Index: lib/CodeGen/CGObjC.cpp
===
--- lib/CodeGen/CGObjC.cpp
+++ lib/CodeGen/CGObjC.cpp
@@ -2631,7 +2631,19 @@
   value = Builder.CreateBitCast(value, Int8PtrTy);
 
   // Call objc_release.
-  llvm::CallInst *call = EmitNounwindRuntimeCall(fn, value);
+  ASTContext  = getContext();
+  const ImplicitParamDecl *paramDecl =
+  ImplicitParamDecl::Create(Ctx, nullptr, SourceLocation(), nullptr,
+Ctx.VoidPtrTy, ImplicitParamDecl::Other);
+  FunctionArgList funcArgs;
+  funcArgs.push_back(paramDecl);
+  const CGFunctionInfo  =
+  CGM.getTypes().arrangeBuiltinFunctionDeclaration(Ctx.VoidTy, funcArgs);
+  CallArgList args;
+  args.add(RValue::get(value), Ctx.VoidPtrTy);
+  llvm::CallBase *call;
+  EmitCall(fnInfo, CGCallee::forDirect(cast(fn.getCallee())),
+   ReturnValueSlot(), args, );
 
   if (precise == ARCImpreciseLifetime) {
 call->setMetadata("clang.imprecise_release",
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61765: [OpenMP][Clang][BugFix] Split declares and math functions inclusion.

2019-05-10 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 199073.
gtbercea added a comment.

- Add tests. Exclude additional abs definition.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61765

Files:
  lib/Driver/ToolChains/Clang.cpp
  lib/Headers/CMakeLists.txt
  lib/Headers/__clang_cuda_cmath.h
  lib/Headers/__clang_cuda_math_forward_declares.h
  lib/Headers/openmp_wrappers/__clang_openmp_math.h
  lib/Headers/openmp_wrappers/__clang_openmp_math_declares.h
  lib/Headers/openmp_wrappers/cmath
  lib/Headers/openmp_wrappers/math.h
  test/Headers/Inputs/include/cstdlib
  test/Headers/nvptx_device_cmath_functions.c
  test/Headers/nvptx_device_cmath_functions.cpp
  test/Headers/nvptx_device_math_functions.c
  test/Headers/nvptx_device_math_functions.cpp

Index: test/Headers/nvptx_device_math_functions.cpp
===
--- test/Headers/nvptx_device_math_functions.cpp
+++ test/Headers/nvptx_device_math_functions.cpp
@@ -4,9 +4,11 @@
 // REQUIRES: nvptx-registered-target
 
 // RUN: %clang_cc1 -internal-isystem %S/Inputs/include -include math.h -x c++ -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
-// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_math.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include math.h -internal-isystem %S/Inputs/include -include stdlib.h -include limits -x c++ -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck -check-prefix CHECK-YES %s
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_math_declares.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include math.h -internal-isystem %S/Inputs/include -include stdlib.h -include limits -include cstdlib -x c++ -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck -check-prefix CHECK-YES %s
 
+//#include 
 #include 
+#include 
 
 void test_sqrt(double a1) {
   #pragma omp target
Index: test/Headers/nvptx_device_math_functions.c
===
--- test/Headers/nvptx_device_math_functions.c
+++ test/Headers/nvptx_device_math_functions.c
@@ -4,7 +4,7 @@
 // REQUIRES: nvptx-registered-target
 
 // RUN: %clang_cc1 -internal-isystem %S/Inputs/include -include math.h -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
-// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_math.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include math.h -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck -check-prefix CHECK-YES %s
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_math_declares.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include math.h -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck -check-prefix CHECK-YES %s
 
 #include 
 
Index: test/Headers/nvptx_device_cmath_functions.cpp
===
--- test/Headers/nvptx_device_cmath_functions.cpp
+++ test/Headers/nvptx_device_cmath_functions.cpp
@@ -4,9 +4,10 @@
 // REQUIRES: nvptx-registered-target
 
 // RUN: %clang_cc1 -internal-isystem %S/Inputs/include -include cmath -x c++ -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
-// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_math.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include cmath -internal-isystem %S/Inputs/include -include stdlib.h -x c++ -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck -check-prefix CHECK-YES %s
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_math_declares.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include cmath -internal-isystem %S/Inputs/include -include stdlib.h -x c++ -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s 

[PATCH] D61765: [OpenMP][Clang][BugFix] Split declares and math functions inclusion.

2019-05-10 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: lib/Headers/__clang_cuda_math_forward_declares.h:30-38
+#ifndef _OPENMP
+__DEVICE__ long abs(long);
+__DEVICE__ long long abs(long long);
+#else
+#ifndef __cplusplus
 __DEVICE__ long abs(long);
 __DEVICE__ long long abs(long long);

I'm not quite sure what's the idea here. It may be worth adding a comment.

It could also be expressed somewhat simpler:

```
#if !(defined(_OPENMP) && defined(__cplusplus))
...
#endif
```




Comment at: lib/Headers/openmp_wrappers/__clang_openmp_math_declares.h:10
+
+#if defined(__NVPTX__) && defined(_OPENMP)
+

You may want to add include guards.

I'd also make inclusion of the file in non-openmp compilation an error, if it 
makes sense for OpenMP. It does for CUDA.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61765



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


r360465 - Add target triple to test.

2019-05-10 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Fri May 10 13:07:47 2019
New Revision: 360465

URL: http://llvm.org/viewvc/llvm-project?rev=360465=rev
Log:
Add target triple to test.

Modified:
cfe/trunk/test/Frontend/macro_defined_type.cpp

Modified: cfe/trunk/test/Frontend/macro_defined_type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/macro_defined_type.cpp?rev=360465=360464=360465=diff
==
--- cfe/trunk/test/Frontend/macro_defined_type.cpp (original)
+++ cfe/trunk/test/Frontend/macro_defined_type.cpp Fri May 10 13:07:47 2019
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-linux-gnu %s
 
 #define NODEREF __attribute__((noderef))
 


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


[PATCH] D61496: Fixed tests where grep was not matching the linefeed

2019-05-10 Thread Alexandre Ganea via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC360467: Fixed tests where grep was not matching the linefeed 
(authored by aganea, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D61496?vs=197990=199069#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D61496

Files:
  test/Preprocessor/indent_macro.c
  test/Preprocessor/macro_fn_varargs_named.c
  test/Preprocessor/macro_not_define.c
  test/Preprocessor/macro_rparen_scan.c


Index: test/Preprocessor/macro_rparen_scan.c
===
--- test/Preprocessor/macro_rparen_scan.c
+++ test/Preprocessor/macro_rparen_scan.c
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -E %s | grep '^3 ;$'
+// RUN: %clang_cc1 -E %s | FileCheck %s --match-full-lines --strict-whitespace
+// CHECK:3 ;
 
 /* Right paren scanning, hard case.  Should expand to 3. */
 #define i(x) 3 
Index: test/Preprocessor/macro_fn_varargs_named.c
===
--- test/Preprocessor/macro_fn_varargs_named.c
+++ test/Preprocessor/macro_fn_varargs_named.c
@@ -1,6 +1,9 @@
-// RUN: %clang_cc1 -E %s | grep '^a: x$'
-// RUN: %clang_cc1 -E %s | grep '^b: x y, z,h$'
-// RUN: %clang_cc1 -E %s | grep '^c: foo(x)$'
+// RUN: %clang_cc1 -E %s | FileCheck %s --match-full-lines --strict-whitespace 
--check-prefix CHECK-1
+// CHECK-1:a: x
+// RUN: %clang_cc1 -E %s | FileCheck %s --match-full-lines --strict-whitespace 
--check-prefix CHECK-2
+// CHECK-2:b: x y, z,h
+// RUN: %clang_cc1 -E %s | FileCheck %s --match-full-lines --strict-whitespace 
--check-prefix CHECK-3
+// CHECK-3:c: foo(x)
 
 #define A(b, c...) b c
 a: A(x)
Index: test/Preprocessor/macro_not_define.c
===
--- test/Preprocessor/macro_not_define.c
+++ test/Preprocessor/macro_not_define.c
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -E %s | grep '^ # define X 3$'
+// RUN: %clang_cc1 -E %s | FileCheck %s --match-full-lines --strict-whitespace
+// CHECK: # define X 3
 
 #define H # 
  #define D define 
Index: test/Preprocessor/indent_macro.c
===
--- test/Preprocessor/indent_macro.c
+++ test/Preprocessor/indent_macro.c
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -E %s | grep '^   zzap$'
+// RUN: %clang_cc1 -E %s | FileCheck %s --match-full-lines --strict-whitespace
+// CHECK:   zzap
 
 // zzap is on a new line, should be indented.
 #define BLAH  zzap


Index: test/Preprocessor/macro_rparen_scan.c
===
--- test/Preprocessor/macro_rparen_scan.c
+++ test/Preprocessor/macro_rparen_scan.c
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -E %s | grep '^3 ;$'
+// RUN: %clang_cc1 -E %s | FileCheck %s --match-full-lines --strict-whitespace
+// CHECK:3 ;
 
 /* Right paren scanning, hard case.  Should expand to 3. */
 #define i(x) 3 
Index: test/Preprocessor/macro_fn_varargs_named.c
===
--- test/Preprocessor/macro_fn_varargs_named.c
+++ test/Preprocessor/macro_fn_varargs_named.c
@@ -1,6 +1,9 @@
-// RUN: %clang_cc1 -E %s | grep '^a: x$'
-// RUN: %clang_cc1 -E %s | grep '^b: x y, z,h$'
-// RUN: %clang_cc1 -E %s | grep '^c: foo(x)$'
+// RUN: %clang_cc1 -E %s | FileCheck %s --match-full-lines --strict-whitespace --check-prefix CHECK-1
+// CHECK-1:a: x
+// RUN: %clang_cc1 -E %s | FileCheck %s --match-full-lines --strict-whitespace --check-prefix CHECK-2
+// CHECK-2:b: x y, z,h
+// RUN: %clang_cc1 -E %s | FileCheck %s --match-full-lines --strict-whitespace --check-prefix CHECK-3
+// CHECK-3:c: foo(x)
 
 #define A(b, c...) b c
 a: A(x)
Index: test/Preprocessor/macro_not_define.c
===
--- test/Preprocessor/macro_not_define.c
+++ test/Preprocessor/macro_not_define.c
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -E %s | grep '^ # define X 3$'
+// RUN: %clang_cc1 -E %s | FileCheck %s --match-full-lines --strict-whitespace
+// CHECK: # define X 3
 
 #define H # 
  #define D define 
Index: test/Preprocessor/indent_macro.c
===
--- test/Preprocessor/indent_macro.c
+++ test/Preprocessor/indent_macro.c
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -E %s | grep '^   zzap$'
+// RUN: %clang_cc1 -E %s | FileCheck %s --match-full-lines --strict-whitespace
+// CHECK:   zzap
 
 // zzap is on a new line, should be indented.
 #define BLAH  zzap
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r360467 - Fixed tests where grep was not matching the linefeed

2019-05-10 Thread Alexandre Ganea via cfe-commits
Author: aganea
Date: Fri May 10 13:11:36 2019
New Revision: 360467

URL: http://llvm.org/viewvc/llvm-project?rev=360467=rev
Log:
Fixed tests where grep was not matching the linefeed

When files are synchronized locally as CRLF on Windows, grep didn't match the 
newline. Switched to FileCheck instead.

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

Modified:
cfe/trunk/test/Preprocessor/indent_macro.c
cfe/trunk/test/Preprocessor/macro_fn_varargs_named.c
cfe/trunk/test/Preprocessor/macro_not_define.c
cfe/trunk/test/Preprocessor/macro_rparen_scan.c

Modified: cfe/trunk/test/Preprocessor/indent_macro.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/indent_macro.c?rev=360467=360466=360467=diff
==
--- cfe/trunk/test/Preprocessor/indent_macro.c (original)
+++ cfe/trunk/test/Preprocessor/indent_macro.c Fri May 10 13:11:36 2019
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -E %s | grep '^   zzap$'
+// RUN: %clang_cc1 -E %s | FileCheck %s --match-full-lines --strict-whitespace
+// CHECK:   zzap
 
 // zzap is on a new line, should be indented.
 #define BLAH  zzap

Modified: cfe/trunk/test/Preprocessor/macro_fn_varargs_named.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/macro_fn_varargs_named.c?rev=360467=360466=360467=diff
==
--- cfe/trunk/test/Preprocessor/macro_fn_varargs_named.c (original)
+++ cfe/trunk/test/Preprocessor/macro_fn_varargs_named.c Fri May 10 13:11:36 
2019
@@ -1,6 +1,9 @@
-// RUN: %clang_cc1 -E %s | grep '^a: x$'
-// RUN: %clang_cc1 -E %s | grep '^b: x y, z,h$'
-// RUN: %clang_cc1 -E %s | grep '^c: foo(x)$'
+// RUN: %clang_cc1 -E %s | FileCheck %s --match-full-lines --strict-whitespace 
--check-prefix CHECK-1
+// CHECK-1:a: x
+// RUN: %clang_cc1 -E %s | FileCheck %s --match-full-lines --strict-whitespace 
--check-prefix CHECK-2
+// CHECK-2:b: x y, z,h
+// RUN: %clang_cc1 -E %s | FileCheck %s --match-full-lines --strict-whitespace 
--check-prefix CHECK-3
+// CHECK-3:c: foo(x)
 
 #define A(b, c...) b c
 a: A(x)

Modified: cfe/trunk/test/Preprocessor/macro_not_define.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/macro_not_define.c?rev=360467=360466=360467=diff
==
--- cfe/trunk/test/Preprocessor/macro_not_define.c (original)
+++ cfe/trunk/test/Preprocessor/macro_not_define.c Fri May 10 13:11:36 2019
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -E %s | grep '^ # define X 3$'
+// RUN: %clang_cc1 -E %s | FileCheck %s --match-full-lines --strict-whitespace
+// CHECK: # define X 3
 
 #define H # 
  #define D define 

Modified: cfe/trunk/test/Preprocessor/macro_rparen_scan.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/macro_rparen_scan.c?rev=360467=360466=360467=diff
==
--- cfe/trunk/test/Preprocessor/macro_rparen_scan.c (original)
+++ cfe/trunk/test/Preprocessor/macro_rparen_scan.c Fri May 10 13:11:36 2019
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -E %s | grep '^3 ;$'
+// RUN: %clang_cc1 -E %s | FileCheck %s --match-full-lines --strict-whitespace
+// CHECK:3 ;
 
 /* Right paren scanning, hard case.  Should expand to 3. */
 #define i(x) 3 


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


r360463 - Improve interface of APValuePathEntry.

2019-05-10 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri May 10 13:05:31 2019
New Revision: 360463

URL: http://llvm.org/viewvc/llvm-project?rev=360463=rev
Log:
Improve interface of APValuePathEntry.

Modified:
cfe/trunk/include/clang/AST/APValue.h
cfe/trunk/lib/AST/APValue.cpp
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp

Modified: cfe/trunk/include/clang/AST/APValue.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/APValue.h?rev=360463=360462=360463=diff
==
--- cfe/trunk/include/clang/AST/APValue.h (original)
+++ cfe/trunk/include/clang/AST/APValue.h Fri May 10 13:05:31 2019
@@ -106,13 +106,41 @@ public:
 unsigned CallIndex, Version;
   };
 
+  /// A FieldDecl or CXXRecordDecl, along with a flag indicating whether we
+  /// mean a virtual or non-virtual base class subobject.
   typedef llvm::PointerIntPair BaseOrMemberType;
-  union LValuePathEntry {
-/// BaseOrMember - The FieldDecl or CXXRecordDecl indicating the next item
-/// in the path. An opaque value of type BaseOrMemberType.
-void *BaseOrMember;
-/// ArrayIndex - The array index of the next item in the path.
-uint64_t ArrayIndex;
+
+  /// A non-discriminated union of a base, field, or array index.
+  class LValuePathEntry {
+static_assert(sizeof(uintptr_t) <= sizeof(uint64_t),
+  "pointer doesn't fit in 64 bits?");
+uint64_t Value;
+
+  public:
+LValuePathEntry() : Value() {}
+LValuePathEntry(BaseOrMemberType BaseOrMember)
+: Value{reinterpret_cast(BaseOrMember.getOpaqueValue())} {}
+static LValuePathEntry ArrayIndex(uint64_t Index) {
+  LValuePathEntry Result;
+  Result.Value = Index;
+  return Result;
+}
+
+BaseOrMemberType getAsBaseOrMember() const {
+  return BaseOrMemberType::getFromOpaqueValue(
+  reinterpret_cast(Value));
+}
+uint64_t getAsArrayIndex() const { return Value; }
+
+friend bool operator==(LValuePathEntry A, LValuePathEntry B) {
+  return A.Value == B.Value;
+}
+friend bool operator!=(LValuePathEntry A, LValuePathEntry B) {
+  return A.Value != B.Value;
+}
+friend llvm::hash_code hash_value(LValuePathEntry A) {
+  return llvm::hash_value(A.Value);
+}
   };
   struct NoLValuePath {};
   struct UninitArray {};

Modified: cfe/trunk/lib/AST/APValue.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/APValue.cpp?rev=360463=360462=360463=diff
==
--- cfe/trunk/lib/AST/APValue.cpp (original)
+++ cfe/trunk/lib/AST/APValue.cpp Fri May 10 13:05:31 2019
@@ -505,8 +505,7 @@ void APValue::printPretty(raw_ostream 
   if (ElemTy->getAs()) {
 // The lvalue refers to a class type, so the next path entry is a base
 // or member.
-const Decl *BaseOrMember =
-
BaseOrMemberType::getFromOpaqueValue(Path[I].BaseOrMember).getPointer();
+const Decl *BaseOrMember = Path[I].getAsBaseOrMember().getPointer();
 if (const CXXRecordDecl *RD = dyn_cast(BaseOrMember)) {
   CastToBase = RD;
   ElemTy = Ctx.getRecordType(RD);
@@ -520,7 +519,7 @@ void APValue::printPretty(raw_ostream 
 }
   } else {
 // The lvalue must refer to an array.
-Out << '[' << Path[I].ArrayIndex << ']';
+Out << '[' << Path[I].getAsArrayIndex() << ']';
 ElemTy = Ctx.getAsArrayType(ElemTy)->getElementType();
   }
 }

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=360463=360462=360463=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Fri May 10 13:05:31 2019
@@ -103,28 +103,19 @@ namespace {
   }
 
   /// Get an LValue path entry, which is known to not be an array index, as a
-  /// field or base class.
-  static
-  APValue::BaseOrMemberType getAsBaseOrMember(APValue::LValuePathEntry E) {
-APValue::BaseOrMemberType Value;
-Value.setFromOpaqueValue(E.BaseOrMember);
-return Value;
-  }
-
-  /// Get an LValue path entry, which is known to not be an array index, as a
   /// field declaration.
   static const FieldDecl *getAsField(APValue::LValuePathEntry E) {
-return dyn_cast(getAsBaseOrMember(E).getPointer());
+return dyn_cast(E.getAsBaseOrMember().getPointer());
   }
   /// Get an LValue path entry, which is known to not be an array index, as a
   /// base class declaration.
   static const CXXRecordDecl *getAsBaseClass(APValue::LValuePathEntry E) {
-return dyn_cast(getAsBaseOrMember(E).getPointer());
+return dyn_cast(E.getAsBaseOrMember().getPointer());
   }
   /// Determine whether this LValue path entry for a base class names a virtual
   /// base class.
   static bool isVirtualBaseClass(APValue::LValuePathEntry 

r360464 - Fix handling of objects under construction during constant expression

2019-05-10 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri May 10 13:05:32 2019
New Revision: 360464

URL: http://llvm.org/viewvc/llvm-project?rev=360464=rev
Log:
Fix handling of objects under construction during constant expression
evaluation.

It's not enough to just track the LValueBase that we're evaluating, we
need to also track the path to the objects whose constructors are
running.

Modified:
cfe/trunk/include/clang/AST/APValue.h
cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
cfe/trunk/lib/AST/APValue.cpp
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp

Modified: cfe/trunk/include/clang/AST/APValue.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/APValue.h?rev=360464=360463=360464=diff
==
--- cfe/trunk/include/clang/AST/APValue.h (original)
+++ cfe/trunk/include/clang/AST/APValue.h Fri May 10 13:05:32 2019
@@ -96,10 +96,14 @@ public:
   return Version;
 }
 
-bool operator==(const LValueBase ) const {
-  return Ptr == Other.Ptr && CallIndex == Other.CallIndex &&
- Version == Other.Version;
+friend bool operator==(const LValueBase , const LValueBase ) {
+  return LHS.Ptr == RHS.Ptr && LHS.CallIndex == RHS.CallIndex &&
+ LHS.Version == RHS.Version;
 }
+friend bool operator!=(const LValueBase , const LValueBase ) {
+  return !(LHS == RHS);
+}
+friend llvm::hash_code hash_value(const LValueBase );
 
   private:
 PtrTy Ptr;

Modified: cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td?rev=360464=360463=360464=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td Fri May 10 13:05:32 2019
@@ -114,6 +114,8 @@ def note_constexpr_access_volatile_obj :
   "%select{read of|assignment to|increment of|decrement of}0 volatile "
   "%select{temporary|object %2|member %2}1 is not allowed in "
   "a constant expression">;
+def note_constexpr_volatile_here : Note<
+  "volatile %select{temporary created|object declared|member declared}0 here">;
 def note_constexpr_ltor_mutable : Note<
   "read of mutable member %0 is not allowed in a constant expression">;
 def note_constexpr_ltor_non_const_int : Note<

Modified: cfe/trunk/lib/AST/APValue.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/APValue.cpp?rev=360464=360463=360464=diff
==
--- cfe/trunk/lib/AST/APValue.cpp (original)
+++ cfe/trunk/lib/AST/APValue.cpp Fri May 10 13:05:32 2019
@@ -58,13 +58,16 @@ llvm::DenseMapInfo::getTombstoneKey());
 }
 
+namespace clang {
+llvm::hash_code hash_value(const APValue::LValueBase ) {
+  return llvm::hash_combine(Base.getOpaqueValue(), Base.getCallIndex(),
+Base.getVersion());
+}
+}
+
 unsigned llvm::DenseMapInfo::getHashValue(
 const clang::APValue::LValueBase ) {
-  llvm::FoldingSetNodeID ID;
-  ID.AddPointer(Base.getOpaqueValue());
-  ID.AddInteger(Base.getCallIndex());
-  ID.AddInteger(Base.getVersion());
-  return ID.ComputeHash();
+  return hash_value(Base);
 }
 
 bool llvm::DenseMapInfo::isEqual(

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=360464=360463=360464=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Fri May 10 13:05:32 2019
@@ -622,6 +622,40 @@ namespace {
 }
   };
 
+  /// A reference to an object whose construction we are currently evaluating.
+  struct ObjectUnderConstruction {
+APValue::LValueBase Base;
+ArrayRef Path;
+friend bool operator==(const ObjectUnderConstruction ,
+   const ObjectUnderConstruction ) {
+  return LHS.Base == RHS.Base && LHS.Path == RHS.Path;
+}
+friend llvm::hash_code hash_value(const ObjectUnderConstruction ) {
+  return llvm::hash_combine(Obj.Base, Obj.Path);
+}
+  };
+  enum class ConstructionPhase { None, Bases, AfterBases };
+}
+
+namespace llvm {
+template<> struct DenseMapInfo {
+  using Base = DenseMapInfo;
+  static ObjectUnderConstruction getEmptyKey() {
+return {Base::getEmptyKey(), {}}; }
+  static ObjectUnderConstruction getTombstoneKey() {
+return {Base::getTombstoneKey(), {}};
+  }
+  static unsigned getHashValue(const ObjectUnderConstruction ) {
+return hash_value(Object);
+  }
+  static bool isEqual(const ObjectUnderConstruction ,
+  const ObjectUnderConstruction ) {
+return LHS == RHS;
+  }
+};
+}
+
+namespace {
   /// EvalInfo - This is a private struct used by the evaluator to capture
   /// information about 

[PATCH] D61765: [OpenMP][Clang][BugFix] Split declares and math functions inclusion.

2019-05-10 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: lib/Headers/openmp_wrappers/__clang_openmp_math_declares.h:17
+  #include 
+  #include 
+#endif

gtbercea wrote:
> jdoerfert wrote:
> > Why do we need the stdlib includes again?
> They are both prone to abs inclusion.
> 
> We need them here to control the order in which they are included relative to 
> the forward_declares header.
I thought the "not defining abs" in __clang_cuda_math_forward_declares.h was 
the solution?


Repository:
  rC Clang

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

https://reviews.llvm.org/D61765



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


[PATCH] D61788: Make getObjCEncodingForTypeImpl() take a bitmask instead of 8 bools

2019-05-10 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/include/clang/AST/ASTContext.h:2877
+OCET_EncodePointerToObjCTypedef = 1 << 7,
+  };
+  void getObjCEncodingForTypeImpl(QualType t, std::string , unsigned Options,

thakis wrote:
> rjmccall wrote:
> > I like the idea of doing this, but can you add some boilerplate? :)  I 
> > think it'd be better if this were a struct with some nice accessors, 
> > factories, transformations, and so on.
> > 
> > This example isn't from Clang, but something like this (without the 
> > templating, of course): 
> > https://github.com/apple/swift/blob/14a20eea03e9115e2c5cf91bccc86e6cd5334df9/include/swift/ABI/MetadataValues.h#L118
> Done. It got pretty wordy (+30 lines instead of -30 before), so I x-macro'd 
> it a bit.
That looks good, but please `camelCase` the method names.  Also, the method 
names sound like they mutate `this` rather than returning a value with the 
mutation in effect.



Comment at: clang/lib/AST/ASTContext.cpp:6885
+.SetIsStructField()
+.SetEncodePointerToObjCTypedef()),
+  FD, NotEncodedT);

These two uses can probably be hoisted up as a common operation, basically "do 
this for a component of the original type".  `forComponentType()`, maybe?


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

https://reviews.llvm.org/D61788



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


[PATCH] D61765: [OpenMP][Clang][BugFix] Split declares and math functions inclusion.

2019-05-10 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 199062.
gtbercea added a comment.

- Clean test header.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61765

Files:
  lib/Driver/ToolChains/Clang.cpp
  lib/Headers/CMakeLists.txt
  lib/Headers/__clang_cuda_math_forward_declares.h
  lib/Headers/openmp_wrappers/__clang_openmp_math.h
  lib/Headers/openmp_wrappers/__clang_openmp_math_declares.h
  lib/Headers/openmp_wrappers/cmath
  lib/Headers/openmp_wrappers/math.h
  test/Headers/Inputs/include/cstdlib
  test/Headers/nvptx_device_cmath_functions.c
  test/Headers/nvptx_device_cmath_functions.cpp
  test/Headers/nvptx_device_math_functions.c
  test/Headers/nvptx_device_math_functions.cpp

Index: test/Headers/nvptx_device_math_functions.cpp
===
--- test/Headers/nvptx_device_math_functions.cpp
+++ test/Headers/nvptx_device_math_functions.cpp
@@ -4,7 +4,7 @@
 // REQUIRES: nvptx-registered-target
 
 // RUN: %clang_cc1 -internal-isystem %S/Inputs/include -include math.h -x c++ -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
-// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_math.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include math.h -internal-isystem %S/Inputs/include -include stdlib.h -include limits -x c++ -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck -check-prefix CHECK-YES %s
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_math_declares.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include math.h -internal-isystem %S/Inputs/include -include stdlib.h -include limits -include cstdlib -x c++ -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck -check-prefix CHECK-YES %s
 
 #include 
 
Index: test/Headers/nvptx_device_math_functions.c
===
--- test/Headers/nvptx_device_math_functions.c
+++ test/Headers/nvptx_device_math_functions.c
@@ -4,7 +4,7 @@
 // REQUIRES: nvptx-registered-target
 
 // RUN: %clang_cc1 -internal-isystem %S/Inputs/include -include math.h -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
-// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_math.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include math.h -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck -check-prefix CHECK-YES %s
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_math_declares.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include math.h -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck -check-prefix CHECK-YES %s
 
 #include 
 
Index: test/Headers/nvptx_device_cmath_functions.cpp
===
--- test/Headers/nvptx_device_cmath_functions.cpp
+++ test/Headers/nvptx_device_cmath_functions.cpp
@@ -4,7 +4,7 @@
 // REQUIRES: nvptx-registered-target
 
 // RUN: %clang_cc1 -internal-isystem %S/Inputs/include -include cmath -x c++ -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
-// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_math.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include cmath -internal-isystem %S/Inputs/include -include stdlib.h -x c++ -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck -check-prefix CHECK-YES %s
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_math_declares.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include cmath -internal-isystem %S/Inputs/include -include stdlib.h -x c++ -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck -check-prefix CHECK-YES %s
 
 #include 
 
Index: 

[PATCH] D61765: [OpenMP][Clang][BugFix] Split declares and math functions inclusion.

2019-05-10 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea marked 2 inline comments as done.
gtbercea added inline comments.



Comment at: lib/Headers/openmp_wrappers/__clang_openmp_math_declares.h:17
+  #include 
+  #include 
+#endif

jdoerfert wrote:
> Why do we need the stdlib includes again?
They are both prone to abs inclusion.

We need them here to control the order in which they are included relative to 
the forward_declares header.



Comment at: test/Headers/Inputs/include/cstdlib:2
+#pragma once
+typedef __SIZE_TYPE__ size_t;

jdoerfert wrote:
> Where is this used? Are there tests missing?
I'll remove it.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61765



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


[PATCH] D60974: Clang IFSO driver action.

2019-05-10 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi updated this revision to Diff 199058.
plotfi added a comment.

Changing !tapi-tbe to !experimental-tapi-elf-v1, removing Endianness field from 
tapi-tbe.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60974

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/Types.def
  clang/include/clang/Frontend/FrontendActions.h
  clang/include/clang/Frontend/FrontendOptions.h
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CMakeLists.txt
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
  clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  clang/test/IFSO/foo-inline.h
  clang/test/IFSO/foo.cpp

Index: clang/test/IFSO/foo.cpp
===
--- /dev/null
+++ clang/test/IFSO/foo.cpp
@@ -0,0 +1,57 @@
+// Using %clang instead of %clang_cc1 because of -fvisibility
+// RUN: %clang -target x86_64-linux-gnu -emit-interface-stubs -interface-stub-version=experimental-tapi-elf-v1 -fvisibility=hidden %s -o - | FileCheck --check-prefix=CHECK-HIDDEN %s
+// RUN: %clang -target x86_64-linux-gnu -emit-interface-stubs -interface-stub-version=experimental-tapi-elf-v1 %s -o - | FileCheck %s
+
+// CHECK-HIDDEN-NOT: _Z4fbarff
+// CHECK: _Z4fbarff
+
+
+
+
+// CHECK-HIDDEN-NOT: _Z3fooii
+// CHECK-NOT:_Z3fooii
+
+
+
+#include "foo-inline.h"
+
+__attribute__ ((visibility ("hidden"))) int foo(int a, int b) { return a + b; }
+__attribute__ ((visibility ("default"))) int foo_default_visi(int a, int b) { return a + b; }
+
+
+__attribute__ ((visibility ("default"))) int fvih_1(int a, int b) { return a + fvih(); }
+
+
+__attribute__((weak)) int someWeakFunc() { return 42; }
+
+int dataA = 34;
+
+namespace baz {
+  template 
+  T add(T a, T b) {
+return a + b;
+  }
+}
+
+namespace n {
+  template 
+  struct __attribute__((__visibility__("default"))) S {
+S() = default;
+~S() = default;
+int __attribute__((__visibility__(("default" func() const { return 32; }
+int __attribute__((__visibility__(("hidden" operator()() const { return 53; }
+  };
+}
+
+template  T neverUsed(T t) { return t + 2; }
+
+template<> int neverUsed(int t);
+
+void g() { n::S()(); }
+
+namespace qux {
+int bar(int a, int b) { return baz::add(a, b); }
+}
+
+float fbar(float a, float b) { return baz::add(a, b); }
+
Index: clang/test/IFSO/foo-inline.h
===
--- /dev/null
+++ clang/test/IFSO/foo-inline.h
@@ -0,0 +1,6 @@
+
+inline int fvih() {
+static int fortytwo = 42;
+  return fortytwo;
+}
+
Index: clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -64,6 +64,10 @@
   case GenerateHeaderModule:
 return llvm::make_unique();
   case GeneratePCH:return llvm::make_unique();
+  case GenerateInterfaceYAMLExpV1:
+return llvm::make_unique();
+  case GenerateInterfaceTBEExpV1:
+return llvm::make_unique();
   case InitOnly:   return llvm::make_unique();
   case ParseSyntaxOnly:return llvm::make_unique();
   case ModuleFileInfo: return llvm::make_unique();
Index: clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
===
--- /dev/null
+++ clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
@@ -0,0 +1,304 @@
+//===--- InterfaceStubFunctionsConsumer.cpp ---===//
+//
+// 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 "clang/AST/RecursiveASTVisitor.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/FrontendActions.h"
+#include "clang/Index/CodegenNameGenerator.h"
+#include "clang/Sema/TemplateInstCallback.h"
+#include "llvm/BinaryFormat/ELF.h"
+
+using namespace clang;
+
+class InterfaceStubFunctionsConsumer : public ASTConsumer {
+  CompilerInstance 
+  StringRef InFile = "";
+  StringRef Format = "";
+  std::set ParsedTemplates;
+
+  enum RootDeclOrigin { TopLevel = 0, FromTU = 1, IsLate = 2 };
+  struct MangledSymbol {
+std::string Name = "";
+uint8_t Type;
+uint8_t Binding;
+MangledSymbol() = delete;
+MangledSymbol(const std::string , uint8_t Type, uint8_t Binding)
+: Name(Name), Type(Type), Binding(Binding) {}
+  };
+  using MangledSymbols = std::map;
+
+  bool WriteNamedDecl(const NamedDecl *ND, MangledSymbols , int RDO) {
+if (!(RDO & FromTU))
+  return true;
+if (Symbols.find(ND) != Symbols.end())

[PATCH] D61765: [OpenMP][Clang][BugFix] Split declares and math functions inclusion.

2019-05-10 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

What about `abs` tests?




Comment at: lib/Headers/openmp_wrappers/__clang_openmp_math_declares.h:17
+  #include 
+  #include 
+#endif

Why do we need the stdlib includes again?



Comment at: test/Headers/Inputs/include/cstdlib:2
+#pragma once
+typedef __SIZE_TYPE__ size_t;

Where is this used? Are there tests missing?


Repository:
  rC Clang

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

https://reviews.llvm.org/D61765



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


[PATCH] D61788: Make getObjCEncodingForTypeImpl() take a bitmask instead of 8 bools

2019-05-10 Thread Nico Weber via Phabricator via cfe-commits
thakis marked 2 inline comments as done.
thakis added inline comments.



Comment at: clang/include/clang/AST/ASTContext.h:2877
+OCET_EncodePointerToObjCTypedef = 1 << 7,
+  };
+  void getObjCEncodingForTypeImpl(QualType t, std::string , unsigned Options,

rjmccall wrote:
> I like the idea of doing this, but can you add some boilerplate? :)  I think 
> it'd be better if this were a struct with some nice accessors, factories, 
> transformations, and so on.
> 
> This example isn't from Clang, but something like this (without the 
> templating, of course): 
> https://github.com/apple/swift/blob/14a20eea03e9115e2c5cf91bccc86e6cd5334df9/include/swift/ABI/MetadataValues.h#L118
Done. It got pretty wordy (+30 lines instead of -30 before), so I x-macro'd it 
a bit.


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

https://reviews.llvm.org/D61788



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


[PATCH] D61709: [NewPM] Port HWASan and Kernel HWASan

2019-05-10 Thread Philip Pfaffe via Phabricator via cfe-commits
philip.pfaffe accepted this revision.
philip.pfaffe added a comment.
This revision is now accepted and ready to land.

Nit aside, looks good!




Comment at: llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp:179
 
-  bool runOnFunction(Function ) override;
-  bool doInitialization(Module ) override;
+  bool instrumentFunction(Function );
+  void initializeWithModule(Module );

There are some naming clashes here. In the other sanitizers these functions are 
called `sanitizeFunction` and `initializeModule`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61709



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


[PATCH] D61634: [clang/llvm] Allow efficient implementation of libc's memory functions in C/C++

2019-05-10 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

> -fno-builtin* is about preventing clang/llvm from recognizing that a piece of 
> code has the same semantic as a particular IR intrinsic, it has nothing to do 
> with preventing the compiler from generating runtime calls.

It has a dual purpose for C library functions.  One, it prevents the compiler 
from assuming an explicitly written call to that function has some particular 
semantics.  Two, it prevents the compiler from assuming the underlying library 
function exists for the purpose of optimization.  (These are sort of 
intertwined, but they both matter in this context.)

> I believe very few people will use the attribute described in the RFC, it 
> will most probably be library maintainers that already know a good deal of 
> how the compiler is allowed to transform the code.

Sure, I'm happy to assume that memcpy/memset implementations are written using 
some appropriate subset of C.  (We should probably document that subset at some 
point.)

--

I still think there are really two things you're trying to accomplish here, 
which should be handled separately.

1. Add a function attribute that works like -fno-builtin-memcpy currently does, 
to prevent the compiler from synthesizing calls to memcpy.
2. Provide a convenient way to write a small, fixed-length "memcpy", in C and 
in LLVM IR, that is always expanded to optimal straight-line code (without any 
calls or loops).

These correspond to proposals (1) and (2) from your RFC; I think we need both 
to arrive at a reasonable final state.

(The "rep; movs" is a third thing, which I think should also be handled 
separately, but it sounds like you don't think that's very important.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61634



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


[PATCH] D60974: Clang IFSO driver action.

2019-05-10 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi marked an inline comment as done.
plotfi added a comment.

In D60974#1498240 , @jakehehrlich 
wrote:

> This shouldn't emit the .tbe format at all, the .tbe format is meant to be in 
> near 1-1 correspondence with .so files, not with .o files. It has things like 
> DT_NEEDED, and DT_SONAME related information that don't make sense for .o 
> files for instance.
>
> If we put things under an --experimental flags, minimize what we add in the 
> first patch, and try and make each additional field added need based, I'm ok 
> with whatever being added to Clang assuming it doesn't interfere with other 
> parts of the compiler.


That sounds good. I wasn't sure if you wanted straight up tbe or not. I can 
basically keep what we have here and make the heading line include an 
"experimental" tag so that it cant be directly read by the llvm-elfabi tool 
without some changes. I do think it should be sufficient to have some subset of 
tbe as a merging format in llvm-elbabi. Will post an update.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60974



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


[PATCH] D60974: Clang IFSO driver action.

2019-05-10 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi marked 2 inline comments as done.
plotfi added inline comments.



Comment at: llvm/include/llvm/TextAPI/ELF/ELFStub.h:58
   ELFArch Arch;
+  Optional Endian;
   std::vector NeededLibs;

jakehehrlich wrote:
> Why do we need or want this? If it is needed can it be added later when 
> needed? Also why is this a string?
Just a suggestion, I saw that ELF needs endianness specified and I also saw 
that the llvm-elfabi tool (the latest patch set from phab anyways) has cmd 
clangs for specifying endianness and thought it could be nice to specify in the 
file. Also you are right, this probably shouldn't be a string. I can drop it 
from this change. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60974



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


[PATCH] D43576: Solution to fix PR27066 - Redefinition with same mangled name as another definition (dllexport and uuid)

2019-05-10 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: include/clang/AST/Decl.h:4281
+ class DeclSpecUuidDecl : public Decl {
+   StringRef StrUuid;
+ public:

Can we store a `StringLiteral*` here instead?



Comment at: include/clang/Sema/Sema.h:393-394
 
+  /// List of declspec(uuid ...) for a specific uuid string.
+  SmallVector DeclSpecUuidDecls;
+

rsmith wrote:
> Remove this? It is only used once, and only to initialize an unused variable.
Comment marked done but not done?



Comment at: include/clang/Sema/Sema.h:399
+  std::map UuidExpMap;
+  std::map DeclSpecToStrUuid;
+

rsmith wrote:
> This seems suspicious. If we want the uuid of a declaration, should we not be 
> asking it for its `UuidAttr` instead?
Comment marked done but not done?



Comment at: lib/Parse/ParseDecl.cpp:572
+DeclSpecUuidDecl *ArgDecl =
+  DeclSpecUuidDecl::Create(Actions.getASTContext(),
+   Actions.getFunctionLevelDeclContext(),

zahiraam wrote:
> rsmith wrote:
> > What should happen if multiple declarations (of distinct entities) use the 
> > same `__declspec(uuid(...))` attribute? Should you get a redefinition error 
> > for the attribute or should they all share the same UUID entity? Either 
> > way, we'll want to do some (minimal) UUID lookup and build a redeclaration 
> > chain for `DeclSpecUuidDecl`s.
> If we want to align with MS, we don't want  to signal an error. So may be I 
> should have a map that assigns to each StrUuid a list of DeclSpecUuid?
> So for this code:
> struct
> __declspec(uuid("{DDB47A6A-0F23-11D5-9109-00E0296B75D3}"))
> S1 {};
> 
> struct
> __declspec(uuid("{DDB47A6A-0F23-11D5-9109-00E0296B75D3}"))
> S2 {};
> 
> I will have a map from DDB47A6A-0F23-11D5-9109-00E0296B75D3 to {S1, S2}. Do 
> you agree?
> 
I think you should have a map from UUID to either the most recent 
`DeclSpecUuidDecl` for that UUID, and form redeclaration chains for 
`DeclSpecUuidDecl`s with the same UUID. (`DeclSpecUuidDecl` should derive from 
`Redeclarable` and you can call `setPreviousDecl` to connect 
the new declaration to the prior one.)

You'll need to make sure this case is properly handled during lazy AST 
deserialization.



Comment at: lib/Parse/ParseDecl.cpp:594
+  bool Invalid = false;
+  StringRef UuidStr = PP.getSpelling(Tok, UuidBuffer, );
+

zahiraam wrote:
> rsmith wrote:
> > How does this handle the case where multiple tokens must be concatenated to 
> > form a uuid? Eg, `uuid(12345678-9abc-def0-1234-56789abcdef0)`
> ksh-3.2$ cat m3.cpp
> struct __declspec (uuid(12345678-9abc-def0-1234-56789abcdef0)) s;
> ksh-3.2$ clang -c m3.cpp
> m3.cpp:1:35: error: invalid digit 'a' in decimal constant
> struct __declspec (uuid(12345678-9abc-def0-1234-56789abcdef0)) s;
>   ^
> m3.cpp:1:39: error: use of undeclared identifier 'def0'
> struct __declspec (uuid(12345678-9abc-def0-1234-56789abcdef0)) s;
>   ^
> m3.cpp:1:54: error: invalid digit 'a' in decimal constant
> struct __declspec (uuid(12345678-9abc-def0-1234-56789abcdef0)) s;
>  ^
> 3 errors generated.
> ksh-3.2$
> 
This case is accepted by MSVC and not here:
```
struct __declspec(uuid(R"(12345678-9abc-def0-1234-56789abcdef0)")) s;
```
(MSVC also accepts a `u8` prefix, but no other encoding prefix. I also note 
that MSVC does not support string literal concatenation here, so we don't need 
to deal with that.)

Please use `StringLiteralParser` to properly handle cases like this, rather 
than rolling your own string literal parsing here.



Comment at: lib/Sema/SemaExprCXX.cpp:619
+ /// Finds the __declSpec uuid Decl off a type.
+ static void FindADeclOffAType(Sema ,
+   QualType QT,

Do we need both this and getUuidAttrOfType?



Comment at: lib/Sema/SemaExprCXX.cpp:635
+   if (TD->getMostRecentDecl()->getAttr()) {
+ UuidDecl.push_back(dcl);
+ return;

It would seem cleaner to collect the `UuidAttrDecl`s or `UuidAttr`s here rather 
than the declarations that have those attributes.



Comment at: lib/Sema/SemaExprCXX.cpp:647-648
+ FindADeclOffAType(SemaRef, TA.getAsType(), UuidDecl);
+   if (dd)
+ UuidDecl.push_back(dcl);
+ }

Dead code.



Comment at: lib/Sema/SemaExprCXX.cpp:675-681
+   if (expr.isUnset()) {
+ uuid_expr =
+   new (Context) CXXUuidofExpr(TypeInfoType.withConst(), Operand, UuidStr,
+ SourceRange(TypeidLoc, RParenLoc));
+ UuidExpMap[UuidStr] = uuid_expr;
+ return uuid_expr;
+   }

Revert this change; we need to build a new `CXXUuidofExpr` with a correct 
source location and type rather than reusing one from somewhere else. Then 
remove 

r360452 - Replace 'REQUIRES: nozlib' with '!zlib' because we don't need two ways

2019-05-10 Thread Paul Robinson via cfe-commits
Author: probinson
Date: Fri May 10 11:32:53 2019
New Revision: 360452

URL: http://llvm.org/viewvc/llvm-project?rev=360452=rev
Log:
Replace 'REQUIRES: nozlib' with '!zlib' because we don't need two ways
to say the same thing.

Modified:
cfe/trunk/test/Driver/nozlibcompress.c

Modified: cfe/trunk/test/Driver/nozlibcompress.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/nozlibcompress.c?rev=360452=360451=360452=diff
==
--- cfe/trunk/test/Driver/nozlibcompress.c (original)
+++ cfe/trunk/test/Driver/nozlibcompress.c Fri May 10 11:32:53 2019
@@ -1,4 +1,4 @@
-// REQUIRES: nozlib
+// REQUIRES: !zlib
 
 // RUN: %clang -### -fintegrated-as -gz -c %s 2>&1 | FileCheck %s 
-check-prefix CHECK-WARN
 // RUN: %clang -### -fintegrated-as -gz=none -c %s 2>&1 | FileCheck 
-allow-empty -check-prefix CHECK-NOWARN %s


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


[clang-tools-extra] r360451 - Removing an unused member variable; NFC.

2019-05-10 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Fri May 10 11:29:10 2019
New Revision: 360451

URL: http://llvm.org/viewvc/llvm-project?rev=360451=rev
Log:
Removing an unused member variable; NFC.

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp?rev=360451=360450=360451=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp 
Fri May 10 11:29:10 2019
@@ -23,8 +23,7 @@ namespace modernize {
 namespace {
 struct UnqualNameVisitor : public RecursiveASTVisitor {
 public:
-  UnqualNameVisitor(const FunctionDecl , const SourceManager )
-  : F(F), SM(SM) {}
+  UnqualNameVisitor(const FunctionDecl ) : F(F) {}
 
   bool Collision = false;
 
@@ -96,7 +95,6 @@ public:
 
 private:
   const FunctionDecl 
-  const SourceManager 
 };
 } // namespace
 
@@ -447,7 +445,7 @@ void UseTrailingReturnTypeCheck::check(c
   // name, then we can either not perform a rewrite or explicitely qualify the
   // entity. Such entities could be function parameter names, (inherited) class
   // members, template parameters, etc.
-  UnqualNameVisitor UNV{*F, SM};
+  UnqualNameVisitor UNV{*F};
   UNV.TraverseTypeLoc(FTL.getReturnLoc());
   if (UNV.Collision) {
 diag(F->getLocation(), Message);


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


[PATCH] D60629: [clang-tidy] Change the namespace for llvm checkers from 'llvm' to 'llvm_check'

2019-05-10 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE360450: [clang-tidy] Change the namespace for llvm 
checkers from llvm to llvm_check (authored by dhinton, 
committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D60629?vs=196531=199042#toc

Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D60629

Files:
  clang-tidy/add_new_check.py
  clang-tidy/llvm/HeaderGuardCheck.cpp
  clang-tidy/llvm/HeaderGuardCheck.h
  clang-tidy/llvm/IncludeOrderCheck.cpp
  clang-tidy/llvm/IncludeOrderCheck.h
  clang-tidy/llvm/LLVMTidyModule.cpp
  clang-tidy/llvm/PreferIsaOrDynCastInConditionalsCheck.cpp
  clang-tidy/llvm/PreferIsaOrDynCastInConditionalsCheck.h
  clang-tidy/llvm/TwineLocalCheck.cpp
  clang-tidy/llvm/TwineLocalCheck.h
  clang-tidy/rename_check.py
  unittests/clang-tidy/LLVMModuleTest.cpp

Index: unittests/clang-tidy/LLVMModuleTest.cpp
===
--- unittests/clang-tidy/LLVMModuleTest.cpp
+++ unittests/clang-tidy/LLVMModuleTest.cpp
@@ -3,7 +3,7 @@
 #include "llvm/IncludeOrderCheck.h"
 #include "gtest/gtest.h"
 
-using namespace clang::tidy::llvm;
+using namespace clang::tidy::llvm_check;
 
 namespace clang {
 namespace tidy {
Index: clang-tidy/rename_check.py
===
--- clang-tidy/rename_check.py
+++ clang-tidy/rename_check.py
@@ -14,6 +14,18 @@
 import re
 
 
+def replaceInFileRegex(fileName, sFrom, sTo):
+  if sFrom == sTo:
+return
+  txt = None
+  with open(fileName, "r") as f:
+txt = f.read()
+
+  txt = re.sub(sFrom, sTo, txt)
+  print("Replacing '%s' -> '%s' in '%s'..." % (sFrom, sTo, fileName))
+  with open(fileName, "w") as f:
+f.write(txt)
+
 def replaceInFile(fileName, sFrom, sTo):
   if sFrom == sTo:
 return
@@ -203,6 +215,8 @@
   clang_tidy_path = os.path.dirname(__file__)
 
   header_guard_variants = [
+  (args.old_check_name.replace('-', '_')).upper() + '_CHECK',
+  (old_module + '_' + check_name_camel).upper(),
   (old_module + '_' + new_check_name_camel).upper(),
   args.old_check_name.replace('-', '_').upper()]
   header_guard_new = (new_module + '_' + new_check_name_camel).upper()
@@ -210,18 +224,19 @@
   old_module_path = os.path.join(clang_tidy_path, old_module)
   new_module_path = os.path.join(clang_tidy_path, new_module)
 
-  # Remove the check from the old module.
-  cmake_lists = os.path.join(old_module_path, 'CMakeLists.txt')
-  check_found = deleteMatchingLines(cmake_lists, '\\b' + check_name_camel)
-  if not check_found:
-print("Check name '%s' not found in %s. Exiting." %
+  if (args.old_check_name != args.new_check_name):
+# Remove the check from the old module.
+cmake_lists = os.path.join(old_module_path, 'CMakeLists.txt')
+check_found = deleteMatchingLines(cmake_lists, '\\b' + check_name_camel)
+if not check_found:
+  print("Check name '%s' not found in %s. Exiting." %
 (check_name_camel, cmake_lists))
-return 1
+  return 1
 
-  modulecpp = filter(
-  lambda p: p.lower() == old_module.lower() + 'tidymodule.cpp',
-  os.listdir(old_module_path))[0]
-  deleteMatchingLines(os.path.join(old_module_path, modulecpp),
+modulecpp = filter(
+lambda p: p.lower() == old_module.lower() + 'tidymodule.cpp',
+os.listdir(old_module_path))[0]
+deleteMatchingLines(os.path.join(old_module_path, modulecpp),
   '\\b' + check_name_camel + '|\\b' + args.old_check_name)
 
   for filename in getListOfFiles(clang_tidy_path):
@@ -249,14 +264,21 @@
   new_module + '/' + new_check_name_camel)
 replaceInFile(filename, check_name_camel, new_check_name_camel)
 
-  if old_module != new_module:
+  if old_module != new_module or new_module == 'llvm':
+if new_module == 'llvm':
+  new_namespace = new_module + '_check'
+else:
+  new_namespace = new_module
 check_implementation_files = glob.glob(
 os.path.join(old_module_path, new_check_name_camel + '*'))
 for filename in check_implementation_files:
   # Move check implementation to the directory of the new module.
   filename = fileRename(filename, old_module_path, new_module_path)
-  replaceInFile(filename, 'namespace ' + old_module,
-'namespace ' + new_module)
+  replaceInFileRegex(filename, 'namespace ' + old_module + '[^ \n]*',
+ 'namespace ' + new_namespace)
+
+  if (args.old_check_name == args.new_check_name):
+return
 
   # Add check to the new module.
   adapt_cmake(new_module_path, new_check_name_camel)
Index: clang-tidy/add_new_check.py
===
--- clang-tidy/add_new_check.py
+++ clang-tidy/add_new_check.py
@@ -46,7 +46,7 @@
 
 
 # Adds a header for the new check.
-def write_header(module_path, module, 

[clang-tools-extra] r360450 - [clang-tidy] Change the namespace for llvm checkers from 'llvm' to 'llvm_check'

2019-05-10 Thread Don Hinton via cfe-commits
Author: dhinton
Date: Fri May 10 11:27:09 2019
New Revision: 360450

URL: http://llvm.org/viewvc/llvm-project?rev=360450=rev
Log:
[clang-tidy] Change the namespace for llvm checkers from 'llvm' to 'llvm_check'

Summary:
Change the namespace for llvm checkers from 'llvm' to
'llvm_check', and modify add_new_check.py and rename_check.py to
support the new namespace. Checker, file, and directory names remain
unchanged.

Used new version of rename_check.py to make the change in existing
llvm checkers, but had to fix LLVMTidyModule.cpp and
LLVMModuleTest.cpp by hand.

The changes made by rename_check.py are idempotent, so if accidentally
run multiple times, it won't do anything.

Reviewed By: aaron.ballman

Tags: #clang, #clang-tools-extra

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

Modified:
clang-tools-extra/trunk/clang-tidy/add_new_check.py
clang-tools-extra/trunk/clang-tidy/llvm/HeaderGuardCheck.cpp
clang-tools-extra/trunk/clang-tidy/llvm/HeaderGuardCheck.h
clang-tools-extra/trunk/clang-tidy/llvm/IncludeOrderCheck.cpp
clang-tools-extra/trunk/clang-tidy/llvm/IncludeOrderCheck.h
clang-tools-extra/trunk/clang-tidy/llvm/LLVMTidyModule.cpp

clang-tools-extra/trunk/clang-tidy/llvm/PreferIsaOrDynCastInConditionalsCheck.cpp

clang-tools-extra/trunk/clang-tidy/llvm/PreferIsaOrDynCastInConditionalsCheck.h
clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.cpp
clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.h
clang-tools-extra/trunk/clang-tidy/rename_check.py
clang-tools-extra/trunk/unittests/clang-tidy/LLVMModuleTest.cpp

Modified: clang-tools-extra/trunk/clang-tidy/add_new_check.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/add_new_check.py?rev=360450=360449=360450=diff
==
--- clang-tools-extra/trunk/clang-tidy/add_new_check.py (original)
+++ clang-tools-extra/trunk/clang-tidy/add_new_check.py Fri May 10 11:27:09 2019
@@ -46,7 +46,7 @@ def adapt_cmake(module_path, check_name_
 
 
 # Adds a header for the new check.
-def write_header(module_path, module, check_name, check_name_camel):
+def write_header(module_path, module, namespace, check_name, check_name_camel):
   check_name_dashes = module + '-' + check_name
   filename = os.path.join(module_path, check_name_camel) + '.h'
   print('Creating %s...' % filename)
@@ -73,7 +73,7 @@ def write_header(module_path, module, ch
 
 namespace clang {
 namespace tidy {
-namespace %(module)s {
+namespace %(namespace)s {
 
 /// FIXME: Write a short description.
 ///
@@ -87,7 +87,7 @@ public:
   void check(const ast_matchers::MatchFinder::MatchResult ) override;
 };
 
-} // namespace %(module)s
+} // namespace %(namespace)s
 } // namespace tidy
 } // namespace clang
 
@@ -95,11 +95,12 @@ public:
 """ % {'header_guard': header_guard,
'check_name': check_name_camel,
'check_name_dashes': check_name_dashes,
-   'module': module})
+   'module': module,
+   'namespace': namespace})
 
 
 # Adds the implementation of the new check.
-def write_implementation(module_path, module, check_name_camel):
+def write_implementation(module_path, module, namespace, check_name_camel):
   filename = os.path.join(module_path, check_name_camel) + '.cpp'
   print('Creating %s...' % filename)
   with open(filename, 'w') as f:
@@ -124,7 +125,7 @@ using namespace clang::ast_matchers;
 
 namespace clang {
 namespace tidy {
-namespace %(module)s {
+namespace %(namespace)s {
 
 void %(check_name)s::registerMatchers(MatchFinder *Finder) {
   // FIXME: Add matchers.
@@ -142,11 +143,12 @@ void %(check_name)s::check(const MatchFi
   << FixItHint::CreateInsertion(MatchedDecl->getLocation(), "awesome_");
 }
 
-} // namespace %(module)s
+} // namespace %(namespace)s
 } // namespace tidy
 } // namespace clang
 """ % {'check_name': check_name_camel,
-   'module': module})
+   'module': module,
+   'namespace': namespace})
 
 
 # Modifies the module to include the new check.
@@ -375,8 +377,15 @@ def main():
 
   if not adapt_cmake(module_path, check_name_camel):
 return
-  write_header(module_path, module, check_name, check_name_camel)
-  write_implementation(module_path, module, check_name_camel)
+
+  # Map module names to namespace names that don't conflict with widely used 
top-level namespaces.
+  if module == 'llvm':
+namespace = module + '_check'
+  else:
+namespace = module
+
+  write_header(module_path, module, namespace, check_name, check_name_camel)
+  write_implementation(module_path, module, namespace, check_name_camel)
   adapt_module(module_path, module, check_name, check_name_camel)
   add_release_notes(module_path, module, check_name)
   test_extension = language_to_extension.get(args.language)

Modified: clang-tools-extra/trunk/clang-tidy/llvm/HeaderGuardCheck.cpp
URL: 

[PATCH] D61765: [OpenMP][Clang][BugFix] Split declares and math functions inclusion.

2019-05-10 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 199041.
gtbercea added a comment.

- Fix cstdlib issue.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61765

Files:
  lib/Driver/ToolChains/Clang.cpp
  lib/Headers/CMakeLists.txt
  lib/Headers/__clang_cuda_math_forward_declares.h
  lib/Headers/openmp_wrappers/__clang_openmp_math.h
  lib/Headers/openmp_wrappers/__clang_openmp_math_declares.h
  lib/Headers/openmp_wrappers/cmath
  lib/Headers/openmp_wrappers/math.h
  test/Headers/Inputs/include/cstdlib
  test/Headers/nvptx_device_cmath_functions.c
  test/Headers/nvptx_device_cmath_functions.cpp
  test/Headers/nvptx_device_math_functions.c
  test/Headers/nvptx_device_math_functions.cpp

Index: test/Headers/nvptx_device_math_functions.cpp
===
--- test/Headers/nvptx_device_math_functions.cpp
+++ test/Headers/nvptx_device_math_functions.cpp
@@ -4,7 +4,7 @@
 // REQUIRES: nvptx-registered-target
 
 // RUN: %clang_cc1 -internal-isystem %S/Inputs/include -include math.h -x c++ -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
-// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_math.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include math.h -internal-isystem %S/Inputs/include -include stdlib.h -include limits -x c++ -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck -check-prefix CHECK-YES %s
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_math_declares.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include math.h -internal-isystem %S/Inputs/include -include stdlib.h -include limits -include cstdlib -x c++ -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck -check-prefix CHECK-YES %s
 
 #include 
 
Index: test/Headers/nvptx_device_math_functions.c
===
--- test/Headers/nvptx_device_math_functions.c
+++ test/Headers/nvptx_device_math_functions.c
@@ -4,7 +4,7 @@
 // REQUIRES: nvptx-registered-target
 
 // RUN: %clang_cc1 -internal-isystem %S/Inputs/include -include math.h -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
-// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_math.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include math.h -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck -check-prefix CHECK-YES %s
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_math_declares.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include math.h -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck -check-prefix CHECK-YES %s
 
 #include 
 
Index: test/Headers/nvptx_device_cmath_functions.cpp
===
--- test/Headers/nvptx_device_cmath_functions.cpp
+++ test/Headers/nvptx_device_cmath_functions.cpp
@@ -4,7 +4,7 @@
 // REQUIRES: nvptx-registered-target
 
 // RUN: %clang_cc1 -internal-isystem %S/Inputs/include -include cmath -x c++ -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
-// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_math.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include cmath -internal-isystem %S/Inputs/include -include stdlib.h -x c++ -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck -check-prefix CHECK-YES %s
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_math_declares.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -include cmath -internal-isystem %S/Inputs/include -include stdlib.h -x c++ -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck -check-prefix CHECK-YES %s
 
 #include 
 
Index: 

[PATCH] D51329: [Attribute/Diagnostics] Print macro if definition is an attribute declaration

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

In D51329#1498193 , @miyuki wrote:

> This caused https://bugs.llvm.org/show_bug.cgi?id=41835
>  Could you please look into it?


Sorry for the delay. I submitted r360448 as a fix for this.


Repository:
  rC Clang

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

https://reviews.llvm.org/D51329



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


r360448 - Fix and test for assertion error in P41835.

2019-05-10 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Fri May 10 11:05:15 2019
New Revision: 360448

URL: http://llvm.org/viewvc/llvm-project?rev=360448=rev
Log:
Fix and test for assertion error in P41835.

Modified:
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/test/Frontend/macro_defined_type.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=360448=360447=360448=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Fri May 10 11:05:15 2019
@@ -2758,6 +2758,12 @@ QualType ASTContext::getFunctionTypeWith
 return getParenType(
 getFunctionTypeWithExceptionSpec(PT->getInnerType(), ESI));
 
+  // Might be wrapped in a macro qualified type.
+  if (const auto *MQT = dyn_cast(Orig))
+return getMacroQualifiedType(
+getFunctionTypeWithExceptionSpec(MQT->getUnderlyingType(), ESI),
+MQT->getMacroIdentifier());
+
   // Might have a calling-convention attribute.
   if (const auto *AT = dyn_cast(Orig))
 return getAttributedType(

Modified: cfe/trunk/test/Frontend/macro_defined_type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/macro_defined_type.cpp?rev=360448=360447=360448=diff
==
--- cfe/trunk/test/Frontend/macro_defined_type.cpp (original)
+++ cfe/trunk/test/Frontend/macro_defined_type.cpp Fri May 10 11:05:15 2019
@@ -13,3 +13,9 @@ void Func() {
   auto NODEREF *auto_i_ptr2 = i_ptr;
   auto NODEREF auto_i2 = i; // expected-warning{{'noderef' can only be used on 
an array or pointer type}}
 }
+
+// Added test for fix for P41835
+#define _LIBCPP_FLOAT_ABI __attribute__((pcs("aapcs")))
+struct A {
+  _LIBCPP_FLOAT_ABI int operator()() throw(); // expected-warning{{'pcs' 
calling convention ignored for this target}}
+};


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


[PATCH] D61749: [clang-tidy] initial version of readability-static-const-method

2019-05-10 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a reviewer: lebedev.ri.
lebedev.ri added a comment.

In D61749#1497162 , @Eugene.Zelenko 
wrote:

> @JonasToth tried to implement const check, so probably const and static part 
> should be split.


I agree, there is D54943 , which should be 99% 
ready to go, and is only stuck due to @JonasToth
time constraints, IIRC. Treating `*this` pointer should simply be a logical 
extension of
that check. (unless it already does that, or there is some other patch i forgot 
about)

I.e. let's split this, and start with `static` part.

Also, you are aware of `ExprMutationAnalyzer`?

> It's hard to tell about state of existing implementation, but you could 
> continue it or at least borrow ideas and tests.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61749



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


r360447 - Replace 'REQUIRES: not_?san' with 'UNSUPPORTED: ?san' as that better

2019-05-10 Thread Paul Robinson via cfe-commits
Author: probinson
Date: Fri May 10 10:57:22 2019
New Revision: 360447

URL: http://llvm.org/viewvc/llvm-project?rev=360447=rev
Log:
Replace 'REQUIRES: not_?san' with 'UNSUPPORTED: ?san' as that better
expresses the intent of the exclusion.

Modified:
cfe/trunk/test/Index/annotate-deep-statements.cpp
cfe/trunk/test/Index/index-many-call-ops.cpp
cfe/trunk/test/Index/index-many-logical-ops.c
cfe/trunk/test/SemaTemplate/instantiation-depth-default.cpp

Modified: cfe/trunk/test/Index/annotate-deep-statements.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/annotate-deep-statements.cpp?rev=360447=360446=360447=diff
==
--- cfe/trunk/test/Index/annotate-deep-statements.cpp (original)
+++ cfe/trunk/test/Index/annotate-deep-statements.cpp Fri May 10 10:57:22 2019
@@ -4,7 +4,7 @@
 // Check that we don't get stack overflow trying to annotate an extremely deep 
AST.
 
 // AddressSanitizer and UndefinedBehaviorSanitizer increases stack usage.
-// REQUIRES: not_asan, not_ubsan
+// UNSUPPORTED: asan, ubsan
 
 struct S {
   S ()();

Modified: cfe/trunk/test/Index/index-many-call-ops.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/index-many-call-ops.cpp?rev=360447=360446=360447=diff
==
--- cfe/trunk/test/Index/index-many-call-ops.cpp (original)
+++ cfe/trunk/test/Index/index-many-call-ops.cpp Fri May 10 10:57:22 2019
@@ -5,7 +5,7 @@
 // call operators.
 
 // UBSan increses stack usage.
-// REQUIRES: not_ubsan
+// UNSUPPORTED: ubsan
 
 struct S {
   S ()();

Modified: cfe/trunk/test/Index/index-many-logical-ops.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/index-many-logical-ops.c?rev=360447=360446=360447=diff
==
--- cfe/trunk/test/Index/index-many-logical-ops.c (original)
+++ cfe/trunk/test/Index/index-many-logical-ops.c Fri May 10 10:57:22 2019
@@ -5,7 +5,7 @@
 // logical operators.
 
 // UBSan increases stack usage.
-// REQUIRES: not_ubsan
+// UNSUPPORTED: ubsan
 
 // CHECK: [indexDeclaration]: kind: function | name: foo
 int foo(int x) {

Modified: cfe/trunk/test/SemaTemplate/instantiation-depth-default.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/instantiation-depth-default.cpp?rev=360447=360446=360447=diff
==
--- cfe/trunk/test/SemaTemplate/instantiation-depth-default.cpp (original)
+++ cfe/trunk/test/SemaTemplate/instantiation-depth-default.cpp Fri May 10 
10:57:22 2019
@@ -3,7 +3,7 @@
 // FIXME: Disable this test when Clang was built with ASan, because ASan
 // increases our per-frame stack usage enough that this test no longer fits
 // within our normal stack space allocation.
-// REQUIRES: not_asan
+// UNSUPPORTED: asan
 
 template struct X : X {};
 // expected-error-re@8 {{recursive template instantiation exceeded maximum 
depth of 1024{{$


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


[PATCH] D59885: [Lex] Allow to consume tokens while preprocessing

2019-05-10 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In D59885#1496734 , @ilya-biryukov 
wrote:

> Overall, the performance cost in empty-callback case seems to be lower than 
> `5%`. This is significant, but hopefully acceptable.


5% is a lot to pay for something that we won't be using at all during normal 
preprocessing / compilation. But I think we can simplify this a bit, and that 
might help.




Comment at: clang/lib/Lex/PPCaching.cpp:64
   ExitCachingLexMode();
-  Lex(Result);
+  Lex(Result, Report);
 

This change seems redundant: `LexLevel` is always `1` here, so this token would 
never be reported anyway. And with that gone I think you can remove the 
`Report` parameter entirely.



Comment at: clang/lib/Lex/Preprocessor.cpp:892
   do {
 switch (CurLexerKind) {
 case CLK_Lexer:

Doesn't this always set `Report` to the same value as `IsNewToken`? (The only 
case we set `Report` to `false` is when we call `CachingLex` and it sets 
`IsNewToken` to `false`, and `CachingLex` can't be recursively called twice, so 
its recursive call to `Lex` can't set `Report` to `false`..)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59885



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


[PATCH] D61165: Fix a crash where a [[no_destroy]] destructor was not emitted in an array

2019-05-10 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL360446: [Sema] Mark array element destructors referenced 
during initialization (authored by epilk, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D61165?vs=198944=199038#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D61165

Files:
  cfe/trunk/include/clang/Basic/AttrDocs.td
  cfe/trunk/lib/Sema/SemaDeclCXX.cpp
  cfe/trunk/lib/Sema/SemaExprCXX.cpp
  cfe/trunk/lib/Sema/SemaInit.cpp
  cfe/trunk/test/CXX/expr/expr.unary/expr.new/p17.cpp
  cfe/trunk/test/CodeGenCXX/no_destroy.cpp
  cfe/trunk/test/SemaCXX/no_destroy.cpp

Index: cfe/trunk/include/clang/Basic/AttrDocs.td
===
--- cfe/trunk/include/clang/Basic/AttrDocs.td
+++ cfe/trunk/include/clang/Basic/AttrDocs.td
@@ -3880,6 +3880,39 @@
 storage duration shouldn't have its exit-time destructor run. Annotating every
 static and thread duration variable with this attribute is equivalent to
 invoking clang with -fno-c++-static-destructors.
+
+If a variable is declared with this attribute, clang doesn't access check or
+generate the type's destructor. If you have a type that you only want to be
+annotated with ``no_destroy``, you can therefore declare the destructor private:
+
+.. code-block:: c++
+
+  struct only_no_destroy {
+only_no_destroy();
+  private:
+~only_no_destroy();
+  };
+
+  [[clang::no_destroy]] only_no_destroy global; // fine!
+
+Note that destructors are still required for subobjects of aggregates annotated
+with this attribute. This is because previously constructed subobjects need to
+be destroyed if an exception gets thrown before the initialization of the
+complete object is complete. For instance:
+
+.. code-block::c++
+
+  void f() {
+try {
+  [[clang::no_destroy]]
+  static only_no_destroy array[10]; // error, only_no_destroy has a private destructor.
+} catch (...) {
+  // Handle the error
+}
+  }
+
+Here, if the construction of `array[9]` fails with an exception, `array[0..8]`
+will be destroyed, so the element's destructor needs to be accessible.
   }];
 }
 
Index: cfe/trunk/test/CXX/expr/expr.unary/expr.new/p17.cpp
===
--- cfe/trunk/test/CXX/expr/expr.unary/expr.new/p17.cpp
+++ cfe/trunk/test/CXX/expr/expr.unary/expr.new/p17.cpp
@@ -10,7 +10,7 @@
 
 void test() {
   new ctor[0]; // expected-error{{calling a private constructor of class 'ctor'}}
-  new dtor[0]; // expected-error{{calling a private destructor of class 'dtor'}}
-  new dtor[3]; // expected-error{{calling a private destructor of class 'dtor'}}
-  new dtor[3][3]; // expected-error{{calling a private destructor of class 'dtor'}}
+  new dtor[0]; // expected-error{{temporary of type 'dtor' has private destructor}}
+  new dtor[3]; // expected-error{{temporary of type 'dtor' has private destructor}}
+  new dtor[3][3]; // expected-error{{temporary of type 'dtor' has private destructor}}
 }
Index: cfe/trunk/test/CodeGenCXX/no_destroy.cpp
===
--- cfe/trunk/test/CodeGenCXX/no_destroy.cpp
+++ cfe/trunk/test/CodeGenCXX/no_destroy.cpp
@@ -1,11 +1,14 @@
-// RUN: %clang_cc1 %s -emit-llvm -triple x86_64-apple-macosx10.13.0 -o - | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -triple x86_64-apple-macosx10.13.0 -o - | FileCheck %s --check-prefixes=CHECK,NO_EXCEPTIONS
+// RUN: %clang_cc1 -fexceptions %s -emit-llvm -triple x86_64-apple-macosx10.13.0 -o - | FileCheck %s --check-prefixes=CHECK,EXCEPTIONS
 
 struct NonTrivial {
   ~NonTrivial();
 };
 
+// CHECK-LABEL: define internal void @__cxx_global_var_init
 // CHECK-NOT: __cxa_atexit{{.*}}_ZN10NonTrivialD1Ev
 [[clang::no_destroy]] NonTrivial nt1;
+// CHECK-LABEL: define internal void @__cxx_global_var_init
 // CHECK-NOT: _tlv_atexit{{.*}}_ZN10NonTrivialD1Ev
 [[clang::no_destroy]] thread_local NonTrivial nt2;
 
@@ -13,11 +16,14 @@
   ~NonTrivial2();
 };
 
+// CHECK-LABEL: define internal void @__cxx_global_var_init
 // CHECK: __cxa_atexit{{.*}}_ZN11NonTrivial2D1Ev
 NonTrivial2 nt21;
+// CHECK-LABEL: define internal void @__cxx_global_var_init
 // CHECK: _tlv_atexit{{.*}}_ZN11NonTrivial2D1Ev
 thread_local NonTrivial2 nt22;
 
+// CHECK-LABEL: define void @_Z1fv
 void f() {
   // CHECK: __cxa_atexit{{.*}}_ZN11NonTrivial2D1Ev
   static NonTrivial2 nt21;
@@ -25,7 +31,51 @@
   thread_local NonTrivial2 nt22;
 }
 
+// CHECK-LABEL: define void @_Z1gv
+void g() {
+  // CHECK-NOT: __cxa_atexit
+  [[clang::no_destroy]] static NonTrivial2 nt21;
+  // CHECK-NOT: _tlv_atexit
+  [[clang::no_destroy]] thread_local NonTrivial2 nt22;
+}
+
+// CHECK-LABEL: define internal void @__cxx_global_var_init
 // CHECK: __cxa_atexit{{.*}}_ZN10NonTrivialD1Ev
 [[clang::always_destroy]] NonTrivial 

r360446 - [Sema] Mark array element destructors referenced during initialization

2019-05-10 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Fri May 10 10:52:26 2019
New Revision: 360446

URL: http://llvm.org/viewvc/llvm-project?rev=360446=rev
Log:
[Sema] Mark array element destructors referenced during initialization

This fixes a crash where we would neglect to mark a destructor referenced for an
__attribute__((no_destory)) array. The destructor is needed though, since if an
exception is thrown we need to cleanup the elements.

rdar://48462498

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

Modified:
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/test/CXX/expr/expr.unary/expr.new/p17.cpp
cfe/trunk/test/CodeGenCXX/no_destroy.cpp
cfe/trunk/test/SemaCXX/no_destroy.cpp

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=360446=360445=360446=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Fri May 10 10:52:26 2019
@@ -3880,6 +3880,39 @@ The ``no_destroy`` attribute specifies t
 storage duration shouldn't have its exit-time destructor run. Annotating every
 static and thread duration variable with this attribute is equivalent to
 invoking clang with -fno-c++-static-destructors.
+
+If a variable is declared with this attribute, clang doesn't access check or
+generate the type's destructor. If you have a type that you only want to be
+annotated with ``no_destroy``, you can therefore declare the destructor 
private:
+
+.. code-block:: c++
+
+  struct only_no_destroy {
+only_no_destroy();
+  private:
+~only_no_destroy();
+  };
+
+  [[clang::no_destroy]] only_no_destroy global; // fine!
+
+Note that destructors are still required for subobjects of aggregates annotated
+with this attribute. This is because previously constructed subobjects need to
+be destroyed if an exception gets thrown before the initialization of the
+complete object is complete. For instance:
+
+.. code-block::c++
+
+  void f() {
+try {
+  [[clang::no_destroy]]
+  static only_no_destroy array[10]; // error, only_no_destroy has a 
private destructor.
+} catch (...) {
+  // Handle the error
+}
+  }
+
+Here, if the construction of `array[9]` fails with an exception, `array[0..8]`
+will be destroyed, so the element's destructor needs to be accessible.
   }];
 }
 

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=360446=360445=360446=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Fri May 10 10:52:26 2019
@@ -13098,12 +13098,17 @@ void Sema::FinalizeVarWithDestructor(Var
 return;
 
   CXXDestructorDecl *Destructor = LookupDestructor(ClassDecl);
-  MarkFunctionReferenced(VD->getLocation(), Destructor);
-  CheckDestructorAccess(VD->getLocation(), Destructor,
-PDiag(diag::err_access_dtor_var)
-<< VD->getDeclName()
-<< VD->getType());
-  DiagnoseUseOfDecl(Destructor, VD->getLocation());
+
+  // If this is an array, we'll require the destructor during initialization, 
so
+  // we can skip over this. We still want to emit exit-time destructor warnings
+  // though.
+  if (!VD->getType()->isArrayType()) {
+MarkFunctionReferenced(VD->getLocation(), Destructor);
+CheckDestructorAccess(VD->getLocation(), Destructor,
+  PDiag(diag::err_access_dtor_var)
+  << VD->getDeclName() << VD->getType());
+DiagnoseUseOfDecl(Destructor, VD->getLocation());
+  }
 
   if (Destructor->isTrivial()) return;
   if (!VD->hasGlobalStorage()) return;

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=360446=360445=360446=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Fri May 10 10:52:26 2019
@@ -2200,24 +2200,6 @@ Sema::BuildCXXNew(SourceRange Range, boo
 MarkFunctionReferenced(StartLoc, OperatorDelete);
   }
 
-  // C++0x [expr.new]p17:
-  //   If the new expression creates an array of objects of class type,
-  //   access and ambiguity control are done for the destructor.
-  QualType BaseAllocType = Context.getBaseElementType(AllocType);
-  if (ArraySize && !BaseAllocType->isDependentType()) {
-if (const RecordType *BaseRecordType = BaseAllocType->getAs()) 
{
-  if (CXXDestructorDecl *dtor = LookupDestructor(
-  cast(BaseRecordType->getDecl( {
-MarkFunctionReferenced(StartLoc, dtor);
-CheckDestructorAccess(StartLoc, dtor,
-  

[PATCH] D61788: Make getObjCEncodingForTypeImpl() take a bitmask instead of 8 bools

2019-05-10 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/include/clang/AST/ASTContext.h:2877
+OCET_EncodePointerToObjCTypedef = 1 << 7,
+  };
+  void getObjCEncodingForTypeImpl(QualType t, std::string , unsigned Options,

I like the idea of doing this, but can you add some boilerplate? :)  I think 
it'd be better if this were a struct with some nice accessors, factories, 
transformations, and so on.

This example isn't from Clang, but something like this (without the templating, 
of course): 
https://github.com/apple/swift/blob/14a20eea03e9115e2c5cf91bccc86e6cd5334df9/include/swift/ABI/MetadataValues.h#L118


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

https://reviews.llvm.org/D61788



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


[PATCH] D60974: Clang IFSO driver action.

2019-05-10 Thread Jake Ehrlich via Phabricator via cfe-commits
jakehehrlich added a comment.

This shouldn't emit the .tbe format at all, the .tbe format is meant to be in 
near 1-1 correspondence with .so files, not with .o files. It has things like 
DT_NEEDED, and DT_SONAME related information that don't make sense for .o files 
for instance.

If we put things under an --experimental flags, minimize what we add in the 
first patch, and try and make each additional field added need based, I'm ok 
with whatever being added to Clang assuming it doesn't interfere with other 
parts of the compiler.




Comment at: llvm/include/llvm/TextAPI/ELF/ELFStub.h:58
   ELFArch Arch;
+  Optional Endian;
   std::vector NeededLibs;

Why do we need or want this? If it is needed can it be added later when needed? 
Also why is this a string?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60974



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


[PATCH] D60974: Clang IFSO driver action.

2019-05-10 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi added a comment.

@jakehehrlich What else are you looking for here? Can the patch for merging tbe 
files come later? @compnerd @rupprecht thoughts? I think this is a reasonable 
compromise: a minimal subset of what the yaml2obj and llvm-elfabi (with the 
addition of the Endian field) tools can already consume.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60974



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


LLVM buildmaster will be updated and restarted tonight

2019-05-10 Thread Galina Kistanova via cfe-commits
 Hello everyone,

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

Thanks

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


[PATCH] D51329: [Attribute/Diagnostics] Print macro if definition is an attribute declaration

2019-05-10 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki added a comment.

This caused https://bugs.llvm.org/show_bug.cgi?id=41835


Repository:
  rC Clang

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

https://reviews.llvm.org/D51329



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


[PATCH] D61700: [clang-tidy] readability-redundant-declaration: fix false positive with C "extern inline"

2019-05-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM with some testing nits.




Comment at: 
clang-tools-extra/test/clang-tidy/readability-redundant-declaration.c:32
+extern inline void g();
\ No newline at end of file


Please add a newline.



Comment at: 
clang-tools-extra/test/clang-tidy/readability-redundant-declaration.cpp:81
+// CHECK-FIXES: {{^}}// extern g{{$}}
\ No newline at end of file


Please add a newline.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61700



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


[PATCH] D56160: [clang-tidy] modernize-use-trailing-return-type check

2019-05-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

In D56160#1497473 , @bernhardmgruber 
wrote:

> - fixed formatting
> - fixed function names in tests
> - added `-fexceptions` to test arguments
> - fixed typo in release notes


Thanks! I committed in r360438.


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

https://reviews.llvm.org/D56160



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


[clang-tools-extra] r360438 - Recommit r360345 with fixes (was reverted in r360348).

2019-05-10 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Fri May 10 09:24:28 2019
New Revision: 360438

URL: http://llvm.org/viewvc/llvm-project?rev=360438=rev
Log:
Recommit r360345 with fixes (was reverted in r360348).

Add the modernize-use-trailing-return check to rewrite function signatures to 
use trailing return types.

Patch by Bernhard Manfred Gruber.

Added:
clang-tools-extra/trunk/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/UseTrailingReturnTypeCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-trailing-return-type.rst

clang-tools-extra/trunk/test/clang-tidy/modernize-use-trailing-return-type.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt?rev=360438=360437=360438=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt Fri May 10 
09:24:28 2019
@@ -30,6 +30,7 @@ add_clang_library(clangTidyModernizeModu
   UseNoexceptCheck.cpp
   UseNullptrCheck.cpp
   UseOverrideCheck.cpp
+  UseTrailingReturnTypeCheck.cpp
   UseTransparentFunctorsCheck.cpp
   UseUncaughtExceptionsCheck.cpp
   UseUsingCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp?rev=360438=360437=360438=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp Fri 
May 10 09:24:28 2019
@@ -35,6 +35,7 @@
 #include "UseNoexceptCheck.h"
 #include "UseNullptrCheck.h"
 #include "UseOverrideCheck.h"
+#include "UseTrailingReturnTypeCheck.h"
 #include "UseTransparentFunctorsCheck.h"
 #include "UseUncaughtExceptionsCheck.h"
 #include "UseUsingCheck.h"
@@ -87,6 +88,8 @@ public:
 CheckFactories.registerCheck("modernize-use-noexcept");
 CheckFactories.registerCheck("modernize-use-nullptr");
 CheckFactories.registerCheck("modernize-use-override");
+CheckFactories.registerCheck(
+"modernize-use-trailing-return-type");
 CheckFactories.registerCheck(
 "modernize-use-transparent-functors");
 CheckFactories.registerCheck(

Added: 
clang-tools-extra/trunk/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp?rev=360438=auto
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp 
(added)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp 
Fri May 10 09:24:28 2019
@@ -0,0 +1,478 @@
+//===--- UseTrailingReturnTypeCheck.cpp - 
clang-tidy---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "UseTrailingReturnTypeCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Tooling/FixIt.h"
+
+#include 
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+namespace {
+struct UnqualNameVisitor : public RecursiveASTVisitor {
+public:
+  UnqualNameVisitor(const FunctionDecl , const SourceManager )
+  : F(F), SM(SM) {}
+
+  bool Collision = false;
+
+  bool shouldWalkTypesOfTypeLocs() const { return false; }
+
+  bool VisitUnqualName(StringRef UnqualName) {
+// Check for collisions with function arguments.
+for (ParmVarDecl *Param : F.parameters())
+  if (const IdentifierInfo *Ident = Param->getIdentifier())
+if (Ident->getName() == UnqualName) {
+  Collision = true;
+  return true;
+}
+return false;
+  }
+
+  bool TraverseTypeLoc(TypeLoc TL, bool Elaborated = false) {
+if (TL.isNull())
+  return true;
+
+if (!Elaborated) {
+  switch (TL.getTypeLocClass()) {
+  case TypeLoc::Record:
+if (VisitUnqualName(
+TL.getAs().getTypePtr()->getDecl()->getName()))
+  return false;
+break;
+  case TypeLoc::Enum:
+if (VisitUnqualName(
+

[PATCH] D61790: [C++20] add consteval specifier

2019-05-10 Thread Tyker via Phabricator via cfe-commits
Tyker created this revision.
Tyker added a reviewer: rsmith.
Herald added a reviewer: martong.
Herald added a reviewer: shafik.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

this revision adds the consteval specifier as specified by 
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1073r3.html

Changes:

- add the consteval keyword.
- add parsing of consteval specifier for normal declarations and lambdas 
expressions.
- add the a bit to FunctionDeclBits for consteval.
- adapt creation of FunctionDecl and some classes inheriting from it to take an 
extra bool for consteval.
- change most calls to FunctionDecl::isConstexpr into call to 
FunctionDecl::isConstexprOrConsteval.
- add semantic checking to prevent call to consteval function that cannot be 
constant evaluated.
- add semantic checking to prevent taking address from consteval function.
- add semantic checking to prevent consteval specified allocation function.
- add tests for semantic.

The code-gen has not yet been adapted, but it will need to be change to not 
emit consteval function and ensure calls to consteval function are folded 
correctly.


Repository:
  rC Clang

https://reviews.llvm.org/D61790

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Sema/DeclSpec.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/DeclPrinter.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/Analysis/ReachableCode.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Parse/ParseTentative.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaCoroutine.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/SemaCXX/cxx2a-compat.cpp
  clang/test/SemaCXX/cxx2a-consteval.cpp

Index: clang/test/SemaCXX/cxx2a-consteval.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx2a-consteval.cpp
@@ -0,0 +1,224 @@
+// RUN: %clang_cc1 -std=c++2a -fsyntax-only %s -verify
+
+int i_global; // expected-note+ {{declared here}}
+extern int i_extern; // expected-note+ {{declared here}}
+const int i_const = 0;
+constexpr int i_constexpr = 0;
+
+consteval int f_eval(int i) {
+// expected-note@-1+ {{consteval function declared here}}
+  return i;
+}
+
+constexpr auto l_eval = [](int i) consteval {
+// expected-note@-1+ {{consteval operator declared here}}
+  return i;
+};
+
+constexpr int f_expr(int i) {
+  return i;
+}
+
+struct A {
+  consteval int f_eval(int i) const {
+// expected-note@-1+ {{consteval function declared here}}
+return i;
+  }
+};
+
+constexpr A a;
+
+namespace invalid_call_args {
+
+int d0 = f_eval(0);
+int l0 = l_eval(0);
+int m0 = a.f_eval(0);
+int d2 = f_eval(i_extern);
+// expected-error@-1 {{call to consteval function cannot be constant evaluated}}
+// expected-note@-2 {{argument 0 cannot be constant evaluated}}
+// expected-note@-3 {{not allowed in a constant expression}}
+int l2 = l_eval(i_extern);
+// expected-error@-1 {{call to consteval operator cannot be constant evaluated}}
+// expected-note@-2 {{argument 0 cannot be constant evaluated}}
+// expected-note@-3 {{not allowed in a constant expression}}
+int m2 = a.f_eval(i_extern);
+// expected-error@-1 {{call to consteval function cannot be constant evaluated}}
+// expected-note@-2 {{argument 0 cannot be constant evaluated}}
+// expected-note@-3 {{not allowed in a constant expression}}
+int d4 = f_eval(i_const);
+int l4 = l_eval(i_const);
+int m4 = a.f_eval(i_const);
+int d6 = f_eval(i_constexpr);
+int l6 = l_eval(i_constexpr);
+int m6 = a.f_eval(i_constexpr);
+int d8 = f_eval(i_global);
+// expected-error@-1 {{call to consteval function cannot be constant evaluated}}
+// expected-note@-2 {{argument 0 cannot be constant evaluated}}
+// expected-note@-3 {{not allowed in a constant expression}}
+int l8 = l_eval(i_global);
+// expected-error@-1 {{call to consteval operator cannot be constant evaluated}}
+// expected-note@-2 {{argument 0 cannot be constant evaluated}}
+// expected-note@-3 {{not allowed in a constant expression}}
+int m8 = a.f_eval(i_global);
+// expected-error@-1 {{call to consteval function cannot be constant evaluated}}
+// expected-note@-2 {{argument 0 cannot be constant evaluated}}
+// expected-note@-3 {{not allowed in a constant expression}}
+

[PATCH] D61627: [clang driver] Allow -fembed-bitcode combined with -mno-red-zone

2019-05-10 Thread Steven Wu via Phabricator via cfe-commits
steven_wu added a comment.

In D61627#1497919 , @wanders wrote:

> > Why are you interested in expending this list?
>
> I have a (kernel) that is compiled with `-mno-red-zone` and `-mcmodel=large` 
> which I want to compile with `-fembed-bitcode` for a debugging tool that 
> needs the bitcode.
>
> But I can carry these patches locally for now.


I think the best option for this situation might be just make this blacklist to 
be darwin toolchain specific.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61627



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


[PATCH] D61788: Make getObjCEncodingForTypeImpl() take a bitmask instead of 8 bools

2019-05-10 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added a reviewer: rjmccall.

Slightly less code, uses slightly less stack space, and makes it
impossible to mix up the order of all those bools.

No behavior change.


https://reviews.llvm.org/D61788

Files:
  clang/include/clang/AST/ASTContext.h
  clang/lib/AST/ASTContext.cpp

Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -6303,13 +6303,11 @@
   // Encode type qualifer, 'in', 'inout', etc. for the parameter.
   getObjCEncodingForTypeQualifier(QT, S);
   // Encode parameter type.
-  getObjCEncodingForTypeImpl(T, S, /*ExpandPointedToStructures=*/true,
- /*ExpandStructures=*/true, /*Field=*/nullptr,
- /*OutermostType=*/true,
- /*EncodingProperty=*/false,
- /*StructField=*/false,
- /*EncodeBlockParameters=*/Extended,
- /*EncodeClassNames=*/Extended);
+  unsigned Options = OCET_ExpandPointedToStructures | OCET_ExpandStructures |
+ OCET_IsOutermostType;
+  if (Extended)
+Options |= OCET_EncodeBlockParameters | OCET_EncodeClassNames;
+  getObjCEncodingForTypeImpl(T, S, Options, /*Field=*/nullptr);
 }
 
 /// getObjCEncodingForMethodDecl - Return the encoded type for this method
@@ -6501,13 +6499,10 @@
   // directly pointed to, and expanding embedded structures. Note that
   // these rules are sufficient to prevent recursive encoding of the
   // same type.
-  getObjCEncodingForTypeImpl(T, S, /*ExpandPointedToStructures=*/true,
- /*ExpandStructures=*/true, Field,
- /*OutermostType=*/true, /*EncodingProperty=*/false,
- /*StructField=*/false,
- /*EncodeBlockParameters=*/false,
- /*EncodeClassNames=*/false,
- /*EncodePointerToObjCTypedef=*/false, NotEncodedT);
+  getObjCEncodingForTypeImpl(T, S,
+ OCET_ExpandPointedToStructures |
+ OCET_ExpandStructures | OCET_IsOutermostType,
+ Field, NotEncodedT);
 }
 
 void ASTContext::getObjCEncodingForPropertyType(QualType T,
@@ -6515,9 +6510,11 @@
   // Encode result type.
   // GCC has some special rules regarding encoding of properties which
   // closely resembles encoding of ivars.
-  getObjCEncodingForTypeImpl(
-  T, S, /*ExpandPointedToStructures=*/true, /*ExpandStructures=*/true,
-  /*Field=*/nullptr, /*OutermostType=*/true, /*EncodingProperty=*/true);
+  getObjCEncodingForTypeImpl(T, S,
+ OCET_ExpandPointedToStructures |
+ OCET_ExpandStructures |
+ OCET_IsOutermostType | OCET_EncodingProperty,
+ /*Field=*/nullptr);
 }
 
 static char getObjCEncodingForPrimitiveKind(const ASTContext *C,
@@ -6664,16 +6661,9 @@
 }
 
 // FIXME: Use SmallString for accumulating string.
-void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
-bool ExpandPointedToStructures,
-bool ExpandStructures,
+void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string ,
+unsigned Options,
 const FieldDecl *FD,
-bool OutermostType,
-bool EncodingProperty,
-bool StructField,
-bool EncodeBlockParameters,
-bool EncodeClassNames,
-bool EncodePointerToObjCTypedef,
 QualType *NotEncodedT) const {
   CanQualType CT = getCanonicalType(T);
   switch (CT->getTypeClass()) {
@@ -6690,18 +6680,14 @@
   case Type::Complex: {
 const auto *CT = T->castAs();
 S += 'j';
-getObjCEncodingForTypeImpl(CT->getElementType(), S,
-   /*ExpandPointedToStructures=*/false,
-   /*ExpandStructures=*/false, /*Field=*/nullptr);
+getObjCEncodingForTypeImpl(CT->getElementType(), S, 0, /*Field=*/nullptr);
 return;
   }
 
   case Type::Atomic: {
 const auto *AT = T->castAs();
 S += 'A';
-getObjCEncodingForTypeImpl(AT->getValueType(), S,
-   /*ExpandPointedToStructures=*/false,
-   /*ExpandStructures=*/false, /*Field=*/nullptr);
+getObjCEncodingForTypeImpl(AT->getValueType(), S, 0, /*Field=*/nullptr);
 return;
   }
 
@@ -6727,11 +6713,11 @@
 // the pointer itself 

[PATCH] D28462: clang-format: Add new style option AlignConsecutiveMacros

2019-05-10 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.
This revision is now accepted and ready to land.

@klimek  responded via the mailing list

http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20190506/270976.html


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

https://reviews.llvm.org/D28462



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


[PATCH] D61786: [ASTImporter] Separate unittest files

2019-05-10 Thread Gabor Marton via Phabricator via cfe-commits
martong created this revision.
martong added a reviewer: a_sidorin.
Herald added subscribers: cfe-commits, gamesh411, Szelethus, dkrupp, rnkovacs, 
mgorny.
Herald added a reviewer: a.sidorin.
Herald added a reviewer: shafik.
Herald added a project: clang.

Move generic redecl chain tests and visibility tests into their own
separate test files.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D61786

Files:
  clang/unittests/AST/ASTImporterFixtures.cpp
  clang/unittests/AST/ASTImporterFixtures.h
  clang/unittests/AST/ASTImporterGenericRedeclTest.cpp
  clang/unittests/AST/ASTImporterTest.cpp
  clang/unittests/AST/ASTImporterVisibilityTest.cpp
  clang/unittests/AST/CMakeLists.txt

Index: clang/unittests/AST/CMakeLists.txt
===
--- clang/unittests/AST/CMakeLists.txt
+++ clang/unittests/AST/CMakeLists.txt
@@ -8,7 +8,10 @@
 
 add_clang_unittest(ASTTests
   ASTContextParentMapTest.cpp
+  ASTImporterFixtures.cpp
   ASTImporterTest.cpp
+  ASTImporterGenericRedeclTest.cpp
+  ASTImporterVisibilityTest.cpp
   ASTTypeTraitsTest.cpp
   ASTVectorTest.cpp
   CommentLexer.cpp
Index: clang/unittests/AST/ASTImporterVisibilityTest.cpp
===
--- /dev/null
+++ clang/unittests/AST/ASTImporterVisibilityTest.cpp
@@ -0,0 +1,221 @@
+//===- unittest/AST/ASTImporterTest.cpp - AST node import test ===//
+//
+// 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
+//
+//===--===//
+//
+// Type-parameterized tests for the correct import of Decls with different
+// visibility.
+//
+//===--===//
+
+// Define this to have ::testing::Combine available.
+// FIXME: Better solution for this?
+#define GTEST_HAS_COMBINE 1
+
+#include "ASTImporterFixtures.h"
+
+namespace clang {
+namespace ast_matchers {
+
+using internal::BindableMatcher;
+
+// Type parameters for type-parameterized test fixtures.
+struct GetFunPattern {
+  using DeclTy = FunctionDecl;
+  BindableMatcher operator()() { return functionDecl(hasName("f")); }
+};
+struct GetVarPattern {
+  using DeclTy = VarDecl;
+  BindableMatcher operator()() { return varDecl(hasName("v")); }
+};
+
+// Values for the value-parameterized test fixtures.
+// FunctionDecl:
+auto *ExternF = "void f();";
+auto *StaticF = "static void f();";
+auto *AnonF = "namespace { void f(); }";
+// VarDecl:
+auto *ExternV = "extern int v;";
+auto *StaticV = "static int v;";
+auto *AnonV = "namespace { extern int v; }";
+
+// First value in tuple: Compile options.
+// Second value in tuple: Source code to be used in the test.
+using ImportVisibilityChainParams =
+::testing::WithParamInterface>;
+// Fixture to test the redecl chain of Decls with the same visibility.  Gtest
+// makes it possible to have either value-parameterized or type-parameterized
+// fixtures.  However, we cannot have both value- and type-parameterized test
+// fixtures.  This is a value-parameterized test fixture in the gtest sense. We
+// intend to mimic gtest's type-parameters via the PatternFactory template
+// parameter.  We manually instantiate the different tests with the each types.
+template 
+class ImportVisibilityChain
+: public ASTImporterTestBase, public ImportVisibilityChainParams {
+protected:
+  using DeclTy = typename PatternFactory::DeclTy;
+  ArgVector getExtraArgs() const override { return std::get<0>(GetParam()); }
+  std::string getCode() const { return std::get<1>(GetParam()); }
+  BindableMatcher getPattern() const { return PatternFactory()(); }
+
+  // Type-parameterized test.
+  void TypedTest_ImportChain() {
+std::string Code = getCode() + getCode();
+auto Pattern = getPattern();
+
+TranslationUnitDecl *FromTu = getTuDecl(Code, Lang_CXX, "input0.cc");
+
+auto *FromF0 = FirstDeclMatcher().match(FromTu, Pattern);
+auto *FromF1 = LastDeclMatcher().match(FromTu, Pattern);
+
+auto *ToF0 = Import(FromF0, Lang_CXX);
+auto *ToF1 = Import(FromF1, Lang_CXX);
+
+EXPECT_TRUE(ToF0);
+ASSERT_TRUE(ToF1);
+EXPECT_NE(ToF0, ToF1);
+EXPECT_EQ(ToF1->getPreviousDecl(), ToF0);
+  }
+};
+
+// Manual instantiation of the fixture with each type.
+using ImportFunctionsVisibilityChain = ImportVisibilityChain;
+using ImportVariablesVisibilityChain = ImportVisibilityChain;
+// Value-parameterized test for the first type.
+TEST_P(ImportFunctionsVisibilityChain, ImportChain) {
+  TypedTest_ImportChain();
+}
+// Value-parameterized test for the second type.
+TEST_P(ImportVariablesVisibilityChain, ImportChain) {
+  TypedTest_ImportChain();
+}
+
+// Automatic instantiation of the value-parameterized tests.
+INSTANTIATE_TEST_CASE_P(ParameterizedTests, 

[PATCH] D61742: [Driver][Windows] Add dependent lib argument for profile instr generate

2019-05-10 Thread Russell Gallop via Phabricator via cfe-commits
russell.gallop added a comment.

In D61742#1497259 , @rnk wrote:

> Thanks, I would like to do this for the sanitizers as well, since this is a 
> constant pain point for users


That would be good. I think that this might already work for UBSan.


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

https://reviews.llvm.org/D61742



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


[PATCH] D61742: [Driver][Windows] Add dependent lib argument for profile instr generate

2019-05-10 Thread Russell Gallop via Phabricator via cfe-commits
russell.gallop updated this revision to Diff 199016.
russell.gallop added a comment.
Herald added a subscriber: mstorsjo.

Prevent adding -dependent-lib on mingw32 and add tests.


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

https://reviews.llvm.org/D61742

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/cl-options.c
  clang/test/Driver/instrprof-ld.c


Index: clang/test/Driver/instrprof-ld.c
===
--- clang/test/Driver/instrprof-ld.c
+++ clang/test/Driver/instrprof-ld.c
@@ -129,3 +129,17 @@
 //
 // CHECK-MINGW-X86-64: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
 // CHECK-MINGW-X86-64: 
"{{.*}}/Inputs/resource_dir{{/|}}lib{{/|}}windows{{/|}}libclang_rt.profile-x86_64.a"
+
+// Test instrumented profiling dependent-lib flags
+//
+// RUN: %clang %s -### -o %t.o -target x86_64-pc-win32 \
+// RUN: -fprofile-instr-generate 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-WINDOWS-X86-64-DEPENDENT-LIB %s
+//
+// CHECK-WINDOWS-X86-64-DEPENDENT-LIB: 
"--dependent-lib={{[^"]*}}clang_rt.profile-{{[^"]*}}.lib"
+//
+// RUN: %clang %s -### -o %t.o -target x86_64-mingw32 \
+// RUN: -fprofile-instr-generate 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MINGW-X86-64-DEPENDENT-LIB %s
+//
+// CHECK-MINGW-X86-64-DEPENDENT-LIB-NOT: 
"--dependent-lib={{[^"]*}}clang_rt.profile-{{[^"]*}}.a"
Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -66,7 +66,7 @@
 // RUN: %clang_cl -### /FA -fprofile-instr-generate=/tmp/somefile.profraw -- 
%s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE-FILE %s
 // RUN: %clang_cl -### /FA -fprofile-instr-generate -fprofile-instr-use -- %s 
2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s
 // RUN: %clang_cl -### /FA -fprofile-instr-generate -fprofile-instr-use=file 
-- %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s
-// CHECK-PROFILE-GENERATE: "-fprofile-instrument=clang"
+// CHECK-PROFILE-GENERATE: "-fprofile-instrument=clang" 
"--dependent-lib={{[^"]*}}clang_rt.profile-{{[^"]*}}.lib"
 // CHECK-PROFILE-GENERATE-FILE: 
"-fprofile-instrument-path=/tmp/somefile.profraw"
 // CHECK-NO-MIX-GEN-USE: '{{[a-z=-]*}}' not allowed with '{{[a-z=-]*}}'
 
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -731,8 +731,9 @@
   Result.append(UID.begin(), UID.end());
 }
 
-static void addPGOAndCoverageFlags(Compilation , const Driver ,
-   const InputInfo , const ArgList 
,
+static void addPGOAndCoverageFlags(const ToolChain , Compilation ,
+   const Driver , const InputInfo ,
+   const ArgList ,
ArgStringList ) {
 
   auto *PGOGenerateArg = Args.getLastArg(options::OPT_fprofile_generate,
@@ -783,6 +784,11 @@
ProfileGenerateArg->getValue()));
 // The default is to use Clang Instrumentation.
 CmdArgs.push_back("-fprofile-instrument=clang");
+if (TC.getTriple().isWindowsMSVCEnvironment()) {
+  // Add dependent lib for clang_rt.profile
+  CmdArgs.push_back(Args.MakeArgString("--dependent-lib=" +
+   TC.getCompilerRT(Args, "profile")));
+}
   }
 
   Arg *PGOGenArg = nullptr;
@@ -4176,7 +4182,7 @@
   // sampling, overhead of call arc collection is way too high and there's no
   // way to collect the output.
   if (!Triple.isNVPTX())
-addPGOAndCoverageFlags(C, D, Output, Args, CmdArgs);
+addPGOAndCoverageFlags(TC, C, D, Output, Args, CmdArgs);
 
   if (auto *ABICompatArg = Args.getLastArg(options::OPT_fclang_abi_compat_EQ))
 ABICompatArg->render(Args, CmdArgs);


Index: clang/test/Driver/instrprof-ld.c
===
--- clang/test/Driver/instrprof-ld.c
+++ clang/test/Driver/instrprof-ld.c
@@ -129,3 +129,17 @@
 //
 // CHECK-MINGW-X86-64: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
 // CHECK-MINGW-X86-64: "{{.*}}/Inputs/resource_dir{{/|}}lib{{/|}}windows{{/|}}libclang_rt.profile-x86_64.a"
+
+// Test instrumented profiling dependent-lib flags
+//
+// RUN: %clang %s -### -o %t.o -target x86_64-pc-win32 \
+// RUN: -fprofile-instr-generate 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-WINDOWS-X86-64-DEPENDENT-LIB %s
+//
+// CHECK-WINDOWS-X86-64-DEPENDENT-LIB: "--dependent-lib={{[^"]*}}clang_rt.profile-{{[^"]*}}.lib"
+//
+// RUN: %clang %s -### -o %t.o -target x86_64-mingw32 \
+// RUN: -fprofile-instr-generate 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MINGW-X86-64-DEPENDENT-LIB %s
+//
+// CHECK-MINGW-X86-64-DEPENDENT-LIB-NOT: "--dependent-lib={{[^"]*}}clang_rt.profile-{{[^"]*}}.a"
Index: 

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

2019-05-10 Thread Nikolai Kosjar via Phabricator via cfe-commits
nik added a comment.

Sorry for the pointless ping, haven't seen the inline comments. They are 
addressed now.

I've also increased CINDEX_VERSION_MINOR so clients can detect availability of 
this new flag.

> It's been a while since I've looked at the ASTUnit code, though, would be 
> good if someone else took an extra look at it.

Benjamin? Argyrios? Would you be so kind? :)


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] D48116: [libclang] Allow skipping warnings from all included files

2019-05-10 Thread Nikolai Kosjar via Phabricator via cfe-commits
nik updated this revision to Diff 199015.
nik marked 2 inline comments as done.
nik added a comment.

Addressed inline comments.


Repository:
  rC Clang

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

https://reviews.llvm.org/D48116

Files:
  include/clang-c/Index.h
  include/clang/Frontend/ASTUnit.h
  lib/Frontend/ASTUnit.cpp
  test/Index/ignore-warnings-from-headers.cpp
  test/Index/ignore-warnings-from-headers.h
  tools/c-index-test/c-index-test.c
  tools/c-index-test/core_main.cpp
  tools/libclang/CIndex.cpp
  tools/libclang/Indexing.cpp
  unittests/Frontend/ASTUnitTest.cpp
  unittests/Frontend/PCHPreambleTest.cpp

Index: unittests/Frontend/PCHPreambleTest.cpp
===
--- unittests/Frontend/PCHPreambleTest.cpp
+++ unittests/Frontend/PCHPreambleTest.cpp
@@ -96,8 +96,8 @@
 FileManager *FileMgr = new FileManager(FSOpts, VFS);
 
 std::unique_ptr AST = ASTUnit::LoadFromCompilerInvocation(
-  CI, PCHContainerOpts, Diags, FileMgr, false, false,
-  /*PrecompilePreambleAfterNParses=*/1);
+CI, PCHContainerOpts, Diags, FileMgr, false, CaptureDiagsKind::None,
+/*PrecompilePreambleAfterNParses=*/1);
 return AST;
   }
 
Index: unittests/Frontend/ASTUnitTest.cpp
===
--- unittests/Frontend/ASTUnitTest.cpp
+++ unittests/Frontend/ASTUnitTest.cpp
@@ -51,8 +51,8 @@
 PCHContainerOps = std::make_shared();
 
 return ASTUnit::LoadFromCompilerInvocation(
-CInvok, PCHContainerOps, Diags, FileMgr, false, false, 0, TU_Complete,
-false, false, isVolatile);
+CInvok, PCHContainerOps, Diags, FileMgr, false, CaptureDiagsKind::None,
+0, TU_Complete, false, false, isVolatile);
   }
 };
 
Index: tools/libclang/Indexing.cpp
===
--- tools/libclang/Indexing.cpp
+++ tools/libclang/Indexing.cpp
@@ -443,10 +443,14 @@
   if (CXXIdx->isOptEnabled(CXGlobalOpt_ThreadBackgroundPriorityForIndexing))
 setThreadBackgroundPriority();
 
-  bool CaptureDiagnostics = !Logger::isLoggingEnabled();
+  CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::All;
+  if (TU_options & CXTranslationUnit_IgnoreNonErrorsFromIncludedFiles)
+CaptureDiagnostics = CaptureDiagsKind::AllWithoutNonErrorsFromIncludes;
+  if (Logger::isLoggingEnabled())
+CaptureDiagnostics = CaptureDiagsKind::None;
 
   CaptureDiagnosticConsumer *CaptureDiag = nullptr;
-  if (CaptureDiagnostics)
+  if (CaptureDiagnostics != CaptureDiagsKind::None)
 CaptureDiag = new CaptureDiagnosticConsumer();
 
   // Configure the diagnostics.
Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -3352,7 +3352,7 @@
   ASTUnit::LoadEverything, Diags,
   FileSystemOpts, /*UseDebugInfo=*/false,
   CXXIdx->getOnlyLocalDecls(), None,
-  /*CaptureDiagnostics=*/true,
+  CaptureDiagsKind::All,
   /*AllowPCHWithCompilerErrors=*/true,
   /*UserFilesAreVolatile=*/true);
   *out_TU = MakeCXTranslationUnit(CXXIdx, std::move(AU));
@@ -3425,6 +3425,10 @@
   if (options & CXTranslationUnit_KeepGoing)
 Diags->setFatalsAsError(true);
 
+  CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::All;
+  if (options & CXTranslationUnit_IgnoreNonErrorsFromIncludedFiles)
+CaptureDiagnostics = CaptureDiagsKind::AllWithoutNonErrorsFromIncludes;
+
   // Recover resources if we crash before exiting this function.
   llvm::CrashRecoveryContextCleanupRegistrar >
@@ -3502,7 +3506,7 @@
   Args->data(), Args->data() + Args->size(),
   CXXIdx->getPCHContainerOperations(), Diags,
   CXXIdx->getClangResourcesPath(), CXXIdx->getOnlyLocalDecls(),
-  /*CaptureDiagnostics=*/true, *RemappedFiles.get(),
+  CaptureDiagnostics, *RemappedFiles.get(),
   /*RemappedFilesKeepOriginalName=*/true, PrecompilePreambleAfterNParses,
   TUKind, CacheCodeCompletionResults, IncludeBriefCommentsInCodeCompletion,
   /*AllowPCHWithCompilerErrors=*/true, SkipFunctionBodies, SingleFileParse,
Index: tools/c-index-test/core_main.cpp
===
--- tools/c-index-test/core_main.cpp
+++ tools/c-index-test/core_main.cpp
@@ -264,7 +264,7 @@
   modulePath, *pchRdr, ASTUnit::LoadASTOnly, Diags,
   FileSystemOpts, /*UseDebugInfo=*/false,
   /*OnlyLocalDecls=*/true, None,
-  /*CaptureDiagnostics=*/false,
+  CaptureDiagsKind::None,
   /*AllowPCHWithCompilerErrors=*/true,
   /*UserFilesAreVolatile=*/false);
   if (!AU) {
Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -88,6 +88,8 @@
 options |= CXTranslationUnit_IncludeAttributedTypes;
   if 

  1   2   >