[PATCH] D69213: Avoid appending the source directory to an absolute path

2019-10-18 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl created this revision.
aprantl added reviewers: JDevlieghere, davide.
aprantl added a project: debug-info.

When building a precompiled header in `-fmodule-format=obj` (i.e., `-gmodules) 
in an absolute path, the locig in CGDebugInfo::createCompileUnit would 
unconditionally append the source directory to the -main-file-name. This patch 
avoids that behavior for absolute paths.

rdar://problem/46045865


https://reviews.llvm.org/D69213

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/PCH/debug-info-pch-container-path.c


Index: clang/test/PCH/debug-info-pch-container-path.c
===
--- /dev/null
+++ clang/test/PCH/debug-info-pch-container-path.c
@@ -0,0 +1,22 @@
+// REQUIRES: asserts
+
+// Modules:
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: cd %t
+
+// RUN: %clang_cc1 -fmodule-format=obj -emit-pch\
+// RUN: -triple %itanium_abi_triple \
+// RUN: -fdebug-prefix-map=%t=BUILD \
+// RUN: -fdebug-prefix-map=%S=SOURCE\
+// RUN: -o %t/prefix.ll %S/debug-info-limited-struct.h  \
+// RUN:   -mllvm -debug-only=pchcontainer &>%t-container.ll
+// RUN: cat %t-container.ll | FileCheck %s
+
+// CHECK: distinct !DICompileUnit(
+// CHECK-SAME:language: DW_LANG_C99,
+// CHECK-SAME:file: ![[FILE:[0-9]+]],
+// CHECK: ![[FILE]] = !DIFile(
+// CHECK-SAME:filename: "SOURCE/debug-info-limited-struct.h",
+// CHECK-SAME:directory: "BUILD"
+
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -537,8 +537,8 @@
   // file to determine the real absolute path for the file.
   std::string MainFileDir;
   if (const FileEntry *MainFile = SM.getFileEntryForID(SM.getMainFileID())) {
-MainFileDir = remapDIPath(MainFile->getDir()->getName());
-if (MainFileDir != ".") {
+MainFileDir = MainFile->getDir()->getName();
+if (MainFileDir != "." && !llvm::sys::path::is_absolute(MainFileName)) {
   llvm::SmallString<1024> MainFileDirSS(MainFileDir);
   llvm::sys::path::append(MainFileDirSS, MainFileName);
   MainFileName = MainFileDirSS.str();


Index: clang/test/PCH/debug-info-pch-container-path.c
===
--- /dev/null
+++ clang/test/PCH/debug-info-pch-container-path.c
@@ -0,0 +1,22 @@
+// REQUIRES: asserts
+
+// Modules:
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: cd %t
+
+// RUN: %clang_cc1 -fmodule-format=obj -emit-pch\
+// RUN: -triple %itanium_abi_triple \
+// RUN: -fdebug-prefix-map=%t=BUILD \
+// RUN: -fdebug-prefix-map=%S=SOURCE\
+// RUN: -o %t/prefix.ll %S/debug-info-limited-struct.h  \
+// RUN:   -mllvm -debug-only=pchcontainer &>%t-container.ll
+// RUN: cat %t-container.ll | FileCheck %s
+
+// CHECK: distinct !DICompileUnit(
+// CHECK-SAME:language: DW_LANG_C99,
+// CHECK-SAME:file: ![[FILE:[0-9]+]],
+// CHECK: ![[FILE]] = !DIFile(
+// CHECK-SAME:filename: "SOURCE/debug-info-limited-struct.h",
+// CHECK-SAME:directory: "BUILD"
+
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -537,8 +537,8 @@
   // file to determine the real absolute path for the file.
   std::string MainFileDir;
   if (const FileEntry *MainFile = SM.getFileEntryForID(SM.getMainFileID())) {
-MainFileDir = remapDIPath(MainFile->getDir()->getName());
-if (MainFileDir != ".") {
+MainFileDir = MainFile->getDir()->getName();
+if (MainFileDir != "." && !llvm::sys::path::is_absolute(MainFileName)) {
   llvm::SmallString<1024> MainFileDirSS(MainFileDir);
   llvm::sys::path::append(MainFileDirSS, MainFileName);
   MainFileName = MainFileDirSS.str();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68528: [Implicit Modules] Add -cc1 option -fmodules-strict-hash which includes search paths and diagnostics.

2019-10-18 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Looks like this fails on win: http://45.33.8.238/win/841/step_6.txt

Ptal!

Maybe just cat'ing all files instead of echoing the first and piping into cat 
works?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68528



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


[PATCH] D68591: [analyzer] PR43551: Do not dereferce void* in UndefOrNullArgVisitor

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

Decided to commit myself in order to hurry things up^^
Also rC375328 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68591



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


[PATCH] D68591: [analyzer] PR43551: Do not dereferce void* in UndefOrNullArgVisitor

2019-10-18 Thread Artem Dergachev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4a5df7312ec2: [analyzer] PR43551: Do not dereferce void* in 
UndefOrNullArgVisitor. (authored by dergachev.a).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68591

Files:
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  clang/test/Analysis/novoidtypecrash.c


Index: clang/test/Analysis/novoidtypecrash.c
===
--- clang/test/Analysis/novoidtypecrash.c
+++ clang/test/Analysis/novoidtypecrash.c
@@ -1,8 +1,27 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=core %s
+x;
+y(void **z) { // no-crash
+  *z = x;
+  int *w;
+  y(&w);
+  *w;
+}
+
 a;
-b(void **c) { // no-crash
-  *c = a;
-  int *d;
-  b(&d);
-  *d;
+b(*c) {}
+e(*c) {
+  void *d = f();
+  b(d);
+  *c = d;
+}
+void *g() {
+  e(&a);
+  return a;
+}
+j() {
+  int h;
+  char i = g();
+  if (i)
+for (; h;)
+  ;
 }
Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -2034,8 +2034,6 @@
 
   // Is it a symbolic value?
   if (auto L = V.getAs()) {
-report.addVisitor(std::make_unique(L->getRegion()));
-
 // FIXME: this is a hack for fixing a later crash when attempting to
 // dereference a void* pointer.
 // We should not try to dereference pointers at all when we don't care
@@ -2056,10 +2054,14 @@
 else if (CanDereference)
   RVal = LVState->getSVal(L->getRegion());
 
-if (CanDereference)
+if (CanDereference) {
+  report.addVisitor(
+  std::make_unique(L->getRegion()));
+
   if (auto KV = RVal.getAs())
 report.addVisitor(std::make_unique(
 *KV, L->getRegion(), EnableNullFPSuppression, TKind, SFC));
+}
 
 const MemRegion *RegionRVal = RVal.getAsRegion();
 if (RegionRVal && isa(RegionRVal)) {


Index: clang/test/Analysis/novoidtypecrash.c
===
--- clang/test/Analysis/novoidtypecrash.c
+++ clang/test/Analysis/novoidtypecrash.c
@@ -1,8 +1,27 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=core %s
+x;
+y(void **z) { // no-crash
+  *z = x;
+  int *w;
+  y(&w);
+  *w;
+}
+
 a;
-b(void **c) { // no-crash
-  *c = a;
-  int *d;
-  b(&d);
-  *d;
+b(*c) {}
+e(*c) {
+  void *d = f();
+  b(d);
+  *c = d;
+}
+void *g() {
+  e(&a);
+  return a;
+}
+j() {
+  int h;
+  char i = g();
+  if (i)
+for (; h;)
+  ;
 }
Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -2034,8 +2034,6 @@
 
   // Is it a symbolic value?
   if (auto L = V.getAs()) {
-report.addVisitor(std::make_unique(L->getRegion()));
-
 // FIXME: this is a hack for fixing a later crash when attempting to
 // dereference a void* pointer.
 // We should not try to dereference pointers at all when we don't care
@@ -2056,10 +2054,14 @@
 else if (CanDereference)
   RVal = LVState->getSVal(L->getRegion());
 
-if (CanDereference)
+if (CanDereference) {
+  report.addVisitor(
+  std::make_unique(L->getRegion()));
+
   if (auto KV = RVal.getAs())
 report.addVisitor(std::make_unique(
 *KV, L->getRegion(), EnableNullFPSuppression, TKind, SFC));
+}
 
 const MemRegion *RegionRVal = RVal.getAsRegion();
 if (RegionRVal && isa(RegionRVal)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D66043: Add to -Wparentheses case of bitwise-and ("&") and bitwise-or ("|") verses conditional operator ("?:")

2019-10-18 Thread Richard Trieu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG637af4cc3780: Add -Wbitwise-conditional-parentheses to warn 
on mixing '|' and '&' with "?:" (authored by 
rtrieu).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D66043?vs=219213&id=225732#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66043

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/parentheses.c

Index: clang/test/Sema/parentheses.c
===
--- clang/test/Sema/parentheses.c
+++ clang/test/Sema/parentheses.c
@@ -93,6 +93,28 @@
 
   (void)(x + y > 0 ? 1 : 2); // no warning
   (void)(x + (y > 0) ? 1 : 2); // expected-warning {{operator '?:' has lower precedence than '+'}} expected-note 2{{place parentheses}}
+
+  (void)(b ? 0xf0 : 0x10 | b ? 0x5 : 0x2); // expected-warning {{operator '?:' has lower precedence than '|'}} expected-note 2{{place parentheses}}
+
+  (void)((b ? 0xf0 : 0x10) | (b ? 0x5 : 0x2));  // no warning, has parentheses
+  (void)(b ? 0xf0 : (0x10 | b) ? 0x5 : 0x2);  // no warning, has parentheses
+
+  (void)(x | b ? 1 : 2); // expected-warning {{operator '?:' has lower precedence than '|'}} expected-note 2{{place parentheses}}
+  (void)(x & b ? 1 : 2); // expected-warning {{operator '?:' has lower precedence than '&'}} expected-note 2{{place parentheses}}
+
+  (void)((x | b) ? 1 : 2);  // no warning, has parentheses
+  (void)(x | (b ? 1 : 2));  // no warning, has parentheses
+  (void)((x & b) ? 1 : 2);  // no warning, has parentheses
+  (void)(x & (b ? 1 : 2));  // no warning, has parentheses
+
+  // Only warn on uses of the bitwise operators, and not the logical operators.
+  // The bitwise operators are more likely to be bugs while the logical
+  // operators are more likely to be used correctly.  Since there is no
+  // explicit logical-xor operator, the bitwise-xor is commonly used instead.
+  // For this warning, treat the bitwise-xor as if it were a logical operator.
+  (void)(x ^ b ? 1 : 2);  // no warning, ^ is often used as logical xor
+  (void)(x || b ? 1 : 2);  // no warning, logical operator
+  (void)(x && b ? 1 : 2);  // no warning, logical operator
 }
 
 // RUN: not %clang_cc1 -fsyntax-only -Wparentheses -Werror -fdiagnostics-show-option %s 2>&1 | FileCheck %s -check-prefix=CHECK-FLAG
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -7620,7 +7620,12 @@
 static bool IsArithmeticOp(BinaryOperatorKind Opc) {
   return BinaryOperator::isAdditiveOp(Opc) ||
  BinaryOperator::isMultiplicativeOp(Opc) ||
- BinaryOperator::isShiftOp(Opc);
+ BinaryOperator::isShiftOp(Opc) || Opc == BO_And || Opc == BO_Or;
+  // This only checks for bitwise-or and bitwise-and, but not bitwise-xor and
+  // not any of the logical operators.  Bitwise-xor is commonly used as a
+  // logical-xor because there is no logical-xor operator.  The logical
+  // operators, including uses of xor, have a high false positive rate for
+  // precedence warnings.
 }
 
 /// IsArithmeticBinaryExpr - Returns true if E is an arithmetic binary
@@ -7710,7 +7715,11 @@
   // The condition is an arithmetic binary expression, with a right-
   // hand side that looks boolean, so warn.
 
-  Self.Diag(OpLoc, diag::warn_precedence_conditional)
+  unsigned DiagID = BinaryOperator::isBitwiseOp(CondOpcode)
+? diag::warn_precedence_bitwise_conditional
+: diag::warn_precedence_conditional;
+
+  Self.Diag(OpLoc, DiagID)
   << Condition->getSourceRange()
   << BinaryOperator::getOpcodeStr(CondOpcode);
 
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -5745,6 +5745,9 @@
 def warn_precedence_conditional : Warning<
   "operator '?:' has lower precedence than '%0'; '%0' will be evaluated first">,
   InGroup;
+def warn_precedence_bitwise_conditional : Warning<
+  "operator '?:' has lower precedence than '%0'; '%0' will be evaluated first">,
+  InGroup;
 def note_precedence_conditional_first : Note<
   "place parentheses around the '?:' expression to evaluate it first">;
 
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -296,6 +296,7 @@
 def FlexibleArrayExtensions : DiagGroup<"flexible-array-extensions">;
 def FourByteMultiChar : DiagGroup<"four-char-constants">;
 def GlobalConstruc

r375329 - [analyzer] PR43551: Do not dereferce void* in UndefOrNullArgVisitor.

2019-10-18 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Fri Oct 18 18:50:46 2019
New Revision: 375329

URL: http://llvm.org/viewvc/llvm-project?rev=375329&view=rev
Log:
[analyzer] PR43551: Do not dereferce void* in UndefOrNullArgVisitor.

Patch by Kristóf Umann!

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
cfe/trunk/test/Analysis/novoidtypecrash.c

Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp?rev=375329&r1=375328&r2=375329&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp Fri Oct 18 
18:50:46 2019
@@ -2034,8 +2034,6 @@ bool bugreporter::trackExpressionValue(c
 
   // Is it a symbolic value?
   if (auto L = V.getAs()) {
-report.addVisitor(std::make_unique(L->getRegion()));
-
 // FIXME: this is a hack for fixing a later crash when attempting to
 // dereference a void* pointer.
 // We should not try to dereference pointers at all when we don't care
@@ -2056,10 +2054,14 @@ bool bugreporter::trackExpressionValue(c
 else if (CanDereference)
   RVal = LVState->getSVal(L->getRegion());
 
-if (CanDereference)
+if (CanDereference) {
+  report.addVisitor(
+  std::make_unique(L->getRegion()));
+
   if (auto KV = RVal.getAs())
 report.addVisitor(std::make_unique(
 *KV, L->getRegion(), EnableNullFPSuppression, TKind, SFC));
+}
 
 const MemRegion *RegionRVal = RVal.getAsRegion();
 if (RegionRVal && isa(RegionRVal)) {

Modified: cfe/trunk/test/Analysis/novoidtypecrash.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/novoidtypecrash.c?rev=375329&r1=375328&r2=375329&view=diff
==
--- cfe/trunk/test/Analysis/novoidtypecrash.c (original)
+++ cfe/trunk/test/Analysis/novoidtypecrash.c Fri Oct 18 18:50:46 2019
@@ -1,8 +1,27 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=core %s
+x;
+y(void **z) { // no-crash
+  *z = x;
+  int *w;
+  y(&w);
+  *w;
+}
+
 a;
-b(void **c) { // no-crash
-  *c = a;
-  int *d;
-  b(&d);
-  *d;
+b(*c) {}
+e(*c) {
+  void *d = f();
+  b(d);
+  *c = d;
+}
+void *g() {
+  e(&a);
+  return a;
+}
+j() {
+  int h;
+  char i = g();
+  if (i)
+for (; h;)
+  ;
 }


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


r375328 - [analyzer] Fix a crash on tracking Objective-C 'self' as a control dependency.

2019-10-18 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Fri Oct 18 18:50:43 2019
New Revision: 375328

URL: http://llvm.org/viewvc/llvm-project?rev=375328&view=rev
Log:
[analyzer] Fix a crash on tracking Objective-C 'self' as a control dependency.

'self' was previously never tracked, but now it can be tracked
because it may be part of a condition.

Added:
cfe/trunk/test/Analysis/track-control-dependency-conditions.m
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp?rev=375328&r1=375327&r2=375328&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp Fri Oct 18 
18:50:43 2019
@@ -1418,14 +1418,19 @@ FindLastStoreBRVisitor::VisitNode(const
 if (Optional CE = Succ->getLocationAs()) {
   if (const auto *VR = dyn_cast(R)) {
 
-const auto *Param = cast(VR->getDecl());
+if (const auto *Param = dyn_cast(VR->getDecl())) {
+  ProgramStateManager &StateMgr = BRC.getStateManager();
+  CallEventManager &CallMgr = StateMgr.getCallEventManager();
 
-ProgramStateManager &StateMgr = BRC.getStateManager();
-CallEventManager &CallMgr = StateMgr.getCallEventManager();
-
-CallEventRef<> Call = CallMgr.getCaller(CE->getCalleeContext(),
-Succ->getState());
-InitE = Call->getArgExpr(Param->getFunctionScopeIndex());
+  CallEventRef<> Call = CallMgr.getCaller(CE->getCalleeContext(),
+  Succ->getState());
+  InitE = Call->getArgExpr(Param->getFunctionScopeIndex());
+} else {
+  // Handle Objective-C 'self'.
+  assert(isa(VR->getDecl()));
+  InitE = cast(CE->getCalleeContext()->getCallSite())
+  ->getInstanceReceiver()->IgnoreParenCasts();
+}
 IsParam = true;
   }
 }

Added: cfe/trunk/test/Analysis/track-control-dependency-conditions.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/track-control-dependency-conditions.m?rev=375328&view=auto
==
--- cfe/trunk/test/Analysis/track-control-dependency-conditions.m (added)
+++ cfe/trunk/test/Analysis/track-control-dependency-conditions.m Fri Oct 18 
18:50:43 2019
@@ -0,0 +1,32 @@
+// RUN: %clang_analyze_cc1 -w -analyzer-checker=core,nullability -verify %s
+
+// expected-no-diagnostics
+
+@class C;
+
+#pragma clang assume_nonnull begin
+@interface I
+- foo:(C *)c;
+@end
+#pragma clang assume_nonnull end
+
+@interface J
+@property C *c;
+@end
+
+J *conjure_J();
+
+@implementation I
+- (void)bar {
+  if (self) { // no-crash
+J *j = conjure_J();
+if (j.c)
+  [self bar];
+// FIXME: Should warn.
+[self foo:j.c]; // no-warning
+  }
+}
+@end
+
+@implementation J
+@end


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


r375327 - [Docs] Fix header level.

2019-10-18 Thread Michael J. Spencer via cfe-commits
Author: mspencer
Date: Fri Oct 18 18:48:57 2019
New Revision: 375327

URL: http://llvm.org/viewvc/llvm-project?rev=375327&view=rev
Log:
[Docs] Fix header level.

Modified:
cfe/trunk/docs/Modules.rst

Modified: cfe/trunk/docs/Modules.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/Modules.rst?rev=375327&r1=375326&r2=375327&view=diff
==
--- cfe/trunk/docs/Modules.rst (original)
+++ cfe/trunk/docs/Modules.rst Fri Oct 18 18:48:57 2019
@@ -226,7 +226,7 @@ Command-line parameters
   Specify the path to the prebuilt modules. If specified, we will look for 
modules in this directory for a given top-level module name. We don't need a 
module map for loading prebuilt modules in this directory and the compiler will 
not try to rebuild these modules. This can be specified multiple times.
 
 -cc1 Options
-
+
 
 ``-fmodules-strict-context-hash``
   Enables hashing of all compiler options that could impact the semantics of a


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


r375326 - Add -Wbitwise-conditional-parentheses to warn on mixing '|' and '&' with "?:"

2019-10-18 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Oct 18 18:47:49 2019
New Revision: 375326

URL: http://llvm.org/viewvc/llvm-project?rev=375326&view=rev
Log:
Add -Wbitwise-conditional-parentheses to warn on mixing '|' and '&' with "?:"

Extend -Wparentheses to cover mixing bitwise-and and bitwise-or with the
conditional operator. There's two main cases seen with this:

unsigned bits1 = 0xf0 | cond ? 0x4 : 0x1;
unsigned bits2 = cond1 ? 0xf0 : 0x10 | cond2 ? 0x5 : 0x2;

// Intended order of evaluation:
unsigned bits1 = 0xf0 | (cond ? 0x4 : 0x1);
unsigned bits2 = (cond1 ? 0xf0 : 0x10) | (cond2 ? 0x5 : 0x2);

// Actual order of evaluation:
unsigned bits1 = (0xf0 | cond) ? 0x4 : 0x1;
unsigned bits2 = cond1 ? 0xf0 : ((0x10 | cond2) ? 0x5 : 0x2);

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


Modified:
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/Sema/parentheses.c

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=375326&r1=375325&r2=375326&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Fri Oct 18 18:47:49 2019
@@ -61,6 +61,9 @@ Improvements to Clang's diagnostics
   operation and a constant.  The group also has the new warning which diagnoses
   when a bitwise-or with a non-negative value is converted to a bool, since
   that bool will always be true.
+- -Wbitwise-conditional-parentheses will warn on operator precedence issues
+  when mixing bitwise-and (&) and bitwise-or (|) operator with the
+  conditional operator (?:).
 
 Non-comprehensive list of changes in this release
 -

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=375326&r1=375325&r2=375326&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Fri Oct 18 18:47:49 2019
@@ -296,6 +296,7 @@ def ExitTimeDestructors : DiagGroup<"exi
 def FlexibleArrayExtensions : DiagGroup<"flexible-array-extensions">;
 def FourByteMultiChar : DiagGroup<"four-char-constants">;
 def GlobalConstructors : DiagGroup<"global-constructors">;
+def BitwiseConditionalParentheses: 
DiagGroup<"bitwise-conditional-parentheses">;
 def BitwiseOpParentheses: DiagGroup<"bitwise-op-parentheses">;
 def LogicalOpParentheses: DiagGroup<"logical-op-parentheses">;
 def LogicalNotParentheses: DiagGroup<"logical-not-parentheses">;
@@ -737,6 +738,7 @@ def ParenthesesOnEquality : DiagGroup<"p
 def Parentheses : DiagGroup<"parentheses",
 [LogicalOpParentheses,
  LogicalNotParentheses,
+ BitwiseConditionalParentheses,
  BitwiseOpParentheses,
  ShiftOpParentheses,
  OverloadedShiftOpParentheses,

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=375326&r1=375325&r2=375326&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Oct 18 18:47:49 
2019
@@ -5745,6 +5745,9 @@ def note_precedence_silence : Note<
 def warn_precedence_conditional : Warning<
   "operator '?:' has lower precedence than '%0'; '%0' will be evaluated 
first">,
   InGroup;
+def warn_precedence_bitwise_conditional : Warning<
+  "operator '?:' has lower precedence than '%0'; '%0' will be evaluated 
first">,
+  InGroup;
 def note_precedence_conditional_first : Note<
   "place parentheses around the '?:' expression to evaluate it first">;
 

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=375326&r1=375325&r2=375326&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Oct 18 18:47:49 2019
@@ -7620,7 +7620,12 @@ static void SuggestParentheses(Sema &Sel
 static bool IsArithmeticOp(BinaryOperatorKind Opc) {
   return BinaryOperator::isAdditiveOp(Opc) ||
  BinaryOperator::isMultiplicativeOp(Opc) ||
- BinaryOperator::isShiftOp(Opc);
+ BinaryOperator::isShiftOp(Opc) || Opc == BO_And || Opc == BO_Or;
+  // This only checks for bitwise-or and bitwise-and, but not bitwise-xor and
+  // not any of the logical operators.  Bitwise-xor is commonly used as a
+  // 

[PATCH] D68528: [Implicit Modules] Add -cc1 option -fmodules-strict-hash which includes search paths and diagnostics.

2019-10-18 Thread Michael Spencer via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG14a3f77ba103: [Implicit Modules] Add -cc1 option 
-fmodules-strict-context-hash which includes… (authored by Bigcheese).

Changed prior to commit:
  https://reviews.llvm.org/D68528?vs=225326&id=225731#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68528

Files:
  clang/docs/Modules.rst
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Lex/HeaderSearchOptions.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Modules/context-hash.c

Index: clang/test/Modules/context-hash.c
===
--- /dev/null
+++ clang/test/Modules/context-hash.c
@@ -0,0 +1,33 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fsyntax-only -internal-isystem \
+// RUN:   %S/Inputs/System/usr/include -fmodules -fimplicit-module-maps \
+// RUN:   -fmodules-cache-path=%t %s -Rmodule-build 2> %t1
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fsyntax-only -internal-isystem \
+// RUN:   %S/Inputs/System/usr/include -internal-isystem %S -fmodules \
+// RUN:   -fimplicit-module-maps -fmodules-cache-path=%t %s -Rmodule-build 2> \
+// RUN:   %t2
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fsyntax-only -internal-isystem \
+// RUN:   %S/Inputs/System/usr/include -internal-isystem %S -fmodules \
+// RUN:   -fimplicit-module-maps -fmodules-cache-path=%t %s \
+// RUN:   -fmodules-strict-context-hash -Rmodule-build 2> %t3
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fsyntax-only -Weverything -internal-isystem \
+// RUN:   %S/Inputs/System/usr/include -fmodules -fmodules-strict-context-hash \
+// RUN:   -fimplicit-module-maps -fmodules-cache-path=%t %s -Rmodule-build 2> \
+// RUN:   %t4
+// RUN: echo %t | cat - %t1 %t2 %t3 %t4 | FileCheck %s
+
+// This test verifies that only strict hashing includes search paths and
+// diagnostics in the module context hash.
+
+#include 
+
+// CHECK: [[PREFIX:(.*[/\\])+[a-zA-Z0-9.-]+]]
+// CHECK: building module 'cstd' as '[[PREFIX]]{{[/\\]}}[[CONTEXT_HASH:[A-Z0-9]+]]{{[/\\]}}cstd-[[AST_HASH:[A-Z0-9]+]].pcm'
+// CHECK: building module 'cstd' as '{{.*[/\\]}}[[CONTEXT_HASH]]{{[/\\]}}cstd-[[AST_HASH]].pcm'
+// CHECK-NOT: building module 'cstd' as '{{.*[/\\]}}[[CONTEXT_HASH]]{{[/\\]}}
+// CHECK: cstd-[[AST_HASH]].pcm'
+// CHECK-NOT: building module 'cstd' as '{{.*[/\\]}}[[CONTEXT_HASH]]{{[/\\]}}
+// CHECK: cstd-[[AST_HASH]].pcm'
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2067,6 +2067,7 @@
 Opts.AddPrebuiltModulePath(A->getValue());
   Opts.DisableModuleHash = Args.hasArg(OPT_fdisable_module_hash);
   Opts.ModulesHashContent = Args.hasArg(OPT_fmodules_hash_content);
+  Opts.ModulesStrictContextHash = Args.hasArg(OPT_fmodules_strict_context_hash);
   Opts.ModulesValidateDiagnosticOptions =
   !Args.hasArg(OPT_fmodules_disable_diagnostic_validation);
   Opts.ImplicitModuleMaps = Args.hasArg(OPT_fimplicit_module_maps);
@@ -3546,6 +3547,7 @@
   using llvm::hash_code;
   using llvm::hash_value;
   using llvm::hash_combine;
+  using llvm::hash_combine_range;
 
   // Start the signature with the compiler version.
   // FIXME: We'd rather use something more cryptographically sound than
@@ -3600,6 +3602,24 @@
   hsOpts.ModulesValidateDiagnosticOptions);
   code = hash_combine(code, hsOpts.ResourceDir);
 
+  if (hsOpts.ModulesStrictContextHash) {
+hash_code SHPC = hash_combine_range(hsOpts.SystemHeaderPrefixes.begin(),
+hsOpts.SystemHeaderPrefixes.end());
+hash_code UEC = hash_combine_range(hsOpts.UserEntries.begin(),
+   hsOpts.UserEntries.end());
+code = hash_combine(code, hsOpts.SystemHeaderPrefixes.size(), SHPC,
+hsOpts.UserEntries.size(), UEC);
+
+const DiagnosticOptions &diagOpts = getDiagnosticOpts();
+#define DIAGOPT(Name, Bits, Default) \
+  code = hash_combine(code, diagOpts.Name);
+#define ENUM_DIAGOPT(Name, Type, Bits, Default) \
+  code = hash_combine(code, diagOpts.get##Name());
+#include "clang/Basic/DiagnosticOptions.def"
+#undef DIAGOPT
+#undef ENUM_DIAGOPT
+  }
+
   // Extend the signature with the user build path.
   code = hash_combine(code, hsOpts.ModuleUserBuildPath);
 
Index: clang/include/clang/Lex/HeaderSearchOptions.h
===
--- clang/include/clang/Lex/HeaderSearchOptions.h
+++ clang/include/clang/Lex/HeaderSearchOptions.h
@@ -11,6 +11,7 @@
 
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/CachedHashString.h"
+#include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/SetVector.h"
 #include "llvm/ADT/StringRef.h"
 #include 
@@ -206,6 +207,13 @@
 
   unsigned ModulesHashContent : 1;
 

[PATCH] D63164: [HIP] Add option to force lambda nameing following ODR in HIP/CUDA.

2019-10-18 Thread Michael Liao via Phabricator via cfe-commits
hliao abandoned this revision.
hliao added a comment.

revised change is already committed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63164



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


r375322 - [Implicit Modules] Add -cc1 option -fmodules-strict-context-hash which includes search paths and diagnostics.

2019-10-18 Thread Michael J. Spencer via cfe-commits
Author: mspencer
Date: Fri Oct 18 18:36:37 2019
New Revision: 375322

URL: http://llvm.org/viewvc/llvm-project?rev=375322&view=rev
Log:
[Implicit Modules] Add -cc1 option -fmodules-strict-context-hash which includes 
search paths and diagnostics.

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

Added:
cfe/trunk/test/Modules/context-hash.c
Modified:
cfe/trunk/docs/Modules.rst
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Lex/HeaderSearchOptions.h
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/docs/Modules.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/Modules.rst?rev=375322&r1=375321&r2=375322&view=diff
==
--- cfe/trunk/docs/Modules.rst (original)
+++ cfe/trunk/docs/Modules.rst Fri Oct 18 18:36:37 2019
@@ -225,6 +225,16 @@ Command-line parameters
 ``-fprebuilt-module-path=``
   Specify the path to the prebuilt modules. If specified, we will look for 
modules in this directory for a given top-level module name. We don't need a 
module map for loading prebuilt modules in this directory and the compiler will 
not try to rebuild these modules. This can be specified multiple times.
 
+-cc1 Options
+
+
+``-fmodules-strict-context-hash``
+  Enables hashing of all compiler options that could impact the semantics of a
+  module in an implicit build. This includes things such as header search paths
+  and diagnostics. Using this option may lead to an excessive number of modules
+  being built if the command line arguments are not homogeneous across your
+  build.
+
 Module Semantics
 
 

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=375322&r1=375321&r2=375322&view=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Fri Oct 18 18:36:37 2019
@@ -815,6 +815,9 @@ def fdisable_module_hash : Flag<["-"], "
   HelpText<"Disable the module hash">;
 def fmodules_hash_content : Flag<["-"], "fmodules-hash-content">,
   HelpText<"Enable hashing the content of a module file">;
+def fmodules_strict_context_hash : Flag<["-"], "fmodules-strict-context-hash">,
+  HelpText<"Enable hashing of all compiler options that could impact the "
+   "semantics of a module in an implicit build">;
 def c_isystem : JoinedOrSeparate<["-"], "c-isystem">, 
MetaVarName<"">,
   HelpText<"Add directory to the C SYSTEM include search path">;
 def objc_isystem : JoinedOrSeparate<["-"], "objc-isystem">,

Modified: cfe/trunk/include/clang/Lex/HeaderSearchOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearchOptions.h?rev=375322&r1=375321&r2=375322&view=diff
==
--- cfe/trunk/include/clang/Lex/HeaderSearchOptions.h (original)
+++ cfe/trunk/include/clang/Lex/HeaderSearchOptions.h Fri Oct 18 18:36:37 2019
@@ -11,6 +11,7 @@
 
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/CachedHashString.h"
+#include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/SetVector.h"
 #include "llvm/ADT/StringRef.h"
 #include 
@@ -206,6 +207,13 @@ public:
 
   unsigned ModulesHashContent : 1;
 
+  /// Whether we should include all things that could impact the module in the
+  /// hash.
+  ///
+  /// This includes things like the full header search path, and enabled
+  /// diagnostics.
+  unsigned ModulesStrictContextHash : 1;
+
   HeaderSearchOptions(StringRef _Sysroot = "/")
   : Sysroot(_Sysroot), ModuleFormat("raw"), DisableModuleHash(false),
 ImplicitModuleMaps(false), ModuleMapFileHomeIsCwd(false),
@@ -214,7 +222,8 @@ public:
 ModulesValidateOncePerBuildSession(false),
 ModulesValidateSystemHeaders(false),
 ValidateASTInputFilesContent(false), UseDebugInfo(false),
-ModulesValidateDiagnosticOptions(true), ModulesHashContent(false) {}
+ModulesValidateDiagnosticOptions(true), ModulesHashContent(false),
+ModulesStrictContextHash(false) {}
 
   /// AddPath - Add the \p Path path to the specified \p Group list.
   void AddPath(StringRef Path, frontend::IncludeDirGroup Group,
@@ -238,6 +247,15 @@ public:
   }
 };
 
+inline llvm::hash_code hash_value(const HeaderSearchOptions::Entry &E) {
+  return llvm::hash_combine(E.Path, E.Group, E.IsFramework, E.IgnoreSysRoot);
+}
+
+inline llvm::hash_code
+hash_value(const HeaderSearchOptions::SystemHeaderPrefix &SHP) {
+  return llvm::hash_combine(SHP.Prefix, SHP.IsSystemHeader);
+}
+
 } // namespace clang
 
 #endif // LLVM_CLANG_LEX_HEADERSEARCHOPTIONS_H

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=375322&r1=375321&r2=375322&view=diff
=

[PATCH] D68891: Remove unnecessary triple from test

2019-10-18 Thread Yuki Okushi via Phabricator via cfe-commits
JohnTitor added a comment.

ping @rsmith


Repository:
  rC Clang

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

https://reviews.llvm.org/D68891



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


[PATCH] D68108: Redeclare Objective-C property accessors inside the ObjCImplDecl in which they are synthesized.

2019-10-18 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ edited reviewers, added: NoQ; removed: dergachev.a.
NoQ added inline comments.



Comment at: 
clang/test/Analysis/Inputs/expected-plists/nullability-notes.m.plist:191

-10
 14

It looks like the body farm for the property accessor has stopped working here. 
The code under analysis (from `test/Analysis/nullability-notes.m`) is:
```lang=objc
 7  void takesNonnull(NSObject *_Nonnull y);
 8
 9  @interface ClassWithProperties: NSObject
10  @property(copy, nullable) NSObject *x; // plist check ensures no 
control flow piece from here to 'self.x'.
11  -(void) method;
12  @end;
13  @implementation ClassWithProperties
14  -(void) method {
15// no-crash
16NSObject *x = self.x; // expected-note{{Nullability 'nullable' is 
inferred}}
17takesNonnull(x); // expected-warning{{Nullable pointer is passed to a 
callee that requires a non-null 1st parameter}}
18 // expected-note@-1{{Nullable pointer is passed to a 
callee that requires a non-null 1st parameter}}
19  }
20  @end
```
The point of the test is to check how control flow is displayed to the user, 
and //this// change in the plist file will not really be visible to the user. 
However i'm worried that we've lost precision of the analysis on similar 
examples. I'll double-check.


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

https://reviews.llvm.org/D68108



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


[PATCH] D68108: Redeclare Objective-C property accessors inside the ObjCImplDecl in which they are synthesized.

2019-10-18 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl updated this revision to Diff 225729.

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

https://reviews.llvm.org/D68108

Files:
  clang/include/clang/AST/DeclObjC.h
  clang/lib/AST/DeclObjC.cpp
  clang/lib/Analysis/BodyFarm.cpp
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/CodeGen/CGObjCGNU.cpp
  clang/lib/CodeGen/CGObjCMac.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
  clang/lib/Frontend/Rewrite/RewriteObjC.cpp
  clang/lib/Index/IndexDecl.cpp
  clang/lib/Sema/SemaDeclObjC.cpp
  clang/lib/Sema/SemaObjCProperty.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp
  clang/lib/StaticAnalyzer/Core/CallEvent.cpp
  clang/test/AST/ast-dump-decl-json.m
  clang/test/Analysis/Inputs/expected-plists/nullability-notes.m.plist
  clang/test/CodeGenObjC/debug-info-synthesis.m
  clang/test/CodeGenObjC/debug-property-synth.m
  clang/test/CodeGenObjC/debuginfo-properties.m
  clang/test/CodeGenObjC/instance-method-metadata.m
  clang/test/SemaObjC/iboutlet.m
  clang/tools/libclang/CIndex.cpp

Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -629,6 +629,11 @@
 Decl *D = *I;
 if (D->getLexicalDeclContext() != DC)
   continue;
+// Filter out synthesized property accessor redeclarations.
+if (isa(DC))
+  if (auto *OMD = dyn_cast(D))
+if (OMD->isImplicit() && !OMD->hasBody())
+  continue;
 const Optional V = handleDeclForVisitation(D);
 if (!V.hasValue())
   continue;
Index: clang/test/SemaObjC/iboutlet.m
===
--- clang/test/SemaObjC/iboutlet.m
+++ clang/test/SemaObjC/iboutlet.m
@@ -11,7 +11,7 @@
 
 IBInspectable @property (readonly) IBOutlet NSView *myView1; // expected-warning {{readonly IBOutlet property 'myView1' when auto-synthesized may not work correctly with 'nib' loader}} expected-note {{property should be changed to be readwrite}}
 
-@property (getter = MyGetter, READONLY) IBOutlet NSView *myView2; // expected-warning {{readonly IBOutlet property 'myView2' when auto-synthesized may not work correctly with 'nib' loader}}
+@property (getter = MyGetter2, READONLY) IBOutlet NSView *myView2; // expected-warning {{readonly IBOutlet property 'myView2' when auto-synthesized may not work correctly with 'nib' loader}}
 
 @end
 
Index: clang/test/CodeGenObjC/instance-method-metadata.m
===
--- clang/test/CodeGenObjC/instance-method-metadata.m
+++ clang/test/CodeGenObjC/instance-method-metadata.m
@@ -1,6 +1,5 @@
 // REQUIRES: x86-registered-target
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -S -o %t %s 
-// RUN: FileCheck < %t %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -S %s -o - | FileCheck %s
 
 // rdar://9072317
 
Index: clang/test/CodeGenObjC/debuginfo-properties.m
===
--- clang/test/CodeGenObjC/debuginfo-properties.m
+++ clang/test/CodeGenObjC/debuginfo-properties.m
@@ -11,19 +11,6 @@
 
 @protocol HasASelection 
 @property (nonatomic, retain) Selection* selection;
-// CHECK: !DISubprogram(name: "-[MyClass selection]"
-// CHECK-SAME:  line: [[@LINE-2]]
-// CHECK-SAME:  DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK: !DISubprogram(name: "-[MyClass setSelection:]"
-// CHECK-SAME:  line: [[@LINE-5]]
-// CHECK-SAME:  DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK: !DISubprogram(name: "-[OtherClass selection]"
-// CHECK-SAME:  line: [[@LINE-8]]
-// CHECK-SAME:  DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK: !DISubprogram(name: "-[OtherClass setSelection:]"
-// CHECK-SAME:  line: [[@LINE-11]]
-// CHECK-SAME:  DISPFlagLocalToUnit | DISPFlagDefinition
-
 @end
 
 @interface MyClass : NSObject  {
@@ -33,6 +20,12 @@
 
 @implementation MyClass
 @synthesize selection = _selection;
+// CHECK: !DISubprogram(name: "-[MyClass selection]"
+// CHECK-SAME:  line: [[@LINE-2]]
+// CHECK-SAME:  DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK: !DISubprogram(name: "-[MyClass setSelection:]"
+// CHECK-SAME:  line: [[@LINE-5]]
+// CHECK-SAME:  DISPFlagLocalToUnit | DISPFlagDefinition
 @end
 
 @interface OtherClass : NSObject  {
@@ -41,4 +34,10 @@
 @end
 @implementation OtherClass
 @synthesize selection = _selection;
+// CHECK: !DISubprogram(name: "-[OtherClass selection]"
+// CHECK-SAME:  line: [[@LINE-2]]
+// CHECK-SAME:  DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK: !DISubprogram(name: "-[OtherClass setSelection:]"
+// CHECK-SAME:  line: [[@LINE-5]]
+// CHECK-SAME:  DISPFlagLocalToUnit | DISPFlagDefinition
 @end
Inde

[PATCH] D68108: Redeclare Objective-C property accessors inside the ObjCImplDecl in which they are synthesized.

2019-10-18 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl updated this revision to Diff 225727.
aprantl added a comment.

Addressed most of the feedback, explained the rest.


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

https://reviews.llvm.org/D68108

Files:
  clang/include/clang/AST/DeclObjC.h
  clang/lib/AST/DeclObjC.cpp
  clang/lib/Analysis/BodyFarm.cpp
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/CodeGen/CGObjCGNU.cpp
  clang/lib/CodeGen/CGObjCMac.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
  clang/lib/Frontend/Rewrite/RewriteObjC.cpp
  clang/lib/Index/IndexDecl.cpp
  clang/lib/Sema/SemaDeclObjC.cpp
  clang/lib/Sema/SemaObjCProperty.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp
  clang/lib/StaticAnalyzer/Core/CallEvent.cpp
  clang/test/AST/ast-dump-decl-json.m
  clang/test/Analysis/Inputs/expected-plists/nullability-notes.m.plist
  clang/test/CodeGenObjC/debug-info-synthesis.m
  clang/test/CodeGenObjC/debug-property-synth.m
  clang/test/CodeGenObjC/debuginfo-properties.m
  clang/test/CodeGenObjC/instance-method-metadata.m
  clang/test/SemaObjC/iboutlet.m
  clang/tools/libclang/CIndex.cpp

Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -629,6 +629,11 @@
 Decl *D = *I;
 if (D->getLexicalDeclContext() != DC)
   continue;
+// Filter out synthesized property accessor redeclarations.
+if (isa(DC))
+  if (auto *OMD = dyn_cast(D))
+if (OMD->isImplicit() && !OMD->hasBody())
+  continue;
 const Optional V = handleDeclForVisitation(D);
 if (!V.hasValue())
   continue;
Index: clang/test/SemaObjC/iboutlet.m
===
--- clang/test/SemaObjC/iboutlet.m
+++ clang/test/SemaObjC/iboutlet.m
@@ -11,7 +11,7 @@
 
 IBInspectable @property (readonly) IBOutlet NSView *myView1; // expected-warning {{readonly IBOutlet property 'myView1' when auto-synthesized may not work correctly with 'nib' loader}} expected-note {{property should be changed to be readwrite}}
 
-@property (getter = MyGetter, READONLY) IBOutlet NSView *myView2; // expected-warning {{readonly IBOutlet property 'myView2' when auto-synthesized may not work correctly with 'nib' loader}}
+@property (getter = MyGetter2, READONLY) IBOutlet NSView *myView2; // expected-warning {{readonly IBOutlet property 'myView2' when auto-synthesized may not work correctly with 'nib' loader}}
 
 @end
 
Index: clang/test/CodeGenObjC/instance-method-metadata.m
===
--- clang/test/CodeGenObjC/instance-method-metadata.m
+++ clang/test/CodeGenObjC/instance-method-metadata.m
@@ -1,6 +1,5 @@
 // REQUIRES: x86-registered-target
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -S -o %t %s 
-// RUN: FileCheck < %t %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -S %s -o - | FileCheck %s
 
 // rdar://9072317
 
Index: clang/test/CodeGenObjC/debuginfo-properties.m
===
--- clang/test/CodeGenObjC/debuginfo-properties.m
+++ clang/test/CodeGenObjC/debuginfo-properties.m
@@ -11,19 +11,6 @@
 
 @protocol HasASelection 
 @property (nonatomic, retain) Selection* selection;
-// CHECK: !DISubprogram(name: "-[MyClass selection]"
-// CHECK-SAME:  line: [[@LINE-2]]
-// CHECK-SAME:  DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK: !DISubprogram(name: "-[MyClass setSelection:]"
-// CHECK-SAME:  line: [[@LINE-5]]
-// CHECK-SAME:  DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK: !DISubprogram(name: "-[OtherClass selection]"
-// CHECK-SAME:  line: [[@LINE-8]]
-// CHECK-SAME:  DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK: !DISubprogram(name: "-[OtherClass setSelection:]"
-// CHECK-SAME:  line: [[@LINE-11]]
-// CHECK-SAME:  DISPFlagLocalToUnit | DISPFlagDefinition
-
 @end
 
 @interface MyClass : NSObject  {
@@ -33,6 +20,12 @@
 
 @implementation MyClass
 @synthesize selection = _selection;
+// CHECK: !DISubprogram(name: "-[MyClass selection]"
+// CHECK-SAME:  line: [[@LINE-2]]
+// CHECK-SAME:  DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK: !DISubprogram(name: "-[MyClass setSelection:]"
+// CHECK-SAME:  line: [[@LINE-5]]
+// CHECK-SAME:  DISPFlagLocalToUnit | DISPFlagDefinition
 @end
 
 @interface OtherClass : NSObject  {
@@ -41,4 +34,10 @@
 @end
 @implementation OtherClass
 @synthesize selection = _selection;
+// CHECK: !DISubprogram(name: "-[OtherClass selection]"
+// CHECK-SAME:  line: [[@LINE-2]]
+// CHECK-SAME:  DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK: !DISubprogram(name: "-[OtherClass setSelection:]"
+// CHECK-SAME:  line: [[@LINE-5

[PATCH] D68108: Redeclare Objective-C property accessors inside the ObjCImplDecl in which they are synthesized.

2019-10-18 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl marked 8 inline comments as done.
aprantl added inline comments.



Comment at: clang/lib/Analysis/BodyFarm.cpp:843
+return Val.getValue();
+  Val = nullptr;
+

rjmccall wrote:
> Why did this logic need to change?
I don't have a satisfying answer for this.

Without this extra code, the assertion in 
https://github.com/llvm/llvm-project/blob/b081220cfd46965fa25dbf826cd3f42f4f9e54cd/clang/test/Analysis/properties.m#L1035
 (and only that one) turns from `UNKNOWN` to `TRUE`.

There is a similar workaround with a similar comment in
https://github.com/llvm/llvm-project/blob/b081220cfd46965fa25dbf826cd3f42f4f9e54cd/clang/lib/StaticAnalyzer/Core/CallEvent.cpp#L1291
that looks like it is related.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:5063
  const_cast(D), PID);
 }
   }

rjmccall wrote:
> Is this special treatment still necessary?  Won't we encounter the getter and 
> setter on the normal pass over the method definitions in the 
> `@implementation`?
We don't know which ObjMethodDecls without bodies are property accessor 
implementations since there is no pointer from the ObjCMethodDecl back to the 
ObjCPropertyImplDecl.


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

https://reviews.llvm.org/D68108



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


[PATCH] D66046: Add new tautological compare warning for bitwise-or with a non-zero constant

2019-10-18 Thread Richard Trieu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8b0d14a8f0cc: New tautological warning for bitwise-or with 
non-zero constant always true. (authored by rtrieu).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D66046?vs=214733&id=225726#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66046

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Analysis/CFG.h
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Analysis/CFG.cpp
  clang/lib/Sema/AnalysisBasedWarnings.cpp
  clang/test/Sema/warn-bitwise-compare.c
  clang/test/SemaCXX/warn-bitwise-compare.cpp

Index: clang/test/SemaCXX/warn-bitwise-compare.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/warn-bitwise-compare.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wtautological-bitwise-compare %s
+
+void test(int x) {
+  bool b1 = (8 & x) == 3;
+  // expected-warning@-1 {{bitwise comparison always evaluates to false}}
+  bool b2 = x | 5;
+  // expected-warning@-1 {{bitwise or with non-zero value always evaluates to true}}
+  bool b3 = (x | 5);
+  // expected-warning@-1 {{bitwise or with non-zero value always evaluates to true}}
+  bool b4 = !!(x | 5);
+  // expected-warning@-1 {{bitwise or with non-zero value always evaluates to true}}
+}
Index: clang/test/Sema/warn-bitwise-compare.c
===
--- clang/test/Sema/warn-bitwise-compare.c
+++ clang/test/Sema/warn-bitwise-compare.c
@@ -1,7 +1,12 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -Wtautological-compare %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wtautological-bitwise-compare %s
 
 #define mydefine 2
 
+enum {
+  ZERO,
+  ONE,
+};
+
 void f(int x) {
   if ((8 & x) == 3) {}  // expected-warning {{bitwise comparison always evaluates to false}}
   if ((x & 8) == 4) {}  // expected-warning {{bitwise comparison always evaluates to false}}
@@ -13,6 +18,9 @@
   if ((x & 0x15) == 0x13) {} // expected-warning {{bitwise comparison always evaluates to false}}
   if ((0x23 | x) == 0x155){} // expected-warning {{bitwise comparison always evaluates to false}}
 
+  if (!!((8 & x) == 3)) {}  // expected-warning {{bitwise comparison always evaluates to false}}
+  int y = ((8 & x) == 3) ? 1 : 2;  // expected-warning {{bitwise comparison always evaluates to false}}
+
   if ((x & 8) == 8) {}
   if ((x & 8) != 8) {}
   if ((x | 4) == 4) {}
@@ -26,3 +34,14 @@
   if ((x & mydefine) == 8) {}
   if ((x | mydefine) == 4) {}
 }
+
+void g(int x) {
+  if (x | 5) {}  // expected-warning {{bitwise or with non-zero value always evaluates to true}}
+  if (5 | x) {}  // expected-warning {{bitwise or with non-zero value always evaluates to true}}
+  if (!((x | 5))) {}  // expected-warning {{bitwise or with non-zero value always evaluates to true}}
+
+  if (x | -1) {}  // expected-warning {{bitwise or with non-zero value always evaluates to true}}
+  if (x | ONE) {}  // expected-warning {{bitwise or with non-zero value always evaluates to true}}
+
+  if (x | ZERO) {}
+}
Index: clang/lib/Sema/AnalysisBasedWarnings.cpp
===
--- clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -159,6 +159,20 @@
 S.Diag(B->getExprLoc(), diag::warn_comparison_bitwise_always)
 << DiagRange << isAlwaysTrue;
   }
+
+  void compareBitwiseOr(const BinaryOperator *B) override {
+if (HasMacroID(B))
+  return;
+
+SourceRange DiagRange = B->getSourceRange();
+S.Diag(B->getExprLoc(), diag::warn_comparison_bitwise_or) << DiagRange;
+  }
+
+  static bool hasActiveDiagnostics(DiagnosticsEngine &Diags,
+   SourceLocation Loc) {
+return !Diags.isIgnored(diag::warn_tautological_overlap_comparison, Loc) ||
+   !Diags.isIgnored(diag::warn_comparison_bitwise_or, Loc);
+  }
 };
 } // anonymous namespace
 
@@ -2070,10 +2084,9 @@
   .setAlwaysAdd(Stmt::AttributedStmtClass);
   }
 
-  // Install the logical handler for -Wtautological-overlap-compare
+  // Install the logical handler.
   llvm::Optional LEH;
-  if (!Diags.isIgnored(diag::warn_tautological_overlap_comparison,
-   D->getBeginLoc())) {
+  if (LogicalErrorHandler::hasActiveDiagnostics(Diags, D->getBeginLoc())) {
 LEH.emplace(S);
 AC.getCFGBuildOptions().Observer = &*LEH;
   }
@@ -,9 +2235,8 @@
 checkThrowInNonThrowingFunc(S, FD, AC);
 
   // If none of the previous checks caused a CFG build, trigger one here
-  // for -Wtautological-overlap-compare
-  if (!Diags.isIgnored(diag::warn_tautological_overlap_comparison,
-   D->getBeginLoc())) {
+  // for the logical error handler.
+  if (LogicalErrorHandler::hasActiveDiagnostic

r375318 - New tautological warning for bitwise-or with non-zero constant always true.

2019-10-18 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Oct 18 17:57:23 2019
New Revision: 375318

URL: http://llvm.org/viewvc/llvm-project?rev=375318&view=rev
Log:
New tautological warning for bitwise-or with non-zero constant always true.

Taking a value and the bitwise-or it with a non-zero constant will always
result in a non-zero value. In a boolean context, this is always true.

if (x | 0x4) {}  // always true, intended '&'

This patch creates a new warning group -Wtautological-bitwise-compare for this
warning. It also moves in the existing tautological bitwise comparisons into
this group. A few other changes were needed to the CFGBuilder so that all bool
contexts would be checked. The warnings in -Wtautological-bitwise-compare will
be off by default due to using the CFG.

Fixes: https://bugs.llvm.org/show_bug.cgi?id=42666
Differential Revision: https://reviews.llvm.org/D66046


Added:
cfe/trunk/test/SemaCXX/warn-bitwise-compare.cpp
Modified:
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/include/clang/Analysis/CFG.h
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Analysis/CFG.cpp
cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
cfe/trunk/test/Sema/warn-bitwise-compare.c

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=375318&r1=375317&r2=375318&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Fri Oct 18 17:57:23 2019
@@ -56,6 +56,11 @@ Improvements to Clang's diagnostics
 - -Wtautological-compare for self comparisons and
   -Wtautological-overlap-compare will now look through member and array
   access to determine if two operand expressions are the same.
+- -Wtautological-bitwise-compare is a new warning group.  This group has the
+  current warning which diagnoses the tautological comparison of a bitwise
+  operation and a constant.  The group also has the new warning which diagnoses
+  when a bitwise-or with a non-negative value is converted to a bool, since
+  that bool will always be true.
 
 Non-comprehensive list of changes in this release
 -

Modified: cfe/trunk/include/clang/Analysis/CFG.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/CFG.h?rev=375318&r1=375317&r2=375318&view=diff
==
--- cfe/trunk/include/clang/Analysis/CFG.h (original)
+++ cfe/trunk/include/clang/Analysis/CFG.h Fri Oct 18 17:57:23 2019
@@ -1213,6 +1213,7 @@ public:
   virtual void compareAlwaysTrue(const BinaryOperator *B, bool isAlwaysTrue) {}
   virtual void compareBitwiseEquality(const BinaryOperator *B,
   bool isAlwaysTrue) {}
+  virtual void compareBitwiseOr(const BinaryOperator *B) {}
 };
 
 /// Represents a source-level, intra-procedural CFG that represents the

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=375318&r1=375317&r2=375318&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Fri Oct 18 17:57:23 2019
@@ -516,12 +516,14 @@ def TautologicalConstantCompare : DiagGr
 [TautologicalOutOfRangeCompare]>;
 def TautologicalPointerCompare : DiagGroup<"tautological-pointer-compare">;
 def TautologicalOverlapCompare : DiagGroup<"tautological-overlap-compare">;
+def TautologicalBitwiseCompare : DiagGroup<"tautological-bitwise-compare">;
 def TautologicalUndefinedCompare : DiagGroup<"tautological-undefined-compare">;
 def TautologicalObjCBoolCompare : DiagGroup<"tautological-objc-bool-compare">;
 def TautologicalCompare : DiagGroup<"tautological-compare",
 [TautologicalConstantCompare,
  TautologicalPointerCompare,
  TautologicalOverlapCompare,
+ TautologicalBitwiseCompare,
  TautologicalUndefinedCompare,
  TautologicalObjCBoolCompare]>;
 def HeaderHygiene : DiagGroup<"header-hygiene">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=375318&r1=375317&r2=375318&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Oct 18 17:57:23 
2019
@@ -8332,7 +8332,10 @@ def warn_comparison_always : Warning<

[clang-tools-extra] r375316 - Move endian constant from Host.h to SwapByteOrder.h, prune include

2019-10-18 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Fri Oct 18 17:48:11 2019
New Revision: 375316

URL: http://llvm.org/viewvc/llvm-project?rev=375316&view=rev
Log:
Move endian constant from Host.h to SwapByteOrder.h, prune include

Works on this dependency chain:
  ArrayRef.h ->
  Hashing.h -> --CUT--
  Host.h ->
  StringMap.h / StringRef.h

ArrayRef is very popular, but Host.h is rarely needed. Move the
IsBigEndianHost constant to SwapByteOrder.h. Clients of that header are
more likely to need it.

Modified:
clang-tools-extra/trunk/clangd/FileDistance.h

Modified: clang-tools-extra/trunk/clangd/FileDistance.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/FileDistance.h?rev=375316&r1=375315&r2=375316&view=diff
==
--- clang-tools-extra/trunk/clangd/FileDistance.h (original)
+++ clang-tools-extra/trunk/clangd/FileDistance.h Fri Oct 18 17:48:11 2019
@@ -43,6 +43,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseMapInfo.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/Path.h"


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


r375316 - Move endian constant from Host.h to SwapByteOrder.h, prune include

2019-10-18 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Fri Oct 18 17:48:11 2019
New Revision: 375316

URL: http://llvm.org/viewvc/llvm-project?rev=375316&view=rev
Log:
Move endian constant from Host.h to SwapByteOrder.h, prune include

Works on this dependency chain:
  ArrayRef.h ->
  Hashing.h -> --CUT--
  Host.h ->
  StringMap.h / StringRef.h

ArrayRef is very popular, but Host.h is rarely needed. Move the
IsBigEndianHost constant to SwapByteOrder.h. Clients of that header are
more likely to need it.

Modified:
cfe/trunk/lib/Driver/ToolChains/Arch/AArch64.cpp
cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp
cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp
cfe/trunk/lib/Driver/ToolChains/Arch/X86.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/AArch64.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/AArch64.cpp?rev=375316&r1=375315&r2=375316&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/AArch64.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/AArch64.cpp Fri Oct 18 17:48:11 2019
@@ -12,6 +12,7 @@
 #include "clang/Driver/Options.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/TargetParser.h"
+#include "llvm/Support/Host.h"
 
 using namespace clang::driver;
 using namespace clang::driver::tools;

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp?rev=375316&r1=375315&r2=375316&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp Fri Oct 18 17:48:11 2019
@@ -13,6 +13,7 @@
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/TargetParser.h"
+#include "llvm/Support/Host.h"
 
 using namespace clang::driver;
 using namespace clang::driver::tools;

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp?rev=375316&r1=375315&r2=375316&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp Fri Oct 18 17:48:11 2019
@@ -13,6 +13,7 @@
 #include "clang/Driver/Options.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Option/ArgList.h"
+#include "llvm/Support/Host.h"
 
 using namespace clang::driver;
 using namespace clang::driver::tools;

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/X86.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/X86.cpp?rev=375316&r1=375315&r2=375316&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/X86.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/X86.cpp Fri Oct 18 17:48:11 2019
@@ -13,6 +13,7 @@
 #include "clang/Driver/Options.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Option/ArgList.h"
+#include "llvm/Support/Host.h"
 
 using namespace clang::driver;
 using namespace clang::driver::tools;


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


[PATCH] D66437: Sema: Create a no-op implicit cast for lvalue function conversions.

2019-10-18 Thread Peter Collingbourne via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG766f15814a01: Sema: Create a no-op implicit cast for lvalue 
function conversions. (authored by pcc).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66437

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/CodeGenCXX/implicit-function-conversion.cpp

Index: clang/test/CodeGenCXX/implicit-function-conversion.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/implicit-function-conversion.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-unknown-linux -std=c++17 | FileCheck %s
+
+double a(double) noexcept;
+int b(double (&)(double));
+
+// CHECK: call i32 @_Z1bRFddE(double (double)* @_Z1ad)
+int c = b(a);
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -4372,7 +4372,8 @@
QualType OrigT1, QualType OrigT2,
bool &DerivedToBase,
bool &ObjCConversion,
-   bool &ObjCLifetimeConversion) {
+   bool &ObjCLifetimeConversion,
+   bool &FunctionConversion) {
   assert(!OrigT1->isReferenceType() &&
 "T1 must be the pointee type of the reference type");
   assert(!OrigT2->isReferenceType() && "T2 cannot be a reference type");
@@ -4402,15 +4403,16 @@
Context.canBindObjCObjectType(UnqualT1, UnqualT2))
 ObjCConversion = true;
   else if (UnqualT2->isFunctionType() &&
-   IsFunctionConversion(UnqualT2, UnqualT1, ConvertedT2))
+   IsFunctionConversion(UnqualT2, UnqualT1, ConvertedT2)) {
 // C++1z [dcl.init.ref]p4:
 //   cv1 T1" is reference-compatible with "cv2 T2" if [...] T2 is "noexcept
 //   function" and T1 is "function"
 //
 // We extend this to also apply to 'noreturn', so allow any function
 // conversion between function types.
+FunctionConversion = true;
 return Ref_Compatible;
-  else
+  } else
 return Ref_Incompatible;
 
   // At this point, we know that T1 and T2 are reference-related (at
@@ -4491,6 +4493,7 @@
   bool DerivedToBase = false;
   bool ObjCConversion = false;
   bool ObjCLifetimeConversion = false;
+  bool FunctionConversion = false;
 
   // If we are initializing an rvalue reference, don't permit conversion
   // functions that return lvalues.
@@ -4503,12 +4506,13 @@
 
   if (!ConvTemplate &&
   S.CompareReferenceRelationship(
-DeclLoc,
-Conv->getConversionType().getNonReferenceType()
-  .getUnqualifiedType(),
-DeclType.getNonReferenceType().getUnqualifiedType(),
-DerivedToBase, ObjCConversion, ObjCLifetimeConversion) ==
-  Sema::Ref_Incompatible)
+  DeclLoc,
+  Conv->getConversionType()
+  .getNonReferenceType()
+  .getUnqualifiedType(),
+  DeclType.getNonReferenceType().getUnqualifiedType(),
+  DerivedToBase, ObjCConversion, ObjCLifetimeConversion,
+  FunctionConversion) == Sema::Ref_Incompatible)
 continue;
 } else {
   // If the conversion function doesn't return a reference type,
@@ -4612,11 +4616,11 @@
   bool DerivedToBase = false;
   bool ObjCConversion = false;
   bool ObjCLifetimeConversion = false;
+  bool FunctionConversion = false;
   Expr::Classification InitCategory = Init->Classify(S.Context);
-  Sema::ReferenceCompareResult RefRelationship
-= S.CompareReferenceRelationship(DeclLoc, T1, T2, DerivedToBase,
- ObjCConversion, ObjCLifetimeConversion);
-
+  Sema::ReferenceCompareResult RefRelationship = S.CompareReferenceRelationship(
+  DeclLoc, T1, T2, DerivedToBase, ObjCConversion, ObjCLifetimeConversion,
+  FunctionConversion);
 
   // C++0x [dcl.init.ref]p5:
   //   A reference to type "cv1 T1" is initialized by an expression
@@ -5041,9 +5045,10 @@
   bool dummy1 = false;
   bool dummy2 = false;
   bool dummy3 = false;
+  bool dummy4 = false;
   Sema::ReferenceCompareResult RefRelationship =
   S.CompareReferenceRelationship(From->getBeginLoc(), T1, T2, dummy1,
- dummy2, dummy3);
+ dummy2, dummy3, dummy4);
 
   if (RefRelationship >= Sema::Ref_Related) {
 return TryReferenceInit(S, Init, ToType, /*FIXME*/ From->getBeginLoc(),
Index: clang/lib/Sema/SemaInit.cpp
=

r375313 - Sema: Create a no-op implicit cast for lvalue function conversions.

2019-10-18 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Fri Oct 18 17:34:54 2019
New Revision: 375313

URL: http://llvm.org/viewvc/llvm-project?rev=375313&view=rev
Log:
Sema: Create a no-op implicit cast for lvalue function conversions.

This fixes an assertion failure in the case where an implicit conversion for a
function call involves an lvalue function conversion, and makes the AST for
initializations involving implicit lvalue function conversions more accurate.

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

Added:
cfe/trunk/test/CodeGenCXX/implicit-function-conversion.cpp
Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaCast.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=375313&r1=375312&r2=375313&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri Oct 18 17:34:54 2019
@@ -10419,11 +10419,11 @@ public:
 Ref_Compatible
   };
 
-  ReferenceCompareResult CompareReferenceRelationship(SourceLocation Loc,
-  QualType T1, QualType T2,
-  bool &DerivedToBase,
-  bool &ObjCConversion,
-bool &ObjCLifetimeConversion);
+  ReferenceCompareResult
+  CompareReferenceRelationship(SourceLocation Loc, QualType T1, QualType T2,
+   bool &DerivedToBase, bool &ObjCConversion,
+   bool &ObjCLifetimeConversion,
+   bool &FunctionConversion);
 
   ExprResult checkUnknownAnyCast(SourceRange TypeRange, QualType CastType,
  Expr *CastExpr, CastKind &CastKind,

Modified: cfe/trunk/lib/Sema/SemaCast.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCast.cpp?rev=375313&r1=375312&r2=375313&view=diff
==
--- cfe/trunk/lib/Sema/SemaCast.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCast.cpp Fri Oct 18 17:34:54 2019
@@ -1304,6 +1304,7 @@ TryCastResult TryLValueToRValueCast(Sema
   bool DerivedToBase;
   bool ObjCConversion;
   bool ObjCLifetimeConversion;
+  bool FunctionConversion;
   QualType FromType = SrcExpr->getType();
   QualType ToType = R->getPointeeType();
   if (CStyle) {
@@ -1313,7 +1314,7 @@ TryCastResult TryLValueToRValueCast(Sema
 
   Sema::ReferenceCompareResult RefResult = Self.CompareReferenceRelationship(
   SrcExpr->getBeginLoc(), ToType, FromType, DerivedToBase, ObjCConversion,
-  ObjCLifetimeConversion);
+  ObjCLifetimeConversion, FunctionConversion);
   if (RefResult != Sema::Ref_Compatible) {
 if (CStyle || RefResult == Sema::Ref_Incompatible)
   return TC_NotApplicable;

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=375313&r1=375312&r2=375313&view=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Fri Oct 18 17:34:54 2019
@@ -5852,20 +5852,21 @@ QualType Sema::CXXCheckConditionalOperan
   LVK == RVK && LVK != VK_RValue) {
 // DerivedToBase was already handled by the class-specific case above.
 // FIXME: Should we allow ObjC conversions here?
-bool DerivedToBase, ObjCConversion, ObjCLifetimeConversion;
-if (CompareReferenceRelationship(
-QuestionLoc, LTy, RTy, DerivedToBase,
-ObjCConversion, ObjCLifetimeConversion) == Ref_Compatible &&
+bool DerivedToBase, ObjCConversion, ObjCLifetimeConversion,
+FunctionConversion;
+if (CompareReferenceRelationship(QuestionLoc, LTy, RTy, DerivedToBase,
+ ObjCConversion, ObjCLifetimeConversion,
+ FunctionConversion) == Ref_Compatible &&
 !DerivedToBase && !ObjCConversion && !ObjCLifetimeConversion &&
 // [...] subject to the constraint that the reference must bind
 // directly [...]
-!RHS.get()->refersToBitField() &&
-!RHS.get()->refersToVectorElement()) {
+!RHS.get()->refersToBitField() && !RHS.get()->refersToVectorElement()) 
{
   RHS = ImpCastExprToType(RHS.get(), LTy, CK_NoOp, RVK);
   RTy = RHS.get()->getType();
 } else if (CompareReferenceRelationship(
-   QuestionLoc, RTy, LTy, DerivedToBase,
-   ObjCConversion, ObjCLifetimeConversion) == Ref_Compatible &&
+   QuestionLoc, RTy, LTy, DerivedToBase, ObjCConversion,
+   ObjCLifetimeConversion,
+   Funct

[PATCH] D68818: [hip][cuda] Fix the extended lambda name mangling issue.

2019-10-18 Thread Michael Liao via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG243ebfba17da: [hip][cuda] Fix the extended lambda name 
mangling issue. (authored by hliao).

Changed prior to commit:
  https://reviews.llvm.org/D68818?vs=225678&id=225720#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68818

Files:
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CodeGenCUDA/unnamed-types.cu

Index: clang/test/CodeGenCUDA/unnamed-types.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/unnamed-types.cu
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -std=c++11 -x hip -triple x86_64-linux-gnu -aux-triple amdgcn-amd-amdhsa -emit-llvm %s -o - | FileCheck %s --check-prefix=HOST
+// RUN: %clang_cc1 -std=c++11 -x hip -triple amdgcn-amd-amdhsa -fcuda-is-device -emit-llvm %s -o - | FileCheck %s --check-prefix=DEVICE
+
+#include "Inputs/cuda.h"
+
+// HOST: @0 = private unnamed_addr constant [43 x i8] c"_Z2k0IZZ2f1PfENKUlS0_E_clES0_EUlfE_EvS0_T_\00", align 1
+
+__device__ float d0(float x) {
+  return [](float x) { return x + 2.f; }(x);
+}
+
+__device__ float d1(float x) {
+  return [](float x) { return x * 2.f; }(x);
+}
+
+// DEVICE: amdgpu_kernel void @_Z2k0IZZ2f1PfENKUlS0_E_clES0_EUlfE_EvS0_T_(
+template 
+__global__ void k0(float *p, F f) {
+  p[0] = f(p[0]) + d0(p[1]) + d1(p[2]);
+}
+
+void f0(float *p) {
+  [](float *p) {
+*p = 1.f;
+  }(p);
+}
+
+// The inner/outer lambdas are required to be mangled following ODR but their
+// linkages are still required to keep the original `internal` linkage.
+
+// HOST: define internal void @_ZZ2f1PfENKUlS_E_clES_(
+// DEVICE: define internal float @_ZZZ2f1PfENKUlS_E_clES_ENKUlfE_clEf(
+void f1(float *p) {
+  [](float *p) {
+k0<<<1,1>>>(p, [] __device__ (float x) { return x + 1.f; });
+  }(p);
+}
+// HOST: @__hip_register_globals
+// HOST: __hipRegisterFunction{{.*}}@_Z2k0IZZ2f1PfENKUlS0_E_clES0_EUlfE_EvS0_T_{{.*}}@0
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -6224,6 +6224,7 @@
 Record->push_back(Lambda.CaptureDefault);
 Record->push_back(Lambda.NumCaptures);
 Record->push_back(Lambda.NumExplicitCaptures);
+Record->push_back(Lambda.HasKnownInternalLinkage);
 Record->push_back(Lambda.ManglingNumber);
 AddDeclRef(D->getLambdaContextDecl());
 AddTypeSourceInfo(Lambda.MethodTyInfo);
Index: clang/lib/Serialization/ASTReaderDecl.cpp
===
--- clang/lib/Serialization/ASTReaderDecl.cpp
+++ clang/lib/Serialization/ASTReaderDecl.cpp
@@ -1690,6 +1690,7 @@
 Lambda.CaptureDefault = Record.readInt();
 Lambda.NumCaptures = Record.readInt();
 Lambda.NumExplicitCaptures = Record.readInt();
+Lambda.HasKnownInternalLinkage = Record.readInt();
 Lambda.ManglingNumber = Record.readInt();
 Lambda.ContextDecl = ReadDeclID();
 Lambda.Captures = (Capture *)Reader.getContext().Allocate(
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -11497,17 +11497,18 @@
 E->getCaptureDefault());
   getDerived().transformedLocalDecl(OldClass, {Class});
 
-  Optional> Mangling;
+  Optional> Mangling;
   if (getDerived().ReplacingOriginal())
-Mangling = std::make_pair(OldClass->getLambdaManglingNumber(),
-  OldClass->getLambdaContextDecl());
+Mangling = std::make_tuple(OldClass->getLambdaManglingNumber(),
+   OldClass->hasKnownLambdaInternalLinkage(),
+   OldClass->getLambdaContextDecl());
 
   // Build the call operator.
   CXXMethodDecl *NewCallOperator = getSema().startLambdaDefinition(
   Class, E->getIntroducerRange(), NewCallOpTSI,
   E->getCallOperator()->getEndLoc(),
   NewCallOpTSI->getTypeLoc().castAs().getParams(),
-  E->getCallOperator()->getConstexprKind(), Mangling);
+  E->getCallOperator()->getConstexprKind());
 
   LSI->CallOperator = NewCallOperator;
 
@@ -11527,6 +11528,9 @@
   getDerived().transformAttrs(E->getCallOperator(), NewCallOperator);
   getDerived().transformedLocalDecl(E->getCallOperator(), {NewCallOperator});
 
+  // Number the lambda for linkage purposes if necessary.
+  getSema().handleLambdaNumbering(Class, NewCallOperator, Mangling);
+
   // Introduce the context of the call operator.
   Sema::ContextRAII SavedContext(getSema(), NewCallOperator,

[PATCH] D69124: [clang][driver] Print compilation phases with indentation.

2019-10-18 Thread Michael Liao via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd7a487adfedb: [clang][driver] Print compilation phases with 
indentation. (authored by hliao).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69124

Files:
  clang/lib/Driver/Driver.cpp


Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1802,23 +1802,36 @@
   return true;
 }
 
+enum {
+  TopLevelAction = 0,
+  HeadSibAction = 1,
+  OtherSibAction = 2,
+};
+
 // Display an action graph human-readably.  Action A is the "sink" node
 // and latest-occuring action. Traversal is in pre-order, visiting the
 // inputs to each action before printing the action itself.
 static unsigned PrintActions1(const Compilation &C, Action *A,
-  std::map &Ids) {
+  std::map &Ids,
+  Twine Indent = {}, int Kind = TopLevelAction) {
   if (Ids.count(A)) // A was already visited.
 return Ids[A];
 
   std::string str;
   llvm::raw_string_ostream os(str);
 
+  auto getSibIndent = [](int K) -> Twine {
+return (K == HeadSibAction) ? "   " : (K == OtherSibAction) ? "|  " : "";
+  };
+
+  Twine SibIndent = Indent + getSibIndent(Kind);
+  int SibKind = HeadSibAction;
   os << Action::getClassName(A->getKind()) << ", ";
   if (InputAction *IA = dyn_cast(A)) {
 os << "\"" << IA->getInputArg().getValue() << "\"";
   } else if (BindArchAction *BIA = dyn_cast(A)) {
 os << '"' << BIA->getArchName() << '"' << ", {"
-   << PrintActions1(C, *BIA->input_begin(), Ids) << "}";
+   << PrintActions1(C, *BIA->input_begin(), Ids, SibIndent, SibKind) << 
"}";
   } else if (OffloadAction *OA = dyn_cast(A)) {
 bool IsFirst = true;
 OA->doOnEachDependence(
@@ -1841,8 +1854,9 @@
 os << ":" << BoundArch;
   os << ")";
   os << '"';
-  os << " {" << PrintActions1(C, A, Ids) << "}";
+  os << " {" << PrintActions1(C, A, Ids, SibIndent, SibKind) << "}";
   IsFirst = false;
+  SibKind = OtherSibAction;
 });
   } else {
 const ActionList *AL = &A->getInputs();
@@ -1850,8 +1864,9 @@
 if (AL->size()) {
   const char *Prefix = "{";
   for (Action *PreRequisite : *AL) {
-os << Prefix << PrintActions1(C, PreRequisite, Ids);
+os << Prefix << PrintActions1(C, PreRequisite, Ids, SibIndent, 
SibKind);
 Prefix = ", ";
+SibKind = OtherSibAction;
   }
   os << "}";
 } else
@@ -1872,9 +1887,13 @@
 }
   }
 
+  auto getSelfIndent = [](int K) -> Twine {
+return (K == HeadSibAction) ? "+- " : (K == OtherSibAction) ? "|- " : "";
+  };
+
   unsigned Id = Ids.size();
   Ids[A] = Id;
-  llvm::errs() << Id << ": " << os.str() << ", "
+  llvm::errs() << Indent + getSelfIndent(Kind) << Id << ": " << os.str() << ", 
"
<< types::getTypeName(A->getType()) << offload_os.str() << "\n";
 
   return Id;


Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1802,23 +1802,36 @@
   return true;
 }
 
+enum {
+  TopLevelAction = 0,
+  HeadSibAction = 1,
+  OtherSibAction = 2,
+};
+
 // Display an action graph human-readably.  Action A is the "sink" node
 // and latest-occuring action. Traversal is in pre-order, visiting the
 // inputs to each action before printing the action itself.
 static unsigned PrintActions1(const Compilation &C, Action *A,
-  std::map &Ids) {
+  std::map &Ids,
+  Twine Indent = {}, int Kind = TopLevelAction) {
   if (Ids.count(A)) // A was already visited.
 return Ids[A];
 
   std::string str;
   llvm::raw_string_ostream os(str);
 
+  auto getSibIndent = [](int K) -> Twine {
+return (K == HeadSibAction) ? "   " : (K == OtherSibAction) ? "|  " : "";
+  };
+
+  Twine SibIndent = Indent + getSibIndent(Kind);
+  int SibKind = HeadSibAction;
   os << Action::getClassName(A->getKind()) << ", ";
   if (InputAction *IA = dyn_cast(A)) {
 os << "\"" << IA->getInputArg().getValue() << "\"";
   } else if (BindArchAction *BIA = dyn_cast(A)) {
 os << '"' << BIA->getArchName() << '"' << ", {"
-   << PrintActions1(C, *BIA->input_begin(), Ids) << "}";
+   << PrintActions1(C, *BIA->input_begin(), Ids, SibIndent, SibKind) << "}";
   } else if (OffloadAction *OA = dyn_cast(A)) {
 bool IsFirst = true;
 OA->doOnEachDependence(
@@ -1841,8 +1854,9 @@
 os << ":" << BoundArch;
   os << ")";
   os << '"';
-  os << " {" << PrintActions1(C, A, Ids) << "}";
+  os << " {" << PrintActions1(C, A, Ids, SibIndent, SibKind) << "}";
   IsFirst = false;
+  SibKind = O

r375310 - [clang][driver] Print compilation phases with indentation.

2019-10-18 Thread Michael Liao via cfe-commits
Author: hliao
Date: Fri Oct 18 17:17:00 2019
New Revision: 375310

URL: http://llvm.org/viewvc/llvm-project?rev=375310&view=rev
Log:
[clang][driver] Print compilation phases with indentation.

Reviewers: tra, sfantao, echristo

Subscribers: cfe-commits

Tags: #clang

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

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

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=375310&r1=375309&r2=375310&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Fri Oct 18 17:17:00 2019
@@ -1802,23 +1802,36 @@ bool Driver::HandleImmediateArgs(const C
   return true;
 }
 
+enum {
+  TopLevelAction = 0,
+  HeadSibAction = 1,
+  OtherSibAction = 2,
+};
+
 // Display an action graph human-readably.  Action A is the "sink" node
 // and latest-occuring action. Traversal is in pre-order, visiting the
 // inputs to each action before printing the action itself.
 static unsigned PrintActions1(const Compilation &C, Action *A,
-  std::map &Ids) {
+  std::map &Ids,
+  Twine Indent = {}, int Kind = TopLevelAction) {
   if (Ids.count(A)) // A was already visited.
 return Ids[A];
 
   std::string str;
   llvm::raw_string_ostream os(str);
 
+  auto getSibIndent = [](int K) -> Twine {
+return (K == HeadSibAction) ? "   " : (K == OtherSibAction) ? "|  " : "";
+  };
+
+  Twine SibIndent = Indent + getSibIndent(Kind);
+  int SibKind = HeadSibAction;
   os << Action::getClassName(A->getKind()) << ", ";
   if (InputAction *IA = dyn_cast(A)) {
 os << "\"" << IA->getInputArg().getValue() << "\"";
   } else if (BindArchAction *BIA = dyn_cast(A)) {
 os << '"' << BIA->getArchName() << '"' << ", {"
-   << PrintActions1(C, *BIA->input_begin(), Ids) << "}";
+   << PrintActions1(C, *BIA->input_begin(), Ids, SibIndent, SibKind) << 
"}";
   } else if (OffloadAction *OA = dyn_cast(A)) {
 bool IsFirst = true;
 OA->doOnEachDependence(
@@ -1841,8 +1854,9 @@ static unsigned PrintActions1(const Comp
 os << ":" << BoundArch;
   os << ")";
   os << '"';
-  os << " {" << PrintActions1(C, A, Ids) << "}";
+  os << " {" << PrintActions1(C, A, Ids, SibIndent, SibKind) << "}";
   IsFirst = false;
+  SibKind = OtherSibAction;
 });
   } else {
 const ActionList *AL = &A->getInputs();
@@ -1850,8 +1864,9 @@ static unsigned PrintActions1(const Comp
 if (AL->size()) {
   const char *Prefix = "{";
   for (Action *PreRequisite : *AL) {
-os << Prefix << PrintActions1(C, PreRequisite, Ids);
+os << Prefix << PrintActions1(C, PreRequisite, Ids, SibIndent, 
SibKind);
 Prefix = ", ";
+SibKind = OtherSibAction;
   }
   os << "}";
 } else
@@ -1872,9 +1887,13 @@ static unsigned PrintActions1(const Comp
 }
   }
 
+  auto getSelfIndent = [](int K) -> Twine {
+return (K == HeadSibAction) ? "+- " : (K == OtherSibAction) ? "|- " : "";
+  };
+
   unsigned Id = Ids.size();
   Ids[A] = Id;
-  llvm::errs() << Id << ": " << os.str() << ", "
+  llvm::errs() << Indent + getSelfIndent(Kind) << Id << ": " << os.str() << ", 
"
<< types::getTypeName(A->getType()) << offload_os.str() << "\n";
 
   return Id;


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


r375309 - [hip][cuda] Fix the extended lambda name mangling issue.

2019-10-18 Thread Michael Liao via cfe-commits
Author: hliao
Date: Fri Oct 18 17:15:19 2019
New Revision: 375309

URL: http://llvm.org/viewvc/llvm-project?rev=375309&view=rev
Log:
[hip][cuda] Fix the extended lambda name mangling issue.

Summary:
- HIP/CUDA host side needs to use device kernel symbol name to match the
  device side binaries. Without a consistent naming between host- and
  device-side compilations, it's risky that wrong device binaries are
  executed. Consistent naming is usually not an issue until unnamed
  types are used, especially the lambda. In this patch, the consistent
  name mangling is addressed for the extended lambdas, i.e. the lambdas
  annotated with `__device__`.
- In [Itanium C++ ABI][1], the mangling of the lambda is generally
  unspecified unless, in certain cases, ODR rule is required to ensure
  consisent naming cross TUs. The extended lambda is such a case as its
  name may be part of a device kernel function, e.g., the extended
  lambda is used as a template argument and etc. Thus, we need to force
  ODR for extended lambdas as they are referenced in both device- and
  host-side TUs. Furthermore, if a extended lambda is nested in other
  (extended or not) lambdas, those lambdas are required to follow ODR
  naming as well. This patch revises the current lambda mangle numbering
  to force ODR from an extended lambda to all its parent lambdas.
- On the other side, the aforementioned ODR naming should not change
  those lambdas' original linkages, i.e., we cannot replace the original
  `internal` with `linkonce_odr`; otherwise, we may violate ODR in
  general. This patch introduces a new field `HasKnownInternalLinkage`
  in lambda data to decouple the current linkage calculation based on
  mangling number assigned.

[1]: https://itanium-cxx-abi.github.io/cxx-abi/abi.html

Reviewers: tra, rsmith, yaxunl, martong, shafik

Subscribers: cfe-commits

Tags: #clang

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

Added:
cfe/trunk/test/CodeGenCUDA/unnamed-types.cu
Modified:
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/Sema/SemaLambda.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=375309&r1=375308&r2=375309&view=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Fri Oct 18 17:15:19 2019
@@ -389,9 +389,12 @@ class CXXRecordDecl : public RecordDecl
 /// The number of explicit captures in this lambda.
 unsigned NumExplicitCaptures : 13;
 
+/// Has known `internal` linkage.
+unsigned HasKnownInternalLinkage : 1;
+
 /// The number used to indicate this lambda expression for name
 /// mangling in the Itanium C++ ABI.
-unsigned ManglingNumber = 0;
+unsigned ManglingNumber : 31;
 
 /// The declaration that provides context for this lambda, if the
 /// actual DeclContext does not suffice. This is used for lambdas that
@@ -406,12 +409,12 @@ class CXXRecordDecl : public RecordDecl
 /// The type of the call method.
 TypeSourceInfo *MethodTyInfo;
 
-LambdaDefinitionData(CXXRecordDecl *D, TypeSourceInfo *Info,
- bool Dependent, bool IsGeneric,
- LambdaCaptureDefault CaptureDefault)
-  : DefinitionData(D), Dependent(Dependent), IsGenericLambda(IsGeneric),
-CaptureDefault(CaptureDefault), NumCaptures(0), NumExplicitCaptures(0),
-MethodTyInfo(Info) {
+LambdaDefinitionData(CXXRecordDecl *D, TypeSourceInfo *Info, bool 
Dependent,
+ bool IsGeneric, LambdaCaptureDefault CaptureDefault)
+: DefinitionData(D), Dependent(Dependent), IsGenericLambda(IsGeneric),
+  CaptureDefault(CaptureDefault), NumCaptures(0),
+  NumExplicitCaptures(0), HasKnownInternalLinkage(0), 
ManglingNumber(0),
+  MethodTyInfo(Info) {
   IsLambda = true;
 
   // C++1z [expr.prim.lambda]p4:
@@ -1705,6 +1708,13 @@ public:
 return getLambdaData().ManglingNumber;
   }
 
+  /// The lambda is known to has internal linkage no matter whether it has name
+  /// mangling number.
+  bool hasKnownLambdaInternalLinkage() const {
+assert(isLambda() && "Not a lambda closure type!");
+return getLambdaData().HasKnownInternalLinkage;
+  }
+
   /// Retrieve the declaration that provides additional context for a
   /// lambda, when the normal declaration context is not specific enough.
   ///
@@ -1718,9 +1728,12 @@ public:
 
   /// Set the mangling number and context declaration for a lambda
   /// class.
-  void setLambdaMangling(unsigned ManglingNumber, Decl *ContextDecl) {
+  void setLambdaMangling(unsigned ManglingNumber

r375308 - [analyzer] Specify the C++ standard in more tests.

2019-10-18 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Fri Oct 18 17:08:17 2019
New Revision: 375308

URL: http://llvm.org/viewvc/llvm-project?rev=375308&view=rev
Log:
[analyzer] Specify the C++ standard in more tests.

Makes life easier for downstream developers with different default standard.

Modified:
cfe/trunk/test/Analysis/cast-value-logic.cpp
cfe/trunk/test/Analysis/cast-value-notes.cpp
cfe/trunk/test/Analysis/cast-value-state-dump.cpp
cfe/trunk/test/Analysis/ctu-different-triples.cpp
cfe/trunk/test/Analysis/ctu-main.cpp
cfe/trunk/test/Analysis/ctu-unknown-parts-in-triples.cpp
cfe/trunk/test/Analysis/deadstores-driverkit.cpp
cfe/trunk/test/Analysis/diagnostics/dtors.cpp
cfe/trunk/test/Analysis/domtest.cpp
cfe/trunk/test/Analysis/explain-svals.cpp
cfe/trunk/test/Analysis/initialization.cpp
cfe/trunk/test/Analysis/inlining/placement-new-fp-suppression.cpp
cfe/trunk/test/Analysis/inner-pointer.cpp
cfe/trunk/test/Analysis/malloc.mm
cfe/trunk/test/Analysis/mig.mm
cfe/trunk/test/Analysis/new-ctor-null-throw.cpp
cfe/trunk/test/Analysis/new-ctor-null.cpp
cfe/trunk/test/Analysis/osobject-retain-release.cpp
cfe/trunk/test/Analysis/osobjectcstylecastchecker_test.cpp
cfe/trunk/test/Analysis/plist-macros-with-expansion.cpp
cfe/trunk/test/Analysis/ptr-iter.cpp
cfe/trunk/test/Analysis/ptr-sort.cpp
cfe/trunk/test/Analysis/rvo.cpp
cfe/trunk/test/Analysis/sizeofpack.cpp
cfe/trunk/test/Analysis/stack-frame-context-revision.cpp
cfe/trunk/test/Analysis/temporaries.mm
cfe/trunk/test/Analysis/test-separate-retaincount.cpp
cfe/trunk/test/Analysis/track-control-dependency-conditions.cpp
cfe/trunk/test/Analysis/unions.cpp

Modified: cfe/trunk/test/Analysis/cast-value-logic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/cast-value-logic.cpp?rev=375308&r1=375307&r2=375308&view=diff
==
--- cfe/trunk/test/Analysis/cast-value-logic.cpp (original)
+++ cfe/trunk/test/Analysis/cast-value-logic.cpp Fri Oct 18 17:08:17 2019
@@ -1,4 +1,4 @@
-// RUN: %clang_analyze_cc1 \
+// RUN: %clang_analyze_cc1 -std=c++14 \
 // RUN:  
-analyzer-checker=core,apiModeling.llvm.CastValue,debug.ExprInspection\
 // RUN:  -verify %s
 

Modified: cfe/trunk/test/Analysis/cast-value-notes.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/cast-value-notes.cpp?rev=375308&r1=375307&r2=375308&view=diff
==
--- cfe/trunk/test/Analysis/cast-value-notes.cpp (original)
+++ cfe/trunk/test/Analysis/cast-value-notes.cpp Fri Oct 18 17:08:17 2019
@@ -1,4 +1,4 @@
-// RUN: %clang_analyze_cc1 \
+// RUN: %clang_analyze_cc1 -std=c++14 \
 // RUN:  
-analyzer-checker=core,apiModeling.llvm.CastValue,debug.ExprInspection\
 // RUN:  -analyzer-output=text -verify %s
 

Modified: cfe/trunk/test/Analysis/cast-value-state-dump.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/cast-value-state-dump.cpp?rev=375308&r1=375307&r2=375308&view=diff
==
--- cfe/trunk/test/Analysis/cast-value-state-dump.cpp (original)
+++ cfe/trunk/test/Analysis/cast-value-state-dump.cpp Fri Oct 18 17:08:17 2019
@@ -1,4 +1,4 @@
-// RUN: %clang_analyze_cc1 \
+// RUN: %clang_analyze_cc1 -std=c++14 \
 // RUN:  
-analyzer-checker=core,apiModeling.llvm.CastValue,debug.ExprInspection\
 // RUN:  -analyzer-output=text -verify %s 2>&1 | FileCheck %s
 

Modified: cfe/trunk/test/Analysis/ctu-different-triples.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/ctu-different-triples.cpp?rev=375308&r1=375307&r2=375308&view=diff
==
--- cfe/trunk/test/Analysis/ctu-different-triples.cpp (original)
+++ cfe/trunk/test/Analysis/ctu-different-triples.cpp Fri Oct 18 17:08:17 2019
@@ -1,9 +1,9 @@
 // RUN: rm -rf %t && mkdir %t
 // RUN: mkdir -p %t/ctudir
-// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu \
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-pc-linux-gnu \
 // RUN:   -emit-pch -o %t/ctudir/ctu-other.cpp.ast %S/Inputs/ctu-other.cpp
 // RUN: cp %S/Inputs/ctu-other.cpp.externalDefMap.txt 
%t/ctudir/externalDefMap.txt
-// RUN: %clang_analyze_cc1 -triple powerpc64-montavista-linux-gnu \
+// RUN: %clang_analyze_cc1 -std=c++14 -triple powerpc64-montavista-linux-gnu \
 // RUN:   -analyzer-checker=core,debug.ExprInspection \
 // RUN:   -analyzer-config experimental-enable-naive-ctu-analysis=true \
 // RUN:   -analyzer-config ctu-dir=%t/ctudir \

Modified: cfe/trunk/test/Analysis/ctu-main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/ctu-main.cpp?rev=375308&r1=375307&r2=375308&view=diff
==
--- cfe/trunk/test/Analysis/ctu-main.cpp (original)
+++ cfe/trunk/test/Analysis/ctu-main.

r375306 - [c++20] Add rewriting from comparison operators to <=> / ==.

2019-10-18 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Oct 18 17:04:43 2019
New Revision: 375306

URL: http://llvm.org/viewvc/llvm-project?rev=375306&view=rev
Log:
[c++20] Add rewriting from comparison operators to <=> / ==.

This adds support for rewriting <, >, <=, and >= to a normal or reversed
call to operator<=>, for rewriting != to a normal or reversed call to
operator==, and for rewriting <=> and == to reversed forms of those same
operators.

Note that this is a breaking change for various C++17 code patterns,
including some in use in LLVM. The most common patterns (where an
operator== becomes ambiguous with a reversed form of itself) are still
accepted under this patch, as an extension (with a warning). I'm hopeful
that we can get the language rules fixed before C++20 ships, and the
extension warning is aimed primarily at providing data to inform that
decision.

Added:

cfe/trunk/test/CXX/over/over.match/over.match.funcs/over.match.oper/p3-2a.cpp

cfe/trunk/test/CXX/over/over.match/over.match.funcs/over.match.oper/p8-2a.cpp

cfe/trunk/test/CXX/over/over.match/over.match.funcs/over.match.oper/p9-2a.cpp
cfe/trunk/test/CodeGenCXX/mangle-cxx2a.cpp
Modified:
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Basic/OperatorKinds.h
cfe/trunk/include/clang/Sema/Overload.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/ExprCXX.cpp
cfe/trunk/lib/Frontend/FrontendActions.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/test/CXX/temp/temp.fct.spec/temp.deduct/p7.cpp
cfe/trunk/test/PCH/cxx2a-compare.cpp
cfe/trunk/test/SemaCXX/compare-cxx2a.cpp
cfe/trunk/test/SemaCXX/self-comparison.cpp
cfe/trunk/www/cxx_status.html

Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=375306&r1=375305&r2=375306&view=diff
==
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Fri Oct 18 17:04:43 2019
@@ -220,6 +220,40 @@ public:
   }
 };
 
+/// Represents a call to a CUDA kernel function.
+class CUDAKernelCallExpr final : public CallExpr {
+  friend class ASTStmtReader;
+
+  enum { CONFIG, END_PREARG };
+
+  // CUDAKernelCallExpr has some trailing objects belonging
+  // to CallExpr. See CallExpr for the details.
+
+  CUDAKernelCallExpr(Expr *Fn, CallExpr *Config, ArrayRef Args,
+ QualType Ty, ExprValueKind VK, SourceLocation RP,
+ unsigned MinNumArgs);
+
+  CUDAKernelCallExpr(unsigned NumArgs, EmptyShell Empty);
+
+public:
+  static CUDAKernelCallExpr *Create(const ASTContext &Ctx, Expr *Fn,
+CallExpr *Config, ArrayRef Args,
+QualType Ty, ExprValueKind VK,
+SourceLocation RP, unsigned MinNumArgs = 
0);
+
+  static CUDAKernelCallExpr *CreateEmpty(const ASTContext &Ctx,
+ unsigned NumArgs, EmptyShell Empty);
+
+  const CallExpr *getConfig() const {
+return cast_or_null(getPreArg(CONFIG));
+  }
+  CallExpr *getConfig() { return cast_or_null(getPreArg(CONFIG)); }
+
+  static bool classof(const Stmt *T) {
+return T->getStmtClass() == CUDAKernelCallExprClass;
+  }
+};
+
 /// A rewritten comparison expression that was originally written using
 /// operator syntax.
 ///
@@ -310,40 +344,6 @@ public:
   }
 };
 
-/// Represents a call to a CUDA kernel function.
-class CUDAKernelCallExpr final : public CallExpr {
-  friend class ASTStmtReader;
-
-  enum { CONFIG, END_PREARG };
-
-  // CUDAKernelCallExpr has some trailing objects belonging
-  // to CallExpr. See CallExpr for the details.
-
-  CUDAKernelCallExpr(Expr *Fn, CallExpr *Config, ArrayRef Args,
- QualType Ty, ExprValueKind VK, SourceLocation RP,
- unsigned MinNumArgs);
-
-  CUDAKernelCallExpr(unsigned NumArgs, EmptyShell Empty);
-
-public:
-  static CUDAKernelCallExpr *Create(const ASTContext &Ctx, Expr *Fn,
-CallExpr *Config, ArrayRef Args,
-QualType Ty, ExprValueKind VK,
-SourceLocation RP, unsigned MinNumArgs = 
0);
-
-  static CUDAKernelCallExpr *CreateEmpty(const ASTContext &Ctx,
- unsigned NumArgs, EmptyShell Empty);
-
-  const CallExpr *getConfig() const {
-return cast_or_null(getPreArg(CONFIG));
-  }
-  CallExpr *getConfig() { return cast_or_null(getPreArg(CONFIG)); }
-
-  static bool classof(const Stmt *T) {
-return T->getStmtClass() == CUDAKernelCallExprClass;
-  }
-};
-
 /// Abstract class common to all of the C++ "named"

r375305 - [c++20] Add CXXRewrittenBinaryOperator to represent a comparison

2019-10-18 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Oct 18 17:04:38 2019
New Revision: 375305

URL: http://llvm.org/viewvc/llvm-project?rev=375305&view=rev
Log:
[c++20] Add CXXRewrittenBinaryOperator to represent a comparison
operator that is rewritten as a call to multiple other operators.

No functionality change yet: nothing creates these expressions.

Modified:
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/include/clang/Basic/StmtNodes.td
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/AST/ExprCXX.cpp
cfe/trunk/lib/AST/ExprClassification.cpp
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprAgg.cpp
cfe/trunk/lib/CodeGen/CGExprComplex.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/Sema/SemaExceptionSpec.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/tools/libclang/CXCursor.cpp

Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=375305&r1=375304&r2=375305&view=diff
==
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Fri Oct 18 17:04:38 2019
@@ -220,6 +220,96 @@ public:
   }
 };
 
+/// A rewritten comparison expression that was originally written using
+/// operator syntax.
+///
+/// In C++20, the following rewrites are performed:
+/// - a == b -> b == a
+/// - a != b -> !(a == b)
+/// - a != b -> !(b == a)
+/// - For \c \@ in \c <, \c <=, \c >, \c >=, \c <=>:
+///   - a @ b -> (a <=> b) @ 0
+///   - a @ b -> 0 @ (b <=> a)
+///
+/// This expression provides access to both the original syntax and the
+/// rewritten expression.
+///
+/// Note that the rewritten calls to \c ==, \c <=>, and \c \@ are typically
+/// \c CXXOperatorCallExprs, but could theoretically be \c BinaryOperators.
+class CXXRewrittenBinaryOperator : public Expr {
+  friend class ASTStmtReader;
+
+  /// The rewritten semantic form.
+  Stmt *SemanticForm;
+
+public:
+  CXXRewrittenBinaryOperator(Expr *SemanticForm, bool IsReversed)
+  : Expr(CXXRewrittenBinaryOperatorClass, SemanticForm->getType(),
+ SemanticForm->getValueKind(), SemanticForm->getObjectKind(),
+ SemanticForm->isTypeDependent(), SemanticForm->isValueDependent(),
+ SemanticForm->isInstantiationDependent(),
+ SemanticForm->containsUnexpandedParameterPack()),
+SemanticForm(SemanticForm) {
+CXXRewrittenBinaryOperatorBits.IsReversed = IsReversed;
+  }
+  CXXRewrittenBinaryOperator(EmptyShell Empty)
+  : Expr(CXXRewrittenBinaryOperatorClass, Empty), SemanticForm() {}
+
+  /// Get an equivalent semantic form for this expression.
+  Expr *getSemanticForm() { return cast(SemanticForm); }
+  const Expr *getSemanticForm() const { return cast(SemanticForm); }
+
+  struct DecomposedForm {
+/// The original opcode, prior to rewriting.
+BinaryOperatorKind Opcode;
+/// The original left-hand side.
+const Expr *LHS;
+/// The original right-hand side.
+const Expr *RHS;
+/// The inner \c == or \c <=> operator expression.
+const Expr *InnerBinOp;
+  };
+
+  /// Decompose this operator into its syntactic form.
+  DecomposedForm getDecomposedForm() const LLVM_READONLY;
+
+  /// Determine whether this expression was rewritten in reverse form.
+  bool isReversed() const { return CXXRewrittenBinaryOperatorBits.IsReversed; }
+
+  BinaryOperatorKind getOperator() const { return getDecomposedForm().Opcode; }
+  const Expr *getLHS() const { return getDecomposedForm().LHS; }
+  const Expr *getRHS() const { return getDecomposedForm().RHS; }
+
+  SourceLocation getOperatorLoc() const LLVM_READONLY {
+return getDecomposedForm().InnerBinOp->getExprLoc();
+  }
+  SourceLocation getExprLoc() const LLVM_READONLY { return getOperatorLoc(); }
+
+  /// Compute the begin and end locations from the decomposed form.
+  /// The locations of the semantic form are not reliable if this is
+  /// a reversed expression.
+  //@{
+  SourceLocation getBeginLoc() const LLVM_READONLY {
+return getDecomposedForm().LHS->getBeginLoc();
+  }
+  SourceLocation getEndLoc() const LLVM_READONLY {
+return getDecomposedForm().RHS->getEndLoc();
+  }
+  SourceRange getSourceRange() const LLVM_READONLY {
+DecomposedForm DF = getDecomposedForm();
+return SourceRange(DF.LHS->getBeginLoc(), DF.RHS->getEndLoc());
+  }
+  //@}
+
+  child_range children() {
+return child_range(&SemanticForm, &

[PATCH] D63031: DebugInfo: Render the canonical name of a class template specialization, even when nested in another class template specialization

2019-10-18 Thread David Blaikie via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9fdd09a4ccd0: DebugInfo: Render the canonical name of a 
class template specialization, even… (authored by dblaikie).

Changed prior to commit:
  https://reviews.llvm.org/D63031?vs=203639&id=225718#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63031

Files:
  clang/lib/AST/TypePrinter.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp


Index: clang/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp
===
--- clang/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp
+++ clang/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp
@@ -105,7 +105,12 @@
 };
 extern template class j;
 j jj;
+template 
+struct j_wrap {
+};
+j_wrap> j_wrap_j;
 // CHECK: DICompositeType(tag: DW_TAG_structure_type, name: "j"
+// CHECK: DICompositeType(tag: DW_TAG_structure_type, name: "j_wrap >"
 
 template 
 struct k {
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -314,7 +314,9 @@
   if (isa(RD)) {
 SmallString<128> Name;
 llvm::raw_svector_ostream OS(Name);
-RD->getNameForDiagnostic(OS, getPrintingPolicy(),
+PrintingPolicy PP = getPrintingPolicy();
+PP.PrintCanonicalTypes = true;
+RD->getNameForDiagnostic(OS, PP,
  /*Qualified*/ false);
 
 // Copy this name on the side and use its reference.
Index: clang/lib/AST/TypePrinter.cpp
===
--- clang/lib/AST/TypePrinter.cpp
+++ clang/lib/AST/TypePrinter.cpp
@@ -1204,7 +1204,8 @@
   // arguments.
   if (const auto *Spec = dyn_cast(D)) {
 ArrayRef Args;
-if (TypeSourceInfo *TAW = Spec->getTypeAsWritten()) {
+TypeSourceInfo *TAW = Spec->getTypeAsWritten();
+if (!Policy.PrintCanonicalTypes && TAW) {
   const TemplateSpecializationType *TST =
 cast(TAW->getType());
   Args = TST->template_arguments();


Index: clang/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp
===
--- clang/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp
+++ clang/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp
@@ -105,7 +105,12 @@
 };
 extern template class j;
 j jj;
+template 
+struct j_wrap {
+};
+j_wrap> j_wrap_j;
 // CHECK: DICompositeType(tag: DW_TAG_structure_type, name: "j"
+// CHECK: DICompositeType(tag: DW_TAG_structure_type, name: "j_wrap >"
 
 template 
 struct k {
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -314,7 +314,9 @@
   if (isa(RD)) {
 SmallString<128> Name;
 llvm::raw_svector_ostream OS(Name);
-RD->getNameForDiagnostic(OS, getPrintingPolicy(),
+PrintingPolicy PP = getPrintingPolicy();
+PP.PrintCanonicalTypes = true;
+RD->getNameForDiagnostic(OS, PP,
  /*Qualified*/ false);
 
 // Copy this name on the side and use its reference.
Index: clang/lib/AST/TypePrinter.cpp
===
--- clang/lib/AST/TypePrinter.cpp
+++ clang/lib/AST/TypePrinter.cpp
@@ -1204,7 +1204,8 @@
   // arguments.
   if (const auto *Spec = dyn_cast(D)) {
 ArrayRef Args;
-if (TypeSourceInfo *TAW = Spec->getTypeAsWritten()) {
+TypeSourceInfo *TAW = Spec->getTypeAsWritten();
+if (!Policy.PrintCanonicalTypes && TAW) {
   const TemplateSpecializationType *TST =
 cast(TAW->getType());
   Args = TST->template_arguments();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r375304 - DebugInfo: Render the canonical name of a class template specialization, even when nested in another class template specialization

2019-10-18 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Fri Oct 18 16:58:34 2019
New Revision: 375304

URL: http://llvm.org/viewvc/llvm-project?rev=375304&view=rev
Log:
DebugInfo: Render the canonical name of a class template specialization, even 
when nested in another class template specialization

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

Modified:
cfe/trunk/lib/AST/TypePrinter.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp

Modified: cfe/trunk/lib/AST/TypePrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TypePrinter.cpp?rev=375304&r1=375303&r2=375304&view=diff
==
--- cfe/trunk/lib/AST/TypePrinter.cpp (original)
+++ cfe/trunk/lib/AST/TypePrinter.cpp Fri Oct 18 16:58:34 2019
@@ -1204,7 +1204,8 @@ void TypePrinter::printTag(TagDecl *D, r
   // arguments.
   if (const auto *Spec = dyn_cast(D)) {
 ArrayRef Args;
-if (TypeSourceInfo *TAW = Spec->getTypeAsWritten()) {
+TypeSourceInfo *TAW = Spec->getTypeAsWritten();
+if (!Policy.PrintCanonicalTypes && TAW) {
   const TemplateSpecializationType *TST =
 cast(TAW->getType());
   Args = TST->template_arguments();

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=375304&r1=375303&r2=375304&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Oct 18 16:58:34 2019
@@ -314,7 +314,9 @@ StringRef CGDebugInfo::getClassName(cons
   if (isa(RD)) {
 SmallString<128> Name;
 llvm::raw_svector_ostream OS(Name);
-RD->getNameForDiagnostic(OS, getPrintingPolicy(),
+PrintingPolicy PP = getPrintingPolicy();
+PP.PrintCanonicalTypes = true;
+RD->getNameForDiagnostic(OS, PP,
  /*Qualified*/ false);
 
 // Copy this name on the side and use its reference.

Modified: 
cfe/trunk/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp?rev=375304&r1=375303&r2=375304&view=diff
==
--- cfe/trunk/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp 
(original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-template-explicit-specialization.cpp 
Fri Oct 18 16:58:34 2019
@@ -105,7 +105,12 @@ struct j {
 };
 extern template class j;
 j jj;
+template 
+struct j_wrap {
+};
+j_wrap> j_wrap_j;
 // CHECK: DICompositeType(tag: DW_TAG_structure_type, name: "j"
+// CHECK: DICompositeType(tag: DW_TAG_structure_type, name: "j_wrap >"
 
 template 
 struct k {


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


[PATCH] D69171: [clang-fuzzer] Add new fuzzer target for Objective-C

2019-10-18 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse added inline comments.



Comment at: tools/clang-fuzzer/ClangObjectiveCFuzzer.cpp:19
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) { return 0; }
+

Nit:  Since it does nothing, let's omit the `LLVMFuzzerInitialize` definition.



Comment at: tools/clang-fuzzer/ClangObjectiveCFuzzer.cpp:22
+extern "C" int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {
+  std::string s((const char *)data, size);
+  HandleObjC(s, {"-O2"});

Nit: reinterpret_cast



Comment at: tools/clang-fuzzer/handle-objc/handle_objc.cpp:50
+&Diags);
+}
+

Since this is ~identical to handle_cxx, I'd like to reuse the implementation.  
Can we make a more generic function (e.g., `handleLanguage(Language type, 
...)`) and use it for both?


Repository:
  rC Clang

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

https://reviews.llvm.org/D69171



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


[PATCH] D69137: [profile] Do not cache __llvm_profile_get_filename result

2019-10-18 Thread Vedant Kumar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG937241b0d9e8: [profile] Do not cache 
__llvm_profile_get_filename result (authored by vsk).
Herald added projects: clang, Sanitizers.
Herald added subscribers: Sanitizers, cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69137

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/test/Driver/darwin-ld.c
  compiler-rt/lib/profile/InstrProfiling.h
  compiler-rt/lib/profile/InstrProfilingFile.c
  compiler-rt/test/profile/Inputs/instrprof-get-filename-dso.c
  compiler-rt/test/profile/Posix/instrprof-set-filename-shared.test
  compiler-rt/test/profile/instrprof-get-filename-merge-mode.c

Index: compiler-rt/test/profile/instrprof-get-filename-merge-mode.c
===
--- /dev/null
+++ compiler-rt/test/profile/instrprof-get-filename-merge-mode.c
@@ -0,0 +1,18 @@
+// Test __llvm_profile_get_filename when the on-line merging mode is enabled.
+//
+// RUN: %clang_pgogen -dynamiclib -o %t.dso %p/Inputs/instrprof-get-filename-dso.c
+// RUN: %clang_pgogen -o %t %s %t.dso
+// RUN: env LLVM_PROFILE_FILE="%t-%m.profraw" %run %t
+
+#include 
+
+const char *__llvm_profile_get_filename(void);
+extern const char *get_filename_from_DSO(void);
+
+int main(int argc, const char *argv[]) {
+  const char *filename1 = __llvm_profile_get_filename();
+  const char *filename2 = get_filename_from_DSO();
+
+  // Exit with code 1 if the two filenames are the same.
+  return strcmp(filename1, filename2) == 0;
+}
Index: compiler-rt/test/profile/Posix/instrprof-set-filename-shared.test
===
--- compiler-rt/test/profile/Posix/instrprof-set-filename-shared.test
+++ /dev/null
@@ -1,8 +0,0 @@
-# Test that __llvm_profile_set_filename is honored by shared libary too.
-RUN: mkdir -p %t.d
-RUN: %clang_profgen=%t.shared.profraw -fPIC -shared -o %t.d/t.shared %S/../Inputs/instrprof-dlopen-func.c
-RUN: %clang_profgen -DCALL_SHARED -o %t.m -O3 -rpath %t.d %t.d/t.shared %S/../instrprof-set-filename.c
-RUN: %run %t.m %t.main.profraw
-RUN: llvm-profdata show %t.main.profraw | FileCheck --check-prefix=SHARED %s
-
-# SHARED: Total functions: 2
Index: compiler-rt/test/profile/Inputs/instrprof-get-filename-dso.c
===
--- /dev/null
+++ compiler-rt/test/profile/Inputs/instrprof-get-filename-dso.c
@@ -0,0 +1,5 @@
+const char *__llvm_profile_get_filename(void);
+
+const char *get_filename_from_DSO(void) {
+  return __llvm_profile_get_filename();
+}
Index: compiler-rt/lib/profile/InstrProfilingFile.c
===
--- compiler-rt/lib/profile/InstrProfilingFile.c
+++ compiler-rt/lib/profile/InstrProfilingFile.c
@@ -70,7 +70,6 @@
* by runtime. */
   unsigned OwnsFilenamePat;
   const char *ProfilePathPrefix;
-  const char *Filename;
   char PidChars[MAX_PID_SIZE];
   char Hostname[COMPILER_RT_MAX_HOSTLEN];
   unsigned NumPids;
@@ -86,8 +85,8 @@
   ProfileNameSpecifier PNS;
 } lprofFilename;
 
-COMPILER_RT_WEAK lprofFilename lprofCurFilename = {0,   0, 0, 0, {0},
-   {0}, 0, 0, 0, PNS_unknown};
+static lprofFilename lprofCurFilename = {0, 0, 0, {0},{0},
+ 0, 0, 0, PNS_unknown};
 
 static int ProfileMergeRequested = 0;
 static int isProfileMergeRequested() { return ProfileMergeRequested; }
@@ -387,8 +386,6 @@
   /* Clean up cached prefix and filename.  */
   if (lprofCurFilename.ProfilePathPrefix)
 free((void *)lprofCurFilename.ProfilePathPrefix);
-  if (lprofCurFilename.Filename)
-free((void *)lprofCurFilename.Filename);
 
   if (lprofCurFilename.FilenamePat && lprofCurFilename.OwnsFilenamePat) {
 free((void *)lprofCurFilename.FilenamePat);
@@ -602,9 +599,6 @@
   char *FilenameBuf;
   const char *Filename;
 
-  if (lprofCurFilename.Filename)
-return lprofCurFilename.Filename;
-
   Length = getCurFilenameLength();
   FilenameBuf = (char *)malloc(Length + 1);
   if (!FilenameBuf) {
@@ -615,7 +609,6 @@
   if (!Filename)
 return "\0";
 
-  lprofCurFilename.Filename = FilenameBuf;
   return FilenameBuf;
 }
 
Index: compiler-rt/lib/profile/InstrProfiling.h
===
--- compiler-rt/lib/profile/InstrProfiling.h
+++ compiler-rt/lib/profile/InstrProfiling.h
@@ -155,6 +155,10 @@
  *
  * \c Name is not copied, so it must remain valid.  Passing NULL resets the
  * filename logic to the default behaviour.
+ *
+ * Note: There may be multiple copies of the profile runtime (one for each
+ * instrumented image/DSO). This API only modifies the filename within the
+ * copy of the runtime available to the calling image.
  */
 void __llvm_profile_set_filename(const char *Name);
 
@@ -173,6 +177,

r375301 - [profile] Do not cache __llvm_profile_get_filename result

2019-10-18 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Fri Oct 18 16:33:40 2019
New Revision: 375301

URL: http://llvm.org/viewvc/llvm-project?rev=375301&view=rev
Log:
[profile] Do not cache __llvm_profile_get_filename result

When the %m filename pattern is used, the filename is unique to each
image, so the cached value is wrong.

It struck me that the full filename isn't something that's recomputed
often, so perhaps it doesn't need to be cached at all. David Li pointed
out we can go further and just hide lprofCurFilename. This may regress
workflows that depend on using the set-filename API to change filenames
across all loaded DSOs, but this is expected to be very rare.

rdar://55137071

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
cfe/trunk/test/Driver/darwin-ld.c

Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=375301&r1=375300&r2=375301&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Fri Oct 18 16:33:40 2019
@@ -1128,7 +1128,6 @@ void Darwin::addProfileRTLibs(const ArgL
 } else {
   addExportedSymbol(CmdArgs, "___llvm_profile_filename");
   addExportedSymbol(CmdArgs, "___llvm_profile_raw_version");
-  addExportedSymbol(CmdArgs, "_lprofCurFilename");
 }
 addExportedSymbol(CmdArgs, "_lprofDirMode");
   }

Modified: cfe/trunk/test/Driver/darwin-ld.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-ld.c?rev=375301&r1=375300&r2=375301&view=diff
==
--- cfe/trunk/test/Driver/darwin-ld.c (original)
+++ cfe/trunk/test/Driver/darwin-ld.c Fri Oct 18 16:33:40 2019
@@ -355,7 +355,7 @@
 // RUN: FileCheck -check-prefix=PROFILE_EXPORT %s < %t.log
 // RUN: %clang -target x86_64-apple-darwin12 -fprofile-instr-generate -Xlinker 
-exported_symbols_list -Xlinker /dev/null -### %t.o 2> %t.log
 // RUN: FileCheck -check-prefix=PROFILE_EXPORT %s < %t.log
-// PROFILE_EXPORT: "-exported_symbol" "___llvm_profile_filename" 
"-exported_symbol" "___llvm_profile_raw_version" "-exported_symbol" 
"_lprofCurFilename"
+// PROFILE_EXPORT: "-exported_symbol" "___llvm_profile_filename" 
"-exported_symbol" "___llvm_profile_raw_version"
 //
 // RUN: %clang -target x86_64-apple-darwin12 -fprofile-instr-generate 
--coverage -### %t.o 2> %t.log
 // RUN: FileCheck -check-prefix=NO_PROFILE_EXPORT %s < %t.log


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


[PATCH] D69124: [clang][driver] Print compilation phases with indentation.

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

Neat. I like the visual cues showing what gets passed on to the next processing 
stage.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69124



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


[PATCH] D66983: [WebAssembly] Add wasm-specific vector shuffle builtin and intrinsic

2019-10-18 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin added inline comments.



Comment at: llvm/include/llvm/IR/IntrinsicsWebAssembly.td:117
+ llvm_i32_ty, llvm_i32_ty, llvm_i32_ty, llvm_i32_ty, llvm_i32_ty,
+ llvm_i32_ty, llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
+[IntrNoMem, IntrSpeculatable]>;

i32 is bigger than `ImmLaneIdx32`. Should we model this into something smaller, 
like i8? What happens if we specify an index grater than 31? (I think this 
question also applies to other intrinsics and builtins. I don't think it 
matters a lot given than all integers are larger than lane types though.)



Comment at: llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp:1251
+return DAG.getNode(WebAssemblyISD::SHUFFLE, DL, Op.getValueType(), Ops);
+  }
   }

This looks rather straightforward... Can't we do this in TableGen?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66983



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


[PATCH] D69090: [Try 2] Include sanitize blacklist and other extra deps as part of scan-deps output

2019-10-18 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In D69090#1713983 , @kousikk wrote:

> Thanks for the comment @jkorous.
>
> > I think you could've just used CHECK-DAG to fix the tests. It *might* be a 
> > bit more robust. Although just reordering checks seems perfectly fine too. 
> > https://llvm.org/docs/CommandGuide/FileCheck.html#the-check-dag-directive. 
> > Using std::set here sounds reasonable to me but I'd like @arphaman to be 
> > aware of this.
>
> Thanks for pointing me to it - I have a minor preference towards a `sorted` 
> order of outputs vs `order in which we visit the files`. I think a sorted 
> order is much more easy to reason about for a client. Having said that, 
> @arphaman what do you think? If you and Jan both feel that we should maintain 
> the current order, I'll stick to that and not change `Dependencies` to `set`.


Sorting seems reasonable to me, perhaps behind an option (I'll leave that up to 
others).  But you don't need a `std::set` for this, just run `llvm::sort` and 
`std::unique` once the dependencies are collected.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69090



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


[PATCH] D66437: Sema: Create a no-op implicit cast for lvalue function conversions.

2019-10-18 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66437



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


[PATCH] D68117: [DWARF-5] Support for C++11 defaulted, deleted member functions.

2019-10-18 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a subscriber: rsmith.
dblaikie added a comment.

In D68117#1714091 , @SouraVX wrote:

> Hi @probinson @dblaikie  @aprantl , I've was investigating and working on 
> your inputs regarding the problem with DW_at_defaulted once. I think clang 
> has also some issues.


You think clang has bugs, independent of the debug info?

>   Though I'm not able to precisely point out. I ranned into some problems in 
> CFE while marking out_of_class functions. i.e consider this for instance 
> "debug-info-defaulted-out_of_class.cpp" FIXME:.  Causing too much trouble and 
> possibly can introduce some bugs in clang/llvm. 
> 
> May be we'll reconsider this in future. Thanks for putting time in reviewing 
> and discussing this.

Yeah, I looked at it a bit & asked @rsmith for some thoughts. Eventually 
wrapped my head around it.

Clang's codegen occurs during parsing - rather than parsing/AST building 
entirely, then code generating. So to take a smaller example:

  struct foo {
foo();
// virtual
void f1();
void f2();
  };
  void foo::f2() { }
  foo::foo() = default;

Without the virtual keyword, the first time the debug info needs the type (when 
building the description for f1's definition's "this" parameter) the foo::foo() 
= default definition hasn't been parsed yet, so there is no definition of 
foo::foo() available. (so the out of class defaulting isn't visible)

The reason virtual matters is that the actual class definition of 'foo' is 
never built - check the DWARF and metadata, only a declaration of "foo" is 
built. And the declarations of the member functions are injected into the 
declaration as the definitions are parsed, not before - so they observe the 
correct defaulting state.

Another way to show the bug is with -fstandalone-debug, even with a virtual 
function it shows the problem.

And moving 'f2' around (before/after 'foo()') also shows the problem - because 
having f2 first means the type definition (without virtual, or while using 
-fstandalone-debug) is built before any defaulting is seen - so 'foo()' isn't 
shown as defaulted.

All of this somewhat goes to my point - out of line defaulting should be tested 
and recorded on the out of line definition, not on the declaration, of a 
special member.

> Anyway here's the next course of action I'm considering. I'll be marking this 
> review as abandoned. I'll raise a fresh new review for DW_AT_deleted feature, 
> that;s pretty straight forward, considering C++ spec. If it's deleted, it has 
> to be declared/defined{whatever} deleted in it's first declaration. This 
> feature also augments the consumer information regarding which spl member 
> functions are deleted, hence restrict their calling for user or do something 
> useful with this at it's disposal.
> 
> @probinson @dblaikie @aprantl Please share your thoughts/comments inclination 
> regarding adding this DW_AT_deleted to clang/llvm.

Sure, deleted support seems fine/reasonable/good to me.


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

https://reviews.llvm.org/D68117



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


[PATCH] D69088: [Lex] #pragma clang transform

2019-10-18 Thread Hideki Saito via Phabricator via cfe-commits
hsaito added a comment.

In D69088#1715210 , @Meinersbur wrote:

> I'd rather just enable them with a command-line switch, such as 
> `-fexperimental-transform`.


This direction works for me. `-fexperimental-transform-pragma` might be better, 
though.


Repository:
  rC Clang

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

https://reviews.llvm.org/D69088



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


[PATCH] D69184: [libTooling] Introduce general combinator for fixed-value `MatchConsumer`s.

2019-10-18 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added a comment.

What are the use cases for non-text values?

I like the name `text` much better... If the name conflict is the issue, I 
think you could rename it to `toText` -- it would even read more fluently 
`change(toText("abc"))`, also making it obvious that we are not changing *the 
text abc*, but we are changing the code to say "abc".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69184



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


[PATCH] D69088: [Lex] #pragma clang transform

2019-10-18 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

In D69088#1715038 , @hsaito wrote:

> If there is a precedence, just follow that. Else, how to spell an 
> experimental clang pragma would be a good discussion topic by itself. If I 
> need to provide a discussion starter, I'd say how about 
> transform_experimental instead of transform. All I ask is somehow make it 
> easier for programmers to know it is experimental so that they won't use it 
> w/o first reading about the current state of support. I don't have a strong 
> opinion about how to do so.


The precedences I have found are `-fexperimental-pass-manager`, 
`-fexperimental-isel`, `std::experimental` and `clang-cl /openmp:experimental`, 
Modules  and a 
couple of features only mentioning "experimental" in their commit log.

I dislike changing the syntax syntax as it means that we will at one point 
break already written code or have to maintain two spellings. I'd rather just 
enable them with a command-line switch, such as `-fexperimental-transform`.


Repository:
  rC Clang

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

https://reviews.llvm.org/D69088



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


Re: Zorg migration to GitHub/monorepo

2019-10-18 Thread Vitaly Buka via cfe-commits
On Mon, Oct 14, 2019 at 6:16 PM Galina Kistanova via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Hello everyone,
>
>
>
> We are in the middle of porting the majority of zorg to
> GitHub/monorepo. The following build factories will be ported and if you
> use one of those for your bots, you are all covered:
>
>
>
> * ClangBuilder.getClangCMakeBuildFactory (31 bots)
>
> * ClangBuilder.getClangCMakeGCSBuildFactory (2 bots)
>
> * LibcxxAndAbiBuilder (23 bots)
>
> * SphinxDocsBuilder (7 bots)
>
> * UnifiedTreeBuilder (11 bots)
>
> * ABITestsuitBuilder (1 bot) - based on UnifiedTreeBuilder
>
> * ClangLTOBuilder (2 bots) - based on UnifiedTreeBuilder
>
> * LLDPerformanceTesuiteBuilder (1 bot) - based on UnifiedTreeBuilder
>
>
>
> Some build factories will be deprecated. If you use one of these, please
> change your bot to use something else instead. Here is the list of
> deprecated build factories:
>
>
>
> * ClangBuilder.getClangBuildFactory (0 bots)
>
> * LLDBuilder (0 bots)
>
> * ClangAndLLDBuilder (0 bots)
>
>
>
> However, some special build factories and build factories with a few bots
> would need your attention.
>
> Here is the list of build factories in need of porting. Patches are
> welcome.
>
>
>
> * LLVMBuilder (3 bots)
>
> * PollyBuilder (3 bots)
>
> * LLDBBuilder (6 bots)
>
> * SanitizerBuilder (10 bots)
>

SanitizerBuilder already uses monorepo from github. Still it uses svn
BUILDBOT_REVISION. 'BUILDBOT_REVISION' is
WithProperties('%(revision:-None)s').
Not sure what is going to happen after migration.


> * CUDATestsuiteBuilder (1 bot) - depends on
> ClangBuilder.getClangBuildFactory
>
> * AOSPBuilder (1 bot) - depends on PollyBuilder
>
> * AnnotatedBuilder (2 bots)
>
> * OpenMPBuilder (2 bots)
>
> * FuchsiaBuilder (1 bot)
>
>
>
> Please feel free to ask if you have questions.
>
>
>
> Thanks
>
>
>
> Galina
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69194: build: add clang-cl and clang++ symlinks in the build tree

2019-10-18 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

> Furthermore, the current build only installs the symbolic links in the 
> install tree, not the build tree

This isn't right ... if I look at my LLVM build tree, I have clang, clang++ and 
clang-cl symlinks, all pointing to the actual clang-10 binary.

Where are you seeing this?


Repository:
  rC Clang

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

https://reviews.llvm.org/D69194



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


[PATCH] D69194: build: add clang-cl and clang++ symlinks in the build tree

2019-10-18 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd created this revision.
compnerd added reviewers: xiaobai, beanz, smeenai.
Herald added a subscriber: mgorny.
Herald added a project: clang.

This adds the clang-cl and clang++ symlinks.  Since there are no targets to 
depend on for this, we cannot force the creation of the symlinks.  Furthermore, 
the current build only installs the symbolic links in the install tree, not the 
build tree.  This enables the use of the clang driver without having adjust the 
C/C++ flags to add `--driver=...` to switch between driver modes.  Usage of 
this is present in Swift and there is some usage in lldb.


Repository:
  rC Clang

https://reviews.llvm.org/D69194

Files:
  tools/driver/CMakeLists.txt


Index: tools/driver/CMakeLists.txt
===
--- tools/driver/CMakeLists.txt
+++ tools/driver/CMakeLists.txt
@@ -49,6 +49,15 @@
   clangSerialization
   )
 
+if(CMAKE_VERSION VERSION_GREATER 3.7 OR NOT CMAKE_SYSTEM_NAME STREQUAL Windows)
+  set(command create_symlink)
+else()
+  set(command copy)
+endif()
+add_custom_command(TARGET clang POST_BUILD
+  COMMAND ${CMAKE_COMMAND} -E ${command} $ 
$/clang-cl${CMAKE_EXECUTABLE_SUFFIX}
+  COMMAND ${CMAKE_COMMAND} -E ${command} $ 
$/clang++${CMAKE_EXECUTABLE_SUFFIX})
+
 if(WIN32 AND NOT CYGWIN)
   # Prevent versioning if the buildhost is targeting for Win32.
 else()


Index: tools/driver/CMakeLists.txt
===
--- tools/driver/CMakeLists.txt
+++ tools/driver/CMakeLists.txt
@@ -49,6 +49,15 @@
   clangSerialization
   )
 
+if(CMAKE_VERSION VERSION_GREATER 3.7 OR NOT CMAKE_SYSTEM_NAME STREQUAL Windows)
+  set(command create_symlink)
+else()
+  set(command copy)
+endif()
+add_custom_command(TARGET clang POST_BUILD
+  COMMAND ${CMAKE_COMMAND} -E ${command} $ $/clang-cl${CMAKE_EXECUTABLE_SUFFIX}
+  COMMAND ${CMAKE_COMMAND} -E ${command} $ $/clang++${CMAKE_EXECUTABLE_SUFFIX})
+
 if(WIN32 AND NOT CYGWIN)
   # Prevent versioning if the buildhost is targeting for Win32.
 else()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67647: [Consumed] Refactor handleCall to take function argument list. NFC.

2019-10-18 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D67647#1713974 , @comex wrote:

> So, I landed this patch but had to revert it as it broke the build on MSVC 
> (and only MSVC).  That was almost a month ago, but I haven't gotten back 
> around to this until now – sorry :|
>
> In this updated patch, I switched is_random_iterator from a constexpr 
> function:
>
>   template 
>   constexpr bool is_random_iterator() {
> return std::is_same<
>   typename std::iterator_traits::iterator_category,
>   std::random_access_iterator_tag>::value;
>   }
>
>
> to a type alias:
>
>   template 
>   using is_random_iterator =
> std::is_same::iterator_category,
>  std::random_access_iterator_tag>;
>
>
> and changed the uses accordingly.  For some reason, MSVC thought the two 
> overloads of `drop_begin`, one with `enable_if()>` and 
> one with `enable_if()>`, were duplicate definitions.  
> But with `is_random_iterator` changed to a type alias, MSVC is fine with 
> them.  GCC and Clang think both versions are valid, so I think it's just an 
> MSVC bug.
>
> Simplified example for reference: https://gcc.godbolt.org/z/niXCy4


Sounds good to me. Maybe leave a comment explaining why a constexpr function 
was not used?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67647



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


r375286 - [analyzer] exploded-graph-rewriter: Unforget to censor stmt_ids in the test.

2019-10-18 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Fri Oct 18 13:48:21 2019
New Revision: 375286

URL: http://llvm.org/viewvc/llvm-project?rev=375286&view=rev
Log:
[analyzer] exploded-graph-rewriter: Unforget to censor stmt_ids in the test.

They're not stable across machines.

Fixes buildbots after r375278.

Modified:
cfe/trunk/test/Analysis/dump_egraph.c

Modified: cfe/trunk/test/Analysis/dump_egraph.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/dump_egraph.c?rev=375286&r1=375285&r2=375286&view=diff
==
--- cfe/trunk/test/Analysis/dump_egraph.c (original)
+++ cfe/trunk/test/Analysis/dump_egraph.c Fri Oct 18 13:48:21 2019
@@ -27,7 +27,7 @@ int foo() {
 // CHECK-SAME:\"node_id\": 2, \"is_sink\": 0, \"has_report\": 0
 // CHECK-SAME: \},
 // CHECK-SAME: \{ \"kind\": \"Statement\", \"stmt_kind\": \"IntegerLiteral\",
-// CHECK-SAME:\"stmt_id\": 597, \"pointer\": \"0x{{[0-9a-f]*}}\",
+// CHECK-SAME:\"stmt_id\": {{[0-9]*}}, \"pointer\": \"0x{{[0-9a-f]*}}\",
 // CHECK-SAME:\"pretty\": \"0\", \"location\": \{
 // CHECK-SAME:\"line\": 15, \"column\": 12, \"file\":
 // CHECK-SAME:\}, \"stmt_point_kind\": \"PreStmtPurgeDeadSymbols\",
@@ -35,7 +35,7 @@ int foo() {
 // CHECK-SAME:\"is_sink\": 0, \"has_report\": 0
 // CHECK-SAME: \},
 // CHECK-SAME: \{ \"kind\": \"Statement\", \"stmt_kind\": \"IntegerLiteral\",
-// CHECK-SAME:\"stmt_id\": 597, \"pointer\": \"0x{{[0-9a-f]*}}\",
+// CHECK-SAME:\"stmt_id\": {{[0-9]*}}, \"pointer\": \"0x{{[0-9a-f]*}}\",
 // CHECK-SAME:\"pretty\": \"0\", \"location\": \{
 // CHECK-SAME:\"line\": 15, \"column\": 12, \"file\":
 // CHECK-SAME:\}, \"stmt_point_kind\": \"PostStmt\", \"tag\": null,


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


[PATCH] D69150: [analyzer] Fix hidden node traversal in exploded graph dumps.

2019-10-18 Thread Artem Dergachev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7a17f197093a: [analyzer] Fix hidden node traversal in 
exploded graph dumps. (authored by dergachev.a).

Changed prior to commit:
  https://reviews.llvm.org/D69150?vs=225547&id=225685#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69150

Files:
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/test/Analysis/dump_egraph.c


Index: clang/test/Analysis/dump_egraph.c
===
--- clang/test/Analysis/dump_egraph.c
+++ clang/test/Analysis/dump_egraph.c
@@ -18,10 +18,30 @@
   return *x + *y;
 }
 
-// CHECK: \"program_points\": [\l\{ \"kind\": 
\"Edge\", \"src_id\": 2, \"dst_id\": 1, \"terminator\": null, \"term_kind\": 
null, \"tag\": null, \"node_id\": 1, \"is_sink\": 0, \"has_report\": 0 
\}\l  ],\l  \"program_state\": null
-
-// CHECK: \"program_points\": [\l\{ \"kind\": 
\"BlockEntrance\", \"block_id\": 1
-
+// CHECK: \"program_points\": [\l
+// CHECK-SAME: \{ \"kind\": \"Edge\", \"src_id\": 2, \"dst_id\": 1,
+// CHECK-SAME:\"terminator\": null, \"term_kind\": null, \"tag\": null,
+// CHECK-SAME:\"node_id\": 1, \"is_sink\": 0, \"has_report\": 0
+// CHECK-SAME: \},
+// CHECK-SAME: \{ \"kind\": \"BlockEntrance\", \"block_id\": 1, \"tag\": null,
+// CHECK-SAME:\"node_id\": 2, \"is_sink\": 0, \"has_report\": 0
+// CHECK-SAME: \},
+// CHECK-SAME: \{ \"kind\": \"Statement\", \"stmt_kind\": \"IntegerLiteral\",
+// CHECK-SAME:\"stmt_id\": 597, \"pointer\": \"0x{{[0-9a-f]*}}\",
+// CHECK-SAME:\"pretty\": \"0\", \"location\": \{
+// CHECK-SAME:\"line\": 15, \"column\": 12, \"file\":
+// CHECK-SAME:\}, \"stmt_point_kind\": \"PreStmtPurgeDeadSymbols\",
+// CHECK-SAME:\"tag\": \"ExprEngine : Clean Node\", \"node_id\": 3,
+// CHECK-SAME:\"is_sink\": 0, \"has_report\": 0
+// CHECK-SAME: \},
+// CHECK-SAME: \{ \"kind\": \"Statement\", \"stmt_kind\": \"IntegerLiteral\",
+// CHECK-SAME:\"stmt_id\": 597, \"pointer\": \"0x{{[0-9a-f]*}}\",
+// CHECK-SAME:\"pretty\": \"0\", \"location\": \{
+// CHECK-SAME:\"line\": 15, \"column\": 12, \"file\":
+// CHECK-SAME:\}, \"stmt_point_kind\": \"PostStmt\", \"tag\": null,
+// CHECK-SAME:\"node_id\": 4, \"is_sink\": 0, \"has_report\": 0
+// CHECK-SAME: \}
+// CHECK-SAME: ]
 
 // CHECK: \"pretty\": \"*x\", \"location\": \{ \"line\": 18, \"column\": 10, 
\"file\": \"{{(.+)}}dump_egraph.c\" \}
 
Index: clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -3030,22 +3030,16 @@
   llvm::function_ref PreCallback,
   llvm::function_ref PostCallback,
   llvm::function_ref Stop) {
-const ExplodedNode *FirstHiddenNode = N;
-while (FirstHiddenNode->pred_size() == 1 &&
-   isNodeHidden(*FirstHiddenNode->pred_begin())) {
-  FirstHiddenNode = *FirstHiddenNode->pred_begin();
-}
-const ExplodedNode *OtherNode = FirstHiddenNode;
 while (true) {
-  PreCallback(OtherNode);
-  if (Stop(OtherNode))
+  PreCallback(N);
+  if (Stop(N))
 return true;
 
-  if (OtherNode == N)
+  if (N->succ_size() != 1 || !isNodeHidden(N->getFirstSucc()))
 break;
-  PostCallback(OtherNode);
+  PostCallback(N);
 
-  OtherNode = *OtherNode->succ_begin();
+  N = N->getFirstSucc();
 }
 return false;
   }


Index: clang/test/Analysis/dump_egraph.c
===
--- clang/test/Analysis/dump_egraph.c
+++ clang/test/Analysis/dump_egraph.c
@@ -18,10 +18,30 @@
   return *x + *y;
 }
 
-// CHECK: \"program_points\": [\l\{ \"kind\": \"Edge\", \"src_id\": 2, \"dst_id\": 1, \"terminator\": null, \"term_kind\": null, \"tag\": null, \"node_id\": 1, \"is_sink\": 0, \"has_report\": 0 \}\l  ],\l  \"program_state\": null
-
-// CHECK: \"program_points\": [\l\{ \"kind\": \"BlockEntrance\", \"block_id\": 1
-
+// CHECK: \"program_points\": [\l
+// CHECK-SAME: \{ \"kind\": \"Edge\", \"src_id\": 2, \"dst_id\": 1,
+// CHECK-SAME:\"terminator\": null, \"term_kind\": null, \"tag\": null,
+// CHECK-SAME:\"node_id\": 1, \"is_sink\": 0, \"has_report\": 0
+// CHECK-SAME: \},
+// CHECK-SAME: \{ \"kind\": \"BlockEntrance\", \"block_id\": 1, \"tag\": null,
+// CHECK-SAME:\"node_id\": 2, \"is_sink\": 0, \"has_report\": 0
+// CHECK-SAME: \},
+// CHECK-SAME: \{ \"kind\": \"Statement\", \"stmt_kind\": \"IntegerLiteral\",
+// CHECK-SAME:\"stmt_id\": 597, \"pointer\": \"0x{{[0-9a-f]*}}\",
+// CHECK-SAME:\"pretty\": \"0\", \"location\": \{
+// CHECK-SAME:\"line\": 15, \"column\": 12, \"file\":
+// CHECK-SAME:\}, \"stmt_point_kind\": \"PreStmtPurgeDeadSymbols\",
+// CHECK-SAME:\"tag\": \"ExprEngine : Clean 

r375279 - [analyzer] exploded-graph-rewriter: Fix dump for state 0.

2019-10-18 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Fri Oct 18 13:15:32 2019
New Revision: 375279

URL: http://llvm.org/viewvc/llvm-project?rev=375279&view=rev
Log:
[analyzer] exploded-graph-rewriter: Fix dump for state 0.

It shouldn't say "unspecified" when the state is specified to be empty.

Modified:
cfe/trunk/test/Analysis/exploded-graph-rewriter/edge.dot
cfe/trunk/test/Analysis/exploded-graph-rewriter/node_labels.dot
cfe/trunk/test/Analysis/exploded-graph-rewriter/program_points.dot
cfe/trunk/test/Analysis/exploded-graph-rewriter/trimmers.dot
cfe/trunk/utils/analyzer/exploded-graph-rewriter.py

Modified: cfe/trunk/test/Analysis/exploded-graph-rewriter/edge.dot
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/exploded-graph-rewriter/edge.dot?rev=375279&r1=375278&r2=375279&view=diff
==
--- cfe/trunk/test/Analysis/exploded-graph-rewriter/edge.dot (original)
+++ cfe/trunk/test/Analysis/exploded-graph-rewriter/edge.dot Fri Oct 18 
13:15:32 2019
@@ -5,7 +5,7 @@
 // UNSUPPORTED: system-windows
 
 Node0x1 [shape=record,label=
- "{{ "program_state": null, "program_points": [
+ "{{ "state_id": 0, "program_state": null, "program_points": [
 {
   "kind": "BlockEntrance", "block_id": 1,
   "terminator": null, "term_kind": null,
@@ -19,7 +19,7 @@ Node0x1 [shape=record,label=
 Node0x1 -> Node0x2;
 
 Node0x2 [shape=record,label=
- "{{ "program_state": null, "program_points": [
+ "{{ "state_id": 0, "program_state": null, "program_points": [
 {
   "kind": "BlockEntrance", "block_id": 1,
   "terminator": null, "term_kind": null,

Modified: cfe/trunk/test/Analysis/exploded-graph-rewriter/node_labels.dot
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/exploded-graph-rewriter/node_labels.dot?rev=375279&r1=375278&r2=375279&view=diff
==
--- cfe/trunk/test/Analysis/exploded-graph-rewriter/node_labels.dot (original)
+++ cfe/trunk/test/Analysis/exploded-graph-rewriter/node_labels.dot Fri Oct 18 
13:15:32 2019
@@ -15,13 +15,12 @@
 // CHECK-SAME:   
 // LIGHT-SAME: 
 // DARK-SAME:  
-// CHECK-SAME:   State Unspecified
+// CHECK-SAME:   State 0
 // CHECK-SAME: 
 // CHECK-SAME:   
 Node0x1 [shape=record,label=
  "{
-{ "node_id": 1, "pointer": "0x1", "has_report": false, "is_sink": false,
-  "program_state": null,
+{ "state_id": 0, "program_state": null,
   "program_points": [
 {
   "kind": "BlockEntrance", "block_id": 1,
@@ -48,7 +47,7 @@ Node0x1 [shape=record,label=
 // CHECK-SAME: 
 Node0x2 [shape=record,label=
  "{
-{ "program_state": null,
+{ "state_id": 0, "program_state": null,
   "program_points": [
 {
   "kind": "BlockEntrance", "block_id": 1,

Modified: cfe/trunk/test/Analysis/exploded-graph-rewriter/program_points.dot
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/exploded-graph-rewriter/program_points.dot?rev=375279&r1=375278&r2=375279&view=diff
==
--- cfe/trunk/test/Analysis/exploded-graph-rewriter/program_points.dot 
(original)
+++ cfe/trunk/test/Analysis/exploded-graph-rewriter/program_points.dot Fri Oct 
18 13:15:32 2019
@@ -29,7 +29,7 @@
 Node0x1 [shape=record,label=
  "{
 {
-  "program_state": null, "program_points": [
+  "state_id": 0, "program_state": null, "program_points": [
   {
 "kind": "Edge",
 "src_id": 0,
@@ -80,7 +80,7 @@ Node0x1 [shape=record,label=
 // CHECK-SAME: 
 Node0x3 [shape=record,label=
  "{
-{ "program_state": null, "program_points": [
+{ "state_id": 0, "program_state": null, "program_points": [
   {
 "kind": "Statement",
 "stmt_kind": "DeclRefExpr",
@@ -109,7 +109,7 @@ Node0x3 [shape=record,label=
 Node0x4 [shape=record,label=
  "{
 {
-  "program_state": null, "program_points": [
+  "state_id": 0, "program_state": null, "program_points": [
   {
 "kind": "Statement",
 "stmt_kind": "CompoundStmt",
@@ -157,7 +157,7 @@ Node0x4 [shape=record,label=
 // CHECK-SAME: 
 Node0x5 [shape=record,label=
  "{
-{ "program_state": null, "program_points": [
+{ "state_id": 0, "program_state": null, "program_points": [
   {
 "kind": "Statement",
 "stmt_kind": "ImplicitCastExpr",

Modified: cfe/trunk/test/Analysis/exploded-graph-rewriter/trimmers.dot
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/exploded-graph-rewriter/trimmers.dot?rev=375279&r1=375278&r2=375279&view=diff
==
--- cfe/trunk/test/Analysis/exploded-graph-rewriter/trimmers.dot (original)
+++ cfe/trunk/test/Analysis/exploded-graph-rewriter/trimmers.dot Fri Oct 18 
13:15:32 2019
@@ -17,7 +17,7 @@
 // UNSUPPORTED: system-windows
 
 Node0x1 [shape=record,label=
- "{{ "pro

r375282 - [analyzer] exploded-graph-rewriter: Rename Environment to Expressions.

2019-10-18 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Fri Oct 18 13:15:41 2019
New Revision: 375282

URL: http://llvm.org/viewvc/llvm-project?rev=375282&view=rev
Log:
[analyzer] exploded-graph-rewriter: Rename Environment to Expressions.

It's less confusing for newcomers.

Modified:
cfe/trunk/test/Analysis/exploded-graph-rewriter/environment.dot
cfe/trunk/test/Analysis/exploded-graph-rewriter/escapes.c
cfe/trunk/utils/analyzer/exploded-graph-rewriter.py

Modified: cfe/trunk/test/Analysis/exploded-graph-rewriter/environment.dot
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/exploded-graph-rewriter/environment.dot?rev=375282&r1=375281&r2=375282&view=diff
==
--- cfe/trunk/test/Analysis/exploded-graph-rewriter/environment.dot (original)
+++ cfe/trunk/test/Analysis/exploded-graph-rewriter/environment.dot Fri Oct 18 
13:15:41 2019
@@ -3,7 +3,7 @@
 // FIXME: Substitution doesn't seem to work on Windows.
 // UNSUPPORTED: system-windows
 
-// CHECK: Environment: 
+// CHECK: Expressions: 
 // CHECK-SAME: 
 // CHECK-SAME:   
 // CHECK-SAME: 

Modified: cfe/trunk/test/Analysis/exploded-graph-rewriter/escapes.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/exploded-graph-rewriter/escapes.c?rev=375282&r1=375281&r2=375282&view=diff
==
--- cfe/trunk/test/Analysis/exploded-graph-rewriter/escapes.c (original)
+++ cfe/trunk/test/Analysis/exploded-graph-rewriter/escapes.c Fri Oct 18 
13:15:41 2019
@@ -12,7 +12,7 @@ void escapes() {
   // CHECK: Store:  (0x{{[0-9a-f]*}})
   // CHECK-SAME: foo0
   // CHECK-SAME: &Element\{"foo",0 S64b,char\}
-  // CHECK: Environment: 
+  // CHECK: Expressions: 
   // CHECK-SAME: "foo"
   // CHECK-SAME: &Element\{"foo",0 S64b,char\}
   const char *const foo = "\x66\x6f\x6f";

Modified: cfe/trunk/utils/analyzer/exploded-graph-rewriter.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/analyzer/exploded-graph-rewriter.py?rev=375282&r1=375281&r2=375282&view=diff
==
--- cfe/trunk/utils/analyzer/exploded-graph-rewriter.py (original)
+++ cfe/trunk/utils/analyzer/exploded-graph-rewriter.py Fri Oct 18 13:15:41 2019
@@ -792,7 +792,7 @@ class DotDumpVisitor(object):
 
 def visit_state(self, s, prev_s):
 self.visit_store_in_state(s, prev_s)
-self.visit_environment_in_state('environment', 'Environment',
+self.visit_environment_in_state('environment', 'Expressions',
 s, prev_s)
 self.visit_generic_map_in_state('constraints', 'Ranges',
 s, prev_s)


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


r375281 - [analyzer] Fix FieldRegion dumps.

2019-10-18 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Fri Oct 18 13:15:39 2019
New Revision: 375281

URL: http://llvm.org/viewvc/llvm-project?rev=375281&view=rev
Log:
[analyzer] Fix FieldRegion dumps.

The '->' thing has always been confusing; the actual operation '->'
translates to a pointer dereference together with adding a FieldRegion,
but FieldRegion on its own doesn't imply an additional pointer
dereference.

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp
cfe/trunk/test/Analysis/dump_egraph.cpp

cfe/trunk/test/Analysis/exploded-graph-rewriter/initializers_under_construction.cpp
cfe/trunk/test/Analysis/expr-inspection.c

Modified: cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp?rev=375281&r1=375280&r2=375281&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp Fri Oct 18 13:15:39 2019
@@ -506,7 +506,7 @@ void ElementRegion::dumpToStream(raw_ost
 }
 
 void FieldRegion::dumpToStream(raw_ostream &os) const {
-  os << superRegion << "->" << *getDecl();
+  os << superRegion << "." << *getDecl();
 }
 
 void ObjCIvarRegion::dumpToStream(raw_ostream &os) const {

Modified: cfe/trunk/test/Analysis/dump_egraph.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/dump_egraph.cpp?rev=375281&r1=375280&r2=375281&view=diff
==
--- cfe/trunk/test/Analysis/dump_egraph.cpp (original)
+++ cfe/trunk/test/Analysis/dump_egraph.cpp Fri Oct 18 13:15:39 2019
@@ -20,7 +20,7 @@ void foo() {
 
 // CHECK: \"location_context\": \"#0 Call\", \"calling\": \"foo\", 
\"location\": null, \"items\": 
[\l\{ \"stmt_id\": {{[0-9]+}}, 
\"kind\": \"construct into local variable\", \"argument_index\": null, 
\"pretty\": \"T t;\", \"value\": \"&t\"
 
-// CHECK: \"location_context\": \"#0 Call\", \"calling\": \"T::T\", 
\"location\": \{ \"line\": 16, \"column\": 5, \"file\": 
\"{{.*}}dump_egraph.cpp\" \}, \"items\": 
[\l\{ \"init_id\": {{[0-9]+}}, 
\"kind\": \"construct into member variable\", \"argument_index\": null, 
\"pretty\": \"s\", \"value\": \"&t-\>s\"
+// CHECK: \"location_context\": \"#0 Call\", \"calling\": \"T::T\", 
\"location\": \{ \"line\": 16, \"column\": 5, \"file\": 
\"{{.*}}dump_egraph.cpp\" \}, \"items\": 
[\l\{ \"init_id\": {{[0-9]+}}, 
\"kind\": \"construct into member variable\", \"argument_index\": null, 
\"pretty\": \"s\", \"value\": \"&t.s\"
 
 // CHECK: \"cluster\": \"t\", \"pointer\": \"{{0x[0-9a-f]+}}\", \"items\": 
[\l\{ \"kind\": \"Default\", 
\"offset\": 0, \"value\": \"conj_$2\{int, LC5, no stmt, #1\}\"
 

Modified: 
cfe/trunk/test/Analysis/exploded-graph-rewriter/initializers_under_construction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/exploded-graph-rewriter/initializers_under_construction.cpp?rev=375281&r1=375280&r2=375281&view=diff
==
--- 
cfe/trunk/test/Analysis/exploded-graph-rewriter/initializers_under_construction.cpp
 (original)
+++ 
cfe/trunk/test/Analysis/exploded-graph-rewriter/initializers_under_construction.cpp
 Fri Oct 18 13:15:39 2019
@@ -20,6 +20,6 @@ struct B {
 void test() {
   // CHECK: (construct into member variable)
   // CHECK-SAME: a
-  // CHECK-SAME: &b->a
+  // CHECK-SAME: &b.a
   B b;
 }

Modified: cfe/trunk/test/Analysis/expr-inspection.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/expr-inspection.c?rev=375281&r1=375280&r2=375281&view=diff
==
--- cfe/trunk/test/Analysis/expr-inspection.c (original)
+++ cfe/trunk/test/Analysis/expr-inspection.c Fri Oct 18 13:15:39 2019
@@ -5,6 +5,7 @@
 // Self-tests for the debug.ExprInspection checker.
 
 void clang_analyzer_dump(int x);
+void clang_analyzer_dump_pointer(int *p);
 void clang_analyzer_printState();
 void clang_analyzer_numTimesReached();
 
@@ -30,7 +31,7 @@ void foo(int x) {
 // CHECK-NEXT: ]}
 // CHECK-NEXT:   ]},
 // CHECK-NEXT:   "environment": { "pointer": "{{0x[0-9a-f]+}}", "items": [
-// CHECK-NEXT: { "lctx_id": 1, "location_context": "#0 Call", "calling": 
"foo", "location": null, "items": [
+// CHECK-NEXT: { "lctx_id": {{[0-9]+}}, "location_context": "#0 Call", 
"calling": "foo", "location": null, "items": [
 // CHECK-NEXT:   { "stmt_id": {{[0-9]+}}, "pretty": 
"clang_analyzer_printState", "value": "&code{clang_analyzer_printState}" }
 // CHECK-NEXT: ]}
 // CHECK-NEXT:   ]},
@@ -43,3 +44,11 @@ void foo(int x) {
 // CHECK-NEXT:   "checker_messages": null
 // CHECK-NEXT: }
 
+struct S {
+  int x, y;
+};
+
+void test_field_dumps(struct S s, struct S *p) {
+  clang_analyzer_dump_pointer(&s.x); // expected-warning{{&s.x}}
+  clang_analyzer_dump_pointer(&p->x)

r375280 - [analyzer] Drop the logic for collapsing the state if it's same as in preds.

2019-10-18 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Fri Oct 18 13:15:35 2019
New Revision: 375280

URL: http://llvm.org/viewvc/llvm-project?rev=375280&view=rev
Log:
[analyzer] Drop the logic for collapsing the state if it's same as in preds.

One of the first attempts to reduce the size of the exploded graph dumps
was to skip the state dump as long as the state is the same as in all of
the predecessor nodes. With all the new facilities in place (node joining,
diff dumps), this feature doesn't do much, and when it does,
it's more harmful than useful. Let's remove it.

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/test/Analysis/dump_egraph.c

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=375280&r1=375279&r2=375280&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Fri Oct 18 13:15:35 2019
@@ -3083,16 +3083,7 @@ struct DOTGraphTraits :
 Out << "\\l"; // Adds a new-line to the last program point.
 Indent(Out, Space, IsDot) << "],\\l";
 
-bool SameAsAllPredecessors =
-std::all_of(N->pred_begin(), N->pred_end(), [&](const ExplodedNode *P) 
{
-  return P->getState() == State;
-});
-
-if (!SameAsAllPredecessors) {
-  State->printDOT(Out, N->getLocationContext(), Space);
-} else {
-  Indent(Out, Space, IsDot) << "\"program_state\": null";
-}
+State->printDOT(Out, N->getLocationContext(), Space);
 
 Out << "\\l}\\l";
 return Out.str();

Modified: cfe/trunk/test/Analysis/dump_egraph.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/dump_egraph.c?rev=375280&r1=375279&r2=375280&view=diff
==
--- cfe/trunk/test/Analysis/dump_egraph.c (original)
+++ cfe/trunk/test/Analysis/dump_egraph.c Fri Oct 18 13:15:35 2019
@@ -48,3 +48,5 @@ int foo() {
 // CHECK: \"pretty\": \"'x13'\"
 
 // CHECK: \"has_report\": 1
+
+// CHECK-NOT: \"program_state\": null


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


r375278 - [analyzer] Fix hidden node traversal in exploded graph dumps.

2019-10-18 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Fri Oct 18 13:15:29 2019
New Revision: 375278

URL: http://llvm.org/viewvc/llvm-project?rev=375278&view=rev
Log:
[analyzer] Fix hidden node traversal in exploded graph dumps.

The joined nodes now actually have the same state. That was intended
from the start but the original implementation turned out to be buggy.

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/test/Analysis/dump_egraph.c

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=375278&r1=375277&r2=375278&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Fri Oct 18 13:15:29 2019
@@ -3030,22 +3030,16 @@ struct DOTGraphTraits :
   llvm::function_ref PreCallback,
   llvm::function_ref PostCallback,
   llvm::function_ref Stop) {
-const ExplodedNode *FirstHiddenNode = N;
-while (FirstHiddenNode->pred_size() == 1 &&
-   isNodeHidden(*FirstHiddenNode->pred_begin())) {
-  FirstHiddenNode = *FirstHiddenNode->pred_begin();
-}
-const ExplodedNode *OtherNode = FirstHiddenNode;
 while (true) {
-  PreCallback(OtherNode);
-  if (Stop(OtherNode))
+  PreCallback(N);
+  if (Stop(N))
 return true;
 
-  if (OtherNode == N)
+  if (N->succ_size() != 1 || !isNodeHidden(N->getFirstSucc()))
 break;
-  PostCallback(OtherNode);
+  PostCallback(N);
 
-  OtherNode = *OtherNode->succ_begin();
+  N = N->getFirstSucc();
 }
 return false;
   }

Modified: cfe/trunk/test/Analysis/dump_egraph.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/dump_egraph.c?rev=375278&r1=375277&r2=375278&view=diff
==
--- cfe/trunk/test/Analysis/dump_egraph.c (original)
+++ cfe/trunk/test/Analysis/dump_egraph.c Fri Oct 18 13:15:29 2019
@@ -18,10 +18,30 @@ int foo() {
   return *x + *y;
 }
 
-// CHECK: \"program_points\": [\l\{ \"kind\": 
\"Edge\", \"src_id\": 2, \"dst_id\": 1, \"terminator\": null, \"term_kind\": 
null, \"tag\": null, \"node_id\": 1, \"is_sink\": 0, \"has_report\": 0 
\}\l  ],\l  \"program_state\": null
-
-// CHECK: \"program_points\": [\l\{ \"kind\": 
\"BlockEntrance\", \"block_id\": 1
-
+// CHECK: \"program_points\": [\l
+// CHECK-SAME: \{ \"kind\": \"Edge\", \"src_id\": 2, \"dst_id\": 1,
+// CHECK-SAME:\"terminator\": null, \"term_kind\": null, \"tag\": null,
+// CHECK-SAME:\"node_id\": 1, \"is_sink\": 0, \"has_report\": 0
+// CHECK-SAME: \},
+// CHECK-SAME: \{ \"kind\": \"BlockEntrance\", \"block_id\": 1, \"tag\": null,
+// CHECK-SAME:\"node_id\": 2, \"is_sink\": 0, \"has_report\": 0
+// CHECK-SAME: \},
+// CHECK-SAME: \{ \"kind\": \"Statement\", \"stmt_kind\": \"IntegerLiteral\",
+// CHECK-SAME:\"stmt_id\": 597, \"pointer\": \"0x{{[0-9a-f]*}}\",
+// CHECK-SAME:\"pretty\": \"0\", \"location\": \{
+// CHECK-SAME:\"line\": 15, \"column\": 12, \"file\":
+// CHECK-SAME:\}, \"stmt_point_kind\": \"PreStmtPurgeDeadSymbols\",
+// CHECK-SAME:\"tag\": \"ExprEngine : Clean Node\", \"node_id\": 3,
+// CHECK-SAME:\"is_sink\": 0, \"has_report\": 0
+// CHECK-SAME: \},
+// CHECK-SAME: \{ \"kind\": \"Statement\", \"stmt_kind\": \"IntegerLiteral\",
+// CHECK-SAME:\"stmt_id\": 597, \"pointer\": \"0x{{[0-9a-f]*}}\",
+// CHECK-SAME:\"pretty\": \"0\", \"location\": \{
+// CHECK-SAME:\"line\": 15, \"column\": 12, \"file\":
+// CHECK-SAME:\}, \"stmt_point_kind\": \"PostStmt\", \"tag\": null,
+// CHECK-SAME:\"node_id\": 4, \"is_sink\": 0, \"has_report\": 0
+// CHECK-SAME: \}
+// CHECK-SAME: ]
 
 // CHECK: \"pretty\": \"*x\", \"location\": \{ \"line\": 18, \"column\": 10, 
\"file\": \"{{(.+)}}dump_egraph.c\" \}
 


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


[PATCH] D69150: [analyzer] Fix hidden node traversal in exploded graph dumps.

2019-10-18 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ marked an inline comment as done.
NoQ added inline comments.



Comment at: clang/test/Analysis/dump_egraph.c:46
 
 // CHECK: \"pretty\": \"*x\", \"location\": \{ \"line\": 18, \"column\": 10, 
\"file\": \"{{(.+)}}dump_egraph.c\" \}
 

Charusso wrote:
> `\"file\": \"{{(.+)}}dump_egraph.c\" \}` is a cool workaround, but otherwise 
> if you do not want to end line 32, could you remove this line's ending please?
Interestingly, this doesn't work in my case but does work in this older case, 
due to greediness: the first `{(.+)}}dump_egraph.c` matches everything until 
the second `dump_egraph.c` and then it can't find the `PreStmtPurgeDeadSymbols` 
line after it because it was already skipped.

I tried to make it non-greedy: `{{(.+?)}}dump_egraph.c` but it says it's not 
allowed.

I'm pretty bad with regexps so i decided to screw it :) But let's keep at least 
this test in order to test that the filename is actually printed.


Repository:
  rC Clang

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

https://reviews.llvm.org/D69150



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


[PATCH] D68818: [hip][cuda] Fix the extended lambda name mangling issue.

2019-10-18 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/include/clang/AST/DeclCXX.h:1713
+  /// mangling number.
+  bool hasKnownInternalLinkage() const {
+assert(isLambda() && "Not a lambda closure type!");

This function name should mention that it's only applicable to lambdas.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68818



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


[libunwind] r375275 - [libunwind][Android] Fix findUnwindSections for ARM EHABI Bionic

2019-10-18 Thread Ryan Prichard via cfe-commits
Author: rprichard
Date: Fri Oct 18 12:59:22 2019
New Revision: 375275

URL: http://llvm.org/viewvc/llvm-project?rev=375275&view=rev
Log:
[libunwind][Android] Fix findUnwindSections for ARM EHABI Bionic

Summary:
Fix the arm_section_length count. The meaning of the arm_section_length
field changed from num-of-elements to num-of-bytes when the
dl_unwind_find_exidx special case was removed (D30306 and D30681). The
special case was restored in D39468, but that patch didn't account for the
change in arm_section_length's meaning.

That patch worked when it was applied to the NDK's fork of libunwind,
because it never removed the special case in the first place, and the
special case is probably disabled in the Android platform's copy of
libunwind, because __ANDROID_API__ is greater than 21.

Turn the dl_unwind_find_exidx special case on unconditionally for Bionic.
Bionic's dl_unwind_find_exidx is much faster than using dl_iterate_phdr.
(e.g. Bionic stores exidx info on an internal soinfo object.)

Reviewers: thomasanderson, srhines, danalbert, ed, keith.walker.arm, 
mclow.lists, compnerd

Reviewed By: srhines, danalbert

Subscribers: srhines, kristof.beyls, christof, libcxx-commits

Tags: #libc

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

Modified:
libunwind/trunk/src/AddressSpace.hpp
libunwind/trunk/src/UnwindCursor.hpp

Modified: libunwind/trunk/src/AddressSpace.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/AddressSpace.hpp?rev=375275&r1=375274&r2=375275&view=diff
==
--- libunwind/trunk/src/AddressSpace.hpp (original)
+++ libunwind/trunk/src/AddressSpace.hpp Fri Oct 18 12:59:22 2019
@@ -32,6 +32,13 @@
 #endif
 #endif
 
+#if defined(_LIBUNWIND_ARM_EHABI)
+struct EHABIIndexEntry {
+  uint32_t functionOffset;
+  uint32_t data;
+};
+#endif
+
 #ifdef __APPLE__
 #include 
 namespace libunwind {
@@ -462,12 +469,13 @@ inline bool LocalAddressSpace::findUnwin
   (void)targetAddr;
   (void)info;
   return true;
-#elif defined(_LIBUNWIND_ARM_EHABI) && defined(__BIONIC__) &&  
\
-(__ANDROID_API__ < 21)
+#elif defined(_LIBUNWIND_ARM_EHABI) && defined(__BIONIC__)
+  // For ARM EHABI, Bionic didn't implement dl_iterate_phdr until API 21. After
+  // API 21, dl_iterate_phdr exists, but dl_unwind_find_exidx is much faster.
   int length = 0;
   info.arm_section =
   (uintptr_t)dl_unwind_find_exidx((_Unwind_Ptr)targetAddr, &length);
-  info.arm_section_length = (uintptr_t)length;
+  info.arm_section_length = (uintptr_t)length * sizeof(EHABIIndexEntry);
   if (info.arm_section && info.arm_section_length)
 return true;
 #elif defined(_LIBUNWIND_ARM_EHABI) || defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)

Modified: libunwind/trunk/src/UnwindCursor.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/UnwindCursor.hpp?rev=375275&r1=375274&r2=375275&view=diff
==
--- libunwind/trunk/src/UnwindCursor.hpp (original)
+++ libunwind/trunk/src/UnwindCursor.hpp Fri Oct 18 12:59:22 2019
@@ -1222,11 +1222,6 @@ template  bool U
 #endif // defined(_LIBUNWIND_SUPPORT_SEH_UNWIND)
 
 #if defined(_LIBUNWIND_ARM_EHABI)
-struct EHABIIndexEntry {
-  uint32_t functionOffset;
-  uint32_t data;
-};
-
 template
 struct EHABISectionIterator {
   typedef EHABISectionIterator _Self;


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


[PATCH] D69088: [Lex] #pragma clang transform

2019-10-18 Thread Hideki Saito via Phabricator via cfe-commits
hsaito added a comment.

In D69088#1714575 , @Meinersbur wrote:

> In D69088#1714020 , @hsaito wrote:
>
> > Personally, I like the intent. I don't foresee a clear (enough) path to get 
> > there. This leads to hesitation of adding a new non-experimental pragma and 
> > present it to programmers. If you call it experimental, it's easier for me 
> > to swallow.
>
>
> Is there anything more to do than mentioning as being it experimental in the 
> (no-patch-available-yet) docs?


If there is a precedence, just follow that. Else, how to spell an experimental 
clang pragma would be a good discussion topic by itself. If I need to provide a 
discussion starter, I'd say how about transform_experimental instead of 
transform. All I ask is somehow make it easier for programmers to know it is 
experimental so that they won't use it w/o first reading about the current 
state of support. I don't have a strong opinion about how to do so.

If others with stakes in loop optimizations foresee a clear enough path to get 
there, I won't insist this being experimental, but I would like to understand 
the path.

Thanks,
Hideki


Repository:
  rC Clang

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

https://reviews.llvm.org/D69088



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


[PATCH] D68818: [hip][cuda] Fix the extended lambda name mangling issue.

2019-10-18 Thread Michael Liao via Phabricator via cfe-commits
hliao updated this revision to Diff 225678.
hliao added a comment.

minor test case revising.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68818

Files:
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CodeGenCUDA/unnamed-types.cu

Index: clang/test/CodeGenCUDA/unnamed-types.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/unnamed-types.cu
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -std=c++11 -x hip -triple x86_64-linux-gnu -aux-triple amdgcn-amd-amdhsa -emit-llvm %s -o - | FileCheck %s --check-prefix=HOST
+// RUN: %clang_cc1 -std=c++11 -x hip -triple amdgcn-amd-amdhsa -fcuda-is-device -emit-llvm %s -o - | FileCheck %s --check-prefix=DEVICE
+
+#include "Inputs/cuda.h"
+
+// HOST: @0 = private unnamed_addr constant [43 x i8] c"_Z2k0IZZ2f1PfENKUlS0_E_clES0_EUlfE_EvS0_T_\00", align 1
+
+__device__ float d0(float x) {
+  return [](float x) { return x + 2.f; }(x);
+}
+
+__device__ float d1(float x) {
+  return [](float x) { return x * 2.f; }(x);
+}
+
+// DEVICE: amdgpu_kernel void @_Z2k0IZZ2f1PfENKUlS0_E_clES0_EUlfE_EvS0_T_(
+template 
+__global__ void k0(float *p, F f) {
+  p[0] = f(p[0]) + d0(p[1]) + d1(p[2]);
+}
+
+void f0(float *p) {
+  [](float *p) {
+*p = 1.f;
+  }(p);
+}
+
+// The inner/outer lambdas are required to be mangled following ODR but their
+// linkages are still required to keep the original `internal` linkage.
+
+// HOST: define internal void @_ZZ2f1PfENKUlS_E_clES_(
+// DEVICE: define internal float @_ZZZ2f1PfENKUlS_E_clES_ENKUlfE_clEf(
+void f1(float *p) {
+  [](float *p) {
+k0<<<1,1>>>(p, [] __device__ (float x) { return x + 1.f; });
+  }(p);
+}
+// HOST: @__hip_register_globals
+// HOST: __hipRegisterFunction{{.*}}@_Z2k0IZZ2f1PfENKUlS0_E_clES0_EUlfE_EvS0_T_{{.*}}@0
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -6223,6 +6223,7 @@
 Record->push_back(Lambda.CaptureDefault);
 Record->push_back(Lambda.NumCaptures);
 Record->push_back(Lambda.NumExplicitCaptures);
+Record->push_back(Lambda.HasKnownInternalLinkage);
 Record->push_back(Lambda.ManglingNumber);
 AddDeclRef(D->getLambdaContextDecl());
 AddTypeSourceInfo(Lambda.MethodTyInfo);
Index: clang/lib/Serialization/ASTReaderDecl.cpp
===
--- clang/lib/Serialization/ASTReaderDecl.cpp
+++ clang/lib/Serialization/ASTReaderDecl.cpp
@@ -1690,6 +1690,7 @@
 Lambda.CaptureDefault = Record.readInt();
 Lambda.NumCaptures = Record.readInt();
 Lambda.NumExplicitCaptures = Record.readInt();
+Lambda.HasKnownInternalLinkage = Record.readInt();
 Lambda.ManglingNumber = Record.readInt();
 Lambda.ContextDecl = ReadDeclID();
 Lambda.Captures = (Capture *)Reader.getContext().Allocate(
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -11442,17 +11442,18 @@
 E->getCaptureDefault());
   getDerived().transformedLocalDecl(OldClass, {Class});
 
-  Optional> Mangling;
+  Optional> Mangling;
   if (getDerived().ReplacingOriginal())
-Mangling = std::make_pair(OldClass->getLambdaManglingNumber(),
-  OldClass->getLambdaContextDecl());
+Mangling = std::make_tuple(OldClass->getLambdaManglingNumber(),
+   OldClass->hasKnownInternalLinkage(),
+   OldClass->getLambdaContextDecl());
 
   // Build the call operator.
   CXXMethodDecl *NewCallOperator = getSema().startLambdaDefinition(
   Class, E->getIntroducerRange(), NewCallOpTSI,
   E->getCallOperator()->getEndLoc(),
   NewCallOpTSI->getTypeLoc().castAs().getParams(),
-  E->getCallOperator()->getConstexprKind(), Mangling);
+  E->getCallOperator()->getConstexprKind());
 
   LSI->CallOperator = NewCallOperator;
 
@@ -11472,6 +11473,9 @@
   getDerived().transformAttrs(E->getCallOperator(), NewCallOperator);
   getDerived().transformedLocalDecl(E->getCallOperator(), {NewCallOperator});
 
+  // Number the lambda for linkage purposes if necessary.
+  getSema().handleLambdaNumbering(Class, NewCallOperator, Mangling);
+
   // Introduce the context of the call operator.
   Sema::ContextRAII SavedContext(getSema(), NewCallOperator,
  /*NewThisContext*/false);
Index: clang/lib/Sema/SemaLambda.cpp
===
--- clang/lib/S

[PATCH] D69088: [Lex] #pragma clang transform

2019-10-18 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

In D69088#1713623 , @hsaito wrote:

> @Meinersbur, if I remember correctly, there was an RFC discussion on this 
> topic, right? If yes, would you post the pointer to that? I need a refresher 
> on what has been discussed/settled in the past.


My publications on this topic would also be useful here, available on arXiv. 
Here is an overview, also including previous discussions:

Loop optimization directives:

- A Proposal for Loop-Transformation Pragmas  
(IWOMP'19)
- User-Directed Loop-Transformations in Clang 
 (LLVM-HPC'18)
- Design and Use of Loop-Transformation Pragmas 
 (IWOMP'19)
- RFC: Extending #pragma clang loop 
 (cfe-dev)
- Prototype implementation using `#pragma clang loop` and attributes 
 (GitHub)

Loop attributes metadata:

- RFC: Extending loop metadata 
 (llvm-dev)
- D57978 : Metadata for follow-up 
transformations

Applying loop optimizations:

- Loop Optimization Framework  (LCPC'18)
- Loop Transformations in LLVM  (LLVM 
DevMtg'18)
- Prototype implementation for applying transformations using Polly 
 (GitHub)


Repository:
  rC Clang

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

https://reviews.llvm.org/D69088



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


[PATCH] D69181: [clang-tidy] Adding misc-signal-terminated-thread check

2019-10-18 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/clang-tidy/misc/BadSignalToKillThreadCheck.cpp:28
+
+namespace {
+static Preprocessor *PP;

static is enough, no need for anonymous namespace.



Comment at: clang-tools-extra/clang-tidy/misc/BadSignalToKillThreadCheck.cpp:33
+void BadSignalToKillThreadCheck::check(const MatchFinder::MatchResult &Result) 
{
+
+  Preprocessor::macro_iterator It = PP->macro_begin();

Unnecessary empty line.



Comment at: clang-tools-extra/clang-tidy/misc/BadSignalToKillThreadCheck.cpp:37
+if (It->first->getName() == "SIGTERM") {
+  const auto *MI = PP->getMacroInfo(It->first);
+  const auto &T = MI->tokens().back();

Please don't use auto unless type is spelled in same statement or iterator.



Comment at: clang-tools-extra/clang-tidy/misc/BadSignalToKillThreadCheck.cpp:67
+} // namespace clang
\ No newline at end of file


Please add new line.



Comment at: clang-tools-extra/clang-tidy/misc/BadSignalToKillThreadCheck.h:40
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_BADSIGNALTOKILLTHREADCHECK_H
\ No newline at end of file


Please add new line.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:76
 
+- New :doc:`misc-signal-terminated-thread
+  ` check.

Please keep alphabetical order in new checks list.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:79
+
+  Do not send an uncaught signal to kill a thread because the signal kills the 
entire process, not just the individual thread. 
+  To learn more about this rule please visit the following page:

Please synchronize with first sentence in documentation. Link belongs to 
documentation.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/misc-bad-signal-to-kill-thread.rst:8
+terminated by ``SIGTERM`` signal.
+.. code-block: c++
+

Please separate with empty line.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/misc-bad-signal-to-kill-thread.rst:11
+pthread_kill(thread, SIGTERM);
\ No newline at end of file


Please add new line.



Comment at: 
clang-tools-extra/test/clang-tidy/misc-bad-signal-to-kill-thread.cpp:31
+}
\ No newline at end of file


Please add new line.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D69181



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


[PATCH] D69171: [clang-fuzzer] Add new fuzzer target for Objective-C

2019-10-18 Thread David Goldman via Phabricator via cfe-commits
dgoldman added a comment.

Not sure who is best to review, feel free to add someone else instead.


Repository:
  rC Clang

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

https://reviews.llvm.org/D69171



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


[PATCH] D69164: [clang-format] fix regression recognizing casts in Obj-C calls

2019-10-18 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir marked an inline comment as done.
krasimir added inline comments.



Comment at: lib/Format/TokenAnnotator.cpp:1612
+  Keywords.kw_final) ||
+isCpp11AttributeSpecifier(*Tok.Next))
   return false;

rdwampler wrote:
> I think the issue r373922 was fixing is only related to the `delete`. Can 
> this check be move further up where we explicitly check if the token is the 
> delete keyword? 
> 
Sorry, I didn't notice this comment until now. I can investigate whether all 
the other cases for non-delete methods are already covered, it would be 
interesting. + @MyDeveloperDay, who might have better insights into this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69164



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


[PATCH] D62731: Add support for options -frounding-math, ftrapping-math, -fp-model=, and -fp-exception-behavior=, : Specify floating point behavior

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



Comment at: clang/docs/UsersManual.rst:1318
+   mode informs the compiler that it must not assume any particular
+   rounding mode.
+

rjmccall wrote:
> "represent *the* corresponding IEEE rounding rules"
A few points about this documentation that occurred to me since the last time I 
looked at it:

- It's weird to talk about LLVM here, since this is the Clang documentation.  
Clang's behavior is not specified in terms of the IR it generates; it's 
specified in terms of the formal behavior of the source code.  Therefore this 
documentation should talk about things using concepts from an appropriate 
language standard whenever possible; in this case, C99 works.

- It's weird to bring up all these different rounding modes when this option 
doesn't actually let you do anything with them.  If you want to talk about 
rounding modes in general that's fine as a way of informing the programmer, but 
we shouldn't give them information they can't use.

- I don't think `-fno-rounding-math` is actually equivalent to forcing the use 
of the `tonearest` rounding mode; I think it *assumes* that the rounding mode 
is set to `tonearest`.  (Or am I wrong and this is actually guaranteed by ABI?)

- I don't think we want to *define* `-frounding-math` as exactly equivalent to 
`-ffp-model=strict`.  That might be a convenient implementation for now, but it 
seems to me that `-frounding-math` still allows some optimizations that 
`-ffp-model=strict` wouldn't.

With that in mind, I'd suggest something like this:

> Force floating-point operations to honor the dynamically-set rounding mode by 
> default.
>
> The result of a floating-point operation often cannot be exactly represented 
> in the result type and therefore must be rounded.  IEEE 754 describes 
> different rounding modes that control how to perform this rounding, not all 
> of which are supported by all implementations.  C provides interfaces 
> (``fesetround`` and ``fesetenv``) for dynamically controlling the rounding 
> mode, and while it also recommends certain conventions for changing the 
> rounding mode, these conventions are not typically enforced in the ABI.  
> Since the rounding mode changes the numerical result of operations, the 
> compiler must understand something about it in order to optimize floating 
> point operations.
>
> Note that floating-point operations performed as part of constant 
> initialization are formally performed prior to the start of the program and 
> are therefore not subject to the current rounding mode.  This includes the 
> initialization of global variables and local ``static`` variables.  
> Floating-point operations in these contexts will be rounded using 
> ``FE_TONEAREST``.
>
> - The option ``-fno-rounding-math`` allows the compiler to assume that the 
> rounding mode is set to ``FE_TONEAREST``.  This is the default.
> - The option ``-frounding-math`` forces the compiler to honor the 
> dynamically-set rounding mode.  This prevents optimizations which might 
> affect results if the rounding mode changes or is different from the default; 
> for example, it prevents floating-point operations from being reordered 
> across most calls and prevents constant-folding when the result is not 
> exactly representable.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D62731



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


[PATCH] D69180: [Format] Add format check for coroutine keywords with negative numbers

2019-10-18 Thread Jonathan Thomas via Phabricator via cfe-commits
jonathoma updated this revision to Diff 225671.
jonathoma added a comment.

Rebase onto master


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69180

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6912,6 +6912,7 @@
   verifyFormat("alignof(char);", getGoogleStyle());
 
   verifyFormat("return -1;");
+  verifyFormat("throw -1;");
   verifyFormat("switch (a) {\n"
"case -1:\n"
"  break;\n"
@@ -6925,6 +6926,9 @@
   verifyFormat("int a = /* confusing comment */ -1;");
   // FIXME: The space after 'i' is wrong, but hopefully, this is a rare case.
   verifyFormat("int a = i /* confusing comment */++;");
+
+  verifyFormat("co_yield -1;");
+  verifyFormat("co_return -1;");
 }
 
 TEST_F(FormatTest, DoesNotIndentRelativeToUnaryOperators) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1756,7 +1756,8 @@
 // Use heuristics to recognize unary operators.
 if (PrevToken->isOneOf(tok::equal, tok::l_paren, tok::comma, tok::l_square,
tok::question, tok::colon, tok::kw_return,
-   tok::kw_case, tok::at, tok::l_brace))
+   tok::kw_case, tok::at, tok::l_brace, tok::kw_throw,
+   tok::kw_co_return, tok_kw_co_yield))
   return TT_UnaryOperator;
 
 // There can't be two consecutive binary operators.


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6912,6 +6912,7 @@
   verifyFormat("alignof(char);", getGoogleStyle());
 
   verifyFormat("return -1;");
+  verifyFormat("throw -1;");
   verifyFormat("switch (a) {\n"
"case -1:\n"
"  break;\n"
@@ -6925,6 +6926,9 @@
   verifyFormat("int a = /* confusing comment */ -1;");
   // FIXME: The space after 'i' is wrong, but hopefully, this is a rare case.
   verifyFormat("int a = i /* confusing comment */++;");
+
+  verifyFormat("co_yield -1;");
+  verifyFormat("co_return -1;");
 }
 
 TEST_F(FormatTest, DoesNotIndentRelativeToUnaryOperators) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1756,7 +1756,8 @@
 // Use heuristics to recognize unary operators.
 if (PrevToken->isOneOf(tok::equal, tok::l_paren, tok::comma, tok::l_square,
tok::question, tok::colon, tok::kw_return,
-   tok::kw_case, tok::at, tok::l_brace))
+   tok::kw_case, tok::at, tok::l_brace, tok::kw_throw,
+   tok::kw_co_return, tok_kw_co_yield))
   return TT_UnaryOperator;
 
 // There can't be two consecutive binary operators.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69180: [Format] Add format check for coroutine keywords with negative numbers

2019-10-18 Thread Jonathan Thomas via Phabricator via cfe-commits
jonathoma updated this revision to Diff 225672.
jonathoma added a comment.

Rebase properly


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69180

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6926,6 +6926,9 @@
   verifyFormat("int a = /* confusing comment */ -1;");
   // FIXME: The space after 'i' is wrong, but hopefully, this is a rare case.
   verifyFormat("int a = i /* confusing comment */++;");
+
+  verifyFormat("co_yield -1;");
+  verifyFormat("co_return -1;");
 }
 
 TEST_F(FormatTest, DoesNotIndentRelativeToUnaryOperators) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1757,7 +1757,8 @@
 // Use heuristics to recognize unary operators.
 if (PrevToken->isOneOf(tok::equal, tok::l_paren, tok::comma, tok::l_square,
tok::question, tok::colon, tok::kw_return,
-   tok::kw_case, tok::at, tok::l_brace, tok::kw_throw))
+   tok::kw_case, tok::at, tok::l_brace, tok::kw_throw,
+   tok::kw_co_return, tok_kw_co_yield))
   return TT_UnaryOperator;
 
 // There can't be two consecutive binary operators.


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6926,6 +6926,9 @@
   verifyFormat("int a = /* confusing comment */ -1;");
   // FIXME: The space after 'i' is wrong, but hopefully, this is a rare case.
   verifyFormat("int a = i /* confusing comment */++;");
+
+  verifyFormat("co_yield -1;");
+  verifyFormat("co_return -1;");
 }
 
 TEST_F(FormatTest, DoesNotIndentRelativeToUnaryOperators) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1757,7 +1757,8 @@
 // Use heuristics to recognize unary operators.
 if (PrevToken->isOneOf(tok::equal, tok::l_paren, tok::comma, tok::l_square,
tok::question, tok::colon, tok::kw_return,
-   tok::kw_case, tok::at, tok::l_brace, tok::kw_throw))
+   tok::kw_case, tok::at, tok::l_brace, tok::kw_throw,
+   tok::kw_co_return, tok_kw_co_yield))
   return TT_UnaryOperator;
 
 // There can't be two consecutive binary operators.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69186: Refactor DependencyScanningTool to its own file

2019-10-18 Thread Kousik Kumar via Phabricator via cfe-commits
kousikk created this revision.
kousikk added reviewers: arphaman, jkorous, Bigcheese, dexonsmith.
Herald added subscribers: cfe-commits, mgorny.
Herald added a project: clang.
kousikk updated this revision to Diff 225667.
kousikk added a comment.

Lint fixes


There's no behavior change - just moving DependencyScanningTool to its own file 
since this tool can be reused across both clang-scan-deps binary and an 
interface
exposed as part of libClang APIs.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69186

Files:
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
  clang/lib/Tooling/DependencyScanning/CMakeLists.txt
  clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
  clang/tools/clang-scan-deps/ClangScanDeps.cpp

Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -10,6 +10,7 @@
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/DependencyScanning/DependencyScanningService.h"
 #include "clang/Tooling/DependencyScanning/DependencyScanningWorker.h"
+#include "clang/Tooling/DependencyScanning/DependencyScanningTool.h"
 #include "clang/Tooling/JSONCompilationDatabase.h"
 #include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/Options.h"
@@ -38,101 +39,6 @@
   raw_ostream &OS;
 };
 
-/// The high-level implementation of the dependency discovery tool that runs on
-/// an individual worker thread.
-class DependencyScanningTool {
-public:
-  /// Construct a dependency scanning tool.
-  ///
-  /// \param Compilations The reference to the compilation database that's
-  /// used by the clang tool.
-  DependencyScanningTool(DependencyScanningService &Service,
- const tooling::CompilationDatabase &Compilations,
- SharedStream &OS, SharedStream &Errs)
-  : Worker(Service), Compilations(Compilations), OS(OS), Errs(Errs) {}
-
-  /// Print out the dependency information into a string using the dependency
-  /// file format that is specified in the options (-MD is the default) and
-  /// return it.
-  ///
-  /// \returns A \c StringError with the diagnostic output if clang errors
-  /// occurred, dependency file contents otherwise.
-  llvm::Expected getDependencyFile(const std::string &Input,
-StringRef CWD) {
-/// Prints out all of the gathered dependencies into a string.
-class DependencyPrinterConsumer : public DependencyConsumer {
-public:
-  void handleFileDependency(const DependencyOutputOptions &Opts,
-StringRef File) override {
-if (!this->Opts)
-  this->Opts = std::make_unique(Opts);
-Dependencies.push_back(File);
-  }
-
-  void printDependencies(std::string &S) {
-if (!Opts)
-  return;
-
-class DependencyPrinter : public DependencyFileGenerator {
-public:
-  DependencyPrinter(DependencyOutputOptions &Opts,
-ArrayRef Dependencies)
-  : DependencyFileGenerator(Opts) {
-for (const auto &Dep : Dependencies)
-  addDependency(Dep);
-  }
-
-  void printDependencies(std::string &S) {
-llvm::raw_string_ostream OS(S);
-outputDependencyFile(OS);
-  }
-};
-
-DependencyPrinter Generator(*Opts, Dependencies);
-Generator.printDependencies(S);
-  }
-
-private:
-  std::unique_ptr Opts;
-  std::vector Dependencies;
-};
-
-DependencyPrinterConsumer Consumer;
-auto Result =
-Worker.computeDependencies(Input, CWD, Compilations, Consumer);
-if (Result)
-  return std::move(Result);
-std::string Output;
-Consumer.printDependencies(Output);
-return Output;
-  }
-
-  /// Computes the dependencies for the given file and prints them out.
-  ///
-  /// \returns True on error.
-  bool runOnFile(const std::string &Input, StringRef CWD) {
-auto MaybeFile = getDependencyFile(Input, CWD);
-if (!MaybeFile) {
-  llvm::handleAllErrors(
-  MaybeFile.takeError(), [this, &Input](llvm::StringError &Err) {
-Errs.applyLocked([&](raw_ostream &OS) {
-  OS << "Error while scanning dependencies for " << Input << ":\n";
-  OS << Err.getMessage();
-});
-  });
-  return true;
-}
-OS.applyLocked([&](raw_ostream &OS) { OS << *MaybeFile; });
-return false;
-  }
-
-private:
-  DependencyScanningWorker Worker;
-  const tooling::CompilationDatabase &Compilations;
-  SharedStream &OS;
-  SharedStream &Errs;
-};
-
 llvm::cl::opt Help("h", llvm::cl::desc("Alias for -help"),
  llvm::cl::Hidden);
 
@@ -191,6 +97,28 @@
   return ObjFileName.str();
 }
 
+/// Takes the result of a dependency scan and pr

[PATCH] D69186: Refactor DependencyScanningTool to its own file

2019-10-18 Thread Kousik Kumar via Phabricator via cfe-commits
kousikk updated this revision to Diff 225667.
kousikk added a comment.

Lint fixes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69186

Files:
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
  clang/lib/Tooling/DependencyScanning/CMakeLists.txt
  clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
  clang/tools/clang-scan-deps/ClangScanDeps.cpp

Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -10,6 +10,7 @@
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/DependencyScanning/DependencyScanningService.h"
 #include "clang/Tooling/DependencyScanning/DependencyScanningWorker.h"
+#include "clang/Tooling/DependencyScanning/DependencyScanningTool.h"
 #include "clang/Tooling/JSONCompilationDatabase.h"
 #include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/Options.h"
@@ -38,101 +39,6 @@
   raw_ostream &OS;
 };
 
-/// The high-level implementation of the dependency discovery tool that runs on
-/// an individual worker thread.
-class DependencyScanningTool {
-public:
-  /// Construct a dependency scanning tool.
-  ///
-  /// \param Compilations The reference to the compilation database that's
-  /// used by the clang tool.
-  DependencyScanningTool(DependencyScanningService &Service,
- const tooling::CompilationDatabase &Compilations,
- SharedStream &OS, SharedStream &Errs)
-  : Worker(Service), Compilations(Compilations), OS(OS), Errs(Errs) {}
-
-  /// Print out the dependency information into a string using the dependency
-  /// file format that is specified in the options (-MD is the default) and
-  /// return it.
-  ///
-  /// \returns A \c StringError with the diagnostic output if clang errors
-  /// occurred, dependency file contents otherwise.
-  llvm::Expected getDependencyFile(const std::string &Input,
-StringRef CWD) {
-/// Prints out all of the gathered dependencies into a string.
-class DependencyPrinterConsumer : public DependencyConsumer {
-public:
-  void handleFileDependency(const DependencyOutputOptions &Opts,
-StringRef File) override {
-if (!this->Opts)
-  this->Opts = std::make_unique(Opts);
-Dependencies.push_back(File);
-  }
-
-  void printDependencies(std::string &S) {
-if (!Opts)
-  return;
-
-class DependencyPrinter : public DependencyFileGenerator {
-public:
-  DependencyPrinter(DependencyOutputOptions &Opts,
-ArrayRef Dependencies)
-  : DependencyFileGenerator(Opts) {
-for (const auto &Dep : Dependencies)
-  addDependency(Dep);
-  }
-
-  void printDependencies(std::string &S) {
-llvm::raw_string_ostream OS(S);
-outputDependencyFile(OS);
-  }
-};
-
-DependencyPrinter Generator(*Opts, Dependencies);
-Generator.printDependencies(S);
-  }
-
-private:
-  std::unique_ptr Opts;
-  std::vector Dependencies;
-};
-
-DependencyPrinterConsumer Consumer;
-auto Result =
-Worker.computeDependencies(Input, CWD, Compilations, Consumer);
-if (Result)
-  return std::move(Result);
-std::string Output;
-Consumer.printDependencies(Output);
-return Output;
-  }
-
-  /// Computes the dependencies for the given file and prints them out.
-  ///
-  /// \returns True on error.
-  bool runOnFile(const std::string &Input, StringRef CWD) {
-auto MaybeFile = getDependencyFile(Input, CWD);
-if (!MaybeFile) {
-  llvm::handleAllErrors(
-  MaybeFile.takeError(), [this, &Input](llvm::StringError &Err) {
-Errs.applyLocked([&](raw_ostream &OS) {
-  OS << "Error while scanning dependencies for " << Input << ":\n";
-  OS << Err.getMessage();
-});
-  });
-  return true;
-}
-OS.applyLocked([&](raw_ostream &OS) { OS << *MaybeFile; });
-return false;
-  }
-
-private:
-  DependencyScanningWorker Worker;
-  const tooling::CompilationDatabase &Compilations;
-  SharedStream &OS;
-  SharedStream &Errs;
-};
-
 llvm::cl::opt Help("h", llvm::cl::desc("Alias for -help"),
  llvm::cl::Hidden);
 
@@ -191,6 +97,28 @@
   return ObjFileName.str();
 }
 
+/// Takes the result of a dependency scan and prints error / dependency files
+/// based on the result.
+///
+/// \returns True on error.
+static bool handleDependencyToolResult(const std::string &Input,
+  llvm::Expected &MaybeFile,
+  SharedStream &OS,
+  Shar

[PATCH] D69184: [libTooling] Introduce general combinator for fixed-value `MatchConsumer`s.

2019-10-18 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added a reviewer: gribozavr.
Herald added a project: clang.

This revision generalizes the (deprecated) `clang::tooling::text` combinator to
a `value` combinator, which works for any type. Aside from being more general,
it resolves the naming confict between `clang::tooling::text` and
`clang::transformer::text`, which has a subtly different meaning.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69184

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

Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- clang/unittests/Tooling/TransformerTest.cpp
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -21,6 +21,7 @@
 namespace {
 using ::testing::IsEmpty;
 using transformer::RewriteRule;
+using transformer::value;
 
 constexpr char KHeaderContents[] = R"cc(
   struct string {
@@ -147,7 +148,8 @@
   on(expr(hasType(isOrPointsTo(StringType)))
  .bind(StringExpr)),
   callee(cxxMethodDecl(hasName("c_str")),
-  change(text("REPLACED")), text("Use size() method directly on string."));
+  change(value("REPLACED")),
+  value("Use size() method directly on string."));
   return R;
 }
 
@@ -171,7 +173,7 @@
 hasName("proto::ProtoCommandLineFlag"
.bind(Flag)),
 unless(callee(cxxMethodDecl(hasName("GetProto"),
-  change(node(Flag), text("EXPR")));
+  change(node(Flag), value("EXPR")));
 
   std::string Input = R"cc(
 proto::ProtoCommandLineFlag flag;
@@ -189,7 +191,7 @@
 
 TEST_F(TransformerTest, AddIncludeQuoted) {
   RewriteRule Rule = makeRule(callExpr(callee(functionDecl(hasName("f",
-  change(text("other()")));
+  change(value("other()")));
   addInclude(Rule, "clang/OtherLib.h");
 
   std::string Input = R"cc(
@@ -207,7 +209,7 @@
 
 TEST_F(TransformerTest, AddIncludeAngled) {
   RewriteRule Rule = makeRule(callExpr(callee(functionDecl(hasName("f",
-  change(text("other()")));
+  change(value("other()")));
   addInclude(Rule, "clang/OtherLib.h", transformer::IncludeFormat::Angled);
 
   std::string Input = R"cc(
@@ -226,7 +228,7 @@
 TEST_F(TransformerTest, NodePartNameNamedDecl) {
   StringRef Fun = "fun";
   RewriteRule Rule = makeRule(functionDecl(hasName("bad")).bind(Fun),
-  change(name(Fun), text("good")));
+  change(name(Fun), value("good")));
 
   std::string Input = R"cc(
 int bad(int x);
@@ -258,7 +260,7 @@
 
   StringRef Ref = "ref";
   testRule(makeRule(declRefExpr(to(functionDecl(hasName("bad".bind(Ref),
-change(name(Ref), text("good"))),
+change(name(Ref), value("good"))),
Input, Expected);
 }
 
@@ -276,7 +278,7 @@
 
   StringRef Ref = "ref";
   Transformer T(makeRule(declRefExpr(to(functionDecl())).bind(Ref),
- change(name(Ref), text("good"))),
+ change(name(Ref), value("good"))),
 consumer());
   T.registerMatchers(&MatchFinder);
   EXPECT_FALSE(rewrite(Input));
@@ -285,7 +287,7 @@
 TEST_F(TransformerTest, NodePartMember) {
   StringRef E = "expr";
   RewriteRule Rule = makeRule(memberExpr(member(hasName("bad"))).bind(E),
-  change(member(E), text("good")));
+  change(member(E), value("good")));
 
   std::string Input = R"cc(
 struct S {
@@ -338,7 +340,7 @@
   )cc";
 
   StringRef E = "expr";
-  testRule(makeRule(memberExpr().bind(E), change(member(E), text("good"))),
+  testRule(makeRule(memberExpr().bind(E), change(member(E), value("good"))),
Input, Expected);
 }
 
@@ -370,7 +372,7 @@
 
   StringRef MemExpr = "member";
   testRule(makeRule(memberExpr().bind(MemExpr),
-change(member(MemExpr), text("good"))),
+change(member(MemExpr), value("good"))),
Input, Expected);
 }
 
@@ -389,7 +391,7 @@
 
   StringRef Ret = "return";
   testRule(makeRule(returnStmt().bind(Ret),
-insertBefore(statement(Ret), text("int y = 3;"))),
+insertBefore(statement(Ret), value("int y = 3;"))),
Input, Expected);
 }
 
@@ -410,7 +412,7 @@
 
   StringRef Decl = "decl";
   testRule(makeRule(declStmt().bind(Decl),
-insertAfter(statement(Decl), text("int y = 3;"))),
+insertAfter(statement(Decl), value("int y = 3;"))),
Input, Expected);
 }
 
@@ -451,9 +453,9 @@
   StringRef C = "C", T = "T", E = "E";
   testRule(makeRule(ifStmt(hasCondition(expr().bind(C)),
hasThen(stmt().bi

[PATCH] D62731: Add support for options -frounding-math, ftrapping-math, -fp-model=, and -fp-exception-behavior=, : Specify floating point behavior

2019-10-18 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

Ping.  Hoping for code review so I can move this forward.  Affirmative or 
negative, please let me know.  Thank you! --Melanie


Repository:
  rL LLVM

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

https://reviews.llvm.org/D62731



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


[PATCH] D69181: [clang-tidy] Adding misc-signal-terminated-thread check

2019-10-18 Thread Kocsis Ábel via Phabricator via cfe-commits
abelkocsis created this revision.
abelkocsis added reviewers: aaron.ballman, alexfh, JonasToth, steakhal, 
Charusso.
abelkocsis added a project: clang-tools-extra.
Herald added subscribers: cfe-commits, mgehre, jfb, dexonsmith, steven_wu, 
hiraditya, xazax.hun, mgorny, mehdi_amini.
Herald added a reviewer: jfb.
Herald added a project: clang.

According to 
https://wiki.sei.cmu.edu/confluence/display/c/POS44-C.+Do+not+use+signals+to+terminate+threads
misc-signal-terminated-thread check is created. The check warn if 
`pthread_kill` function is called with `SIGTERM` signal.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D69181

Files:
  clang-tools-extra/clang-tidy/misc/BadSignalToKillThreadCheck.cpp
  clang-tools-extra/clang-tidy/misc/BadSignalToKillThreadCheck.h
  clang-tools-extra/clang-tidy/misc/CMakeLists.txt
  clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/misc-bad-signal-to-kill-thread.rst
  clang-tools-extra/test/clang-tidy/misc-bad-signal-to-kill-thread.cpp

Index: clang-tools-extra/test/clang-tidy/misc-bad-signal-to-kill-thread.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/misc-bad-signal-to-kill-thread.cpp
@@ -0,0 +1,30 @@
+// RUN: %check_clang_tidy %s misc-bad-signal-to-kill-thread %t
+
+#define SIGTERM 15
+using pthread_t = int;
+using pthread_attr_t = int;
+
+int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
+   void *(*start_routine)(void *), void *arg);
+
+int pthread_kill(pthread_t thread, int sig);
+
+int pthread_cancel(pthread_t thread);
+
+void *test_func_return_a_pointer(void *foo);
+
+int main() {
+  int result;
+  pthread_t thread;
+
+  if ((result = pthread_create(&thread, nullptr, test_func_return_a_pointer, 0)) != 0) {
+  }
+  if ((result = pthread_kill(thread, SIGTERM)) != 0) {
+// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: Thread should not be terminated by signal. [misc-bad-signal-to-kill-thread]
+  }
+
+  if ((result = pthread_cancel(thread)) != 0) {
+  }
+
+  return 0;
+}
\ No newline at end of file
Index: clang-tools-extra/docs/clang-tidy/checks/misc-bad-signal-to-kill-thread.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/misc-bad-signal-to-kill-thread.rst
@@ -0,0 +1,10 @@
+.. title:: clang-tidy - misc-bad-signal-to-kill-thread
+
+misc-bad-signal-to-kill-thread
+==
+
+Warn on uses of the ``pthread_kill`` function when thread is 
+terminated by ``SIGTERM`` signal.
+.. code-block: c++
+
+pthread_kill(thread, SIGTERM);
\ No newline at end of file
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -282,6 +282,7 @@
llvm-prefer-isa-or-dyn-cast-in-conditionals
llvm-prefer-register-over-unsigned
llvm-twine-local
+   misc-bad-signal-to-kill-thread
misc-definitions-in-headers
misc-misplaced-const
misc-new-delete-overloads
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -73,6 +73,13 @@
   Finds instances where variables with static storage are initialized
   dynamically in header files.
 
+- New :doc:`misc-signal-terminated-thread
+  ` check.
+
+  Do not send an uncaught signal to kill a thread because the signal kills the entire process, not just the individual thread. 
+  To learn more about this rule please visit the following page:
+  https://wiki.sei.cmu.edu/confluence/display/c/POS44-C.+Do+not+use+signals+to+terminate+threads
+
 - New :doc:`bugprone-infinite-loop
   ` check.
 
Index: clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
===
--- clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
+++ clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
@@ -9,6 +9,7 @@
 #include "../ClangTidy.h"
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
+#include "BadSignalToKillThreadCheck.h"
 #include "DefinitionsInHeadersCheck.h"
 #include "MisplacedConstCheck.h"
 #include "NewDeleteOverloadsCheck.h"
@@ -30,6 +31,8 @@
 class MiscModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck(
+"misc-bad-signal-to-kill-thread");
 CheckFactories.registerCheck(
 "misc-definitions-in-headers");
 CheckFactories.registerCheck("misc-misplaced-const");
Index: clang-tools-extra/clang-tidy/misc/CMakeLists.txt
==

[PATCH] D69171: [clang-fuzzer] Add new fuzzer target for Objective-C

2019-10-18 Thread David Goldman via Phabricator via cfe-commits
dgoldman added a comment.

In D69171#1714624 , @sammccall wrote:

> Rather than adding a new fuzzer binary, can we make the language an option?
>  The whole implementation seems almost identical down to 
> handleobjc/handlecxx...


It's similar at the moment (was initially going to add more flags), but I could 
swap it over to read an integer/Boolean to swap between the two languages. If 
we want to modify them in the future (which we might be interested in depending 
on how well this works) it probably makes sense to keep them separate though.


Repository:
  rC Clang

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

https://reviews.llvm.org/D69171



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


[PATCH] D69144: [Format] Add format check for throwing negative numbers

2019-10-18 Thread Brian Gesiak via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7f704320b058: [Format] Add format check for throwing 
negative numbers (authored by modocache).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69144

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6912,6 +6912,7 @@
   verifyFormat("alignof(char);", getGoogleStyle());
 
   verifyFormat("return -1;");
+  verifyFormat("throw -1;");
   verifyFormat("switch (a) {\n"
"case -1:\n"
"  break;\n"
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1757,7 +1757,7 @@
 // Use heuristics to recognize unary operators.
 if (PrevToken->isOneOf(tok::equal, tok::l_paren, tok::comma, tok::l_square,
tok::question, tok::colon, tok::kw_return,
-   tok::kw_case, tok::at, tok::l_brace))
+   tok::kw_case, tok::at, tok::l_brace, tok::kw_throw))
   return TT_UnaryOperator;
 
 // There can't be two consecutive binary operators.


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6912,6 +6912,7 @@
   verifyFormat("alignof(char);", getGoogleStyle());
 
   verifyFormat("return -1;");
+  verifyFormat("throw -1;");
   verifyFormat("switch (a) {\n"
"case -1:\n"
"  break;\n"
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1757,7 +1757,7 @@
 // Use heuristics to recognize unary operators.
 if (PrevToken->isOneOf(tok::equal, tok::l_paren, tok::comma, tok::l_square,
tok::question, tok::colon, tok::kw_return,
-   tok::kw_case, tok::at, tok::l_brace))
+   tok::kw_case, tok::at, tok::l_brace, tok::kw_throw))
   return TT_UnaryOperator;
 
 // There can't be two consecutive binary operators.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r375258 - [Format] Add format check for throwing negative numbers

2019-10-18 Thread Brian Gesiak via cfe-commits
Author: modocache
Date: Fri Oct 18 09:59:02 2019
New Revision: 375258

URL: http://llvm.org/viewvc/llvm-project?rev=375258&view=rev
Log:
[Format] Add format check for throwing negative numbers

Summary:
The code `throw -1;` is currently formatted by clang-format as
`throw - 1;`. This diff adds a fix for this edge case and a test to check
for this in the future.

For context, I am looking into a related bug in the clang-formatting of
coroutine keywords: `co_yield -1;` is also reformatted in this manner
as `co_yield - 1;`. A later diff will add these changes and tests for the
`co_yield` and `co_return` keywords.

Patch by Jonathan Thomas (jonathoma)!

Reviewers: modocache, sammccall, Quuxplusone

Reviewed By: sammccall

Subscribers: cfe-commits

Tags: #clang-format, #clang

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

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

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=375258&r1=375257&r2=375258&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri Oct 18 09:59:02 2019
@@ -1757,7 +1757,7 @@ private:
 // Use heuristics to recognize unary operators.
 if (PrevToken->isOneOf(tok::equal, tok::l_paren, tok::comma, tok::l_square,
tok::question, tok::colon, tok::kw_return,
-   tok::kw_case, tok::at, tok::l_brace))
+   tok::kw_case, tok::at, tok::l_brace, tok::kw_throw))
   return TT_UnaryOperator;
 
 // There can't be two consecutive binary operators.

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=375258&r1=375257&r2=375258&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Fri Oct 18 09:59:02 2019
@@ -6912,6 +6912,7 @@ TEST_F(FormatTest, UnderstandsUnaryOpera
   verifyFormat("alignof(char);", getGoogleStyle());
 
   verifyFormat("return -1;");
+  verifyFormat("throw -1;");
   verifyFormat("switch (a) {\n"
"case -1:\n"
"  break;\n"


___
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

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

LLVM buildmaster will be updated and restarted in an hour.

Thanks

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


r375257 - [DOCS]Update list of implemented constructs, NFC.

2019-10-18 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Oct 18 09:53:54 2019
New Revision: 375257

URL: http://llvm.org/viewvc/llvm-project?rev=375257&view=rev
Log:
[DOCS]Update list of implemented constructs, NFC.

Modified:
cfe/trunk/docs/OpenMPSupport.rst

Modified: cfe/trunk/docs/OpenMPSupport.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/OpenMPSupport.rst?rev=375257&r1=375256&r2=375257&view=diff
==
--- cfe/trunk/docs/OpenMPSupport.rst (original)
+++ cfe/trunk/docs/OpenMPSupport.rst Fri Oct 18 09:53:54 2019
@@ -181,9 +181,9 @@ implementation.
 
+--+--+--+---+
 | task extension   | master taskloop   
   | :good:`done` | 
  |
 
+--+--+--+---+
-| task extension   | parallel master taskloop  
   | :none:`unclaimed`| 
  |
+| task extension   | parallel master taskloop  
   | :none:`done` | 
  |
 
+--+--+--+---+
-| task extension   | master taskloop simd  
   | :none:`unclaimed`| 
  |
+| task extension   | master taskloop simd  
   | :none:`done` | 
  |
 
+--+--+--+---+
 | task extension   | parallel master taskloop simd 
   | :none:`unclaimed`| 
  |
 
+--+--+--+---+


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


[PATCH] D69180: [Format] Add format check for coroutine keywords with negative numbers

2019-10-18 Thread Jonathan Thomas via Phabricator via cfe-commits
jonathoma created this revision.
jonathoma added reviewers: modocache, sammccall, Quuxplusone.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
jonathoma planned changes to this revision.

As a followup to D69144 , this diff fixes the 
coroutine keyword spacing
for co_yield / co_returning negative numbers.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69180

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6912,6 +6912,7 @@
   verifyFormat("alignof(char);", getGoogleStyle());
 
   verifyFormat("return -1;");
+  verifyFormat("throw -1;");
   verifyFormat("switch (a) {\n"
"case -1:\n"
"  break;\n"
@@ -6925,6 +6926,9 @@
   verifyFormat("int a = /* confusing comment */ -1;");
   // FIXME: The space after 'i' is wrong, but hopefully, this is a rare case.
   verifyFormat("int a = i /* confusing comment */++;");
+
+  verifyFormat("co_yield -1;");
+  verifyFormat("co_return -1;");
 }
 
 TEST_F(FormatTest, DoesNotIndentRelativeToUnaryOperators) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1756,7 +1756,8 @@
 // Use heuristics to recognize unary operators.
 if (PrevToken->isOneOf(tok::equal, tok::l_paren, tok::comma, tok::l_square,
tok::question, tok::colon, tok::kw_return,
-   tok::kw_case, tok::at, tok::l_brace))
+   tok::kw_case, tok::at, tok::l_brace, tok::kw_throw,
+   tok::kw_co_return, tok_kw_co_yield))
   return TT_UnaryOperator;
 
 // There can't be two consecutive binary operators.


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6912,6 +6912,7 @@
   verifyFormat("alignof(char);", getGoogleStyle());
 
   verifyFormat("return -1;");
+  verifyFormat("throw -1;");
   verifyFormat("switch (a) {\n"
"case -1:\n"
"  break;\n"
@@ -6925,6 +6926,9 @@
   verifyFormat("int a = /* confusing comment */ -1;");
   // FIXME: The space after 'i' is wrong, but hopefully, this is a rare case.
   verifyFormat("int a = i /* confusing comment */++;");
+
+  verifyFormat("co_yield -1;");
+  verifyFormat("co_return -1;");
 }
 
 TEST_F(FormatTest, DoesNotIndentRelativeToUnaryOperators) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1756,7 +1756,8 @@
 // Use heuristics to recognize unary operators.
 if (PrevToken->isOneOf(tok::equal, tok::l_paren, tok::comma, tok::l_square,
tok::question, tok::colon, tok::kw_return,
-   tok::kw_case, tok::at, tok::l_brace))
+   tok::kw_case, tok::at, tok::l_brace, tok::kw_throw,
+   tok::kw_co_return, tok_kw_co_yield))
   return TT_UnaryOperator;
 
 // There can't be two consecutive binary operators.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69179: [Format] Add format check for coroutine keywords with negative numbers

2019-10-18 Thread Jonathan Thomas via Phabricator via cfe-commits
jonathoma created this revision.
Herald added subscribers: cfe-commits, modocache.
Herald added a project: clang.
jonathoma retitled this revision from "[Format] Add format check for throwing 
negative numbers" to "[Format] Add format check for coroutine keywords with 
negative numbers".
jonathoma edited the summary of this revision.
jonathoma abandoned this revision.

As a followup to D69144 , this diff fixes the 
coroutine keyword spacing
for `co_yield` / `co_return`ing negative numbers.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69179

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6912,6 +6912,7 @@
   verifyFormat("alignof(char);", getGoogleStyle());
 
   verifyFormat("return -1;");
+  verifyFormat("throw -1;");
   verifyFormat("switch (a) {\n"
"case -1:\n"
"  break;\n"
@@ -6925,6 +6926,9 @@
   verifyFormat("int a = /* confusing comment */ -1;");
   // FIXME: The space after 'i' is wrong, but hopefully, this is a rare case.
   verifyFormat("int a = i /* confusing comment */++;");
+
+  verifyFormat("co_yield -1;");
+  verifyFormat("co_return -1;");
 }
 
 TEST_F(FormatTest, DoesNotIndentRelativeToUnaryOperators) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1693,7 +1693,8 @@
 if (PrevToken->isOneOf(tok::l_paren, tok::l_square, tok::l_brace,
tok::comma, tok::semi, tok::kw_return, tok::colon,
tok::equal, tok::kw_delete, tok::kw_sizeof,
-   tok::kw_throw) ||
+   tok::kw_throw, tok::kw_co_return,
+   tok::kw_co_yield) ||
 PrevToken->isOneOf(TT_BinaryOperator, TT_ConditionalExpr,
TT_UnaryOperator, TT_CastRParen))
   return TT_UnaryOperator;
@@ -1756,7 +1757,7 @@
 // Use heuristics to recognize unary operators.
 if (PrevToken->isOneOf(tok::equal, tok::l_paren, tok::comma, tok::l_square,
tok::question, tok::colon, tok::kw_return,
-   tok::kw_case, tok::at, tok::l_brace))
+   tok::kw_case, tok::at, tok::l_brace, tok::kw_throw))
   return TT_UnaryOperator;
 
 // There can't be two consecutive binary operators.


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6912,6 +6912,7 @@
   verifyFormat("alignof(char);", getGoogleStyle());
 
   verifyFormat("return -1;");
+  verifyFormat("throw -1;");
   verifyFormat("switch (a) {\n"
"case -1:\n"
"  break;\n"
@@ -6925,6 +6926,9 @@
   verifyFormat("int a = /* confusing comment */ -1;");
   // FIXME: The space after 'i' is wrong, but hopefully, this is a rare case.
   verifyFormat("int a = i /* confusing comment */++;");
+
+  verifyFormat("co_yield -1;");
+  verifyFormat("co_return -1;");
 }
 
 TEST_F(FormatTest, DoesNotIndentRelativeToUnaryOperators) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1693,7 +1693,8 @@
 if (PrevToken->isOneOf(tok::l_paren, tok::l_square, tok::l_brace,
tok::comma, tok::semi, tok::kw_return, tok::colon,
tok::equal, tok::kw_delete, tok::kw_sizeof,
-   tok::kw_throw) ||
+   tok::kw_throw, tok::kw_co_return,
+   tok::kw_co_yield) ||
 PrevToken->isOneOf(TT_BinaryOperator, TT_ConditionalExpr,
TT_UnaryOperator, TT_CastRParen))
   return TT_UnaryOperator;
@@ -1756,7 +1757,7 @@
 // Use heuristics to recognize unary operators.
 if (PrevToken->isOneOf(tok::equal, tok::l_paren, tok::comma, tok::l_square,
tok::question, tok::colon, tok::kw_return,
-   tok::kw_case, tok::at, tok::l_brace))
+   tok::kw_case, tok::at, tok::l_brace, tok::kw_throw))
   return TT_UnaryOperator;
 
 // There can't be two consecutive binary operators.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r375224 - [ThinLTOCodeGenerator] Add support for index-based WPD

2019-10-18 Thread Eugene Leviant via cfe-commits
Author: evgeny777
Date: Fri Oct 18 04:58:21 2019
New Revision: 375224

URL: http://llvm.org/viewvc/llvm-project?rev=375224&view=rev
Log:
[ThinLTOCodeGenerator] Add support for index-based WPD

This is clang part of the patch. It adds -flto-unit flag for thin LTO
builds on Mac and PS4

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/lto-unit.c

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=375224&r1=375223&r2=375224&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Fri Oct 18 04:58:21 2019
@@ -3631,13 +3631,7 @@ void Clang::ConstructJob(Compilation &C,
 
 if (D.isUsingLTO() && !isDeviceOffloadAction) {
   Args.AddLastArg(CmdArgs, options::OPT_flto, options::OPT_flto_EQ);
-
-  // The Darwin and PS4 linkers currently use the legacy LTO API, which
-  // does not support LTO unit features (CFI, whole program vtable opt)
-  // under ThinLTO.
-  if (!(RawTriple.isOSDarwin() || RawTriple.isPS4()) ||
-  D.getLTOMode() == LTOK_Full)
-CmdArgs.push_back("-flto-unit");
+  CmdArgs.push_back("-flto-unit");
 }
   }
 

Modified: cfe/trunk/test/Driver/lto-unit.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/lto-unit.c?rev=375224&r1=375223&r2=375224&view=diff
==
--- cfe/trunk/test/Driver/lto-unit.c (original)
+++ cfe/trunk/test/Driver/lto-unit.c Fri Oct 18 04:58:21 2019
@@ -1,9 +1,8 @@
 // RUN: %clang -target x86_64-unknown-linux -### %s -flto=full 2>&1 | 
FileCheck --check-prefix=UNIT %s
 // RUN: %clang -target x86_64-unknown-linux -### %s -flto=thin 2>&1 | 
FileCheck --check-prefix=UNIT %s
 // RUN: %clang -target x86_64-apple-darwin13.3.0 -### %s -flto=full 2>&1 | 
FileCheck --check-prefix=UNIT %s
-// RUN: %clang -target x86_64-apple-darwin13.3.0 -### %s -flto=thin 2>&1 | 
FileCheck --check-prefix=NOUNIT %s
+// RUN: %clang -target x86_64-apple-darwin13.3.0 -### %s -flto=thin 2>&1 | 
FileCheck --check-prefix=UNIT %s
 // RUN: %clang -target x86_64-scei-ps4 -### %s -flto=full 2>&1 | FileCheck 
--check-prefix=UNIT %s
-// RUN: %clang -target x86_64-scei-ps4 -### %s -flto=thin 2>&1 | FileCheck 
--check-prefix=NOUNIT %s
+// RUN: %clang -target x86_64-scei-ps4 -### %s -flto=thin 2>&1 | FileCheck 
--check-prefix=UNIT %s
 
 // UNIT: "-flto-unit"
-// NOUNIT-NOT: "-flto-unit"


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


Re: [PATCH] D55802: Change CGObjC to use objc intrinsics instead of runtime methods

2019-10-18 Thread Alina Sbirlea via cfe-commits
I only got a chance to look more into this now. I can reproduce it with
re-inserting the "static".

The miscompile is not related to MemorySSA, i.e. disabling all uses of
MemorySSA doesn't help.
It appears to be a GVN bug, but I haven't tracked it further than this.

To repro, see attached .ll files. The only difference is the global
variable being static or not, which in IR translates to internal or
dso_local.
A simple `opt -O3 AssociatedObject_O0_*.ll` shows the difference you
mention.

Reducing the pipeline, I believe the result after the following command is
incorrect.
`opt -globals-aa -gvn AssociatedObject_O0_*.ll`
I'll need to dig deeper to confirm and track down the bug inside the pass.


Thanks,
Alina


On Mon, Sep 30, 2019 at 4:30 AM David Chisnall 
wrote:

> Hi,
>
> Yes, I believe it does still reproduce (at least, with the most recent
> build that I tried).  We worked around the clang bug to make the test pass:
>
>
> https://github.com/gnustep/libobjc2/commit/eab35fce379eb6ab1423dbb6d7908cb782f13458#diff-7f1eea7fdb5c7c3bf21f08d1cfe98a19
>
> Reintroducing the 'static' on deallocCalled reduces the test case to
> unconditionally failing the assert immediately after the pop, and DCEs
> the rest of the code.
>
> David
>
> On 11/09/2019 01:17, Alina Sbirlea wrote:
> > Hi David,
> >
> > Does this still reproduce?
> > I'm seeing the load after the call to autoreleasePoolPop at ToT, but
> > perhaps I'm not using the proper flags?
> > I only checked out the github repo and did "clang
> > -fobjc-runtime=gnustep-2.0 -O3 -emit-llvm -S
> > libobjc2/Test/AssociatedObject.m" with a ToT clang.
> >
> > Thanks,
> > Alina
> >
> >
> > On Sun, Feb 24, 2019 at 9:56 AM Pete Cooper via llvm-commits
> > mailto:llvm-comm...@lists.llvm.org>>
> wrote:
> >
> > Hey David
> >
> > Thanks for letting me know, and analysing it this far!
> >
> > I also can't see anything wrong with the intrinsic.  Its just
> > defined as:
> >
> > def int_objc_autoreleasePoolPop : Intrinsic<[],
> > [llvm_ptr_ty]>;
> >
> >
> > which (I believe) means it has unmodelled side effects so it should
> > have been fine for your example.
> >
> > I'll try build the same file you did and see if I can reproduce.
> >
> > Cheers,
> > Pete
> >
> >> On Feb 24, 2019, at 7:48 AM, David Chisnall via Phabricator
> >> mailto:revi...@reviews.llvm.org>> wrote:
> >>
> >> theraven added a comment.
> >> Herald added a project: LLVM.
> >>
> >> After some bisection, it appears that this is the revision that
> >> introduced the regression in the GNUstep Objective-C runtime test
> >> suite that I reported on the list a few weeks ago.  In this is the
> >> test (compiled with `-fobjc-runtime=gnustep-2.0 -O3` and an ELF
> >> triple):
> >>
> >>
> https://github.com/gnustep/libobjc2/blob/master/Test/AssociatedObject.m
> >>
> >> After this change, Early CSE w/ MemorySSA is determining that the
> >> second load of `deallocCalled` is redundant.  The code goes from:
> >>
> >>%7 = load i1, i1* @deallocCalled, align 1
> >>br i1 %7, label %8, label %9
> >>
> >>  ; :8:  ; preds = %0
> >>call void @__assert(i8* getelementptr inbounds ([5 x i8], [5 x
> >> i8]* @__func__.main, i64 0, i64 0), i8* getelementptr inbounds
> >> ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 26, i8*
> >> getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64
> >> 0)) #5
> >>unreachable
> >>
> >>  ; :9:  ; preds = %0
> >>call void @llvm.objc.autoreleasePoolPop(i8* %1)
> >>%10 = load i1, i1* @deallocCalled, align 1
> >>br i1 %10, label %12, label %11
> >>
> >>  ; :11: ; preds = %9
> >>call void @__assert(i8* getelementptr inbounds ([5 x i8], [5 x
> >> i8]* @__func__.main, i64 0, i64 0), i8* getelementptr inbounds
> >> ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 29, i8*
> >> getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64
> >> 0)) #5
> >>unreachable
> >>
> >> to:
> >>
> >>%7 = load i1, i1* @deallocCalled, align 1
> >>br i1 %7, label %8, label %9
> >>
> >>  ; :8:  ; preds = %0
> >>call void @__assert(i8* getelementptr inbounds ([5 x i8], [5 x
> >> i8]* @__func__.main, i64 0, i64 0), i8* getelementptr inbounds
> >> ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 26, i8*
> >> getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64
> >> 0)) #5
> >>unreachable
> >>
> >>  ; :9:  ; preds = %0
> >>call void @llvm.objc.autoreleasePoolPop(i8* %1)
> >>br i1 %7, label %11, label %10
> >>
> >>  ; :10: ; preds = %9
> >>call void @__assert(i8* getelementptr inbounds ([5

[PATCH] D69177: [clangd] Propogate FS into Tweak::Selection

2019-10-18 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: ilya-biryukov.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay.
Herald added a project: clang.
kadircet added a parent revision: D69165: [clangd] Store Index in 
Tweak::Selection.

Incoming define out-of-line code action needs to access files that
weren't touched during compilation of the translation unit. This patch passes FS
into Tweak::Selection to make files accessible.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69177

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/refactor/Tweak.cpp
  clang-tools-extra/clangd/refactor/Tweak.h
  clang-tools-extra/clangd/unittests/TestTU.cpp
  clang-tools-extra/clangd/unittests/TestTU.h
  clang-tools-extra/clangd/unittests/TweakTesting.cpp

Index: clang-tools-extra/clangd/unittests/TweakTesting.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTesting.cpp
+++ clang-tools-extra/clangd/unittests/TweakTesting.cpp
@@ -72,7 +72,8 @@
   TU.Code = Input.code();
   TU.AdditionalFiles = std::move(ExtraFiles);
   ParsedAST AST = TU.build();
-  Tweak::Selection S(AST, Selection.first, Selection.second, Index);
+  auto FS = TU.getVFS();
+  Tweak::Selection S(AST, Selection.first, Selection.second, Index, FS.get());
   auto PrepareResult = prepareTweak(TweakID, S);
   if (PrepareResult)
 return true;
@@ -94,7 +95,9 @@
   TU.Code = Input.code();
   TU.ExtraArgs = ExtraArgs;
   ParsedAST AST = TU.build();
-  Tweak::Selection S(AST, Selection.first, Selection.second, Index);
+
+  auto FS = TU.getVFS();
+  Tweak::Selection S(AST, Selection.first, Selection.second, Index, FS.get());
 
   auto T = prepareTweak(TweakID, S);
   if (!T) {
Index: clang-tools-extra/clangd/unittests/TestTU.h
===
--- clang-tools-extra/clangd/unittests/TestTU.h
+++ clang-tools-extra/clangd/unittests/TestTU.h
@@ -20,7 +20,9 @@
 #include "ParsedAST.h"
 #include "Path.h"
 #include "index/Index.h"
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/StringMap.h"
+#include "llvm/Support/VirtualFileSystem.h"
 #include "gtest/gtest.h"
 #include 
 #include 
@@ -67,6 +69,7 @@
   ParsedAST build() const;
   SymbolSlab headerSymbols() const;
   std::unique_ptr index() const;
+  llvm::IntrusiveRefCntPtr getVFS() const;
 };
 
 // Look up an index symbol by qualified name, which must be unique.
Index: clang-tools-extra/clangd/unittests/TestTU.cpp
===
--- clang-tools-extra/clangd/unittests/TestTU.cpp
+++ clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -19,7 +19,7 @@
 namespace clang {
 namespace clangd {
 
-ParsedAST TestTU::build() const {
+llvm::IntrusiveRefCntPtr TestTU::getVFS() const {
   std::string FullFilename = testPath(Filename),
   FullHeaderName = testPath(HeaderFilename),
   ImportThunk = testPath("import_thunk.h");
@@ -32,6 +32,13 @@
   Files[FullFilename] = Code;
   Files[FullHeaderName] = HeaderCode;
   Files[ImportThunk] = ThunkContents;
+  return buildTestFS(Files);
+}
+
+ParsedAST TestTU::build() const {
+  std::string FullFilename = testPath(Filename),
+  FullHeaderName = testPath(HeaderFilename),
+  ImportThunk = testPath("import_thunk.h");
 
   std::vector Cmd = {"clang"};
   // FIXME: this shouldn't need to be conditional, but it breaks a
@@ -54,7 +61,7 @@
   Inputs.CompileCommand.CommandLine = {Cmd.begin(), Cmd.end()};
   Inputs.CompileCommand.Directory = testRoot();
   Inputs.Contents = Code;
-  Inputs.FS = buildTestFS(Files);
+  Inputs.FS = getVFS();
   Inputs.Opts = ParseOptions();
   Inputs.Opts.ClangTidyOpts.Checks = ClangTidyChecks;
   Inputs.Opts.ClangTidyOpts.WarningsAsErrors = ClangTidyWarningsAsErrors;
Index: clang-tools-extra/clangd/refactor/Tweak.h
===
--- clang-tools-extra/clangd/refactor/Tweak.h
+++ clang-tools-extra/clangd/refactor/Tweak.h
@@ -30,6 +30,7 @@
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/VirtualFileSystem.h"
 #include 
 
 namespace clang {
@@ -48,7 +49,7 @@
   /// Input to prepare and apply tweaks.
   struct Selection {
 Selection(ParsedAST &AST, unsigned RangeBegin, unsigned RangeEnd,
-  const SymbolIndex *Index);
+  const SymbolIndex *Index, llvm::vfs::FileSystem *FS);
 /// The text of the active document.
 llvm::StringRef Code;
 /// Parsed AST of the active file.
@@ -64,6 +65,9 @@
 SelectionTree ASTSelection;
 /// The Index being used by ClangdServer.
 const SymbolIndex *Index = nullptr;
+/// The FS to be used by actions that will need access to files that are not
+/// touched while building AST.
+llvm::vfs::FileSystem *FS = nullptr;
 // FIXME: provide a way to get sources an

[PATCH] D56924: Special case ObjCPropertyDecl for printing

2019-10-18 Thread David Goldman via Phabricator via cfe-commits
dgoldman added inline comments.



Comment at: unittests/AST/NamedDeclPrinterTest.cpp:220
+"property",
+"Obj::property"));
+}

dexonsmith wrote:
> gribozavr wrote:
> > I don't think that `Obj::property` is the preferred syntax. `Obj.property`? 
> > I'd want a review from someone from Apple to confirm.
> @arphaman, @jkorous, or @benlangmuir: can you check on this?
For more context here: I'm seeing similar issues for Objective-C instance 
variables (they can be declared inside a class extension --> meaning the Decl 
has no name --> clangd fails with an assertion that the name shouldn't be 
empty).

It seems to me that for Objective-C we could do something like 
`Obj(Extension::property` or alternatively `Obj(Extension).property` and 
`Obj(class extension)->_instanceVar`, but I'm not sure about what relies upon 
this current behavior (if anything).


Repository:
  rC Clang

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

https://reviews.llvm.org/D56924



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


[PATCH] D69171: [clang-fuzzer] Add new fuzzer target for Objective-C

2019-10-18 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Rather than adding a new fuzzer binary, can we make the language an option?
The whole implementation seems almost identical down to handleobjc/handlecxx...


Repository:
  rC Clang

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

https://reviews.llvm.org/D69171



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


[PATCH] D69088: [Lex] #pragma clang transform

2019-10-18 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

In D69088#1714020 , @hsaito wrote:

> Personally, I like the intent. I don't foresee a clear (enough) path to get 
> there. This leads to hesitation of adding a new non-experimental pragma and 
> present it to programmers. If you call it experimental, it's easier for me to 
> swallow.


Is there anything more to do than mentioning as being it experimental in the 
(no-patch-available-yet) docs?


Repository:
  rC Clang

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

https://reviews.llvm.org/D69088



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


[PATCH] D69171: [clang-fuzzer] Add new fuzzer target for Objective-C

2019-10-18 Thread David Goldman via Phabricator via cfe-commits
dgoldman created this revision.
Herald added subscribers: cfe-commits, jfb, mgorny.
Herald added a project: clang.

- Similar to that of `clang-fuzzer` itself but instead only targets Objective-C 
source files via cc1

- Also adds an example corpus directory containing some input for Objective-C


Repository:
  rC Clang

https://reviews.llvm.org/D69171

Files:
  tools/clang-fuzzer/CMakeLists.txt
  tools/clang-fuzzer/ClangObjectiveCFuzzer.cpp
  tools/clang-fuzzer/Dockerfile
  tools/clang-fuzzer/README.txt
  tools/clang-fuzzer/corpus_examples/objc/BasicClass.m
  tools/clang-fuzzer/corpus_examples/objc/ClassCategory.m
  tools/clang-fuzzer/corpus_examples/objc/ClassExtension.m
  tools/clang-fuzzer/corpus_examples/objc/SharedInstance.m
  tools/clang-fuzzer/handle-objc/CMakeLists.txt
  tools/clang-fuzzer/handle-objc/handle_objc.cpp
  tools/clang-fuzzer/handle-objc/handle_objc.h

Index: tools/clang-fuzzer/handle-objc/handle_objc.h
===
--- /dev/null
+++ tools/clang-fuzzer/handle-objc/handle_objc.h
@@ -0,0 +1,24 @@
+//==-- handle_objc.h - Helper function for Clang fuzzers ---==//
+//
+// 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
+//
+//===--===//
+//
+// Defines HandleObjC for use by the Clang Objective-C fuzzers.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_CLANG_FUZZER_HANDLE_OBJC_HANDLEOBJC_H
+#define LLVM_CLANG_TOOLS_CLANG_FUZZER_HANDLE_OBJC_HANDLEOBJC_H
+
+#include 
+#include 
+
+namespace clang_fuzzer {
+void HandleObjC(const std::string &S,
+const std::vector &ExtraArgs);
+} // namespace clang_fuzzer
+
+#endif
Index: tools/clang-fuzzer/handle-objc/handle_objc.cpp
===
--- /dev/null
+++ tools/clang-fuzzer/handle-objc/handle_objc.cpp
@@ -0,0 +1,51 @@
+//==-- handle_objc.cpp - Helper function for Clang fuzzers -==//
+//
+// 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
+//
+//===--===//
+//
+// Implements HandleObjC for use by the Clang Objective-C fuzzers.
+//
+//===--===//
+
+#include "handle_objc.h"
+
+#include "clang/CodeGen/CodeGenAction.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Lex/PreprocessorOptions.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/Option/Option.h"
+
+using namespace clang;
+
+void clang_fuzzer::HandleObjC(const std::string &S,
+  const std::vector &ExtraArgs) {
+  llvm::opt::ArgStringList CC1Args;
+  CC1Args.push_back("-cc1");
+  for (auto &A : ExtraArgs)
+CC1Args.push_back(A);
+  CC1Args.push_back("./test.m");
+
+  llvm::IntrusiveRefCntPtr Files(
+  new FileManager(FileSystemOptions()));
+  IgnoringDiagConsumer Diags;
+  IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
+  DiagnosticsEngine Diagnostics(
+  IntrusiveRefCntPtr(new DiagnosticIDs()), &*DiagOpts,
+  &Diags, false);
+  std::unique_ptr Invocation(
+  tooling::newInvocation(&Diagnostics, CC1Args));
+  std::unique_ptr Input =
+  llvm::MemoryBuffer::getMemBuffer(S);
+  Invocation->getPreprocessorOpts().addRemappedFile("./test.m",
+Input.release());
+  std::unique_ptr action(
+  tooling::newFrontendActionFactory());
+  std::shared_ptr PCHContainerOps =
+  std::make_shared();
+  action->runInvocation(std::move(Invocation), Files.get(), PCHContainerOps,
+&Diags);
+}
+
Index: tools/clang-fuzzer/handle-objc/CMakeLists.txt
===
--- /dev/null
+++ tools/clang-fuzzer/handle-objc/CMakeLists.txt
@@ -0,0 +1,13 @@
+set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} Support)
+
+add_clang_library(clangHandleObjC
+  handle_objc.cpp
+
+  LINK_LIBS
+  clangBasic
+  clangCodeGen
+  clangFrontend
+  clangLex
+  clangSerialization
+  clangTooling
+  )
Index: tools/clang-fuzzer/corpus_examples/objc/SharedInstance.m
===
--- /dev/null
+++ tools/clang-fuzzer/corpus_examples/objc/SharedInstance.m
@@ -0,0 +1,34 @@
+@interface RootObject
++ (instancetype)alloc;
+
+- (instancetype)init;
+@end
+
+@interface BaseClass : RootObject
++ (instancetype)sharedInstance;
+
+- (instancetype)initWithFoo:(int)foo;
+@end
+
+static BaseClass *sharedInstance = (void *)0;
+static int counter = 0;
+
+@implementation BaseClass
++ (instance

[PATCH] D69164: [clang-format] fix regression recognizing casts in Obj-C calls

2019-10-18 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGeff2a2ab2b51: [clang-format] fix regression recognizing 
casts in Obj-C calls (authored by krasimir).

Changed prior to commit:
  https://reviews.llvm.org/D69164?vs=225604&id=225635#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69164

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -7541,6 +7541,8 @@
   verifyFormat("my_int a = (ns::my_int)-2;");
   verifyFormat("case (my_int)ONE:");
   verifyFormat("auto x = (X)this;");
+  // Casts in Obj-C style calls used to not be recognized as such.
+  verifyFormat("int a = [(type*)[((type*)val) arg] arg];", getGoogleStyle());
 
   // FIXME: single value wrapped with paren will be treated as cast.
   verifyFormat("void f(int i = (kValue)*kMask) {}");
@@ -7581,6 +7583,29 @@
   verifyFormat("int a = alignof(int *) + b;", getGoogleStyle());
   verifyFormat("bool b = f(g) && c;");
   verifyFormat("typedef void (*f)(int i) func;");
+  verifyFormat("void operator++(int) noexcept;");
+  verifyFormat("void operator++(int &) noexcept;");
+  verifyFormat("void operator delete(void *, std::size_t, const std::nothrow_t 
"
+   "&) noexcept;");
+  verifyFormat(
+  "void operator delete(std::size_t, const std::nothrow_t &) noexcept;");
+  verifyFormat("void operator delete(const std::nothrow_t &) noexcept;");
+  verifyFormat("void operator delete(std::nothrow_t &) noexcept;");
+  verifyFormat("void operator delete(nothrow_t &) noexcept;");
+  verifyFormat("void operator delete(foo &) noexcept;");
+  verifyFormat("void operator delete(foo) noexcept;");
+  verifyFormat("void operator delete(int) noexcept;");
+  verifyFormat("void operator delete(int &) noexcept;");
+  verifyFormat("void operator delete(int &) volatile noexcept;");
+  verifyFormat("void operator delete(int &) const");
+  verifyFormat("void operator delete(int &) = default");
+  verifyFormat("void operator delete(int &) = delete");
+  verifyFormat("void operator delete(int &) [[noreturn]]");
+  verifyFormat("void operator delete(int &) throw();");
+  verifyFormat("void operator delete(int &) throw(int);");
+  verifyFormat("auto operator delete(int &) -> int;");
+  verifyFormat("auto operator delete(int &) override");
+  verifyFormat("auto operator delete(int &) final");
 
   verifyFormat(" *foo = (a 
*)\n"
"bbb;");
@@ -14696,33 +14721,6 @@
   */
 }
 
-TEST_F(FormatTest, NotCastRPaen) {
-
-  verifyFormat("void operator++(int) noexcept;");
-  verifyFormat("void operator++(int &) noexcept;");
-  verifyFormat("void operator delete(void *, std::size_t, const std::nothrow_t 
"
-   "&) noexcept;");
-  verifyFormat(
-  "void operator delete(std::size_t, const std::nothrow_t &) noexcept;");
-  verifyFormat("void operator delete(const std::nothrow_t &) noexcept;");
-  verifyFormat("void operator delete(std::nothrow_t &) noexcept;");
-  verifyFormat("void operator delete(nothrow_t &) noexcept;");
-  verifyFormat("void operator delete(foo &) noexcept;");
-  verifyFormat("void operator delete(foo) noexcept;");
-  verifyFormat("void operator delete(int) noexcept;");
-  verifyFormat("void operator delete(int &) noexcept;");
-  verifyFormat("void operator delete(int &) volatile noexcept;");
-  verifyFormat("void operator delete(int &) const");
-  verifyFormat("void operator delete(int &) = default");
-  verifyFormat("void operator delete(int &) = delete");
-  verifyFormat("void operator delete(int &) [[noreturn]]");
-  verifyFormat("void operator delete(int &) throw();");
-  verifyFormat("void operator delete(int &) throw(int);");
-  verifyFormat("auto operator delete(int &) -> int;");
-  verifyFormat("auto operator delete(int &) override");
-  verifyFormat("auto operator delete(int &) final");
-}
-
 TEST_F(FormatTest, STLWhileNotDefineChed) {
   verifyFormat("#if defined(while)\n"
"#define while EMIT WARNING C4005\n"
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1607,8 +1607,9 @@
 // Functions which end with decorations like volatile, noexcept are 
unlikely
 // to be casts.
 if (Tok.Next->isOneOf(tok::kw_noexcept, tok::kw_volatile, tok::kw_const,
-  tok::kw_throw, tok::l_square, tok::arrow,
-  Keywords.kw_override, Keywords.kw_final))
+  tok::kw_throw, tok::arrow, Keywords.kw_override,
+  Keywords.kw_fin

r375247 - [clang-format] fix regression recognizing casts in Obj-C calls

2019-10-18 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Fri Oct 18 08:21:06 2019
New Revision: 375247

URL: http://llvm.org/viewvc/llvm-project?rev=375247&view=rev
Log:
[clang-format] fix regression recognizing casts in Obj-C calls

Summary:
r373922 added checks for a few tokens that, following an `)` make it
unlikely that the `)` is the closing paren of a cast expression. The
specific check for `tok::l_square` there introduced a regression for
casts of Obj-C calls, like:
```
(cast)[func arg]
```
From the tests added in r373922, I believe the `tok::l_square` case is added to
capture the case where a non-cast `)` is directly followed by an
attribute specifier, like:
```
int f(int x) [[noreturn]];
```

I've specialized the code to look for such attribute specifier instead
of `tok::l_square` in general. Also, I added a regression test and moved
the test cases added in r373922 to an already existing place documenting
other instances of historically misidentified casts.

Reviewers: MyDeveloperDay

Reviewed By: MyDeveloperDay

Subscribers: cfe-commits

Tags: #clang

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

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

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=375247&r1=375246&r2=375247&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri Oct 18 08:21:06 2019
@@ -1607,8 +1607,9 @@ private:
 // Functions which end with decorations like volatile, noexcept are 
unlikely
 // to be casts.
 if (Tok.Next->isOneOf(tok::kw_noexcept, tok::kw_volatile, tok::kw_const,
-  tok::kw_throw, tok::l_square, tok::arrow,
-  Keywords.kw_override, Keywords.kw_final))
+  tok::kw_throw, tok::arrow, Keywords.kw_override,
+  Keywords.kw_final) ||
+isCpp11AttributeSpecifier(*Tok.Next))
   return false;
 
 // As Java has no function types, a "(" after the ")" likely means that 
this

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=375247&r1=375246&r2=375247&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Fri Oct 18 08:21:06 2019
@@ -7541,6 +7541,8 @@ TEST_F(FormatTest, FormatsCasts) {
   verifyFormat("my_int a = (ns::my_int)-2;");
   verifyFormat("case (my_int)ONE:");
   verifyFormat("auto x = (X)this;");
+  // Casts in Obj-C style calls used to not be recognized as such.
+  verifyFormat("int a = [(type*)[((type*)val) arg] arg];", getGoogleStyle());
 
   // FIXME: single value wrapped with paren will be treated as cast.
   verifyFormat("void f(int i = (kValue)*kMask) {}");
@@ -7581,6 +7583,29 @@ TEST_F(FormatTest, FormatsCasts) {
   verifyFormat("int a = alignof(int *) + b;", getGoogleStyle());
   verifyFormat("bool b = f(g) && c;");
   verifyFormat("typedef void (*f)(int i) func;");
+  verifyFormat("void operator++(int) noexcept;");
+  verifyFormat("void operator++(int &) noexcept;");
+  verifyFormat("void operator delete(void *, std::size_t, const std::nothrow_t 
"
+   "&) noexcept;");
+  verifyFormat(
+  "void operator delete(std::size_t, const std::nothrow_t &) noexcept;");
+  verifyFormat("void operator delete(const std::nothrow_t &) noexcept;");
+  verifyFormat("void operator delete(std::nothrow_t &) noexcept;");
+  verifyFormat("void operator delete(nothrow_t &) noexcept;");
+  verifyFormat("void operator delete(foo &) noexcept;");
+  verifyFormat("void operator delete(foo) noexcept;");
+  verifyFormat("void operator delete(int) noexcept;");
+  verifyFormat("void operator delete(int &) noexcept;");
+  verifyFormat("void operator delete(int &) volatile noexcept;");
+  verifyFormat("void operator delete(int &) const");
+  verifyFormat("void operator delete(int &) = default");
+  verifyFormat("void operator delete(int &) = delete");
+  verifyFormat("void operator delete(int &) [[noreturn]]");
+  verifyFormat("void operator delete(int &) throw();");
+  verifyFormat("void operator delete(int &) throw(int);");
+  verifyFormat("auto operator delete(int &) -> int;");
+  verifyFormat("auto operator delete(int &) override");
+  verifyFormat("auto operator delete(int &) final");
 
   verifyFormat(" *foo = (a 
*)\n"
"bbb;");
@@ -14696,33 +14721,6 @@ TEST_F(FormatTest, AlternativeOperators)
   */
 }
 
-TEST_F(FormatTest, NotCastRPaen) {
-
-  verifyFormat("void operator++(int) noexcept;");
-  verifyFormat("void operator++(int &) noexcept;");
-  verifyFormat("void 

[PATCH] D68340: Add AIX toolchain and basic linker functionality

2019-10-18 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 225631.
stevewan marked 25 inline comments as done.
stevewan added reviewers: jasonliu, Xiangling_L.
stevewan added a comment.

Fix periods at the end of comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68340

Files:
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/AIX.h
  clang/test/Driver/Inputs/aix_ppc_tree/powerpc-ibm-aix7.1.0.0/dummy.a
  clang/test/Driver/Inputs/aix_ppc_tree/usr/lib/crt0.o
  clang/test/Driver/Inputs/aix_ppc_tree/usr/lib/crt0_64.o
  clang/test/Driver/Inputs/aix_ppc_tree/usr/lib/crti.o
  clang/test/Driver/Inputs/aix_ppc_tree/usr/lib/crti_64.o
  clang/test/Driver/Inputs/aix_ppc_tree/usr/lib/gcrt0.o
  clang/test/Driver/Inputs/aix_ppc_tree/usr/lib/gcrt0_64.o
  clang/test/Driver/Inputs/aix_ppc_tree/usr/lib/mcrt0.o
  clang/test/Driver/Inputs/aix_ppc_tree/usr/lib/mcrt0_64.o
  clang/test/Driver/aix-ld.c

Index: clang/test/Driver/aix-ld.c
===
--- /dev/null
+++ clang/test/Driver/aix-ld.c
@@ -0,0 +1,177 @@
+// General tests that ld invocations on AIX targets are sane. Note that we use
+// sysroot to make these tests independent of the host system.
+
+// Check powerpc-ibm-aix7.1.0.0, 32-bit.
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target powerpc-ibm-aix7.1.0.0 \
+// RUN: --sysroot %S/Inputs/aix_ppc_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD32 %s
+// CHECK-LD32-NOT: warning:
+// CHECK-LD32: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-LD32: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-LD32: "{{.*}}ld{{(.exe)?}}" 
+// CHECK-LD32-NOT: "-bnso"
+// CHECK-LD32: "-b32" 
+// CHECK-LD32: "-bpT:0x1000" "-bpD:0x2000" 
+// CHECK-LD32: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-LD32: "-L[[SYSROOT]]/usr/lib" 
+// CHECK-LD32: "-lc"
+
+// Check powerpc64-ibm-aix7.1.0.0, 64-bit.
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target powerpc64-ibm-aix7.1.0.0 \
+// RUN: --sysroot %S/Inputs/aix_ppc_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD64 %s
+// CHECK-LD64-NOT: warning:
+// CHECK-LD64: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0"
+// CHECK-LD64: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-LD64: "{{.*}}ld{{(.exe)?}}" 
+// CHECK-LD64-NOT: "-bnso"
+// CHECK-LD64: "-b64" 
+// CHECK-LD64: "-bpT:0x1" "-bpD:0x11000" 
+// CHECK-LD64: "[[SYSROOT]]/usr/lib{{/|}}crt0_64.o"
+// CHECK-LD64: "-L[[SYSROOT]]/usr/lib" 
+// CHECK-LD64: "-lc"
+
+// Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable POSIX thread support.
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -pthread \
+// RUN: -target powerpc-ibm-aix7.1.0.0 \
+// RUN: --sysroot %S/Inputs/aix_ppc_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD32-PTHREAD %s
+// CHECK-LD32-PTHREAD-NOT: warning:
+// CHECK-LD32-PTHREAD: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-LD32-PTHREAD: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-LD32-PTHREAD: "{{.*}}ld{{(.exe)?}}" 
+// CHECK-LD32-PTHREAD-NOT: "-bnso"
+// CHECK-LD32-PTHREAD: "-b32" 
+// CHECK-LD32-PTHREAD: "-bpT:0x1000" "-bpD:0x2000" 
+// CHECK-LD32-PTHREAD: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-LD32-PTHREAD: "-L[[SYSROOT]]/usr/lib"
+// CHECK-LD32-PTHREAD: "-lpthreads"
+// CHECK-LD32-PTHREAD: "-lc"
+
+// Check powerpc-ibm-aix7.1.0.0, 64-bit. POSIX thread alias.
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -pthreads \
+// RUN: -target powerpc64-ibm-aix7.1.0.0 \
+// RUN: --sysroot %S/Inputs/aix_ppc_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD64-PTHREAD %s
+// CHECK-LD64-PTHREAD-NOT: warning:
+// CHECK-LD64-PTHREAD: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0"
+// CHECK-LD64-PTHREAD: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-LD64-PTHREAD: "{{.*}}ld{{(.exe)?}}" 
+// CHECK-LD64-PTHREAD-NOT: "-bnso"
+// CHECK-LD64-PTHREAD: "-b64" 
+// CHECK-LD64-PTHREAD: "-bpT:0x1" "-bpD:0x11000" 
+// CHECK-LD64-PTHREAD: "[[SYSROOT]]/usr/lib{{/|}}crt0_64.o"
+// CHECK-LD64-PTHREAD: "-L[[SYSROOT]]/usr/lib"
+// CHECK-LD64-PTHREAD: "-lpthreads"
+// CHECK-LD64-PTHREAD: "-lc"
+
+// Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable profiling.
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -p \
+// RUN: -target powerpc-ibm-aix7.1.0.0 \
+// RUN: --sysroot %S/Inputs/aix_ppc_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD32-PROF %s
+// CHECK-LD32-PROF-NOT: warning:
+// CHECK-LD32-PROF: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-LD32-PROF: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-LD32-PROF: "{{.*}}ld{{(.exe)?}}" 
+// CHECK-LD32-PROF-NOT: "-bn

[PATCH] D56924: Special case ObjCPropertyDecl for printing

2019-10-18 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added subscribers: jkorous, benlangmuir.
dexonsmith added inline comments.



Comment at: unittests/AST/NamedDeclPrinterTest.cpp:220
+"property",
+"Obj::property"));
+}

gribozavr wrote:
> I don't think that `Obj::property` is the preferred syntax. `Obj.property`? 
> I'd want a review from someone from Apple to confirm.
@arphaman, @jkorous, or @benlangmuir: can you check on this?


Repository:
  rC Clang

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

https://reviews.llvm.org/D56924



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


r375245 - [tooling] Relax an assert when multiple GPU targets are specified.

2019-10-18 Thread Michael Liao via cfe-commits
Author: hliao
Date: Fri Oct 18 08:03:34 2019
New Revision: 375245

URL: http://llvm.org/viewvc/llvm-project?rev=375245&view=rev
Log:
[tooling] Relax an assert when multiple GPU targets are specified.

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

Modified: cfe/trunk/lib/Tooling/Tooling.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Tooling.cpp?rev=375245&r1=375244&r2=375245&view=diff
==
--- cfe/trunk/lib/Tooling/Tooling.cpp (original)
+++ cfe/trunk/lib/Tooling/Tooling.cpp Fri Oct 18 08:03:34 2019
@@ -105,7 +105,7 @@ static const llvm::opt::ArgStringList *g
 // tooling will consider host-compilation only. For tooling on device
 // compilation, device compilation only option, such as
 // `--cuda-device-only`, needs specifying.
-assert(Actions.size() == 2);
+assert(Actions.size() > 1);
 assert(
 isa(Actions.front()) ||
 // On MacOSX real actions may end up being wrapped in


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


[PATCH] D67545: [clang-tidy] Added DefaultOperatorNewCheck.

2019-10-18 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 225625.
balazske added a comment.

- Fixes from review comments, added C++ version test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67545

Files:
  clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
  clang-tools-extra/clang-tidy/cert/CMakeLists.txt
  clang-tools-extra/clang-tidy/cert/DefaultOperatorNewAlignmentCheck.cpp
  clang-tools-extra/clang-tidy/cert/DefaultOperatorNewAlignmentCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/cert-mem57-cpp.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/cert-mem57-cpp-cpp17.cpp
  clang-tools-extra/test/clang-tidy/cert-mem57-cpp.cpp

Index: clang-tools-extra/test/clang-tidy/cert-mem57-cpp.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/cert-mem57-cpp.cpp
@@ -0,0 +1,39 @@
+// RUN: %check_clang_tidy %s -std=c++14 cert-mem57-cpp %t
+
+namespace std {
+typedef __typeof(sizeof(int)) size_t;
+void *aligned_alloc(size_t, size_t);
+void free(void *);
+} // namespace std
+
+struct alignas(32) Vector1 {
+  char elems[32];
+};
+
+struct Vector2 {
+  char elems[32];
+};
+
+struct alignas(32) Vector3 {
+  char elems[32];
+  static void *operator new(std::size_t nbytes) noexcept(true) {
+return std::aligned_alloc(alignof(Vector3), nbytes);
+  }
+  static void operator delete(void *p) {
+std::free(p);
+  }
+};
+
+struct alignas(8) Vector4 {
+  char elems[32];
+};
+
+void f() {
+  auto *V1 = new Vector1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: allocation function returns a pointer with alignment 16 but the over-aligned type being allocated requires alignment 32 [cert-mem57-cpp]
+  auto *V2 = new Vector2;
+  auto *V3 = new Vector3;
+  auto *V4 = new Vector4;
+  auto *V1_Arr = new Vector1[2];
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: allocation function returns a pointer with alignment 16 but the over-aligned type being allocated requires alignment 32 [cert-mem57-cpp]
+}
Index: clang-tools-extra/test/clang-tidy/cert-mem57-cpp-cpp17.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/cert-mem57-cpp-cpp17.cpp
@@ -0,0 +1,12 @@
+// RUN: %check_clang_tidy %s -std=c++14 cert-mem57-cpp %t
+// RUN: clang-tidy --extra-arg='-std=c++17' -checks='-*,cert-mem57-cpp' --warnings-as-errors='*' %s
+// RUN: clang-tidy --extra-arg='-std=c++2a' -checks='-*,cert-mem57-cpp' --warnings-as-errors='*' %s
+
+struct alignas(32) Vector {
+  char Elems[32];
+};
+
+void f() {
+  auto *V1 = new Vector;// CHECK-MESSAGES: warning: allocation function returns a pointer with alignment 16 but the over-aligned type being allocated requires alignment 32 [cert-mem57-cpp]
+  auto *V1_Arr = new Vector[2]; // CHECK-MESSAGES: warning: allocation function returns a pointer with alignment 16 but the over-aligned type being allocated requires alignment 32 [cert-mem57-cpp]
+}
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -98,6 +98,7 @@
cert-err61-cpp (redirects to misc-throw-by-value-catch-by-reference) 
cert-fio38-c (redirects to misc-non-copyable-objects) 
cert-flp30-c
+   cert-mem57-cpp
cert-msc30-c (redirects to cert-msc50-cpp) 
cert-msc32-c (redirects to cert-msc51-cpp) 
cert-msc50-cpp
Index: clang-tools-extra/docs/clang-tidy/checks/cert-mem57-cpp.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/cert-mem57-cpp.rst
@@ -0,0 +1,16 @@
+.. title:: clang-tidy - cert-mem57-cpp
+
+cert-mem57-cpp
+==
+
+This check flags uses of default ``operator new`` where the type has extended
+alignment (an alignment greater than the fundamental alignment). (The default
+``operator new`` is guaranteed to provide the correct alignmment if the
+requested alignment is less or equal to the fundamental alignment).
+Only cases are detected (by design) where the ``operator new`` is not
+user-defined and is not a placement new (the reason is that in these cases we
+assume that the user provided the correct memory allocation).
+
+This check corresponds to the CERT C++ Coding Standard rule
+`MEM57-CPP. Avoid using default operator new for over-aligned types
+`_.
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -73,6 +73,12 @@
   Finds instances where variables with static storage are initializ

[PATCH] D69124: [clang][driver] Print compilation phases with indentation.

2019-10-18 Thread Michael Liao via Phabricator via cfe-commits
hliao updated this revision to Diff 225620.
hliao added a comment.

revise the output by drawing tree lines. now, the output looks like

  $ clang -x cuda -ccc-print-phases --cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_60 
-c dummy.cpp
  +- 0: input, "/home/michliao/dummy.cpp", cuda, (host-cuda)
   +- 1: preprocessor, {0}, cuda-cpp-output, (host-cuda)
+- 2: compiler, {1}, ir, (host-cuda)
| +- 3: input, "/home/michliao/dummy.cpp", cuda, 
(device-cuda, sm_30)
|  +- 4: preprocessor, {3}, cuda-cpp-output, (device-cuda, 
sm_30)
|   +- 5: compiler, {4}, ir, (device-cuda, sm_30)
|+- 6: backend, {5}, assembler, (device-cuda, sm_30)
| +- 7: assembler, {6}, object, (device-cuda, sm_30)
|  +- 8: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {7}, object
|  |- 9: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {6}, 
assembler
|  |  +- 10: input, "/home/michliao/dummy.cpp", cuda, 
(device-cuda, sm_60)
|  |   +- 11: preprocessor, {10}, cuda-cpp-output, 
(device-cuda, sm_60)
|  |+- 12: compiler, {11}, ir, (device-cuda, sm_60)
|  | +- 13: backend, {12}, assembler, (device-cuda, sm_60)
|  |  +- 14: assembler, {13}, object, (device-cuda, sm_60)
|  |- 15: offload, "device-cuda (nvptx64-nvidia-cuda:sm_60)" {14}, 
object
|  |- 16: offload, "device-cuda (nvptx64-nvidia-cuda:sm_60)" {13}, 
assembler
|- 17: linker, {8, 9, 15, 16}, cuda-fatbin, (device-cuda)
 +- 18: offload, "host-cuda (x86_64-unknown-linux-gnu)" {2}, "device-cuda 
(nvptx64-nvidia-cuda)" {17}, ir
  +- 19: backend, {18}, assembler, (host-cuda)
  20: assembler, {19}, object, (host-cuda)



  $ clang -x hip -ccc-print-phases --cuda-gpu-arch=gfx900 
--cuda-gpu-arch=gfx906 -c dummy.cpp
  +- 0: input, "/home/michliao/dummy.cpp", hip, (host-hip)
   +- 1: preprocessor, {0}, hip-cpp-output, (host-hip)
+- 2: compiler, {1}, ir, (host-hip)
|  +- 3: input, "/home/michliao/dummy.cpp", hip, 
(device-hip, gfx900)
|   +- 4: preprocessor, {3}, hip-cpp-output, (device-hip, 
gfx900)
|+- 5: compiler, {4}, ir, (device-hip, gfx900)
| +- 6: linker, {5}, image, (device-hip, gfx900)
|  +- 7: offload, "device-hip (amdgcn-amd-amdhsa:gfx900)" {6}, image
|  |   +- 8: input, "/home/michliao/dummy.cpp", hip, 
(device-hip, gfx906)
|  |+- 9: preprocessor, {8}, hip-cpp-output, (device-hip, 
gfx906)
|  | +- 10: compiler, {9}, ir, (device-hip, gfx906)
|  |  +- 11: linker, {10}, image, (device-hip, gfx906)
|  |- 12: offload, "device-hip (amdgcn-amd-amdhsa:gfx906)" {11}, image
|- 13: linker, {7, 12}, hip-fatbin, (device-hip)
 +- 14: offload, "host-hip (x86_64-unknown-linux-gnu)" {2}, "device-hip 
(amdgcn-amd-amdhsa)" {13}, ir
  +- 15: backend, {14}, assembler, (host-hip)
  16: assembler, {15}, object, (host-hip)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69124

Files:
  clang/lib/Driver/Driver.cpp


Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1802,23 +1802,36 @@
   return true;
 }
 
+enum {
+  TopLevelAction = 0,
+  HeadSibAction = 1,
+  OtherSibAction = 2,
+};
+
 // Display an action graph human-readably.  Action A is the "sink" node
 // and latest-occuring action. Traversal is in pre-order, visiting the
 // inputs to each action before printing the action itself.
 static unsigned PrintActions1(const Compilation &C, Action *A,
-  std::map &Ids) {
+  std::map &Ids,
+  Twine Indent = {}, int Kind = TopLevelAction) {
   if (Ids.count(A)) // A was already visited.
 return Ids[A];
 
   std::string str;
   llvm::raw_string_ostream os(str);
 
+  auto getSibIndent = [](int K) -> Twine {
+return (K == HeadSibAction) ? "   " : (K == OtherSibAction) ? "|  " : "";
+  };
+
+  Twine SibIndent = Indent + getSibIndent(Kind);
+  int SibKind = HeadSibAction;
   os << Action::getClassName(A->getKind()) << ", ";
   if (InputAction *IA = dyn_cast(A)) {
 os << "\"" << IA->getInputArg().getValue() << "\"";
   } else if (BindArchAction *BIA = dyn_cast(A)) {
 os << '"' << BIA->getArchName() << '"' << ", {"
-   << PrintActions1(C, *BIA->input_begin(), Ids) << "}";
+   << PrintActions1(C, *BIA->input_begin(), Ids, SibIndent, SibKind) << 
"}";
   } else if (OffloadAction *OA = dyn_cast(A)) {
 bool IsFirst = true;
 OA->doOnEachDependence(
@@ -1841,8 +1854,9 @@
 os << ":" << BoundArch;
   os << ")";
   os << '"';
-  os << " {" << PrintActions1(C, A, Ids) << "}";
+   

[PATCH] D69124: [clang][driver] Print compilation phases with indentation.

2019-10-18 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment.

In D69124#1713427 , @tra wrote:

> This is... rather oddly-structured output. My brain refuses to accept that 
> the most-indented phase is the input.
>  Perhaps we should do `llvm::errs().indent(MaxIdent-Ident)`. This should give 
> us something like this (withMaxIdent=9), which is somewhat easier to grok, 
> IMO:
>
>   0: input, "/home/michliao/dummy.cpp", cuda, (host-cuda)
>1: preprocessor, {0}, cuda-cpp-output, (host-cuda)
> 2: compiler, {1}, ir, (host-cuda)
>   3: input, "/home/michliao/dummy.cpp", cuda, (device-cuda, sm_30)
>4: preprocessor, {3}, cuda-cpp-output, (device-cuda, sm_30)
> 5: compiler, {4}, ir, (device-cuda, sm_30)
>  6: backend, {5}, assembler, (device-cuda, sm_30)
>   7: assembler, {6}, object, (device-cuda, sm_30)
>8: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {7}, object
>9: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {6}, assembler
>   10: input, "/home/michliao/dummy.cpp", cuda, (device-cuda, sm_60)
>11: preprocessor, {10}, cuda-cpp-output, (device-cuda, sm_60)
> 12: compiler, {11}, ir, (device-cuda, sm_60)
>  13: backend, {12}, assembler, (device-cuda, sm_60)
>   14: assembler, {13}, object, (device-cuda, sm_60)
>15: offload, "device-cuda (nvptx64-nvidia-cuda:sm_60)" {14}, object
>16: offload, "device-cuda (nvptx64-nvidia-cuda:sm_60)" {13}, assembler
> 17: linker, {8, 9, 15, 16}, cuda-fatbin, (device-cuda)
>  18: offload, "host-cuda (x86_64-unknown-linux-gnu)" {2}, 
> "device-cuda (nvptx64-nvidia-cuda)" {17}, ir
>   19: backend, {18}, assembler, (host-cuda)
>20: assembler, {19}, object, (host-cuda)
>


As the top-level actions are the last actions to be performed, they should have 
no indentation

In D69124#1713427 , @tra wrote:

> This is... rather oddly-structured output. My brain refuses to accept that 
> the most-indented phase is the input.
>  Perhaps we should do `llvm::errs().indent(MaxIdent-Ident)`. This should give 
> us something like this (withMaxIdent=9), which is somewhat easier to grok, 
> IMO:
>
>   0: input, "/home/michliao/dummy.cpp", cuda, (host-cuda)
>1: preprocessor, {0}, cuda-cpp-output, (host-cuda)
> 2: compiler, {1}, ir, (host-cuda)
>   3: input, "/home/michliao/dummy.cpp", cuda, (device-cuda, sm_30)
>4: preprocessor, {3}, cuda-cpp-output, (device-cuda, sm_30)
> 5: compiler, {4}, ir, (device-cuda, sm_30)
>  6: backend, {5}, assembler, (device-cuda, sm_30)
>   7: assembler, {6}, object, (device-cuda, sm_30)
>8: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {7}, object
>9: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {6}, assembler
>   10: input, "/home/michliao/dummy.cpp", cuda, (device-cuda, sm_60)
>11: preprocessor, {10}, cuda-cpp-output, (device-cuda, sm_60)
> 12: compiler, {11}, ir, (device-cuda, sm_60)
>  13: backend, {12}, assembler, (device-cuda, sm_60)
>   14: assembler, {13}, object, (device-cuda, sm_60)
>15: offload, "device-cuda (nvptx64-nvidia-cuda:sm_60)" {14}, object
>16: offload, "device-cuda (nvptx64-nvidia-cuda:sm_60)" {13}, assembler
> 17: linker, {8, 9, 15, 16}, cuda-fatbin, (device-cuda)
>  18: offload, "host-cuda (x86_64-unknown-linux-gnu)" {2}, 
> "device-cuda (nvptx64-nvidia-cuda)" {17}, ir
>   19: backend, {18}, assembler, (host-cuda)
>20: assembler, {19}, object, (host-cuda)
>


it's difficult to choose a proper `MaxIdent` though to avoid unnecessary 
leading whitespaces or misalign the output. How about we draw the tree edges in 
the original output? It looks much easier for me to identify sibling actions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69124



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


[PATCH] D68028: [clang] Add no_builtin attribute

2019-10-18 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet updated this revision to Diff 225618.
gchatelet added a comment.

- Fix documentation and Warning category


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68028

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/no-builtin.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/no-builtin.cpp

Index: clang/test/Sema/no-builtin.cpp
===
--- /dev/null
+++ clang/test/Sema/no-builtin.cpp
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify %s
+
+/// Prevent use of all builtins.
+void valid_attribute_all_1() __attribute__((no_builtin)) {}
+void valid_attribute_all_2() __attribute__((no_builtin())) {}
+
+/// Prevent use of specific builtins.
+void valid_attribute_function() __attribute__((no_builtin("memcpy"))) {}
+void valid_attribute_functions() __attribute__((no_builtin("memcpy"))) __attribute__((no_builtin("memcmp"))) {}
+
+/// Many times the same builtin is fine.
+void many_attribute_function_1() __attribute__((no_builtin)) __attribute__((no_builtin)) {}
+void many_attribute_function_2() __attribute__((no_builtin("memcpy"))) __attribute__((no_builtin("memcpy"))) {}
+void many_attribute_function_3() __attribute__((no_builtin("memcpy", "memcpy"))) {}
+void many_attribute_function_4() __attribute__((no_builtin("memcpy", "memcpy"))) __attribute__((no_builtin("memcpy"))) {}
+
+/// Invalid builtin name.
+void invalid_builtin() __attribute__((no_builtin("not_a_builtin"))) {}
+// expected-warning@-1 {{'not_a_builtin' is not a valid builtin name for no_builtin}}
+
+/// Can't use bare no_builtin with a named one.
+void wildcard_and_functionname() __attribute__((no_builtin)) __attribute__((no_builtin("memcpy"))) {}
+// expected-error@-1 {{empty no_builtin cannot be composed with named ones}}
+
+/// Can't attach attribute to a variable.
+int __attribute__((no_builtin)) variable;
+// expected-warning@-1 {{'no_builtin' attribute only applies to functions}}
+
+/// Can't attach attribute to a declaration.
+void nobuiltin_on_declaration() __attribute__((no_builtin));
+// expected-error@-1 {{no_builtin attribute is permitted on definitions only}}
+
+struct S {
+  /// Can't attach attribute to a defaulted function,
+  S()
+  __attribute__((no_builtin)) = default;
+  // expected-error@-1 {{no_builtin attribute has no effect on defaulted or deleted functions}}
+
+  /// Can't attach attribute to a deleted function,
+  S(const S &)
+  __attribute__((no_builtin)) = delete;
+  // expected-error@-1 {{no_builtin attribute has no effect on defaulted or deleted functions}}
+
+  void whatever() __attribute__((no_builtin("memcpy")));
+  // expected-error@-1 {{no_builtin attribute is permitted on definitions only}}
+};
+
+/// Can't attach attribute to an aliased function.
+void alised_function() {}
+void aliasing_function() __attribute__((no_builtin)) __attribute__((alias("alised_function")));
+// expected-error@-1 {{no_builtin attribute is permitted on definitions only}}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -74,6 +74,7 @@
 // CHECK-NEXT: NSConsumed (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: NSConsumesSelf (SubjectMatchRule_objc_method)
 // CHECK-NEXT: Naked (SubjectMatchRule_function)
+// CHECK-NEXT: NoBuiltin (SubjectMatchRule_function)
 // CHECK-NEXT: NoCommon (SubjectMatchRule_variable)
 // CHECK-NEXT: NoDebug (SubjectMatchRule_type_alias, SubjectMatchRule_hasType_functionType, SubjectMatchRule_objc_method, SubjectMatchRule_variable_not_is_parameter)
 // CHECK-NEXT: NoDestroy (SubjectMatchRule_variable)
Index: clang/test/CodeGen/no-builtin.cpp
===
--- /dev/null
+++ clang/test/CodeGen/no-builtin.cpp
@@ -0,0 +1,64 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -o - %s | FileCheck %s
+
+// CHECK-LABEL: define void @foo_no_mempcy() #0
+extern "C" void foo_no_mempcy() __attribute__((no_builtin("memcpy"))) {}
+
+// CHECK-LABEL: define void @foo_no_mempcy_twice() #0
+extern "C" void foo_no_mempcy_twice() __attribute__((no_builtin("memcpy"))) __attribute__((no_builtin("memcpy"))) {}
+
+// CHECK-LABEL: define void @foo_no_builtins() #1
+extern "C" void foo_no_builtins() __attribute__((no_builtin)) {}
+
+// CHECK-LABEL: define void @foo_no_mempcy_memset() #2
+extern "C" void foo_no_mempcy_memset() __attribute__((no_builtin("memset", "memcpy"))) {}
+
+// CHECK-LABEL:

[PATCH] D68340: Add AIX toolchain and basic linker functionality

2019-10-18 Thread Jason Liu via Phabricator via cfe-commits
jasonliu added inline comments.



Comment at: clang/lib/Driver/ToolChains/AIX.h:19
+
+/// aix -- Directly call system default and linker.
+// TODO: Enable direct call to system default assembler.

remove "and".



Comment at: clang/lib/Driver/ToolChains/AIX.h:36
+
+} // end namespace aix.
+

Sorry, I don't think we need '.' for any of the "end namespace ..." comment. 



Comment at: clang/lib/Driver/ToolChains/AIX.h:63
+
+#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_AIX_H.

We don't need '.' here as well. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68340



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


[PATCH] D68028: [clang] Add no_builtin attribute

2019-10-18 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet marked 4 inline comments as done.
gchatelet added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:3609
+  "'%0' is not a valid builtin name for %1">,
+  InGroup; // Which group should it be in?
+def err_attribute_no_builtin_wildcard_or_builtin_name : Error<

aaron.ballman wrote:
> Hmm, I thought there was a way you could do:
> ```
> InGroup>;
> ```
> but it seems I've got the order reversed and you'd have to add a new 
> diagnostic group that `IgnoredAttributes` could subsume. We don't do that for 
> other attributes, so I think you should just do:
> ```
> InGroup>;
> ```
> (Feel free to pick a better diagnostic group name if you have a better idea, 
> I'm not tied to my suggestion.)
`"invalid-no-builtin-names"` LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68028



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


[PATCH] D69164: [clang-format] fix regression recognizing casts in Obj-C calls

2019-10-18 Thread Ronald Wampler via Phabricator via cfe-commits
rdwampler added inline comments.



Comment at: lib/Format/TokenAnnotator.cpp:1612
+  Keywords.kw_final) ||
+isCpp11AttributeSpecifier(*Tok.Next))
   return false;

I think the issue r373922 was fixing is only related to the `delete`. Can this 
check be move further up where we explicitly check if the token is the delete 
keyword? 



Repository:
  rC Clang

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

https://reviews.llvm.org/D69164



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


[PATCH] D68885: Add a Ranges field to Diagnostic struct

2019-10-18 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: include/clang/Tooling/Core/Diagnostic.h:93
+  /// representation of the source code associated with the diagnostic.
+  ArrayRef Ranges;
 };

Please add YAML serialization/deserialization code for this. See 
include/clang/Tooling/DiagnosticsYaml.h


Repository:
  rC Clang

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

https://reviews.llvm.org/D68885



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


[PATCH] D69155: [analyzer] Fix off-by-one in operator call parameter binding.

2019-10-18 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso accepted this revision.
Charusso marked an inline comment as done.
Charusso added a comment.
This revision is now accepted and ready to land.

I think it will be a great educational material how to touch the core. Good 
luck!




Comment at: clang/lib/StaticAnalyzer/Core/CallEvent.cpp:325
 if (getKind() != CE_CXXAllocator)
   if (isArgumentConstructedDirectly(Idx))
 if (auto AdjIdx = getAdjustedParameterIndex(Idx))

NoQ wrote:
> Charusso wrote:
> > What about this one? It smells the same issue.
> Here `Idx` is an argument index to begin with, so it shouldn't be a problem.
Okai, thanks!


Repository:
  rC Clang

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

https://reviews.llvm.org/D69155



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


[PATCH] D69155: [analyzer] Fix off-by-one in operator call parameter binding.

2019-10-18 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ marked an inline comment as done.
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/CallEvent.cpp:325
 if (getKind() != CE_CXXAllocator)
   if (isArgumentConstructedDirectly(Idx))
 if (auto AdjIdx = getAdjustedParameterIndex(Idx))

Charusso wrote:
> What about this one? It smells the same issue.
Here `Idx` is an argument index to begin with, so it shouldn't be a problem.


Repository:
  rC Clang

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

https://reviews.llvm.org/D69155



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


  1   2   >