[PATCH] D61931: [Driver] Use --android-tls for Android ARM/AArch64 when lld is used

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

Abandon in favor of D62055 


Repository:
  rC Clang

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

https://reviews.llvm.org/D61931



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


[PATCH] D38479: Make -mgeneral-regs-only more like GCC's

2019-05-17 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

We (Fuchsia) would like to see this landed as well so we can start using this 
in our kernel.


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

https://reviews.llvm.org/D38479



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


[PATCH] D62094: [analyzer] Categorize checker/plugin options into 3 categories, same as for checkers

2019-05-17 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus created this revision.
Szelethus added reviewers: NoQ, dcoughlin, rnkovacs, xazax.hun, Charusso, 
a_sidorin, dkrupp, o.gyorgy.
Szelethus added a project: clang.
Herald added subscribers: cfe-commits, gamesh411, donat.nagy, mikhail.ramalho, 
a.sidorin, szepet, baloghadamsoftware, whisperity.
Szelethus added a parent revision: D61839: [analyzer] Hide developer-only 
checker/package options by default.

Literally the same as D62093 , but for 
checker/package options. Sorry for the lack of formatting at some parts -- I 
definitely wanted to share the code to gather feedback, as I don't have much 
time left to wrap this project up.


Repository:
  rC Clang

https://reviews.llvm.org/D62094

Files:
  include/clang/Driver/CC1Options.td
  include/clang/StaticAnalyzer/Checkers/CheckerBase.td
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
  lib/Frontend/CompilerInvocation.cpp
  lib/FrontendTool/ExecuteCompilerInvocation.cpp
  lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
  test/Analysis/analyzer-checker-option-help.c
  test/Analysis/plugins/CheckerOptionHandling/CheckerOptionHandling.cpp
  utils/TableGen/ClangSACheckersEmitter.cpp

Index: utils/TableGen/ClangSACheckersEmitter.cpp
===
--- utils/TableGen/ClangSACheckersEmitter.cpp
+++ utils/TableGen/ClangSACheckersEmitter.cpp
@@ -110,6 +110,24 @@
   return "";
 }
 
+static std::string getDevelopmentStage(const Record ) {
+  if (BitsInit *BI = R.getValueAsBitsInit("DevelopmentStage")) {
+switch(getValueFromBitsInit(BI, R)) {
+case 0:
+  return "alpha";
+case 1:
+  return "beta";
+case 2:
+  return "released";
+}
+  }
+
+  PrintFatalError(R.getLoc(),
+  "unable to parse command line option type for "
+  + getCheckerFullName());
+  return "";
+}
+
 static bool isHidden(const Record *R) {
   if (R->getValueAsBit("Hidden"))
 return true;
@@ -149,6 +167,8 @@
   OS.write_escaped(getStringValue(R, "Desc")) << "\", ";
   OS << '\"';
   OS.write_escaped(getStringValue(R, "DefaultVal")) << "\", ";
+  OS << '\"';
+  OS << getDevelopmentStage(R) << "\", ";
 
   if (!R.getValueAsBit("Hidden"))
 OS << "false";
Index: test/Analysis/plugins/CheckerOptionHandling/CheckerOptionHandling.cpp
===
--- test/Analysis/plugins/CheckerOptionHandling/CheckerOptionHandling.cpp
+++ test/Analysis/plugins/CheckerOptionHandling/CheckerOptionHandling.cpp
@@ -36,7 +36,8 @@
 /*CheckerFullName*/ "example.MyChecker",
 /*OptionName*/ "ExampleOption",
 /*DefaultValStr*/ "false",
-/*Description*/ "This is an example checker opt.");
+/*Description*/ "This is an example checker opt.",
+/*DevelopmentStage*/ "released");
 }
 
 extern "C" const char clang_analyzerAPIVersionString[] =
Index: test/Analysis/analyzer-checker-option-help.c
===
--- test/Analysis/analyzer-checker-option-help.c
+++ test/Analysis/analyzer-checker-option-help.c
@@ -1,25 +1,87 @@
-// RUN: %clang_cc1 -analyzer-checker-option-help 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -analyzer-checker-option-help \
+// RUN:   2>&1 | FileCheck %s -check-prefix=CHECK-STABLE
+
+// RUN: %clang_cc1 -analyzer-checker-option-help-alpha \
+// RUN:   2>&1 | FileCheck %s -check-prefix=CHECK-ALPHA
+
+// RUN: %clang_cc1 -analyzer-checker-option-help-developer \
+// RUN:   2>&1 | FileCheck %s -check-prefix=CHECK-DEVELOPER
 
 // RUN: %clang_cc1 -analyzer-checker-option-help-developer \
-// RUN:   2>&1 | FileCheck %s -check-prefix=CHECK-HIDDEN
+// RUN:   -analyzer-checker-option-help-alpha \
+// RUN:   2>&1 | FileCheck %s -check-prefix=CHECK-DEVELOPER-ALPHA
+
+// RUN: %clang_cc1 -analyzer-checker-option-help \
+// RUN:   -analyzer-checker-option-help-alpha \
+// RUN:   2>&1 | FileCheck %s -check-prefix=CHECK-STABLE-ALPHA
 
-// CHECK: OVERVIEW: Clang Static Analyzer Checker and Package Option List
+// RUN: %clang_cc1 -analyzer-checker-option-help \
+// RUN:   -analyzer-checker-option-help-developer \
+// RUN:   2>&1 | FileCheck %s -check-prefix=CHECK-STABLE-DEVELOPER
+
+// RUN: %clang_cc1 -analyzer-checker-option-help \
+// RUN:   -analyzer-checker-option-help-alpha \
+// RUN:   -analyzer-checker-option-help-developer \
+// RUN:   2>&1 | FileCheck %s -check-prefix=CHECK-STABLE-ALPHA-DEVELOPER
+
+// CHECK-STABLE: OVERVIEW: Clang Static Analyzer Checker and Package Option List
 //
-// CHECK: USAGE: -analyzer-config 
+// CHECK-STABLE: USAGE: -analyzer-config 
 //
-// CHECK:-analyzer-config OPTION1=VALUE, -analyzer-config
-// CHECK-SAME:   OPTION2=VALUE, ...
+// CHECK-STABLE:

[PATCH] D61839: [analyzer] Hide developer-only checker/package options by default

2019-05-17 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus updated this revision to Diff 200127.
Szelethus retitled this revision from "[analyzer][WIP] Hide developer-only 
checker/package options by default" to "[analyzer] Hide developer-only 
checker/package options by default".
Szelethus added a comment.

- Hide several more checkers
- Rename `-analyzer-checker-option-help-hidden` to 
`-analyzer-checker-option-help-developer`


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

https://reviews.llvm.org/D61839

Files:
  include/clang/Driver/CC1Options.td
  include/clang/StaticAnalyzer/Checkers/CheckerBase.td
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
  lib/Frontend/CompilerInvocation.cpp
  lib/FrontendTool/ExecuteCompilerInvocation.cpp
  lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
  test/Analysis/analyzer-checker-option-help.c
  utils/TableGen/ClangSACheckersEmitter.cpp

Index: utils/TableGen/ClangSACheckersEmitter.cpp
===
--- utils/TableGen/ClangSACheckersEmitter.cpp
+++ utils/TableGen/ClangSACheckersEmitter.cpp
@@ -113,6 +113,7 @@
 static bool isHidden(const Record *R) {
   if (R->getValueAsBit("Hidden"))
 return true;
+
   // Not declared as hidden, check the parent package if it is hidden.
   if (DefInit *DI = dyn_cast(R->getValueInit("ParentPackage")))
 return isHidden(DI->getDef());
@@ -121,21 +122,38 @@
 }
 
 static void printChecker(llvm::raw_ostream , const Record ) {
-OS << "CHECKER(" << "\"";
-OS.write_escaped(getCheckerFullName()) << "\", ";
-OS << R.getName() << ", ";
-OS << "\"";
-OS.write_escaped(getStringValue(R, "HelpText")) << "\", ";
-OS << "\"";
-OS.write_escaped(getCheckerDocs(R));
-OS << "\", ";
-
-if (!isHidden())
-  OS << "false";
-else
-  OS << "true";
+  OS << "CHECKER(" << "\"";
+  OS.write_escaped(getCheckerFullName()) << "\", ";
+  OS << R.getName() << ", ";
+  OS << "\"";
+  OS.write_escaped(getStringValue(R, "HelpText")) << "\", ";
+  OS << "\"";
+  OS.write_escaped(getCheckerDocs(R));
+  OS << "\", ";
+
+  if (!isHidden())
+OS << "false";
+  else
+OS << "true";
+
+  OS << ")\n";
+}
+
+static void printOption(llvm::raw_ostream , StringRef FullName,
+const Record ) {
+  OS << "\"";
+  OS.write_escaped(getCheckerOptionType(R)) << "\", \"";
+  OS.write_escaped(FullName) << "\", ";
+  OS << '\"' << getStringValue(R, "CmdFlag") << "\", ";
+  OS << '\"';
+  OS.write_escaped(getStringValue(R, "Desc")) << "\", ";
+  OS << '\"';
+  OS.write_escaped(getStringValue(R, "DefaultVal")) << "\", ";
 
-OS << ")\n";
+  if (!R.getValueAsBit("Hidden"))
+OS << "false";
+  else
+OS << "true";
 }
 
 namespace clang {
@@ -196,14 +214,8 @@
 std::vector PackageOptions = Package
->getValueAsListOfDefs("PackageOptions");
 for (Record *PackageOpt : PackageOptions) {
-  OS << "PACKAGE_OPTION(\"";
-  OS.write_escaped(getCheckerOptionType(*PackageOpt)) << "\", \"";
-  OS.write_escaped(getPackageFullName(Package)) << "\", ";
-  OS << '\"' << getStringValue(*PackageOpt, "CmdFlag") << "\", ";
-  OS << '\"';
-  OS.write_escaped(getStringValue(*PackageOpt, "Desc")) << "\", ";
-  OS << '\"';
-  OS.write_escaped(getStringValue(*PackageOpt, "DefaultVal")) << "\"";
+  OS << "PACKAGE_OPTION(";
+  printOption(OS, getPackageFullName(Package), *PackageOpt);
   OS << ")\n";
 }
   }
@@ -277,16 +289,9 @@
 std::vector CheckerOptions = Checker
->getValueAsListOfDefs("CheckerOptions");
 for (Record *CheckerOpt : CheckerOptions) {
-  OS << "CHECKER_OPTION(\"";
-  OS << getCheckerOptionType(*CheckerOpt) << "\", \"";
-  OS.write_escaped(getCheckerFullName(Checker)) << "\", ";
-  OS << '\"' << getStringValue(*CheckerOpt, "CmdFlag") << "\", ";
-  OS << '\"';
-  OS.write_escaped(getStringValue(*CheckerOpt, "Desc")) << "\", ";
-  OS << '\"';
-  OS.write_escaped(getStringValue(*CheckerOpt, "DefaultVal")) << "\"";
-  OS << ")";
-  OS << '\n';
+  OS << "CHECKER_OPTION(";
+  printOption(OS, getCheckerFullName(Checker), *CheckerOpt);
+  OS << ")\n";
 }
   }
   OS << "#endif // GET_CHECKER_OPTIONS\n"
Index: test/Analysis/analyzer-checker-option-help.c
===
--- test/Analysis/analyzer-checker-option-help.c
+++ test/Analysis/analyzer-checker-option-help.c
@@ -1,5 +1,8 @@
 // RUN: %clang_cc1 -analyzer-checker-option-help 2>&1 | FileCheck %s
 
+// RUN: %clang_cc1 -analyzer-checker-option-help-developer \
+// RUN:   2>&1 | FileCheck %s -check-prefix=CHECK-HIDDEN
+
 // CHECK: OVERVIEW: Clang Static Analyzer Checker and Package Option List
 //
 // CHECK: USAGE: -analyzer-config 
@@ -17,3 +20,6 @@
 // CHECK:the first statement 

[PATCH] D62093: [analyzer] Divide checkers into 3 categories: released, alpha, developer

2019-05-17 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus created this revision.
Szelethus added reviewers: NoQ, dcoughlin, dkrupp, o.gyorgy, xazax.hun, 
rnkovacs, Charusso, a.sidorin.
Szelethus added a project: clang.
Herald added subscribers: cfe-commits, gamesh411, donat.nagy, mikhail.ramalho, 
szepet, baloghadamsoftware, whisperity.
Szelethus added parent revisions: D62092: [analyzer] Create the beta package 
that is more stable than alpha, move unix.cstring.OutOfBounds there, D57858: 
[analyzer] Add a new frontend flag to display all checker options.

Implementation of the proposed 
 checker 
categories. Quote from the mail:

> `-analyzer-checker-help`: Displays production ready (non-modeling) checkers, 
> and beta checkers with a disclaimer for each description. Don't forget to 
> patch clang-tidy!
> `-analyzer-checker-help-developer`: Displays only developer (modeling, debug) 
> checkers (renamed from *-hidden).
> `-analyzer-checker-help-alpha`: Displays only alpha (non-modeling) checkers 
> with very scary disclaimers both around the list and for each checker 
> description.
> 
> Note how each of these is mutually exclusive. I think we shouldn't make a 
> flag that displays all checkers, but should allow the following invocation to 
> do so:
> 
> `clang -cc1 -analyzer-checker-help -analyzer-checker-help-alpha 
> -analyzer-checker-help-developer`

Came to realize that this won't affect clang-tidy at all.


Repository:
  rC Clang

https://reviews.llvm.org/D62093

Files:
  include/clang/Driver/CC1Options.td
  include/clang/StaticAnalyzer/Checkers/CheckerBase.td
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  lib/Frontend/CompilerInvocation.cpp
  lib/FrontendTool/ExecuteCompilerInvocation.cpp
  lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
  test/Analysis/show-checker-list.c

Index: test/Analysis/show-checker-list.c
===
--- test/Analysis/show-checker-list.c
+++ test/Analysis/show-checker-list.c
@@ -1,11 +1,60 @@
 // RUN: %clang_cc1 -analyzer-checker-help \
-// RUN:   2>&1 | FileCheck %s -check-prefix=CHECK
+// RUN:   2>&1 | FileCheck %s -check-prefix=CHECK-STABLE
 
-// RUN: %clang_cc1 -analyzer-checker-help-hidden \
-// RUN:   2>&1 | FileCheck %s -check-prefix=CHECK-HIDDEN
+// RUN: %clang_cc1 -analyzer-checker-help-alpha \
+// RUN:   2>&1 | FileCheck %s -check-prefix=CHECK-ALPHA
 
-// CHECK: core.DivideZero
-// CHECK-HIDDEN: core.DivideZero
+// RUN: %clang_cc1 -analyzer-checker-help-developer \
+// RUN:   2>&1 | FileCheck %s -check-prefix=CHECK-DEVELOPER
 
-// CHECK-NOT: unix.DynamicMemoryModeling
-// CHECK-HIDDEN: unix.DynamicMemoryModeling
+// RUN: %clang_cc1 -analyzer-checker-help-developer \
+// RUN:   -analyzer-checker-help-alpha \
+// RUN:   2>&1 | FileCheck %s -check-prefix=CHECK-DEVELOPER-ALPHA
+
+// RUN: %clang_cc1 -analyzer-checker-help \
+// RUN:   -analyzer-checker-help-alpha \
+// RUN:   2>&1 | FileCheck %s -check-prefix=CHECK-STABLE-ALPHA
+
+// RUN: %clang_cc1 -analyzer-checker-help \
+// RUN:   -analyzer-checker-help-developer \
+// RUN:   2>&1 | FileCheck %s -check-prefix=CHECK-STABLE-DEVELOPER
+
+// RUN: %clang_cc1 -analyzer-checker-help \
+// RUN:   -analyzer-checker-help-alpha \
+// RUN:   -analyzer-checker-help-developer \
+// RUN:   2>&1 | FileCheck %s -check-prefix=CHECK-STABLE-ALPHA-DEVELOPER
+
+// CHECK-STABLE-NOT:alpha.unix.Chroot
+// CHECK-DEVELOPER-NOT: alpha.unix.Chroot
+// CHECK-ALPHA: alpha.unix.Chroot
+
+// Note that alpha.cplusplus.IteratorModeling is not only an alpha, but also a
+// hidden checker. In this case, we'd only like to see it in the developer list.
+// CHECK-ALPHA-NOT: alpha.cplusplus.IteratorModeling
+// CHECK-DEVELOPER: alpha.cplusplus.IteratorModeling
+
+// CHECK-STABLE:core.DivideZero
+// CHECK-DEVELOPER-NOT: core.DivideZero
+// CHECK-ALPHA-NOT: core.DivideZero
+
+// CHECK-STABLE-NOT: debug.ConfigDumper
+// CHECK-DEVELOPER:  debug.ConfigDumper
+// CHECK-ALPHA-NOT:  debug.ConfigDumper
+
+
+// CHECK-STABLE-ALPHA: alpha.unix.Chroot
+// CHECK-DEVELOPER-ALPHA:  alpha.unix.Chroot
+// CHECK-STABLE-DEVELOPER-NOT: alpha.unix.Chroot
+
+// CHECK-STABLE-ALPHA:core.DivideZero
+// CHECK-DEVELOPER-ALPHA-NOT: core.DivideZero
+// CHECK-STABLE-DEVELOPER:core.DivideZero
+
+// CHECK-STABLE-ALPHA-NOT: debug.ConfigDumper
+// CHECK-DEVELOPER-ALPHA:  debug.ConfigDumper
+// CHECK-STABLE-DEVELOPER: debug.ConfigDumper
+
+
+// CHECK-STABLE-ALPHA-DEVELOPER: alpha.unix.Chroot
+// CHECK-STABLE-ALPHA-DEVELOPER: core.DivideZero
+// CHECK-STABLE-ALPHA-DEVELOPER: debug.ConfigDumper
Index: lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
===
--- lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
+++ lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
@@ -514,13 +514,40 @@
   }
 
   const size_t InitialPad = 2;
-  for (const auto  : Checkers) {
-if (!AnOpts.ShowCheckerHelpHidden && 

[PATCH] D62092: [analyzer] Create the beta package that is more stable than alpha, move unix.cstring.OutOfBounds there

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

As per discussed on the mailing list 
, this patch 
introduces a new package, that is conceptually in between an alpha and a 
production ready package called `beta`.

Beta packages and checkers may lack a better better bug reporting,some 
finetuning on the FP/TP ratio, but as an experimental feature they are 
considered stable enough to be run on production code.

We philosophically define alpha as not "power user feature"s, or "high fp/tp 
reporting checkers that is usable sometimes", but as unfinished. For checkers 
in beta, while still unfinished, we would like to allow users to experiment 
with it, because according to our experience analyzing internal C/C++ code at 
Ericsson, false positives from alpha checkers, even with poor reporting were 
tolerable, hence the desire to move a portion of alpha checkers to beta.

This patch only moves a single checker to beta, `beta.unix.cstring.OutOfBounds`.


Repository:
  rC Clang

https://reviews.llvm.org/D62092

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  test/Analysis/bsd-string.c
  test/Analysis/bstring.c
  test/Analysis/cstring-plist.c
  test/Analysis/null-deref-ps-region.c
  test/Analysis/string.c

Index: test/Analysis/string.c
===
--- test/Analysis/string.c
+++ test/Analysis/string.c
@@ -1,8 +1,50 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.cstring,unix.Malloc,alpha.unix.cstring,debug.ExprInspection -analyzer-store=region -Wno-null-dereference -verify -analyzer-config eagerly-assume=false %s
-// RUN: %clang_analyze_cc1 -DUSE_BUILTINS -analyzer-checker=core,unix.cstring,unix.Malloc,alpha.unix.cstring,debug.ExprInspection -analyzer-store=region -Wno-null-dereference -verify -analyzer-config eagerly-assume=false %s
-// RUN: %clang_analyze_cc1 -DVARIANT -analyzer-checker=core,unix.cstring,unix.Malloc,alpha.unix.cstring,debug.ExprInspection -analyzer-store=region -Wno-null-dereference -verify -analyzer-config eagerly-assume=false %s
-// RUN: %clang_analyze_cc1 -DUSE_BUILTINS -DVARIANT -analyzer-checker=alpha.security.taint,core,unix.cstring,unix.Malloc,alpha.unix.cstring,debug.ExprInspection -analyzer-store=region -Wno-null-dereference -verify -analyzer-config eagerly-assume=false %s
-// RUN: %clang_analyze_cc1 -DSUPPRESS_OUT_OF_BOUND -analyzer-checker=core,unix.cstring,unix.Malloc,alpha.unix.cstring.BufferOverlap,alpha.unix.cstring.NotNullTerminated,debug.ExprInspection -analyzer-store=region -Wno-null-dereference -verify -analyzer-config eagerly-assume=false %s
+// RUN: %clang_analyze_cc1 -verify %s -Wno-null-dereference \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=unix.cstring \
+// RUN:   -analyzer-checker=unix.Malloc \
+// RUN:   -analyzer-checker=alpha.unix.cstring \
+// RUN:   -analyzer-checker=beta.unix.cstring \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false
+//
+// RUN: %clang_analyze_cc1 -verify %s -Wno-null-dereference -DUSE_BUILTINS \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=unix.cstring \
+// RUN:   -analyzer-checker=unix.Malloc \
+// RUN:   -analyzer-checker=alpha.unix.cstring \
+// RUN:   -analyzer-checker=beta.unix.cstring \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false
+//
+// RUN: %clang_analyze_cc1 -verify %s -Wno-null-dereference -DVARIANT \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=unix.cstring \
+// RUN:   -analyzer-checker=unix.Malloc \
+// RUN:   -analyzer-checker=alpha.unix.cstring \
+// RUN:   -analyzer-checker=beta.unix.cstring \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false
+//
+// RUN: %clang_analyze_cc1 -verify %s -Wno-null-dereference \
+// RUN:   -DUSE_BUILTINS -DVARIANT \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=alpha.security.taint \
+// RUN:   -analyzer-checker=unix.cstring \
+// RUN:   -analyzer-checker=unix.Malloc \
+// RUN:   -analyzer-checker=alpha.unix.cstring \
+// RUN:   -analyzer-checker=beta.unix.cstring \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false
+//
+// RUN: %clang_analyze_cc1 -verify %s -Wno-null-dereference \
+// RUN:   -DSUPPRESS_OUT_OF_BOUND \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=unix.cstring \
+// RUN:   -analyzer-checker=unix.Malloc \
+// RUN:   -analyzer-checker=alpha.unix.cstring.BufferOverlap \
+// RUN:   -analyzer-checker=alpha.unix.cstring.NotNullTerminated \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   

[PATCH] D62045: Modified global variable declaration to fit updated objc guide.

2019-05-17 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/google/GlobalVariableDeclarationCheck.cpp:45
+
+  auto NewName = (IsConst? "k": "g") + llvm::StringRef(std::string(1, 
FC)).upper()) +
+   Decl->getName().substr(1).str());

Can you make sure this is formatted correctly? I would expect a space before 
the `?` but I am not familiar with LLVM style on every detail.



Comment at: 
clang-tools-extra/clang-tidy/google/GlobalVariableDeclarationCheck.cpp:45
+
+  auto NewName = (IsConst? "k": "g") + llvm::StringRef(std::string(1, 
FC)).upper()) +
+   Decl->getName().substr(1).str());

stephanemoore wrote:
> Can you make sure this is formatted correctly? I would expect a space before 
> the `?` but I am not familiar with LLVM style on every detail.
Do the tests pass with the added `GlobalConstant` test case? I would expect 
that we need to add an early return to handle extern global constants but I 
could be mistaken.



Comment at: 
clang-tools-extra/clang-tidy/google/GlobalVariableDeclarationCheck.cpp:74
+  unless(isLocalVariable()),
+  unless(matchesName("::(k[A-Z].*)|([A-Z][A-Z0-9].*)")))
+  .bind("global_const"),

What is the reason for changing the regex to match the entire name?

(I do not object to the change but I want to know if there is a policy that I 
am not aware of)



Comment at: 
clang-tools-extra/test/clang-tidy/google-objc-global-variable-declaration.m:28
 
-static NSString* const k_Alpha = @"SecondNotAlpha";
-// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'k_Alpha' 
must have a name which starts with an appropriate prefix 
[google-objc-global-variable-declaration]

I would keep a `k_Alpha` test case so that we know that an underscore after the 
`k` is not accepted.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62045



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


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

2019-05-17 Thread Jan Korous via Phabricator via cfe-commits
jkorous updated this revision to Diff 200123.
jkorous added a comment.

fix link libraries in cmake


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

https://reviews.llvm.org/D58418

Files:
  clang/cmake/modules/AddClang.cmake
  clang/include/clang/DirectoryWatcher/DirectoryWatcher.h
  clang/lib/CMakeLists.txt
  clang/lib/DirectoryWatcher/CMakeLists.txt
  clang/lib/DirectoryWatcher/DirectoryScanner.cpp
  clang/lib/DirectoryWatcher/DirectoryScanner.h
  clang/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp
  clang/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp
  clang/unittests/CMakeLists.txt
  clang/unittests/DirectoryWatcher/CMakeLists.txt
  clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp

Index: clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
===
--- /dev/null
+++ clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
@@ -0,0 +1,359 @@
+//===- unittests/DirectoryWatcher/DirectoryWatcherTest.cpp ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/DirectoryWatcher/DirectoryWatcher.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Mutex.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/raw_ostream.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+#include 
+
+using namespace llvm;
+using namespace llvm::sys;
+using namespace llvm::sys::fs;
+using namespace clang;
+
+namespace clang {
+static bool operator==(const DirectoryWatcher::Event ,
+   const DirectoryWatcher::Event ) {
+  return lhs.Filename == rhs.Filename &&
+ static_cast(lhs.Kind) == static_cast(rhs.Kind);
+}
+} // namespace clang
+
+namespace {
+
+// Intentionally trivial - expecting just a very small numbers of events.
+class TestEventConsumer {
+  std::vector InitialEvents;
+  std::vector NonInitialEvents;
+  sys::Mutex Mtx;
+
+  // Expecting only very small sets - don't bother with anything smart.
+  static bool
+  AreExpectedPresent(const std::vector ,
+ const std::vector ) {
+for (const auto  : expected) {
+  if (std::find(actual.begin(), actual.end(), e) == actual.end())
+return false;
+}
+return true;
+  }
+
+public:
+  void push(llvm::ArrayRef Events, bool isInitial) {
+sys::ScopedLock L(Mtx);
+if (isInitial) {
+  for (const auto  : Events)
+InitialEvents.push_back(E);
+} else {
+  for (const auto  : Events)
+NonInitialEvents.push_back(E);
+}
+  }
+
+  std::vector getInitialEvents() {
+sys::ScopedLock L(Mtx);
+return InitialEvents;
+  }
+  std::vector getNonInitialEvents() {
+sys::ScopedLock L(Mtx);
+return NonInitialEvents;
+  }
+
+  // Fool-proof way how to compare.
+  bool AreExpectedPresentInInitial(
+  const std::vector ) {
+sys::ScopedLock L(Mtx);
+return AreExpectedPresent(InitialEvents, expected);
+  }
+
+  // Fool-proof way how to compare.
+  bool AreExpectedPresentInNonInitial(
+  const std::vector ) {
+sys::ScopedLock L(Mtx);
+return AreExpectedPresent(NonInitialEvents, expected);
+  }
+};
+
+struct DirectoryWatcherTestFixture {
+  std::string TestRootDir;
+  std::string TestWatchedDir;
+
+  DirectoryWatcherTestFixture() {
+SmallString<128> pathBuf;
+assert(!createUniqueDirectory("dirwatcher", pathBuf));
+TestRootDir = pathBuf.str();
+path::append(pathBuf, "watch");
+TestWatchedDir = pathBuf.str();
+assert(!create_directory(TestWatchedDir, false));
+  }
+
+  ~DirectoryWatcherTestFixture() { remove_directories(TestRootDir); }
+
+  SmallString<128> getPathInWatched(const std::string ) {
+SmallString<128> pathBuf;
+pathBuf = TestWatchedDir;
+path::append(pathBuf, testFile);
+return pathBuf;
+  }
+
+  void addFile(const std::string ) {
+Expected ft = openNativeFileForWrite(getPathInWatched(testFile),
+ CD_CreateNew, OF_None);
+if (ft) {
+  closeFile(*ft);
+} else {
+  llvm::errs() << llvm::toString(ft.takeError()) << "\n";
+  llvm::errs() << getPathInWatched(testFile) << "\n";
+  llvm_unreachable("Couldn't create test file.");
+}
+  }
+
+  void deleteFile(const std::string ) {
+std::error_code EC =
+remove(getPathInWatched(testFile), /*IgnoreNonExisting=*/false);
+ASSERT_FALSE(EC);
+  }
+};
+
+void WaitForAsync() {
+  // This is just a heuristic - trying to wait for changes to FS to propagate so
+  // the async event handling picks them up. Can make this test flaky.
+  std::this_thread::sleep_for(std::chrono::milliseconds(100)); // 0.1s
+}
+
+} // namespace
+
+TEST(DirectoryWatcherTest, initialScanSync) {
+  

[PATCH] D61809: [BPF] Preserve debuginfo array/union/struct type name/access index

2019-05-17 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song updated this revision to Diff 200117.
yonghong-song edited the summary of this revision.
yonghong-song added a comment.

array index may not be constant and remove inst_name


Repository:
  rC Clang

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

https://reviews.llvm.org/D61809

Files:
  include/clang/Basic/TargetInfo.h
  lib/Basic/Targets/BPF.h
  lib/CodeGen/CGBuilder.h
  lib/CodeGen/CGExpr.cpp
  test/CodeGen/bpf-offsetreloc.c

Index: test/CodeGen/bpf-offsetreloc.c
===
--- /dev/null
+++ test/CodeGen/bpf-offsetreloc.c
@@ -0,0 +1,17 @@
+// RUN: %clang -target bpf -emit-llvm -S -Xclang -target-feature -Xclang +offsetreloc -o - %s > %t1
+// RUN: grep "llvm.preserve.struct.access.index" %t1
+// RUN: grep "llvm.preserve.array.access.index" %t1
+// RUN: grep "llvm.preserve.union.access.index" %t1
+
+struct t {
+  int i:1;
+  int j:2;
+  union {
+   int a;
+   int b;
+  } c[4];
+};
+
+void *test(struct t *arg) {
+  return >c[3].b;
+}
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -3350,8 +3350,19 @@
   CharUnits eltAlign =
 getArrayElementAlign(addr.getAlignment(), indices.back(), eltSize);
 
-  llvm::Value *eltPtr = emitArraySubscriptGEP(
-  CGF, addr.getPointer(), indices, inbounds, signedIndices, loc, name);
+  llvm::Value *eltPtr;
+  auto LastIndex = dyn_cast(indices.back());
+  if (!CGF.getTarget().isPreserveDIAccessIndexNeeded() || !LastIndex) {
+eltPtr = emitArraySubscriptGEP(
+CGF, addr.getPointer(), indices, inbounds, signedIndices, loc, name);
+  } else {
+// Remember the original array subscript for bpf target
+unsigned idx = LastIndex->getZExtValue();
+eltPtr = CGF.Builder.CreatePreserveArrayAccessIndex(addr.getPointer(),
+indices.size() - 1,
+idx);
+  }
+
   return Address(eltPtr, eltAlign);
 }
 
@@ -3825,6 +3836,17 @@
   return CGF.Builder.CreateStructGEP(base, idx, field->getName());
 }
 
+static Address emitPreserveStructAccess(CodeGenFunction , Address base,
+const FieldDecl *field) {
+  const RecordDecl *rec = field->getParent();
+
+  unsigned idx =
+  CGF.CGM.getTypes().getCGRecordLayout(rec).getLLVMFieldNo(field);
+
+  return CGF.Builder.CreatePreserveStructAccessIndex(
+  base, rec->getName(), idx, field->getFieldIndex());
+}
+
 static bool hasAnyVptr(const QualType Type, const ASTContext ) {
   const auto *RD = Type.getTypePtr()->getAsCXXRecordDecl();
   if (!RD)
@@ -3932,9 +3954,21 @@
   // a barrier every time CXXRecord field with vptr is referenced.
   addr = Address(Builder.CreateLaunderInvariantGroup(addr.getPointer()),
  addr.getAlignment());
+
+if (getTarget().isPreserveDIAccessIndexNeeded())
+  // Remember the original union field index
+  addr = Address(
+  Builder.CreatePreserveUnionAccessIndex(
+  addr.getPointer(), rec->getName(), field->getFieldIndex()),
+  addr.getAlignment());
   } else {
-// For structs, we GEP to the field that the record layout suggests.
-addr = emitAddrOfFieldStorage(*this, addr, field);
+
+if (!getTarget().isPreserveDIAccessIndexNeeded())
+  // For structs, we GEP to the field that the record layout suggests.
+  addr = emitAddrOfFieldStorage(*this, addr, field);
+else
+  // Remember the original struct field index
+  addr = emitPreserveStructAccess(*this, addr, field);
 
 // If this is a reference field, load the reference right now.
 if (FieldType->isReferenceType()) {
Index: lib/CodeGen/CGBuilder.h
===
--- lib/CodeGen/CGBuilder.h
+++ lib/CodeGen/CGBuilder.h
@@ -298,6 +298,22 @@
 return CreateMemSet(Dest.getPointer(), Value, Size,
 Dest.getAlignment().getQuantity(), IsVolatile);
   }
+
+  using CGBuilderBaseTy::CreatePreserveStructAccessIndex;
+  Address CreatePreserveStructAccessIndex(Address Addr,
+  llvm::StringRef StructName,
+  unsigned Index,
+  unsigned FieldIndex) {
+llvm::StructType *ElTy = cast(Addr.getElementType());
+const llvm::DataLayout  = BB->getParent()->getParent()->getDataLayout();
+const llvm::StructLayout *Layout = DL.getStructLayout(ElTy);
+auto Offset = CharUnits::fromQuantity(Layout->getElementOffset(Index));
+
+return Address(CreatePreserveStructAccessIndex(Addr.getPointer(),
+   StructName,
+   Index, FieldIndex),
+   Addr.getAlignment().alignmentAtOffset(Offset));
+  }
 };
 
 }  // end 

[PATCH] D62045: Modified global variable declaration to fit updated objc guide.

2019-05-17 Thread Yaqi Ji via Phabricator via cfe-commits
yaqiji updated this revision to Diff 200113.
yaqiji marked an inline comment as done.
yaqiji added a comment.

Added fixithint for const as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62045

Files:
  clang-tools-extra/clang-tidy/google/GlobalVariableDeclarationCheck.cpp
  clang-tools-extra/test/clang-tidy/google-objc-global-variable-declaration.m

Index: clang-tools-extra/test/clang-tidy/google-objc-global-variable-declaration.m
===
--- clang-tools-extra/test/clang-tidy/google-objc-global-variable-declaration.m
+++ clang-tools-extra/test/clang-tidy/google-objc-global-variable-declaration.m
@@ -1,49 +1,58 @@
 // RUN: %check_clang_tidy %s google-objc-global-variable-declaration %t
 
 @class NSString;
-static NSString* const myConstString = @"hello";
+
+static NSString *const myConstString = @"hello";
 // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'myConstString' must have a name which starts with an appropriate prefix [google-objc-global-variable-declaration]
 // CHECK-FIXES: static NSString* const kMyConstString = @"hello";
 
-static NSString* MyString = @"hi";
+extern NSString *const GlobalConstant = @"hey";
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'GlobalConstant' must have a name which starts with an appropriate prefix [google-objc-global-variable-declaration]
+
+static NSString *MyString = @"hi";
 // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: non-const global variable 'MyString' must have a name which starts with 'g[A-Z]' [google-objc-global-variable-declaration]
-// CHECK-FIXES: static NSString* gMyString = @"hi";
+// CHECK-FIXES: static NSString *gMyString = @"hi";
 
-NSString* globalString = @"test";
+NSString *globalString = @"test";
 // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: non-const global variable 'globalString' must have a name which starts with 'g[A-Z]' [google-objc-global-variable-declaration]
-// CHECK-FIXES: NSString* gGlobalString = @"test";
+// CHECK-FIXES: NSString *gGlobalString = @"test";
 
-static NSString* a = @"too simple";
+static NSString *a = @"too simple";
 // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: non-const global variable 'a' must have a name which starts with 'g[A-Z]' [google-objc-global-variable-declaration]
-// CHECK-FIXES: static NSString* a = @"too simple";
+// CHECK-FIXES: static NSString *a = @"too simple";
 
-static NSString* noDef;
+static NSString *noDef;
 // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: non-const global variable 'noDef' must have a name which starts with 'g[A-Z]' [google-objc-global-variable-declaration]
-// CHECK-FIXES: static NSString* gNoDef;
+// CHECK-FIXES: static NSString *gNoDef;
 
-static NSString* const _notAlpha = @"NotBeginWithAlpha";
+static NSString *const _notAlpha = @"NotBeginWithAlpha";
 // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable '_notAlpha' must have a name which starts with an appropriate prefix [google-objc-global-variable-declaration]
-// CHECK-FIXES: static NSString* const _notAlpha = @"NotBeginWithAlpha";
 
-static NSString* const k_Alpha = @"SecondNotAlpha";
-// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'k_Alpha' must have a name which starts with an appropriate prefix [google-objc-global-variable-declaration]
-// CHECK-FIXES: static NSString* const k_Alpha = @"SecondNotAlpha";
+static NSString *const notCap = @"NotBeginWithCap";
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'notCap' must have a name which starts with an appropriate prefix [google-objc-global-variable-declaration]
+
+static NSString *const A_Alpha = @"SecondNotAlpha";
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'A_Alpha' must have a name which starts with an appropriate prefix [google-objc-global-variable-declaration]
+
+static NSString *const SecondNotCap = @"SecondNotCapOrNumber";
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'SecondNotCap' must have a name which starts with an appropriate prefix [google-objc-global-variable-declaration]
 
-static NSString* const kGood = @"hello";
-static NSString* const XYGood = @"hello";
-static NSString* gMyIntGood = 0;
+static NSString *const kGood = @"hello";
+static NSString *const XYGood = @"hello";
+static NSString *const X1Good = @"hello";
+static NSString *gMyIntGood = 0;
 
-extern NSString* const GTLServiceErrorDomain;
+extern NSString *const GTLServiceErrorDomain;
 
 enum GTLServiceError {
   GTLServiceErrorQueryResultMissing = -3000,
-  GTLServiceErrorWaitTimedOut   = -3001,
+  GTLServiceErrorWaitTimedOut = -3001,
 };
 
 @implementation Foo
 - (void)f {
-int x = 0;
-static int bar;
-static const int baz = 42;
+  int x = 0;
+  static int bar;
+  static const int baz = 42;
 }
 @end
Index: clang-tools-extra/clang-tidy/google/GlobalVariableDeclarationCheck.cpp

[PATCH] D62045: Modified global variable declaration to fit updated objc guide.

2019-05-17 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore requested changes to this revision.
stephanemoore added a comment.
This revision now requires changes to proceed.

Thanks for restoring the support for the legacy style! I noticed that there are 
some cases where we can preserve an existing fixit.




Comment at: 
clang-tools-extra/clang-tidy/google/GlobalVariableDeclarationCheck.cpp:45
+
+  if (IsConst) {
+// No fix available if it is a global constant, since it is difficult to

We can still emit a fix for static constants. Perhaps only early return if the 
variable declaration is both constant and static?



Comment at: 
clang-tools-extra/test/clang-tidy/google-objc-global-variable-declaration.m:6
-// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 
'myConstString' must have a name which starts with an appropriate prefix 
[google-objc-global-variable-declaration]
-// CHECK-FIXES: static NSString* const kMyConstString = @"hello";
 

This is still a valid fix that we can emit.

Maybe we can just recommend a fix for static constants?

Maybe we can add a case that we don't believe should have an emitted fixit like 
so:
```
extern NSString *const GlobalConstant;
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62045



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


[PATCH] D61617: [NewPassManager] Add tuning option: SLPVectorization [clang-change]

2019-05-17 Thread Chandler Carruth via Phabricator via cfe-commits
chandlerc accepted this revision.
chandlerc added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

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

https://reviews.llvm.org/D61617



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


[PATCH] D62045: Modified global variable declaration to fit updated objc guide.

2019-05-17 Thread Yaqi Ji via Phabricator via cfe-commits
yaqiji updated this revision to Diff 200102.
yaqiji added a comment.

Updated matching criteria to allow variable declarations for legacy code


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62045

Files:
  clang-tools-extra/clang-tidy/google/GlobalVariableDeclarationCheck.cpp
  clang-tools-extra/test/clang-tidy/google-objc-global-variable-declaration.m

Index: clang-tools-extra/test/clang-tidy/google-objc-global-variable-declaration.m
===
--- clang-tools-extra/test/clang-tidy/google-objc-global-variable-declaration.m
+++ clang-tools-extra/test/clang-tidy/google-objc-global-variable-declaration.m
@@ -1,49 +1,49 @@
 // RUN: %check_clang_tidy %s google-objc-global-variable-declaration %t
 
 @class NSString;
-static NSString* const myConstString = @"hello";
-// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'myConstString' must have a name which starts with an appropriate prefix [google-objc-global-variable-declaration]
-// CHECK-FIXES: static NSString* const kMyConstString = @"hello";
 
-static NSString* MyString = @"hi";
+static NSString *MyString = @"hi";
 // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: non-const global variable 'MyString' must have a name which starts with 'g[A-Z]' [google-objc-global-variable-declaration]
-// CHECK-FIXES: static NSString* gMyString = @"hi";
+// CHECK-FIXES: static NSString *gMyString = @"hi";
 
-NSString* globalString = @"test";
+NSString *globalString = @"test";
 // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: non-const global variable 'globalString' must have a name which starts with 'g[A-Z]' [google-objc-global-variable-declaration]
-// CHECK-FIXES: NSString* gGlobalString = @"test";
+// CHECK-FIXES: NSString *gGlobalString = @"test";
 
-static NSString* a = @"too simple";
+static NSString *a = @"too simple";
 // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: non-const global variable 'a' must have a name which starts with 'g[A-Z]' [google-objc-global-variable-declaration]
-// CHECK-FIXES: static NSString* a = @"too simple";
+// CHECK-FIXES: static NSString *a = @"too simple";
 
-static NSString* noDef;
+static NSString *noDef;
 // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: non-const global variable 'noDef' must have a name which starts with 'g[A-Z]' [google-objc-global-variable-declaration]
-// CHECK-FIXES: static NSString* gNoDef;
+// CHECK-FIXES: static NSString *gNoDef;
 
-static NSString* const _notAlpha = @"NotBeginWithAlpha";
+static NSString *const _notAlpha = @"NotBeginWithAlpha";
 // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable '_notAlpha' must have a name which starts with an appropriate prefix [google-objc-global-variable-declaration]
-// CHECK-FIXES: static NSString* const _notAlpha = @"NotBeginWithAlpha";
 
-static NSString* const k_Alpha = @"SecondNotAlpha";
-// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'k_Alpha' must have a name which starts with an appropriate prefix [google-objc-global-variable-declaration]
-// CHECK-FIXES: static NSString* const k_Alpha = @"SecondNotAlpha";
+static NSString *const notCap = @"NotBeginWithCap";
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'notCap' must have a name which starts with an appropriate prefix [google-objc-global-variable-declaration]
 
-static NSString* const kGood = @"hello";
-static NSString* const XYGood = @"hello";
-static NSString* gMyIntGood = 0;
+static NSString *const A_Alpha = @"SecondNotAlpha";
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'A_Alpha' must have a name which starts with an appropriate prefix [google-objc-global-variable-declaration]
 
-extern NSString* const GTLServiceErrorDomain;
+static NSString *const SecondNotCap = @"SecondNotCapOrNumber";
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'SecondNotCap' must have a name which starts with an appropriate prefix [google-objc-global-variable-declaration]
+
+static NSString *const XYGood = @"hello";
+static NSString *gMyIntGood = 0;
+
+extern NSString *const GTLServiceErrorDomain;
 
 enum GTLServiceError {
   GTLServiceErrorQueryResultMissing = -3000,
-  GTLServiceErrorWaitTimedOut   = -3001,
+  GTLServiceErrorWaitTimedOut = -3001,
 };
 
 @implementation Foo
 - (void)f {
-int x = 0;
-static int bar;
-static const int baz = 42;
+  int x = 0;
+  static int bar;
+  static const int baz = 42;
 }
 @end
Index: clang-tools-extra/clang-tidy/google/GlobalVariableDeclarationCheck.cpp
===
--- clang-tools-extra/clang-tidy/google/GlobalVariableDeclarationCheck.cpp
+++ clang-tools-extra/clang-tidy/google/GlobalVariableDeclarationCheck.cpp
@@ -23,34 +23,39 @@
 
 namespace {
 
-AST_MATCHER(VarDecl, isLocalVariable) {
-  return Node.isLocalVarDecl();
-}
+AST_MATCHER(VarDecl, isLocalVariable) { return 

LLvm masrer and llvm lab unavailable tomorrow

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

LLvm masrer and llvm lab will be unavailable tomorrow Saturday, May 18th,
from 10:30 am to 2:00 pm PST due to works related to an infrastructure
improvement project.
Thank you for understanding.

Thanks

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


[PATCH] D61923: [GWP-ASan] Mutex implementation [2].

2019-05-17 Thread Mitch Phillips via Phabricator via cfe-commits
hctim updated this revision to Diff 200094.
hctim added a comment.

Merged in master after fixing up some buildbots with the previous patches.

Also have pinged libcxx-dev :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61923

Files:
  clang/runtime/CMakeLists.txt
  compiler-rt/lib/gwp_asan/CMakeLists.txt
  compiler-rt/lib/gwp_asan/definitions.h
  compiler-rt/lib/gwp_asan/mutex.h
  compiler-rt/lib/gwp_asan/tests/CMakeLists.txt
  compiler-rt/lib/gwp_asan/tests/driver.cpp
  compiler-rt/lib/gwp_asan/tests/mutex_test.cpp
  compiler-rt/test/gwp_asan/CMakeLists.txt
  compiler-rt/test/gwp_asan/dummy_test.cc
  compiler-rt/test/gwp_asan/lit.cfg
  compiler-rt/test/gwp_asan/lit.site.cfg.in
  compiler-rt/test/gwp_asan/unit/lit.site.cfg.in

Index: compiler-rt/test/gwp_asan/unit/lit.site.cfg.in
===
--- /dev/null
+++ compiler-rt/test/gwp_asan/unit/lit.site.cfg.in
@@ -0,0 +1,9 @@
+@LIT_SITE_CFG_IN_HEADER@
+
+config.name = "GwpAsan-Unittest"
+# Load common config for all compiler-rt unit tests.
+lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/unittests/lit.common.unit.configured")
+
+config.test_exec_root = os.path.join("@COMPILER_RT_BINARY_DIR@",
+ "lib", "gwp_asan", "tests")
+config.test_source_root = config.test_exec_root
Index: compiler-rt/test/gwp_asan/lit.site.cfg.in
===
--- /dev/null
+++ compiler-rt/test/gwp_asan/lit.site.cfg.in
@@ -0,0 +1,11 @@
+@LIT_SITE_CFG_IN_HEADER@
+
+config.name_suffix = "@GWP_ASAN_TEST_CONFIG_SUFFIX@"
+config.target_arch = "@GWP_ASAN_TEST_TARGET_ARCH@"
+config.target_cflags = "@GWP_ASAN_TEST_TARGET_CFLAGS@"
+
+# Load common config for all compiler-rt lit tests.
+lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured")
+
+# Load tool-specific config that would do the real work.
+lit_config.load_config(config, "@GWP_ASAN_LIT_SOURCE_DIR@/lit.cfg")
Index: compiler-rt/test/gwp_asan/lit.cfg
===
--- /dev/null
+++ compiler-rt/test/gwp_asan/lit.cfg
@@ -0,0 +1,31 @@
+# -*- Python -*-
+
+import os
+
+# Setup config name.
+config.name = 'GWP-ASan' + config.name_suffix
+
+# Setup source root.
+config.test_source_root = os.path.dirname(__file__)
+
+# Test suffixes.
+config.suffixes = ['.c', '.cc', '.cpp', '.test']
+
+# C & CXX flags.
+c_flags = ([config.target_cflags])
+
+# Android doesn't want -lrt.
+if not config.android:
+  c_flags += ["-lrt"]
+
+cxx_flags = (c_flags + config.cxx_mode_flags + ["-std=c++11"])
+
+def build_invocation(compile_flags):
+  return " " + " ".join([config.clang] + compile_flags) + " "
+
+# Add substitutions.
+config.substitutions.append(("%clang ", build_invocation(c_flags)))
+
+# GWP-ASan tests are currently supported on Linux only.
+if config.host_os not in ['Linux']:
+   config.unsupported = True
Index: compiler-rt/test/gwp_asan/dummy_test.cc
===
--- /dev/null
+++ compiler-rt/test/gwp_asan/dummy_test.cc
@@ -0,0 +1,4 @@
+// Exists to simply stop warnings about lit not discovering any tests here.
+// RUN: %clang %s
+
+int main() { return 0; }
Index: compiler-rt/test/gwp_asan/CMakeLists.txt
===
--- compiler-rt/test/gwp_asan/CMakeLists.txt
+++ compiler-rt/test/gwp_asan/CMakeLists.txt
@@ -0,0 +1,45 @@
+set(GWP_ASAN_LIT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+set(GWP_ASAN_LIT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
+
+set(GWP_ASAN_TESTSUITES)
+
+set(GWP_ASAN_UNITTEST_DEPS)
+set(GWP_ASAN_TEST_DEPS
+  ${SANITIZER_COMMON_LIT_TEST_DEPS}
+  gwp_asan)
+
+if (COMPILER_RT_INCLUDE_TESTS)
+  list(APPEND GWP_ASAN_TEST_DEPS GwpAsanUnitTests)
+  configure_lit_site_cfg(
+${CMAKE_CURRENT_SOURCE_DIR}/unit/lit.site.cfg.in
+${CMAKE_CURRENT_BINARY_DIR}/unit/lit.site.cfg)
+  add_lit_testsuite(check-gwp_asan-unit "Running GWP-ASan unit tests"
+${CMAKE_CURRENT_BINARY_DIR}/unit
+DEPENDS ${GWP_ASAN_TEST_DEPS})
+  set_target_properties(check-gwp_asan-unit PROPERTIES FOLDER
+"Compiler-RT Tests")
+list(APPEND GWP_ASAN_TEST_DEPS check-gwp_asan-unit)
+endif()
+
+configure_lit_site_cfg(
+  ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
+  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
+  )
+
+foreach(arch ${GWP_ASAN_SUPPORTED_ARCH})
+  set(GWP_ASAN_TEST_TARGET_ARCH ${arch})
+  string(TOLOWER "-${arch}" GWP_ASAN_TEST_CONFIG_SUFFIX)
+  get_test_cc_for_arch(${arch} GWP_ASAN_TEST_TARGET_CC GWP_ASAN_TEST_TARGET_CFLAGS)
+  string(TOUPPER ${arch} ARCH_UPPER_CASE)
+  set(CONFIG_NAME ${ARCH_UPPER_CASE}${OS_NAME}Config)
+
+  configure_lit_site_cfg(
+${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
+${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg)
+  list(APPEND GWP_ASAN_TESTSUITES 

[PATCH] D60568: [OpenMP] Add support for registering requires directives with the runtime

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

- Fix braces.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60568

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.h
  lib/CodeGen/CodeGenModule.cpp
  test/OpenMP/openmp_offload_registration.cpp
  test/OpenMP/target_codegen.cpp
  test/OpenMP/target_codegen_registration.cpp
  test/OpenMP/target_depend_codegen.cpp
  test/OpenMP/target_parallel_codegen.cpp
  test/OpenMP/target_parallel_codegen_registration.cpp
  test/OpenMP/target_parallel_depend_codegen.cpp
  test/OpenMP/target_parallel_for_codegen.cpp
  test/OpenMP/target_parallel_for_codegen_registration.cpp
  test/OpenMP/target_parallel_for_depend_codegen.cpp
  test/OpenMP/target_parallel_for_simd_codegen.cpp
  test/OpenMP/target_parallel_for_simd_codegen_registration.cpp
  test/OpenMP/target_parallel_for_simd_depend_codegen.cpp
  test/OpenMP/target_parallel_if_codegen.cpp
  test/OpenMP/target_parallel_num_threads_codegen.cpp
  test/OpenMP/target_simd_codegen.cpp
  test/OpenMP/target_simd_codegen_registration.cpp
  test/OpenMP/target_simd_depend_codegen.cpp
  test/OpenMP/target_teams_codegen.cpp
  test/OpenMP/target_teams_codegen_registration.cpp
  test/OpenMP/target_teams_depend_codegen.cpp
  test/OpenMP/target_teams_distribute_codegen.cpp
  test/OpenMP/target_teams_distribute_codegen_registration.cpp
  test/OpenMP/target_teams_distribute_depend_codegen.cpp
  test/OpenMP/target_teams_distribute_parallel_for_depend_codegen.cpp
  test/OpenMP/target_teams_distribute_parallel_for_simd_codegen_registration.cpp
  test/OpenMP/target_teams_distribute_parallel_for_simd_depend_codegen.cpp
  test/OpenMP/target_teams_distribute_simd_codegen.cpp
  test/OpenMP/target_teams_distribute_simd_codegen_registration.cpp
  test/OpenMP/target_teams_distribute_simd_depend_codegen.cpp
  test/OpenMP/target_teams_num_teams_codegen.cpp
  test/OpenMP/target_teams_thread_limit_codegen.cpp

Index: test/OpenMP/target_teams_thread_limit_codegen.cpp
===
--- test/OpenMP/target_teams_thread_limit_codegen.cpp
+++ test/OpenMP/target_teams_thread_limit_codegen.cpp
@@ -76,7 +76,7 @@
 // CHECK: [[DESC:@.+]] = internal constant [[DSCTY]] { i32 1, [[DEVTY]]* getelementptr inbounds ([1 x [[DEVTY]]], [1 x [[DEVTY]]]* [[IMAGES]], i32 0, i32 0), [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* [[ENTEND]] }, comdat($[[REGFN]])
 
 // Check target registration is registered as a Ctor.
-// CHECK: appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
+// CHECK: appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @.omp_offloading.requires_reg, i8* null }, { i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
 
 
 template
Index: test/OpenMP/target_teams_num_teams_codegen.cpp
===
--- test/OpenMP/target_teams_num_teams_codegen.cpp
+++ test/OpenMP/target_teams_num_teams_codegen.cpp
@@ -76,7 +76,7 @@
 // CHECK: [[DESC:@.+]] = internal constant [[DSCTY]] { i32 1, [[DEVTY]]* getelementptr inbounds ([1 x [[DEVTY]]], [1 x [[DEVTY]]]* [[IMAGES]], i32 0, i32 0), [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* [[ENTEND]] }, comdat($[[REGFN]])
 
 // Check target registration is registered as a Ctor.
-// CHECK: appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
+// CHECK: appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @.omp_offloading.requires_reg, i8* null }, { i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
 
 
 template
Index: test/OpenMP/target_teams_distribute_simd_depend_codegen.cpp
===
--- test/OpenMP/target_teams_distribute_simd_depend_codegen.cpp
+++ test/OpenMP/target_teams_distribute_simd_depend_codegen.cpp
@@ -64,7 +64,7 @@
 // CHECK: [[DESC:@.+]] = internal constant [[DSCTY]] { i32 1, [[DEVTY]]* getelementptr inbounds ([1 x [[DEVTY]]], [1 x [[DEVTY]]]* [[IMAGES]], i32 0, i32 0), [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* [[ENTEND]] }, comdat($[[REGFN]])
 
 // Check target registration is registered as a Ctor.
-// CHECK: appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
+// CHECK: appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @.omp_offloading.requires_reg, i8* null }, { i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
 
 
 template
Index: 

[PATCH] D60568: [OpenMP] Add support for registering requires directives with the runtime

2019-05-17 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 200089.
gtbercea marked 3 inline comments as done.
gtbercea added a comment.

- Fix format.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60568

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.h
  lib/CodeGen/CodeGenModule.cpp
  test/OpenMP/openmp_offload_registration.cpp
  test/OpenMP/target_codegen.cpp
  test/OpenMP/target_codegen_registration.cpp
  test/OpenMP/target_depend_codegen.cpp
  test/OpenMP/target_parallel_codegen.cpp
  test/OpenMP/target_parallel_codegen_registration.cpp
  test/OpenMP/target_parallel_depend_codegen.cpp
  test/OpenMP/target_parallel_for_codegen.cpp
  test/OpenMP/target_parallel_for_codegen_registration.cpp
  test/OpenMP/target_parallel_for_depend_codegen.cpp
  test/OpenMP/target_parallel_for_simd_codegen.cpp
  test/OpenMP/target_parallel_for_simd_codegen_registration.cpp
  test/OpenMP/target_parallel_for_simd_depend_codegen.cpp
  test/OpenMP/target_parallel_if_codegen.cpp
  test/OpenMP/target_parallel_num_threads_codegen.cpp
  test/OpenMP/target_simd_codegen.cpp
  test/OpenMP/target_simd_codegen_registration.cpp
  test/OpenMP/target_simd_depend_codegen.cpp
  test/OpenMP/target_teams_codegen.cpp
  test/OpenMP/target_teams_codegen_registration.cpp
  test/OpenMP/target_teams_depend_codegen.cpp
  test/OpenMP/target_teams_distribute_codegen.cpp
  test/OpenMP/target_teams_distribute_codegen_registration.cpp
  test/OpenMP/target_teams_distribute_depend_codegen.cpp
  test/OpenMP/target_teams_distribute_parallel_for_depend_codegen.cpp
  test/OpenMP/target_teams_distribute_parallel_for_simd_codegen_registration.cpp
  test/OpenMP/target_teams_distribute_parallel_for_simd_depend_codegen.cpp
  test/OpenMP/target_teams_distribute_simd_codegen.cpp
  test/OpenMP/target_teams_distribute_simd_codegen_registration.cpp
  test/OpenMP/target_teams_distribute_simd_depend_codegen.cpp
  test/OpenMP/target_teams_num_teams_codegen.cpp
  test/OpenMP/target_teams_thread_limit_codegen.cpp

Index: test/OpenMP/target_teams_thread_limit_codegen.cpp
===
--- test/OpenMP/target_teams_thread_limit_codegen.cpp
+++ test/OpenMP/target_teams_thread_limit_codegen.cpp
@@ -76,7 +76,7 @@
 // CHECK: [[DESC:@.+]] = internal constant [[DSCTY]] { i32 1, [[DEVTY]]* getelementptr inbounds ([1 x [[DEVTY]]], [1 x [[DEVTY]]]* [[IMAGES]], i32 0, i32 0), [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* [[ENTEND]] }, comdat($[[REGFN]])
 
 // Check target registration is registered as a Ctor.
-// CHECK: appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
+// CHECK: appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @.omp_offloading.requires_reg, i8* null }, { i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
 
 
 template
Index: test/OpenMP/target_teams_num_teams_codegen.cpp
===
--- test/OpenMP/target_teams_num_teams_codegen.cpp
+++ test/OpenMP/target_teams_num_teams_codegen.cpp
@@ -76,7 +76,7 @@
 // CHECK: [[DESC:@.+]] = internal constant [[DSCTY]] { i32 1, [[DEVTY]]* getelementptr inbounds ([1 x [[DEVTY]]], [1 x [[DEVTY]]]* [[IMAGES]], i32 0, i32 0), [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* [[ENTEND]] }, comdat($[[REGFN]])
 
 // Check target registration is registered as a Ctor.
-// CHECK: appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
+// CHECK: appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @.omp_offloading.requires_reg, i8* null }, { i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
 
 
 template
Index: test/OpenMP/target_teams_distribute_simd_depend_codegen.cpp
===
--- test/OpenMP/target_teams_distribute_simd_depend_codegen.cpp
+++ test/OpenMP/target_teams_distribute_simd_depend_codegen.cpp
@@ -64,7 +64,7 @@
 // CHECK: [[DESC:@.+]] = internal constant [[DSCTY]] { i32 1, [[DEVTY]]* getelementptr inbounds ([1 x [[DEVTY]]], [1 x [[DEVTY]]]* [[IMAGES]], i32 0, i32 0), [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* [[ENTEND]] }, comdat($[[REGFN]])
 
 // Check target registration is registered as a Ctor.
-// CHECK: appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
+// CHECK: appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @.omp_offloading.requires_reg, i8* null }, { i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
 
 
 template
Index: 

[PATCH] D60568: [OpenMP] Add support for registering requires directives with the runtime

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

- Fix conditions.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60568

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.h
  lib/CodeGen/CodeGenModule.cpp
  test/OpenMP/openmp_offload_registration.cpp
  test/OpenMP/target_codegen.cpp
  test/OpenMP/target_codegen_registration.cpp
  test/OpenMP/target_depend_codegen.cpp
  test/OpenMP/target_parallel_codegen.cpp
  test/OpenMP/target_parallel_codegen_registration.cpp
  test/OpenMP/target_parallel_depend_codegen.cpp
  test/OpenMP/target_parallel_for_codegen.cpp
  test/OpenMP/target_parallel_for_codegen_registration.cpp
  test/OpenMP/target_parallel_for_depend_codegen.cpp
  test/OpenMP/target_parallel_for_simd_codegen.cpp
  test/OpenMP/target_parallel_for_simd_codegen_registration.cpp
  test/OpenMP/target_parallel_for_simd_depend_codegen.cpp
  test/OpenMP/target_parallel_if_codegen.cpp
  test/OpenMP/target_parallel_num_threads_codegen.cpp
  test/OpenMP/target_simd_codegen.cpp
  test/OpenMP/target_simd_codegen_registration.cpp
  test/OpenMP/target_simd_depend_codegen.cpp
  test/OpenMP/target_teams_codegen.cpp
  test/OpenMP/target_teams_codegen_registration.cpp
  test/OpenMP/target_teams_depend_codegen.cpp
  test/OpenMP/target_teams_distribute_codegen.cpp
  test/OpenMP/target_teams_distribute_codegen_registration.cpp
  test/OpenMP/target_teams_distribute_depend_codegen.cpp
  test/OpenMP/target_teams_distribute_parallel_for_depend_codegen.cpp
  test/OpenMP/target_teams_distribute_parallel_for_simd_codegen_registration.cpp
  test/OpenMP/target_teams_distribute_parallel_for_simd_depend_codegen.cpp
  test/OpenMP/target_teams_distribute_simd_codegen.cpp
  test/OpenMP/target_teams_distribute_simd_codegen_registration.cpp
  test/OpenMP/target_teams_distribute_simd_depend_codegen.cpp
  test/OpenMP/target_teams_num_teams_codegen.cpp
  test/OpenMP/target_teams_thread_limit_codegen.cpp

Index: test/OpenMP/target_teams_thread_limit_codegen.cpp
===
--- test/OpenMP/target_teams_thread_limit_codegen.cpp
+++ test/OpenMP/target_teams_thread_limit_codegen.cpp
@@ -76,7 +76,7 @@
 // CHECK: [[DESC:@.+]] = internal constant [[DSCTY]] { i32 1, [[DEVTY]]* getelementptr inbounds ([1 x [[DEVTY]]], [1 x [[DEVTY]]]* [[IMAGES]], i32 0, i32 0), [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* [[ENTEND]] }, comdat($[[REGFN]])
 
 // Check target registration is registered as a Ctor.
-// CHECK: appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
+// CHECK: appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @.omp_offloading.requires_reg, i8* null }, { i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
 
 
 template
Index: test/OpenMP/target_teams_num_teams_codegen.cpp
===
--- test/OpenMP/target_teams_num_teams_codegen.cpp
+++ test/OpenMP/target_teams_num_teams_codegen.cpp
@@ -76,7 +76,7 @@
 // CHECK: [[DESC:@.+]] = internal constant [[DSCTY]] { i32 1, [[DEVTY]]* getelementptr inbounds ([1 x [[DEVTY]]], [1 x [[DEVTY]]]* [[IMAGES]], i32 0, i32 0), [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* [[ENTEND]] }, comdat($[[REGFN]])
 
 // Check target registration is registered as a Ctor.
-// CHECK: appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
+// CHECK: appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @.omp_offloading.requires_reg, i8* null }, { i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
 
 
 template
Index: test/OpenMP/target_teams_distribute_simd_depend_codegen.cpp
===
--- test/OpenMP/target_teams_distribute_simd_depend_codegen.cpp
+++ test/OpenMP/target_teams_distribute_simd_depend_codegen.cpp
@@ -64,7 +64,7 @@
 // CHECK: [[DESC:@.+]] = internal constant [[DSCTY]] { i32 1, [[DEVTY]]* getelementptr inbounds ([1 x [[DEVTY]]], [1 x [[DEVTY]]]* [[IMAGES]], i32 0, i32 0), [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* [[ENTEND]] }, comdat($[[REGFN]])
 
 // Check target registration is registered as a Ctor.
-// CHECK: appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
+// CHECK: appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @.omp_offloading.requires_reg, i8* null }, { i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
 
 
 template
Index: 

[PATCH] D62045: Modified global variable declaration to fit updated objc guide.

2019-05-17 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore requested changes to this revision.
stephanemoore marked 4 inline comments as done.
stephanemoore added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/google/GlobalVariableDeclarationCheck.cpp:51-52
+
+  auto NewName = "g" + llvm::StringRef(std::string(1, FC)).upper()) +
+   Decl->getName().substr(1).str());
+

benhamilton wrote:
> I don't see any guidance in the style guide about prefixing with `g` either. 
> I assume we should remove that?
> 
Non-const static variable declaration names should have the prefix `g`:
"File scope or global variables have a prefix g."
https://google.github.io/styleguide/objcguide.html#variable-names

The prefixes section in the style guide 
(https://google.github.io/styleguide/objcguide.html#prefixes) is targeted 
towards prefixes for classes, protocols, global functions, and global constants 
(i.e., const qualified variable declaration names).



Comment at: 
clang-tools-extra/clang-tidy/google/GlobalVariableDeclarationCheck.cpp:79
  unless(isLocalVariable()),
- unless(matchesName("::(k[A-Z]|[A-Z]{2,})")))
+ unless(matchesName("::[A-Z][A-Z0-9].*")))
  .bind("global_const"),

For legacy code, I think we still need to allow variable declarations of the 
following form:
```
static const int kFileCount = 12;
static const int kFOOFileCount = 12;
```



Comment at: 
clang-tools-extra/test/clang-tidy/google-objc-global-variable-declaration.m:26
 // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable '_notAlpha' 
must have a name which starts with an appropriate prefix 
[google-objc-global-variable-declaration]
-// CHECK-FIXES: static NSString* const _notAlpha = @"NotBeginWithAlpha";
 

Thanks for removing the fixit on this case  The fix was not compliant with 
Google Objective-C style.



Comment at: 
clang-tools-extra/test/clang-tidy/google-objc-global-variable-declaration.m:30
-// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'k_Alpha' 
must have a name which starts with an appropriate prefix 
[google-objc-global-variable-declaration]
-// CHECK-FIXES: static NSString* const k_Alpha = @"SecondNotAlpha";
 

Thanks for removing the fixit on this case  The fix was not compliant with 
Google Objective-C style.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62045



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


[PATCH] D61774: [LibTooling] Add RangeSelector library for defining source ranges based on bound AST nodes.

2019-05-17 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 200079.
ymandel marked 2 inline comments as done.
ymandel added a comment.

fixed formatting.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61774

Files:
  clang/include/clang/Tooling/Refactoring/RangeSelector.h
  clang/lib/Tooling/Refactoring/CMakeLists.txt
  clang/lib/Tooling/Refactoring/RangeSelector.cpp
  clang/unittests/Tooling/CMakeLists.txt
  clang/unittests/Tooling/RangeSelectorTest.cpp

Index: clang/unittests/Tooling/RangeSelectorTest.cpp
===
--- /dev/null
+++ clang/unittests/Tooling/RangeSelectorTest.cpp
@@ -0,0 +1,496 @@
+//===- unittest/Tooling/RangeSelectorTest.cpp -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Tooling/Refactoring/RangeSelector.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/FixIt.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Testing/Support/Error.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+using namespace tooling;
+using namespace ast_matchers;
+
+namespace {
+using ::testing::AllOf;
+using ::testing::HasSubstr;
+using MatchResult = MatchFinder::MatchResult;
+using ::llvm::Expected;
+using ::llvm::Failed;
+using ::llvm::HasValue;
+using ::llvm::StringError;
+
+struct TestMatch {
+  // The AST unit from which `result` is built. We bundle it because it backs
+  // the result. Users are not expected to access it.
+  std::unique_ptr ASTUnit;
+  // The result to use in the test. References `ast_unit`.
+  MatchResult Result;
+};
+
+template  TestMatch matchCode(StringRef Code, M Matcher) {
+  auto ASTUnit = buildASTFromCode(Code);
+  assert(ASTUnit != nullptr && "AST construction failed");
+
+  ASTContext  = ASTUnit->getASTContext();
+  assert(!Context.getDiagnostics().hasErrorOccurred() && "Compilation error");
+
+  auto Matches = ast_matchers::match(Matcher, Context);
+  // We expect a single, exact match.
+  assert(Matches.size() != 0 && "no matches found");
+  assert(Matches.size() == 1 && "too many matches");
+
+  return TestMatch{std::move(ASTUnit), MatchResult(Matches[0], )};
+}
+
+// Applies \p Selector to \p Match and, on success, returns the selected source.
+Expected apply(RangeSelector Selector, const TestMatch ) {
+  Expected Range = Selector(Match.Result);
+  if (!Range)
+return Range.takeError();
+  return fixit::internal::getText(*Range, *Match.Result.Context);
+}
+
+// Applies \p Selector to a trivial match with only a single bound node with id
+// "bound_node_id".  For use in testing unbound-node errors.
+Expected applyToTrivial(const RangeSelector ) {
+  // We need to bind the result to something, or the match will fail. Use a
+  // binding that is not used in the unbound node tests.
+  TestMatch Match =
+  matchCode("static int x = 0;", varDecl().bind("bound_node_id"));
+  return Selector(Match.Result);
+}
+
+// Matches the message expected for unbound-node failures.
+testing::Matcher withUnboundNodeMessage() {
+  return testing::Property(
+  ::getMessage,
+  AllOf(HasSubstr("unbound_id"), HasSubstr("not bound")));
+}
+
+// Applies \p Selector to code containing assorted node types, where the match
+// binds each one: a statement ("stmt"), a (non-member) ctor-initializer
+// ("init"), an expression ("expr") and a (nameless) declaration ("decl").  Used
+// to test failures caused by applying selectors to nodes of the wrong type.
+Expected applyToAssorted(RangeSelector Selector) {
+  StringRef Code = R"cc(
+  struct A {};
+  class F : public A {
+   public:
+F(int) {}
+  };
+  void g() { F f(1); }
+)cc";
+
+  auto Matcher =
+  compoundStmt(
+  hasDescendant(
+  cxxConstructExpr(
+  hasDeclaration(
+  decl(hasDescendant(cxxCtorInitializer(isBaseInitializer())
+ .bind("init")))
+  .bind("decl")))
+  .bind("expr")))
+  .bind("stmt");
+
+  return Selector(matchCode(Code, Matcher).Result);
+}
+
+// Matches the message expected for type-error failures.
+testing::Matcher withTypeErrorMessage(StringRef NodeID) {
+  return testing::Property(
+  ::getMessage,
+  AllOf(HasSubstr(NodeID), HasSubstr("mismatched type")));
+}
+
+TEST(RangeSelectorTest, UnboundNode) {
+  EXPECT_THAT_EXPECTED(applyToTrivial(node("unbound_id")),
+   Failed(withUnboundNodeMessage()));
+}
+
+TEST(RangeSelectorTest, RangeOp) {
+  StringRef Code = R"cc(
+int f(int x, int y, int z) { return 

r361067 - [c++20] P1327R1: Support for typeid applied to objects of polymorphic

2019-05-17 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri May 17 12:19:28 2019
New Revision: 361067

URL: http://llvm.org/viewvc/llvm-project?rev=361067=rev
Log:
[c++20] P1327R1: Support for typeid applied to objects of polymorphic
class type in constant evaluation.

This reinstates r360977, reverted in r360987, now that its rerequisite
patch is reinstated and fixed.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/SemaCXX/constant-expression-cxx2a.cpp
cfe/trunk/www/cxx_status.html

Modified: cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td?rev=361067=361066=361067=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td Fri May 17 12:19:28 2019
@@ -12,7 +12,8 @@ let Component = "AST" in {
 def note_expr_divide_by_zero : Note<"division by zero">;
 def note_constexpr_invalid_cast : Note<
   "%select{reinterpret_cast|dynamic_cast|cast that performs the conversions of"
-  " a reinterpret_cast|cast from %1}0 is not allowed in a constant 
expression">;
+  " a reinterpret_cast|cast from %1}0 is not allowed in a constant expression"
+  "%select{| in C++ standards before C++2a||}0">;
 def note_constexpr_invalid_downcast : Note<
   "cannot cast object of dynamic type %0 to type %1">;
 def note_constexpr_overflow : Note<
@@ -31,12 +32,13 @@ def note_constexpr_invalid_inhctor : Not
 def note_constexpr_no_return : Note<
   "control reached end of constexpr function">;
 def note_constexpr_virtual_call : Note<
-  "cannot evaluate call to virtual function in a constant expression">;
+  "cannot evaluate call to virtual function in a constant expression "
+  "in C++ standards before C++2a">;
 def note_constexpr_pure_virtual_call : Note<
   "pure virtual function %q0 called">;
 def note_constexpr_polymorphic_unknown_dynamic_type : Note<
-  "%select{virtual function called on|dynamic_cast applied to}0 "
-  "object '%1' whose dynamic type is not constant">;
+  "%select{virtual function called on|dynamic_cast applied to|"
+  "typeid applied to}0 object '%1' whose dynamic type is not constant">;
 def note_constexpr_dynamic_cast_to_reference_failed : Note<
   "reference dynamic_cast failed: %select{"
   "static type %1 of operand is a non-public base class of dynamic type %2|"
@@ -90,7 +92,7 @@ def note_constexpr_var_init_non_constant
   "initializer of %0 is not a constant expression">;
 def note_constexpr_typeid_polymorphic : Note<
   "typeid applied to expression of polymorphic type %0 is "
-  "not allowed in a constant expression">;
+  "not allowed in a constant expression in C++ standards before C++2a">;
 def note_constexpr_void_comparison : Note<
   "comparison between unequal pointers to void has unspecified result">;
 def note_constexpr_temporary_here : Note<"temporary created here">;
@@ -108,11 +110,11 @@ def note_constexpr_this : Note<
   "evaluation of a call to a 'constexpr' member function">;
 def note_constexpr_lifetime_ended : Note<
   "%select{read of|assignment to|increment of|decrement of|member call on|"
-  "dynamic_cast of}0 "
+  "dynamic_cast of|typeid applied to}0 "
   "%select{temporary|variable}1 whose lifetime has ended">;
 def note_constexpr_access_uninit : Note<
   "%select{read of|assignment to|increment of|decrement of|member call on|"
-  "dynamic_cast of}0 "
+  "dynamic_cast of|typeid applied to}0 "
   "object outside its lifetime is not allowed in a constant expression">;
 def note_constexpr_use_uninit_reference : Note<
   "use of reference outside its lifetime "
@@ -139,30 +141,30 @@ def note_constexpr_ltor_incomplete_type
   "read of incomplete type %0 is not allowed in a constant expression">;
 def note_constexpr_access_null : Note<
   "%select{read of|assignment to|increment of|decrement of|member call on|"
-  "dynamic_cast of}0 "
+  "dynamic_cast of|typeid applied to}0 "
   "dereferenced null pointer is not allowed in a constant expression">;
 def note_constexpr_access_past_end : Note<
   "%select{read of|assignment to|increment of|decrement of|member call on|"
-  "dynamic_cast of}0 "
+  "dynamic_cast of|typeid applied to}0 "
   "dereferenced one-past-the-end pointer is not allowed in a constant 
expression">;
 def note_constexpr_access_unsized_array : Note<
   "%select{read of|assignment to|increment of|decrement of|member call on|"
-  "dynamic_cast of}0 "
+  "dynamic_cast of|typeid applied to}0 "
   "element of array without known bound "
   "is not allowed in a constant expression">;
 def note_constexpr_access_inactive_union_member : Note<
   "%select{read of|assignment to|increment of|decrement of|member call on|"
-  "dynamic_cast of}0 "
+  "dynamic_cast of|typeid applied to}0 "
   "member %1 of union with %select{active member %3|no active member}2 "
   "is not allowed in a constant 

[PATCH] D62046: [OpenMP][bugfix] Add missing math functions variants for log and abs.

2019-05-17 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC361066: [OpenMP][bugfix] Add missing math functions variants 
for log and abs. (authored by gbercea, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D62046?vs=200048=200076#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D62046

Files:
  lib/Headers/__clang_cuda_cmath.h
  lib/Headers/__clang_cuda_math_forward_declares.h


Index: lib/Headers/__clang_cuda_math_forward_declares.h
===
--- lib/Headers/__clang_cuda_math_forward_declares.h
+++ lib/Headers/__clang_cuda_math_forward_declares.h
@@ -42,6 +42,14 @@
 __DEVICE__ double abs(double);
 __DEVICE__ float abs(float);
 #endif
+// While providing the CUDA declarations and definitions for math functions,
+// we may manually define additional functions.
+// TODO: Once variant is supported the additional functions will have
+// to be removed.
+#if defined(_OPENMP) && defined(__cplusplus)
+__DEVICE__ const double abs(const double);
+__DEVICE__ const float abs(const float);
+#endif
 __DEVICE__ int abs(int) __NOEXCEPT;
 __DEVICE__ double acos(double);
 __DEVICE__ float acos(float);
@@ -144,6 +152,9 @@
 __DEVICE__ float log2(float);
 __DEVICE__ double logb(double);
 __DEVICE__ float logb(float);
+#if defined(_OPENMP) && defined(__cplusplus)
+__DEVICE__ long double log(long double);
+#endif
 __DEVICE__ double log(double);
 __DEVICE__ float log(float);
 __DEVICE__ long lrint(double);
Index: lib/Headers/__clang_cuda_cmath.h
===
--- lib/Headers/__clang_cuda_cmath.h
+++ lib/Headers/__clang_cuda_cmath.h
@@ -51,6 +51,11 @@
 __DEVICE__ float abs(float __x) { return ::fabsf(__x); }
 __DEVICE__ double abs(double __x) { return ::fabs(__x); }
 #endif
+// TODO: remove once variat is supported.
+#if defined(_OPENMP) && defined(__cplusplus)
+__DEVICE__ const float abs(const float __x) { return ::fabsf((float)__x); }
+__DEVICE__ const double abs(const double __x) { return ::fabs((double)__x); }
+#endif
 __DEVICE__ float acos(float __x) { return ::acosf(__x); }
 __DEVICE__ float asin(float __x) { return ::asinf(__x); }
 __DEVICE__ float atan(float __x) { return ::atanf(__x); }


Index: lib/Headers/__clang_cuda_math_forward_declares.h
===
--- lib/Headers/__clang_cuda_math_forward_declares.h
+++ lib/Headers/__clang_cuda_math_forward_declares.h
@@ -42,6 +42,14 @@
 __DEVICE__ double abs(double);
 __DEVICE__ float abs(float);
 #endif
+// While providing the CUDA declarations and definitions for math functions,
+// we may manually define additional functions.
+// TODO: Once variant is supported the additional functions will have
+// to be removed.
+#if defined(_OPENMP) && defined(__cplusplus)
+__DEVICE__ const double abs(const double);
+__DEVICE__ const float abs(const float);
+#endif
 __DEVICE__ int abs(int) __NOEXCEPT;
 __DEVICE__ double acos(double);
 __DEVICE__ float acos(float);
@@ -144,6 +152,9 @@
 __DEVICE__ float log2(float);
 __DEVICE__ double logb(double);
 __DEVICE__ float logb(float);
+#if defined(_OPENMP) && defined(__cplusplus)
+__DEVICE__ long double log(long double);
+#endif
 __DEVICE__ double log(double);
 __DEVICE__ float log(float);
 __DEVICE__ long lrint(double);
Index: lib/Headers/__clang_cuda_cmath.h
===
--- lib/Headers/__clang_cuda_cmath.h
+++ lib/Headers/__clang_cuda_cmath.h
@@ -51,6 +51,11 @@
 __DEVICE__ float abs(float __x) { return ::fabsf(__x); }
 __DEVICE__ double abs(double __x) { return ::fabs(__x); }
 #endif
+// TODO: remove once variat is supported.
+#if defined(_OPENMP) && defined(__cplusplus)
+__DEVICE__ const float abs(const float __x) { return ::fabsf((float)__x); }
+__DEVICE__ const double abs(const double __x) { return ::fabs((double)__x); }
+#endif
 __DEVICE__ float acos(float __x) { return ::acosf(__x); }
 __DEVICE__ float asin(float __x) { return ::asinf(__x); }
 __DEVICE__ float atan(float __x) { return ::atanf(__x); }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r361066 - [OpenMP][bugfix] Add missing math functions variants for log and abs.

2019-05-17 Thread Gheorghe-Teodor Bercea via cfe-commits
Author: gbercea
Date: Fri May 17 12:15:53 2019
New Revision: 361066

URL: http://llvm.org/viewvc/llvm-project?rev=361066=rev
Log:
[OpenMP][bugfix] Add missing math functions variants for log and abs.

Summary: When including the random header in C++, some of the math functions it 
relies on are not present in the CUDA headers. We include this variants in this 
case.

Reviewers: jdoerfert, hfinkel, tra, caomhin

Reviewed By: tra

Subscribers: efriedma, guansong, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/lib/Headers/__clang_cuda_cmath.h
cfe/trunk/lib/Headers/__clang_cuda_math_forward_declares.h

Modified: cfe/trunk/lib/Headers/__clang_cuda_cmath.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_cmath.h?rev=361066=361065=361066=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_cmath.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_cmath.h Fri May 17 12:15:53 2019
@@ -51,6 +51,11 @@ __DEVICE__ long abs(long __n) { return :
 __DEVICE__ float abs(float __x) { return ::fabsf(__x); }
 __DEVICE__ double abs(double __x) { return ::fabs(__x); }
 #endif
+// TODO: remove once variat is supported.
+#if defined(_OPENMP) && defined(__cplusplus)
+__DEVICE__ const float abs(const float __x) { return ::fabsf((float)__x); }
+__DEVICE__ const double abs(const double __x) { return ::fabs((double)__x); }
+#endif
 __DEVICE__ float acos(float __x) { return ::acosf(__x); }
 __DEVICE__ float asin(float __x) { return ::asinf(__x); }
 __DEVICE__ float atan(float __x) { return ::atanf(__x); }

Modified: cfe/trunk/lib/Headers/__clang_cuda_math_forward_declares.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_math_forward_declares.h?rev=361066=361065=361066=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_math_forward_declares.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_math_forward_declares.h Fri May 17 
12:15:53 2019
@@ -42,6 +42,14 @@ __DEVICE__ long long abs(long long);
 __DEVICE__ double abs(double);
 __DEVICE__ float abs(float);
 #endif
+// While providing the CUDA declarations and definitions for math functions,
+// we may manually define additional functions.
+// TODO: Once variant is supported the additional functions will have
+// to be removed.
+#if defined(_OPENMP) && defined(__cplusplus)
+__DEVICE__ const double abs(const double);
+__DEVICE__ const float abs(const float);
+#endif
 __DEVICE__ int abs(int) __NOEXCEPT;
 __DEVICE__ double acos(double);
 __DEVICE__ float acos(float);
@@ -144,6 +152,9 @@ __DEVICE__ double log2(double);
 __DEVICE__ float log2(float);
 __DEVICE__ double logb(double);
 __DEVICE__ float logb(float);
+#if defined(_OPENMP) && defined(__cplusplus)
+__DEVICE__ long double log(long double);
+#endif
 __DEVICE__ double log(double);
 __DEVICE__ float log(float);
 __DEVICE__ long lrint(double);


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


[PATCH] D61909: Add Clang shared library with C++ exports

2019-05-17 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

@sylvestre.ledru, I’ve added you on D62040 , 
which is an attempt to document best practices for generating releases.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61909



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


[PATCH] D62045: Modified global variable declaration to fit updated objc guide.

2019-05-17 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton requested changes to this revision.
benhamilton added inline comments.
This revision now requires changes to proceed.



Comment at: 
clang-tools-extra/clang-tidy/google/GlobalVariableDeclarationCheck.cpp:51-52
+
+  auto NewName = "g" + llvm::StringRef(std::string(1, FC)).upper()) +
+   Decl->getName().substr(1).str());
+

I don't see any guidance in the style guide about prefixing with `g` either. I 
assume we should remove that?



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62045



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


[PATCH] D62034: compiler-rt/lib/builtins: s/#include /#include /g to match proper case.

2019-05-17 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo requested changes to this revision.
mstorsjo added a comment.
This revision now requires changes to proceed.

No, I don't think this is a good idea.

Like I said, the Windows SDK is not self-consistent, so you cannot use it on a 
case sensitive file system without other case insensitivity fixes anyway. Thus, 
this change breaks things for any existing user with mingw headers (which works 
fine on case sensitive file systems without any fixups), and doesn't make the 
Windows SDK work on a case sensitive filesystem anyway. Once the Windows SDK 
actually is self-consistent so that it works on a case sensitive filesystem, 
I'm sure it's possible to add symlinks to mingw to allow the casing that has 
been decided upon by the Windows SDK by then. But until then, please don't.

As an example, the Windows SDK itself (version 10.0.17763.0) contains 839 
occurrances of `#include ` or `#include "windows.h"` with all lower 
case, while it contains 1 (one) occurrance of `#include `. Now, is 
it easier to change all those 839 occurrances of `windows.h` to `Windows.h` in 
the SDK itself, or conclude that `#include ` is the canonical 
spelling?

The SDK contains 455 headers in total where the casing between file name and 
name used in include directives differs.

In addition, when the linker parses embedded `/defaultlib:` attributes, those 
don't match the actual files either. `msvcrt.lib` contains 
`/defaultlib:kernel32.lib`, while the actual file on disk is named 
`Kernel32.lib`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62034



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


[PATCH] D61386: [clang-tidy] Add support writing a check as a Transformer rewrite rule.

2019-05-17 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 200072.
ymandel added a comment.

Updated to incorporate changes to Transformer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61386

Files:
  clang-tools-extra/clang-tidy/utils/CMakeLists.txt
  clang-tools-extra/clang-tidy/utils/TransformerTidy.cpp
  clang-tools-extra/clang-tidy/utils/TransformerTidy.h
  clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
  clang-tools-extra/unittests/clang-tidy/TransformerTidyTest.cpp

Index: clang-tools-extra/unittests/clang-tidy/TransformerTidyTest.cpp
===
--- /dev/null
+++ clang-tools-extra/unittests/clang-tidy/TransformerTidyTest.cpp
@@ -0,0 +1,63 @@
+//=== TransformerTidyTest.cpp - clang-tidy ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "../clang-tidy/utils/TransformerTidy.h"
+#include "ClangTidyTest.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/Refactoring/Stencil.h"
+#include "clang/Tooling/Refactoring/Transformer.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace tidy {
+namespace utils {
+namespace {
+// Invert the code of an if-statement, while maintaining its semantics.
+tooling::RewriteRule invertIf() {
+  using namespace ::clang::ast_matchers;
+  using tooling::change;
+  using tooling::stencil::cat;
+  using tooling::stencil::node;
+  using tooling::stencil::sNode;
+
+  StringRef C = "C", T = "T", E = "E";
+  return tooling::makeRule(
+  ifStmt(hasCondition(expr().bind(C)), hasThen(stmt().bind(T)),
+ hasElse(stmt().bind(E))),
+  change(cat("if(!(", node(C), ")) ", sNode(E), " else ", sNode(T;
+}
+
+class IfInverterTidy : public TransformerTidy {
+public:
+  IfInverterTidy(StringRef Name, ClangTidyContext *Context)
+  : TransformerTidy(invertIf(), Name, Context) {}
+};
+
+// Basic test of using a rewrite rule as a ClangTidy.
+TEST(TransformerTidyTest, Basic) {
+  const std::string Input = R"cc(
+void log(const char* msg);
+void foo() {
+  if (10 > 1.0)
+log("oh no!");
+  else
+log("ok");
+}
+  )cc";
+  const std::string Expected = R"(
+void log(const char* msg);
+void foo() {
+  if(!(10 > 1.0)) log("ok"); else log("oh no!");
+}
+  )";
+  EXPECT_EQ(Expected, test::runCheckOnCode(Input));
+}
+} // namespace
+} // namespace utils
+} // namespace tidy
+} // namespace clang
Index: clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
===
--- clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
+++ clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
@@ -17,6 +17,7 @@
   OverlappingReplacementsTest.cpp
   UsingInserterTest.cpp
   ReadabilityModuleTest.cpp
+  TransformerTidyTest.cpp
   )
 
 target_link_libraries(ClangTidyTests
@@ -36,4 +37,5 @@
   clangTidyUtils
   clangTooling
   clangToolingCore
+  clangToolingRefactor
   )
Index: clang-tools-extra/clang-tidy/utils/TransformerTidy.h
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/utils/TransformerTidy.h
@@ -0,0 +1,49 @@
+//===-- TransformerTidy.h - clang-tidy ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_TRANSFORMER_TIDY_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_TRANSFORMER_TIDY_H
+
+#include "../ClangTidy.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Tooling/Refactoring/Transformer.h"
+#include 
+#include 
+
+namespace clang {
+namespace tidy {
+namespace utils {
+
+// A base class for defining a ClangTidy check based on a rewrite rule.
+//
+// For example, given a RewriteRule `MyCheckAsRewriteRule`, one can define your
+// tidy check as follows:
+//
+// class MyTidyCheck : public TransformerTidy {
+//  public:
+//   MyTidyCheck(StringRef Name, ClangTidyContext *Context)
+//   : TransformerTidy(MyCheckAsRewriteRule, Name, Context) {}
+// };
+class TransformerTidy : public ClangTidyCheck {
+public:
+  TransformerTidy(tooling::RewriteRule R, StringRef Name,
+  ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context), Rule(std::move(R)) {}
+
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult ) override;
+
+private:
+  

[PATCH] D62034: compiler-rt/lib/builtins: s/#include /#include /g to match proper case.

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

In D62034#1506879 , @mclow.lists wrote:

> I have no objection to this; but I'm not really confident that this won't 
> break more than it solves.


Actually, I think the existing VFS overlay would fix this without any changes. 
So I will likely pull this patch back.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62034



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


[PATCH] D62034: compiler-rt/lib/builtins: s/#include /#include /g to match proper case.

2019-05-17 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

I have no objection to this; but I'm not really confident that this won't break 
more than it solves.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62034



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


[PATCH] D62034: compiler-rt/lib/builtins: s/#include /#include /g to match proper case.

2019-05-17 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi added a comment.
Herald added a subscriber: dexonsmith.

In D62034#1506102 , @mstorsjo wrote:

> Yes, MinGW headers are all lowercase.
>
> And the Windows SDK, where the file is spelled with a capital W, isn't 
> self-consistent (some headers include others with a different capitalization 
> than the files actually are stored with), so to use the official Windows SDK 
> on a case sensitive file system, you need some sort of case fixup anyway. (Or 
> did that change very recently?) And in that case, making it all lowercase is 
> the simplest, which also happens to match the MinGW headers.


We can't control the case mismatches in the Windows SDK but we can control them 
in LLVM. Why should we consistently use the wrong case? The difference between 
LLVM and the Windows SDK using the wrong case is, that we can maintain a vfs 
overlay file for the Windows SDK only and be fairly certain that it wont change 
that frequently.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62034



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


[PATCH] D62034: compiler-rt/lib/builtins: s/#include /#include /g to match proper case.

2019-05-17 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi updated this revision to Diff 200067.
plotfi added a comment.
Herald added subscribers: openmp-commits, libcxx-commits, lldb-commits, 
cfe-commits, lebedev.ri, kadircet, arphaman, jkorous, christof, hiraditya, 
mgorny, ki.stfu, kubamracek.
Herald added a reviewer: jfb.
Herald added a reviewer: lebedev.ri.
Herald added projects: clang, LLDB, libc++, OpenMP.

adding all windows.h's in all of monorepo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62034

Files:
  clang-tools-extra/clangd/Threading.cpp
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/tools/libclang/CIndexer.cpp
  compiler-rt/lib/BlocksRuntime/runtime.c
  compiler-rt/lib/asan/asan_win.cc
  compiler-rt/lib/asan/asan_win_dynamic_runtime_thunk.cc
  compiler-rt/lib/builtins/emutls.c
  compiler-rt/lib/builtins/enable_execute_stack.c
  compiler-rt/lib/fuzzer/FuzzerIOWindows.cpp
  compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp
  compiler-rt/lib/interception/interception_win.cc
  compiler-rt/lib/interception/tests/interception_win_test.cc
  compiler-rt/lib/profile/CMakeLists.txt
  compiler-rt/lib/profile/GCDAProfiling.c
  compiler-rt/lib/profile/InstrProfilingPort.h
  compiler-rt/lib/profile/InstrProfilingUtil.c
  compiler-rt/lib/profile/WindowsMMap.c
  compiler-rt/lib/sanitizer_common/sanitizer_dbghelp.h
  compiler-rt/lib/sanitizer_common/sanitizer_unwind_win.cc
  compiler-rt/lib/sanitizer_common/sanitizer_win.cc
  compiler-rt/lib/sanitizer_common/tests/sanitizer_libc_test.cc
  compiler-rt/lib/stats/stats_client.cc
  compiler-rt/test/asan/TestCases/Windows/aligned_mallocs.cc
  compiler-rt/test/asan/TestCases/Windows/beginthreadex.cc
  compiler-rt/test/asan/TestCases/Windows/bind_io_completion_callback.cc
  compiler-rt/test/asan/TestCases/Windows/bitfield.cc
  compiler-rt/test/asan/TestCases/Windows/bitfield_uaf.cc
  compiler-rt/test/asan/TestCases/Windows/crash_read_write.cc
  compiler-rt/test/asan/TestCases/Windows/dll_control_c.cc
  compiler-rt/test/asan/TestCases/Windows/dll_heap_allocation.cc
  compiler-rt/test/asan/TestCases/Windows/dll_host.cc
  
compiler-rt/test/asan/TestCases/Windows/dll_report_globals_symbolization_at_startup.cc
  compiler-rt/test/asan/TestCases/Windows/dll_seh.cc
  compiler-rt/test/asan/TestCases/Windows/dll_thread_stack_array_left_oob.cc
  compiler-rt/test/asan/TestCases/Windows/global_const_string.cc
  compiler-rt/test/asan/TestCases/Windows/global_const_string_oob.cc
  compiler-rt/test/asan/TestCases/Windows/operator_array_new_right_oob.cc
  compiler-rt/test/asan/TestCases/Windows/operator_array_new_uaf.cc
  compiler-rt/test/asan/TestCases/Windows/operator_delete_wrong_argument.cc
  compiler-rt/test/asan/TestCases/Windows/operator_new_left_oob.cc
  compiler-rt/test/asan/TestCases/Windows/operator_new_right_oob.cc
  compiler-rt/test/asan/TestCases/Windows/operator_new_uaf.cc
  compiler-rt/test/asan/TestCases/Windows/queue_user_work_item.cc
  compiler-rt/test/asan/TestCases/Windows/queue_user_work_item_report.cc
  compiler-rt/test/asan/TestCases/Windows/recalloc_sanity.cc
  compiler-rt/test/asan/TestCases/Windows/report_after_syminitialize.cc
  compiler-rt/test/asan/TestCases/Windows/report_globals_reload_dll.cc
  compiler-rt/test/asan/TestCases/Windows/report_globals_vs_freelibrary.cc
  compiler-rt/test/asan/TestCases/Windows/seh.cc
  compiler-rt/test/asan/TestCases/Windows/thread_simple.cc
  compiler-rt/test/asan/TestCases/Windows/thread_stack_array_left_oob.cc
  compiler-rt/test/asan/TestCases/Windows/thread_stack_array_right_oob.cc
  compiler-rt/test/asan/TestCases/Windows/thread_stack_reuse.cc
  compiler-rt/test/asan/TestCases/Windows/thread_stress.cc
  compiler-rt/test/asan/TestCases/Windows/thread_suspended.cc
  compiler-rt/test/asan/TestCases/Windows/tls_init.cc
  compiler-rt/test/asan/TestCases/Windows/user-exception.cc
  compiler-rt/test/asan/TestCases/Windows/windows_h.cc
  compiler-rt/test/asan/TestCases/exitcode.cc
  compiler-rt/test/asan/TestCases/ill.cc
  compiler-rt/test/builtins/Unit/clear_cache_test.c
  libcxx/src/chrono.cpp
  libcxx/src/support/win32/thread_win32.cpp
  libcxx/src/thread.cpp
  libcxx/utils/google-benchmark/src/colorprint.cc
  libcxx/utils/google-benchmark/src/sleep.cc
  libcxx/utils/google-benchmark/src/sysinfo.cc
  libcxx/utils/google-benchmark/src/timers.cc
  libcxxabi/src/cxa_personality.cpp
  libunwind/include/unwind.h
  libunwind/src/AddressSpace.hpp
  libunwind/src/RWMutex.hpp
  libunwind/src/UnwindCursor.hpp
  lldb/include/lldb/Host/windows/windows.h
  lldb/packages/Python/lldbsuite/test/python_api/hello_world/main.c
  lldb/packages/Python/lldbsuite/test/python_api/signals/main.cpp
  lldb/packages/Python/lldbsuite/test/tools/lldb-server/main.cpp
  lldb/source/Utility/Status.cpp
  lldb/tools/lldb-mi/MICmnStreamStdin.cpp
  lldb/tools/lldb-mi/MIUtilDebug.cpp
  lldb/tools/lldb-vscode/IOStream.h
  lldb/tools/lldb-vscode/lldb-vscode.cpp
  llgo/third_party/gofrontend/libffi/src/dlmalloc.c
  

Re: r361033 - Add a Visit overload for DynTypedNode to ASTNodeTraverser

2019-05-17 Thread Nico Weber via cfe-commits
*From: *Stephen Kelly via cfe-commits 
*Date: *Fri, May 17, 2019 at 1:56 PM
*To: *Yitzhak Mandelbaum
*Cc: *cfe-commits

Hmm, thanks for letting me know!
>
> Is that an old compiler?
>
> I'm not near a computer for the weekend.
>
> Can someone fix or revert?
>

Sure, reverted in 361059.


>
> Thanks,
>
> Stephen.
>
> On Fri 17 May 2019, 17:11 Yitzhak Mandelbaum,  wrote:
>
>> Looks like this caused a breakage:
>> http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/18641/steps/ninja%20check%201/logs/stdio
>>
>> On Fri, May 17, 2019 at 9:52 AM Stephen Kelly via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: steveire
>>> Date: Fri May 17 06:55:28 2019
>>> New Revision: 361033
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=361033=rev
>>> Log:
>>> Add a Visit overload for DynTypedNode to ASTNodeTraverser
>>>
>>> Reviewers: aaron.ballman
>>>
>>> Subscribers: cfe-commits
>>>
>>> Tags: #clang
>>>
>>> Differential Revision: https://reviews.llvm.org/D61834
>>>
>>> Added:
>>> cfe/trunk/unittests/AST/ASTTraverserTest.cpp
>>> Modified:
>>> cfe/trunk/include/clang/AST/ASTNodeTraverser.h
>>> cfe/trunk/unittests/AST/CMakeLists.txt
>>>
>>> Modified: cfe/trunk/include/clang/AST/ASTNodeTraverser.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTNodeTraverser.h?rev=361033=361032=361033=diff
>>>
>>> ==
>>> --- cfe/trunk/include/clang/AST/ASTNodeTraverser.h (original)
>>> +++ cfe/trunk/include/clang/AST/ASTNodeTraverser.h Fri May 17 06:55:28
>>> 2019
>>> @@ -205,6 +205,24 @@ public:
>>>  });
>>>}
>>>
>>> +  void Visit(const ast_type_traits::DynTypedNode ) {
>>> +// FIXME: Improve this with a switch or a visitor pattern.
>>> +if (const auto *D = N.get())
>>> +  Visit(D);
>>> +else if (const auto *S = N.get())
>>> +  Visit(S);
>>> +else if (const auto *QT = N.get())
>>> +  Visit(*QT);
>>> +else if (const auto *T = N.get())
>>> +  Visit(T);
>>> +else if (const auto *C = N.get())
>>> +  Visit(C);
>>> +else if (const auto *C = N.get())
>>> +  Visit(C);
>>> +else if (const auto *T = N.get())
>>> +  Visit(*T);
>>> +  }
>>> +
>>>void dumpDeclContext(const DeclContext *DC) {
>>>  if (!DC)
>>>return;
>>>
>>> Added: cfe/trunk/unittests/AST/ASTTraverserTest.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/ASTTraverserTest.cpp?rev=361033=auto
>>>
>>> ==
>>> --- cfe/trunk/unittests/AST/ASTTraverserTest.cpp (added)
>>> +++ cfe/trunk/unittests/AST/ASTTraverserTest.cpp Fri May 17 06:55:28 2019
>>> @@ -0,0 +1,220 @@
>>> +//===-
>>> unittests/AST/ASTTraverserTest.h===//
>>> +//
>>> +// Part of the LLVM Project, under the Apache License v2.0 with LLVM
>>> Exceptions.
>>> +// See https://llvm.org/LICENSE.txt for license information.
>>> +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
>>> +//
>>>
>>> +//===--===//
>>> +
>>> +#include "clang/AST/ASTContext.h"
>>> +#include "clang/AST/ASTNodeTraverser.h"
>>> +#include "clang/AST/TextNodeDumper.h"
>>> +#include "clang/ASTMatchers/ASTMatchFinder.h"
>>> +#include "clang/ASTMatchers/ASTMatchers.h"
>>> +#include "clang/Tooling/Tooling.h"
>>> +#include "gmock/gmock.h"
>>> +#include "gtest/gtest.h"
>>> +
>>> +using namespace clang::tooling;
>>> +using namespace clang::ast_matchers;
>>> +
>>> +namespace clang {
>>> +
>>> +class NodeTreePrinter : public TextTreeStructure {
>>> +  llvm::raw_ostream 
>>> +
>>> +public:
>>> +  NodeTreePrinter(llvm::raw_ostream )
>>> +  : TextTreeStructure(OS, /* showColors */ false), OS(OS) {}
>>> +
>>> +  void Visit(const Decl *D) { OS << D->getDeclKindName() << "Decl"; }
>>> +
>>> +  void Visit(const Stmt *S) { OS << S->getStmtClassName(); }
>>> +
>>> +  void Visit(QualType QT) {
>>> +OS << "QualType " << QT.split().Quals.getAsString();
>>> +  }
>>> +
>>> +  void Visit(const Type *T) { OS << T->getTypeClassName() << "Type"; }
>>> +
>>> +  void Visit(const comments::Comment *C, const comments::FullComment
>>> *FC) {
>>> +OS << C->getCommentKindName();
>>> +  }
>>> +
>>> +  void Visit(const CXXCtorInitializer *Init) { OS <<
>>> "CXXCtorInitializer"; }
>>> +
>>> +  void Visit(const Attr *A) {
>>> +switch (A->getKind()) {
>>> +#define ATTR(X)
>>> \
>>> +  case attr::X:
>>> \
>>> +OS << #X;
>>> \
>>> +break;
>>> +#include "clang/Basic/AttrList.inc"
>>> +}
>>> +OS << "Attr";
>>> +  }
>>> +
>>> +  void Visit(const OMPClause *C) { OS << "OMPClause"; }
>>> +  void Visit(const TemplateArgument , SourceRange R = {},
>>> + const Decl *From = nullptr, const char *Label = nullptr) {
>>> +OS << "TemplateArgument";
>>> +  }
>>> +
>>> +  template  void Visit(T...) {}

r361059 - Revert r361033 "Add a Visit overload for DynTypedNode to ASTNodeTraverser"

2019-05-17 Thread Nico Weber via cfe-commits
Author: nico
Date: Fri May 17 11:31:24 2019
New Revision: 361059

URL: http://llvm.org/viewvc/llvm-project?rev=361059=rev
Log:
Revert r361033 "Add a Visit overload for DynTypedNode to ASTNodeTraverser"

It fails to build on some bots.

Also revert follow-up r361055.

Removed:
cfe/trunk/unittests/AST/ASTTraverserTest.cpp
Modified:
cfe/trunk/include/clang/AST/ASTNodeTraverser.h
cfe/trunk/unittests/AST/CMakeLists.txt

Modified: cfe/trunk/include/clang/AST/ASTNodeTraverser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTNodeTraverser.h?rev=361059=361058=361059=diff
==
--- cfe/trunk/include/clang/AST/ASTNodeTraverser.h (original)
+++ cfe/trunk/include/clang/AST/ASTNodeTraverser.h Fri May 17 11:31:24 2019
@@ -205,24 +205,6 @@ public:
 });
   }
 
-  void Visit(const ast_type_traits::DynTypedNode ) {
-// FIXME: Improve this with a switch or a visitor pattern.
-if (const auto *D = N.get())
-  Visit(D);
-else if (const auto *S = N.get())
-  Visit(S);
-else if (const auto *QT = N.get())
-  Visit(*QT);
-else if (const auto *T = N.get())
-  Visit(T);
-else if (const auto *C = N.get())
-  Visit(C);
-else if (const auto *C = N.get())
-  Visit(C);
-else if (const auto *T = N.get())
-  Visit(*T);
-  }
-
   void dumpDeclContext(const DeclContext *DC) {
 if (!DC)
   return;

Removed: cfe/trunk/unittests/AST/ASTTraverserTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/ASTTraverserTest.cpp?rev=361058=auto
==
--- cfe/trunk/unittests/AST/ASTTraverserTest.cpp (original)
+++ cfe/trunk/unittests/AST/ASTTraverserTest.cpp (removed)
@@ -1,220 +0,0 @@
-//===- 
unittests/AST/ASTTraverserTest.h===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-
-#include "clang/AST/ASTContext.h"
-#include "clang/AST/ASTNodeTraverser.h"
-#include "clang/AST/TextNodeDumper.h"
-#include "clang/ASTMatchers/ASTMatchFinder.h"
-#include "clang/ASTMatchers/ASTMatchers.h"
-#include "clang/Tooling/Tooling.h"
-#include "gmock/gmock.h"
-#include "gtest/gtest.h"
-
-using namespace clang::tooling;
-using namespace clang::ast_matchers;
-
-namespace clang {
-
-class NodeTreePrinter : public TextTreeStructure {
-  llvm::raw_ostream 
-
-public:
-  NodeTreePrinter(llvm::raw_ostream )
-  : TextTreeStructure(OS, /* showColors */ false), OS(OS) {}
-
-  void Visit(const Decl *D) { OS << D->getDeclKindName() << "Decl"; }
-
-  void Visit(const Stmt *S) { OS << S->getStmtClassName(); }
-
-  void Visit(QualType QT) {
-OS << "QualType " << QT.split().Quals.getAsString();
-  }
-
-  void Visit(const Type *T) { OS << T->getTypeClassName() << "Type"; }
-
-  void Visit(const comments::Comment *C, const comments::FullComment *FC) {
-OS << C->getCommentKindName();
-  }
-
-  void Visit(const CXXCtorInitializer *Init) { OS << "CXXCtorInitializer"; }
-
-  void Visit(const Attr *A) {
-switch (A->getKind()) {
-#define ATTR(X)
\
-  case attr::X:
\
-OS << #X;  
\
-break;
-#include "clang/Basic/AttrList.inc"
-}
-OS << "Attr";
-  }
-
-  void Visit(const OMPClause *C) { OS << "OMPClause"; }
-  void Visit(const TemplateArgument , SourceRange R = {},
- const Decl *From = nullptr, const char *Label = nullptr) {
-OS << "TemplateArgument";
-  }
-
-  template  void Visit(T...) {}
-};
-
-class TestASTDumper : public ASTNodeTraverser {
-
-  NodeTreePrinter MyNodeRecorder;
-
-public:
-  TestASTDumper(llvm::raw_ostream ) : MyNodeRecorder(OS) {}
-  NodeTreePrinter () { return MyNodeRecorder; }
-};
-
-template  std::string dumpASTString(NodeType &&... N) {
-  std::string Buffer;
-  llvm::raw_string_ostream OS(Buffer);
-
-  TestASTDumper Dumper(OS);
-
-  OS << "\n";
-
-  Dumper.Visit(std::forward(N)...);
-
-  return OS.str();
-}
-
-const FunctionDecl *getFunctionNode(clang::ASTUnit *AST,
-const std::string ) {
-  auto Result = ast_matchers::match(functionDecl(hasName(Name)).bind("fn"),
-AST->getASTContext());
-  EXPECT_EQ(Result.size(), 1u);
-  return Result[0].getNodeAs("fn");
-}
-
-template  struct Verifier {
-  static void withDynNode(T Node, const std::string ) {
-EXPECT_EQ(dumpASTString(ast_type_traits::DynTypedNode::create(Node)),
-  DumpString);
-  }
-};
-
-template  struct Verifier {
-  static void withDynNode(T 

[PATCH] D61931: [Driver] Use --android-tls for Android ARM/AArch64 when lld is used

2019-05-17 Thread Stephen Hines via Phabricator via cfe-commits
srhines added a comment.

This LGTM if Ryan is happy with it. Thanks for taking care of getting a 
workaround implemented until this can be fixed.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61931



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


[PATCH] D61909: Add Clang shared library with C++ exports

2019-05-17 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

ok, it should probably be installed in that case (it is currently in 
usr/lib/llvm-9/lib/libclang_shared.so.9 )
by the way, the name of lib isn't super explicit :/


Repository:
  rC Clang

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

https://reviews.llvm.org/D61909



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


[PATCH] D61909: Add Clang shared library with C++ exports

2019-05-17 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

I would leave it out of any distribution (at least for now).


Repository:
  rC Clang

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

https://reviews.llvm.org/D61909



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


[PATCH] D61909: Add Clang shared library with C++ exports

2019-05-17 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

@beanz @tstellar 
I am wondering what to do wrt apt.llvm.org 
should it be part of libclang or create a libclang++ package
what do you think?


Repository:
  rC Clang

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

https://reviews.llvm.org/D61909



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


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

2019-05-17 Thread Jian Cai via Phabricator via cfe-commits
jcai19 updated this revision to Diff 200068.
jcai19 marked an inline comment as done.
jcai19 added a comment.

Update based on comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61967

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

Index: clang-tools-extra/test/clang-tidy/android-cloexec-pipe.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/android-cloexec-pipe.cpp
@@ -0,0 +1,27 @@
+// RUN: %check_clang_tidy %s android-cloexec-pipe %t
+
+extern "C" int pipe(int pipefd[2]);
+
+void f() {
+  int pipefd[2];
+  pipe(pipefd);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer pipe2() to pipe() because pipe2() allows O_CLOEXEC [android-cloexec-pipe]
+  // CHECK-FIXES: pipe2(pipefd, O_CLOEXEC);
+}
+
+namespace i {
+int pipe(int pipefd[2]);
+void g() {
+  int pipefd[2];
+  pipe(pipefd);
+}
+} // namespace i
+
+class C {
+public:
+  int pipe(int pipefd[2]);
+  void h() {
+int pipefd[2];
+pipe(pipefd);
+  }
+};
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
@@ -32,6 +32,7 @@
android-cloexec-inotify-init1
android-cloexec-memfd-create
android-cloexec-open
+   android-cloexec-pipe
android-cloexec-socket
android-comparison-in-temp-failure-retry
boost-use-to-string
Index: clang-tools-extra/docs/clang-tidy/checks/android-cloexec-pipe.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/android-cloexec-pipe.rst
@@ -0,0 +1,18 @@
+.. title:: clang-tidy - android-cloexec-pipe
+
+android-cloexec-pipe
+
+
+Detects usage of ``pipe()``. The usage of ``pipe()`` is not recommended, it's better to use ``pipe2()``.
+Without this flag, an opened sensitive file descriptor would remain open across
+a ``fork``+``exec`` to a lower-privileged SELinux domain.
+
+Examples:
+
+.. code-block:: c++
+
+  pipe(pipefd);
+
+  // becomes
+
+  pipe2(pipefd, O_CLOEXEC);
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -101,6 +101,11 @@
   Finds and fixes ``absl::Time`` subtraction expressions to do subtraction
   in the Time domain instead of the numeric domain.
 
+- New :doc:`android-cloexec-pipe
+  ` check.
+
+  Detects usage of ``pipe()``.
+
 - New :doc:`bugprone-unhandled-self-assignment
   ` check.
 
Index: clang-tools-extra/clang-tidy/android/CloexecPipeCheck.h
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/android/CloexecPipeCheck.h
@@ -0,0 +1,34 @@
+//===--- CloexecPipeCheck.h - clang-tidy-*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_PIPE_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_PIPE_H
+
+#include "CloexecCheck.h"
+
+namespace clang {
+namespace tidy {
+namespace android {
+
+/// pipe() is better to be replaced by pipe2().
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/android-cloexec-pipe.html
+class CloexecPipeCheck : public CloexecCheck {
+public:
+  CloexecPipeCheck(StringRef Name, ClangTidyContext *Context)
+  : CloexecCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult ) override;
+};
+
+} // namespace android
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_CLOEXEC_PIPE_H
Index: clang-tools-extra/clang-tidy/android/CloexecPipeCheck.cpp
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/android/CloexecPipeCheck.cpp
@@ -0,0 +1,37 @@
+//===--- CloexecPipeCheck.cpp - clang-tidy-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// 

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

2019-05-17 Thread Jian Cai via Phabricator via cfe-commits
jcai19 updated this revision to Diff 200066.
jcai19 added a comment.

Update based on comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62049

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

Index: clang-tools-extra/test/clang-tidy/android-cloexec-pipe2.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/android-cloexec-pipe2.cpp
@@ -0,0 +1,68 @@
+// RUN: %check_clang_tidy %s android-cloexec-pipe2 %t
+
+#define O_NONBLOCK 1
+#define __O_CLOEXEC 3
+#define O_CLOEXEC __O_CLOEXEC
+#define TEMP_FAILURE_RETRY(exp) \
+  ({\
+int _rc;\
+do {\
+  _rc = (exp);  \
+} while (_rc == -1);\
+  })
+#define NULL 0
+
+extern "C" int pipe2(int pipefd[2], int flags);
+
+void a() {
+  int pipefd[2];
+  pipe2(pipefd, O_NONBLOCK);
+  // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: 'pipe2' should use O_CLOEXEC where possible [android-cloexec-pipe2]
+  // CHECK-FIXES: pipe2(pipefd, O_NONBLOCK | O_CLOEXEC);
+  TEMP_FAILURE_RETRY(pipe2(pipefd, O_NONBLOCK));
+  // CHECK-MESSAGES: :[[@LINE-1]]:46: warning: 'pipe2'
+  // CHECK-FIXES: TEMP_FAILURE_RETRY(pipe2(pipefd, O_NONBLOCK | O_CLOEXEC));
+}
+
+void f() {
+  int pipefd[2];
+  pipe2(pipefd, 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: 'pipe2'
+  // CHECK-FIXES: pipe2(pipefd, 3 | O_CLOEXEC);
+  TEMP_FAILURE_RETRY(pipe2(pipefd, 3));
+  // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: 'pipe2'
+  // CHECK-FIXES: TEMP_FAILURE_RETRY(pipe2(pipefd, 3 | O_CLOEXEC));
+
+  int flag = O_NONBLOCK;
+  pipe2(pipefd, flag);
+  TEMP_FAILURE_RETRY(pipe2(pipefd, flag));
+}
+
+namespace i {
+int pipe2(int pipefd[2], int flags);
+
+void d() {
+  int pipefd[2];
+  pipe2(pipefd, O_NONBLOCK);
+  TEMP_FAILURE_RETRY(pipe2(pipefd, O_NONBLOCK));
+}
+
+} // namespace i
+
+void e() {
+  int pipefd[2];
+  pipe2(pipefd, O_CLOEXEC);
+  TEMP_FAILURE_RETRY(pipe2(pipefd, O_CLOEXEC));
+  pipe2(pipefd, O_NONBLOCK | O_CLOEXEC);
+  TEMP_FAILURE_RETRY(pipe2(pipefd, O_NONBLOCK | O_CLOEXEC));
+}
+
+class G {
+public:
+  int pipe2(int pipefd[2], int flags);
+  void d() {
+int pipefd[2];
+pipe2(pipefd, O_NONBLOCK);
+TEMP_FAILURE_RETRY(pipe2(pipefd, O_NONBLOCK));
+  }
+};
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
@@ -32,6 +32,7 @@
android-cloexec-inotify-init1
android-cloexec-memfd-create
android-cloexec-open
+   android-cloexec-pipe2
android-cloexec-socket
android-comparison-in-temp-failure-retry
boost-use-to-string
Index: clang-tools-extra/docs/clang-tidy/checks/android-cloexec-pipe2.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/android-cloexec-pipe2.rst
@@ -0,0 +1,19 @@
+.. title:: clang-tidy - android-cloexec-pipe2
+
+android-cloexec-pipe2
+=
+
+Checks if the required file flag ``O_CLOEXEC`` is present in the argument of
+``pipe2()``. ``pipe2()`` should include ``O_CLOEXEC`` in its type argument to
+avoid the file descriptor leakage. Without this flag, an opened sensitive file
+would remain open across a ``fork``+``exec`` to a lower-privileged SELinux domain.
+
+Examples:
+
+.. code-block:: c++
+
+  pipe2(pipefd, O_NONBLOCK);
+
+  // becomes
+
+  pipe2(pipefd, O_CLOEXEC);
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -101,6 +101,12 @@
   Finds and fixes ``absl::Time`` subtraction expressions to do subtraction
   in the Time domain instead of the numeric domain.
 
+- New :doc:`android-cloexec-pipe
+  ` check.
+
+  Checks if the required file flag ``O_CLOEXEC`` is present in the argument of
+  ``pipe2()``.
+
 - New :doc:`bugprone-unhandled-self-assignment
   ` check.
 
Index: clang-tools-extra/clang-tidy/android/CloexecPipe2Check.h
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/android/CloexecPipe2Check.h
@@ -0,0 +1,34 @@
+//===--- CloexecPipe2Check.h - clang-tidy*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See 

Re: r360998 - Fix crash if, during evaluation of __builtin_object_size, we try to load

2019-05-17 Thread Richard Smith via cfe-commits
Looks good, thanks :)

On Fri, 17 May 2019, 10:31 Nico Weber via cfe-commits, <
cfe-commits@lists.llvm.org> wrote:

> I attempted to fix this in 361054.
>
> *From: *Nico Weber 
> *Date: *Fri, May 17, 2019 at 1:16 PM
> *To: *Richard Smith
> *Cc: *cfe-commits
>
> Also on the LLVM waterfall:
>> http://lab.llvm.org:8011/builders/clang-x64-windows-msvc
>>
>> http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/6937/steps/stage%201%20check/logs/stdio
>>
>> (Same error.)
>>
>> *From: *Nico Weber 
>> *Date: *Fri, May 17, 2019 at 1:14 PM
>> *To: *Richard Smith
>> *Cc: *cfe-commits
>>
>> -- Testing: 49966 tests, 32 threads --
>>> Testing: 0 .. 10.. 20..
>>> FAIL: Clang :: SemaCXX/builtin-object-size-cxx14.cpp (14324 of 49966)
>>>  TEST 'Clang ::
>>> SemaCXX/builtin-object-size-cxx14.cpp' FAILED 
>>> Script:
>>> --
>>> : 'RUN: at line 1';
>>> c:\b\s\w\ir\k\src\third_party\llvm-bootstrap\bin\clang.exe -cc1
>>> -internal-isystem
>>> c:\b\s\w\ir\k\src\third_party\llvm-bootstrap\lib\clang\9.0.0\include
>>> -nostdsysteminc -fsyntax-only -verify -std=c++14
>>> C:\b\s\w\ir\k\src\third_party\llvm\tools\clang\test\SemaCXX\builtin-object-size-cxx14.cpp
>>> --
>>> Exit Code: 1
>>>
>>> Command Output (stdout):
>>> --
>>> $ ":" "RUN: at line 1"
>>> $ "c:\b\s\w\ir\k\src\third_party\llvm-bootstrap\bin\clang.exe" "-cc1"
>>> "-internal-isystem"
>>> "c:\b\s\w\ir\k\src\third_party\llvm-bootstrap\lib\clang\9.0.0\include"
>>> "-nostdsysteminc" "-fsyntax-only" "-verify" "-std=c++14"
>>> "C:\b\s\w\ir\k\src\third_party\llvm\tools\clang\test\SemaCXX\builtin-object-size-cxx14.cpp"
>>> # command stderr:
>>> error: 'warning' diagnostics seen but not expected:
>>>   File
>>> C:\b\s\w\ir\k\src\third_party\llvm\tools\clang\test\SemaCXX\builtin-object-size-cxx14.cpp
>>> Line 105: implicit conversion from 'unsigned long long' to 'const long'
>>> changes value from 18446744073709551615 to -1
>>> 1 error generated.
>>>
>>> error: command failed with exit status: 1
>>>
>>>
>>> https://logs.chromium.org/logs/chromium/buildbucket/cr-buildbucket.appspot.com/8913196957157807760/+/steps/package_clang/0/stdout
>>>
>>> *From: *Nico Weber 
>>> *Date: *Fri, May 17, 2019 at 1:13 PM
>>> *To: *Richard Smith
>>> *Cc: *cfe-commits
>>>
>>> The test fails on Windows:


 *From: *Richard Smith via cfe-commits 
 *Date: *Fri, May 17, 2019 at 3:58 AM
 *To: * 

 Author: rsmith
> Date: Fri May 17 01:01:34 2019
> New Revision: 360998
>
> URL: http://llvm.org/viewvc/llvm-project?rev=360998=rev
> Log:
> Fix crash if, during evaluation of __builtin_object_size, we try to
> load
> through an invalid base.
>
> Modified:
> cfe/trunk/lib/AST/ExprConstant.cpp
> cfe/trunk/test/SemaCXX/builtin-object-size-cxx14.cpp
>
> Modified: cfe/trunk/lib/AST/ExprConstant.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=360998=360997=360998=diff
>
> ==
> --- cfe/trunk/lib/AST/ExprConstant.cpp (original)
> +++ cfe/trunk/lib/AST/ExprConstant.cpp Fri May 17 01:01:34 2019
> @@ -3285,6 +3285,11 @@ static bool AreElementsOfSameArray(QualT
>  static CompleteObject findCompleteObject(EvalInfo , const Expr
> *E,
>   AccessKinds AK, const LValue
> ,
>   QualType LValType) {
> +  if (LVal.InvalidBase) {
> +Info.FFDiag(E);
> +return CompleteObject();
> +  }
> +
>if (!LVal.Base) {
>  Info.FFDiag(E, diag::note_constexpr_access_null) << AK;
>  return CompleteObject();
>
> Modified: cfe/trunk/test/SemaCXX/builtin-object-size-cxx14.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/builtin-object-size-cxx14.cpp?rev=360998=360997=360998=diff
>
> ==
> --- cfe/trunk/test/SemaCXX/builtin-object-size-cxx14.cpp (original)
> +++ cfe/trunk/test/SemaCXX/builtin-object-size-cxx14.cpp Fri May 17
> 01:01:34 2019
> @@ -97,3 +97,10 @@ void tooSmallBuf() {
>copy5CharsIntoStrict(small.buf); // expected-error{{no matching
> function for call}}
>  }
>  }
> +
> +namespace InvalidBase {
> +  // Ensure this doesn't crash.
> +  struct S { const char *name; };
> +  S invalid_base();
> +  constexpr long bos_name =
> __builtin_object_size(invalid_base().name, 1);
> +}
>
>
> ___
> 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
> 

Re: r361033 - Add a Visit overload for DynTypedNode to ASTNodeTraverser

2019-05-17 Thread Yitzhak Mandelbaum via cfe-commits
i'll see if i can repro on my build and fix if so.

On Fri, May 17, 2019 at 1:56 PM Stephen Kelly  wrote:

> Hmm, thanks for letting me know!
>
> Is that an old compiler?
>
> I'm not near a computer for the weekend.
>
> Can someone fix or revert?
>
> Thanks,
>
> Stephen.
>
> On Fri 17 May 2019, 17:11 Yitzhak Mandelbaum,  wrote:
>
>> Looks like this caused a breakage:
>> http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/18641/steps/ninja%20check%201/logs/stdio
>>
>> On Fri, May 17, 2019 at 9:52 AM Stephen Kelly via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: steveire
>>> Date: Fri May 17 06:55:28 2019
>>> New Revision: 361033
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=361033=rev
>>> Log:
>>> Add a Visit overload for DynTypedNode to ASTNodeTraverser
>>>
>>> Reviewers: aaron.ballman
>>>
>>> Subscribers: cfe-commits
>>>
>>> Tags: #clang
>>>
>>> Differential Revision: https://reviews.llvm.org/D61834
>>>
>>> Added:
>>> cfe/trunk/unittests/AST/ASTTraverserTest.cpp
>>> Modified:
>>> cfe/trunk/include/clang/AST/ASTNodeTraverser.h
>>> cfe/trunk/unittests/AST/CMakeLists.txt
>>>
>>> Modified: cfe/trunk/include/clang/AST/ASTNodeTraverser.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTNodeTraverser.h?rev=361033=361032=361033=diff
>>>
>>> ==
>>> --- cfe/trunk/include/clang/AST/ASTNodeTraverser.h (original)
>>> +++ cfe/trunk/include/clang/AST/ASTNodeTraverser.h Fri May 17 06:55:28
>>> 2019
>>> @@ -205,6 +205,24 @@ public:
>>>  });
>>>}
>>>
>>> +  void Visit(const ast_type_traits::DynTypedNode ) {
>>> +// FIXME: Improve this with a switch or a visitor pattern.
>>> +if (const auto *D = N.get())
>>> +  Visit(D);
>>> +else if (const auto *S = N.get())
>>> +  Visit(S);
>>> +else if (const auto *QT = N.get())
>>> +  Visit(*QT);
>>> +else if (const auto *T = N.get())
>>> +  Visit(T);
>>> +else if (const auto *C = N.get())
>>> +  Visit(C);
>>> +else if (const auto *C = N.get())
>>> +  Visit(C);
>>> +else if (const auto *T = N.get())
>>> +  Visit(*T);
>>> +  }
>>> +
>>>void dumpDeclContext(const DeclContext *DC) {
>>>  if (!DC)
>>>return;
>>>
>>> Added: cfe/trunk/unittests/AST/ASTTraverserTest.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/ASTTraverserTest.cpp?rev=361033=auto
>>>
>>> ==
>>> --- cfe/trunk/unittests/AST/ASTTraverserTest.cpp (added)
>>> +++ cfe/trunk/unittests/AST/ASTTraverserTest.cpp Fri May 17 06:55:28 2019
>>> @@ -0,0 +1,220 @@
>>> +//===-
>>> unittests/AST/ASTTraverserTest.h===//
>>> +//
>>> +// Part of the LLVM Project, under the Apache License v2.0 with LLVM
>>> Exceptions.
>>> +// See https://llvm.org/LICENSE.txt for license information.
>>> +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
>>> +//
>>>
>>> +//===--===//
>>> +
>>> +#include "clang/AST/ASTContext.h"
>>> +#include "clang/AST/ASTNodeTraverser.h"
>>> +#include "clang/AST/TextNodeDumper.h"
>>> +#include "clang/ASTMatchers/ASTMatchFinder.h"
>>> +#include "clang/ASTMatchers/ASTMatchers.h"
>>> +#include "clang/Tooling/Tooling.h"
>>> +#include "gmock/gmock.h"
>>> +#include "gtest/gtest.h"
>>> +
>>> +using namespace clang::tooling;
>>> +using namespace clang::ast_matchers;
>>> +
>>> +namespace clang {
>>> +
>>> +class NodeTreePrinter : public TextTreeStructure {
>>> +  llvm::raw_ostream 
>>> +
>>> +public:
>>> +  NodeTreePrinter(llvm::raw_ostream )
>>> +  : TextTreeStructure(OS, /* showColors */ false), OS(OS) {}
>>> +
>>> +  void Visit(const Decl *D) { OS << D->getDeclKindName() << "Decl"; }
>>> +
>>> +  void Visit(const Stmt *S) { OS << S->getStmtClassName(); }
>>> +
>>> +  void Visit(QualType QT) {
>>> +OS << "QualType " << QT.split().Quals.getAsString();
>>> +  }
>>> +
>>> +  void Visit(const Type *T) { OS << T->getTypeClassName() << "Type"; }
>>> +
>>> +  void Visit(const comments::Comment *C, const comments::FullComment
>>> *FC) {
>>> +OS << C->getCommentKindName();
>>> +  }
>>> +
>>> +  void Visit(const CXXCtorInitializer *Init) { OS <<
>>> "CXXCtorInitializer"; }
>>> +
>>> +  void Visit(const Attr *A) {
>>> +switch (A->getKind()) {
>>> +#define ATTR(X)
>>> \
>>> +  case attr::X:
>>> \
>>> +OS << #X;
>>> \
>>> +break;
>>> +#include "clang/Basic/AttrList.inc"
>>> +}
>>> +OS << "Attr";
>>> +  }
>>> +
>>> +  void Visit(const OMPClause *C) { OS << "OMPClause"; }
>>> +  void Visit(const TemplateArgument , SourceRange R = {},
>>> + const Decl *From = nullptr, const char *Label = nullptr) {
>>> +OS << "TemplateArgument";
>>> +  }
>>> +
>>> +  template  void Visit(T...) {}
>>> +};
>>> +
>>> +class TestASTDumper : 

Re: r361033 - Add a Visit overload for DynTypedNode to ASTNodeTraverser

2019-05-17 Thread Stephen Kelly via cfe-commits
Hmm, thanks for letting me know!

Is that an old compiler?

I'm not near a computer for the weekend.

Can someone fix or revert?

Thanks,

Stephen.

On Fri 17 May 2019, 17:11 Yitzhak Mandelbaum,  wrote:

> Looks like this caused a breakage:
> http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/18641/steps/ninja%20check%201/logs/stdio
>
> On Fri, May 17, 2019 at 9:52 AM Stephen Kelly via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: steveire
>> Date: Fri May 17 06:55:28 2019
>> New Revision: 361033
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=361033=rev
>> Log:
>> Add a Visit overload for DynTypedNode to ASTNodeTraverser
>>
>> Reviewers: aaron.ballman
>>
>> Subscribers: cfe-commits
>>
>> Tags: #clang
>>
>> Differential Revision: https://reviews.llvm.org/D61834
>>
>> Added:
>> cfe/trunk/unittests/AST/ASTTraverserTest.cpp
>> Modified:
>> cfe/trunk/include/clang/AST/ASTNodeTraverser.h
>> cfe/trunk/unittests/AST/CMakeLists.txt
>>
>> Modified: cfe/trunk/include/clang/AST/ASTNodeTraverser.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTNodeTraverser.h?rev=361033=361032=361033=diff
>>
>> ==
>> --- cfe/trunk/include/clang/AST/ASTNodeTraverser.h (original)
>> +++ cfe/trunk/include/clang/AST/ASTNodeTraverser.h Fri May 17 06:55:28
>> 2019
>> @@ -205,6 +205,24 @@ public:
>>  });
>>}
>>
>> +  void Visit(const ast_type_traits::DynTypedNode ) {
>> +// FIXME: Improve this with a switch or a visitor pattern.
>> +if (const auto *D = N.get())
>> +  Visit(D);
>> +else if (const auto *S = N.get())
>> +  Visit(S);
>> +else if (const auto *QT = N.get())
>> +  Visit(*QT);
>> +else if (const auto *T = N.get())
>> +  Visit(T);
>> +else if (const auto *C = N.get())
>> +  Visit(C);
>> +else if (const auto *C = N.get())
>> +  Visit(C);
>> +else if (const auto *T = N.get())
>> +  Visit(*T);
>> +  }
>> +
>>void dumpDeclContext(const DeclContext *DC) {
>>  if (!DC)
>>return;
>>
>> Added: cfe/trunk/unittests/AST/ASTTraverserTest.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/ASTTraverserTest.cpp?rev=361033=auto
>>
>> ==
>> --- cfe/trunk/unittests/AST/ASTTraverserTest.cpp (added)
>> +++ cfe/trunk/unittests/AST/ASTTraverserTest.cpp Fri May 17 06:55:28 2019
>> @@ -0,0 +1,220 @@
>> +//===-
>> unittests/AST/ASTTraverserTest.h===//
>> +//
>> +// Part of the LLVM Project, under the Apache License v2.0 with LLVM
>> Exceptions.
>> +// See https://llvm.org/LICENSE.txt for license information.
>> +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
>> +//
>>
>> +//===--===//
>> +
>> +#include "clang/AST/ASTContext.h"
>> +#include "clang/AST/ASTNodeTraverser.h"
>> +#include "clang/AST/TextNodeDumper.h"
>> +#include "clang/ASTMatchers/ASTMatchFinder.h"
>> +#include "clang/ASTMatchers/ASTMatchers.h"
>> +#include "clang/Tooling/Tooling.h"
>> +#include "gmock/gmock.h"
>> +#include "gtest/gtest.h"
>> +
>> +using namespace clang::tooling;
>> +using namespace clang::ast_matchers;
>> +
>> +namespace clang {
>> +
>> +class NodeTreePrinter : public TextTreeStructure {
>> +  llvm::raw_ostream 
>> +
>> +public:
>> +  NodeTreePrinter(llvm::raw_ostream )
>> +  : TextTreeStructure(OS, /* showColors */ false), OS(OS) {}
>> +
>> +  void Visit(const Decl *D) { OS << D->getDeclKindName() << "Decl"; }
>> +
>> +  void Visit(const Stmt *S) { OS << S->getStmtClassName(); }
>> +
>> +  void Visit(QualType QT) {
>> +OS << "QualType " << QT.split().Quals.getAsString();
>> +  }
>> +
>> +  void Visit(const Type *T) { OS << T->getTypeClassName() << "Type"; }
>> +
>> +  void Visit(const comments::Comment *C, const comments::FullComment
>> *FC) {
>> +OS << C->getCommentKindName();
>> +  }
>> +
>> +  void Visit(const CXXCtorInitializer *Init) { OS <<
>> "CXXCtorInitializer"; }
>> +
>> +  void Visit(const Attr *A) {
>> +switch (A->getKind()) {
>> +#define ATTR(X)
>>   \
>> +  case attr::X:
>>   \
>> +OS << #X;
>>   \
>> +break;
>> +#include "clang/Basic/AttrList.inc"
>> +}
>> +OS << "Attr";
>> +  }
>> +
>> +  void Visit(const OMPClause *C) { OS << "OMPClause"; }
>> +  void Visit(const TemplateArgument , SourceRange R = {},
>> + const Decl *From = nullptr, const char *Label = nullptr) {
>> +OS << "TemplateArgument";
>> +  }
>> +
>> +  template  void Visit(T...) {}
>> +};
>> +
>> +class TestASTDumper : public ASTNodeTraverser> NodeTreePrinter> {
>> +
>> +  NodeTreePrinter MyNodeRecorder;
>> +
>> +public:
>> +  TestASTDumper(llvm::raw_ostream ) : MyNodeRecorder(OS) {}
>> +  NodeTreePrinter () { return MyNodeRecorder; }
>> +};
>> +
>> +template  std::string dumpASTString(NodeType 

Re: r360998 - Fix crash if, during evaluation of __builtin_object_size, we try to load

2019-05-17 Thread Nico Weber via cfe-commits
I attempted to fix this in 361054.

*From: *Nico Weber 
*Date: *Fri, May 17, 2019 at 1:16 PM
*To: *Richard Smith
*Cc: *cfe-commits

Also on the LLVM waterfall:
> http://lab.llvm.org:8011/builders/clang-x64-windows-msvc
>
> http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/6937/steps/stage%201%20check/logs/stdio
>
> (Same error.)
>
> *From: *Nico Weber 
> *Date: *Fri, May 17, 2019 at 1:14 PM
> *To: *Richard Smith
> *Cc: *cfe-commits
>
> -- Testing: 49966 tests, 32 threads --
>> Testing: 0 .. 10.. 20..
>> FAIL: Clang :: SemaCXX/builtin-object-size-cxx14.cpp (14324 of 49966)
>>  TEST 'Clang ::
>> SemaCXX/builtin-object-size-cxx14.cpp' FAILED 
>> Script:
>> --
>> : 'RUN: at line 1';
>> c:\b\s\w\ir\k\src\third_party\llvm-bootstrap\bin\clang.exe -cc1
>> -internal-isystem
>> c:\b\s\w\ir\k\src\third_party\llvm-bootstrap\lib\clang\9.0.0\include
>> -nostdsysteminc -fsyntax-only -verify -std=c++14
>> C:\b\s\w\ir\k\src\third_party\llvm\tools\clang\test\SemaCXX\builtin-object-size-cxx14.cpp
>> --
>> Exit Code: 1
>>
>> Command Output (stdout):
>> --
>> $ ":" "RUN: at line 1"
>> $ "c:\b\s\w\ir\k\src\third_party\llvm-bootstrap\bin\clang.exe" "-cc1"
>> "-internal-isystem"
>> "c:\b\s\w\ir\k\src\third_party\llvm-bootstrap\lib\clang\9.0.0\include"
>> "-nostdsysteminc" "-fsyntax-only" "-verify" "-std=c++14"
>> "C:\b\s\w\ir\k\src\third_party\llvm\tools\clang\test\SemaCXX\builtin-object-size-cxx14.cpp"
>> # command stderr:
>> error: 'warning' diagnostics seen but not expected:
>>   File
>> C:\b\s\w\ir\k\src\third_party\llvm\tools\clang\test\SemaCXX\builtin-object-size-cxx14.cpp
>> Line 105: implicit conversion from 'unsigned long long' to 'const long'
>> changes value from 18446744073709551615 to -1
>> 1 error generated.
>>
>> error: command failed with exit status: 1
>>
>>
>> https://logs.chromium.org/logs/chromium/buildbucket/cr-buildbucket.appspot.com/8913196957157807760/+/steps/package_clang/0/stdout
>>
>> *From: *Nico Weber 
>> *Date: *Fri, May 17, 2019 at 1:13 PM
>> *To: *Richard Smith
>> *Cc: *cfe-commits
>>
>> The test fails on Windows:
>>>
>>>
>>> *From: *Richard Smith via cfe-commits 
>>> *Date: *Fri, May 17, 2019 at 3:58 AM
>>> *To: * 
>>>
>>> Author: rsmith
 Date: Fri May 17 01:01:34 2019
 New Revision: 360998

 URL: http://llvm.org/viewvc/llvm-project?rev=360998=rev
 Log:
 Fix crash if, during evaluation of __builtin_object_size, we try to load
 through an invalid base.

 Modified:
 cfe/trunk/lib/AST/ExprConstant.cpp
 cfe/trunk/test/SemaCXX/builtin-object-size-cxx14.cpp

 Modified: cfe/trunk/lib/AST/ExprConstant.cpp
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=360998=360997=360998=diff

 ==
 --- cfe/trunk/lib/AST/ExprConstant.cpp (original)
 +++ cfe/trunk/lib/AST/ExprConstant.cpp Fri May 17 01:01:34 2019
 @@ -3285,6 +3285,11 @@ static bool AreElementsOfSameArray(QualT
  static CompleteObject findCompleteObject(EvalInfo , const Expr *E,
   AccessKinds AK, const LValue
 ,
   QualType LValType) {
 +  if (LVal.InvalidBase) {
 +Info.FFDiag(E);
 +return CompleteObject();
 +  }
 +
if (!LVal.Base) {
  Info.FFDiag(E, diag::note_constexpr_access_null) << AK;
  return CompleteObject();

 Modified: cfe/trunk/test/SemaCXX/builtin-object-size-cxx14.cpp
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/builtin-object-size-cxx14.cpp?rev=360998=360997=360998=diff

 ==
 --- cfe/trunk/test/SemaCXX/builtin-object-size-cxx14.cpp (original)
 +++ cfe/trunk/test/SemaCXX/builtin-object-size-cxx14.cpp Fri May 17
 01:01:34 2019
 @@ -97,3 +97,10 @@ void tooSmallBuf() {
copy5CharsIntoStrict(small.buf); // expected-error{{no matching
 function for call}}
  }
  }
 +
 +namespace InvalidBase {
 +  // Ensure this doesn't crash.
 +  struct S { const char *name; };
 +  S invalid_base();
 +  constexpr long bos_name = __builtin_object_size(invalid_base().name,
 1);
 +}


 ___
 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


r361054 - Attempt to fix test on Windows after r360998

2019-05-17 Thread Nico Weber via cfe-commits
Author: nico
Date: Fri May 17 10:33:54 2019
New Revision: 361054

URL: http://llvm.org/viewvc/llvm-project?rev=361054=rev
Log:
Attempt to fix test on Windows after r360998

Modified:
cfe/trunk/test/SemaCXX/builtin-object-size-cxx14.cpp

Modified: cfe/trunk/test/SemaCXX/builtin-object-size-cxx14.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/builtin-object-size-cxx14.cpp?rev=361054=361053=361054=diff
==
--- cfe/trunk/test/SemaCXX/builtin-object-size-cxx14.cpp (original)
+++ cfe/trunk/test/SemaCXX/builtin-object-size-cxx14.cpp Fri May 17 10:33:54 
2019
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s
 
+typedef __SIZE_TYPE__ size_t;
+
 namespace basic {
 // Ensuring that __bos can be used in constexpr functions without anything
 // sketchy going on...
@@ -102,5 +104,5 @@ namespace InvalidBase {
   // Ensure this doesn't crash.
   struct S { const char *name; };
   S invalid_base();
-  constexpr long bos_name = __builtin_object_size(invalid_base().name, 1);
+  constexpr size_t bos_name = __builtin_object_size(invalid_base().name, 1);
 }


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


Re: r360998 - Fix crash if, during evaluation of __builtin_object_size, we try to load

2019-05-17 Thread Nico Weber via cfe-commits
Also on the LLVM waterfall:
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/6937/steps/stage%201%20check/logs/stdio

(Same error.)

*From: *Nico Weber 
*Date: *Fri, May 17, 2019 at 1:14 PM
*To: *Richard Smith
*Cc: *cfe-commits

-- Testing: 49966 tests, 32 threads --
> Testing: 0 .. 10.. 20..
> FAIL: Clang :: SemaCXX/builtin-object-size-cxx14.cpp (14324 of 49966)
>  TEST 'Clang :: SemaCXX/builtin-object-size-cxx14.cpp'
> FAILED 
> Script:
> --
> : 'RUN: at line 1';
> c:\b\s\w\ir\k\src\third_party\llvm-bootstrap\bin\clang.exe -cc1
> -internal-isystem
> c:\b\s\w\ir\k\src\third_party\llvm-bootstrap\lib\clang\9.0.0\include
> -nostdsysteminc -fsyntax-only -verify -std=c++14
> C:\b\s\w\ir\k\src\third_party\llvm\tools\clang\test\SemaCXX\builtin-object-size-cxx14.cpp
> --
> Exit Code: 1
>
> Command Output (stdout):
> --
> $ ":" "RUN: at line 1"
> $ "c:\b\s\w\ir\k\src\third_party\llvm-bootstrap\bin\clang.exe" "-cc1"
> "-internal-isystem"
> "c:\b\s\w\ir\k\src\third_party\llvm-bootstrap\lib\clang\9.0.0\include"
> "-nostdsysteminc" "-fsyntax-only" "-verify" "-std=c++14"
> "C:\b\s\w\ir\k\src\third_party\llvm\tools\clang\test\SemaCXX\builtin-object-size-cxx14.cpp"
> # command stderr:
> error: 'warning' diagnostics seen but not expected:
>   File
> C:\b\s\w\ir\k\src\third_party\llvm\tools\clang\test\SemaCXX\builtin-object-size-cxx14.cpp
> Line 105: implicit conversion from 'unsigned long long' to 'const long'
> changes value from 18446744073709551615 to -1
> 1 error generated.
>
> error: command failed with exit status: 1
>
>
> https://logs.chromium.org/logs/chromium/buildbucket/cr-buildbucket.appspot.com/8913196957157807760/+/steps/package_clang/0/stdout
>
> *From: *Nico Weber 
> *Date: *Fri, May 17, 2019 at 1:13 PM
> *To: *Richard Smith
> *Cc: *cfe-commits
>
> The test fails on Windows:
>>
>>
>> *From: *Richard Smith via cfe-commits 
>> *Date: *Fri, May 17, 2019 at 3:58 AM
>> *To: * 
>>
>> Author: rsmith
>>> Date: Fri May 17 01:01:34 2019
>>> New Revision: 360998
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=360998=rev
>>> Log:
>>> Fix crash if, during evaluation of __builtin_object_size, we try to load
>>> through an invalid base.
>>>
>>> Modified:
>>> cfe/trunk/lib/AST/ExprConstant.cpp
>>> cfe/trunk/test/SemaCXX/builtin-object-size-cxx14.cpp
>>>
>>> Modified: cfe/trunk/lib/AST/ExprConstant.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=360998=360997=360998=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/AST/ExprConstant.cpp (original)
>>> +++ cfe/trunk/lib/AST/ExprConstant.cpp Fri May 17 01:01:34 2019
>>> @@ -3285,6 +3285,11 @@ static bool AreElementsOfSameArray(QualT
>>>  static CompleteObject findCompleteObject(EvalInfo , const Expr *E,
>>>   AccessKinds AK, const LValue
>>> ,
>>>   QualType LValType) {
>>> +  if (LVal.InvalidBase) {
>>> +Info.FFDiag(E);
>>> +return CompleteObject();
>>> +  }
>>> +
>>>if (!LVal.Base) {
>>>  Info.FFDiag(E, diag::note_constexpr_access_null) << AK;
>>>  return CompleteObject();
>>>
>>> Modified: cfe/trunk/test/SemaCXX/builtin-object-size-cxx14.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/builtin-object-size-cxx14.cpp?rev=360998=360997=360998=diff
>>>
>>> ==
>>> --- cfe/trunk/test/SemaCXX/builtin-object-size-cxx14.cpp (original)
>>> +++ cfe/trunk/test/SemaCXX/builtin-object-size-cxx14.cpp Fri May 17
>>> 01:01:34 2019
>>> @@ -97,3 +97,10 @@ void tooSmallBuf() {
>>>copy5CharsIntoStrict(small.buf); // expected-error{{no matching
>>> function for call}}
>>>  }
>>>  }
>>> +
>>> +namespace InvalidBase {
>>> +  // Ensure this doesn't crash.
>>> +  struct S { const char *name; };
>>> +  S invalid_base();
>>> +  constexpr long bos_name = __builtin_object_size(invalid_base().name,
>>> 1);
>>> +}
>>>
>>>
>>> ___
>>> 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


r361050 - Added an assertion to constant evaluation enty points that prohibits dependent expressions

2019-05-17 Thread Dmitri Gribenko via cfe-commits
Author: gribozavr
Date: Fri May 17 10:16:53 2019
New Revision: 361050

URL: http://llvm.org/viewvc/llvm-project?rev=361050=rev
Log:
Added an assertion to constant evaluation enty points that prohibits dependent 
expressions

Summary:
Constant evaluator does not work on value-dependent or type-dependent
expressions.

Also fixed bugs uncovered by these assertions.

Subscribers: cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=361050=361049=361050=diff
==
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Fri May 17 10:16:53 2019
@@ -2974,6 +2974,9 @@ bool Expr::hasAnyTypeDependentArguments(
 
 bool Expr::isConstantInitializer(ASTContext , bool IsForRef,
  const Expr **Culprit) const {
+  assert(!isValueDependent() &&
+ "Expression evaluator can't be called on a dependent expression.");
+
   // This function is attempting whether an expression is an initializer
   // which can be evaluated at compile-time. It very closely parallels
   // ConstExprEmitter in CGExprConstant.cpp; if they don't match, it

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=361050=361049=361050=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Fri May 17 10:16:53 2019
@@ -11642,6 +11642,8 @@ static bool EvaluateAsFixedPoint(const E
 /// will be applied to the result.
 bool Expr::EvaluateAsRValue(EvalResult , const ASTContext ,
 bool InConstantContext) const {
+  assert(!isValueDependent() &&
+ "Expression evaluator can't be called on a dependent expression.");
   EvalInfo Info(Ctx, Result, EvalInfo::EM_IgnoreSideEffects);
   Info.InConstantContext = InConstantContext;
   return ::EvaluateAsRValue(this, Result, Ctx, Info);
@@ -11649,6 +11651,8 @@ bool Expr::EvaluateAsRValue(EvalResult &
 
 bool Expr::EvaluateAsBooleanCondition(bool ,
   const ASTContext ) const {
+  assert(!isValueDependent() &&
+ "Expression evaluator can't be called on a dependent expression.");
   EvalResult Scratch;
   return EvaluateAsRValue(Scratch, Ctx) &&
  HandleConversionToBool(Scratch.Val, Result);
@@ -11656,18 +11660,25 @@ bool Expr::EvaluateAsBooleanCondition(bo
 
 bool Expr::EvaluateAsInt(EvalResult , const ASTContext ,
  SideEffectsKind AllowSideEffects) const {
+  assert(!isValueDependent() &&
+ "Expression evaluator can't be called on a dependent expression.");
   EvalInfo Info(Ctx, Result, EvalInfo::EM_IgnoreSideEffects);
   return ::EvaluateAsInt(this, Result, Ctx, AllowSideEffects, Info);
 }
 
 bool Expr::EvaluateAsFixedPoint(EvalResult , const ASTContext ,
 SideEffectsKind AllowSideEffects) const {
+  assert(!isValueDependent() &&
+ "Expression evaluator can't be called on a dependent expression.");
   EvalInfo Info(Ctx, Result, EvalInfo::EM_IgnoreSideEffects);
   return ::EvaluateAsFixedPoint(this, Result, Ctx, AllowSideEffects, Info);
 }
 
 bool Expr::EvaluateAsFloat(APFloat , const ASTContext ,
SideEffectsKind AllowSideEffects) const {
+  assert(!isValueDependent() &&
+ "Expression evaluator can't be called on a dependent expression.");
+
   if (!getType()->isRealFloatingType())
 return false;
 
@@ -11681,6 +11692,9 @@ bool Expr::EvaluateAsFloat(APFloat 
 }
 
 bool Expr::EvaluateAsLValue(EvalResult , const ASTContext ) const {
+  assert(!isValueDependent() &&
+ "Expression evaluator can't be called on a dependent expression.");
+
   EvalInfo Info(Ctx, Result, EvalInfo::EM_ConstantFold);
 
   LValue LV;
@@ -11696,6 +11710,9 @@ bool Expr::EvaluateAsLValue(EvalResult &
 
 bool Expr::EvaluateAsConstantExpr(EvalResult , ConstExprUsage Usage,
   const ASTContext ) const {
+  assert(!isValueDependent() &&
+ "Expression evaluator can't be called on a dependent expression.");
+
   EvalInfo::EvaluationMode EM = EvalInfo::EM_ConstantExpression;
   EvalInfo Info(Ctx, Result, EM);
   Info.InConstantContext = true;
@@ -11710,6 +11727,9 @@ bool Expr::EvaluateAsConstantExpr(EvalRe
 bool Expr::EvaluateAsInitializer(APValue , const ASTContext ,
  const VarDecl *VD,
 SmallVectorImpl ) const 
{
+  assert(!isValueDependent() &&
+ "Expression evaluator can't be called on a dependent expression.");
+
   // FIXME: Evaluating 

Re: r360998 - Fix crash if, during evaluation of __builtin_object_size, we try to load

2019-05-17 Thread Nico Weber via cfe-commits
-- Testing: 49966 tests, 32 threads --
Testing: 0 .. 10.. 20..
FAIL: Clang :: SemaCXX/builtin-object-size-cxx14.cpp (14324 of 49966)
 TEST 'Clang :: SemaCXX/builtin-object-size-cxx14.cpp'
FAILED 
Script:
--
: 'RUN: at line 1';
c:\b\s\w\ir\k\src\third_party\llvm-bootstrap\bin\clang.exe -cc1
-internal-isystem
c:\b\s\w\ir\k\src\third_party\llvm-bootstrap\lib\clang\9.0.0\include
-nostdsysteminc -fsyntax-only -verify -std=c++14
C:\b\s\w\ir\k\src\third_party\llvm\tools\clang\test\SemaCXX\builtin-object-size-cxx14.cpp
--
Exit Code: 1

Command Output (stdout):
--
$ ":" "RUN: at line 1"
$ "c:\b\s\w\ir\k\src\third_party\llvm-bootstrap\bin\clang.exe" "-cc1"
"-internal-isystem"
"c:\b\s\w\ir\k\src\third_party\llvm-bootstrap\lib\clang\9.0.0\include"
"-nostdsysteminc" "-fsyntax-only" "-verify" "-std=c++14"
"C:\b\s\w\ir\k\src\third_party\llvm\tools\clang\test\SemaCXX\builtin-object-size-cxx14.cpp"
# command stderr:
error: 'warning' diagnostics seen but not expected:
  File
C:\b\s\w\ir\k\src\third_party\llvm\tools\clang\test\SemaCXX\builtin-object-size-cxx14.cpp
Line 105: implicit conversion from 'unsigned long long' to 'const long'
changes value from 18446744073709551615 to -1
1 error generated.

error: command failed with exit status: 1

https://logs.chromium.org/logs/chromium/buildbucket/cr-buildbucket.appspot.com/8913196957157807760/+/steps/package_clang/0/stdout

*From: *Nico Weber 
*Date: *Fri, May 17, 2019 at 1:13 PM
*To: *Richard Smith
*Cc: *cfe-commits

The test fails on Windows:
>
>
> *From: *Richard Smith via cfe-commits 
> *Date: *Fri, May 17, 2019 at 3:58 AM
> *To: * 
>
> Author: rsmith
>> Date: Fri May 17 01:01:34 2019
>> New Revision: 360998
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=360998=rev
>> Log:
>> Fix crash if, during evaluation of __builtin_object_size, we try to load
>> through an invalid base.
>>
>> Modified:
>> cfe/trunk/lib/AST/ExprConstant.cpp
>> cfe/trunk/test/SemaCXX/builtin-object-size-cxx14.cpp
>>
>> Modified: cfe/trunk/lib/AST/ExprConstant.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=360998=360997=360998=diff
>>
>> ==
>> --- cfe/trunk/lib/AST/ExprConstant.cpp (original)
>> +++ cfe/trunk/lib/AST/ExprConstant.cpp Fri May 17 01:01:34 2019
>> @@ -3285,6 +3285,11 @@ static bool AreElementsOfSameArray(QualT
>>  static CompleteObject findCompleteObject(EvalInfo , const Expr *E,
>>   AccessKinds AK, const LValue
>> ,
>>   QualType LValType) {
>> +  if (LVal.InvalidBase) {
>> +Info.FFDiag(E);
>> +return CompleteObject();
>> +  }
>> +
>>if (!LVal.Base) {
>>  Info.FFDiag(E, diag::note_constexpr_access_null) << AK;
>>  return CompleteObject();
>>
>> Modified: cfe/trunk/test/SemaCXX/builtin-object-size-cxx14.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/builtin-object-size-cxx14.cpp?rev=360998=360997=360998=diff
>>
>> ==
>> --- cfe/trunk/test/SemaCXX/builtin-object-size-cxx14.cpp (original)
>> +++ cfe/trunk/test/SemaCXX/builtin-object-size-cxx14.cpp Fri May 17
>> 01:01:34 2019
>> @@ -97,3 +97,10 @@ void tooSmallBuf() {
>>copy5CharsIntoStrict(small.buf); // expected-error{{no matching
>> function for call}}
>>  }
>>  }
>> +
>> +namespace InvalidBase {
>> +  // Ensure this doesn't crash.
>> +  struct S { const char *name; };
>> +  S invalid_base();
>> +  constexpr long bos_name = __builtin_object_size(invalid_base().name,
>> 1);
>> +}
>>
>>
>> ___
>> 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


Re: r360998 - Fix crash if, during evaluation of __builtin_object_size, we try to load

2019-05-17 Thread Nico Weber via cfe-commits
The test fails on Windows:


*From: *Richard Smith via cfe-commits 
*Date: *Fri, May 17, 2019 at 3:58 AM
*To: * 

Author: rsmith
> Date: Fri May 17 01:01:34 2019
> New Revision: 360998
>
> URL: http://llvm.org/viewvc/llvm-project?rev=360998=rev
> Log:
> Fix crash if, during evaluation of __builtin_object_size, we try to load
> through an invalid base.
>
> Modified:
> cfe/trunk/lib/AST/ExprConstant.cpp
> cfe/trunk/test/SemaCXX/builtin-object-size-cxx14.cpp
>
> Modified: cfe/trunk/lib/AST/ExprConstant.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=360998=360997=360998=diff
>
> ==
> --- cfe/trunk/lib/AST/ExprConstant.cpp (original)
> +++ cfe/trunk/lib/AST/ExprConstant.cpp Fri May 17 01:01:34 2019
> @@ -3285,6 +3285,11 @@ static bool AreElementsOfSameArray(QualT
>  static CompleteObject findCompleteObject(EvalInfo , const Expr *E,
>   AccessKinds AK, const LValue
> ,
>   QualType LValType) {
> +  if (LVal.InvalidBase) {
> +Info.FFDiag(E);
> +return CompleteObject();
> +  }
> +
>if (!LVal.Base) {
>  Info.FFDiag(E, diag::note_constexpr_access_null) << AK;
>  return CompleteObject();
>
> Modified: cfe/trunk/test/SemaCXX/builtin-object-size-cxx14.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/builtin-object-size-cxx14.cpp?rev=360998=360997=360998=diff
>
> ==
> --- cfe/trunk/test/SemaCXX/builtin-object-size-cxx14.cpp (original)
> +++ cfe/trunk/test/SemaCXX/builtin-object-size-cxx14.cpp Fri May 17
> 01:01:34 2019
> @@ -97,3 +97,10 @@ void tooSmallBuf() {
>copy5CharsIntoStrict(small.buf); // expected-error{{no matching
> function for call}}
>  }
>  }
> +
> +namespace InvalidBase {
> +  // Ensure this doesn't crash.
> +  struct S { const char *name; };
> +  S invalid_base();
> +  constexpr long bos_name = __builtin_object_size(invalid_base().name, 1);
> +}
>
>
> ___
> 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] D61522: Added an assertion to constant evaluation enty points that prohibits dependent expressions

2019-05-17 Thread Dmitri Gribenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL361050: Added an assertion to constant evaluation enty 
points that prohibits dependent… (authored by gribozavr, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D61522?vs=198603=200062#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D61522

Files:
  cfe/trunk/lib/AST/Expr.cpp
  cfe/trunk/lib/AST/ExprConstant.cpp
  cfe/trunk/lib/Sema/SemaOpenMP.cpp
  cfe/trunk/lib/Sema/SemaOverload.cpp

Index: cfe/trunk/lib/AST/Expr.cpp
===
--- cfe/trunk/lib/AST/Expr.cpp
+++ cfe/trunk/lib/AST/Expr.cpp
@@ -2974,6 +2974,9 @@
 
 bool Expr::isConstantInitializer(ASTContext , bool IsForRef,
  const Expr **Culprit) const {
+  assert(!isValueDependent() &&
+ "Expression evaluator can't be called on a dependent expression.");
+
   // This function is attempting whether an expression is an initializer
   // which can be evaluated at compile-time. It very closely parallels
   // ConstExprEmitter in CGExprConstant.cpp; if they don't match, it
Index: cfe/trunk/lib/AST/ExprConstant.cpp
===
--- cfe/trunk/lib/AST/ExprConstant.cpp
+++ cfe/trunk/lib/AST/ExprConstant.cpp
@@ -11642,6 +11642,8 @@
 /// will be applied to the result.
 bool Expr::EvaluateAsRValue(EvalResult , const ASTContext ,
 bool InConstantContext) const {
+  assert(!isValueDependent() &&
+ "Expression evaluator can't be called on a dependent expression.");
   EvalInfo Info(Ctx, Result, EvalInfo::EM_IgnoreSideEffects);
   Info.InConstantContext = InConstantContext;
   return ::EvaluateAsRValue(this, Result, Ctx, Info);
@@ -11649,6 +11651,8 @@
 
 bool Expr::EvaluateAsBooleanCondition(bool ,
   const ASTContext ) const {
+  assert(!isValueDependent() &&
+ "Expression evaluator can't be called on a dependent expression.");
   EvalResult Scratch;
   return EvaluateAsRValue(Scratch, Ctx) &&
  HandleConversionToBool(Scratch.Val, Result);
@@ -11656,18 +11660,25 @@
 
 bool Expr::EvaluateAsInt(EvalResult , const ASTContext ,
  SideEffectsKind AllowSideEffects) const {
+  assert(!isValueDependent() &&
+ "Expression evaluator can't be called on a dependent expression.");
   EvalInfo Info(Ctx, Result, EvalInfo::EM_IgnoreSideEffects);
   return ::EvaluateAsInt(this, Result, Ctx, AllowSideEffects, Info);
 }
 
 bool Expr::EvaluateAsFixedPoint(EvalResult , const ASTContext ,
 SideEffectsKind AllowSideEffects) const {
+  assert(!isValueDependent() &&
+ "Expression evaluator can't be called on a dependent expression.");
   EvalInfo Info(Ctx, Result, EvalInfo::EM_IgnoreSideEffects);
   return ::EvaluateAsFixedPoint(this, Result, Ctx, AllowSideEffects, Info);
 }
 
 bool Expr::EvaluateAsFloat(APFloat , const ASTContext ,
SideEffectsKind AllowSideEffects) const {
+  assert(!isValueDependent() &&
+ "Expression evaluator can't be called on a dependent expression.");
+
   if (!getType()->isRealFloatingType())
 return false;
 
@@ -11681,6 +11692,9 @@
 }
 
 bool Expr::EvaluateAsLValue(EvalResult , const ASTContext ) const {
+  assert(!isValueDependent() &&
+ "Expression evaluator can't be called on a dependent expression.");
+
   EvalInfo Info(Ctx, Result, EvalInfo::EM_ConstantFold);
 
   LValue LV;
@@ -11696,6 +11710,9 @@
 
 bool Expr::EvaluateAsConstantExpr(EvalResult , ConstExprUsage Usage,
   const ASTContext ) const {
+  assert(!isValueDependent() &&
+ "Expression evaluator can't be called on a dependent expression.");
+
   EvalInfo::EvaluationMode EM = EvalInfo::EM_ConstantExpression;
   EvalInfo Info(Ctx, Result, EM);
   Info.InConstantContext = true;
@@ -11710,6 +11727,9 @@
 bool Expr::EvaluateAsInitializer(APValue , const ASTContext ,
  const VarDecl *VD,
 SmallVectorImpl ) const {
+  assert(!isValueDependent() &&
+ "Expression evaluator can't be called on a dependent expression.");
+
   // FIXME: Evaluating initializers for large array and record types can cause
   // performance problems. Only do so in C++11 for now.
   if (isRValue() && (getType()->isArrayType() || getType()->isRecordType()) &&
@@ -11752,6 +11772,9 @@
 /// isEvaluatable - Call EvaluateAsRValue to see if this expression can be
 /// constant folded, but discard the result.
 bool Expr::isEvaluatable(const ASTContext , SideEffectsKind SEK) const {
+  assert(!isValueDependent() &&
+ "Expression evaluator can't be called on a dependent expression.");
+
   EvalResult Result;
   return 

[PATCH] D59887: [Syntax] Introduce TokenBuffer, start clangToolingSyntax library

2019-05-17 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang/include/clang/Tooling/Syntax/Tokens.h:115
+  /// expansion.
+  llvm::Optional range(const SourceManager ) const;
+

ilya-biryukov wrote:
> sammccall wrote:
> > I think this might need a more explicit name. It's reasonably obvious that 
> > this needs to be optional for some cases (token pasting), but it's not 
> > obvious at callsites that (or why) we don't use the spelling location for 
> > macro-expanded tokens.
> > 
> > One option would be just do that and add an expandedFromMacro() helper so 
> > the no-macros version is easy to express too.
> > If we can't do that, maybe `directlySpelledRange` or something?
> As mentioned in the offline conversation, the idea is that mapping from a 
> token inside a macro expansion to a spelled token should be handled by 
> `TokenBuffer` and these two functions is really just a convenience helper to 
> get to a range *after* the mapping.
> 
> This change has been boiling for some time and I think the other bits of it 
> seem to be non-controversial and agreed upon.
> Would it be ok if we land it with this function using a more concrete name 
> (`directlySpelledRange` or something else) or move it into a separate change?
> 
> There's a follow-up change that adds an 'expand macro' action to clangd, 
> which both has a use-site for these method and provides a functional feature 
> based on `TokenBuffer`. Iterating on the design with (even a single) use-case 
> should be simpler.
If we do want to reflect expanded/spelled as types, this will rapidly get 
harder to change. But we do need to make progress here.

If passing spelled tokens is the intended/well-understood use, let's just 
assert on that and not return Optional. Then I'm less worried about the name: 
misuse will be reliably punished.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59887



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


[PATCH] D58035: [clang/DIVar] Emit flag for params that have unchanged values

2019-05-17 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added inline comments.



Comment at: lib/CodeGen/CGDebugInfo.cpp:4537
+  CGM.getLangOpts().Optimize) {
+for (auto  : DeclCache) {
+  auto *D = SP.first;

djtodoro wrote:
> aprantl wrote:
> > djtodoro wrote:
> > > aprantl wrote:
> > > > Just looking at the type declarations in CGDebugInfo.h: Why not iterate 
> > > > over the `SPCache`  directly? Shouldn't that contain all Function 
> > > > declarations only?
> > > I tried it, but `SPCache` is empty at this point.
> > Where is it emptied? Just grepping through CGDebugInfo did not make this 
> > obvious to me.
> The `SPCache` actually gets filled only in the case of `CXXMemberFunction`.
> In the other cases of `SP` production there is only filling of `DeclCache`.
> Should we use it like this or ?
If the number of entries in the DeclCache is much larger than the size of 
SPCache, we should keep them separate to speed up this loop. Otherwise we 
should join them to conserve memory.


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

https://reviews.llvm.org/D58035



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


[PATCH] D61774: [LibTooling] Add RangeSelector library for defining source ranges based on bound AST nodes.

2019-05-17 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel marked 7 inline comments as done.
ymandel added inline comments.



Comment at: clang/include/clang/Tooling/Refactoring/RangeSelector.h:29
+
+namespace range_selector {
+inline RangeSelector charRange(CharSourceRange R) {

ilya-biryukov wrote:
> ymandel wrote:
> > ilya-biryukov wrote:
> > > Maybe try putting it into the tooling namespace directly?
> > > Or are there immediate and unfortunate conflicts with existing names?
> > > 
> > > 
> > No conflicts. Was just being cautious.
> I can see why a separate namespace would make sense, but since the `tooling` 
> namespace  is not densely populated I hope we can get away with putting 
> things here directly and saving some typing on the use-sites.
> 
> Hope that does not backfire in the future, though.
SGTM. 



Comment at: clang/unittests/Tooling/RangeSelectorTest.cpp:143
+  // Node-id specific version:
+  test(Matcher, range(Arg0, Arg1), Code, "3, 7");
+  // General version:

ilya-biryukov wrote:
> Consider restructuring the code to place assertions into the test function 
> itself.
> This wildly improves locations reported in case of test failures and makes 
> tests easier to read.
> 
> I.e. having something like
> ```
> auto AST = buildASTAndMatch(Code, Matcher);
> EXPECT_EQ(applySelector(range(Arg0, Arg1), AST),  "3, 7");
> ```
> is arguably both easier to read and produces better location information on 
> failures than a function that runs the test.
> Even though it's a bit more code.
> 
> 
> Note that it's a bit more complicated if you need to deal with `Expected<>` 
> return types, but still possible:
> ```
> EXPECT_THAT_EXPECTED(applySelector(range(Arg0, Arg1), AST),  HasValue("3, 
> 7"));
> EXPECT_THAT_EXPECTED(applySelector(range(Arg1, Arg0), AST),  Failed());
> ```
Thanks for the suggestion. Thoroughly reworked the tests along these lines. I 
think the result is much clearer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61774



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


[PATCH] D61774: [LibTooling] Add RangeSelector library for defining source ranges based on bound AST nodes.

2019-05-17 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 200061.
ymandel marked 4 inline comments as done.
ymandel added a comment.

Restructured tests to simplify.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61774

Files:
  clang/include/clang/Tooling/Refactoring/RangeSelector.h
  clang/lib/Tooling/Refactoring/CMakeLists.txt
  clang/lib/Tooling/Refactoring/RangeSelector.cpp
  clang/unittests/Tooling/CMakeLists.txt
  clang/unittests/Tooling/RangeSelectorTest.cpp

Index: clang/unittests/Tooling/RangeSelectorTest.cpp
===
--- /dev/null
+++ clang/unittests/Tooling/RangeSelectorTest.cpp
@@ -0,0 +1,497 @@
+//===- unittest/Tooling/RangeSelectorTest.cpp
+//---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Tooling/Refactoring/RangeSelector.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/FixIt.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Testing/Support/Error.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+using namespace tooling;
+using namespace ast_matchers;
+
+namespace {
+using ::testing::AllOf;
+using ::testing::HasSubstr;
+using MatchResult = MatchFinder::MatchResult;
+using ::llvm::Expected;
+using ::llvm::Failed;
+using ::llvm::HasValue;
+using ::llvm::StringError;
+
+struct TestMatch {
+  // The AST unit from which `result` is built. We bundle it because it backs
+  // the result. Users are not expected to access it.
+  std::unique_ptr ASTUnit;
+  // The result to use in the test. References `ast_unit`.
+  MatchResult Result;
+};
+
+template  TestMatch matchCode(StringRef Code, M Matcher) {
+  auto ASTUnit = buildASTFromCode(Code);
+  assert(ASTUnit != nullptr && "AST construction failed");
+
+  ASTContext  = ASTUnit->getASTContext();
+  assert(!Context.getDiagnostics().hasErrorOccurred() && "Compilation error");
+
+  auto Matches = ast_matchers::match(Matcher, Context);
+  // We expect a single, exact match.
+  assert(Matches.size() != 0 && "no matches found");
+  assert(Matches.size() == 1 && "too many matches");
+
+  return TestMatch{std::move(ASTUnit), MatchResult(Matches[0], )};
+}
+
+// Applies \p Selector to \p Match and, on success, returns the selected source.
+Expected apply(RangeSelector Selector, const TestMatch ) {
+  Expected Range = Selector(Match.Result);
+  if (!Range)
+return Range.takeError();
+  return fixit::internal::getText(*Range, *Match.Result.Context);
+}
+
+// Applies \p Selector to a trivial match with only a single bound node with id
+// "bound_node_id".  For use in testing unbound-node errors.
+Expected applyToTrivial(const RangeSelector ) {
+  // We need to bind the result to something, or the match will fail. Use a
+  // binding that is not used in the unbound node tests.
+  TestMatch Match =
+  matchCode("static int x = 0;", varDecl().bind("bound_node_id"));
+  return Selector(Match.Result);
+}
+
+// Matches the message expected for unbound-node failures.
+testing::Matcher withUnboundNodeMessage() {
+  return testing::Property(
+  ::getMessage,
+  AllOf(HasSubstr("unbound_id"), HasSubstr("not bound")));
+}
+
+// Applies \p Selector to code containing assorted node types, where the match
+// binds each one: a statement ("stmt"), a (non-member) ctor-initializer
+// ("init"), an expression ("expr") and a (nameless) declaration ("decl").  Used
+// to test failures caused by applying selectors to nodes of the wrong type.
+Expected applyToAssorted(RangeSelector Selector) {
+  StringRef Code = R"cc(
+  struct A {};
+  class F : public A {
+   public:
+F(int) {}
+  };
+  void g() { F f(1); }
+)cc";
+
+  auto Matcher =
+  compoundStmt(
+  hasDescendant(
+  cxxConstructExpr(
+  hasDeclaration(
+  decl(hasDescendant(cxxCtorInitializer(isBaseInitializer())
+ .bind("init")))
+  .bind("decl")))
+  .bind("expr")))
+  .bind("stmt");
+
+  return Selector(matchCode(Code, Matcher).Result);
+}
+
+// Matches the message expected for type-error failures.
+testing::Matcher withTypeErrorMessage(StringRef NodeID) {
+  return testing::Property(
+  ::getMessage,
+  AllOf(HasSubstr(NodeID), HasSubstr("mismatched type")));
+}
+
+TEST(RangeSelectorTest, UnboundNode) {
+  EXPECT_THAT_EXPECTED(applyToTrivial(node("unbound_id")),
+   Failed(withUnboundNodeMessage()));
+}
+
+TEST(RangeSelectorTest, RangeOp) {
+  StringRef Code = R"cc(
+int f(int x, 

[PATCH] D59887: [Syntax] Introduce TokenBuffer, start clangToolingSyntax library

2019-05-17 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang/include/clang/Tooling/Syntax/Tokens.h:115
+  /// expansion.
+  llvm::Optional range(const SourceManager ) const;
+

sammccall wrote:
> I think this might need a more explicit name. It's reasonably obvious that 
> this needs to be optional for some cases (token pasting), but it's not 
> obvious at callsites that (or why) we don't use the spelling location for 
> macro-expanded tokens.
> 
> One option would be just do that and add an expandedFromMacro() helper so the 
> no-macros version is easy to express too.
> If we can't do that, maybe `directlySpelledRange` or something?
As mentioned in the offline conversation, the idea is that mapping from a token 
inside a macro expansion to a spelled token should be handled by `TokenBuffer` 
and these two functions is really just a convenience helper to get to a range 
*after* the mapping.

This change has been boiling for some time and I think the other bits of it 
seem to be non-controversial and agreed upon.
Would it be ok if we land it with this function using a more concrete name 
(`directlySpelledRange` or something else) or move it into a separate change?

There's a follow-up change that adds an 'expand macro' action to clangd, which 
both has a use-site for these method and provides a functional feature based on 
`TokenBuffer`. Iterating on the design with (even a single) use-case should be 
simpler.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59887



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


[PATCH] D62046: [OpenMP][bugfix] Add missing math functions variants for log and abs.

2019-05-17 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.

I'd add a comment with a brief explanation for the const variant and a TODO() 
to remove it.

Looks OK to me otherwise.


Repository:
  rC Clang

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

https://reviews.llvm.org/D62046



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


Re: r361011 - [analyzer] Validate checker option names and values

2019-05-17 Thread Nico Weber via cfe-commits
Looks like your r361042 fixed the ppc64be bot nonetheless. Maybe it was
related after all :)

*From: *Kristof Umann 
*Date: *Fri, May 17, 2019 at 11:10 AM
*To: *Nico Weber
*Cc: *cfe-commits

http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick seems to be
> doing fine now, http://lab.llvm.org:8011/builders/clang-ppc64be-linux seems
> to crash on files totally unrelated to mine.
> --
> *From:* Kristof Umann
> *Sent:* 17 May 2019 15:59:28
> *To:* Nico Weber
> *Cc:* cfe-commits
> *Subject:* Re: r361011 - [analyzer] Validate checker option names and
> values
>
>
> I'll take a look.
> --
> *From:* Nico Weber 
> *Sent:* 17 May 2019 15:09:18
> *To:* Kristof Umann
> *Cc:* cfe-commits
> *Subject:* Re: r361011 - [analyzer] Validate checker option names and
> values
>
> It looks like this change is making gcc-7 crash on these (and other
> http://lab.llvm.org:8011/console) bots:
>
> http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/18639
> http://lab.llvm.org:8011/builders/clang-ppc64be-linux/builds/33837/
>
> [100/212] Building CXX object
> tools/clang/unittests/AST/CMakeFiles/ASTTests.dir/ASTImporterTest.cpp.o
> FAILED:
> tools/clang/unittests/AST/CMakeFiles/ASTTests.dir/ASTImporterTest.cpp.o
> ...
> g++-7: internal compiler error: Killed (program cc1plus)
> Please submit a full bug report,
> with preprocessed source if appropriate.
> See  for instructions.
> [101/212] Building CXX object
> tools/clang/unittests/ASTMatchers/CMakeFiles/ASTMatchersTests.dir/ASTMatchersTraversalTest.cpp.o
> FAILED:
> tools/clang/unittests/ASTMatchers/CMakeFiles/ASTMatchersTests.dir/ASTMatchersTraversalTest.cpp.o
>
> ...
> g++-7: internal compiler error: Killed (program cc1plus)
> Please submit a full bug report,
> with preprocessed source if appropriate.
> See  for instructions.
> [102/212] Building CXX object
> tools/clang/unittests/ASTMatchers/CMakeFiles/ASTMatchersTests.dir/ASTMatchersNarrowingTest.cpp.o
> FAILED:
> tools/clang/unittests/ASTMatchers/CMakeFiles/ASTMatchersTests.dir/ASTMatchersNarrowingTest.cpp.o
>
> ...
> g++-7: internal compiler error: Killed (program cc1plus)
> Please submit a full bug report,
> with preprocessed source if appropriate.
> See  for instructions.
> [103/212] Building CXX object
> tools/clang/unittests/ASTMatchers/CMakeFiles/ASTMatchersTests.dir/ASTMatchersNodeTest.cpp.o
> FAILED:
> tools/clang/unittests/ASTMatchers/CMakeFiles/ASTMatchersTests.dir/ASTMatchersNodeTest.cpp.o
>
> ...
> g++-7: internal compiler error: Killed (program cc1plus)
> Please submit a full bug report,
> with preprocessed source if appropriate.
> See  for instructions.
> [104/212] Building CXX object
> tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/CommentHandlerTest.cpp.o
> FAILED:
> tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/CommentHandlerTest.cpp.o
>
> ...
> g++-7: internal compiler error: Killed (program cc1plus)
> Please submit a full bug report,
> with preprocessed source if appropriate.
> See  for instructions.
> [105/212] Building CXX object
> tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/ExecutionTest.cpp.o
> FAILED:
> tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/ExecutionTest.cpp.o
>
> ...
> g++-7: internal compiler error: Killed (program cc1plus)
> Please submit a full bug report,
> with preprocessed source if appropriate.
> See  for instructions.
> [106/212] Building CXX object
> tools/clang/unittests/AST/CMakeFiles/ASTTests.dir/ASTImporterVisibilityTest.cpp.o
> FAILED:
> tools/clang/unittests/AST/CMakeFiles/ASTTests.dir/ASTImporterVisibilityTest.cpp.o
>
> ...
> g++-7: internal compiler error: Killed (program cc1plus)
> Please submit a full bug report,
> with preprocessed source if appropriate.
> See  for instructions.
>
> *From: *Kristof Umann via cfe-commits 
> *Date: *Fri, May 17, 2019 at 5:49 AM
> *To: *
>
> Author: szelethus
> Date: Fri May 17 02:51:59 2019
> New Revision: 361011
>
> URL: http://llvm.org/viewvc/llvm-project?rev=361011=rev
> Log:
> [analyzer] Validate checker option names and values
>
> Validate whether the option exists, and also whether the supplied value is
> of
> the correct type. With this patch, invoking the analyzer should be, at
> least
> in the frontend mode, a lot safer.
>
> Differential Revision: https://reviews.llvm.org/D57860
>
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
> cfe/trunk/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
> cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
> cfe/trunk/test/Analysis/checker-plugins.c
> cfe/trunk/test/Analysis/invalid-checker-option.c
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=361011=361010=361011=diff
>
> ==
> --- 

Re: r361033 - Add a Visit overload for DynTypedNode to ASTNodeTraverser

2019-05-17 Thread Yitzhak Mandelbaum via cfe-commits
Looks like this caused a breakage:
http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/18641/steps/ninja%20check%201/logs/stdio

On Fri, May 17, 2019 at 9:52 AM Stephen Kelly via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: steveire
> Date: Fri May 17 06:55:28 2019
> New Revision: 361033
>
> URL: http://llvm.org/viewvc/llvm-project?rev=361033=rev
> Log:
> Add a Visit overload for DynTypedNode to ASTNodeTraverser
>
> Reviewers: aaron.ballman
>
> Subscribers: cfe-commits
>
> Tags: #clang
>
> Differential Revision: https://reviews.llvm.org/D61834
>
> Added:
> cfe/trunk/unittests/AST/ASTTraverserTest.cpp
> Modified:
> cfe/trunk/include/clang/AST/ASTNodeTraverser.h
> cfe/trunk/unittests/AST/CMakeLists.txt
>
> Modified: cfe/trunk/include/clang/AST/ASTNodeTraverser.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTNodeTraverser.h?rev=361033=361032=361033=diff
>
> ==
> --- cfe/trunk/include/clang/AST/ASTNodeTraverser.h (original)
> +++ cfe/trunk/include/clang/AST/ASTNodeTraverser.h Fri May 17 06:55:28 2019
> @@ -205,6 +205,24 @@ public:
>  });
>}
>
> +  void Visit(const ast_type_traits::DynTypedNode ) {
> +// FIXME: Improve this with a switch or a visitor pattern.
> +if (const auto *D = N.get())
> +  Visit(D);
> +else if (const auto *S = N.get())
> +  Visit(S);
> +else if (const auto *QT = N.get())
> +  Visit(*QT);
> +else if (const auto *T = N.get())
> +  Visit(T);
> +else if (const auto *C = N.get())
> +  Visit(C);
> +else if (const auto *C = N.get())
> +  Visit(C);
> +else if (const auto *T = N.get())
> +  Visit(*T);
> +  }
> +
>void dumpDeclContext(const DeclContext *DC) {
>  if (!DC)
>return;
>
> Added: cfe/trunk/unittests/AST/ASTTraverserTest.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/ASTTraverserTest.cpp?rev=361033=auto
>
> ==
> --- cfe/trunk/unittests/AST/ASTTraverserTest.cpp (added)
> +++ cfe/trunk/unittests/AST/ASTTraverserTest.cpp Fri May 17 06:55:28 2019
> @@ -0,0 +1,220 @@
> +//===-
> unittests/AST/ASTTraverserTest.h===//
> +//
> +// Part of the LLVM Project, under the Apache License v2.0 with LLVM
> Exceptions.
> +// See https://llvm.org/LICENSE.txt for license information.
> +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
> +//
>
> +//===--===//
> +
> +#include "clang/AST/ASTContext.h"
> +#include "clang/AST/ASTNodeTraverser.h"
> +#include "clang/AST/TextNodeDumper.h"
> +#include "clang/ASTMatchers/ASTMatchFinder.h"
> +#include "clang/ASTMatchers/ASTMatchers.h"
> +#include "clang/Tooling/Tooling.h"
> +#include "gmock/gmock.h"
> +#include "gtest/gtest.h"
> +
> +using namespace clang::tooling;
> +using namespace clang::ast_matchers;
> +
> +namespace clang {
> +
> +class NodeTreePrinter : public TextTreeStructure {
> +  llvm::raw_ostream 
> +
> +public:
> +  NodeTreePrinter(llvm::raw_ostream )
> +  : TextTreeStructure(OS, /* showColors */ false), OS(OS) {}
> +
> +  void Visit(const Decl *D) { OS << D->getDeclKindName() << "Decl"; }
> +
> +  void Visit(const Stmt *S) { OS << S->getStmtClassName(); }
> +
> +  void Visit(QualType QT) {
> +OS << "QualType " << QT.split().Quals.getAsString();
> +  }
> +
> +  void Visit(const Type *T) { OS << T->getTypeClassName() << "Type"; }
> +
> +  void Visit(const comments::Comment *C, const comments::FullComment *FC)
> {
> +OS << C->getCommentKindName();
> +  }
> +
> +  void Visit(const CXXCtorInitializer *Init) { OS <<
> "CXXCtorInitializer"; }
> +
> +  void Visit(const Attr *A) {
> +switch (A->getKind()) {
> +#define ATTR(X)
>   \
> +  case attr::X:
>   \
> +OS << #X;
>   \
> +break;
> +#include "clang/Basic/AttrList.inc"
> +}
> +OS << "Attr";
> +  }
> +
> +  void Visit(const OMPClause *C) { OS << "OMPClause"; }
> +  void Visit(const TemplateArgument , SourceRange R = {},
> + const Decl *From = nullptr, const char *Label = nullptr) {
> +OS << "TemplateArgument";
> +  }
> +
> +  template  void Visit(T...) {}
> +};
> +
> +class TestASTDumper : public ASTNodeTraverser NodeTreePrinter> {
> +
> +  NodeTreePrinter MyNodeRecorder;
> +
> +public:
> +  TestASTDumper(llvm::raw_ostream ) : MyNodeRecorder(OS) {}
> +  NodeTreePrinter () { return MyNodeRecorder; }
> +};
> +
> +template  std::string dumpASTString(NodeType &&...
> N) {
> +  std::string Buffer;
> +  llvm::raw_string_ostream OS(Buffer);
> +
> +  TestASTDumper Dumper(OS);
> +
> +  OS << "\n";
> +
> +  Dumper.Visit(std::forward(N)...);
> +
> +  return OS.str();
> +}
> +
> +const FunctionDecl *getFunctionNode(clang::ASTUnit *AST,
> +const std::string ) {
> +  auto Result =
> 

[PATCH] D60568: [OpenMP] Add support for registering requires directives with the runtime

2019-05-17 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:9291
+  if (CGM.getLangOpts().OpenMPSimd || CGM.getLangOpts().OpenMPIsDevice ||
+  (OffloadEntriesInfoManager.empty() && !HasEmittedDeclareTargetRegion))
+return nullptr;

Missed check for `HasEmittedTargetRegion` here



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:9312
+// contain at least 1 target region.
+if ((HasEmittedTargetRegion || HasEmittedDeclareTargetRegion) &&
+HasRequiresUnifiedSharedMemory)

The first part of the condition is excessive. You have early exit from the 
function. Instead of the condition, use 
`assert((!OffloadEntriesInfoManager.empty() || HasEmittedDeclareTargetRegion || 
HasEmittedTargetRegion) && "Expected bla-bla-bla");`



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:10364
+  if (const auto *FD = dyn_cast(D)) {
+if (OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(FD)) {
+  HasEmittedDeclareTargetRegion = true;

gtbercea wrote:
> ABataev wrote:
> > gtbercea wrote:
> > > ABataev wrote:
> > > > gtbercea wrote:
> > > > > ABataev wrote:
> > > > > > ABataev wrote:
> > > > > > > No need for the braces
> > > > > > What if `declare target` is used only for variabes but not for the 
> > > > > > functions?
> > > > > Even more reason to error in that case since it may contain clauses 
> > > > > like link or to which need for requires directives to be used 
> > > > > consistently.
> > > > But I don't see that your patch works in this situation. Currently, it 
> > > > will emit the error only if the declare target function is found, no?
> > > Actually it will work even when just variables are used in the declare 
> > > target region. There is another problem which I have a fix for. I will 
> > > update the patch in a bit. 
> > Why will it work in this case? If you have just a declare target region in 
> > the code for the variables and nothing else. You don't have target regions, 
> > declare target functions etc. It won't work in this case.
> It will work because the OffloadEntriesInfoManager.empty() will return false 
> in that case.
But you don't have a check for `OffloadEntriesInfoManager.empty() ` when you 
set `Flags` for `__tgt_register_requires` function call.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60568



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


r361042 - [analyzer] Remove the default value arg from getChecker*Option

2019-05-17 Thread Kristof Umann via cfe-commits
Author: szelethus
Date: Fri May 17 08:52:13 2019
New Revision: 361042

URL: http://llvm.org/viewvc/llvm-project?rev=361042=rev
Log:
[analyzer] Remove the default value arg from getChecker*Option

Since D57922, the config table contains every checker option, and it's default
value, so having it as an argument for getChecker*Option is redundant.

By the time any of the getChecker*Option function is called, we verified the
value in CheckerRegistry (after D57860), so we can confidently assert here, as
any irregularities detected at this point must be a programmer error. However,
in compatibility mode, verification won't happen, so the default value must be
restored.

This implies something else, other than adding removing one more potential point
of failure -- debug.ConfigDumper will always contain valid values for
checker/package options!

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
cfe/trunk/lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/CloneChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp

cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
cfe/trunk/test/Analysis/checker-plugins.c
cfe/trunk/test/Analysis/invalid-checker-option.c

cfe/trunk/test/Analysis/plugins/CheckerOptionHandling/CheckerOptionHandling.cpp
cfe/trunk/unittests/StaticAnalyzer/AnalyzerOptionsTest.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h?rev=361042=361041=361042=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h Fri May 17 
08:52:13 2019
@@ -281,18 +281,14 @@ public:
   /// Checker options are retrieved in the following format:
   /// `-analyzer-config CheckerName:OptionName=Value.
   /// @param [in] OptionName Name for option to retrieve.
-  /// @param [in] DefaultVal Default value returned if no such option was
-  /// specified.
   /// @param [in] SearchInParents If set to true and the searched option was 
not
   /// specified for the given checker the options for the parent packages will
   /// be searched as well. The inner packages take precedence over the outer
   /// ones.
   bool getCheckerBooleanOption(StringRef CheckerName, StringRef OptionName,
-   bool DefaultVal,
bool SearchInParents = false) const;
 
   bool getCheckerBooleanOption(const ento::CheckerBase *C, StringRef 
OptionName,
-   bool DefaultVal,
bool SearchInParents = false) const;
 
   /// Interprets an option's string value as an integer value.
@@ -305,18 +301,14 @@ public:
   /// Checker options are retrieved in the following format:
   /// `-analyzer-config CheckerName:OptionName=Value.
   /// @param [in] OptionName Name for option to retrieve.
-  /// @param [in] DefaultVal Default value returned if no such option was
-  /// specified.
   /// @param [in] SearchInParents If set to true and the searched option was 
not
   /// specified for the given checker the options for the parent packages will
   /// be searched as well. The inner packages take precedence over the outer
   /// ones.
   int getCheckerIntegerOption(StringRef CheckerName, StringRef OptionName,
-  int DefaultVal,
   bool SearchInParents = false) const;
 
   int getCheckerIntegerOption(const ento::CheckerBase *C, StringRef OptionName,
-  int DefaultVal,
   bool SearchInParents = false) const;
 
   /// Query an option's string value.
@@ -329,18 +321,15 @@ public:
   /// Checker options are retrieved in the following format:
   /// `-analyzer-config CheckerName:OptionName=Value.
   /// @param [in] OptionName Name for option to retrieve.
-  /// @param [in] DefaultVal Default value returned if no such option was
-  /// specified.
   /// @param [in] SearchInParents If set to true and the searched option was 
not
   /// specified for the given checker the options for the parent packages 

[PATCH] D59195: [analyzer] Remove the default value arg from getChecker*Option

2019-05-17 Thread Kristóf Umann via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL361042: [analyzer] Remove the default value arg from 
getChecker*Option (authored by Szelethus, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D59195?vs=190996=200052#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D59195

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  cfe/trunk/lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/CloneChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
  
cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/VirtualCallChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
  cfe/trunk/test/Analysis/checker-plugins.c
  cfe/trunk/test/Analysis/invalid-checker-option.c
  
cfe/trunk/test/Analysis/plugins/CheckerOptionHandling/CheckerOptionHandling.cpp
  cfe/trunk/unittests/StaticAnalyzer/AnalyzerOptionsTest.cpp

Index: cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
@@ -324,7 +324,9 @@
 return;
 
   // Insertion failed, the user supplied this package/checker option on the
-  // command line. If the supplied value is invalid, we'll emit an error.
+  // command line. If the supplied value is invalid, we'll restore the option
+  // to it's default value, and if we're in non-compatibility mode, we'll also
+  // emit an error.
 
   StringRef SuppliedValue = It.first->getValue();
 
@@ -334,6 +336,8 @@
 Diags.Report(diag::err_analyzer_checker_option_invalid_input)
 << FullOption << "a boolean value";
   }
+
+  It.first->setValue(Option.DefaultValStr);
 }
 return;
   }
@@ -346,6 +350,8 @@
 Diags.Report(diag::err_analyzer_checker_option_invalid_input)
 << FullOption << "an integer value";
   }
+
+  It.first->setValue(Option.DefaultValStr);
 }
 return;
   }
Index: cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
@@ -103,8 +103,7 @@
 
 StringRef AnalyzerOptions::getCheckerStringOption(StringRef CheckerName,
   StringRef OptionName,
-  StringRef DefaultVal,
-  bool SearchInParents ) const {
+  bool SearchInParents) const {
   assert(!CheckerName.empty() &&
  "Empty checker name! Make sure the checker object (including it's "
  "bases!) if fully initialized before calling this function!");
@@ -117,62 +116,66 @@
   return StringRef(I->getValue());
 size_t Pos = CheckerName.rfind('.');
 if (Pos == StringRef::npos)
-  return DefaultVal;
+  break;
+
 CheckerName = CheckerName.substr(0, Pos);
   } while (!CheckerName.empty() && SearchInParents);
-  return DefaultVal;
+
+  llvm_unreachable("Unknown checker option! Did you call getChecker*Option "
+   "with incorrect parameters? User input must've been "
+   "verified by CheckerRegistry.");
+
+  return "";
 }
 
 StringRef AnalyzerOptions::getCheckerStringOption(const ento::CheckerBase *C,
   StringRef OptionName,
-  StringRef DefaultVal,
-  bool SearchInParents ) const {
+  bool SearchInParents) const {
   return getCheckerStringOption(
- C->getTagDescription(), OptionName, DefaultVal, SearchInParents);
+   C->getTagDescription(), OptionName, SearchInParents);
 }
 
 bool AnalyzerOptions::getCheckerBooleanOption(StringRef CheckerName,
   StringRef OptionName,
-  bool DefaultVal,
- 

[PATCH] D60568: [OpenMP] Add support for registering requires directives with the runtime

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



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:10364
+  if (const auto *FD = dyn_cast(D)) {
+if (OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(FD)) {
+  HasEmittedDeclareTargetRegion = true;

ABataev wrote:
> gtbercea wrote:
> > ABataev wrote:
> > > gtbercea wrote:
> > > > ABataev wrote:
> > > > > ABataev wrote:
> > > > > > No need for the braces
> > > > > What if `declare target` is used only for variabes but not for the 
> > > > > functions?
> > > > Even more reason to error in that case since it may contain clauses 
> > > > like link or to which need for requires directives to be used 
> > > > consistently.
> > > But I don't see that your patch works in this situation. Currently, it 
> > > will emit the error only if the declare target function is found, no?
> > Actually it will work even when just variables are used in the declare 
> > target region. There is another problem which I have a fix for. I will 
> > update the patch in a bit. 
> Why will it work in this case? If you have just a declare target region in 
> the code for the variables and nothing else. You don't have target regions, 
> declare target functions etc. It won't work in this case.
It will work because the OffloadEntriesInfoManager.empty() will return false in 
that case.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60568



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


[PATCH] D62046: [OpenMP][bugfix] Add missing math functions variants for log and abs.

2019-05-17 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added a comment.

@tra I eliminated the long double definition for log and only left the 
declaration.


Repository:
  rC Clang

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

https://reviews.llvm.org/D62046



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


[PATCH] D62046: [OpenMP][bugfix] Add missing math functions variants for log and abs.

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

- update patch


Repository:
  rC Clang

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

https://reviews.llvm.org/D62046

Files:
  lib/Headers/__clang_cuda_cmath.h
  lib/Headers/__clang_cuda_math_forward_declares.h


Index: lib/Headers/__clang_cuda_math_forward_declares.h
===
--- lib/Headers/__clang_cuda_math_forward_declares.h
+++ lib/Headers/__clang_cuda_math_forward_declares.h
@@ -42,6 +42,10 @@
 __DEVICE__ double abs(double);
 __DEVICE__ float abs(float);
 #endif
+#if defined(_OPENMP) && defined(__cplusplus)
+__DEVICE__ const double abs(const double);
+__DEVICE__ const float abs(const float);
+#endif
 __DEVICE__ int abs(int) __NOEXCEPT;
 __DEVICE__ double acos(double);
 __DEVICE__ float acos(float);
@@ -144,6 +148,9 @@
 __DEVICE__ float log2(float);
 __DEVICE__ double logb(double);
 __DEVICE__ float logb(float);
+#if defined(_OPENMP) && defined(__cplusplus)
+__DEVICE__ long double log(long double);
+#endif
 __DEVICE__ double log(double);
 __DEVICE__ float log(float);
 __DEVICE__ long lrint(double);
Index: lib/Headers/__clang_cuda_cmath.h
===
--- lib/Headers/__clang_cuda_cmath.h
+++ lib/Headers/__clang_cuda_cmath.h
@@ -51,6 +51,10 @@
 __DEVICE__ float abs(float __x) { return ::fabsf(__x); }
 __DEVICE__ double abs(double __x) { return ::fabs(__x); }
 #endif
+#if defined(_OPENMP) && defined(__cplusplus)
+__DEVICE__ const float abs(const float __x) { return ::fabsf((float)__x); }
+__DEVICE__ const double abs(const double __x) { return ::fabs((double)__x); }
+#endif
 __DEVICE__ float acos(float __x) { return ::acosf(__x); }
 __DEVICE__ float asin(float __x) { return ::asinf(__x); }
 __DEVICE__ float atan(float __x) { return ::atanf(__x); }


Index: lib/Headers/__clang_cuda_math_forward_declares.h
===
--- lib/Headers/__clang_cuda_math_forward_declares.h
+++ lib/Headers/__clang_cuda_math_forward_declares.h
@@ -42,6 +42,10 @@
 __DEVICE__ double abs(double);
 __DEVICE__ float abs(float);
 #endif
+#if defined(_OPENMP) && defined(__cplusplus)
+__DEVICE__ const double abs(const double);
+__DEVICE__ const float abs(const float);
+#endif
 __DEVICE__ int abs(int) __NOEXCEPT;
 __DEVICE__ double acos(double);
 __DEVICE__ float acos(float);
@@ -144,6 +148,9 @@
 __DEVICE__ float log2(float);
 __DEVICE__ double logb(double);
 __DEVICE__ float logb(float);
+#if defined(_OPENMP) && defined(__cplusplus)
+__DEVICE__ long double log(long double);
+#endif
 __DEVICE__ double log(double);
 __DEVICE__ float log(float);
 __DEVICE__ long lrint(double);
Index: lib/Headers/__clang_cuda_cmath.h
===
--- lib/Headers/__clang_cuda_cmath.h
+++ lib/Headers/__clang_cuda_cmath.h
@@ -51,6 +51,10 @@
 __DEVICE__ float abs(float __x) { return ::fabsf(__x); }
 __DEVICE__ double abs(double __x) { return ::fabs(__x); }
 #endif
+#if defined(_OPENMP) && defined(__cplusplus)
+__DEVICE__ const float abs(const float __x) { return ::fabsf((float)__x); }
+__DEVICE__ const double abs(const double __x) { return ::fabs((double)__x); }
+#endif
 __DEVICE__ float acos(float __x) { return ::acosf(__x); }
 __DEVICE__ float asin(float __x) { return ::asinf(__x); }
 __DEVICE__ float atan(float __x) { return ::atanf(__x); }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60568: [OpenMP] Add support for registering requires directives with the runtime

2019-05-17 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:10364
+  if (const auto *FD = dyn_cast(D)) {
+if (OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(FD)) {
+  HasEmittedDeclareTargetRegion = true;

gtbercea wrote:
> ABataev wrote:
> > gtbercea wrote:
> > > ABataev wrote:
> > > > ABataev wrote:
> > > > > No need for the braces
> > > > What if `declare target` is used only for variabes but not for the 
> > > > functions?
> > > Even more reason to error in that case since it may contain clauses like 
> > > link or to which need for requires directives to be used consistently.
> > But I don't see that your patch works in this situation. Currently, it will 
> > emit the error only if the declare target function is found, no?
> Actually it will work even when just variables are used in the declare target 
> region. There is another problem which I have a fix for. I will update the 
> patch in a bit. 
Why will it work in this case? If you have just a declare target region in the 
code for the variables and nothing else. You don't have target regions, declare 
target functions etc. It won't work in this case.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60568



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


Re: r361011 - [analyzer] Validate checker option names and values

2019-05-17 Thread Kristof Umann via cfe-commits
http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick seems to be doing 
fine now, http://lab.llvm.org:8011/builders/clang-ppc64be-linux seems to crash 
on files totally unrelated to mine.


From: Kristof Umann
Sent: 17 May 2019 15:59:28
To: Nico Weber
Cc: cfe-commits
Subject: Re: r361011 - [analyzer] Validate checker option names and values


I'll take a look.


From: Nico Weber 
Sent: 17 May 2019 15:09:18
To: Kristof Umann
Cc: cfe-commits
Subject: Re: r361011 - [analyzer] Validate checker option names and values

It looks like this change is making gcc-7 crash on these (and other 
http://lab.llvm.org:8011/console) bots:

http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/18639
http://lab.llvm.org:8011/builders/clang-ppc64be-linux/builds/33837/

[100/212] Building CXX object 
tools/clang/unittests/AST/CMakeFiles/ASTTests.dir/ASTImporterTest.cpp.o
FAILED: tools/clang/unittests/AST/CMakeFiles/ASTTests.dir/ASTImporterTest.cpp.o
...
g++-7: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.
[101/212] Building CXX object 
tools/clang/unittests/ASTMatchers/CMakeFiles/ASTMatchersTests.dir/ASTMatchersTraversalTest.cpp.o
FAILED: 
tools/clang/unittests/ASTMatchers/CMakeFiles/ASTMatchersTests.dir/ASTMatchersTraversalTest.cpp.o
...
g++-7: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.
[102/212] Building CXX object 
tools/clang/unittests/ASTMatchers/CMakeFiles/ASTMatchersTests.dir/ASTMatchersNarrowingTest.cpp.o
FAILED: 
tools/clang/unittests/ASTMatchers/CMakeFiles/ASTMatchersTests.dir/ASTMatchersNarrowingTest.cpp.o
...
g++-7: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.
[103/212] Building CXX object 
tools/clang/unittests/ASTMatchers/CMakeFiles/ASTMatchersTests.dir/ASTMatchersNodeTest.cpp.o
FAILED: 
tools/clang/unittests/ASTMatchers/CMakeFiles/ASTMatchersTests.dir/ASTMatchersNodeTest.cpp.o
...
g++-7: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.
[104/212] Building CXX object 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/CommentHandlerTest.cpp.o
FAILED: 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/CommentHandlerTest.cpp.o
...
g++-7: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.
[105/212] Building CXX object 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/ExecutionTest.cpp.o
FAILED: 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/ExecutionTest.cpp.o
...
g++-7: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.
[106/212] Building CXX object 
tools/clang/unittests/AST/CMakeFiles/ASTTests.dir/ASTImporterVisibilityTest.cpp.o
FAILED: 
tools/clang/unittests/AST/CMakeFiles/ASTTests.dir/ASTImporterVisibilityTest.cpp.o
...
g++-7: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.

From: Kristof Umann via cfe-commits 
mailto:cfe-commits@lists.llvm.org>>
Date: Fri, May 17, 2019 at 5:49 AM
To: mailto:cfe-commits@lists.llvm.org>>

Author: szelethus
Date: Fri May 17 02:51:59 2019
New Revision: 361011

URL: http://llvm.org/viewvc/llvm-project?rev=361011=rev
Log:
[analyzer] Validate checker option names and values

Validate whether the option exists, and also whether the supplied value is of
the correct type. With this patch, invoking the analyzer should be, at least
in the frontend mode, a lot safer.

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
cfe/trunk/test/Analysis/checker-plugins.c
cfe/trunk/test/Analysis/invalid-checker-option.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=361011=361010=361011=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Fri May 17 02:51:59 
2019
@@ -307,6 +307,8 @@ def err_analyzer_config_multiple_values
 def err_analyzer_config_invalid_input : Error<
   "invalid input for analyzer-config option '%0', that expects %1 value">;
 def err_analyzer_config_unknown : Error<"unknown analyzer-config '%0'">;

[PATCH] D60953: [clangd] Respect clang-tidy suppression comments

2019-05-17 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

Could someone merge this and D61841  now that 
they're approved? Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60953



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


[PATCH] D37813: clang-format: better handle namespace macros

2019-05-17 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.
Herald added a project: clang.

ping ?


Repository:
  rC Clang

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

https://reviews.llvm.org/D37813



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


[PATCH] D60568: [OpenMP] Add support for registering requires directives with the runtime

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



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:10364
+  if (const auto *FD = dyn_cast(D)) {
+if (OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(FD)) {
+  HasEmittedDeclareTargetRegion = true;

ABataev wrote:
> gtbercea wrote:
> > ABataev wrote:
> > > ABataev wrote:
> > > > No need for the braces
> > > What if `declare target` is used only for variabes but not for the 
> > > functions?
> > Even more reason to error in that case since it may contain clauses like 
> > link or to which need for requires directives to be used consistently.
> But I don't see that your patch works in this situation. Currently, it will 
> emit the error only if the declare target function is found, no?
Actually it will work even when just variables are used in the declare target 
region. There is another problem which I have a fix for. I will update the 
patch in a bit. 


Repository:
  rC Clang

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

https://reviews.llvm.org/D60568



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


[PATCH] D61837: Make it possible control matcher traversal kind with ASTContext

2019-05-17 Thread Stephen Kelly via Phabricator via cfe-commits
steveire marked an inline comment as done.
steveire added inline comments.



Comment at: lib/ASTMatchers/ASTMatchersInternal.cpp:240
+
+  assert(RestrictKind.isBaseOf(NodeKind));
+  if (Implementation->dynMatches(N, Finder, Builder)) {

aaron.ballman wrote:
> steveire wrote:
> > aaron.ballman wrote:
> > > Add an assertion message?
> > Saying what? The original code doesn't have one. Let's avoid round trips in 
> > review comments :).
> This isn't a "round trip"; it's not unreasonable to ask people to NFC improve 
> the code they're touching (it's akin to saying "Because you figured out this 
> complex piece of code does X, can you add a comment to it so others don't 
> have to do that work next time.").
> 
> As best I can tell, this assertion exists because this function is meant to 
> mirror `matches()` without this base check in release mode. You've lost that 
> mirroring with your refactoring, which looks suspicious. Is there a reason 
> this function deviates from `matches()` now?
> 
> As for the assertion message itself, how about "matched a node of an 
> unexpected derived kind"?
Hmm, maybe that was a misunderstanding. Your note about an assertion message 
was not clear, so I asked you what you suggest the message should be. No need 
for offense :)


Repository:
  rC Clang

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

https://reviews.llvm.org/D61837



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


[PATCH] D62066: [ASTImporter] Enable disabled but passing tests

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

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62066

Files:
  clang/unittests/AST/ASTImporterTest.cpp
  clang/unittests/AST/StructuralEquivalenceTest.cpp


Index: clang/unittests/AST/StructuralEquivalenceTest.cpp
===
--- clang/unittests/AST/StructuralEquivalenceTest.cpp
+++ clang/unittests/AST/StructuralEquivalenceTest.cpp
@@ -300,8 +300,7 @@
   EXPECT_FALSE(testStructuralMatch(t));
 }
 
-TEST_F(StructuralEquivalenceFunctionTest, DISABLED_NoexceptNonMatch) {
-  // The expression is not checked yet.
+TEST_F(StructuralEquivalenceFunctionTest, NoexceptNonMatch) {
   auto t = makeNamedDecls("void foo() noexcept(false);",
   "void foo() noexcept(true);", Lang_CXX11);
   EXPECT_FALSE(testStructuralMatch(t));
Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -2362,12 +2362,7 @@
   EXPECT_EQ(ToFD->getPreviousDecl(), ImportedD);
 }
 
-// Disabled temporarily, because the new structural equivalence check
-// (https://reviews.llvm.org/D48628) breaks it.
-// PreviousDecl is not set because there is no structural match.
-// FIXME Enable!
-TEST_P(ImportFriendFunctions,
-DISABLED_ImportFriendFunctionRedeclChainDefWithClass) {
+TEST_P(ImportFriendFunctions, ImportFriendFunctionRedeclChainDefWithClass) {
   auto Pattern = functionDecl(hasName("f"));
 
   Decl *FromTU = getTuDecl(
@@ -2395,12 +2390,8 @@
 (*ImportedD->param_begin())->getOriginalType());
 }
 
-// Disabled temporarily, because the new structural equivalence check
-// (https://reviews.llvm.org/D48628) breaks it.
-// PreviousDecl is not set because there is no structural match.
-// FIXME Enable!
 TEST_P(ImportFriendFunctions,
-DISABLED_ImportFriendFunctionRedeclChainDefWithClass_ImportTheProto) {
+   ImportFriendFunctionRedeclChainDefWithClass_ImportTheProto) {
   auto Pattern = functionDecl(hasName("f"));
 
   Decl *FromTU = getTuDecl(


Index: clang/unittests/AST/StructuralEquivalenceTest.cpp
===
--- clang/unittests/AST/StructuralEquivalenceTest.cpp
+++ clang/unittests/AST/StructuralEquivalenceTest.cpp
@@ -300,8 +300,7 @@
   EXPECT_FALSE(testStructuralMatch(t));
 }
 
-TEST_F(StructuralEquivalenceFunctionTest, DISABLED_NoexceptNonMatch) {
-  // The expression is not checked yet.
+TEST_F(StructuralEquivalenceFunctionTest, NoexceptNonMatch) {
   auto t = makeNamedDecls("void foo() noexcept(false);",
   "void foo() noexcept(true);", Lang_CXX11);
   EXPECT_FALSE(testStructuralMatch(t));
Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -2362,12 +2362,7 @@
   EXPECT_EQ(ToFD->getPreviousDecl(), ImportedD);
 }
 
-// Disabled temporarily, because the new structural equivalence check
-// (https://reviews.llvm.org/D48628) breaks it.
-// PreviousDecl is not set because there is no structural match.
-// FIXME Enable!
-TEST_P(ImportFriendFunctions,
-DISABLED_ImportFriendFunctionRedeclChainDefWithClass) {
+TEST_P(ImportFriendFunctions, ImportFriendFunctionRedeclChainDefWithClass) {
   auto Pattern = functionDecl(hasName("f"));
 
   Decl *FromTU = getTuDecl(
@@ -2395,12 +2390,8 @@
 (*ImportedD->param_begin())->getOriginalType());
 }
 
-// Disabled temporarily, because the new structural equivalence check
-// (https://reviews.llvm.org/D48628) breaks it.
-// PreviousDecl is not set because there is no structural match.
-// FIXME Enable!
 TEST_P(ImportFriendFunctions,
-DISABLED_ImportFriendFunctionRedeclChainDefWithClass_ImportTheProto) {
+   ImportFriendFunctionRedeclChainDefWithClass_ImportTheProto) {
   auto Pattern = functionDecl(hasName("f"));
 
   Decl *FromTU = getTuDecl(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62065: Move dump method implementations to their respective class files

2019-05-17 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
steveire added a reviewer: aaron.ballman.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

There is no need to group them together.


Repository:
  rC Clang

https://reviews.llvm.org/D62065

Files:
  lib/AST/ASTDumper.cpp
  lib/AST/Comment.cpp
  lib/AST/DeclBase.cpp
  lib/AST/Stmt.cpp
  lib/AST/Type.cpp

Index: lib/AST/Type.cpp
===
--- lib/AST/Type.cpp
+++ lib/AST/Type.cpp
@@ -44,6 +44,7 @@
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Casting.h"
+#include "clang/AST/ASTDumper.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/MathExtras.h"
 #include 
@@ -53,6 +54,25 @@
 
 using namespace clang;
 
+void QualType::dump(const char *msg) const {
+  if (msg)
+llvm::errs() << msg << ": ";
+  dump();
+}
+
+LLVM_DUMP_METHOD void QualType::dump() const { dump(llvm::errs()); }
+
+LLVM_DUMP_METHOD void QualType::dump(llvm::raw_ostream ) const {
+  ASTDumper Dumper(OS, nullptr, nullptr);
+  Dumper.Visit(*this);
+}
+
+LLVM_DUMP_METHOD void Type::dump() const { dump(llvm::errs()); }
+
+LLVM_DUMP_METHOD void Type::dump(llvm::raw_ostream ) const {
+  QualType(this, 0).dump(OS);
+}
+
 bool Qualifiers::isStrictSupersetOf(Qualifiers Other) const {
   return (*this != Other) &&
 // CVR qualifiers superset
Index: lib/AST/Stmt.cpp
===
--- lib/AST/Stmt.cpp
+++ lib/AST/Stmt.cpp
@@ -19,6 +19,7 @@
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/ExprObjC.h"
 #include "clang/AST/ExprOpenMP.h"
+#include "clang/AST/ASTDumper.h"
 #include "clang/AST/StmtCXX.h"
 #include "clang/AST/StmtObjC.h"
 #include "clang/AST/StmtOpenMP.h"
@@ -1292,3 +1293,27 @@
 
   return false;
 }
+
+LLVM_DUMP_METHOD void Stmt::dump(SourceManager ) const {
+  dump(llvm::errs(), SM);
+}
+
+LLVM_DUMP_METHOD void Stmt::dump(raw_ostream , SourceManager ) const {
+  ASTDumper P(OS, nullptr, );
+  P.Visit(this);
+}
+
+LLVM_DUMP_METHOD void Stmt::dump(raw_ostream ) const {
+  ASTDumper P(OS, nullptr, nullptr);
+  P.Visit(this);
+}
+
+LLVM_DUMP_METHOD void Stmt::dump() const {
+  ASTDumper P(llvm::errs(), nullptr, nullptr);
+  P.Visit(this);
+}
+
+LLVM_DUMP_METHOD void Stmt::dumpColor() const {
+  ASTDumper P(llvm::errs(), nullptr, nullptr, /*ShowColors*/true);
+  P.Visit(this);
+}
Index: lib/AST/DeclBase.cpp
===
--- lib/AST/DeclBase.cpp
+++ lib/AST/DeclBase.cpp
@@ -19,6 +19,8 @@
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclContextInternals.h"
 #include "clang/AST/DeclFriend.h"
+#include "clang/AST/JSONNodeDumper.h"
+#include "clang/AST/ASTDumper.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/DeclOpenMP.h"
 #include "clang/AST/DeclTemplate.h"
@@ -1969,3 +1971,48 @@
 
   return DD;
 }
+
+LLVM_DUMP_METHOD void Decl::dump() const { dump(llvm::errs()); }
+
+LLVM_DUMP_METHOD void Decl::dump(raw_ostream , bool Deserialize,
+ ASTDumpOutputFormat Format) const {
+  const ASTContext  = getASTContext();
+  const SourceManager  = Ctx.getSourceManager();
+
+  if (ADOF_JSON == Format) {
+JSONDumper P(OS, SM, Ctx.getPrintingPolicy());
+(void)Deserialize; // FIXME?
+P.Visit(this);
+  } else {
+ASTDumper P(OS, (), ,
+SM.getDiagnostics().getShowColors(), Ctx.getPrintingPolicy());
+P.setDeserialize(Deserialize);
+P.Visit(this);
+  }
+}
+
+LLVM_DUMP_METHOD void Decl::dumpColor() const {
+  const ASTContext  = getASTContext();
+  ASTDumper P(llvm::errs(), (),
+  (), /*ShowColors*/ true,
+  Ctx.getPrintingPolicy());
+  P.Visit(this);
+}
+
+LLVM_DUMP_METHOD void DeclContext::dumpLookups() const {
+  dumpLookups(llvm::errs());
+}
+
+LLVM_DUMP_METHOD void DeclContext::dumpLookups(raw_ostream ,
+   bool DumpDecls,
+   bool Deserialize) const {
+  const DeclContext *DC = this;
+  while (!DC->isTranslationUnit())
+DC = DC->getParent();
+  ASTContext  = cast(DC)->getASTContext();
+  const SourceManager  = Ctx.getSourceManager();
+  ASTDumper P(OS, (), (),
+  SM.getDiagnostics().getShowColors(), Ctx.getPrintingPolicy());
+  P.setDeserialize(Deserialize);
+  P.dumpLookups(this, DumpDecls);
+}
Index: lib/AST/Comment.cpp
===
--- lib/AST/Comment.cpp
+++ lib/AST/Comment.cpp
@@ -12,6 +12,7 @@
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/Basic/CharInfo.h"
+#include "clang/AST/ASTDumper.h"
 #include "llvm/Support/ErrorHandling.h"
 
 namespace clang {
@@ -374,6 +375,32 @@
   return "";
 }
 
+LLVM_DUMP_METHOD void Comment::dump() const {
+  dump(llvm::errs(), nullptr, nullptr);
+}
+
+LLVM_DUMP_METHOD void Comment::dump(const ASTContext ) const {
+  dump(llvm::errs(), (),
+  

[PATCH] D59887: [Syntax] Introduce TokenBuffer, start clangToolingSyntax library

2019-05-17 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.



Comment at: clang/include/clang/Tooling/Syntax/Tokens.h:49
+
+/// A half-open range inside a particular file, the start offset is included 
and
+/// the end offset is excluded from the range.

nit: character range (just to be totally explicit)?



Comment at: clang/include/clang/Tooling/Syntax/Tokens.h:115
+  /// expansion.
+  llvm::Optional range(const SourceManager ) const;
+

I think this might need a more explicit name. It's reasonably obvious that this 
needs to be optional for some cases (token pasting), but it's not obvious at 
callsites that (or why) we don't use the spelling location for macro-expanded 
tokens.

One option would be just do that and add an expandedFromMacro() helper so the 
no-macros version is easy to express too.
If we can't do that, maybe `directlySpelledRange` or something?



Comment at: clang/include/clang/Tooling/Syntax/Tokens.h:121
+  /// are from different files or \p Last is located before \p First.
+  static llvm::Optional range(const SourceManager ,
+ const syntax::Token ,

similar to above, I'd naively expect this to return a valid range, given the 
tokens expanded from `assert(X && [[Y.z()]] )`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59887



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


[PATCH] D61335: [LibTooling] Add support to Transformer for composing rules as an ordered choice.

2019-05-17 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC361037: [LibTooling] Add support to Transformer for 
composing rules as an ordered… (authored by ymandel, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D61335?vs=200042=200044#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D61335

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

Index: lib/Tooling/Refactoring/Transformer.cpp
===
--- lib/Tooling/Refactoring/Transformer.cpp
+++ lib/Tooling/Refactoring/Transformer.cpp
@@ -28,6 +28,7 @@
 using namespace tooling;
 
 using ast_matchers::MatchFinder;
+using ast_matchers::internal::DynTypedMatcher;
 using ast_type_traits::ASTNodeKind;
 using ast_type_traits::DynTypedNode;
 using llvm::Error;
@@ -144,9 +145,9 @@
   llvm_unreachable("Unexpected case in NodePart type.");
 }
 
-Expected>
-tooling::translateEdits(const MatchResult ,
-llvm::ArrayRef Edits) {
+Expected>
+tooling::detail::translateEdits(const MatchResult ,
+llvm::ArrayRef Edits) {
   SmallVector Transformations;
   auto  = Result.Nodes.getMap();
   for (const auto  : Edits) {
@@ -171,18 +172,113 @@
   return Transformations;
 }
 
-RewriteRule tooling::makeRule(ast_matchers::internal::DynTypedMatcher M,
+RewriteRule tooling::makeRule(DynTypedMatcher M,
   SmallVector Edits) {
+  return RewriteRule{
+  {RewriteRule::Case{std::move(M), std::move(Edits), nullptr}}};
+}
+
+// Determines whether A is a base type of B in the class hierarchy, including
+// the implicit relationship of Type and QualType.
+static bool isBaseOf(ASTNodeKind A, ASTNodeKind B) {
+  static auto TypeKind = ASTNodeKind::getFromNodeKind();
+  static auto QualKind = ASTNodeKind::getFromNodeKind();
+  /// Mimic the implicit conversions of Matcher<>.
+  /// - From Matcher to Matcher
+  /// - From Matcher to Matcher
+  return (A.isSame(TypeKind) && B.isSame(QualKind)) || A.isBaseOf(B);
+}
+
+// Try to find a common kind to which all of the rule's matchers can be
+// converted.
+static ASTNodeKind
+findCommonKind(const SmallVectorImpl ) {
+  assert(!Cases.empty() && "Rule must have at least one case.");
+  ASTNodeKind JoinKind = Cases[0].Matcher.getSupportedKind();
+  // Find a (least) Kind K, for which M.canConvertTo(K) holds, for all matchers
+  // M in Rules.
+  for (const auto  : Cases) {
+auto K = Case.Matcher.getSupportedKind();
+if (isBaseOf(JoinKind, K)) {
+  JoinKind = K;
+  continue;
+}
+if (K.isSame(JoinKind) || isBaseOf(K, JoinKind))
+  // JoinKind is already the lowest.
+  continue;
+// K and JoinKind are unrelated -- there is no least common kind.
+return ASTNodeKind();
+  }
+  return JoinKind;
+}
+
+// Binds each rule's matcher to a unique (and deterministic) tag based on
+// `TagBase`.
+static std::vector
+taggedMatchers(StringRef TagBase,
+   const SmallVectorImpl ) {
+  std::vector Matchers;
+  Matchers.reserve(Cases.size());
+  size_t count = 0;
+  for (const auto  : Cases) {
+std::string Tag = (TagBase + Twine(count)).str();
+++count;
+auto M = Case.Matcher.tryBind(Tag);
+assert(M && "RewriteRule matchers should be bindable.");
+Matchers.push_back(*std::move(M));
+  }
+  return Matchers;
+}
+
+// Simply gathers the contents of the various rules into a single rule. The
+// actual work to combine these into an ordered choice is deferred to matcher
+// registration.
+RewriteRule tooling::applyFirst(ArrayRef Rules) {
+  RewriteRule R;
+  for (auto  : Rules)
+R.Cases.append(Rule.Cases.begin(), Rule.Cases.end());
+  return R;
+}
+
+static DynTypedMatcher joinCaseMatchers(const RewriteRule ) {
+  assert(!Rule.Cases.empty() && "Rule must have at least one case.");
+  if (Rule.Cases.size() == 1)
+return Rule.Cases[0].Matcher;
+
+  auto CommonKind = findCommonKind(Rule.Cases);
+  assert(!CommonKind.isNone() && "Cases must have compatible matchers.");
+  return DynTypedMatcher::constructVariadic(
+  DynTypedMatcher::VO_AnyOf, CommonKind, taggedMatchers("Tag", Rule.Cases));
+}
+
+DynTypedMatcher tooling::detail::buildMatcher(const RewriteRule ) {
+  DynTypedMatcher M = joinCaseMatchers(Rule);
   M.setAllowBind(true);
   // `tryBind` is guaranteed to succeed, because `AllowBind` was set to true.
-  return RewriteRule{*M.tryBind(RewriteRule::RootId), std::move(Edits),
- nullptr};
+  return *M.tryBind(RewriteRule::RootId);
+}
+
+// Finds the case that was "selected" -- that is, whose matcher triggered the
+// `MatchResult`.
+const RewriteRule::Case &
+tooling::detail::findSelectedCase(const MatchResult ,
+  const RewriteRule ) {
+  if (Rule.Cases.size() == 1)
+return 

r361037 - [LibTooling] Add support to Transformer for composing rules as an ordered choice.

2019-05-17 Thread Yitzhak Mandelbaum via cfe-commits
Author: ymandel
Date: Fri May 17 07:23:33 2019
New Revision: 361037

URL: http://llvm.org/viewvc/llvm-project?rev=361037=rev
Log:
[LibTooling] Add support to Transformer for composing rules as an ordered 
choice.

This revision updates `RewriteRule` to support multiple subrules that are
interpreted as an ordered-choice (apply the first one that matches). With this
feature, users can write the rules that appear later in the list of subrules
knowing that previous rules' patterns *have not matched*, freeing them from
reasoning about those cases in the current pattern.

Reviewers: ilya-biryukov

Subscribers: cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/include/clang/Tooling/Refactoring/Transformer.h
cfe/trunk/lib/Tooling/Refactoring/Transformer.cpp
cfe/trunk/unittests/Tooling/TransformerTest.cpp

Modified: cfe/trunk/include/clang/Tooling/Refactoring/Transformer.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/Transformer.h?rev=361037=361036=361037=diff
==
--- cfe/trunk/include/clang/Tooling/Refactoring/Transformer.h (original)
+++ cfe/trunk/include/clang/Tooling/Refactoring/Transformer.h Fri May 17 
07:23:33 2019
@@ -145,8 +145,8 @@ template  ASTEdit change(std
 
 /// Description of a source-code transformation.
 //
-// A *rewrite rule* describes a transformation of source code. It has the
-// following components:
+// A *rewrite rule* describes a transformation of source code. A simple rule
+// contains each of the following components:
 //
 // * Matcher: the pattern term, expressed as clang matchers (with Transformer
 //   extensions).
@@ -156,30 +156,31 @@ template  ASTEdit change(std
 // * Explanation: explanation of the rewrite.  This will be displayed to the
 //   user, where possible; for example, in clang-tidy diagnostics.
 //
-// Rules have an additional, implicit, component: the parameters. These are
-// portions of the pattern which are left unspecified, yet named so that we can
-// reference them in the replacement term.  The structure of parameters can be
-// partially or even fully specified, in which case they serve just to identify
-// matched nodes for later reference rather than abstract over portions of the
-// AST.  However, in all cases, we refer to named portions of the pattern as
-// parameters.
+// However, rules can also consist of (sub)rules, where the first that matches
+// is applied and the rest are ignored.  So, the above components are gathered
+// as a `Case` and a rule is a list of cases.
+//
+// Rule cases have an additional, implicit, component: the parameters. These 
are
+// portions of the pattern which are left unspecified, yet bound in the pattern
+// so that we can reference them in the edits.
 //
-// The \c Transformer class should be used to apply the rewrite rule and obtain
-// the corresponding replacements.
+// The \c Transformer class can be used to apply the rewrite rule and obtain 
the
+// corresponding replacements.
 struct RewriteRule {
-  // `Matcher` describes the context of this rule. It should always be bound to
-  // at least `RootId`.
-  ast_matchers::internal::DynTypedMatcher Matcher;
-  SmallVector Edits;
-  TextGenerator Explanation;
+  struct Case {
+ast_matchers::internal::DynTypedMatcher Matcher;
+SmallVector Edits;
+TextGenerator Explanation;
+  };
+  // We expect RewriteRules will most commonly include only one case.
+  SmallVector Cases;
 
   // Id used as the default target of each match. The node described by the
   // matcher is should always be bound to this id.
   static constexpr llvm::StringLiteral RootId = "___root___";
 };
 
-/// Convenience function for constructing a \c RewriteRule. Takes care of
-/// binding the matcher to RootId.
+/// Convenience function for constructing a simple \c RewriteRule.
 RewriteRule makeRule(ast_matchers::internal::DynTypedMatcher M,
  SmallVector Edits);
 
@@ -191,12 +192,73 @@ inline RewriteRule makeRule(ast_matchers
   return makeRule(std::move(M), std::move(Edits));
 }
 
+/// Applies the first rule whose pattern matches; other rules are ignored.
+///
+/// N.B. All of the rules must use the same kind of matcher (that is, share a
+/// base class in the AST hierarchy).  However, this constraint is caused by an
+/// implementation detail and should be lifted in the future.
+//
+// `applyFirst` is like an `anyOf` matcher with an edit action attached to each
+// of its cases. Anywhere you'd use `anyOf(m1.bind("id1"), m2.bind("id2"))` and
+// then dispatch on those ids in your code for control flow, `applyFirst` lifts
+// that behavior to the rule level.  So, you can write 
`applyFirst({makeRule(m1,
+// action1), makeRule(m2, action2), ...});`
+//
+// For example, consider a type `T` with a deterministic serialization 
function,
+// `serialize()`.  For performance reasons, we would like to make 

[PATCH] D58035: [clang/DIVar] Emit flag for params that have unchanged values

2019-05-17 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro marked 3 inline comments as done.
djtodoro added inline comments.



Comment at: lib/CodeGen/CGDebugInfo.cpp:4537
+  CGM.getLangOpts().Optimize) {
+for (auto  : DeclCache) {
+  auto *D = SP.first;

aprantl wrote:
> djtodoro wrote:
> > aprantl wrote:
> > > Just looking at the type declarations in CGDebugInfo.h: Why not iterate 
> > > over the `SPCache`  directly? Shouldn't that contain all Function 
> > > declarations only?
> > I tried it, but `SPCache` is empty at this point.
> Where is it emptied? Just grepping through CGDebugInfo did not make this 
> obvious to me.
The `SPCache` actually gets filled only in the case of `CXXMemberFunction`.
In the other cases of `SP` production there is only filling of `DeclCache`.
Should we use it like this or ?



Comment at: lib/CodeGen/CGDebugInfo.cpp:3885
+  if (CGM.getCodeGenOpts().EnableDebugEntryValues &&
+  CGM.getLangOpts().Optimize && ArgNo) {
+if (auto *PD = dyn_cast(VD))

aprantl wrote:
> We shouldn't query CGM.getLangOpts().Optimize. If we don't want this to 
> happen at -O0, we shouldn't set EnableDebugEntryValues at a higher level 
> (Driver, CompilerInvocation, ...) ..Otherwise inevitably someone will query 
> one but not the other and things will go out of sync.
I agree. Thanks!



Comment at: lib/CodeGen/CGDebugInfo.cpp:4535
   DBuilder.retainType(cast(MD));
 
+  if (CGM.getCodeGenOpts().EnableDebugEntryValues &&

aprantl wrote:
> Please add either a top-level comment about what this block is doing or 
> perhaps factor this out into a descriptively named static function.
Sure.


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

https://reviews.llvm.org/D58035



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


[PATCH] D62064: [ASTImporter] Fix unhandled cases in ASTImporterLookupTable

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

In most cases the FriendDecl contains the declaration of the befriended
class as a child node, so it is discovered during the recursive
visitation. However, there are cases when the befriended class is not a
child, thus it must be fetched explicitly from the FriendDecl, and only
then can we add it to the lookup table.
(Note, this does affect only CTU and does not affect LLDB, because we
cannot and do not use the ASTImporterLookupTable in LLDB.)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62064

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTImporterLookupTable.cpp
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -4246,13 +4246,27 @@
   ASSERT_EQ(Res.size(), 0u);
 }
 
+static QualType getUnderlyingType(const TypedefType *TDT) {
+  QualType T = TDT->getDecl()->getUnderlyingType();
+
+  if (const auto *Inner = dyn_cast(T.getTypePtr()))
+return getUnderlyingType(Inner);
+
+  return T;
+}
+
 static const RecordDecl * getRecordDeclOfFriend(FriendDecl *FD) {
   QualType Ty = FD->getFriendType()->getType();
-  QualType NamedTy = cast(Ty)->getNamedType();
-  return cast(NamedTy)->getDecl();
+  if (auto *Inner = dyn_cast(Ty.getTypePtr())) {
+Ty = getUnderlyingType(Inner);
+  }
+  if (isa(Ty))
+Ty = cast(Ty)->getNamedType();
+  return cast(Ty)->getDecl();
 }
 
-TEST_P(ASTImporterLookupTableTest, LookupFindsFwdFriendClassDecl) {
+TEST_P(ASTImporterLookupTableTest,
+   LookupFindsFwdFriendClassDeclWithElaboratedType) {
   TranslationUnitDecl *ToTU = getToTuDecl(
   R"(
   class Y { friend class F; };
@@ -4276,6 +4290,52 @@
   EXPECT_EQ(Res.size(), 0u);
 }
 
+TEST_P(ASTImporterLookupTableTest,
+   LookupFindsFwdFriendClassDeclWithUnelaboratedType) {
+  TranslationUnitDecl *ToTU = getToTuDecl(
+  R"(
+  class F;
+  class Y { friend F; };
+  )",
+  Lang_CXX11);
+
+  // In this case, the CXXRecordDecl is hidden, the FriendDecl is not a parent.
+  // So we must dig up the underlying CXXRecordDecl.
+  ASTImporterLookupTable LT(*ToTU);
+  auto *FriendD = FirstDeclMatcher().match(ToTU, friendDecl());
+  const RecordDecl *RD = getRecordDeclOfFriend(FriendD);
+  auto *Y = FirstDeclMatcher().match(ToTU, cxxRecordDecl(hasName("Y")));
+
+  DeclarationName Name = RD->getDeclName();
+  auto Res = LT.lookup(ToTU, Name);
+  EXPECT_EQ(Res.size(), 1u);
+  EXPECT_EQ(*Res.begin(), RD);
+
+  Res = LT.lookup(Y, Name);
+  EXPECT_EQ(Res.size(), 0u);
+}
+
+TEST_P(ASTImporterLookupTableTest,
+   LookupFindsFriendClassDeclWithTypeAliasDoesNotAssert) {
+  TranslationUnitDecl *ToTU = getToTuDecl(
+  R"(
+  class F;
+  using alias_of_f = F;
+  class Y { friend alias_of_f; };
+  )",
+  Lang_CXX11);
+
+  // ASTImporterLookupTable constructor handles using declarations correctly,
+  // no assert is expected.
+  ASTImporterLookupTable LT(*ToTU);
+
+  auto *Alias = FirstDeclMatcher().match(
+  ToTU, typeAliasDecl(hasName("alias_of_f")));
+  DeclarationName Name = Alias->getDeclName();
+  auto Res = LT.lookup(ToTU, Name);
+  EXPECT_EQ(Res.count(Alias), 1u);
+}
+
 TEST_P(ASTImporterLookupTableTest, LookupFindsFwdFriendClassTemplateDecl) {
   TranslationUnitDecl *ToTU = getToTuDecl(
   R"(
Index: clang/lib/AST/ASTImporterLookupTable.cpp
===
--- clang/lib/AST/ASTImporterLookupTable.cpp
+++ clang/lib/AST/ASTImporterLookupTable.cpp
@@ -26,17 +26,30 @@
 LT.add(D);
 return true;
   }
+  // In most cases the FriendDecl contains the declaration of the befriended
+  // class as a child node, so it is discovered during the recursive
+  // visitation. However, there are cases when the befriended class is not a
+  // child, thus it must be fetched explicitly from the FriendDecl, and only
+  // then can we add it to the lookup table.
   bool VisitFriendDecl(FriendDecl *D) {
 if (D->getFriendType()) {
   QualType Ty = D->getFriendType()->getType();
-  // FIXME Can this be other than elaborated?
-  QualType NamedTy = cast(Ty)->getNamedType();
-  if (!NamedTy->isDependentType()) {
-if (const auto *RTy = dyn_cast(NamedTy))
+  if (isa(Ty))
+Ty = cast(Ty)->getNamedType();
+  // A FriendDecl with a dependent type (e.g. ClassTemplateSpecialization)
+  // always has that decl as child node.
+  // However, there are non-dependent cases which does not have the
+  // type as a child node. We have to dig up that type now.
+  if (!Ty->isDependentType()) {
+if (const auto *RTy = 

[PATCH] D61335: [LibTooling] Add support to Transformer for composing rules as an ordered choice.

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

Synced to HEAD in preparation for committing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61335

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

Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- clang/unittests/Tooling/TransformerTest.cpp
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -116,7 +116,8 @@
 };
   }
 
-  void testRule(RewriteRule Rule, StringRef Input, StringRef Expected) {
+  template 
+  void testRule(R Rule, StringRef Input, StringRef Expected) {
 Transformer T(std::move(Rule), consumer());
 T.registerMatchers();
 compareSnippets(Expected, rewrite(Input));
@@ -147,7 +148,7 @@
  .bind(StringExpr)),
   callee(cxxMethodDecl(hasName("c_str")),
   change("REPLACED"));
-  R.Explanation = text("Use size() method directly on string.");
+  R.Cases[0].Explanation = text("Use size() method directly on string.");
   return R;
 }
 
@@ -375,6 +376,92 @@
Input, Expected);
 }
 
+TEST_F(TransformerTest, OrderedRuleUnrelated) {
+  StringRef Flag = "flag";
+  RewriteRule FlagRule = makeRule(
+  cxxMemberCallExpr(on(expr(hasType(cxxRecordDecl(
+hasName("proto::ProtoCommandLineFlag"
+   .bind(Flag)),
+unless(callee(cxxMethodDecl(hasName("GetProto"),
+  change(Flag, "PROTO"));
+
+  std::string Input = R"cc(
+proto::ProtoCommandLineFlag flag;
+int x = flag.foo();
+int y = flag.GetProto().foo();
+int f(string s) { return strlen(s.c_str()); }
+  )cc";
+  std::string Expected = R"cc(
+proto::ProtoCommandLineFlag flag;
+int x = PROTO.foo();
+int y = flag.GetProto().foo();
+int f(string s) { return REPLACED; }
+  )cc";
+
+  testRule(applyFirst({ruleStrlenSize(), FlagRule}), Input, Expected);
+}
+
+// Version of ruleStrlenSizeAny that inserts a method with a different name than
+// ruleStrlenSize, so we can tell their effect apart.
+RewriteRule ruleStrlenSizeDistinct() {
+  StringRef S;
+  return makeRule(
+  callExpr(callee(functionDecl(hasName("strlen"))),
+   hasArgument(0, cxxMemberCallExpr(
+  on(expr().bind(S)),
+  callee(cxxMethodDecl(hasName("c_str")),
+  change("DISTINCT"));
+}
+
+TEST_F(TransformerTest, OrderedRuleRelated) {
+  std::string Input = R"cc(
+namespace foo {
+struct mystring {
+  char* c_str();
+};
+int f(mystring s) { return strlen(s.c_str()); }
+}  // namespace foo
+int g(string s) { return strlen(s.c_str()); }
+  )cc";
+  std::string Expected = R"cc(
+namespace foo {
+struct mystring {
+  char* c_str();
+};
+int f(mystring s) { return DISTINCT; }
+}  // namespace foo
+int g(string s) { return REPLACED; }
+  )cc";
+
+  testRule(applyFirst({ruleStrlenSize(), ruleStrlenSizeDistinct()}), Input,
+   Expected);
+}
+
+// Change the order of the rules to get a different result.
+TEST_F(TransformerTest, OrderedRuleRelatedSwapped) {
+  std::string Input = R"cc(
+namespace foo {
+struct mystring {
+  char* c_str();
+};
+int f(mystring s) { return strlen(s.c_str()); }
+}  // namespace foo
+int g(string s) { return strlen(s.c_str()); }
+  )cc";
+  std::string Expected = R"cc(
+namespace foo {
+struct mystring {
+  char* c_str();
+};
+int f(mystring s) { return DISTINCT; }
+}  // namespace foo
+int g(string s) { return DISTINCT; }
+  )cc";
+
+  testRule(applyFirst({ruleStrlenSizeDistinct(), ruleStrlenSize()}), Input,
+   Expected);
+}
+
 //
 // Negative tests (where we expect no transformation to occur).
 //
Index: clang/lib/Tooling/Refactoring/Transformer.cpp
===
--- clang/lib/Tooling/Refactoring/Transformer.cpp
+++ clang/lib/Tooling/Refactoring/Transformer.cpp
@@ -28,6 +28,7 @@
 using namespace tooling;
 
 using ast_matchers::MatchFinder;
+using ast_matchers::internal::DynTypedMatcher;
 using ast_type_traits::ASTNodeKind;
 using ast_type_traits::DynTypedNode;
 using llvm::Error;
@@ -144,9 +145,9 @@
   llvm_unreachable("Unexpected case in NodePart type.");
 }
 
-Expected>
-tooling::translateEdits(const MatchResult ,
-llvm::ArrayRef Edits) {
+Expected>
+tooling::detail::translateEdits(const MatchResult ,
+llvm::ArrayRef Edits) {
   SmallVector Transformations;
   auto  = Result.Nodes.getMap();
   for (const auto  : Edits) {
@@ -171,18 +172,113 @@
   return 

[PATCH] D61834: Add a Visit overload for DynTypedNode to ASTNodeTraverser

2019-05-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: unittests/AST/ASTTraverserTest.cpp:75
+
+template  std::string dumpASTString(NodeType &&... N) {
+  std::string Buffer;

steveire wrote:
> aaron.ballman wrote:
> > Did clang-format produce this formatting? (If not, run through 
> > clang-format.)
> Yep, clang-format made it like this.
Weird that it added the extra whitespace -- I think this is the only instance 
where we have whitespace to either side of the adornments, which is what caught 
me by surprise.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D61834



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


[PATCH] D61835: Extract ASTDumper to a header file

2019-05-17 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC361034: Extract ASTDumper to a header file (authored by 
steveire, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D61835?vs=199179=200038#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D61835

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

Index: include/clang/AST/ASTDumper.h
===
--- include/clang/AST/ASTDumper.h
+++ include/clang/AST/ASTDumper.h
@@ -0,0 +1,56 @@
+//===--- ASTDumper.h - Dumping implementation for ASTs ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_AST_ASTDUMPER_H
+#define LLVM_CLANG_AST_ASTDUMPER_H
+
+#include "clang/AST/ASTNodeTraverser.h"
+#include "clang/AST/TextNodeDumper.h"
+
+namespace clang {
+
+class ASTDumper : public ASTNodeTraverser {
+
+  TextNodeDumper NodeDumper;
+
+  raw_ostream 
+
+  const bool ShowColors;
+
+public:
+  ASTDumper(raw_ostream , const comments::CommandTraits *Traits,
+const SourceManager *SM)
+  : ASTDumper(OS, Traits, SM, SM && SM->getDiagnostics().getShowColors()) {}
+
+  ASTDumper(raw_ostream , const comments::CommandTraits *Traits,
+const SourceManager *SM, bool ShowColors)
+  : ASTDumper(OS, Traits, SM, ShowColors, LangOptions()) {}
+  ASTDumper(raw_ostream , const comments::CommandTraits *Traits,
+const SourceManager *SM, bool ShowColors,
+const PrintingPolicy )
+  : NodeDumper(OS, ShowColors, SM, PrintPolicy, Traits), OS(OS),
+ShowColors(ShowColors) {}
+
+  TextNodeDumper () { return NodeDumper; }
+
+  void dumpLookups(const DeclContext *DC, bool DumpDecls);
+
+  template 
+  void dumpTemplateDeclSpecialization(const SpecializationDecl *D,
+  bool DumpExplicitInst, bool DumpRefOnly);
+  template 
+  void dumpTemplateDecl(const TemplateDecl *D, bool DumpExplicitInst);
+
+  void VisitFunctionTemplateDecl(const FunctionTemplateDecl *D);
+  void VisitClassTemplateDecl(const ClassTemplateDecl *D);
+  void VisitVarTemplateDecl(const VarTemplateDecl *D);
+};
+
+} // namespace clang
+
+#endif
Index: lib/AST/ASTDumper.cpp
===
--- lib/AST/ASTDumper.cpp
+++ lib/AST/ASTDumper.cpp
@@ -11,11 +11,10 @@
 //
 //===--===//
 
+#include "clang/AST/ASTDumper.h"
 #include "clang/AST/ASTContext.h"
-#include "clang/AST/ASTNodeTraverser.h"
 #include "clang/AST/DeclLookups.h"
 #include "clang/AST/JSONNodeDumper.h"
-#include "clang/AST/TextNodeDumper.h"
 #include "clang/Basic/Builtins.h"
 #include "clang/Basic/Module.h"
 #include "clang/Basic/SourceManager.h"
@@ -23,50 +22,6 @@
 using namespace clang;
 using namespace clang::comments;
 
-//===--===//
-// ASTDumper Visitor
-//===--===//
-
-namespace  {
-
-class ASTDumper : public ASTNodeTraverser {
-
-  TextNodeDumper NodeDumper;
-
-  raw_ostream 
-
-  const bool ShowColors;
-
-public:
-  ASTDumper(raw_ostream , const CommandTraits *Traits,
-const SourceManager *SM)
-  : ASTDumper(OS, Traits, SM, SM && SM->getDiagnostics().getShowColors()) {}
-
-  ASTDumper(raw_ostream , const CommandTraits *Traits,
-const SourceManager *SM, bool ShowColors)
-  : ASTDumper(OS, Traits, SM, ShowColors, LangOptions()) {}
-  ASTDumper(raw_ostream , const CommandTraits *Traits,
-const SourceManager *SM, bool ShowColors,
-const PrintingPolicy )
-  : NodeDumper(OS, ShowColors, SM, PrintPolicy, Traits), OS(OS),
-ShowColors(ShowColors) {}
-
-  TextNodeDumper () { return NodeDumper; }
-
-  void dumpLookups(const DeclContext *DC, bool DumpDecls);
-
-  template 
-  void dumpTemplateDeclSpecialization(const SpecializationDecl *D,
-  bool DumpExplicitInst, bool DumpRefOnly);
-  template 
-  void dumpTemplateDecl(const TemplateDecl *D, bool DumpExplicitInst);
-
-  void VisitFunctionTemplateDecl(const FunctionTemplateDecl *D);
-  void VisitClassTemplateDecl(const ClassTemplateDecl *D);
-  void VisitVarTemplateDecl(const VarTemplateDecl *D);
-};
-} // namespace
-
 void ASTDumper::dumpLookups(const DeclContext *DC, bool DumpDecls) {
   NodeDumper.AddChild([=] {
 OS << "StoredDeclsMap ";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D61835: Extract ASTDumper to a header file

2019-05-17 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

Great, thanks.

I'm going to investigate whether we can move the `dump` method implementations 
to their respective class files, and then look into a rename for this to 
`StreamNodeDumper` or so (name tbd).


Repository:
  rC Clang

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

https://reviews.llvm.org/D61835



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


[PATCH] D61508: [clang-tidy] bugprone-header-guard : a simple version of llvm-header-guard

2019-05-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/bugprone/HeaderGuardCheck.cpp:50
+
+  } else {
+if (OldGuard.size())

I think this should be an `else if` rather than an `else`. I'd like to see us 
diagnose unknown guard styles so that we only accept "llvm" and "" as guard 
styles; this makes it easier to add new guard styles in the future.



Comment at: docs/clang-tidy/checks/bugprone-header-guard.rst:11
+
+.. option:: HeaderFileExtensions
+

Should we be documenting the `GuardStyle` option here as well? We could 
document "llvm" as the only available option currently and mention the 
llvm-header-guard check as an alias which enables this style.



Comment at: test/clang-tidy/bugprone-header-guard.cpp:1-3
+// RUN: %check_clang_tidy %s bugprone-header-guard %t -- \
+// RUN:   -config="{CheckOptions: [{key: 
bugprone-header-guard.HeaderFileExtensions, value: 'cpp'}]}" \
+// RUN:   -header-filter=.* --

Can you add a test for the `GuardStyle` option? Both when specifying `llvm` and 
some random unsupported string.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D61508



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


Re: r361011 - [analyzer] Validate checker option names and values

2019-05-17 Thread Kristof Umann via cfe-commits
I'll take a look.


From: Nico Weber 
Sent: 17 May 2019 15:09:18
To: Kristof Umann
Cc: cfe-commits
Subject: Re: r361011 - [analyzer] Validate checker option names and values

It looks like this change is making gcc-7 crash on these (and other 
http://lab.llvm.org:8011/console) bots:

http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/18639
http://lab.llvm.org:8011/builders/clang-ppc64be-linux/builds/33837/

[100/212] Building CXX object 
tools/clang/unittests/AST/CMakeFiles/ASTTests.dir/ASTImporterTest.cpp.o
FAILED: tools/clang/unittests/AST/CMakeFiles/ASTTests.dir/ASTImporterTest.cpp.o
...
g++-7: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.
[101/212] Building CXX object 
tools/clang/unittests/ASTMatchers/CMakeFiles/ASTMatchersTests.dir/ASTMatchersTraversalTest.cpp.o
FAILED: 
tools/clang/unittests/ASTMatchers/CMakeFiles/ASTMatchersTests.dir/ASTMatchersTraversalTest.cpp.o
...
g++-7: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.
[102/212] Building CXX object 
tools/clang/unittests/ASTMatchers/CMakeFiles/ASTMatchersTests.dir/ASTMatchersNarrowingTest.cpp.o
FAILED: 
tools/clang/unittests/ASTMatchers/CMakeFiles/ASTMatchersTests.dir/ASTMatchersNarrowingTest.cpp.o
...
g++-7: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.
[103/212] Building CXX object 
tools/clang/unittests/ASTMatchers/CMakeFiles/ASTMatchersTests.dir/ASTMatchersNodeTest.cpp.o
FAILED: 
tools/clang/unittests/ASTMatchers/CMakeFiles/ASTMatchersTests.dir/ASTMatchersNodeTest.cpp.o
...
g++-7: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.
[104/212] Building CXX object 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/CommentHandlerTest.cpp.o
FAILED: 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/CommentHandlerTest.cpp.o
...
g++-7: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.
[105/212] Building CXX object 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/ExecutionTest.cpp.o
FAILED: 
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/ExecutionTest.cpp.o
...
g++-7: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.
[106/212] Building CXX object 
tools/clang/unittests/AST/CMakeFiles/ASTTests.dir/ASTImporterVisibilityTest.cpp.o
FAILED: 
tools/clang/unittests/AST/CMakeFiles/ASTTests.dir/ASTImporterVisibilityTest.cpp.o
...
g++-7: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.

From: Kristof Umann via cfe-commits 
mailto:cfe-commits@lists.llvm.org>>
Date: Fri, May 17, 2019 at 5:49 AM
To: mailto:cfe-commits@lists.llvm.org>>

Author: szelethus
Date: Fri May 17 02:51:59 2019
New Revision: 361011

URL: http://llvm.org/viewvc/llvm-project?rev=361011=rev
Log:
[analyzer] Validate checker option names and values

Validate whether the option exists, and also whether the supplied value is of
the correct type. With this patch, invoking the analyzer should be, at least
in the frontend mode, a lot safer.

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
cfe/trunk/test/Analysis/checker-plugins.c
cfe/trunk/test/Analysis/invalid-checker-option.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=361011=361010=361011=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Fri May 17 02:51:59 
2019
@@ -307,6 +307,8 @@ def err_analyzer_config_multiple_values
 def err_analyzer_config_invalid_input : Error<
   "invalid input for analyzer-config option '%0', that expects %1 value">;
 def err_analyzer_config_unknown : Error<"unknown analyzer-config '%0'">;
+def err_analyzer_checker_option_unknown : Error<
+  "checker '%0' has no option called '%1'">;
 def err_analyzer_checker_option_invalid_input : Error<
   "invalid input for checker option '%0', that expects %1">;


Modified: cfe/trunk/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
URL: 

r361034 - Extract ASTDumper to a header file

2019-05-17 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Fri May 17 06:59:15 2019
New Revision: 361034

URL: http://llvm.org/viewvc/llvm-project?rev=361034=rev
Log:
Extract ASTDumper to a header file

Summary:
This class has member APIs which are useful to clients.  Make it
possible to use those APIs without adding them to dump() member
functions.  Doing so does not scale.  The optional arguments to dump()
should be designed to be useful in a debugging context.

Reviewers: aaron.ballman

Subscribers: cfe-commits

Tags: #clang

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

Added:
cfe/trunk/include/clang/AST/ASTDumper.h
Modified:
cfe/trunk/lib/AST/ASTDumper.cpp

Added: cfe/trunk/include/clang/AST/ASTDumper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTDumper.h?rev=361034=auto
==
--- cfe/trunk/include/clang/AST/ASTDumper.h (added)
+++ cfe/trunk/include/clang/AST/ASTDumper.h Fri May 17 06:59:15 2019
@@ -0,0 +1,56 @@
+//===--- ASTDumper.h - Dumping implementation for ASTs 
===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_AST_ASTDUMPER_H
+#define LLVM_CLANG_AST_ASTDUMPER_H
+
+#include "clang/AST/ASTNodeTraverser.h"
+#include "clang/AST/TextNodeDumper.h"
+
+namespace clang {
+
+class ASTDumper : public ASTNodeTraverser {
+
+  TextNodeDumper NodeDumper;
+
+  raw_ostream 
+
+  const bool ShowColors;
+
+public:
+  ASTDumper(raw_ostream , const comments::CommandTraits *Traits,
+const SourceManager *SM)
+  : ASTDumper(OS, Traits, SM, SM && SM->getDiagnostics().getShowColors()) 
{}
+
+  ASTDumper(raw_ostream , const comments::CommandTraits *Traits,
+const SourceManager *SM, bool ShowColors)
+  : ASTDumper(OS, Traits, SM, ShowColors, LangOptions()) {}
+  ASTDumper(raw_ostream , const comments::CommandTraits *Traits,
+const SourceManager *SM, bool ShowColors,
+const PrintingPolicy )
+  : NodeDumper(OS, ShowColors, SM, PrintPolicy, Traits), OS(OS),
+ShowColors(ShowColors) {}
+
+  TextNodeDumper () { return NodeDumper; }
+
+  void dumpLookups(const DeclContext *DC, bool DumpDecls);
+
+  template 
+  void dumpTemplateDeclSpecialization(const SpecializationDecl *D,
+  bool DumpExplicitInst, bool DumpRefOnly);
+  template 
+  void dumpTemplateDecl(const TemplateDecl *D, bool DumpExplicitInst);
+
+  void VisitFunctionTemplateDecl(const FunctionTemplateDecl *D);
+  void VisitClassTemplateDecl(const ClassTemplateDecl *D);
+  void VisitVarTemplateDecl(const VarTemplateDecl *D);
+};
+
+} // namespace clang
+
+#endif

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=361034=361033=361034=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Fri May 17 06:59:15 2019
@@ -11,11 +11,10 @@
 //
 
//===--===//
 
+#include "clang/AST/ASTDumper.h"
 #include "clang/AST/ASTContext.h"
-#include "clang/AST/ASTNodeTraverser.h"
 #include "clang/AST/DeclLookups.h"
 #include "clang/AST/JSONNodeDumper.h"
-#include "clang/AST/TextNodeDumper.h"
 #include "clang/Basic/Builtins.h"
 #include "clang/Basic/Module.h"
 #include "clang/Basic/SourceManager.h"
@@ -23,50 +22,6 @@
 using namespace clang;
 using namespace clang::comments;
 
-//===--===//
-// ASTDumper Visitor
-//===--===//
-
-namespace  {
-
-class ASTDumper : public ASTNodeTraverser {
-
-  TextNodeDumper NodeDumper;
-
-  raw_ostream 
-
-  const bool ShowColors;
-
-public:
-  ASTDumper(raw_ostream , const CommandTraits *Traits,
-const SourceManager *SM)
-  : ASTDumper(OS, Traits, SM, SM && SM->getDiagnostics().getShowColors()) 
{}
-
-  ASTDumper(raw_ostream , const CommandTraits *Traits,
-const SourceManager *SM, bool ShowColors)
-  : ASTDumper(OS, Traits, SM, ShowColors, LangOptions()) {}
-  ASTDumper(raw_ostream , const CommandTraits *Traits,
-const SourceManager *SM, bool ShowColors,
-const PrintingPolicy )
-  : NodeDumper(OS, ShowColors, SM, PrintPolicy, Traits), OS(OS),
-ShowColors(ShowColors) {}
-
-  TextNodeDumper () { return NodeDumper; }
-
-  void dumpLookups(const DeclContext *DC, bool DumpDecls);
-
-  template 
-  void dumpTemplateDeclSpecialization(const SpecializationDecl *D,
-  bool DumpExplicitInst, bool DumpRefOnly);
-  

[PATCH] D61834: Add a Visit overload for DynTypedNode to ASTNodeTraverser

2019-05-17 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
steveire marked an inline comment as done.
Closed by commit rL361033: Add a Visit overload for DynTypedNode to 
ASTNodeTraverser (authored by steveire, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D61834?vs=12=200036#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D61834

Files:
  cfe/trunk/include/clang/AST/ASTNodeTraverser.h
  cfe/trunk/unittests/AST/ASTTraverserTest.cpp
  cfe/trunk/unittests/AST/CMakeLists.txt

Index: cfe/trunk/unittests/AST/CMakeLists.txt
===
--- cfe/trunk/unittests/AST/CMakeLists.txt
+++ cfe/trunk/unittests/AST/CMakeLists.txt
@@ -12,6 +12,7 @@
   ASTImporterTest.cpp
   ASTImporterGenericRedeclTest.cpp
   ASTImporterVisibilityTest.cpp
+  ASTTraverserTest.cpp
   ASTTypeTraitsTest.cpp
   ASTVectorTest.cpp
   CommentLexer.cpp
Index: cfe/trunk/unittests/AST/ASTTraverserTest.cpp
===
--- cfe/trunk/unittests/AST/ASTTraverserTest.cpp
+++ cfe/trunk/unittests/AST/ASTTraverserTest.cpp
@@ -0,0 +1,220 @@
+//===- unittests/AST/ASTTraverserTest.h===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/ASTNodeTraverser.h"
+#include "clang/AST/TextNodeDumper.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/Tooling.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using namespace clang::tooling;
+using namespace clang::ast_matchers;
+
+namespace clang {
+
+class NodeTreePrinter : public TextTreeStructure {
+  llvm::raw_ostream 
+
+public:
+  NodeTreePrinter(llvm::raw_ostream )
+  : TextTreeStructure(OS, /* showColors */ false), OS(OS) {}
+
+  void Visit(const Decl *D) { OS << D->getDeclKindName() << "Decl"; }
+
+  void Visit(const Stmt *S) { OS << S->getStmtClassName(); }
+
+  void Visit(QualType QT) {
+OS << "QualType " << QT.split().Quals.getAsString();
+  }
+
+  void Visit(const Type *T) { OS << T->getTypeClassName() << "Type"; }
+
+  void Visit(const comments::Comment *C, const comments::FullComment *FC) {
+OS << C->getCommentKindName();
+  }
+
+  void Visit(const CXXCtorInitializer *Init) { OS << "CXXCtorInitializer"; }
+
+  void Visit(const Attr *A) {
+switch (A->getKind()) {
+#define ATTR(X)\
+  case attr::X:\
+OS << #X;  \
+break;
+#include "clang/Basic/AttrList.inc"
+}
+OS << "Attr";
+  }
+
+  void Visit(const OMPClause *C) { OS << "OMPClause"; }
+  void Visit(const TemplateArgument , SourceRange R = {},
+ const Decl *From = nullptr, const char *Label = nullptr) {
+OS << "TemplateArgument";
+  }
+
+  template  void Visit(T...) {}
+};
+
+class TestASTDumper : public ASTNodeTraverser {
+
+  NodeTreePrinter MyNodeRecorder;
+
+public:
+  TestASTDumper(llvm::raw_ostream ) : MyNodeRecorder(OS) {}
+  NodeTreePrinter () { return MyNodeRecorder; }
+};
+
+template  std::string dumpASTString(NodeType &&... N) {
+  std::string Buffer;
+  llvm::raw_string_ostream OS(Buffer);
+
+  TestASTDumper Dumper(OS);
+
+  OS << "\n";
+
+  Dumper.Visit(std::forward(N)...);
+
+  return OS.str();
+}
+
+const FunctionDecl *getFunctionNode(clang::ASTUnit *AST,
+const std::string ) {
+  auto Result = ast_matchers::match(functionDecl(hasName(Name)).bind("fn"),
+AST->getASTContext());
+  EXPECT_EQ(Result.size(), 1u);
+  return Result[0].getNodeAs("fn");
+}
+
+template  struct Verifier {
+  static void withDynNode(T Node, const std::string ) {
+EXPECT_EQ(dumpASTString(ast_type_traits::DynTypedNode::create(Node)),
+  DumpString);
+  }
+};
+
+template  struct Verifier {
+  static void withDynNode(T *Node, const std::string ) {
+EXPECT_EQ(dumpASTString(ast_type_traits::DynTypedNode::create(*Node)),
+  DumpString);
+  }
+};
+
+template 
+void verifyWithDynNode(T Node, const std::string ) {
+  EXPECT_EQ(dumpASTString(Node), DumpString);
+
+  Verifier::withDynNode(Node, DumpString);
+}
+
+TEST(Traverse, Dump) {
+
+  auto AST = buildASTFromCode(R"cpp(
+struct A {
+  int m_number;
+
+  /// CTor
+  A() : m_number(42) {}
+
+  [[nodiscard]] const int func() {
+return 42;
+  }
+
+};
+
+template
+struct templ
+{ 
+};
+

[PATCH] D61834: Add a Visit overload for DynTypedNode to ASTNodeTraverser

2019-05-17 Thread Stephen Kelly via Phabricator via cfe-commits
steveire marked 5 inline comments as done.
steveire added inline comments.



Comment at: unittests/AST/ASTTraverserTest.cpp:75
+
+template  std::string dumpASTString(NodeType &&... N) {
+  std::string Buffer;

aaron.ballman wrote:
> Did clang-format produce this formatting? (If not, run through clang-format.)
Yep, clang-format made it like this.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61834



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


r361033 - Add a Visit overload for DynTypedNode to ASTNodeTraverser

2019-05-17 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Fri May 17 06:55:28 2019
New Revision: 361033

URL: http://llvm.org/viewvc/llvm-project?rev=361033=rev
Log:
Add a Visit overload for DynTypedNode to ASTNodeTraverser

Reviewers: aaron.ballman

Subscribers: cfe-commits

Tags: #clang

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

Added:
cfe/trunk/unittests/AST/ASTTraverserTest.cpp
Modified:
cfe/trunk/include/clang/AST/ASTNodeTraverser.h
cfe/trunk/unittests/AST/CMakeLists.txt

Modified: cfe/trunk/include/clang/AST/ASTNodeTraverser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTNodeTraverser.h?rev=361033=361032=361033=diff
==
--- cfe/trunk/include/clang/AST/ASTNodeTraverser.h (original)
+++ cfe/trunk/include/clang/AST/ASTNodeTraverser.h Fri May 17 06:55:28 2019
@@ -205,6 +205,24 @@ public:
 });
   }
 
+  void Visit(const ast_type_traits::DynTypedNode ) {
+// FIXME: Improve this with a switch or a visitor pattern.
+if (const auto *D = N.get())
+  Visit(D);
+else if (const auto *S = N.get())
+  Visit(S);
+else if (const auto *QT = N.get())
+  Visit(*QT);
+else if (const auto *T = N.get())
+  Visit(T);
+else if (const auto *C = N.get())
+  Visit(C);
+else if (const auto *C = N.get())
+  Visit(C);
+else if (const auto *T = N.get())
+  Visit(*T);
+  }
+
   void dumpDeclContext(const DeclContext *DC) {
 if (!DC)
   return;

Added: cfe/trunk/unittests/AST/ASTTraverserTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/ASTTraverserTest.cpp?rev=361033=auto
==
--- cfe/trunk/unittests/AST/ASTTraverserTest.cpp (added)
+++ cfe/trunk/unittests/AST/ASTTraverserTest.cpp Fri May 17 06:55:28 2019
@@ -0,0 +1,220 @@
+//===- 
unittests/AST/ASTTraverserTest.h===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/ASTNodeTraverser.h"
+#include "clang/AST/TextNodeDumper.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/Tooling.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using namespace clang::tooling;
+using namespace clang::ast_matchers;
+
+namespace clang {
+
+class NodeTreePrinter : public TextTreeStructure {
+  llvm::raw_ostream 
+
+public:
+  NodeTreePrinter(llvm::raw_ostream )
+  : TextTreeStructure(OS, /* showColors */ false), OS(OS) {}
+
+  void Visit(const Decl *D) { OS << D->getDeclKindName() << "Decl"; }
+
+  void Visit(const Stmt *S) { OS << S->getStmtClassName(); }
+
+  void Visit(QualType QT) {
+OS << "QualType " << QT.split().Quals.getAsString();
+  }
+
+  void Visit(const Type *T) { OS << T->getTypeClassName() << "Type"; }
+
+  void Visit(const comments::Comment *C, const comments::FullComment *FC) {
+OS << C->getCommentKindName();
+  }
+
+  void Visit(const CXXCtorInitializer *Init) { OS << "CXXCtorInitializer"; }
+
+  void Visit(const Attr *A) {
+switch (A->getKind()) {
+#define ATTR(X)
\
+  case attr::X:
\
+OS << #X;  
\
+break;
+#include "clang/Basic/AttrList.inc"
+}
+OS << "Attr";
+  }
+
+  void Visit(const OMPClause *C) { OS << "OMPClause"; }
+  void Visit(const TemplateArgument , SourceRange R = {},
+ const Decl *From = nullptr, const char *Label = nullptr) {
+OS << "TemplateArgument";
+  }
+
+  template  void Visit(T...) {}
+};
+
+class TestASTDumper : public ASTNodeTraverser {
+
+  NodeTreePrinter MyNodeRecorder;
+
+public:
+  TestASTDumper(llvm::raw_ostream ) : MyNodeRecorder(OS) {}
+  NodeTreePrinter () { return MyNodeRecorder; }
+};
+
+template  std::string dumpASTString(NodeType &&... N) {
+  std::string Buffer;
+  llvm::raw_string_ostream OS(Buffer);
+
+  TestASTDumper Dumper(OS);
+
+  OS << "\n";
+
+  Dumper.Visit(std::forward(N)...);
+
+  return OS.str();
+}
+
+const FunctionDecl *getFunctionNode(clang::ASTUnit *AST,
+const std::string ) {
+  auto Result = ast_matchers::match(functionDecl(hasName(Name)).bind("fn"),
+AST->getASTContext());
+  EXPECT_EQ(Result.size(), 1u);
+  return Result[0].getNodeAs("fn");
+}
+
+template  struct Verifier {
+  static void withDynNode(T Node, const std::string ) {
+EXPECT_EQ(dumpASTString(ast_type_traits::DynTypedNode::create(Node)),
+  DumpString);
+  }
+};
+
+template 

[PATCH] D59628: Add support for __attribute__((objc_class_stub))

2019-05-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:292
+  // "LangOpts" bound.
+  string CustomCode = customCode;
 }

If this is code, should it be using a `code` type rather than a `string` type?



Comment at: clang/include/clang/Basic/AttrDocs.td:1101
+implementations defined for them. This attribute is intended for use in
+Swift generated headers for classes defined in Swift.
+

Swift generated -> Swift-generated



Comment at: clang/lib/CodeGen/CGObjCMac.cpp:736
+llvm::Type *params[] = { Int8PtrPtrTy };
+auto F = CGM.CreateRuntimeFunction(
+llvm::FunctionType::get(ClassnfABIPtrTy, params, false),

Please spell the type out explicitly rather than use `auto` here.



Comment at: clang/lib/CodeGen/CGObjCMac.cpp:7325
NotForDefinition);
+  assert(ClassGV->getType() == ObjCTypes.ClassnfABIPtrTy);
 }

Can you add a message to this assertion so that when it triggers, users get 
something more helpful to report?



Comment at: clang/lib/CodeGen/CGObjCMac.cpp:7366
   if (!Entry) {
-auto ClassGV = GetClassGlobal(ID, /*metaclass*/ false, NotForDefinition);
+auto ClassGV = GetClassGlobalForClassRef(ID);
 std::string SectionName =

Can you spell out the type here, since you're changing the initialization 
already?



Comment at: clang/lib/CodeGen/CGObjCMac.cpp:7410-7411
   if (ID->isWeakImported()) {
-auto ClassGV = GetClassGlobal(ID, /*metaclass*/ false, NotForDefinition);
+llvm::Constant *ClassGV = GetClassGlobal(ID, /*metaclass*/ false,
+ NotForDefinition);
 (void)ClassGV;

I'm not opposed to this change, but it seems unrelated to the patch. Feel free 
to commit separately as an NFC.


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

https://reviews.llvm.org/D59628



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


r361032 - Fix Wdocumentation warnings. NFCI.

2019-05-17 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Fri May 17 06:42:16 2019
New Revision: 361032

URL: http://llvm.org/viewvc/llvm-project?rev=361032=rev
Log:
Fix Wdocumentation warnings. NFCI.

Modified:
cfe/trunk/include/clang/Sema/Sema.h

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=361032=361031=361032=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri May 17 06:42:16 2019
@@ -4618,11 +4618,7 @@ public:
 SourceLocation BuiltinLoc,
 SourceLocation RPLoc);
 
-  /// Build a potentially resolved SourceLocExpr.
-  ///
-  /// \param SubExpr - null when the SourceLocExpr is unresolved, otherwise
-  /// SubExpr will be a literal expression representing the value of the
-  /// builtin call.
+  // Build a potentially resolved SourceLocExpr.
   ExprResult BuildSourceLocExpr(SourceLocExpr::IdentKind Kind,
 SourceLocation BuiltinLoc, SourceLocation 
RPLoc,
 DeclContext *ParentContext);


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


[PATCH] D61834: Add a Visit overload for DynTypedNode to ASTNodeTraverser

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

In D61834#1505418 , @steveire wrote:

> In D61834#1505124 , @aaron.ballman 
> wrote:
>
> > In D61834#1505056 , @steveire 
> > wrote:
> >
> > > In D61834#1504665 , 
> > > @aaron.ballman wrote:
> > >
> > > > What will be making use of/testing this new functionality?
> > >
> > >
> > > Any code which has a `DynTypedNode` and wishes to traverse it.
> > >
> > > I envisage this as a more-flexible `DynTypedNode::dump` that the user 
> > > does not have to implement themselves in order to use the 
> > > `ASTNodeTraverser`.
> >
> >
> > Do we currently have any such code that's using this functionality, though? 
> > I'm mostly concerned that this is dead code with no testing, currently. The 
> > functionality itself seems reasonable enough and the code looks correct 
> > enough, so if this is part of a series of planned changes, that'd be good 
> > information to have for the review.
>
>
> Ah, yes. This is supposed to be 'useful public API' like the other Visit 
> methods for use inside and outside the codebase. A follow-up patch will use 
> it, but it's provided for external use too anyway.
>
> I'll add a unit test.


Ahh, thank you! It makes a lot more sense to me now. LGTM aside from some nits.




Comment at: include/clang/AST/ASTNodeTraverser.h:208
 
+  void Visit(const ast_type_traits::DynTypedNode ) {
+if (const auto *D = N.get())

Can you add a comment here: `// FIXME: Improve this with a switch or a visitor 
pattern.` (We have a similar comment in similar-looking code in 
ASTMatchFinder.cpp:476.)



Comment at: unittests/AST/ASTTraverserTest.cpp:75
+
+template  std::string dumpASTString(NodeType &&... N) {
+  std::string Buffer;

Did clang-format produce this formatting? (If not, run through clang-format.)



Comment at: unittests/AST/ASTTraverserTest.cpp:89
+const FunctionDecl *getFunctionNode(clang::ASTUnit *AST,
+const std::string ) {
+  auto Result = ast_matchers::match(functionDecl(hasName(name)).bind("fn"),

`Name` instead



Comment at: unittests/AST/ASTTraverserTest.cpp:97
+template  struct Verifier {
+  static void withDynNode(T Node, const std::string ) {
+EXPECT_EQ(dumpASTString(ast_type_traits::DynTypedNode::create(Node)),

`DumpString` -- same elsewhere.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61834



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


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

2019-05-17 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

@dexonsmith Can you take a look at this patch or recommend someone who can 
review it?  Many thanks. --Melanie


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

https://reviews.llvm.org/D61743



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


[PATCH] D61333: [ASTImporter] Fix LLDB lookup in transparent ctx and with ext src

2019-05-17 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 200033.
martong added a comment.

- se -> so


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61333

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp
  lldb/packages/Python/lldbsuite/test/lang/c/ast/Makefile
  lldb/packages/Python/lldbsuite/test/lang/c/ast/TestAST.py
  lldb/packages/Python/lldbsuite/test/lang/c/ast/main.c
  lldb/packages/Python/lldbsuite/test/lang/c/modules/main.c
  lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp

Index: lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
@@ -637,18 +637,6 @@
 
 m_ast_importer_sp->RequireCompleteType(copied_field_type);
   }
-
-  DeclContext *decl_context_non_const =
-  const_cast(decl_context);
-
-  if (copied_decl->getDeclContext() != decl_context) {
-if (copied_decl->getDeclContext()->containsDecl(copied_decl))
-  copied_decl->getDeclContext()->removeDecl(copied_decl);
-copied_decl->setDeclContext(decl_context_non_const);
-  }
-
-  if (!decl_context_non_const->containsDecl(copied_decl))
-decl_context_non_const->addDeclInternal(copied_decl);
 }
   }
 
Index: lldb/packages/Python/lldbsuite/test/lang/c/modules/main.c
===
--- lldb/packages/Python/lldbsuite/test/lang/c/modules/main.c
+++ lldb/packages/Python/lldbsuite/test/lang/c/modules/main.c
@@ -5,11 +5,11 @@
 typedef struct {
 int a;
 int b;
-} FILE;
+} MYFILE;
 
 int main()
 {
-FILE *myFile = malloc(sizeof(FILE));
+MYFILE *myFile = malloc(sizeof(MYFILE));
 
 myFile->a = 5;
 myFile->b = 9;
Index: lldb/packages/Python/lldbsuite/test/lang/c/ast/main.c
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/lang/c/ast/main.c
@@ -0,0 +1,5 @@
+int main()
+{
+int a = 0; // Set breakpoint 0 here.
+return 0;
+}
Index: lldb/packages/Python/lldbsuite/test/lang/c/ast/TestAST.py
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/lang/c/ast/TestAST.py
@@ -0,0 +1,77 @@
+"""Test that importing modules in C works as expected."""
+
+from __future__ import print_function
+
+
+from distutils.version import StrictVersion
+import os
+import time
+import platform
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class CModulesTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@skipIfFreeBSD
+@skipIfLinux
+@skipIfWindows
+@skipIfNetBSD
+@skipIf(macos_version=["<", "10.12"])
+def test_expr(self):
+self.build()
+exe = self.getBuildArtifact("a.out")
+self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+lldbutil.run_break_set_by_file_and_line(
+self, "main.c", self.line, num_expected_locations=1, loc_exact=True)
+
+self.runCmd("run", RUN_SUCCEEDED)
+
+# The stop reason of the thread should be breakpoint.
+self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+substrs=['stopped',
+ 'stop reason = breakpoint'])
+
+# The breakpoint should have a hit count of 1.
+self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
+substrs=[' resolved, hit count = 1'])
+
+# Enable logging of the imported AST.
+log_file = os.path.join(self.getBuildDir(), "lldb-ast-log.txt")
+self.runCmd("log enable lldb ast -f '%s'" % log_file)
+
+self.expect(
+"expr -l objc++ -- @import Darwin; 3",
+VARIABLES_DISPLAYED_CORRECTLY,
+substrs=[
+"int",
+"3"])
+
+# This expr command imports __sFILE with definition
+# (FILE is a typedef to __sFILE.)
+self.expect(
+"expr *fopen(\"/dev/zero\", \"w\")",
+VARIABLES_DISPLAYED_CORRECTLY,
+substrs=[
+"FILE",
+"_close"]
+)
+
+# Check that the AST log contains exactly one definition of __sFILE.
+f = open(log_file)
+log_lines = f.readlines()
+f.close()
+os.remove(log_file)
+self.assertEqual(" ".join(log_lines).count("struct __sFILE definition"), 1)
+
+def setUp(self):
+# Call super's setUp().
+TestBase.setUp(self)
+# Find the line number to break inside main().
+self.line = line_number('main.c', '// Set breakpoint 0 here.')
Index: lldb/packages/Python/lldbsuite/test/lang/c/ast/Makefile

[PATCH] D61333: [ASTImporter] Fix LLDB lookup in transparent ctx and with ext src

2019-05-17 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 200031.
martong added a comment.

- Rebase to master
- Rebase to D62061 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61333

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp
  lldb/packages/Python/lldbsuite/test/lang/c/ast/Makefile
  lldb/packages/Python/lldbsuite/test/lang/c/ast/TestAST.py
  lldb/packages/Python/lldbsuite/test/lang/c/ast/main.c
  lldb/packages/Python/lldbsuite/test/lang/c/modules/main.c
  lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp

Index: lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
@@ -637,18 +637,6 @@
 
 m_ast_importer_sp->RequireCompleteType(copied_field_type);
   }
-
-  DeclContext *decl_context_non_const =
-  const_cast(decl_context);
-
-  if (copied_decl->getDeclContext() != decl_context) {
-if (copied_decl->getDeclContext()->containsDecl(copied_decl))
-  copied_decl->getDeclContext()->removeDecl(copied_decl);
-copied_decl->setDeclContext(decl_context_non_const);
-  }
-
-  if (!decl_context_non_const->containsDecl(copied_decl))
-decl_context_non_const->addDeclInternal(copied_decl);
 }
   }
 
Index: lldb/packages/Python/lldbsuite/test/lang/c/modules/main.c
===
--- lldb/packages/Python/lldbsuite/test/lang/c/modules/main.c
+++ lldb/packages/Python/lldbsuite/test/lang/c/modules/main.c
@@ -5,11 +5,11 @@
 typedef struct {
 int a;
 int b;
-} FILE;
+} MYFILE;
 
 int main()
 {
-FILE *myFile = malloc(sizeof(FILE));
+MYFILE *myFile = malloc(sizeof(MYFILE));
 
 myFile->a = 5;
 myFile->b = 9;
Index: lldb/packages/Python/lldbsuite/test/lang/c/ast/main.c
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/lang/c/ast/main.c
@@ -0,0 +1,5 @@
+int main()
+{
+int a = 0; // Set breakpoint 0 here.
+return 0;
+}
Index: lldb/packages/Python/lldbsuite/test/lang/c/ast/TestAST.py
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/lang/c/ast/TestAST.py
@@ -0,0 +1,77 @@
+"""Test that importing modules in C works as expected."""
+
+from __future__ import print_function
+
+
+from distutils.version import StrictVersion
+import os
+import time
+import platform
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class CModulesTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@skipIfFreeBSD
+@skipIfLinux
+@skipIfWindows
+@skipIfNetBSD
+@skipIf(macos_version=["<", "10.12"])
+def test_expr(self):
+self.build()
+exe = self.getBuildArtifact("a.out")
+self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+lldbutil.run_break_set_by_file_and_line(
+self, "main.c", self.line, num_expected_locations=1, loc_exact=True)
+
+self.runCmd("run", RUN_SUCCEEDED)
+
+# The stop reason of the thread should be breakpoint.
+self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+substrs=['stopped',
+ 'stop reason = breakpoint'])
+
+# The breakpoint should have a hit count of 1.
+self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
+substrs=[' resolved, hit count = 1'])
+
+# Enable logging of the imported AST.
+log_file = os.path.join(self.getBuildDir(), "lldb-ast-log.txt")
+self.runCmd("log enable lldb ast -f '%s'" % log_file)
+
+self.expect(
+"expr -l objc++ -- @import Darwin; 3",
+VARIABLES_DISPLAYED_CORRECTLY,
+substrs=[
+"int",
+"3"])
+
+# This expr command imports __sFILE with definition
+# (FILE is a typedef to __sFILE.)
+self.expect(
+"expr *fopen(\"/dev/zero\", \"w\")",
+VARIABLES_DISPLAYED_CORRECTLY,
+substrs=[
+"FILE",
+"_close"]
+)
+
+# Check that the AST log contains exactly one definition of __sFILE.
+f = open(log_file)
+log_lines = f.readlines()
+f.close()
+os.remove(log_file)
+self.assertEqual(" ".join(log_lines).count("struct __sFILE definition"), 1)
+
+def setUp(self):
+# Call super's setUp().
+TestBase.setUp(self)
+# Find the line number to break inside main().
+self.line = line_number('main.c', '// Set breakpoint 0 here.')
Index: 

[PATCH] D61333: [ASTImporter] Fix LLDB lookup in transparent ctx and with ext src

2019-05-17 Thread Gabor Marton via Phabricator via cfe-commits
martong marked an inline comment as done.
martong added inline comments.



Comment at: lldb/source/Symbol/ClangASTImporter.cpp:922
+
+  Log *log_ast(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_AST));
+  if (log_ast) {

shafik wrote:
> I am going to say that the logging change is an excellent additions and 
> stands alone from this change. Although I realize the test depends on this 
> new feature. It makes sense to add the logging in a separate PR.
> 
> I also say this b/c I found a regression and it would be nice to get the 
> logging in while we resolve the regression.
Ok, I have created a new patch for logging (https://reviews.llvm.org/D62061).
I made this patch to be the child of that and rebased to that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61333



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


[PATCH] D61837: Make it possible control matcher traversal kind with ASTContext

2019-05-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: lib/AST/ASTContext.cpp:120
+ASTContext::TraverseIgnored(const ast_type_traits::DynTypedNode ) {
+  if (auto E = N.get()) {
+return ast_type_traits::DynTypedNode::create(*TraverseIgnored(E));

aaron.ballman wrote:
> `auto *`
The formatting is wrong here -- be sure to run the patch through clang-format 
before committing.



Comment at: lib/ASTMatchers/ASTMatchersInternal.cpp:240
+
+  assert(RestrictKind.isBaseOf(NodeKind));
+  if (Implementation->dynMatches(N, Finder, Builder)) {

steveire wrote:
> aaron.ballman wrote:
> > Add an assertion message?
> Saying what? The original code doesn't have one. Let's avoid round trips in 
> review comments :).
This isn't a "round trip"; it's not unreasonable to ask people to NFC improve 
the code they're touching (it's akin to saying "Because you figured out this 
complex piece of code does X, can you add a comment to it so others don't have 
to do that work next time.").

As best I can tell, this assertion exists because this function is meant to 
mirror `matches()` without this base check in release mode. You've lost that 
mirroring with your refactoring, which looks suspicious. Is there a reason this 
function deviates from `matches()` now?

As for the assertion message itself, how about "matched a node of an unexpected 
derived kind"?


Repository:
  rC Clang

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

https://reviews.llvm.org/D61837



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


[PATCH] D59887: [Syntax] Introduce TokenBuffer, start clangToolingSyntax library

2019-05-17 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 200030.
ilya-biryukov added a comment.

- Skip annotation tokens, some of them are reported by the preprocessor but we 
don't want them in the final expanded stream.
- Add functions to compute FileRange of tokens, add tests for it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59887

Files:
  clang/include/clang/Tooling/Syntax/Tokens.h
  clang/lib/Tooling/CMakeLists.txt
  clang/lib/Tooling/Syntax/CMakeLists.txt
  clang/lib/Tooling/Syntax/Tokens.cpp
  clang/unittests/Tooling/CMakeLists.txt
  clang/unittests/Tooling/Syntax/CMakeLists.txt
  clang/unittests/Tooling/Syntax/TokensTest.cpp

Index: clang/unittests/Tooling/Syntax/TokensTest.cpp
===
--- /dev/null
+++ clang/unittests/Tooling/Syntax/TokensTest.cpp
@@ -0,0 +1,672 @@
+//===- TokensTest.cpp -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Tooling/Syntax/Tokens.h"
+#include "clang/AST/ASTConsumer.h"
+#include "clang/AST/Expr.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/DiagnosticIDs.h"
+#include "clang/Basic/DiagnosticOptions.h"
+#include "clang/Basic/FileManager.h"
+#include "clang/Basic/FileSystemOptions.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Basic/TokenKinds.def"
+#include "clang/Basic/TokenKinds.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/FrontendAction.h"
+#include "clang/Frontend/Utils.h"
+#include "clang/Lex/Lexer.h"
+#include "clang/Lex/PreprocessorOptions.h"
+#include "clang/Lex/Token.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/VirtualFileSystem.h"
+#include "llvm/Support/raw_os_ostream.h"
+#include "llvm/Support/raw_ostream.h"
+#include "llvm/Testing/Support/Annotations.h"
+#include "llvm/Testing/Support/SupportHelpers.h"
+#include "gmock/gmock-matchers.h"
+#include "gmock/gmock-more-matchers.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+using namespace clang;
+using namespace clang::syntax;
+
+using llvm::ValueIs;
+using ::testing::AllOf;
+using ::testing::Contains;
+using ::testing::ElementsAre;
+using ::testing::Matcher;
+using ::testing::Not;
+using ::testing::StartsWith;
+
+namespace {
+// Checks the passed ArrayRef has the same begin() and end() iterators as the
+// argument.
+MATCHER_P(SameRange, A, "") {
+  return A.begin() == arg.begin() && A.end() == arg.end();
+}
+// Matchers for syntax::Token.
+MATCHER_P(Kind, K, "") { return arg.kind() == K; }
+MATCHER_P2(HasText, Text, SourceMgr, "") {
+  return arg.text(*SourceMgr) == Text;
+}
+/// Checks the start and end location of a token are equal to SourceRng.
+MATCHER_P(RangeIs, SourceRng, "") {
+  return arg.location() == SourceRng.first &&
+ arg.endLocation() == SourceRng.second;
+}
+
+class TokenCollectorTest : public ::testing::Test {
+public:
+  /// Run the clang frontend, collect the preprocessed tokens from the frontend
+  /// invocation and store them in this->Buffer.
+  /// This also clears SourceManager before running the compiler.
+  void recordTokens(llvm::StringRef Code) {
+class RecordTokens : public ASTFrontendAction {
+public:
+  explicit RecordTokens(TokenBuffer ) : Result(Result) {}
+
+  bool BeginSourceFileAction(CompilerInstance ) override {
+assert(!Collector && "expected only a single call to BeginSourceFile");
+Collector.emplace(CI.getPreprocessor());
+return true;
+  }
+  void EndSourceFileAction() override {
+assert(Collector && "BeginSourceFileAction was never called");
+Result = std::move(*Collector).consume();
+  }
+
+  std::unique_ptr
+  CreateASTConsumer(CompilerInstance , StringRef InFile) override {
+return llvm::make_unique();
+  }
+
+private:
+  TokenBuffer 
+  llvm::Optional Collector;
+};
+
+constexpr const char *FileName = "./input.cpp";
+FS->addFile(FileName, time_t(), llvm::MemoryBuffer::getMemBufferCopy(""));
+// Prepare to run a compiler.
+std::vector Args = {"tok-test", "-std=c++03", "-fsyntax-only",
+  FileName};
+auto CI = createInvocationFromCommandLine(Args, 

Re: r361011 - [analyzer] Validate checker option names and values

2019-05-17 Thread Nico Weber via cfe-commits
It looks like this change is making gcc-7 crash on these (and other
http://lab.llvm.org:8011/console) bots:

http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/18639
http://lab.llvm.org:8011/builders/clang-ppc64be-linux/builds/33837/

[100/212] Building CXX object
tools/clang/unittests/AST/CMakeFiles/ASTTests.dir/ASTImporterTest.cpp.o
FAILED:
tools/clang/unittests/AST/CMakeFiles/ASTTests.dir/ASTImporterTest.cpp.o
...
g++-7: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.
[101/212] Building CXX object
tools/clang/unittests/ASTMatchers/CMakeFiles/ASTMatchersTests.dir/ASTMatchersTraversalTest.cpp.o
FAILED:
tools/clang/unittests/ASTMatchers/CMakeFiles/ASTMatchersTests.dir/ASTMatchersTraversalTest.cpp.o

...
g++-7: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.
[102/212] Building CXX object
tools/clang/unittests/ASTMatchers/CMakeFiles/ASTMatchersTests.dir/ASTMatchersNarrowingTest.cpp.o
FAILED:
tools/clang/unittests/ASTMatchers/CMakeFiles/ASTMatchersTests.dir/ASTMatchersNarrowingTest.cpp.o

...
g++-7: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.
[103/212] Building CXX object
tools/clang/unittests/ASTMatchers/CMakeFiles/ASTMatchersTests.dir/ASTMatchersNodeTest.cpp.o
FAILED:
tools/clang/unittests/ASTMatchers/CMakeFiles/ASTMatchersTests.dir/ASTMatchersNodeTest.cpp.o

...
g++-7: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.
[104/212] Building CXX object
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/CommentHandlerTest.cpp.o
FAILED:
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/CommentHandlerTest.cpp.o

...
g++-7: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.
[105/212] Building CXX object
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/ExecutionTest.cpp.o
FAILED:
tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/ExecutionTest.cpp.o

...
g++-7: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.
[106/212] Building CXX object
tools/clang/unittests/AST/CMakeFiles/ASTTests.dir/ASTImporterVisibilityTest.cpp.o
FAILED:
tools/clang/unittests/AST/CMakeFiles/ASTTests.dir/ASTImporterVisibilityTest.cpp.o

...
g++-7: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.

*From: *Kristof Umann via cfe-commits 
*Date: *Fri, May 17, 2019 at 5:49 AM
*To: * 

Author: szelethus
> Date: Fri May 17 02:51:59 2019
> New Revision: 361011
>
> URL: http://llvm.org/viewvc/llvm-project?rev=361011=rev
> Log:
> [analyzer] Validate checker option names and values
>
> Validate whether the option exists, and also whether the supplied value is
> of
> the correct type. With this patch, invoking the analyzer should be, at
> least
> in the frontend mode, a lot safer.
>
> Differential Revision: https://reviews.llvm.org/D57860
>
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
> cfe/trunk/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
> cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
> cfe/trunk/test/Analysis/checker-plugins.c
> cfe/trunk/test/Analysis/invalid-checker-option.c
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=361011=361010=361011=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Fri May 17
> 02:51:59 2019
> @@ -307,6 +307,8 @@ def err_analyzer_config_multiple_values
>  def err_analyzer_config_invalid_input : Error<
>"invalid input for analyzer-config option '%0', that expects %1 value">;
>  def err_analyzer_config_unknown : Error<"unknown analyzer-config '%0'">;
> +def err_analyzer_checker_option_unknown : Error<
> +  "checker '%0' has no option called '%1'">;
>  def err_analyzer_checker_option_invalid_input : Error<
>"invalid input for checker option '%0', that expects %1">;
>
>
> Modified: cfe/trunk/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h?rev=361011=361010=361011=diff
>
> ==
> --- cfe/trunk/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
> 

[PATCH] D61335: [LibTooling] Add support to Transformer for composing rules as an ordered choice.

2019-05-17 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 200026.
ymandel marked 2 inline comments as done.
ymandel added a comment.

updated comments; moved some decls.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61335

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

Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- clang/unittests/Tooling/TransformerTest.cpp
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -116,7 +116,8 @@
 };
   }
 
-  void testRule(RewriteRule Rule, StringRef Input, StringRef Expected) {
+  template 
+  void testRule(R Rule, StringRef Input, StringRef Expected) {
 Transformer T(std::move(Rule), consumer());
 T.registerMatchers();
 compareSnippets(Expected, rewrite(Input));
@@ -147,7 +148,7 @@
  .bind(StringExpr)),
   callee(cxxMethodDecl(hasName("c_str")),
   change("REPLACED"));
-  R.Explanation = text("Use size() method directly on string.");
+  R.Cases[0].Explanation = text("Use size() method directly on string.");
   return R;
 }
 
@@ -375,6 +376,92 @@
Input, Expected);
 }
 
+TEST_F(TransformerTest, OrderedRuleUnrelated) {
+  StringRef Flag = "flag";
+  RewriteRule FlagRule = makeRule(
+  cxxMemberCallExpr(on(expr(hasType(cxxRecordDecl(
+hasName("proto::ProtoCommandLineFlag"
+   .bind(Flag)),
+unless(callee(cxxMethodDecl(hasName("GetProto"),
+  change(Flag, "PROTO"));
+
+  std::string Input = R"cc(
+proto::ProtoCommandLineFlag flag;
+int x = flag.foo();
+int y = flag.GetProto().foo();
+int f(string s) { return strlen(s.c_str()); }
+  )cc";
+  std::string Expected = R"cc(
+proto::ProtoCommandLineFlag flag;
+int x = PROTO.foo();
+int y = flag.GetProto().foo();
+int f(string s) { return REPLACED; }
+  )cc";
+
+  testRule(applyFirst({ruleStrlenSize(), FlagRule}), Input, Expected);
+}
+
+// Version of ruleStrlenSizeAny that inserts a method with a different name than
+// ruleStrlenSize, so we can tell their effect apart.
+RewriteRule ruleStrlenSizeDistinct() {
+  StringRef S;
+  return makeRule(
+  callExpr(callee(functionDecl(hasName("strlen"))),
+   hasArgument(0, cxxMemberCallExpr(
+  on(expr().bind(S)),
+  callee(cxxMethodDecl(hasName("c_str")),
+  change("DISTINCT"));
+}
+
+TEST_F(TransformerTest, OrderedRuleRelated) {
+  std::string Input = R"cc(
+namespace foo {
+struct mystring {
+  char* c_str();
+};
+int f(mystring s) { return strlen(s.c_str()); }
+}  // namespace foo
+int g(string s) { return strlen(s.c_str()); }
+  )cc";
+  std::string Expected = R"cc(
+namespace foo {
+struct mystring {
+  char* c_str();
+};
+int f(mystring s) { return DISTINCT; }
+}  // namespace foo
+int g(string s) { return REPLACED; }
+  )cc";
+
+  testRule(applyFirst({ruleStrlenSize(), ruleStrlenSizeDistinct()}), Input,
+   Expected);
+}
+
+// Change the order of the rules to get a different result.
+TEST_F(TransformerTest, OrderedRuleRelatedSwapped) {
+  std::string Input = R"cc(
+namespace foo {
+struct mystring {
+  char* c_str();
+};
+int f(mystring s) { return strlen(s.c_str()); }
+}  // namespace foo
+int g(string s) { return strlen(s.c_str()); }
+  )cc";
+  std::string Expected = R"cc(
+namespace foo {
+struct mystring {
+  char* c_str();
+};
+int f(mystring s) { return DISTINCT; }
+}  // namespace foo
+int g(string s) { return DISTINCT; }
+  )cc";
+
+  testRule(applyFirst({ruleStrlenSizeDistinct(), ruleStrlenSize()}), Input,
+   Expected);
+}
+
 //
 // Negative tests (where we expect no transformation to occur).
 //
Index: clang/lib/Tooling/Refactoring/Transformer.cpp
===
--- clang/lib/Tooling/Refactoring/Transformer.cpp
+++ clang/lib/Tooling/Refactoring/Transformer.cpp
@@ -28,6 +28,7 @@
 using namespace tooling;
 
 using ast_matchers::MatchFinder;
+using ast_matchers::internal::DynTypedMatcher;
 using ast_type_traits::ASTNodeKind;
 using ast_type_traits::DynTypedNode;
 using llvm::Error;
@@ -144,9 +145,9 @@
   llvm_unreachable("Unexpected case in NodePart type.");
 }
 
-Expected>
-tooling::translateEdits(const MatchResult ,
-llvm::ArrayRef Edits) {
+Expected>
+tooling::detail::translateEdits(const MatchResult ,
+llvm::ArrayRef Edits) {
   SmallVector Transformations;
   auto  = Result.Nodes.getMap();
   for (const auto  : Edits) {
@@ -171,18 +172,113 @@
   return 

[PATCH] D61335: [LibTooling] Add support to Transformer for composing rules as an ordered choice.

2019-05-17 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel marked 2 inline comments as done.
ymandel added inline comments.



Comment at: clang/include/clang/Tooling/Refactoring/Transformer.h:278
+/// Builds the matcher needed for registration.
+ast_matchers::internal::DynTypedMatcher buildMatcher(const RewriteRule );
+

ilya-biryukov wrote:
> ymandel wrote:
> > ilya-biryukov wrote:
> > > Can it be declared in `.cpp` file instead? Or is it used in `clang-tidy` 
> > > integration? 
> > `buildMatcher` and `findSelectedCase` will be used in the clang-tidy 
> > integration and in the apply-rule-to-single-node function that I'm planning.
> I'd say this makes these functions a public interface of rewrite rule, albeit 
> it's an "advanced" use-case.
> It's probably ok to keep them in `detail` namespace for now, but would be 
> nice to come up with a proper public functions that allow us to implement 
> those use-cases.
> (Or declare these function public and well-supported and move them out of 
> `detail` at some point)
Agreed. I noted this explicitly with a FIXME, reworded the comments to 
explicitly associate these with `RewriteRule` and moved them to immediately 
after the other `RewriteRule` functions.  `Transformer` is now the last 
declaration in the file (and should probably be split into its own header at 
this point, being just one interpreter of `RewriteRule` among many).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61335



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


[PATCH] D61835: Extract ASTDumper to a header file

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

In D61835#1505388 , @steveire wrote:

> In D61835#1505314 , @aaron.ballman 
> wrote:
>
> > In D61835#1505280 , @steveire 
> > wrote:
> >
> > > In D61835#1505228 , 
> > > @aaron.ballman wrote:
> > >
> > > > In D61835#1505202 , @steveire 
> > > > wrote:
> > > >
> > > > > 3. Anyone who wants traversal in the same way that dumping is done 
> > > > > and who needs to call API on the instance which is provided by 
> > > > > ASTNodeTraverser (which ASTDumper inherits) needs to use ASTDumper. 
> > > > > For example my UI. See my EuroLLVM talk for more: 
> > > > > https://steveire.wordpress.com/2019/04/30/the-future-of-ast-matching-refactoring-tools-eurollvm-and-accu/
> > > >
> > > >
> > > > Do they? Why is the `ASTNodeTraverser` insufficient?
> > >
> > >
> > > It doesn't have the same behavior as `ASTDumper`, because `ASTDumper` 
> > > "overrides" some `Visit` metthods.
> >
> >
> > I'm aware that they're different, but I may not have been sufficiently 
> > clear. I'm saying that the only public APIs I think a user should be 
> > calling are inherited from `ASTNodeTraverser` and not `ASTDumper`, so it is 
> > not required to expose `ASTDumper` directly, only a way to get an 
> > `ASTNodeTraverser` reference/pointer to an `ASTDumper` instance so that you 
> > get the correct virtual dispatch. e.g., `ASTNodeTraverser 
> > *getSomethingThatActsLikeAnASTDumper() { return new ASTDumper; }`
>
>
> Perhaps. One way to implement the 'less noise' version of AST output (ie 
> removing pointer addresses etc http://ce.steveire.com/z/HaCLeO ) is to make 
> it an API on the `TextNodeDumper`. Then `ASTDumper` would need a forwarding 
> API for it.
>
> Anyway, your argument also applies to `JSONNodeDumper`, but you put that in a 
> header file.


Yeah, and I was unhappy about doing so, but the alternative was to put it into 
ASTDumper.cpp as a local class and that felt even worse.

> That was sane. We should move `ASTDumper` to a header similarly. (Perhaps a 
> rename of the class would help though?)

Yeah, I'd be fine with renaming it to be a bit less general than `ASTDumper`.

This LGTM. It's not a particularly clean interface, but I can see the utility 
in exposing it for D62056 .


Repository:
  rC Clang

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

https://reviews.llvm.org/D61835



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


[PATCH] D62046: [OpenMP][bugfix] Add missing math functions variants for log and abs.

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

This LGTM me, @tra or @efriedma any objections?


Repository:
  rC Clang

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

https://reviews.llvm.org/D62046



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


  1   2   >