[PATCH] D53714: [AST] Only store the needed data in SwitchStmt.

2018-10-26 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rC Clang

https://reviews.llvm.org/D53714



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


[PATCH] D53738: [Fixed Point Arithmetic] Fixed Point Addition

2018-10-26 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In https://reviews.llvm.org/D53738#1277172, @ebevhan wrote:

> I want to float the idea again of adding an AST type to encapsulate an 
> arbitrary fixed-point semantic and using that as the 'common type' for binary 
> operations involving fixed-point types. This would enable 
> UsualArithmeticConversions to handle fixed-point types similarly to how it 
> does today (find the 'common' full precision type, implicitly cast the LHS 
> and RHS if necessary). There is one new thing that it would have to do; the 
> result after the operation should not be the full precision type, but rather 
> be casted to the operand type of highest rank. I don't think the existing 
> code in SemaExpr can handle the case of adding an implicit cast after the 
> operation. I don't think it should be hard to add, though.


I don't think we should add *types* just for this, but if you need to make a 
different kind of `BinaryOperator` that represents that the semantics aren't 
quite the same (the same way that the compound assignments have their own 
subclass), that seems natural to me.


Repository:
  rC Clang

https://reviews.llvm.org/D53738



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


[PATCH] D53764: [OpenCL] Enable address spaces for references in C++

2018-10-26 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/AST/Expr.cpp:1609
   case CK_AddressSpaceConversion:
-assert(getType()->isPointerType() || getType()->isBlockPointerType());
-assert(getSubExpr()->getType()->isPointerType() ||
-   getSubExpr()->getType()->isBlockPointerType());
-assert(getType()->getPointeeType().getAddressSpace() !=
-   getSubExpr()->getType()->getPointeeType().getAddressSpace());
-LLVM_FALLTHROUGH;
+assert(/*If pointer type then addr spaces for pointees must differ*/
+   (((getType()->isPointerType() &&

Anastasia wrote:
> I don't like this assert now. Would adding extra variable be cleaner here?
Yeah, this assertion doesn't make any sense like this.  It should be checking 
whether the cast is a gl-value and, if so, requiring the subexpression to also 
be a gl-value and then asserting the difference between the type.  But you can 
certainly do an address-space conversion on l-values that just happen to be of 
pointer or block-pointer type.



Comment at: lib/CodeGen/CGExpr.cpp:4252
+Address V =
+Builder.CreateAddrSpaceCast(LV.getAddress(), ConvertType(DestTy));
+

Please use the `performAddrSpaceCast` target hook instead of directly 
constructing an LLVM `addrspacecast`.



Comment at: lib/Sema/DeclSpec.cpp:576
+  if (S.getLangOpts().OpenCLVersion < 120 &&
+  !S.getLangOpts().OpenCLCPlusPlus) {
+DiagID = diag::err_opencl_unknown_type_specifier;

Please update the comment above this.



Comment at: lib/Sema/SemaDecl.cpp:7366
+ (getLangOpts().OpenCLVersion == 200 ||
+  getLangOpts().OpenCLCPlusPlus {
 int Scope = NewVD->isStaticLocal() | NewVD->hasExternalStorage() << 1;

Please update the comment above this.



Comment at: lib/Sema/SemaInit.cpp:7614
+: CK_NoOp;
+  CurInit = S.ImpCastExprToType(CurInit.get(), Step->Type, CK, VK);
   break;

Please extract a function to do an l-value qualification conversion just in 
case we add more non-trivial conversions that we need to represent.


https://reviews.llvm.org/D53764



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


[PATCH] D53605: [AST] Refactor PredefinedExpr

2018-10-26 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM.




Comment at: include/clang/AST/Stmt.h:279
+/// in PredefinedExpr::IdentType.
+unsigned Type : 4;
+

rjmccall wrote:
> Since you're changing this around anyway, please make it a "kind" rather than 
> a "type".  Even if it's just the field name for now, it's progress.
Thank you!  That was more than I expected, but it's definitely better this way.


Repository:
  rC Clang

https://reviews.llvm.org/D53605



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


[PATCH] D53674: [CodeGen] Fix assertion on referencing constexpr Obj-C object with ARC.

2018-10-26 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/CodeGen/CGObjC.cpp:2480
+ SuppressResultRetain);
   }
 

vsapsai wrote:
> rjmccall wrote:
> > This switch is just checking what you already computed as 
> > `SuppressResultRetain`.  Please just assert in the second case that the 
> > qualifier is `OCL_Weak`.
> > 
> > Also, please stay consistent with the surrounding capitalization of local 
> > variables.
> Not entirely sure I understand the comment about switch correctly. Will 
> change the code according to my understanding.
That's exactly what I was asking for, thank you.


https://reviews.llvm.org/D53674



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


[PATCH] D53725: [CodeGen] Move `emitConstant` from ScalarExprEmitter to CodeGenFunction. NFC.

2018-10-26 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

This should at least be named `emitScalarConstant`.


https://reviews.llvm.org/D53725



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


[PATCH] D53705: [OpenCL] Postpone PSV address space diagnostic

2018-10-26 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

I don't suppose there's any chance you can just tell Khronos to fix their 
stuff.  It's a little funny to be more conservative about keywords in C++ when 
the C++ committee is actually much more aggressive about adding keywords in the 
non-reserved space than C is.


Repository:
  rC Clang

https://reviews.llvm.org/D53705



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


r345443 - Revert "Pass the nopie flag to the linker when linking with -pg." until

2018-10-26 Thread Brad Smith via cfe-commits
Author: brad
Date: Fri Oct 26 18:14:22 2018
New Revision: 345443

URL: http://llvm.org/viewvc/llvm-project?rev=345443=rev
Log:
Revert "Pass the nopie flag to the linker when linking with -pg." until
one of the tests can be fixed on !OpenBSD hosts.

Modified:
cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp
cfe/trunk/test/Driver/openbsd.c

Modified: cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp?rev=345443=345442=345443=diff
==
--- cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp Fri Oct 26 18:14:22 2018
@@ -138,7 +138,7 @@ void openbsd::Linker::ConstructJob(Compi
 
   if (Args.hasArg(options::OPT_pie))
 CmdArgs.push_back("-pie");
-  if (Args.hasArg(options::OPT_nopie) || Args.hasArg(options::OPT_pg))
+  if (Args.hasArg(options::OPT_nopie))
 CmdArgs.push_back("-nopie");
 
   if (Output.isFilename()) {

Modified: cfe/trunk/test/Driver/openbsd.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/openbsd.c?rev=345443=345442=345443=diff
==
--- cfe/trunk/test/Driver/openbsd.c (original)
+++ cfe/trunk/test/Driver/openbsd.c Fri Oct 26 18:14:22 2018
@@ -12,7 +12,7 @@
 // RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -pg -pthread %s 
-### 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PG %s
 // CHECK-PG: clang{{.*}}" "-cc1" "-triple" "i686-pc-openbsd"
-// CHECK-PG: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" 
"-dynamic-linker" "{{.*}}ld.so" "-o" "a.out" "-nopie" "{{.*}}gcrt0.o" 
"{{.*}}crtbegin.o" "{{.*}}.o" "-lcompiler_rt" "-lpthread_p" "-lc_p" 
"-lcompiler_rt" "{{.*}}crtend.o"
+// CHECK-PG: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" 
"-dynamic-linker" "{{.*}}ld.so" "-o" "a.out" "{{.*}}gcrt0.o" "{{.*}}crtbegin.o" 
"{{.*}}.o" "-lcompiler_rt" "-lpthread_p" "-lc_p" "-lcompiler_rt" 
"{{.*}}crtend.o"
 
 // Check CPU type for MIPS64
 // RUN: %clang -target mips64-unknown-openbsd -### -c %s 2>&1 \
@@ -84,8 +84,6 @@
 // Check linking against correct startup code when (not) using PIE
 // RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd %s -### 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-PIE %s
-// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -pg %s -### 2>&1 
\
-// RUN:   | FileCheck -check-prefix=CHECK-NOPIE %s
 // RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -pie %s -### 
2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-PIE-FLAG %s
 // RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -fno-pie %s -### 
2>&1 \


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


[PATCH] D53457: clang-cl: Add "/clang:" pass-through arg support.

2018-10-26 Thread Neeraj K. Singh via Phabricator via cfe-commits
neerajksingh updated this revision to Diff 171382.
neerajksingh added a comment.

Fix hans' comments.


https://reviews.llvm.org/D53457

Files:
  docs/UsersManual.rst
  include/clang/Driver/CLCompatOptions.td
  include/clang/Driver/Driver.h
  lib/Driver/Driver.cpp
  test/Driver/cl-options.c

Index: test/Driver/cl-options.c
===
--- test/Driver/cl-options.c
+++ test/Driver/cl-options.c
@@ -614,5 +614,17 @@
 // RUN: --version \
 // RUN: -Werror /Zs -- %s 2>&1
 
+// Accept clang options under the /clang: flag.
+
+// RUN: %clang_cl -O2 -### -- %s 2>&1 | FileCheck -check-prefix=NOCLANG %s
+// NOCLANG: "--dependent-lib=libcmt"
+// NOCLANG-SAME: "-vectorize-slp"
+// NOCLANG-NOT: "--dependent-lib=msvcrt"
+
+// RUN: %clang_cl -O2 -MD /clang:-fno-slp-vectorize /clang:-MD /clang:-MF /clang:my_dependency_file.dep -### -- %s 2>&1 | FileCheck -check-prefix=CLANG %s
+// CLANG: "--dependent-lib=msvcrt"
+// CLANG-SAME: "-dependency-file" "my_dependency_file.dep"
+// CLANG-NOT: "--dependent-lib=libcmt"
+// CLANG-NOT: "-vectorize-slp"
 
 void f() { }
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -166,14 +166,15 @@
 }
 
 InputArgList Driver::ParseArgStrings(ArrayRef ArgStrings,
+ bool IsClCompatMode,
  bool ) {
   llvm::PrettyStackTraceString CrashInfo("Command line argument parsing");
   ContainsError = false;
 
   unsigned IncludedFlagsBitmask;
   unsigned ExcludedFlagsBitmask;
   std::tie(IncludedFlagsBitmask, ExcludedFlagsBitmask) =
-  getIncludeExcludeOptionFlagMasks();
+  getIncludeExcludeOptionFlagMasks(IsClCompatMode);
 
   unsigned MissingArgIndex, MissingArgCount;
   InputArgList Args =
@@ -730,7 +731,7 @@
   ConfigFile = CfgFileName.str();
   bool ContainErrors;
   CfgOptions = llvm::make_unique(
-  ParseArgStrings(NewCfgArgs, ContainErrors));
+  ParseArgStrings(NewCfgArgs, IsCLMode(), ContainErrors));
   if (ContainErrors) {
 CfgOptions.reset();
 return true;
@@ -924,7 +925,7 @@
   // Arguments specified in command line.
   bool ContainsError;
   CLOptions = llvm::make_unique(
-  ParseArgStrings(ArgList.slice(1), ContainsError));
+  ParseArgStrings(ArgList.slice(1), IsCLMode(), ContainsError));
 
   // Try parsing configuration file.
   if (!ContainsError)
@@ -934,21 +935,47 @@
   // All arguments, from both config file and command line.
   InputArgList Args = std::move(HasConfigFile ? std::move(*CfgOptions)
   : std::move(*CLOptions));
-  if (HasConfigFile)
-for (auto *Opt : *CLOptions) {
-  if (Opt->getOption().matches(options::OPT_config))
-continue;
+
+  auto appendOneArg = [](const Arg *Opt, const Arg *BaseArg) {
   unsigned Index = Args.MakeIndex(Opt->getSpelling());
-  const Arg *BaseArg = >getBaseArg();
-  if (BaseArg == Opt)
-BaseArg = nullptr;
   Arg *Copy = new llvm::opt::Arg(Opt->getOption(), Opt->getSpelling(),
  Index, BaseArg);
   Copy->getValues() = Opt->getValues();
   if (Opt->isClaimed())
 Copy->claim();
   Args.append(Copy);
+  };
+
+  if (HasConfigFile)
+for (auto *Opt : *CLOptions) {
+  if (Opt->getOption().matches(options::OPT_config))
+continue;
+  const Arg *BaseArg = >getBaseArg();
+  if (BaseArg == Opt)
+BaseArg = nullptr;
+  appendOneArg(Opt, BaseArg);
+}
+
+  // In CL mode, look for any pass-through arguments
+  if (IsCLMode() && !ContainsError) {
+SmallVector CLModePassThroughArgList;
+for (const auto *A : Args.filtered(options::OPT__SLASH_clang)) {
+  A->claim();
+  CLModePassThroughArgList.push_back(A->getValue());
+}
+
+if (!CLModePassThroughArgList.empty()) {
+  // Parse any pass through args using default clang processing rather
+  // than clang-cl processing.
+  auto CLModePassThroughOptions = llvm::make_unique(
+  ParseArgStrings(CLModePassThroughArgList, false, ContainsError));
+
+  if (!ContainsError)
+for (auto *Opt : *CLModePassThroughOptions) {
+  appendOneArg(Opt, nullptr);
+}
 }
+  }
 
   // FIXME: This stuff needs to go into the Compilation, not the driver.
   bool CCCPrintPhases;
@@ -1452,7 +1479,7 @@
   unsigned IncludedFlagsBitmask;
   unsigned ExcludedFlagsBitmask;
   std::tie(IncludedFlagsBitmask, ExcludedFlagsBitmask) =
-  getIncludeExcludeOptionFlagMasks();
+  getIncludeExcludeOptionFlagMasks(IsCLMode());
 
   ExcludedFlagsBitmask |= options::NoDriverOption;
   if (!ShowHidden)
@@ -4661,11 +4688,11 @@
   return false;
 }
 
-std::pair Driver::getIncludeExcludeOptionFlagMasks() const {
+std::pair Driver::getIncludeExcludeOptionFlagMasks(bool IsClCompatMode) const {
   unsigned IncludedFlagsBitmask = 0;
   unsigned 

r345440 - Update the other test.

2018-10-26 Thread Brad Smith via cfe-commits
Author: brad
Date: Fri Oct 26 17:46:12 2018
New Revision: 345440

URL: http://llvm.org/viewvc/llvm-project?rev=345440=rev
Log:
Update the other test.

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

Modified: cfe/trunk/test/Driver/openbsd.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/openbsd.c?rev=345440=345439=345440=diff
==
--- cfe/trunk/test/Driver/openbsd.c (original)
+++ cfe/trunk/test/Driver/openbsd.c Fri Oct 26 17:46:12 2018
@@ -12,7 +12,7 @@
 // RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -pg -pthread %s 
-### 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-PG %s
 // CHECK-PG: clang{{.*}}" "-cc1" "-triple" "i686-pc-openbsd"
-// CHECK-PG: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" 
"-dynamic-linker" "{{.*}}ld.so" "-o" "a.out" "{{.*}}gcrt0.o" "{{.*}}crtbegin.o" 
"{{.*}}.o" "-lcompiler_rt" "-lpthread_p" "-lc_p" "-lcompiler_rt" 
"{{.*}}crtend.o"
+// CHECK-PG: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" 
"-dynamic-linker" "{{.*}}ld.so" "-o" "a.out" "-nopie" "{{.*}}gcrt0.o" 
"{{.*}}crtbegin.o" "{{.*}}.o" "-lcompiler_rt" "-lpthread_p" "-lc_p" 
"-lcompiler_rt" "{{.*}}crtend.o"
 
 // Check CPU type for MIPS64
 // RUN: %clang -target mips64-unknown-openbsd -### -c %s 2>&1 \


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


[PATCH] D52615: Handle -fsanitize-address-poison-class-member-array-new-cookie in the driver and propagate it to cc1

2018-10-26 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

So, three points:

- That's not class-member-specific; you can have a placement `operator new[]` 
at global scope that isn't the special `void*` placement operator and therefore 
still has a cookie, and it would have just as much flexibility as a 
class-member override would.  So the split you're trying to describe is the 
standard operators vs. custom ones.

- Anyone can provide their own definition of the standard operators; there are 
some semantic restrictions on those definitions, but I'm not sure what about 
those restrictions would forbid this kind of capture.

- Even with the standard implementations of the standard replaceable operators, 
I'm not sure what rule would actually outlaw the client from going from the 
result of `new[]` back to the cookie.

At any rate, taking the feature as a given, the first point suggests 
`-fsanitize-address-poison-custom-array-cookie` or something along those lines. 
 If we want a more standard-ese term than "custom", the standard refers to its 
operators collectively as "library allocation functions", so maybe 
"non-library".


Repository:
  rC Clang

https://reviews.llvm.org/D52615



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


[PATCH] D53787: [Sema] Use proper visibility for global new and delete declarations

2018-10-26 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added reviewers: rsmith, rnk.
Herald added a subscriber: cfe-commits.

When the global new and delete operators aren't declared, Clang
provides and implicit declaration, but this declaration currently
always uses the default visibility. This is a problem when the
C++ library itself is being built with non-default visibility because
the implicit declaration will force the new and delete operators to
have the default visibility unlike the rest of the library.

The existing workaround is to use assembly to enforce the visiblity:
https://fuchsia.googlesource.com/zircon/+/master/system/ulib/zxcpp/new.cpp#108
but that solution is not always available, e.g. in the case of of
libFuzzer which is using an internal version of libc++ that's also built
with -fvisibility=hidden where the existing behavior is causing issues.

This change modifies the implicit declaration of the global new and
delete operators to respect the Clang visibility setting i.e. the
-fvisibility= flag.


Repository:
  rC Clang

https://reviews.llvm.org/D53787

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaExprCXX.cpp


Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -2816,9 +2816,9 @@
 // Global allocation functions should always be visible.
 Alloc->setVisibleDespiteOwningModule();
 
-// Implicit sized deallocation functions always have default visibility.
-Alloc->addAttr(
-VisibilityAttr::CreateImplicit(Context, VisibilityAttr::Default));
+Alloc->addAttr(VisibilityAttr::CreateImplicit(
+Context,
+getVisibilityAttr(Context.getLangOpts().getValueVisibilityMode(;
 
 llvm::SmallVector ParamDecls;
 for (QualType T : Params) {
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -5195,6 +5195,18 @@
 AFS_Both
   };
 
+  static VisibilityAttr::VisibilityType getVisibilityAttr(clang::Visibility V) 
{
+switch (V) {
+case DefaultVisibility:
+  return VisibilityAttr::Default;
+case HiddenVisibility:
+  return VisibilityAttr::Hidden;
+case ProtectedVisibility:
+  return VisibilityAttr::Protected;
+}
+llvm_unreachable("unknown visibility!");
+  };
+
   /// Finds the overloads of operator new and delete that are appropriate
   /// for the allocation.
   bool FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range,


Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -2816,9 +2816,9 @@
 // Global allocation functions should always be visible.
 Alloc->setVisibleDespiteOwningModule();
 
-// Implicit sized deallocation functions always have default visibility.
-Alloc->addAttr(
-VisibilityAttr::CreateImplicit(Context, VisibilityAttr::Default));
+Alloc->addAttr(VisibilityAttr::CreateImplicit(
+Context,
+getVisibilityAttr(Context.getLangOpts().getValueVisibilityMode(;
 
 llvm::SmallVector ParamDecls;
 for (QualType T : Params) {
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -5195,6 +5195,18 @@
 AFS_Both
   };
 
+  static VisibilityAttr::VisibilityType getVisibilityAttr(clang::Visibility V) {
+switch (V) {
+case DefaultVisibility:
+  return VisibilityAttr::Default;
+case HiddenVisibility:
+  return VisibilityAttr::Hidden;
+case ProtectedVisibility:
+  return VisibilityAttr::Protected;
+}
+llvm_unreachable("unknown visibility!");
+  };
+
   /// Finds the overloads of operator new and delete that are appropriate
   /// for the allocation.
   bool FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r345439 - Pass the nopie flag to the linker when linking with -pg.

2018-10-26 Thread Brad Smith via cfe-commits
Author: brad
Date: Fri Oct 26 17:23:28 2018
New Revision: 345439

URL: http://llvm.org/viewvc/llvm-project?rev=345439=rev
Log:
Pass the nopie flag to the linker when linking with -pg.

Modified:
cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp
cfe/trunk/test/Driver/openbsd.c

Modified: cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp?rev=345439=345438=345439=diff
==
--- cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp Fri Oct 26 17:23:28 2018
@@ -138,7 +138,7 @@ void openbsd::Linker::ConstructJob(Compi
 
   if (Args.hasArg(options::OPT_pie))
 CmdArgs.push_back("-pie");
-  if (Args.hasArg(options::OPT_nopie))
+  if (Args.hasArg(options::OPT_nopie) || Args.hasArg(options::OPT_pg))
 CmdArgs.push_back("-nopie");
 
   if (Output.isFilename()) {

Modified: cfe/trunk/test/Driver/openbsd.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/openbsd.c?rev=345439=345438=345439=diff
==
--- cfe/trunk/test/Driver/openbsd.c (original)
+++ cfe/trunk/test/Driver/openbsd.c Fri Oct 26 17:23:28 2018
@@ -84,6 +84,8 @@
 // Check linking against correct startup code when (not) using PIE
 // RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd %s -### 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-PIE %s
+// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -pg %s -### 2>&1 
\
+// RUN:   | FileCheck -check-prefix=CHECK-NOPIE %s
 // RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -pie %s -### 
2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-PIE-FLAG %s
 // RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -fno-pie %s -### 
2>&1 \


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


Buildbot numbers for the week of 10/7/018 - 10/13/2018

2018-10-26 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 10/7/018 - 10/13/2018.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:
  buildername  | was_red
---+-
 clang-cmake-aarch64-lld   | 53:03:40
 clang-cmake-armv7-selfhost-neon   | 47:52:22
 clang-cmake-aarch64-full  | 46:26:45
 clang-cmake-armv7-selfhost| 45:37:36
 clang-cmake-armv8-global-isel | 44:16:26
 clang-cmake-armv8-selfhost-neon   | 43:53:13
 clang-cmake-armv7-global-isel | 43:21:08
 clang-cmake-armv7-full| 43:12:18
 clang-cmake-armv8-full| 43:06:19
 clang-cmake-armv8-quick   | 43:03:32
 llvm-hexagon-elf  | 42:59:46
 clang-cmake-armv7-quick   | 42:58:12
 sanitizer-x86_64-linux-bootstrap-ubsan| 42:58:00
 clang-cmake-aarch64-quick | 42:52:10
 clang-sphinx-docs | 42:41:42
 clang-cmake-aarch64-global-isel   | 42:33:28
 clang-hexagon-elf | 42:31:13
 clang-cmake-thumbv8-full-sh   | 41:49:53
 clang-cmake-thumbv7-full-sh   | 41:24:48
 clang-cmake-armv8-lld | 40:12:19
 libcxx-libcxxabi-x86_64-linux-ubuntu-32bit| 39:16:18
 clang-ppc64be-linux-multistage| 38:20:09
 clang-s390x-linux-lnt | 38:00:04
 clang-s390x-linux | 37:47:06
 clang-ppc64be-linux   | 37:40:40
 clang-ppc64be-linux-lnt   | 37:20:41
 clang-s390x-linux-multistage  | 36:45:00
 sanitizer-x86_64-linux-fast   | 30:01:50
 sanitizer-ppc64be-linux   | 28:16:39
 lldb-amd64-ninja-netbsd8  | 26:10:55
 clang-x86_64-linux-selfhost-modules   | 24:23:50
 clang-lld-x86_64-2stage   | 24:11:27
 llvm-clang-x86_64-expensive-checks-win| 23:49:38
 clang-x64-ninja-win7  | 23:39:29
 clang-with-lto-ubuntu | 23:27:02
 clang-with-thin-lto-ubuntu| 22:24:41
 sanitizer-x86_64-linux-android| 22:13:47
 clang-x64-windows-msvc| 22:05:21
 libcxx-libcxxabi-x86_64-linux-debian-noexceptions | 17:16:36
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx03| 16:52:45
 lldb-x86_64-ubuntu-14.04-buildserver  | 14:57:42
 sanitizer-x86_64-linux-bootstrap  | 14:43:40
 lldb-amd64-ninja-freebsd11| 14:23:42
 sanitizer-x86_64-linux-bootstrap-msan | 13:46:21
 clang-bpf-build   | 13:02:20
 clang-ppc64le-linux-lnt   | 12:49:02
 clang-x86_64-debian-fast  | 12:35:47
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast| 12:21:19
 clang-cmake-x86_64-sde-avx512-linux   | 12:18:11
 clang-ppc64le-linux   | 12:16:53
 clang-cmake-x86_64-avx2-linux | 11:50:52
 clang-ppc64le-linux-multistage| 11:08:22
 libcxx-libcxxabi-libunwind-x86_64-linux-debian| 08:40:59
 libcxx-libcxxabi-libunwind-aarch64-linux-noexceptions | 08:34:14
 libcxx-libcxxabi-x86_64-linux-debian  | 07:58:01
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast  | 07:38:28
 sanitizer-windows | 06:50:47
 polly-amd64-linux | 06:38:35
 libcxx-libcxxabi-libunwind-armv8-linux| 06:06:29
 sanitizer-x86_64-linux| 05:41:19
 lld-perf-testsuite| 04:52:20
 lld-x86_64-darwin13   | 04:52:13
 sanitizer-ppc64le-linux   | 04:32:08
 sanitizer-x86_64-linux-autoconf   | 03:41:51
 

Buildbot numbers for the last week of 10/14/2018 - 10/20/2018

2018-10-26 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the last week of 10/14/2018 -
10/20/2018.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:
  buildername  | was_red
---+-
 clang-cmake-aarch64-full  | 75:57:30
 clang-cmake-aarch64-lld   | 75:55:45
 clang-cmake-aarch64-global-isel   | 69:17:11
 clang-cmake-aarch64-quick | 69:12:46
 clang-hexagon-elf | 68:01:41
 libcxx-libcxxabi-libunwind-x86_64-linux-debian| 55:33:39
 clang-cmake-armv7-global-isel | 51:50:32
 clang-cmake-armv8-selfhost-neon   | 51:40:25
 clang-cmake-armv8-global-isel | 51:21:36
 clang-cmake-thumbv8-full-sh   | 51:16:15
 clang-cmake-thumbv7-full-sh   | 50:38:48
 clang-cmake-armv7-full| 50:27:07
 clang-cmake-armv8-full| 50:25:17
 clang-cmake-armv7-quick   | 50:19:14
 clang-cmake-armv7-selfhost-neon   | 50:08:36
 clang-cmake-armv8-quick   | 49:59:30
 clang-cmake-armv7-selfhost| 49:51:30
 clang-cmake-armv8-lld | 49:40:53
 clang-bpf-build   | 46:28:36
 sanitizer-x86_64-linux| 45:14:40
 llvm-clang-x86_64-expensive-checks-win| 42:10:36
 clang-ppc64le-linux-multistage| 32:08:17
 aosp-O3-polly-before-vectorizer-unprofitable  | 24:36:57
 clang-atom-d525-fedora-rel| 22:54:23
 clang-x86_64-linux-selfhost-modules   | 22:43:50
 sanitizer-x86_64-linux-bootstrap-msan | 22:31:01
 sanitizer-x86_64-linux-bootstrap  | 22:29:24
 sanitizer-x86_64-linux-fast   | 21:47:07
 clang-with-lto-ubuntu | 21:45:13
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast  | 19:36:03
 clang-x64-ninja-win7  | 16:17:23
 clang-with-thin-lto-ubuntu| 15:47:01
 lldb-amd64-ninja-netbsd8  | 15:07:44
 clang-cuda-build  | 11:52:20
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast| 11:45:37
 sanitizer-ppc64le-linux   | 11:11:48
 sanitizer-ppc64be-linux   | 10:38:56
 clang-lld-x86_64-2stage   | 10:30:37
 libcxx-libcxxabi-libunwind-armv7-linux-noexceptions   | 10:13:50
 libcxx-libcxxabi-libunwind-armv8-linux| 09:57:55
 libcxx-libcxxabi-libunwind-armv7-linux| 09:57:13
 libcxx-libcxxabi-libunwind-armv8-linux-noexceptions   | 09:55:49
 libcxx-libcxxabi-libunwind-aarch64-linux-noexceptions | 09:55:09
 libcxx-libcxxabi-libunwind-aarch64-linux  | 09:54:48
 clang-s390x-linux-multistage  | 06:02:35
 polly-amd64-linux | 05:00:14
 polly-arm-linux   | 04:59:45
 libcxx-libcxxabi-x86_64-linux-debian  | 04:54:19
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx14| 04:33:10
 clang-ppc64le-linux-lnt   | 03:58:31
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx2a| 03:54:19
 clang-ppc64le-linux   | 03:48:31
 libcxx-libcxxabi-x86_64-linux-ubuntu-tsan | 03:44:45
 libcxx-libcxxabi-x86_64-linux-ubuntu-ubsan| 03:44:14
 libcxx-libcxxabi-libunwind-x86_64-linux-ubuntu| 03:44:03
 libcxx-libcxxabi-x86_64-linux-ubuntu-32bit| 03:43:12
 clang-cmake-x86_64-sde-avx512-linux   | 03:37:35
 clang-s390x-linux-lnt | 03:36:35
 sanitizer-x86_64-linux-bootstrap-ubsan| 03:32:46
 libcxx-libcxxabi-x86_64-linux-ubuntu-asan | 03:25:59
 libcxx-libcxxabi-x86_64-linux-ubuntu-msan | 03:23:25
 llvm-hexagon-elf  | 03:21:41
 clang-x64-windows-msvc| 03:21:35
 clang-ppc64be-linux-multistage| 03:19:48
 

[PATCH] D53457: clang-cl: Add "/clang:" pass-through arg support.

2018-10-26 Thread Neeraj K. Singh via Phabricator via cfe-commits
neerajksingh added a comment.

In https://reviews.llvm.org/D53457#1277315, @hans wrote:

>   One note about flag ordering: the /clang: flags are concatenated to the end 
> of
>   the argument list, so in cases where the last flag wins, the /clang: flags
>   will be chosen regardless of their order relative to other flags on the 
> driver
>   command line.
>
>
> This seems a little unfortunate. I wonder if it would be possible to not have 
> this restriction, i.e. to process these in-line with the rest of the flags?
>
> One way to achieve this would be to change Driver::ParseArgStrings() to 
> handle the "/clang:" arguments. After doing the regular option parsing, it 
> would look for "/clang:" options and substitute them for the underlying 
> option. This has the downside of adding some option-specific logic to 
> ParseArgStrings, but on the other hand it's less intrusive than passing 
> around the IsCLMode bool. Do you think something like this could work?


One difficulty occurs with options that have separated values, like the 
`/clang:-MF /clang:` case.  In this case, we need to take two /clang: 
arguments and process them next to each other in order to form a single 
coherent argument/value pair. Another option is to allow the user to specify 
the option like `/clang:"-MF "` and then require that the user 
specify any flags that need a value in a single /clang: argument.  This would 
require some code to split the value string on spaces before passing it on to 
clang argument parsing.

Do you have any preference or better suggestion for the option-with-value case?


https://reviews.llvm.org/D53457



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


[PATCH] D53715: [AST] Only store the needed data in WhileStmt.

2018-10-26 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rC Clang

https://reviews.llvm.org/D53715



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


r345433 - Revert "[PassManager/Sanitizer] Enable usage of ported AddressSanitizer passes with -fsanitize=address"

2018-10-26 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Fri Oct 26 15:51:51 2018
New Revision: 345433

URL: http://llvm.org/viewvc/llvm-project?rev=345433=rev
Log:
Revert "[PassManager/Sanitizer] Enable usage of ported AddressSanitizer passes 
with -fsanitize=address"

This reverts commit 8d6af840396f2da2e4ed6aab669214ae25443204 and commit
b78d19c287b6e4a9abc9fb0545de9a3106d38d3d which causes slower build times
by initializing the AddressSanitizer on every function run.

The corresponding revisions are https://reviews.llvm.org/D52814 and
https://reviews.llvm.org/D52739.

Removed:
cfe/trunk/test/CodeGen/asan-new-pm.ll
Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=345433=345432=345433=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Fri Oct 26 15:51:51 2018
@@ -52,7 +52,6 @@
 #include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h"
 #include "llvm/Transforms/InstCombine/InstCombine.h"
 #include "llvm/Transforms/Instrumentation.h"
-#include "llvm/Transforms/Instrumentation/AddressSanitizerPass.h"
 #include "llvm/Transforms/Instrumentation/BoundsChecking.h"
 #include "llvm/Transforms/Instrumentation/GCOVProfiler.h"
 #include "llvm/Transforms/ObjCARC.h"
@@ -1023,16 +1022,6 @@ void EmitAssemblyHelper::EmitAssemblyWit
CodeGenOpts.DebugPassManager);
   }
 }
-
-if (LangOpts.Sanitize.has(SanitizerKind::Address)) {
-  bool Recover = CodeGenOpts.SanitizeRecover.has(SanitizerKind::Address);
-  MPM.addPass(createModuleToFunctionPassAdaptor(
-  AddressSanitizerPass(/*CompileKernel=*/false, Recover,
-   CodeGenOpts.SanitizeAddressUseAfterScope)));
-  bool ModuleUseAfterScope = asanUseGlobalsGC(TargetTriple, CodeGenOpts);
-  MPM.addPass(AddressSanitizerPass(/*CompileKernel=*/false, Recover,
-   ModuleUseAfterScope));
-}
   }
 
   // FIXME: We still use the legacy pass manager to do code generation. We

Removed: cfe/trunk/test/CodeGen/asan-new-pm.ll
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/asan-new-pm.ll?rev=345432=auto
==
--- cfe/trunk/test/CodeGen/asan-new-pm.ll (original)
+++ cfe/trunk/test/CodeGen/asan-new-pm.ll (removed)
@@ -1,10 +0,0 @@
-; RUN: %clang_cc1 -S -emit-llvm -o - -fexperimental-new-pass-manager 
-fsanitize=address %s | FileCheck %s
-
-; CHECK: @llvm.global_ctors = {{.*}}@asan.module_ctor
-; CHECK: declare void @__asan_loadN
-
-define i32 @test_load(i32* %a) sanitize_address {
-entry:
-  %tmp1 = load i32, i32* %a, align 4
-  ret i32 %tmp1
-}


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


[PATCH] D53780: Fix bitcast to address space cast for coerced load/stores

2018-10-26 Thread David Salinas via Phabricator via cfe-commits
david-salinas updated this revision to Diff 171367.
david-salinas added a comment.

remove __attribute__((cpu)) __attribute__((hc)) from test


Repository:
  rC Clang

https://reviews.llvm.org/D53780

Files:
  lib/CodeGen/CGCall.cpp
  test/CodeGenCXX/address-space-cast-coerce.cpp


Index: test/CodeGenCXX/address-space-cast-coerce.cpp
===
--- /dev/null
+++ test/CodeGenCXX/address-space-cast-coerce.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 %s -triple=amdgcn-amd-amdhsa -emit-llvm -o - | FileCheck %s
+
+template struct my_vector_base;
+
+template
+struct my_vector_base {
+typedef T Native_vec_ __attribute__((ext_vector_type(1)));
+
+union {
+Native_vec_ data;
+struct {
+T x;
+};
+};
+};
+
+template
+struct my_vector_type : public my_vector_base {
+using my_vector_base::data;
+using typename my_vector_base::Native_vec_;
+
+template< typename U>
+my_vector_type(U x) noexcept
+{
+for (auto i = 0u; i != rank; ++i) data[i] = x;
+}
+my_vector_type& operator+=(const my_vector_type& x) noexcept
+{
+data += x.data;
+return *this;
+}
+};
+
+template
+inline
+my_vector_type operator+(
+const my_vector_type& x, const my_vector_type& y) noexcept
+{
+return my_vector_type{x} += y;
+}
+
+using char1 = my_vector_type;
+
+int mane() {
+
+char1 f1{1};
+char1 f2{1};
+
+// CHECK: %[[a:[^ ]+]] = addrspacecast i16 addrspace(5)* %{{[^ ]+}} to i16*
+// CHECK: %[[a:[^ ]+]] = addrspacecast %{{[^ ]+}} addrspace(5)* %{{[^ ]+}} to 
%{{[^ ]+}} 
+
+char1 f3 = f1 + f2;
+}
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -1253,8 +1253,8 @@
 
   // Otherwise do coercion through memory. This is stupid, but simple.
   Address Tmp = CreateTempAllocaForCoercion(CGF, Ty, Src.getAlignment());
-  Address Casted = CGF.Builder.CreateBitCast(Tmp, CGF.AllocaInt8PtrTy);
-  Address SrcCasted = CGF.Builder.CreateBitCast(Src, CGF.AllocaInt8PtrTy);
+  Address Casted = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(Tmp, 
CGF.AllocaInt8PtrTy);
+  Address SrcCasted = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(Src, 
CGF.AllocaInt8PtrTy);
   CGF.Builder.CreateMemCpy(Casted, SrcCasted,
   llvm::ConstantInt::get(CGF.IntPtrTy, SrcSize),
   false);
@@ -1335,8 +1335,8 @@
 // to that information.
 Address Tmp = CreateTempAllocaForCoercion(CGF, SrcTy, Dst.getAlignment());
 CGF.Builder.CreateStore(Src, Tmp);
-Address Casted = CGF.Builder.CreateBitCast(Tmp, CGF.AllocaInt8PtrTy);
-Address DstCasted = CGF.Builder.CreateBitCast(Dst, CGF.AllocaInt8PtrTy);
+Address Casted = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(Tmp, 
CGF.AllocaInt8PtrTy);
+Address DstCasted = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(Dst, 
CGF.AllocaInt8PtrTy);
 CGF.Builder.CreateMemCpy(DstCasted, Casted,
 llvm::ConstantInt::get(CGF.IntPtrTy, DstSize),
 false);


Index: test/CodeGenCXX/address-space-cast-coerce.cpp
===
--- /dev/null
+++ test/CodeGenCXX/address-space-cast-coerce.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 %s -triple=amdgcn-amd-amdhsa -emit-llvm -o - | FileCheck %s
+
+template struct my_vector_base;
+
+template
+struct my_vector_base {
+typedef T Native_vec_ __attribute__((ext_vector_type(1)));
+
+union {
+Native_vec_ data;
+struct {
+T x;
+};
+};
+};
+
+template
+struct my_vector_type : public my_vector_base {
+using my_vector_base::data;
+using typename my_vector_base::Native_vec_;
+
+template< typename U>
+my_vector_type(U x) noexcept
+{
+for (auto i = 0u; i != rank; ++i) data[i] = x;
+}
+my_vector_type& operator+=(const my_vector_type& x) noexcept
+{
+data += x.data;
+return *this;
+}
+};
+
+template
+inline
+my_vector_type operator+(
+const my_vector_type& x, const my_vector_type& y) noexcept
+{
+return my_vector_type{x} += y;
+}
+
+using char1 = my_vector_type;
+
+int mane() {
+
+char1 f1{1};
+char1 f2{1};
+
+// CHECK: %[[a:[^ ]+]] = addrspacecast i16 addrspace(5)* %{{[^ ]+}} to i16*
+// CHECK: %[[a:[^ ]+]] = addrspacecast %{{[^ ]+}} addrspace(5)* %{{[^ ]+}} to %{{[^ ]+}} 
+
+char1 f3 = f1 + f2;
+}
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -1253,8 +1253,8 @@
 
   // Otherwise do coercion through memory. This is stupid, but simple.
   Address Tmp = CreateTempAllocaForCoercion(CGF, 

[PATCH] D53697: [ASTImporter][Structural Eq] Check for isBeingDefined

2018-10-26 Thread Aleksei Sidorin via Phabricator via cfe-commits
a_sidorin added a comment.

Hi Gabor,
I wonder if it is possible to get into situation where non-equivalent decls are 
marked equivalent with this patch?  If yes, we can create a mapping between 
decls being imported and original decls as an alternative solution. However,  I 
cannot find any counterexample.




Comment at: lib/AST/ASTStructuralEquivalence.cpp:1037
+  // equality and we assume that the decls are equal.
+  if (D1->isBeingDefined() || D2->isBeingDefined())
+return true;

Is it worth it to assert if only one Decl should be in `isBeingDefined()` state 
at time?



Comment at: unittests/AST/ASTImporterTest.cpp:3729
 
+TEST_P(ASTImporterTestBase, ImportingTypedefShouldImportTheCompleteType) {
+  // We already have an incomplete underlying type in the "To" context.

Looks like this test is from another patch (D53693)?


Repository:
  rC Clang

https://reviews.llvm.org/D53697



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


[PATCH] D53781: [ASTMatchers] add a matcher for static locals

2018-10-26 Thread Joe Ranieri via Phabricator via cfe-commits
jranieri-grammatech created this revision.
jranieri-grammatech added reviewers: aaron.ballman, klimek, sbenza.
Herald added a subscriber: cfe-commits.

This adds a matcher, isStaticLocal, that matches local static variables (i.e. 
VarDecl::isStaticLocal).


Repository:
  rC Clang

https://reviews.llvm.org/D53781

Files:
  docs/LibASTMatchersReference.html
  include/clang/ASTMatchers/ASTMatchers.h
  lib/ASTMatchers/Dynamic/Registry.cpp
  unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp


Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -667,6 +667,14 @@
   EXPECT_TRUE(matches("void f() { static int X; }", M));
 }
 
+TEST(Matcher, VarDecl_IsStaticLocal) {
+  auto M = varDecl(isStaticLocal());
+  EXPECT_TRUE(matches("void f() { static int X; }", M));
+  EXPECT_TRUE(notMatches("static int X;", M));
+  EXPECT_TRUE(notMatches("void f() { int X; }", M));
+  EXPECT_TRUE(notMatches("int X;", M));
+}
+
 TEST(Matcher, VarDecl_StorageDuration) {
   std::string T =
 "void f() { int x; static int y; } int a;static int b;extern int c;";
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -378,6 +378,7 @@
   REGISTER_MATCHER(isPure);
   REGISTER_MATCHER(isScoped);
   REGISTER_MATCHER(isSignedInteger);
+  REGISTER_MATCHER(isStaticLocal);
   REGISTER_MATCHER(isStaticStorageClass);
   REGISTER_MATCHER(isStruct);
   REGISTER_MATCHER(isTemplateInstantiation);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -3300,6 +3300,20 @@
   InnerMatcher.matches(*Initializer, Finder, Builder));
 }
 
+/// \brief Matches a static variable with local scope.
+///
+/// Example matches y (matcher = varDecl(isStaticLocal()))
+/// \code
+/// void f() {
+///   int x;
+///   static int y;
+/// }
+/// static int z;
+/// \endcode
+AST_MATCHER(VarDecl, isStaticLocal) {
+  return Node.isStaticLocal();
+}
+
 /// Matches a variable declaration that has function scope and is a
 /// non-static local variable.
 ///
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -4123,6 +4123,18 @@
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1VarDecl.html;>VarDeclisStaticLocal
+Matches a static 
variable with local scope.
+
+Example matches y (matcher = varDecl(isStaticLocal()))
+void f() {
+  int x;
+  static int y;
+}
+static int z;
+
+
+
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1VarDecl.html;>VarDeclisStaticStorageClass
 Matches 
variablefunction declarations that have "static" storage
 class specifier ("static" keyword) written in the source.


Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -667,6 +667,14 @@
   EXPECT_TRUE(matches("void f() { static int X; }", M));
 }
 
+TEST(Matcher, VarDecl_IsStaticLocal) {
+  auto M = varDecl(isStaticLocal());
+  EXPECT_TRUE(matches("void f() { static int X; }", M));
+  EXPECT_TRUE(notMatches("static int X;", M));
+  EXPECT_TRUE(notMatches("void f() { int X; }", M));
+  EXPECT_TRUE(notMatches("int X;", M));
+}
+
 TEST(Matcher, VarDecl_StorageDuration) {
   std::string T =
 "void f() { int x; static int y; } int a;static int b;extern int c;";
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -378,6 +378,7 @@
   REGISTER_MATCHER(isPure);
   REGISTER_MATCHER(isScoped);
   REGISTER_MATCHER(isSignedInteger);
+  REGISTER_MATCHER(isStaticLocal);
   REGISTER_MATCHER(isStaticStorageClass);
   REGISTER_MATCHER(isStruct);
   REGISTER_MATCHER(isTemplateInstantiation);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -3300,6 +3300,20 @@
   InnerMatcher.matches(*Initializer, Finder, Builder));
 }
 
+/// \brief Matches a static variable with local scope.
+///
+/// Example matches y (matcher = varDecl(isStaticLocal()))
+/// \code
+/// void f() {
+///   int x;
+///   static int y;
+/// }
+/// static int z;
+/// \endcode
+AST_MATCHER(VarDecl, isStaticLocal) {
+  return Node.isStaticLocal();
+}
+
 /// Matches a variable declaration that has function scope and is a
 /// non-static local variable.
 

r345432 - [VFS] Add property 'fallthrough' that controls fallback to real file system.

2018-10-26 Thread Volodymyr Sapsai via cfe-commits
Author: vsapsai
Date: Fri Oct 26 15:16:24 2018
New Revision: 345432

URL: http://llvm.org/viewvc/llvm-project?rev=345432=rev
Log:
[VFS] Add property 'fallthrough' that controls fallback to real file system.

Default property value 'true' preserves current behavior. Value 'false' can be
used to create VFS "root", file system that gives better control over which
files compiler can use during compilation as there are no unpredictable
accesses to real file system.

Non-fallthrough use case changes how we treat multiple VFS overlay
files. Instead of all of them being at the same level just above a real
file system, now they are nested and subsequent overlays can refer to
files in previous overlays.

Change is done both in LLVM and Clang, corresponding LLVM commit is r345431.

rdar://problem/39465552

Reviewers: bruno, benlangmuir

Reviewed By: bruno

Subscribers: dexonsmith, cfe-commits, hiraditya

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


Added:
cfe/trunk/test/VFS/Inputs/Broken.framework/
cfe/trunk/test/VFS/Inputs/Broken.framework/Headers/
cfe/trunk/test/VFS/Inputs/Broken.framework/Headers/Error.h
cfe/trunk/test/VFS/Inputs/Broken.framework/Modules/
cfe/trunk/test/VFS/Inputs/Broken.framework/Modules/module.modulemap
cfe/trunk/test/VFS/Inputs/Broken.framework/VFSHeaders/
cfe/trunk/test/VFS/Inputs/Broken.framework/VFSHeaders/A.h
cfe/trunk/test/VFS/Inputs/vfsroot.yaml
cfe/trunk/test/VFS/vfsroot-include.c
cfe/trunk/test/VFS/vfsroot-module.m
cfe/trunk/test/VFS/vfsroot-with-overlay.c
Modified:
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=345432=345431=345432=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Fri Oct 26 15:16:24 2018
@@ -3297,25 +3297,27 @@ IntrusiveRefCntPtr Overlay(
-  new llvm::vfs::OverlayFileSystem(BaseFS));
+  IntrusiveRefCntPtr Result = BaseFS;
   // earlier vfs files are on the bottom
   for (const auto  : CI.getHeaderSearchOpts().VFSOverlayFiles) {
 llvm::ErrorOr> Buffer =
-BaseFS->getBufferForFile(File);
+Result->getBufferForFile(File);
 if (!Buffer) {
   Diags.Report(diag::err_missing_vfs_overlay_file) << File;
   continue;
 }
 
 IntrusiveRefCntPtr FS = llvm::vfs::getVFSFromYAML(
-std::move(Buffer.get()), /*DiagHandler*/ nullptr, File);
-if (FS)
-  Overlay->pushOverlay(FS);
-else
+std::move(Buffer.get()), /*DiagHandler*/ nullptr, File,
+/*DiagContext*/ nullptr, Result);
+if (!FS) {
   Diags.Report(diag::err_invalid_vfs_overlay) << File;
+  continue;
+}
+
+Result = FS;
   }
-  return Overlay;
+  return Result;
 }
 
 } // namespace clang

Added: cfe/trunk/test/VFS/Inputs/Broken.framework/Headers/Error.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/VFS/Inputs/Broken.framework/Headers/Error.h?rev=345432=auto
==
--- cfe/trunk/test/VFS/Inputs/Broken.framework/Headers/Error.h (added)
+++ cfe/trunk/test/VFS/Inputs/Broken.framework/Headers/Error.h Fri Oct 26 
15:16:24 2018
@@ -0,0 +1,3 @@
+// Error.h
+
+#error Should not include this header in a module

Added: cfe/trunk/test/VFS/Inputs/Broken.framework/Modules/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/VFS/Inputs/Broken.framework/Modules/module.modulemap?rev=345432=auto
==
--- cfe/trunk/test/VFS/Inputs/Broken.framework/Modules/module.modulemap (added)
+++ cfe/trunk/test/VFS/Inputs/Broken.framework/Modules/module.modulemap Fri Oct 
26 15:16:24 2018
@@ -0,0 +1,6 @@
+framework module Broken [extern_c] {
+  umbrella "Headers"
+  export *
+  module * { export * }
+}
+

Added: cfe/trunk/test/VFS/Inputs/Broken.framework/VFSHeaders/A.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/VFS/Inputs/Broken.framework/VFSHeaders/A.h?rev=345432=auto
==
--- cfe/trunk/test/VFS/Inputs/Broken.framework/VFSHeaders/A.h (added)
+++ cfe/trunk/test/VFS/Inputs/Broken.framework/VFSHeaders/A.h Fri Oct 26 
15:16:24 2018
@@ -0,0 +1 @@
+// A.h

Added: cfe/trunk/test/VFS/Inputs/vfsroot.yaml
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/VFS/Inputs/vfsroot.yaml?rev=345432=auto
==
--- cfe/trunk/test/VFS/Inputs/vfsroot.yaml (added)
+++ cfe/trunk/test/VFS/Inputs/vfsroot.yaml Fri Oct 26 15:16:24 2018
@@ -0,0 +1,55 @@
+{
+  'version': 0,
+  'use-external-names': false,
+  'fallthrough': false,
+  'roots': [
+{ 'name': '/tests', 'type': 'directory',
+  'contents': [
+  

[PATCH] D50539: [VFS] Add property 'fallthrough' that controls fallback to real file system.

2018-10-26 Thread Volodymyr Sapsai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL345431: [VFS] Add property fallthrough that 
controls fallback to real file system. (authored by vsapsai, committed by ).
Herald added subscribers: llvm-commits, kristina.

Changed prior to commit:
  https://reviews.llvm.org/D50539?vs=171210=171363#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50539

Files:
  llvm/trunk/lib/Support/VirtualFileSystem.cpp
  llvm/trunk/unittests/Support/VirtualFileSystemTest.cpp

Index: llvm/trunk/lib/Support/VirtualFileSystem.cpp
===
--- llvm/trunk/lib/Support/VirtualFileSystem.cpp
+++ llvm/trunk/lib/Support/VirtualFileSystem.cpp
@@ -993,16 +993,44 @@
   static bool classof(const Entry *E) { return E->getKind() == EK_File; }
 };
 
+// FIXME: reuse implementation common with OverlayFSDirIterImpl as these
+// iterators are conceptually similar.
 class VFSFromYamlDirIterImpl : public llvm::vfs::detail::DirIterImpl {
   std::string Dir;
   RedirectingDirectoryEntry::iterator Current, End;
 
-  std::error_code incrementImpl();
+  // To handle 'fallthrough' mode we need to iterate at first through
+  // RedirectingDirectoryEntry and then through ExternalFS. These operations are
+  // done sequentially, we just need to keep a track of what kind of iteration
+  // we are currently performing.
+
+  /// Flag telling if we should iterate through ExternalFS or stop at the last
+  /// RedirectingDirectoryEntry::iterator.
+  bool IterateExternalFS;
+  /// Flag telling if we have switched to iterating through ExternalFS.
+  bool IsExternalFSCurrent = false;
+  FileSystem 
+  directory_iterator ExternalDirIter;
+  llvm::StringSet<> SeenNames;
+
+  /// To combine multiple iterations, different methods are responsible for
+  /// different iteration steps.
+  /// @{
+
+  /// Responsible for dispatching between RedirectingDirectoryEntry iteration
+  /// and ExternalFS iteration.
+  std::error_code incrementImpl(bool IsFirstTime);
+  /// Responsible for RedirectingDirectoryEntry iteration.
+  std::error_code incrementContent(bool IsFirstTime);
+  /// Responsible for ExternalFS iteration.
+  std::error_code incrementExternal();
+  /// @}
 
 public:
   VFSFromYamlDirIterImpl(const Twine ,
  RedirectingDirectoryEntry::iterator Begin,
  RedirectingDirectoryEntry::iterator End,
+ bool IterateExternalFS, FileSystem ,
  std::error_code );
 
   std::error_code increment() override;
@@ -1028,6 +1056,7 @@
 ///   'case-sensitive': 
 ///   'use-external-names': 
 ///   'overlay-relative': 
+///   'fallthrough': 
 ///
 /// Virtual directories are represented as
 /// \verbatim
@@ -1091,6 +1120,10 @@
   /// Whether to use to use the value of 'external-contents' for the
   /// names of files.  This global value is overridable on a per-file basis.
   bool UseExternalNames = true;
+
+  /// Whether to attempt a file lookup in external file system after it wasn't
+  /// found in VFS.
+  bool IsFallthrough = true;
   /// @}
 
   /// Virtual file paths and external files could be canonicalized without "..",
@@ -1141,6 +1174,8 @@
 ErrorOr E = lookupPath(Dir);
 if (!E) {
   EC = E.getError();
+  if (IsFallthrough && EC == errc::no_such_file_or_directory)
+return ExternalFS->dir_begin(Dir, EC);
   return {};
 }
 ErrorOr S = status(Dir, *E);
@@ -1156,7 +1191,8 @@
 
 auto *D = cast(*E);
 return directory_iterator(std::make_shared(
-Dir, D->contents_begin(), D->contents_end(), EC));
+Dir, D->contents_begin(), D->contents_end(),
+/*IterateExternalFS=*/IsFallthrough, *ExternalFS, EC));
   }
 
   void setExternalContentsPrefixDir(StringRef PrefixDir) {
@@ -1538,6 +1574,7 @@
 KeyStatusPair("case-sensitive", false),
 KeyStatusPair("use-external-names", false),
 KeyStatusPair("overlay-relative", false),
+KeyStatusPair("fallthrough", false),
 KeyStatusPair("roots", true),
 };
 
@@ -1595,6 +1632,9 @@
   } else if (Key == "use-external-names") {
 if (!parseScalarBool(I.getValue(), FS->UseExternalNames))
   return false;
+  } else if (Key == "fallthrough") {
+if (!parseScalarBool(I.getValue(), FS->IsFallthrough))
+  return false;
   } else {
 llvm_unreachable("key missing from Keys");
   }
@@ -1760,8 +1800,13 @@
 
 ErrorOr RedirectingFileSystem::status(const Twine ) {
   ErrorOr Result = lookupPath(Path);
-  if (!Result)
+  if (!Result) {
+if (IsFallthrough &&
+Result.getError() == llvm::errc::no_such_file_or_directory) {
+  return ExternalFS->status(Path);
+}
 return Result.getError();
+  }
   return status(Path, *Result);
 }
 
@@ -1793,8 +1838,13 @@
 ErrorOr>
 RedirectingFileSystem::openFileForRead(const Twine ) {
   ErrorOr E = lookupPath(Path);
-  if (!E)
+  if (!E) {
+if 

[PATCH] D51949: [clang-tidy] new check 'readability-isolate-declaration'

2018-10-26 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: docs/ReleaseNotes.rst:142
+
+  Diagnoses local variable declarations declaring more than one variable and
+  tries to refactor the code to one statement per declaration.

May be Finds or Detects like other checks? Same in documentation.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51949



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


[PATCH] D53780: Fix bitcast to address space cast for coerced load/stores

2018-10-26 Thread David Salinas via Phabricator via cfe-commits
david-salinas created this revision.
david-salinas added reviewers: yaxunl, scchan.
Herald added a subscriber: cfe-commits.

Coerced load/stores through memory do not take into account potential address 
space differences  when it creates its bitcasts.


Repository:
  rC Clang

https://reviews.llvm.org/D53780

Files:
  lib/CodeGen/CGCall.cpp
  test/CodeGenCXX/address-space-cast-coerce.cpp


Index: test/CodeGenCXX/address-space-cast-coerce.cpp
===
--- /dev/null
+++ test/CodeGenCXX/address-space-cast-coerce.cpp
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 %s -triple=amdgcn-amd-amdhsa -emit-llvm -o - | FileCheck %s
+
+template struct my_vector_base;
+
+template
+struct my_vector_base {
+typedef T Native_vec_ __attribute__((ext_vector_type(1)));
+
+union {
+Native_vec_ data;
+struct {
+T x;
+};
+};
+};
+
+template
+struct my_vector_type : public my_vector_base {
+using my_vector_base::data;
+using typename my_vector_base::Native_vec_;
+
+template< typename U>
+__attribute__((cpu)) __attribute__((hc))
+my_vector_type(U x) noexcept
+{
+for (auto i = 0u; i != rank; ++i) data[i] = x;
+}
+__attribute__((cpu)) __attribute__((hc))
+my_vector_type& operator+=(const my_vector_type& x) noexcept
+{
+data += x.data;
+return *this;
+}
+};
+
+template
+__attribute__((cpu)) __attribute__((hc))
+inline
+my_vector_type operator+(
+const my_vector_type& x, const my_vector_type& y) noexcept
+{
+return my_vector_type{x} += y;
+}
+
+using char1 = my_vector_type;
+
+int main() {
+
+char1 f1{1};
+char1 f2{1};
+
+// CHECK: %[[a:[^ ]+]] = addrspacecast i16 addrspace(5)* %{{[^ ]+}} to i16*
+// CHECK: %[[a:[^ ]+]] = addrspacecast %{{[^ ]+}} addrspace(5)* %{{[^ ]+}} to 
%{{[^ ]+}} 
+
+char1 f3 = f1 + f2;
+}
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -1253,8 +1253,8 @@
 
   // Otherwise do coercion through memory. This is stupid, but simple.
   Address Tmp = CreateTempAllocaForCoercion(CGF, Ty, Src.getAlignment());
-  Address Casted = CGF.Builder.CreateBitCast(Tmp, CGF.AllocaInt8PtrTy);
-  Address SrcCasted = CGF.Builder.CreateBitCast(Src, CGF.AllocaInt8PtrTy);
+  Address Casted = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(Tmp, 
CGF.AllocaInt8PtrTy);
+  Address SrcCasted = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(Src, 
CGF.AllocaInt8PtrTy);
   CGF.Builder.CreateMemCpy(Casted, SrcCasted,
   llvm::ConstantInt::get(CGF.IntPtrTy, SrcSize),
   false);
@@ -1335,8 +1335,8 @@
 // to that information.
 Address Tmp = CreateTempAllocaForCoercion(CGF, SrcTy, Dst.getAlignment());
 CGF.Builder.CreateStore(Src, Tmp);
-Address Casted = CGF.Builder.CreateBitCast(Tmp, CGF.AllocaInt8PtrTy);
-Address DstCasted = CGF.Builder.CreateBitCast(Dst, CGF.AllocaInt8PtrTy);
+Address Casted = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(Tmp, 
CGF.AllocaInt8PtrTy);
+Address DstCasted = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(Dst, 
CGF.AllocaInt8PtrTy);
 CGF.Builder.CreateMemCpy(DstCasted, Casted,
 llvm::ConstantInt::get(CGF.IntPtrTy, DstSize),
 false);


Index: test/CodeGenCXX/address-space-cast-coerce.cpp
===
--- /dev/null
+++ test/CodeGenCXX/address-space-cast-coerce.cpp
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 %s -triple=amdgcn-amd-amdhsa -emit-llvm -o - | FileCheck %s
+
+template struct my_vector_base;
+
+template
+struct my_vector_base {
+typedef T Native_vec_ __attribute__((ext_vector_type(1)));
+
+union {
+Native_vec_ data;
+struct {
+T x;
+};
+};
+};
+
+template
+struct my_vector_type : public my_vector_base {
+using my_vector_base::data;
+using typename my_vector_base::Native_vec_;
+
+template< typename U>
+__attribute__((cpu)) __attribute__((hc))
+my_vector_type(U x) noexcept
+{
+for (auto i = 0u; i != rank; ++i) data[i] = x;
+}
+__attribute__((cpu)) __attribute__((hc))
+my_vector_type& operator+=(const my_vector_type& x) noexcept
+{
+data += x.data;
+return *this;
+}
+};
+
+template
+__attribute__((cpu)) __attribute__((hc))
+inline
+my_vector_type operator+(
+const my_vector_type& x, const my_vector_type& y) noexcept
+{
+return my_vector_type{x} += y;
+}
+
+using char1 = my_vector_type;
+
+int main() {
+
+char1 f1{1};
+char1 f2{1};
+
+// CHECK: %[[a:[^ ]+]] = addrspacecast i16 addrspace(5)* %{{[^ ]+}} to i16*
+// CHECK: %[[a:[^ 

[PATCH] D51949: [clang-tidy] new check 'readability-isolate-declaration'

2018-10-26 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 171361.
JonasToth added a comment.

- [Fix] wrong condition in matcher coming from incorrect code change


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51949

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/IsolateDeclarationCheck.cpp
  clang-tidy/readability/IsolateDeclarationCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/utils/LexerUtils.cpp
  clang-tidy/utils/LexerUtils.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-isolate-declaration.rst
  test/clang-tidy/readability-isolate-declaration-cxx17.cpp
  test/clang-tidy/readability-isolate-declaration-fixing.cpp
  test/clang-tidy/readability-isolate-declaration.c
  test/clang-tidy/readability-isolate-declaration.cpp

Index: test/clang-tidy/readability-isolate-declaration.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-isolate-declaration.cpp
@@ -0,0 +1,412 @@
+// RUN: %check_clang_tidy %s readability-isolate-declaration %t
+
+void f() {
+  int i;
+}
+
+void f2() {
+  int i, j, *k, lala = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int i;
+  // CHECK-FIXES: {{^  }}int j;
+  // CHECK-FIXES: {{^  }}int *k;
+  // CHECK-FIXES: {{^  }}int lala = 42;
+
+  int normal, weird = /* comment */ 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int normal;
+  // CHECK-FIXES: {{^  }}int weird = /* comment */ 42;
+
+  int /* here is a comment */ v1,
+  // another comment
+  v2 = 42 // Ok, more comments
+  ;
+  // CHECK-MESSAGES: [[@LINE-4]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int /* here is a comment */ v1;
+  // CHECK-FIXES: {{^  }}int /* here is a comment */ // another comment
+  // CHECK-FIXES: {{^  }}v2 = 42 // Ok, more comments
+  // CHECK-FIXES: {{^  }};
+
+  auto int1 = 42, int2 = 0, int3 = 43;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: auto int1 = 42;
+  // CHECK-FIXES: {{^  }}auto int2 = 0;
+  // CHECK-FIXES: {{^  }}auto int3 = 43;
+
+  decltype(auto) ptr1 = , ptr2 = 
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: decltype(auto) ptr1 = 
+  // CHECK-FIXES: {{^  }}decltype(auto) ptr2 = 
+
+  decltype(k) ptr3 = , ptr4 = 
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: decltype(k) ptr3 = 
+  // CHECK-FIXES: {{^  }}decltype(k) ptr4 = 
+}
+
+void f3() {
+  int i, *pointer1;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int i;
+  // CHECK-FIXES: {{^  }}int *pointer1;
+  //
+  int *pointer2 = nullptr, *pointer3 = 
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int *pointer2 = nullptr;
+  // CHECK-FIXES: {{^  }}int *pointer3 = 
+
+  int *(i_ptr) = nullptr, *((i_ptr2));
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int *(i_ptr) = nullptr;
+  // CHECK-FIXES: {{^  }}int *((i_ptr2));
+
+  float(*f_ptr)[42], (((f_value))) = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: float (*f_ptr)[42];
+  // CHECK-FIXES: {{^  }}float (((f_value))) = 42;
+
+  float(((*f_ptr2)))[42], ((*f_ptr3)), f_value2 = 42.f;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: float (((*f_ptr2)))[42];
+  // CHECK-FIXES: {{^  }}float ((*f_ptr3));
+  // CHECK-FIXES: {{^  }}float f_value2 = 42.f;
+
+  float(((*f_ptr4)))[42], *f_ptr5, ((f_value3));
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: float (((*f_ptr4)))[42];
+  // CHECK-FIXES: {{^  }}float *f_ptr5;
+  // CHECK-FIXES: {{^  }}float ((f_value3));
+
+  void(((*f2))(int)), (*g2)(int, float);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: void (((*f2))(int));
+  // CHECK-FIXES: {{^  }}void (*g2)(int, float);
+
+  float(*(*(*f_ptr6)))[42], (*f_ptr7);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: float (*(*(*f_ptr6)))[42];
+  // CHECK-FIXES: {{^  }}float (*f_ptr7);
+}
+
+void f4() {
+  double d = 42. /* foo */, z = 43., /* hi */ y, c /* */ /*  */, l = 2.;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: 

[PATCH] D53443: [OpenMP][NVPTX] Enable default scheduling for parallel for in non-SPMD cases.

2018-10-26 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 171352.
gtbercea added a comment.

  Add test.


Repository:
  rC Clang

https://reviews.llvm.org/D53443

Files:
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  test/OpenMP/nvptx_parallel_for_codegen.cpp


Index: test/OpenMP/nvptx_parallel_for_codegen.cpp
===
--- test/OpenMP/nvptx_parallel_for_codegen.cpp
+++ test/OpenMP/nvptx_parallel_for_codegen.cpp
@@ -57,7 +57,10 @@
 // CHECK: store i32 0, {{.*}} [[OMP_LB:%.+]],
 // CHECK: store i32 9, {{.*}} [[OMP_UB:%.+]],
 // CHECK: store i32 1, {{.*}} [[OMP_ST:%.+]],
-// CHECK: call void @__kmpc_for_static_init_4({{.*}} i32 34, {{.*}} 
[[OMP_LB]], {{.*}} [[OMP_UB]], {{.*}} [[OMP_ST]], i32 1, i32 1)
+// CHECK: call void @__kmpc_for_static_init_4({{.*}} i32 33, {{.*}} 
[[OMP_LB]], {{.*}} [[OMP_UB]], {{.*}} [[OMP_ST]], i32 1, i32 1)
+// CHECK: br label %[[OMP_DISPATCH_COND:.+]]
+
+// CHECK: [[OMP_DISPATCH_COND]]
 // CHECK: [[OMP_UB_1:%.+]] = load {{.*}} [[OMP_UB]]
 // CHECK: [[COMP_1:%.+]] = icmp sgt {{.*}} [[OMP_UB_1]]
 // CHECK: br i1 [[COMP_1]], label %[[COND_TRUE:.+]], label %[[COND_FALSE:.+]]
@@ -74,6 +77,12 @@
 // CHECK: store i32 [[COND_RES]], i32* [[OMP_UB]]
 // CHECK: [[OMP_LB_1:%.+]] = load i32, i32* [[OMP_LB]]
 // CHECK: store i32 [[OMP_LB_1]], i32* [[OMP_IV]]
+// CHECK: [[OMP_IV_1:%.+]] = load i32, i32* [[OMP_IV]]
+// CHECK: [[OMP_UB_3:%.+]] = load i32, i32* [[OMP_UB]]
+// CHECK: [[COMP_2:%.+]] = icmp sle i32 [[OMP_IV_1]], [[OMP_UB_3]]
+// CHECK: br i1 [[COMP_2]], label %[[DISPATCH_BODY:.+]], label 
%[[DISPATCH_END:.+]]
+
+// CHECK: [[DISPATCH_BODY]]
 // CHECK: br label %[[OMP_INNER_FOR_COND:.+]]
 
 // CHECK: [[OMP_INNER_FOR_COND]]
@@ -94,7 +103,20 @@
 // CHECK: store i32 [[ADD_1]], i32* [[OMP_IV]]
 // CHECK: br label %[[OMP_INNER_FOR_COND]]
 
-// CHECK: [[OMP_INNER_FOR_END]]
+// CHECK: [[OMP_INNER_FOR_COND]]
+// CHECK: br label %[[OMP_DISPATCH_INC:.+]]
+
+// CHECK: [[OMP_DISPATCH_INC]]
+// CHECK: [[OMP_LB_2:%.+]] = load i32, i32* [[OMP_LB]]
+// CHECK: [[OMP_ST_1:%.+]] = load i32, i32* [[OMP_ST]]
+// CHECK: [[ADD_2:%.+]] = add nsw i32 [[OMP_LB_2]], [[OMP_ST_1]]
+// CHECK: store i32 [[ADD_2]], i32* [[OMP_LB]]
+// CHECK: [[OMP_UB_5:%.+]] = load i32, i32* [[OMP_UB]]
+// CHECK: [[OMP_ST_2:%.+]] = load i32, i32* [[OMP_ST]]
+// CHECK: [[ADD_3:%.+]] = add nsw i32 [[OMP_UB_5]], [[OMP_ST_2]]
+// CHECK: store i32 [[ADD_3]], i32* [[OMP_UB]]
+
+// CHECK: [[DISPATCH_END]]
 // CHECK: call void @__kmpc_for_static_fini(
 // CHECK: ret void
 
Index: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
===
--- lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
+++ lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
@@ -4238,16 +4238,17 @@
 Chunk = CGF.EmitScalarConversion(getNVPTXNumThreads(CGF),
 CGF.getContext().getIntTypeForBitwidth(32, /*Signed=*/0),
 S.getIterationVariable()->getType(), S.getBeginLoc());
+return;
   }
+  CGOpenMPRuntime::getDefaultDistScheduleAndChunk(
+  CGF, S, ScheduleKind, Chunk);
 }
 
 void CGOpenMPRuntimeNVPTX::getDefaultScheduleAndChunk(
 CodeGenFunction , const OMPLoopDirective ,
 OpenMPScheduleClauseKind ,
 llvm::Value *) const {
-  if (getExecutionMode() == CGOpenMPRuntimeNVPTX::EM_SPMD) {
-ScheduleKind = OMPC_SCHEDULE_static;
-Chunk = CGF.Builder.getIntN(CGF.getContext().getTypeSize(
-S.getIterationVariable()->getType()), 1);
-  }
+  ScheduleKind = OMPC_SCHEDULE_static;
+  Chunk = CGF.Builder.getIntN(CGF.getContext().getTypeSize(
+  S.getIterationVariable()->getType()), 1);
 }


Index: test/OpenMP/nvptx_parallel_for_codegen.cpp
===
--- test/OpenMP/nvptx_parallel_for_codegen.cpp
+++ test/OpenMP/nvptx_parallel_for_codegen.cpp
@@ -57,7 +57,10 @@
 // CHECK: store i32 0, {{.*}} [[OMP_LB:%.+]],
 // CHECK: store i32 9, {{.*}} [[OMP_UB:%.+]],
 // CHECK: store i32 1, {{.*}} [[OMP_ST:%.+]],
-// CHECK: call void @__kmpc_for_static_init_4({{.*}} i32 34, {{.*}} [[OMP_LB]], {{.*}} [[OMP_UB]], {{.*}} [[OMP_ST]], i32 1, i32 1)
+// CHECK: call void @__kmpc_for_static_init_4({{.*}} i32 33, {{.*}} [[OMP_LB]], {{.*}} [[OMP_UB]], {{.*}} [[OMP_ST]], i32 1, i32 1)
+// CHECK: br label %[[OMP_DISPATCH_COND:.+]]
+
+// CHECK: [[OMP_DISPATCH_COND]]
 // CHECK: [[OMP_UB_1:%.+]] = load {{.*}} [[OMP_UB]]
 // CHECK: [[COMP_1:%.+]] = icmp sgt {{.*}} [[OMP_UB_1]]
 // CHECK: br i1 [[COMP_1]], label %[[COND_TRUE:.+]], label %[[COND_FALSE:.+]]
@@ -74,6 +77,12 @@
 // CHECK: store i32 [[COND_RES]], i32* [[OMP_UB]]
 // CHECK: [[OMP_LB_1:%.+]] = load i32, i32* [[OMP_LB]]
 // CHECK: store i32 [[OMP_LB_1]], i32* [[OMP_IV]]
+// CHECK: [[OMP_IV_1:%.+]] = load i32, i32* [[OMP_IV]]
+// CHECK: [[OMP_UB_3:%.+]] = load i32, i32* [[OMP_UB]]
+// CHECK: [[COMP_2:%.+]] = icmp sle i32 [[OMP_IV_1]], [[OMP_UB_3]]
+// CHECK: br i1 [[COMP_2]], label %[[DISPATCH_BODY:.+]], label %[[DISPATCH_END:.+]]
+
+// CHECK: [[DISPATCH_BODY]]
 // CHECK: br label 

[PATCH] D53621: Support for groups of attributes in #pragma clang attribute

2018-10-26 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman accepted this revision.
arphaman added a comment.

LGTM too when Aaron's comments are addressed


https://reviews.llvm.org/D53621



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


[PATCH] D51949: [clang-tidy] new check 'readability-isolate-declaration'

2018-10-26 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 171346.
JonasToth marked 16 inline comments as done.
JonasToth added a comment.

- address review comments


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51949

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/IsolateDeclarationCheck.cpp
  clang-tidy/readability/IsolateDeclarationCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/utils/LexerUtils.cpp
  clang-tidy/utils/LexerUtils.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-isolate-declaration.rst
  test/clang-tidy/readability-isolate-declaration-cxx17.cpp
  test/clang-tidy/readability-isolate-declaration-fixing.cpp
  test/clang-tidy/readability-isolate-declaration.c
  test/clang-tidy/readability-isolate-declaration.cpp

Index: test/clang-tidy/readability-isolate-declaration.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-isolate-declaration.cpp
@@ -0,0 +1,412 @@
+// RUN: %check_clang_tidy %s readability-isolate-declaration %t
+
+void f() {
+  int i;
+}
+
+void f2() {
+  int i, j, *k, lala = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int i;
+  // CHECK-FIXES: {{^  }}int j;
+  // CHECK-FIXES: {{^  }}int *k;
+  // CHECK-FIXES: {{^  }}int lala = 42;
+
+  int normal, weird = /* comment */ 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int normal;
+  // CHECK-FIXES: {{^  }}int weird = /* comment */ 42;
+
+  int /* here is a comment */ v1,
+  // another comment
+  v2 = 42 // Ok, more comments
+  ;
+  // CHECK-MESSAGES: [[@LINE-4]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int /* here is a comment */ v1;
+  // CHECK-FIXES: {{^  }}int /* here is a comment */ // another comment
+  // CHECK-FIXES: {{^  }}v2 = 42 // Ok, more comments
+  // CHECK-FIXES: {{^  }};
+
+  auto int1 = 42, int2 = 0, int3 = 43;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: auto int1 = 42;
+  // CHECK-FIXES: {{^  }}auto int2 = 0;
+  // CHECK-FIXES: {{^  }}auto int3 = 43;
+
+  decltype(auto) ptr1 = , ptr2 = 
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: decltype(auto) ptr1 = 
+  // CHECK-FIXES: {{^  }}decltype(auto) ptr2 = 
+
+  decltype(k) ptr3 = , ptr4 = 
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: decltype(k) ptr3 = 
+  // CHECK-FIXES: {{^  }}decltype(k) ptr4 = 
+}
+
+void f3() {
+  int i, *pointer1;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int i;
+  // CHECK-FIXES: {{^  }}int *pointer1;
+  //
+  int *pointer2 = nullptr, *pointer3 = 
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int *pointer2 = nullptr;
+  // CHECK-FIXES: {{^  }}int *pointer3 = 
+
+  int *(i_ptr) = nullptr, *((i_ptr2));
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: int *(i_ptr) = nullptr;
+  // CHECK-FIXES: {{^  }}int *((i_ptr2));
+
+  float(*f_ptr)[42], (((f_value))) = 42;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: float (*f_ptr)[42];
+  // CHECK-FIXES: {{^  }}float (((f_value))) = 42;
+
+  float(((*f_ptr2)))[42], ((*f_ptr3)), f_value2 = 42.f;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: float (((*f_ptr2)))[42];
+  // CHECK-FIXES: {{^  }}float ((*f_ptr3));
+  // CHECK-FIXES: {{^  }}float f_value2 = 42.f;
+
+  float(((*f_ptr4)))[42], *f_ptr5, ((f_value3));
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: float (((*f_ptr4)))[42];
+  // CHECK-FIXES: {{^  }}float *f_ptr5;
+  // CHECK-FIXES: {{^  }}float ((f_value3));
+
+  void(((*f2))(int)), (*g2)(int, float);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: void (((*f2))(int));
+  // CHECK-FIXES: {{^  }}void (*g2)(int, float);
+
+  float(*(*(*f_ptr6)))[42], (*f_ptr7);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
+  // CHECK-FIXES: float (*(*(*f_ptr6)))[42];
+  // CHECK-FIXES: {{^  }}float (*f_ptr7);
+}
+
+void f4() {
+  double d = 42. /* foo */, z = 43., /* hi */ y, c /* */ /*  */, l = 2.;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: 

[PATCH] D51949: [clang-tidy] new check 'readability-isolate-declaration'

2018-10-26 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments.



Comment at: clang-tidy/readability/IsolateDeclarationCheck.cpp:52
+ const LangOptions ) {
+  assert(Indirections >= 0 && "Indirections must be non-negative");
+  if (Indirections == 0)

aaron.ballman wrote:
> JonasToth wrote:
> > aaron.ballman wrote:
> > > This assertion suggests that `Indirections` should be `unsigned` and that 
> > > you perform the assertion before doing a decrement to ensure it isn't 
> > > trying to decrement past 0.
> > Because the decrement is post-fix it will decrement past 0 on the breaking 
> > condition.
> > Having `unsigned` will result in a wrap (is defined, but still slightly 
> > non-obvious).
> > 
> > I could make a `do - while`, then the condition can be `--Indirections != 
> > 0`. I would just like to follow the CPPCG that say 'don't use unsigned 
> > unless you need modulo arithmetic'.
> I disagree with this logic (personally, I think this is a code smell), but 
> don't feel strongly enough about it to ask you to change it.
I totally see the point, and it started as `unsigned` as well, but it felt 
uncomfortable. thanks for letting me do it :)



Comment at: docs/clang-tidy/checks/readability-isolate-declaration.rst:3
+
+readability-isolate-declarationaration
+==

aaron.ballman wrote:
> Typo. declarationaration -> declaration
> 
> (Don't forget to fix the underlines as well.)
That was definitly too deep in the night :D



Comment at: docs/clang-tidy/checks/readability-isolate-declaration.rst:45
+
+Global variables and member variables are excluded.
+

aaron.ballman wrote:
> Why are global variables excluded from this check? It seems like they should 
> have the exact same behavior as local variables in terms of the 
> transformation, no?
I thought so too, but take a look at the AST:

```
int global_i, global_j = 42, global_k;
void f() {
int local_i, local_j = 42, local_k;
}
```

```
|-VarDecl 0x55c428c4ab08  col:5 global_i 'int'
|-VarDecl 0x55c428c4abc0  col:15 global_j 'int' cinit
| `-IntegerLiteral 0x55c428c4ac20  'int' 42
|-VarDecl 0x55c428c4ac58  col:30 global_k 'int'
`-FunctionDecl 0x55c428c4ad30  line:2:6 f 'void ()'
  `-CompoundStmt 0x55c428c4af90 
`-DeclStmt 0x55c428c4af78 
  |-VarDecl 0x55c428c4ade8  col:9 local_i 'int'
  |-VarDecl 0x55c428c4ae60  col:18 local_j 'int' cinit
  | `-IntegerLiteral 0x55c428c4aec0  'int' 42
  `-VarDecl 0x55c428c4aef8  col:32 local_k 'int'
```

The locals create a `DeclStmt` and the globals don't, right now the 
transformation depends on the fact that its a `DeclStmt`, similar to class 
members that are `FieldDecl`.

I did short investigation on the issue, but couldn't think of a good way to fix 
that issue. I was not capable of "grouping" these decls even though they are 
together. Maybe I just missed something obvious, but right it's not supported. 
I would love to actually support it tough.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51949



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


[PATCH] D50860: [libc++][test] Remove non-portable assumption that thread's constructor allocates with ::new

2018-10-26 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter updated this revision to Diff 171344.
CaseyCarter added a comment.

Clarify use of `numAllocs`.


https://reviews.llvm.org/D50860

Files:
  
test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp


Index: 
test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
===
--- 
test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
+++ 
test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
@@ -31,17 +31,19 @@
 
 void* operator new(std::size_t s) TEST_THROW_SPEC(std::bad_alloc)
 {
-if (throw_one == 0)
-TEST_THROW(std::bad_alloc());
---throw_one;
+unsigned expected = throw_one;
+do {
+if (expected == 0) TEST_THROW(std::bad_alloc());
+} while (!throw_one.compare_exchange_weak(expected, expected - 1));
 ++outstanding_new;
 void* ret = std::malloc(s);
 if (!ret) std::abort(); // placate MSVC's unchecked malloc warning
 return ret;
 }
 
 void  operator delete(void* p) TEST_NOEXCEPT
 {
+if (!p) return;
 --outstanding_new;
 std::free(p);
 }
@@ -109,21 +111,23 @@
 //  B std::thread's constructor should properly handle exceptions and not leak
 //memory.
 // Plan:
-//  1 Create a thread and count the number of allocations, 'N', it performs.
+//  1 Create a thread and count the number of allocations, 'numAllocs', it 
performs.
 //  2 For each allocation performed run a test where that allocation throws.
 //2.1 check that the exception can be caught in the parent thread.
 //2.2 Check that the functor has not been called.
 //2.3 Check that no memory allocated by the creation of the thread is 
leaked.
-//  3 Finally check that a thread runs successfully if we throw after 'N+1'
+//  3 Finally check that a thread runs successfully if we throw after 
'numAllocs+1'
 //allocations.
+int numAllocs;
+
 void test_throwing_new_during_thread_creation() {
 #ifndef TEST_HAS_NO_EXCEPTIONS
 throw_one = 0xFFF;
 {
 std::thread t(f);
 t.join();
 }
-const int numAllocs = 0xFFF - throw_one;
+numAllocs = 0xFFF - throw_one;
 // i <= numAllocs means the last iteration is expected not to throw.
 for (int i=0; i <= numAllocs; ++i) {
 throw_one = i;
@@ -167,16 +171,16 @@
 }
 G::op_run = false;
 #ifndef TEST_HAS_NO_EXCEPTIONS
-{
+if (numAllocs > 0) { // Creating a thread might not call new at all.
 try
 {
 throw_one = 0;
 assert(G::n_alive == 0);
 assert(!G::op_run);
 std::thread t((G()));
 assert(false);
 }
-catch (...)
+catch (std::bad_alloc const&)
 {
 throw_one = 0x;
 assert(G::n_alive == 0);


Index: test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
===
--- test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
+++ test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp
@@ -31,17 +31,19 @@
 
 void* operator new(std::size_t s) TEST_THROW_SPEC(std::bad_alloc)
 {
-if (throw_one == 0)
-TEST_THROW(std::bad_alloc());
---throw_one;
+unsigned expected = throw_one;
+do {
+if (expected == 0) TEST_THROW(std::bad_alloc());
+} while (!throw_one.compare_exchange_weak(expected, expected - 1));
 ++outstanding_new;
 void* ret = std::malloc(s);
 if (!ret) std::abort(); // placate MSVC's unchecked malloc warning
 return ret;
 }
 
 void  operator delete(void* p) TEST_NOEXCEPT
 {
+if (!p) return;
 --outstanding_new;
 std::free(p);
 }
@@ -109,21 +111,23 @@
 //  B std::thread's constructor should properly handle exceptions and not leak
 //memory.
 // Plan:
-//  1 Create a thread and count the number of allocations, 'N', it performs.
+//  1 Create a thread and count the number of allocations, 'numAllocs', it performs.
 //  2 For each allocation performed run a test where that allocation throws.
 //2.1 check that the exception can be caught in the parent thread.
 //2.2 Check that the functor has not been called.
 //2.3 Check that no memory allocated by the creation of the thread is leaked.
-//  3 Finally check that a thread runs successfully if we throw after 'N+1'
+//  3 Finally check that a thread runs successfully if we throw after 'numAllocs+1'
 //allocations.
+int numAllocs;
+
 void test_throwing_new_during_thread_creation() {
 #ifndef TEST_HAS_NO_EXCEPTIONS
 throw_one = 0xFFF;
 {
 std::thread t(f);
 t.join();
 }
-const int numAllocs = 0xFFF - throw_one;
+numAllocs = 0xFFF - throw_one;
 // i <= numAllocs means the last iteration is expected not to throw.
 for (int i=0; i <= numAllocs; ++i) {
 throw_one = i;
@@ -167,16 

[PATCH] D53717: [AST] Only store the needed data in ForStmt.

2018-10-26 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: include/clang/AST/Stmt.h:1863
+  Expr *getCond() {
+return reinterpret_cast(getTrailingObjects()[condOffset()]);
+  }

riccibruno wrote:
> rsmith wrote:
> > Please `static_cast` rather than `reinterpret_cast` throughout. (If the 
> > `Stmt` base class weren't at offset 0 within `Expr`, we'd want to apply the 
> > adjustment.)
> I would gladly get rid of these ugly `reinterpret_cast`,
> but unfortunately the definition of `Expr` is not available in `Stmt.h`.
> 
> As you say these `reinterpret_cast` only work now because of the layout.
> 
> A solution would be to move `Expr` and `Stmt` to something like `StmtBase.h`
> and include this in `Stmt.h`. This would allow us to get of these casts 
> between
> `Stmt` and `Expr`. Of the 91 `reinterpret_cast` in all of the `Stmt*.h` it 
> seems that
> at least 2/3 of them could be removed.
Ugh, I see, thanks. Yes, pulling `Expr` and `Stmt` out into a `StmtBase.h` or 
similar seems like a good approach to me.


Repository:
  rC Clang

https://reviews.llvm.org/D53717



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


[PATCH] D53771: [clang-tidy] Avoid C arrays check

2018-10-26 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments.



Comment at: test/clang-tidy/misc-avoid-c-arrays.cpp:14
+
+template 
+class array {

lebedev.ri wrote:
> JonasToth wrote:
> > Please add a case with templates, where `T` itself is the array type, maybe 
> > there are other fancy template tricks that could create an array implictly?
> Oh i see, `array` is not diagnosed, that is where it gets 
> interesting :S
> So i need to match `type(arrayType())`, and then find the location to 
> complain about
> (the type does not seem to have it).
you could leave it as known limitation as well.
If the type `T` is then diagnosed as array creation through 
template-instantiation the warning is still valid.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53771



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


[PATCH] D53717: [AST] Only store the needed data in ForStmt.

2018-10-26 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno updated this revision to Diff 171340.
riccibruno marked 6 inline comments as done.
riccibruno added a comment.

Add a flag in the output of -ast-dump indicating which sub-statement
the `ForStmt` is storing. This removes the ambiguity in the output
of -ast-dump.


Repository:
  rC Clang

https://reviews.llvm.org/D53717

Files:
  include/clang/AST/Stmt.h
  lib/AST/ASTDumper.cpp
  lib/AST/ASTImporter.cpp
  lib/AST/Stmt.cpp
  lib/Sema/SemaStmt.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/Import/for-stmt/test.cpp

Index: test/Import/for-stmt/test.cpp
===
--- test/Import/for-stmt/test.cpp
+++ test/Import/for-stmt/test.cpp
@@ -3,21 +3,17 @@
 // CHECK: ForStmt
 // CHECK-NEXT: <>
 // CHECK-NEXT: <>
-// CHECK-NEXT: <>
-// CHECK-NEXT: <>
 // CHECK-NEXT: NullStmt
 
 // CHECK: ForStmt
 // CHECK-NEXT: DeclStmt
 // CHECK-NEXT: VarDecl
 // CHECK-NEXT: IntegerLiteral
 // CHECK-NEXT: <>
 // CHECK-NEXT: <>
-// CHECK-NEXT: <>
 // CHECK-NEXT: ContinueStmt
 
 // CHECK: ForStmt
-// CHECK-NEXT: <>
 // CHECK-NEXT: DeclStmt
 // CHECK-NEXT: VarDecl
 // CHECK-NEXT: CXXBoolLiteralExpr
@@ -32,7 +28,6 @@
 // CHECK-NEXT: DeclStmt
 // CHECK-NEXT: VarDecl
 // CHECK-NEXT: IntegerLiteral
-// CHECK-NEXT: <>
 
 // CHECK-NEXT: BinaryOperator
 // CHECK-NEXT: ImplicitCastExpr
Index: lib/Serialization/ASTWriterStmt.cpp
===
--- lib/Serialization/ASTWriterStmt.cpp
+++ lib/Serialization/ASTWriterStmt.cpp
@@ -208,11 +208,20 @@
 
 void ASTStmtWriter::VisitForStmt(ForStmt *S) {
   VisitStmt(S);
-  Record.AddStmt(S->getInit());
+
+  bool HasInit = S->getInit() != nullptr;
+  bool HasVar = S->getConditionVariableDeclStmt() != nullptr;
+  Record.push_back(HasInit);
+  Record.push_back(HasVar);
+
   Record.AddStmt(S->getCond());
-  Record.AddDeclRef(S->getConditionVariable());
   Record.AddStmt(S->getInc());
   Record.AddStmt(S->getBody());
+  if (HasInit)
+Record.AddStmt(S->getInit());
+  if (HasVar)
+Record.AddDeclRef(S->getConditionVariable());
+
   Record.AddSourceLocation(S->getForLoc());
   Record.AddSourceLocation(S->getLParenLoc());
   Record.AddSourceLocation(S->getRParenLoc());
Index: lib/Serialization/ASTReaderStmt.cpp
===
--- lib/Serialization/ASTReaderStmt.cpp
+++ lib/Serialization/ASTReaderStmt.cpp
@@ -292,11 +292,18 @@
 
 void ASTStmtReader::VisitForStmt(ForStmt *S) {
   VisitStmt(S);
-  S->setInit(Record.readSubStmt());
+
+  bool HasInit = Record.readInt();
+  bool HasVar = Record.readInt();
+
   S->setCond(Record.readSubExpr());
-  S->setConditionVariable(Record.getContext(), ReadDeclAs());
   S->setInc(Record.readSubExpr());
   S->setBody(Record.readSubStmt());
+  if (HasInit)
+S->setInit(Record.readSubStmt());
+  if (HasVar)
+S->setConditionVariable(Record.getContext(), ReadDeclAs());
+
   S->setForLoc(ReadSourceLocation());
   S->setLParenLoc(ReadSourceLocation());
   S->setRParenLoc(ReadSourceLocation());
@@ -2342,7 +2349,10 @@
   break;
 
 case STMT_FOR:
-  S = new (Context) ForStmt(Empty);
+  S = ForStmt::CreateEmpty(
+  Context,
+  /* HasInit=*/Record[ASTStmtReader::NumStmtFields + 0],
+  /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 1]);
   break;
 
 case STMT_GOTO:
Index: lib/Sema/SemaStmt.cpp
===
--- lib/Sema/SemaStmt.cpp
+++ lib/Sema/SemaStmt.cpp
@@ -1780,9 +1780,9 @@
   if (isa(Body))
 getCurCompoundScope().setHasEmptyLoopBodies();
 
-  return new (Context)
-  ForStmt(Context, First, Second.get().second, Second.get().first, Third,
-  Body, ForLoc, LParenLoc, RParenLoc);
+  return ForStmt::Create(Context, First, Second.get().second,
+ Second.get().first, Third, Body, ForLoc, LParenLoc,
+ RParenLoc);
 }
 
 /// In an Objective C collection iteration statement:
Index: lib/AST/Stmt.cpp
===
--- lib/AST/Stmt.cpp
+++ lib/AST/Stmt.cpp
@@ -881,36 +881,71 @@
   return isa(getCond());
 }
 
-ForStmt::ForStmt(const ASTContext , Stmt *Init, Expr *Cond, VarDecl *condVar,
- Expr *Inc, Stmt *Body, SourceLocation FL, SourceLocation LP,
- SourceLocation RP)
-  : Stmt(ForStmtClass), LParenLoc(LP), RParenLoc(RP)
-{
-  SubExprs[INIT] = Init;
-  setConditionVariable(C, condVar);
-  SubExprs[COND] = Cond;
-  SubExprs[INC] = Inc;
-  SubExprs[BODY] = Body;
-  ForStmtBits.ForLoc = FL;
-}
-
-VarDecl *ForStmt::getConditionVariable() const {
-  if (!SubExprs[CONDVAR])
-return nullptr;
+ForStmt::ForStmt(const ASTContext , Stmt *Init, Expr *Cond,
+ VarDecl *CondVar, Expr *Inc, Stmt *Body, SourceLocation FL,
+ SourceLocation LP, SourceLocation RP)
+: Stmt(ForStmtClass), LParenLoc(LP), 

[PATCH] D53715: [AST] Only store the needed data in WhileStmt.

2018-10-26 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno updated this revision to Diff 171338.
riccibruno added a reviewer: rsmith.
riccibruno added a comment.

Add a flag to the output of -ast-dump indicating which sub-statement
a `WhileStmt` is storing.


Repository:
  rC Clang

https://reviews.llvm.org/D53715

Files:
  include/clang/AST/Stmt.h
  lib/AST/ASTDumper.cpp
  lib/AST/ASTImporter.cpp
  lib/AST/Stmt.cpp
  lib/Sema/SemaStmt.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/Import/while-stmt/test.cpp

Index: test/Import/while-stmt/test.cpp
===
--- test/Import/while-stmt/test.cpp
+++ test/Import/while-stmt/test.cpp
@@ -1,12 +1,10 @@
 // RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | FileCheck %s
 
 // CHECK: WhileStmt
-// CHECK-NEXT: <>
 // CHECK-NEXT: CXXBoolLiteralExpr
 // CHECK-NEXT: NullStmt
 
 // CHECK: WhileStmt
-// CHECK-NEXT: <>
 // CHECK-NEXT: CXXBoolLiteralExpr
 // CHECK-NEXT: CompoundStmt
 
Index: lib/Serialization/ASTWriterStmt.cpp
===
--- lib/Serialization/ASTWriterStmt.cpp
+++ lib/Serialization/ASTWriterStmt.cpp
@@ -183,9 +183,15 @@
 
 void ASTStmtWriter::VisitWhileStmt(WhileStmt *S) {
   VisitStmt(S);
-  Record.AddDeclRef(S->getConditionVariable());
+
+  bool HasVar = S->getConditionVariableDeclStmt() != nullptr;
+  Record.push_back(HasVar);
+
   Record.AddStmt(S->getCond());
   Record.AddStmt(S->getBody());
+  if (HasVar)
+Record.AddDeclRef(S->getConditionVariable());
+
   Record.AddSourceLocation(S->getWhileLoc());
   Code = serialization::STMT_WHILE;
 }
Index: lib/Serialization/ASTReaderStmt.cpp
===
--- lib/Serialization/ASTReaderStmt.cpp
+++ lib/Serialization/ASTReaderStmt.cpp
@@ -270,10 +270,14 @@
 
 void ASTStmtReader::VisitWhileStmt(WhileStmt *S) {
   VisitStmt(S);
-  S->setConditionVariable(Record.getContext(), ReadDeclAs());
+
+  bool HasVar = Record.readInt();
 
   S->setCond(Record.readSubExpr());
   S->setBody(Record.readSubStmt());
+  if (HasVar)
+S->setConditionVariable(Record.getContext(), ReadDeclAs());
+
   S->setWhileLoc(ReadSourceLocation());
 }
 
@@ -2323,7 +2327,9 @@
   break;
 
 case STMT_WHILE:
-  S = new (Context) WhileStmt(Empty);
+  S = WhileStmt::CreateEmpty(
+  Context,
+  /* HasVar=*/Record[ASTStmtReader::NumStmtFields + 0]);
   break;
 
 case STMT_DO:
Index: lib/Sema/SemaStmt.cpp
===
--- lib/Sema/SemaStmt.cpp
+++ lib/Sema/SemaStmt.cpp
@@ -1305,8 +1305,8 @@
   if (isa(Body))
 getCurCompoundScope().setHasEmptyLoopBodies();
 
-  return new (Context)
-  WhileStmt(Context, CondVal.first, CondVal.second, Body, WhileLoc);
+  return WhileStmt::Create(Context, CondVal.first, CondVal.second, Body,
+   WhileLoc);
 }
 
 StmtResult
Index: lib/AST/Stmt.cpp
===
--- lib/AST/Stmt.cpp
+++ lib/AST/Stmt.cpp
@@ -978,32 +978,60 @@
   DeclStmt(DeclGroupRef(V), VarRange.getBegin(), VarRange.getEnd());
 }
 
-WhileStmt::WhileStmt(const ASTContext , VarDecl *Var, Expr *cond, Stmt *body,
- SourceLocation WL)
-  : Stmt(WhileStmtClass) {
-  setConditionVariable(C, Var);
-  SubExprs[COND] = cond;
-  SubExprs[BODY] = body;
-  WhileStmtBits.WhileLoc = WL;
+WhileStmt::WhileStmt(const ASTContext , VarDecl *Var, Expr *Cond,
+ Stmt *Body, SourceLocation WL)
+: Stmt(WhileStmtClass) {
+  bool HasVar = Var != nullptr;
+  WhileStmtBits.HasVar = HasVar;
+
+  setCond(Cond);
+  setBody(Body);
+  if (HasVar)
+setConditionVariable(Ctx, Var);
+
+  setWhileLoc(WL);
 }
 
-VarDecl *WhileStmt::getConditionVariable() const {
-  if (!SubExprs[VAR])
-return nullptr;
+WhileStmt::WhileStmt(EmptyShell Empty, bool HasVar)
+: Stmt(WhileStmtClass, Empty) {
+  WhileStmtBits.HasVar = HasVar;
+}
+
+WhileStmt *WhileStmt::Create(const ASTContext , VarDecl *Var, Expr *Cond,
+ Stmt *Body, SourceLocation WL) {
+  bool HasVar = Var != nullptr;
+  void *Mem =
+  Ctx.Allocate(totalSizeToAlloc(NumMandatoryStmtPtr + HasVar),
+   alignof(WhileStmt));
+  return new (Mem) WhileStmt(Ctx, Var, Cond, Body, WL);
+}
 
-  auto *DS = cast(SubExprs[VAR]);
+WhileStmt *WhileStmt::CreateEmpty(const ASTContext , bool HasVar) {
+  void *Mem =
+  Ctx.Allocate(totalSizeToAlloc(NumMandatoryStmtPtr + HasVar),
+   alignof(WhileStmt));
+  return new (Mem) WhileStmt(EmptyShell(), HasVar);
+}
+
+VarDecl *WhileStmt::getConditionVariable() {
+  auto *DS = getConditionVariableDeclStmt();
+  if (!DS)
+return nullptr;
   return cast(DS->getSingleDecl());
 }
 
-void WhileStmt::setConditionVariable(const ASTContext , VarDecl *V) {
+void WhileStmt::setConditionVariable(const ASTContext , VarDecl *V) {
+  

[PATCH] D53714: [AST] Only store the needed data in SwitchStmt.

2018-10-26 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno updated this revision to Diff 171337.
riccibruno added a reviewer: rsmith.
riccibruno added a comment.

Add a flag to the output of -ast-dump indicating which sub-statement
a `SwitchStmt` is storing. This removes the ambiguity in the output
of -ast-dump as per rsmith's comment in https://reviews.llvm.org/D53717.


Repository:
  rC Clang

https://reviews.llvm.org/D53714

Files:
  include/clang/AST/Stmt.h
  lib/AST/ASTDumper.cpp
  lib/AST/ASTImporter.cpp
  lib/AST/Stmt.cpp
  lib/Sema/SemaStmt.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/Import/switch-stmt/test.cpp
  test/Misc/ast-dump-color.cpp

Index: test/Misc/ast-dump-color.cpp
===
--- test/Misc/ast-dump-color.cpp
+++ test/Misc/ast-dump-color.cpp
@@ -46,7 +46,6 @@
 //CHECK: {{^}}[[Blue]]|-[[RESET]][[GREEN]]FunctionDecl[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:9:1[[RESET]], [[Yellow]]line:16:1[[RESET]]> [[Yellow]]line:9:6[[RESET]][[CYAN]] TestAttributedStmt[[RESET]] [[Green]]'void ()'[[RESET]]{{$}}
 //CHECK: {{^}}[[Blue]]| |-[[RESET]][[MAGENTA:.\[0;1;35m]]CompoundStmt[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:27[[RESET]], [[Yellow]]line:16:1[[RESET]]>{{$}}
 //CHECK: {{^}}[[Blue]]| | `-[[RESET]][[MAGENTA]]SwitchStmt[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:10:3[[RESET]], [[Yellow]]line:15:3[[RESET]]>{{$}}
-//CHECK: {{^}}[[Blue]]| |   |-[[RESET]][[Blue:.\[0;34m]]<<>>[[RESET]]{{$}}
 //CHECK: {{^}}[[Blue]]| |   |-[[RESET]][[MAGENTA]]IntegerLiteral[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:10:11[[RESET]]> [[Green]]'int'[[RESET]][[Cyan:.\[0;36m]][[RESET]][[Cyan]][[RESET]][[CYAN]] 1[[RESET]]{{$}}
 //CHECK: {{^}}[[Blue]]| |   `-[[RESET]][[MAGENTA]]CompoundStmt[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:14[[RESET]], [[Yellow]]line:15:3[[RESET]]>{{$}}
 //CHECK: {{^}}[[Blue]]| | |-[[RESET]][[MAGENTA]]CaseStmt[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:11:3[[RESET]], [[Yellow]]line:12:27[[RESET]]>{{$}}
Index: test/Import/switch-stmt/test.cpp
===
--- test/Import/switch-stmt/test.cpp
+++ test/Import/switch-stmt/test.cpp
@@ -1,8 +1,6 @@
 // RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | FileCheck %s
 
 // CHECK: SwitchStmt
-// CHECK-NEXT: <>
-// CHECK-NEXT: <>
 // CHECK-NEXT: IntegerLiteral
 // CHECK-NEXT: CompoundStmt
 // CHECK-NEXT: CaseStmt
@@ -22,7 +20,6 @@
 // CHECK-NEXT: DeclStmt
 // CHECK-NEXT: VarDecl
 // CHECK-SAME: varname
-// CHECK-NEXT: <>
 // CHECK-NEXT: IntegerLiteral
 // CHECK-NEXT: CompoundStmt
 // CHECK-NEXT: CaseStmt
@@ -37,15 +34,11 @@
 // CHECK-NEXT: BreakStmt
 
 // CHECK: SwitchStmt
-// CHECK-NEXT: <>
-// CHECK-NEXT: <>
 // CHECK-NEXT: IntegerLiteral
 // CHECK-NEXT: DefaultStmt
 // CHECK-NEXT: BreakStmt
 
 // CHECK: SwitchStmt
-// CHECK-NEXT: <>
-// CHECK-NEXT: <>
 // CHECK-NEXT: IntegerLiteral
 // CHECK-NEXT: NullStmt
 
Index: lib/Serialization/ASTWriterStmt.cpp
===
--- lib/Serialization/ASTWriterStmt.cpp
+++ lib/Serialization/ASTWriterStmt.cpp
@@ -159,12 +159,22 @@
 
 void ASTStmtWriter::VisitSwitchStmt(SwitchStmt *S) {
   VisitStmt(S);
-  Record.AddStmt(S->getInit());
-  Record.AddDeclRef(S->getConditionVariable());
+
+  bool HasInit = S->getInit() != nullptr;
+  bool HasVar = S->getConditionVariableDeclStmt() != nullptr;
+  Record.push_back(HasInit);
+  Record.push_back(HasVar);
+  Record.push_back(S->isAllEnumCasesCovered());
+
   Record.AddStmt(S->getCond());
   Record.AddStmt(S->getBody());
+  if (HasInit)
+Record.AddStmt(S->getInit());
+  if (HasVar)
+Record.AddDeclRef(S->getConditionVariable());
+
   Record.AddSourceLocation(S->getSwitchLoc());
-  Record.push_back(S->isAllEnumCasesCovered());
+
   for (SwitchCase *SC = S->getSwitchCaseList(); SC;
SC = SC->getNextSwitchCase())
 Record.push_back(Writer.RecordSwitchCaseID(SC));
Index: lib/Serialization/ASTReaderStmt.cpp
===
--- lib/Serialization/ASTReaderStmt.cpp
+++ lib/Serialization/ASTReaderStmt.cpp
@@ -240,13 +240,21 @@
 
 void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) {
   VisitStmt(S);
-  S->setInit(Record.readSubStmt());
-  S->setConditionVariable(Record.getContext(), ReadDeclAs());
+
+  bool HasInit = Record.readInt();
+  bool HasVar = Record.readInt();
+  bool AllEnumCasesCovered = Record.readInt();
+  if (AllEnumCasesCovered)
+S->setAllEnumCasesCovered();
+
   S->setCond(Record.readSubExpr());
   S->setBody(Record.readSubStmt());
+  if (HasInit)
+S->setInit(Record.readSubStmt());
+  if (HasVar)
+S->setConditionVariable(Record.getContext(), ReadDeclAs());
+
   S->setSwitchLoc(ReadSourceLocation());
-  if (Record.readInt())
-S->setAllEnumCasesCovered();
 
   SwitchCase *PrevSC = nullptr;
   

[PATCH] D53684: [COFF, ARM64] Change setjmp for AArch64 Windows to use Intrinsic.sponentry

2018-10-26 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo accepted this revision.
mstorsjo added a comment.
This revision is now accepted and ready to land.

Looks good to me, once the dependency patch is done.


Repository:
  rC Clang

https://reviews.llvm.org/D53684



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


[PATCH] D53609: [AST] Don't store data for GNU range case statement if not needed.

2018-10-26 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno updated this revision to Diff 171336.
riccibruno added a reviewer: rsmith.
riccibruno added a comment.

Add a flag in the output of -ast-dump to indicate that
a `CaseStmt` is a GNU range case statement, following
rsmith's comment in https://reviews.llvm.org/D53717


Repository:
  rC Clang

https://reviews.llvm.org/D53609

Files:
  include/clang/AST/Stmt.h
  lib/AST/ASTDumper.cpp
  lib/AST/ASTImporter.cpp
  lib/AST/Stmt.cpp
  lib/Sema/SemaStmt.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/Import/switch-stmt/test.cpp
  test/Misc/ast-dump-color.cpp

Index: test/Misc/ast-dump-color.cpp
===
--- test/Misc/ast-dump-color.cpp
+++ test/Misc/ast-dump-color.cpp
@@ -51,13 +51,11 @@
 //CHECK: {{^}}[[Blue]]| |   `-[[RESET]][[MAGENTA]]CompoundStmt[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:14[[RESET]], [[Yellow]]line:15:3[[RESET]]>{{$}}
 //CHECK: {{^}}[[Blue]]| | |-[[RESET]][[MAGENTA]]CaseStmt[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:11:3[[RESET]], [[Yellow]]line:12:27[[RESET]]>{{$}}
 //CHECK: {{^}}[[Blue]]| | | |-[[RESET]][[MAGENTA]]IntegerLiteral[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:11:8[[RESET]]> [[Green]]'int'[[RESET]][[Cyan]][[RESET]][[Cyan]][[RESET]][[CYAN]] 1[[RESET]]{{$}}
-//CHECK: {{^}}[[Blue]]| | | |-[[RESET]][[Blue]]<<>>[[RESET]]{{$}}
 //CHECK: {{^}}[[Blue]]| | | `-[[RESET]][[MAGENTA]]AttributedStmt[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:12:5[[RESET]], [[Yellow]]col:27[[RESET]]>{{$}}
 //CHECK: {{^}}[[Blue]]| | |   |-[[RESET]][[BLUE]]FallThroughAttr[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:7[[RESET]], [[Yellow]]col:14[[RESET]]>{{$}}
 //CHECK: {{^}}[[Blue]]| | |   `-[[RESET]][[MAGENTA]]NullStmt[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:27[[RESET]]>{{$}}
 //CHECK: {{^}}[[Blue]]| | `-[[RESET]][[MAGENTA]]CaseStmt[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:13:3[[RESET]], [[Yellow]]line:14:5[[RESET]]>{{$}}
 //CHECK: {{^}}[[Blue]]| |   |-[[RESET]][[MAGENTA]]IntegerLiteral[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:13:8[[RESET]]> [[Green]]'int'[[RESET]][[Cyan]][[RESET]][[Cyan]][[RESET]][[CYAN]] 2[[RESET]]{{$}}
-//CHECK: {{^}}[[Blue]]| |   |-[[RESET]][[Blue]]<<>>[[RESET]]{{$}}
 //CHECK: {{^}}[[Blue]]| |   `-[[RESET]][[MAGENTA]]NullStmt[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:14:5[[RESET]]>{{$}}
 //CHECK: {{^}}[[Blue]]| `-[[RESET]][[Blue]]FullComment[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:8:4[[RESET]], [[Yellow]]col:11[[RESET]]>{{$}}
 //CHECK: {{^}}[[Blue]]|   `-[[RESET]][[Blue]]ParagraphComment[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:4[[RESET]], [[Yellow]]col:11[[RESET]]>{{$}}
Index: test/Import/switch-stmt/test.cpp
===
--- test/Import/switch-stmt/test.cpp
+++ test/Import/switch-stmt/test.cpp
@@ -7,10 +7,8 @@
 // CHECK-NEXT: CompoundStmt
 // CHECK-NEXT: CaseStmt
 // CHECK-NEXT: IntegerLiteral
-// CHECK-NEXT: <>
 // CHECK-NEXT: CaseStmt
 // CHECK-NEXT: IntegerLiteral
-// CHECK-NEXT: <>
 // CHECK-NEXT: BreakStmt
 
 // CHECK: SwitchStmt
@@ -22,11 +20,9 @@
 // CHECK-NEXT: CompoundStmt
 // CHECK-NEXT: CaseStmt
 // CHECK-NEXT: IntegerLiteral
-// CHECK-NEXT: <>
 // CHECK-NEXT: BreakStmt
 // CHECK-NEXT: CaseStmt
 // CHECK-NEXT: IntegerLiteral
-// CHECK-NEXT: <>
 // CHECK-NEXT: BreakStmt
 
 // CHECK: SwitchStmt
Index: lib/Serialization/ASTWriterStmt.cpp
===
--- lib/Serialization/ASTWriterStmt.cpp
+++ lib/Serialization/ASTWriterStmt.cpp
@@ -96,10 +96,13 @@
 
 void ASTStmtWriter::VisitCaseStmt(CaseStmt *S) {
   VisitSwitchCase(S);
+  Record.push_back(S->caseStmtIsGNURange());
   Record.AddStmt(S->getLHS());
-  Record.AddStmt(S->getRHS());
   Record.AddStmt(S->getSubStmt());
-  Record.AddSourceLocation(S->getEllipsisLoc());
+  if (S->caseStmtIsGNURange()) {
+Record.AddStmt(S->getRHS());
+Record.AddSourceLocation(S->getEllipsisLoc());
+  }
   Code = serialization::STMT_CASE;
 }
 
Index: lib/Serialization/ASTReaderStmt.cpp
===
--- lib/Serialization/ASTReaderStmt.cpp
+++ lib/Serialization/ASTReaderStmt.cpp
@@ -177,10 +177,13 @@
 
 void ASTStmtReader::VisitCaseStmt(CaseStmt *S) {
   VisitSwitchCase(S);
+  bool CaseStmtIsGNURange = Record.readInt();
   S->setLHS(Record.readSubExpr());
-  S->setRHS(Record.readSubExpr());
   S->setSubStmt(Record.readSubStmt());
-  S->setEllipsisLoc(ReadSourceLocation());
+  if (CaseStmtIsGNURange) {
+S->setRHS(Record.readSubExpr());
+S->setEllipsisLoc(ReadSourceLocation());
+  }
 }
 
 void ASTStmtReader::VisitDefaultStmt(DefaultStmt *S) {
@@ -2277,7 +2280,9 @@
   break;
 
 case STMT_CASE:
-  S = new 

r345423 - Fix test expectation to match reality.

2018-10-26 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Oct 26 12:42:43 2018
New Revision: 345423

URL: http://llvm.org/viewvc/llvm-project?rev=345423=rev
Log:
Fix test expectation to match reality.

Modified:
cfe/trunk/test/SemaCXX/alignof.cpp

Modified: cfe/trunk/test/SemaCXX/alignof.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/alignof.cpp?rev=345423=345422=345423=diff
==
--- cfe/trunk/test/SemaCXX/alignof.cpp (original)
+++ cfe/trunk/test/SemaCXX/alignof.cpp Fri Oct 26 12:42:43 2018
@@ -4,9 +4,9 @@
 
 struct S0 {
   int x;
-  static const int test0 = __alignof__(x); // expected-error {{invalid 
application of '__alignof' to a field of a class still being defined}}
-  static const int test1 = __alignof__(S0::x); // expected-error {{invalid 
application of '__alignof' to a field of a class still being defined}}
-  auto test2() -> char(&)[__alignof__(x)]; // expected-error {{invalid 
application of '__alignof' to a field of a class still being defined}}
+  static const int test0 = __alignof__(x); // expected-error {{invalid 
application of 'alignof' to a field of a class still being defined}}
+  static const int test1 = __alignof__(S0::x); // expected-error {{invalid 
application of 'alignof' to a field of a class still being defined}}
+  auto test2() -> char(&)[__alignof__(x)]; // expected-error {{invalid 
application of 'alignof' to a field of a class still being defined}}
 };
 
 struct S1; // expected-note 6 {{forward declaration}}


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


r345421 - Fix typo.

2018-10-26 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Oct 26 12:35:39 2018
New Revision: 345421

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=345421=345420=345421=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Oct 26 12:35:39 
2018
@@ -5476,7 +5476,7 @@ def err_atomic_specifier_bad_type : Erro
 // Expressions.
 def select_unary_expr_or_type_trait_kind : TextSubstitution<
   "%select{sizeof|alignof|vec_step|__builtin_omp_required_simd_align|"
-  "__alignof}0">
+  "__alignof}0">;
 def ext_sizeof_alignof_function_type : Extension<
   "invalid application of '%sub{select_unary_expr_or_type_trait_kind}0' "
   "to a function type">, InGroup;


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


[PATCH] D53770: Support g++ headers in include/g++

2018-10-26 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

This needs a test.




Comment at: lib/Driver/ToolChains/Linux.cpp:927-928
   LibDir.str() + "/../include/c++",
+  // Some gcc installations put headers under "g++" without a
+  // version suffix.
+  LibDir.str() + "/../include/g++",

It'd be useful to say who this "some" is, so we can check whether this is still 
a valid concern in the future.


Repository:
  rC Clang

https://reviews.llvm.org/D53770



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


[PATCH] D53207: Fix bug 26547 - alignof should return ABI alignment, not preferred alignment

2018-10-26 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL345419: PR26547: alignof should return ABI alignment, not 
preferred alignment (authored by rsmith, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D53207?vs=171247=171333#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D53207

Files:
  cfe/trunk/docs/ReleaseNotes.rst
  cfe/trunk/include/clang/AST/Stmt.h
  cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/include/clang/Basic/LangOptions.h
  cfe/trunk/include/clang/Basic/TypeTraits.h
  cfe/trunk/lib/AST/ASTDumper.cpp
  cfe/trunk/lib/AST/Expr.cpp
  cfe/trunk/lib/AST/ExprConstant.cpp
  cfe/trunk/lib/AST/ItaniumMangle.cpp
  cfe/trunk/lib/AST/StmtPrinter.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/lib/Parse/ParseExpr.cpp
  cfe/trunk/lib/Sema/SemaChecking.cpp
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/test/Headers/thumbv7-apple-ios-types.cpp
  cfe/trunk/test/Sema/align-x86-abi7.c
  cfe/trunk/test/Sema/align-x86.c
  cfe/trunk/test/SemaCXX/align-x86-abi7.cpp
  cfe/trunk/test/SemaCXX/align-x86.cpp
  cfe/trunk/test/SemaCXX/alignof.cpp

Index: cfe/trunk/lib/AST/ASTDumper.cpp
===
--- cfe/trunk/lib/AST/ASTDumper.cpp
+++ cfe/trunk/lib/AST/ASTDumper.cpp
@@ -2281,6 +2281,9 @@
   case UETT_OpenMPRequiredSimdAlign:
 OS << " __builtin_omp_required_simd_align";
 break;
+  case UETT_PreferredAlignOf:
+OS << " __alignof";
+break;
   }
   if (Node->isArgumentType())
 dumpType(Node->getArgumentType());
Index: cfe/trunk/lib/AST/ItaniumMangle.cpp
===
--- cfe/trunk/lib/AST/ItaniumMangle.cpp
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp
@@ -3864,6 +3864,7 @@
 case UETT_SizeOf:
   Out << 's';
   break;
+case UETT_PreferredAlignOf:
 case UETT_AlignOf:
   Out << 'a';
   break;
Index: cfe/trunk/lib/AST/StmtPrinter.cpp
===
--- cfe/trunk/lib/AST/StmtPrinter.cpp
+++ cfe/trunk/lib/AST/StmtPrinter.cpp
@@ -1235,6 +1235,9 @@
 else
   OS << "__alignof";
 break;
+  case UETT_PreferredAlignOf:
+OS << "__alignof";
+break;
   case UETT_VecStep:
 OS << "vec_step";
 break;
Index: cfe/trunk/lib/AST/Expr.cpp
===
--- cfe/trunk/lib/AST/Expr.cpp
+++ cfe/trunk/lib/AST/Expr.cpp
@@ -1446,7 +1446,7 @@
 
   // Check to see if we are in the situation where alignof(decl) should be
   // dependent because decl's alignment is dependent.
-  if (ExprKind == UETT_AlignOf) {
+  if (ExprKind == UETT_AlignOf || ExprKind == UETT_PreferredAlignOf) {
 if (!isValueDependent() || !isInstantiationDependent()) {
   E = E->IgnoreParens();
 
Index: cfe/trunk/lib/AST/ExprConstant.cpp
===
--- cfe/trunk/lib/AST/ExprConstant.cpp
+++ cfe/trunk/lib/AST/ExprConstant.cpp
@@ -5946,21 +5946,35 @@
   return ExprEvaluatorBaseTy::VisitCastExpr(E);
 }
 
-static CharUnits GetAlignOfType(EvalInfo , QualType T) {
+static CharUnits GetAlignOfType(EvalInfo , QualType T,
+UnaryExprOrTypeTrait ExprKind) {
   // C++ [expr.alignof]p3:
   // When alignof is applied to a reference type, the result is the
   // alignment of the referenced type.
   if (const ReferenceType *Ref = T->getAs())
 T = Ref->getPointeeType();
 
-  // __alignof is defined to return the preferred alignment.
   if (T.getQualifiers().hasUnaligned())
 return CharUnits::One();
-  return Info.Ctx.toCharUnitsFromBits(
-Info.Ctx.getPreferredTypeAlign(T.getTypePtr()));
+
+  const bool AlignOfReturnsPreferred =
+  Info.Ctx.getLangOpts().getClangABICompat() <= LangOptions::ClangABI::Ver7;
+
+  // __alignof is defined to return the preferred alignment.
+  // Before 8, clang returned the preferred alignment for alignof and _Alignof
+  // as well.
+  if (ExprKind == UETT_PreferredAlignOf || AlignOfReturnsPreferred)
+return Info.Ctx.toCharUnitsFromBits(
+  Info.Ctx.getPreferredTypeAlign(T.getTypePtr()));
+  // alignof and _Alignof are defined to return the ABI alignment.
+  else if (ExprKind == UETT_AlignOf)
+return Info.Ctx.getTypeAlignInChars(T.getTypePtr());
+  else
+llvm_unreachable("GetAlignOfType on a non-alignment ExprKind");
 }
 
-static CharUnits GetAlignOfExpr(EvalInfo , const Expr *E) {
+static CharUnits GetAlignOfExpr(EvalInfo , const Expr *E,
+UnaryExprOrTypeTrait ExprKind) {
   E = E->IgnoreParens();
 
   // The kinds of expressions that we have special-case logic here for
@@ -5977,7 +5991,7 @@
 return Info.Ctx.getDeclAlign(ME->getMemberDecl(),
  /*RefAsPointee*/true);
 
-  return GetAlignOfType(Info, 

r345419 - PR26547: alignof should return ABI alignment, not preferred alignment

2018-10-26 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Oct 26 12:26:45 2018
New Revision: 345419

URL: http://llvm.org/viewvc/llvm-project?rev=345419=rev
Log:
PR26547: alignof should return ABI alignment, not preferred alignment

Summary:
- Add `UETT_PreferredAlignOf` to account for the difference between `__alignof` 
and `alignof`
- `AlignOfType` now returns ABI alignment instead of preferred alignment iff 
clang-abi-compat > 7, and one uses _Alignof or alignof

Patch by Nicole Mazzuca!

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

Added:
cfe/trunk/test/Sema/align-x86-abi7.c
cfe/trunk/test/SemaCXX/align-x86-abi7.cpp
cfe/trunk/test/SemaCXX/align-x86.cpp
Modified:
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Basic/LangOptions.h
cfe/trunk/include/clang/Basic/TypeTraits.h
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/Headers/thumbv7-apple-ios-types.cpp
cfe/trunk/test/Sema/align-x86.c
cfe/trunk/test/SemaCXX/alignof.cpp

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=345419=345418=345419=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Fri Oct 26 12:26:45 2018
@@ -77,6 +77,11 @@ future versions of Clang.
 Modified Compiler Flags
 ---
 
+- As of clang 8, `alignof` and `_Alignof` return the ABI alignment of a type,
+  as opposed to the preferred alignment. `__alignof` still returns the
+  preferred alignment. `-fclang-abi-compat=7` (and previous) will make
+  `alignof` and `_Alignof` return preferred alignment again.
+
 
 New Pragmas in Clang
 
@@ -132,6 +137,21 @@ OpenCL C Language Changes in Clang
 
 ...
 
+ABI Changes in Clang
+
+
+- `_Alignof` and `alignof` now return the ABI alignment of a type, as opposed
+  to the preferred alignment.
+  - This is more in keeping with the language of the standards, as well as
+being compatible with gcc
+  - `__alignof` and `__alignof__` still return the preferred alignment of
+a type
+  - This shouldn't break any ABI except for things that explicitly ask for
+`alignas(alignof(T))`.
+  - If you have interfaces that break with this change, you may wish to switch
+to `alignas(__alignof(T))`, instead of using the `-fclang-abi-compat`
+switch.
+
 OpenMP Support in Clang
 --
 

Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=345419=345418=345419=diff
==
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Fri Oct 26 12:26:45 2018
@@ -179,7 +179,7 @@ protected:
 
 unsigned : NumExprBits;
 
-unsigned Kind : 2;
+unsigned Kind : 3;
 unsigned IsType : 1; // true if operand is a type, false if an expression.
   };
 

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=345419=345418=345419=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Fri Oct 26 12:26:45 2018
@@ -2425,8 +2425,9 @@ AST_MATCHER_P(UnaryExprOrTypeTraitExpr,
 /// alignof.
 inline internal::Matcher alignOfExpr(
 const internal::Matcher ) {
-  return stmt(unaryExprOrTypeTraitExpr(allOf(
-  ofKind(UETT_AlignOf), InnerMatcher)));
+  return stmt(unaryExprOrTypeTraitExpr(
+  allOf(anyOf(ofKind(UETT_AlignOf), ofKind(UETT_PreferredAlignOf)),
+InnerMatcher)));
 }
 
 /// Same as unaryExprOrTypeTraitExpr, but only matching

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=345419=345418=345419=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Oct 26 12:26:45 
2018
@@ -5474,20 +5474,24 @@ def err_atomic_specifier_bad_type : Erro
   "%1 %select{||which is not trivially copyable}0">;
 
 // Expressions.
+def select_unary_expr_or_type_trait_kind : TextSubstitution<
+  

[PATCH] D53607: [AST] Only store the needed data in IfStmt.

2018-10-26 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno updated this revision to Diff 171332.
riccibruno added a reviewer: rsmith.
riccibruno added a comment.

Add a flag to the output of -ast-dump indicating
which sub-statement `IfStmt` is storing. This removes
the ambiguity in the output of -ast-dump and addresses
rsmith's comment in https://reviews.llvm.org/D53717.


Repository:
  rC Clang

https://reviews.llvm.org/D53607

Files:
  include/clang/AST/Stmt.h
  lib/AST/ASTDumper.cpp
  lib/AST/ASTImporter.cpp
  lib/AST/Stmt.cpp
  lib/Analysis/BodyFarm.cpp
  lib/Sema/SemaStmt.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/Import/if-stmt/test.cpp
  test/Misc/ast-dump-invalid.cpp

Index: test/Misc/ast-dump-invalid.cpp
===
--- test/Misc/ast-dump-invalid.cpp
+++ test/Misc/ast-dump-invalid.cpp
@@ -33,8 +33,6 @@
 // CHECK-NEXT:   |-ParmVarDecl
 // CHECK-NEXT:   `-CompoundStmt
 // CHECK-NEXT: `-IfStmt {{.*}} 
-// CHECK-NEXT:   |-<<>>
-// CHECK-NEXT:   |-<<>>
 // CHECK-NEXT:   |-OpaqueValueExpr {{.*}} <> 'bool'
 // CHECK-NEXT:   |-ReturnStmt {{.*}} 
 // CHECK-NEXT:   | `-IntegerLiteral {{.*}}  'int' 4
@@ -50,15 +48,15 @@
 { return 45; }
 }
 // CHECK: NamespaceDecl {{.*}} <{{.*}}> {{.*}} TestInvalidFunctionDecl
-// CHECK-NEXT: |-CXXRecordDecl {{.*}}  line:46:8 struct Str definition
+// CHECK-NEXT: |-CXXRecordDecl {{.*}}  line:44:8 struct Str definition
 // CHECK:  | |-CXXRecordDecl {{.*}}  col:8 implicit struct Str
-// CHECK-NEXT: | `-CXXMethodDecl {{.*}}  col:11 invalid foo1 'double (double, int)'
+// CHECK-NEXT: | `-CXXMethodDecl {{.*}}  col:11 invalid foo1 'double (double, int)'
 // CHECK-NEXT: |   |-ParmVarDecl {{.*}}  col:22 'double'
 // CHECK-NEXT: |   `-ParmVarDecl {{.*}} > col:36 invalid 'int'
-// CHECK-NEXT: `-CXXMethodDecl {{.*}} parent {{.*}}  line:49:13 invalid foo1 'double (double, int)'
+// CHECK-NEXT: `-CXXMethodDecl {{.*}} parent {{.*}}  line:47:13 invalid foo1 'double (double, int)'
 // CHECK-NEXT:   |-ParmVarDecl {{.*}}  col:24 'double'
 // CHECK-NEXT:   |-ParmVarDecl {{.*}} > col:38 invalid 'int'
-// CHECK-NEXT:   `-CompoundStmt {{.*}} 
+// CHECK-NEXT:   `-CompoundStmt {{.*}} 
 // CHECK-NEXT: `-ReturnStmt {{.*}} 
 // CHECK-NEXT:   `-ImplicitCastExpr {{.*}}  'double' 
 // CHECK-NEXT: `-IntegerLiteral {{.*}}  'int' 45
Index: test/Import/if-stmt/test.cpp
===
--- test/Import/if-stmt/test.cpp
+++ test/Import/if-stmt/test.cpp
@@ -1,41 +1,30 @@
 // RUN: clang-import-test -dump-ast -import %S/Inputs/F.cpp -expression %s | FileCheck %s
 
 // CHECK: IfStmt
-// CHECK-NEXT: <>
-// CHECK-NEXT: <>
 // CHECK-NEXT: CXXBoolLiteralExpr
 // CHECK-NEXT: ReturnStmt
-// CHECK-NEXT: <>
 
 // CHECK: IfStmt
-// CHECK-NEXT: <>
 // CHECK-NEXT: DeclStmt
 // CHECK-NEXT: VarDecl
 // CHECK-NEXT: IntegerLiteral
 // CHECK-NEXT: ImplicitCastExpr
 // CHECK-NEXT: ImplicitCastExpr
 // CHECK-NEXT: DeclRefExpr
 // CHECK-NEXT: ReturnStmt
-// CHECK-NEXT: <>
 
 // CHECK: IfStmt
 // CHECK-NEXT: DeclStmt
 // CHECK-NEXT: VarDecl
-// CHECK-NEXT: <>
 // CHECK-NEXT: CXXBoolLiteralExpr
 // CHECK-NEXT: ReturnStmt
-// CHECK-NEXT: <>
 
 // CHECK: IfStmt
-// CHECK-NEXT: <>
-// CHECK-NEXT: <>
 // CHECK-NEXT: CXXBoolLiteralExpr
 // CHECK-NEXT: ReturnStmt
 // CHECK-NEXT: ReturnStmt
 
 // CHECK: IfStmt
-// CHECK-NEXT: <>
-// CHECK-NEXT: <>
 // CHECK-NEXT: CXXBoolLiteralExpr
 // CHECK-NEXT: CompoundStmt
 // CHECK-NEXT: ReturnStmt
Index: lib/Serialization/ASTWriterStmt.cpp
===
--- lib/Serialization/ASTWriterStmt.cpp
+++ lib/Serialization/ASTWriterStmt.cpp
@@ -128,14 +128,29 @@
 
 void ASTStmtWriter::VisitIfStmt(IfStmt *S) {
   VisitStmt(S);
+
+  bool HasElse = S->getElse() != nullptr;
+  bool HasVar = S->getConditionVariableDeclStmt() != nullptr;
+  bool HasInit = S->getInit() != nullptr;
+
   Record.push_back(S->isConstexpr());
-  Record.AddStmt(S->getInit());
-  Record.AddDeclRef(S->getConditionVariable());
+  Record.push_back(HasElse);
+  Record.push_back(HasVar);
+  Record.push_back(HasInit);
+
   Record.AddStmt(S->getCond());
   Record.AddStmt(S->getThen());
-  Record.AddStmt(S->getElse());
+  if (HasElse)
+Record.AddStmt(S->getElse());
+  if (HasVar)
+Record.AddDeclRef(S->getConditionVariable());
+  if (HasInit)
+Record.AddStmt(S->getInit());
+
   Record.AddSourceLocation(S->getIfLoc());
-  Record.AddSourceLocation(S->getElseLoc());
+  if (HasElse)
+Record.AddSourceLocation(S->getElseLoc());
+
   Code = serialization::STMT_IF;
 }
 
Index: lib/Serialization/ASTReaderStmt.cpp
===
--- lib/Serialization/ASTReaderStmt.cpp
+++ lib/Serialization/ASTReaderStmt.cpp
@@ -215,14 +215,24 @@
 
 void ASTStmtReader::VisitIfStmt(IfStmt *S) {
   VisitStmt(S);
+
   S->setConstexpr(Record.readInt());
-  S->setInit(Record.readSubStmt());
-  

[PATCH] D53605: [AST] Refactor PredefinedExpr

2018-10-26 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno updated this revision to Diff 171326.
riccibruno marked 4 inline comments as done.
riccibruno retitled this revision from "[AST] Pack PredefinedExpr" to "[AST] 
Refactor PredefinedExpr".
riccibruno edited the summary of this revision.
riccibruno added a comment.

Address rjmcall's comments. In particular use "Kind" instead of "Type" and 
propagate
the change to the users. Change the title to "[AST] Refactor PredefinedExpr" 
since this
patch is doing various changes to `PredefinedExpr`.


Repository:
  rC Clang

https://reviews.llvm.org/D53605

Files:
  include/clang/AST/Expr.h
  include/clang/AST/Stmt.h
  include/clang/AST/StmtDataCollectors.td
  include/clang/Sema/Sema.h
  lib/AST/ASTDumper.cpp
  lib/AST/ASTImporter.cpp
  lib/AST/Expr.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaTemplateInstantiate.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp

Index: lib/Serialization/ASTWriterStmt.cpp
===
--- lib/Serialization/ASTWriterStmt.cpp
+++ lib/Serialization/ASTWriterStmt.cpp
@@ -388,9 +388,13 @@
 
 void ASTStmtWriter::VisitPredefinedExpr(PredefinedExpr *E) {
   VisitExpr(E);
+
+  bool HasFunctionName = E->getFunctionName() != nullptr;
+  Record.push_back(HasFunctionName);
+  Record.push_back(E->getIdentKind()); // FIXME: stable encoding
   Record.AddSourceLocation(E->getLocation());
-  Record.push_back(E->getIdentType()); // FIXME: stable encoding
-  Record.AddStmt(E->getFunctionName());
+  if (HasFunctionName)
+Record.AddStmt(E->getFunctionName());
   Code = serialization::EXPR_PREDEFINED;
 }
 
Index: lib/Serialization/ASTReaderStmt.cpp
===
--- lib/Serialization/ASTReaderStmt.cpp
+++ lib/Serialization/ASTReaderStmt.cpp
@@ -496,9 +496,12 @@
 
 void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
   VisitExpr(E);
+  bool HasFunctionName = Record.readInt();
+  E->PredefinedExprBits.HasFunctionName = HasFunctionName;
+  E->PredefinedExprBits.Kind = Record.readInt();
   E->setLocation(ReadSourceLocation());
-  E->Type = (PredefinedExpr::IdentType)Record.readInt();
-  E->FnName = cast_or_null(Record.readSubExpr());
+  if (HasFunctionName)
+E->setFunctionName(cast(Record.readSubExpr()));
 }
 
 void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
@@ -2334,12 +2337,14 @@
   break;
 
 case STMT_CAPTURED:
-  S = CapturedStmt::CreateDeserialized(Context,
-   Record[ASTStmtReader::NumStmtFields]);
+  S = CapturedStmt::CreateDeserialized(
+  Context, Record[ASTStmtReader::NumStmtFields]);
   break;
 
 case EXPR_PREDEFINED:
-  S = new (Context) PredefinedExpr(Empty);
+  S = PredefinedExpr::CreateEmpty(
+  Context,
+  /*HasFunctionName*/ Record[ASTStmtReader::NumExprFields]);
   break;
 
 case EXPR_DECL_REF:
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -2096,8 +2096,8 @@
   /// By default, performs semantic analysis to build the new expression.
   /// Subclasses may override this routine to provide different behavior.
   ExprResult RebuildPredefinedExpr(SourceLocation Loc,
-   PredefinedExpr::IdentType IT) {
-return getSema().BuildPredefinedExpr(Loc, IT);
+   PredefinedExpr::IdentKind IK) {
+return getSema().BuildPredefinedExpr(Loc, IK);
   }
 
   /// Build a new expression that references a declaration.
@@ -8921,7 +8921,7 @@
 return E;
 
   return getDerived().RebuildPredefinedExpr(E->getLocation(),
-E->getIdentType());
+E->getIdentKind());
 }
 
 template
Index: lib/Sema/SemaTemplateInstantiate.cpp
===
--- lib/Sema/SemaTemplateInstantiate.cpp
+++ lib/Sema/SemaTemplateInstantiate.cpp
@@ -1167,7 +1167,7 @@
   if (!E->isTypeDependent())
 return E;
 
-  return getSema().BuildPredefinedExpr(E->getLocation(), E->getIdentType());
+  return getSema().BuildPredefinedExpr(E->getLocation(), E->getIdentKind());
 }
 
 ExprResult
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -3036,7 +3036,7 @@
 }
 
 ExprResult Sema::BuildPredefinedExpr(SourceLocation Loc,
- PredefinedExpr::IdentType IT) {
+ PredefinedExpr::IdentKind IK) {
   // Pick the current block, lambda, captured statement or function.
   Decl *currentDecl = nullptr;
   if (const BlockScopeInfo *BSI = getCurBlock())
@@ -3060,11 +3060,11 @@
   

[PATCH] D53771: [clang-tidy] Avoid C arrays check

2018-10-26 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: test/clang-tidy/misc-avoid-c-arrays.cpp:14
+
+template 
+class array {

JonasToth wrote:
> Please add a case with templates, where `T` itself is the array type, maybe 
> there are other fancy template tricks that could create an array implictly?
Oh i see, `array` is not diagnosed, that is where it gets 
interesting :S
So i need to match `type(arrayType())`, and then find the location to complain 
about
(the type does not seem to have it).


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53771



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


[PATCH] D53170: [clang-doc] Switch to default to all-TUs executor

2018-10-26 Thread Julie Hockett via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE345418: [clang-doc] Switch to default to all-TUs executor 
(authored by juliehockett, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D53170?vs=169414=171331#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53170

Files:
  clang-doc/tool/ClangDocMain.cpp
  test/clang-doc/single-file-public.cpp
  test/clang-doc/single-file.cpp


Index: clang-doc/tool/ClangDocMain.cpp
===
--- clang-doc/tool/ClangDocMain.cpp
+++ clang-doc/tool/ClangDocMain.cpp
@@ -31,7 +31,6 @@
 #include "clang/Frontend/FrontendActions.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Execution.h"
-#include "clang/Tooling/StandaloneExecution.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/APFloat.h"
 #include "llvm/Support/CommandLine.h"
@@ -169,6 +168,7 @@
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
   std::error_code OK;
 
+  ExecutorName.setInitialValue("all-TUs");
   auto Exec = clang::tooling::createExecutorFromCommandLineArgs(
   argc, argv, ClangDocCategory);
 
Index: test/clang-doc/single-file.cpp
===
--- test/clang-doc/single-file.cpp
+++ test/clang-doc/single-file.cpp
@@ -2,7 +2,7 @@
 // RUN: mkdir %t
 // RUN: echo "" > %t/compile_flags.txt
 // RUN: cp "%s" "%t/test.cpp"
-// RUN: clang-doc --doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: clang-doc --doxygen --executor=standalone -p %t %t/test.cpp 
-output=%t/docs
 // RUN: cat %t/docs/GlobalNamespace.yaml | FileCheck %s --check-prefix=CHECK
 // RUN: rm -rf %t
 
Index: test/clang-doc/single-file-public.cpp
===
--- test/clang-doc/single-file-public.cpp
+++ test/clang-doc/single-file-public.cpp
@@ -2,7 +2,7 @@
 // RUN: mkdir %t
 // RUN: echo "" > %t/compile_flags.txt
 // RUN: cp "%s" "%t/test.cpp"
-// RUN: clang-doc --doxygen --public -p %t %t/test.cpp -output=%t/docs
+// RUN: clang-doc --doxygen --public --executor=standalone -p %t %t/test.cpp 
-output=%t/docs
 // RUN: cat %t/docs/Record.yaml | FileCheck %s --check-prefix=CHECK
 // RUN: rm -rf %t
 


Index: clang-doc/tool/ClangDocMain.cpp
===
--- clang-doc/tool/ClangDocMain.cpp
+++ clang-doc/tool/ClangDocMain.cpp
@@ -31,7 +31,6 @@
 #include "clang/Frontend/FrontendActions.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Execution.h"
-#include "clang/Tooling/StandaloneExecution.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/APFloat.h"
 #include "llvm/Support/CommandLine.h"
@@ -169,6 +168,7 @@
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
   std::error_code OK;
 
+  ExecutorName.setInitialValue("all-TUs");
   auto Exec = clang::tooling::createExecutorFromCommandLineArgs(
   argc, argv, ClangDocCategory);
 
Index: test/clang-doc/single-file.cpp
===
--- test/clang-doc/single-file.cpp
+++ test/clang-doc/single-file.cpp
@@ -2,7 +2,7 @@
 // RUN: mkdir %t
 // RUN: echo "" > %t/compile_flags.txt
 // RUN: cp "%s" "%t/test.cpp"
-// RUN: clang-doc --doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: clang-doc --doxygen --executor=standalone -p %t %t/test.cpp -output=%t/docs
 // RUN: cat %t/docs/GlobalNamespace.yaml | FileCheck %s --check-prefix=CHECK
 // RUN: rm -rf %t
 
Index: test/clang-doc/single-file-public.cpp
===
--- test/clang-doc/single-file-public.cpp
+++ test/clang-doc/single-file-public.cpp
@@ -2,7 +2,7 @@
 // RUN: mkdir %t
 // RUN: echo "" > %t/compile_flags.txt
 // RUN: cp "%s" "%t/test.cpp"
-// RUN: clang-doc --doxygen --public -p %t %t/test.cpp -output=%t/docs
+// RUN: clang-doc --doxygen --public --executor=standalone -p %t %t/test.cpp -output=%t/docs
 // RUN: cat %t/docs/Record.yaml | FileCheck %s --check-prefix=CHECK
 // RUN: rm -rf %t
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r345418 - [clang-doc] Switch to default to all-TUs executor

2018-10-26 Thread Julie Hockett via cfe-commits
Author: juliehockett
Date: Fri Oct 26 12:11:34 2018
New Revision: 345418

URL: http://llvm.org/viewvc/llvm-project?rev=345418=rev
Log:
[clang-doc] Switch to default to all-TUs executor

Since we generally want to document a whole project, not just one file.

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

Modified:
clang-tools-extra/trunk/clang-doc/tool/ClangDocMain.cpp
clang-tools-extra/trunk/test/clang-doc/single-file-public.cpp
clang-tools-extra/trunk/test/clang-doc/single-file.cpp

Modified: clang-tools-extra/trunk/clang-doc/tool/ClangDocMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-doc/tool/ClangDocMain.cpp?rev=345418=345417=345418=diff
==
--- clang-tools-extra/trunk/clang-doc/tool/ClangDocMain.cpp (original)
+++ clang-tools-extra/trunk/clang-doc/tool/ClangDocMain.cpp Fri Oct 26 12:11:34 
2018
@@ -31,7 +31,6 @@
 #include "clang/Frontend/FrontendActions.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Execution.h"
-#include "clang/Tooling/StandaloneExecution.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/APFloat.h"
 #include "llvm/Support/CommandLine.h"
@@ -169,6 +168,7 @@ int main(int argc, const char **argv) {
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
   std::error_code OK;
 
+  ExecutorName.setInitialValue("all-TUs");
   auto Exec = clang::tooling::createExecutorFromCommandLineArgs(
   argc, argv, ClangDocCategory);
 

Modified: clang-tools-extra/trunk/test/clang-doc/single-file-public.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-doc/single-file-public.cpp?rev=345418=345417=345418=diff
==
--- clang-tools-extra/trunk/test/clang-doc/single-file-public.cpp (original)
+++ clang-tools-extra/trunk/test/clang-doc/single-file-public.cpp Fri Oct 26 
12:11:34 2018
@@ -2,7 +2,7 @@
 // RUN: mkdir %t
 // RUN: echo "" > %t/compile_flags.txt
 // RUN: cp "%s" "%t/test.cpp"
-// RUN: clang-doc --doxygen --public -p %t %t/test.cpp -output=%t/docs
+// RUN: clang-doc --doxygen --public --executor=standalone -p %t %t/test.cpp 
-output=%t/docs
 // RUN: cat %t/docs/Record.yaml | FileCheck %s --check-prefix=CHECK
 // RUN: rm -rf %t
 

Modified: clang-tools-extra/trunk/test/clang-doc/single-file.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-doc/single-file.cpp?rev=345418=345417=345418=diff
==
--- clang-tools-extra/trunk/test/clang-doc/single-file.cpp (original)
+++ clang-tools-extra/trunk/test/clang-doc/single-file.cpp Fri Oct 26 12:11:34 
2018
@@ -2,7 +2,7 @@
 // RUN: mkdir %t
 // RUN: echo "" > %t/compile_flags.txt
 // RUN: cp "%s" "%t/test.cpp"
-// RUN: clang-doc --doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: clang-doc --doxygen --executor=standalone -p %t %t/test.cpp 
-output=%t/docs
 // RUN: cat %t/docs/GlobalNamespace.yaml | FileCheck %s --check-prefix=CHECK
 // RUN: rm -rf %t
 


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


[PATCH] D53771: [clang-tidy] Avoid C arrays check

2018-10-26 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

May be this check belongs to modernize?




Comment at: docs/clang-tidy/checks/misc-avoid-c-arrays.rst:6
+
+Find C-style array delarations and recommend to use ``std::array<>``.
+All types of C arrays are diagnosed.

Finds.



Comment at: docs/clang-tidy/checks/misc-avoid-c-arrays.rst:9
+
+Hoever, no fix-its are provided. Such transform would need to be able to
+observe *all* the uses of said declaration in order to decide whether it is

However



Comment at: docs/clang-tidy/checks/misc-avoid-c-arrays.rst:30
+
+  ...
+

Please remove ellipsis. and newline.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53771



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


[PATCH] D53025: [clang-tidy] implement new check for const return types.

2018-10-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/readability/ConstValueReturnCheck.cpp:107
+diag(Def->getInnerLocStart(), "return type %0 is 'const'-qualified "
+  "hindering compiler optimizations")
+<< Def->getReturnType();

ymandel wrote:
> aaron.ballman wrote:
> > ymandel wrote:
> > > aaron.ballman wrote:
> > > > It seems strange to me that this is in the readability module but the 
> > > > diagnostic here is about compiler optimizations. Should this be in the 
> > > > performance module instead? Or should this diagnostic be reworded about 
> > > > the readability concerns?
> > > Good point. The readability angle is that the const clutters the code to 
> > > no benefit.  That is, even if it was performance neutral, I'd still want 
> > > to discourage this practice.  But, it does seem like the primary impact 
> > > is performance. 
> > > 
> > > I'm fine either way -- moving it to performance or emphasizing the 
> > > clutter of the unhelpful "const".  I'm inclined to moving it, but don't 
> > > have good sense of how strict these hierarchies are. What do you think?
> > I'm not sold that `const`-qualified return types always pessimize 
> > optimizations. However, I'm also not sold that it's *always* a bad idea to 
> > have a top-level cv-qualifier on a return type either (for instance, this 
> > is one way to prevent callers from modifying a temp returned by a 
> > function). How about leaving this in readability and changing the 
> > diagnostic into: "top-level 'const' qualifier on a return type may reduce 
> > code readability with limited benefit" or something equally weasely?
> I talked this over with other google folks and seems like the consensus is:
> 
> 1.  The readability benefits may be controversial.  Some folks might not view 
> `const` as clutter and there are some corner cases where the qualifier may 
> prevent something harmful.
> 2.  The performance implication is real, if not guaranteed to be a problem.
> 
> Based on this, seems best to move it to performance, but water down the 
> performance claims.  That keeps the focus to an issue we can assume nearly 
> everyone agrees on.
I'm not convinced the performance implications are real compared to how the 
check is currently implemented. I know there are performance concerns when you 
return a const value of class type because it pessimizes the ability to use 
move constructors, but that's a very specific performance concern that I don't 
believe is present in general. For instance, I don't know of any performance 
concerns regarding `const int f();` as a declaration. I'd be fine moving this 
to the performance module, but I think the check would need to be tightened to 
only focus on actual performance concerns.

FWIW, I do agree that the readability benefits may be controversial, but I kind 
of thought that was the point to the check and as such, it's a very reasonable 
check. Almost everything in readability is subjective to some degree and our 
metric has always been "if you agree with a style check, don't enable it".

It's up to you how you want to proceed, but I see two ways forward: 1) keep 
this as a readability check that broadly finds top-level const qualifiers and 
removes them, 2) move this to the performance module and rework the check to 
focus on only the scenarios that have concrete performance impact.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53025



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


[PATCH] D53772: [NFC][OpenMP] Add new test for parallel for code generation.

2018-10-26 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC345417: [NFC][OpenMP] Add new test for parallel for code 
generation. (authored by gbercea, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D53772

Files:
  test/OpenMP/nvptx_parallel_for_codegen.cpp

Index: test/OpenMP/nvptx_parallel_for_codegen.cpp
===
--- test/OpenMP/nvptx_parallel_for_codegen.cpp
+++ test/OpenMP/nvptx_parallel_for_codegen.cpp
@@ -0,0 +1,101 @@
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+template
+tx ftemplate(int n) {
+  tx b[10];
+
+  #pragma omp target
+  {
+tx d = n;
+#pragma omp parallel for
+for(int i=0; i<10; i++) {
+  b[i] += d;
+}
+b[3] += 1;
+  }
+
+  return b[3];
+}
+
+int bar(int n){
+  int a = 0;
+
+  a += ftemplate(n);
+
+  return a;
+}
+
+// CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+template.+l12}}_worker()
+// CHECK: call void @llvm.nvvm.barrier0()
+// CHECK: call i1 @__kmpc_kernel_parallel(
+// CHECK: call void @__omp_outlined___wrapper(
+
+// CHECK: define weak void @__omp_offloading_{{.*}}l12(
+// CHECK: call void @__omp_offloading_{{.*}}l12_worker()
+// CHECK: call void @__kmpc_kernel_init(
+// CHECK: call void @__kmpc_data_sharing_init_stack()
+// CHECK: call i8* @__kmpc_data_sharing_push_stack(i64 4, i16 0)
+// CHECK: call void @__kmpc_kernel_prepare_parallel(
+// CHECK: call void @__kmpc_begin_sharing_variables({{.*}}, i64 2)
+// CHECK: call void @llvm.nvvm.barrier0()
+// CHECK: call void @llvm.nvvm.barrier0()
+// CHECK: call void @__kmpc_end_sharing_variables()
+// CHECK: call void @__kmpc_data_sharing_pop_stack(
+// CHECK: call void @__kmpc_kernel_deinit(i16 1)
+
+// CHECK: define internal void @__omp_outlined__(
+// CHECK: alloca
+// CHECK: alloca
+// CHECK: alloca
+// CHECK: alloca
+// CHECK: [[OMP_IV:%.*]] = alloca i32
+// CHECK: store i32 0, {{.*}} [[OMP_LB:%.+]],
+// CHECK: store i32 9, {{.*}} [[OMP_UB:%.+]],
+// CHECK: store i32 1, {{.*}} [[OMP_ST:%.+]],
+// CHECK: call void @__kmpc_for_static_init_4({{.*}} i32 34, {{.*}} [[OMP_LB]], {{.*}} [[OMP_UB]], {{.*}} [[OMP_ST]], i32 1, i32 1)
+// CHECK: [[OMP_UB_1:%.+]] = load {{.*}} [[OMP_UB]]
+// CHECK: [[COMP_1:%.+]] = icmp sgt {{.*}} [[OMP_UB_1]]
+// CHECK: br i1 [[COMP_1]], label %[[COND_TRUE:.+]], label %[[COND_FALSE:.+]]
+
+// CHECK: [[COND_TRUE]]
+// CHECK: br label %[[COND_END:.+]]
+
+// CHECK: [[COND_FALSE]]
+// CHECK: [[OMP_UB_2:%.+]] = load {{.*}}* [[OMP_UB]]
+// CHECK: br label %[[COND_END]]
+
+// CHECK: [[COND_END]]
+// CHECK: [[COND_RES:%.+]] = phi i32 [ 9, %[[COND_TRUE]] ], [ [[OMP_UB_2]], %[[COND_FALSE]] ]
+// CHECK: store i32 [[COND_RES]], i32* [[OMP_UB]]
+// CHECK: [[OMP_LB_1:%.+]] = load i32, i32* [[OMP_LB]]
+// CHECK: store i32 [[OMP_LB_1]], i32* [[OMP_IV]]
+// CHECK: br label %[[OMP_INNER_FOR_COND:.+]]
+
+// CHECK: [[OMP_INNER_FOR_COND]]
+// CHECK: [[OMP_IV_2:%.+]] = load i32, i32* [[OMP_IV]]
+// CHECK: [[OMP_UB_4:%.+]] = load i32, i32* [[OMP_UB]]
+// CHECK: [[COMP_3:%.+]] = icmp sle i32 [[OMP_IV_2]], [[OMP_UB_4]]
+// CHECK: br i1 [[COMP_3]], label %[[OMP_INNER_FOR_BODY:.+]], label %[[OMP_INNER_FOR_END:.+]]
+
+// CHECK: [[OMP_INNER_FOR_BODY]]
+// CHECK: br label %[[OMP_BODY_CONTINUE:.+]]
+
+// CHECK: [[OMP_BODY_CONTINUE]]
+// CHECK: br label %[[OMP_INNER_FOR_INC:.+]]
+
+// CHECK: [[OMP_INNER_FOR_INC]]
+// CHECK: [[OMP_IV_3:%.+]] = load i32, i32* [[OMP_IV]]
+// CHECK: [[ADD_1:%.+]] = add nsw i32 [[OMP_IV_3]], 1
+// CHECK: store i32 [[ADD_1]], i32* [[OMP_IV]]
+// CHECK: br label %[[OMP_INNER_FOR_COND]]
+
+// CHECK: [[OMP_INNER_FOR_END]]
+// CHECK: call void @__kmpc_for_static_fini(
+// CHECK: ret void
+
+#endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r345417 - [NFC][OpenMP] Add new test for parallel for code generation.

2018-10-26 Thread Gheorghe-Teodor Bercea via cfe-commits
Author: gbercea
Date: Fri Oct 26 11:59:52 2018
New Revision: 345417

URL: http://llvm.org/viewvc/llvm-project?rev=345417=rev
Log:
[NFC][OpenMP] Add new test for parallel for code generation.

Summary:
This is a simple test of the parallel for code generation. It will be used to 
showcase the change introduced by patch D53443.


Reviewers: ABataev, caomhin

Reviewed By: ABataev

Subscribers: guansong, cfe-commits

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

Added:
cfe/trunk/test/OpenMP/nvptx_parallel_for_codegen.cpp

Added: cfe/trunk/test/OpenMP/nvptx_parallel_for_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nvptx_parallel_for_codegen.cpp?rev=345417=auto
==
--- cfe/trunk/test/OpenMP/nvptx_parallel_for_codegen.cpp (added)
+++ cfe/trunk/test/OpenMP/nvptx_parallel_for_codegen.cpp Fri Oct 26 11:59:52 
2018
@@ -0,0 +1,101 @@
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown 
-fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix 
CHECK --check-prefix CHECK-64
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+template
+tx ftemplate(int n) {
+  tx b[10];
+
+  #pragma omp target
+  {
+tx d = n;
+#pragma omp parallel for
+for(int i=0; i<10; i++) {
+  b[i] += d;
+}
+b[3] += 1;
+  }
+
+  return b[3];
+}
+
+int bar(int n){
+  int a = 0;
+
+  a += ftemplate(n);
+
+  return a;
+}
+
+// CHECK-LABEL: define {{.*}}void 
{{@__omp_offloading_.+template.+l12}}_worker()
+// CHECK: call void @llvm.nvvm.barrier0()
+// CHECK: call i1 @__kmpc_kernel_parallel(
+// CHECK: call void @__omp_outlined___wrapper(
+
+// CHECK: define weak void @__omp_offloading_{{.*}}l12(
+// CHECK: call void @__omp_offloading_{{.*}}l12_worker()
+// CHECK: call void @__kmpc_kernel_init(
+// CHECK: call void @__kmpc_data_sharing_init_stack()
+// CHECK: call i8* @__kmpc_data_sharing_push_stack(i64 4, i16 0)
+// CHECK: call void @__kmpc_kernel_prepare_parallel(
+// CHECK: call void @__kmpc_begin_sharing_variables({{.*}}, i64 2)
+// CHECK: call void @llvm.nvvm.barrier0()
+// CHECK: call void @llvm.nvvm.barrier0()
+// CHECK: call void @__kmpc_end_sharing_variables()
+// CHECK: call void @__kmpc_data_sharing_pop_stack(
+// CHECK: call void @__kmpc_kernel_deinit(i16 1)
+
+// CHECK: define internal void @__omp_outlined__(
+// CHECK: alloca
+// CHECK: alloca
+// CHECK: alloca
+// CHECK: alloca
+// CHECK: [[OMP_IV:%.*]] = alloca i32
+// CHECK: store i32 0, {{.*}} [[OMP_LB:%.+]],
+// CHECK: store i32 9, {{.*}} [[OMP_UB:%.+]],
+// CHECK: store i32 1, {{.*}} [[OMP_ST:%.+]],
+// CHECK: call void @__kmpc_for_static_init_4({{.*}} i32 34, {{.*}} 
[[OMP_LB]], {{.*}} [[OMP_UB]], {{.*}} [[OMP_ST]], i32 1, i32 1)
+// CHECK: [[OMP_UB_1:%.+]] = load {{.*}} [[OMP_UB]]
+// CHECK: [[COMP_1:%.+]] = icmp sgt {{.*}} [[OMP_UB_1]]
+// CHECK: br i1 [[COMP_1]], label %[[COND_TRUE:.+]], label %[[COND_FALSE:.+]]
+
+// CHECK: [[COND_TRUE]]
+// CHECK: br label %[[COND_END:.+]]
+
+// CHECK: [[COND_FALSE]]
+// CHECK: [[OMP_UB_2:%.+]] = load {{.*}}* [[OMP_UB]]
+// CHECK: br label %[[COND_END]]
+
+// CHECK: [[COND_END]]
+// CHECK: [[COND_RES:%.+]] = phi i32 [ 9, %[[COND_TRUE]] ], [ [[OMP_UB_2]], 
%[[COND_FALSE]] ]
+// CHECK: store i32 [[COND_RES]], i32* [[OMP_UB]]
+// CHECK: [[OMP_LB_1:%.+]] = load i32, i32* [[OMP_LB]]
+// CHECK: store i32 [[OMP_LB_1]], i32* [[OMP_IV]]
+// CHECK: br label %[[OMP_INNER_FOR_COND:.+]]
+
+// CHECK: [[OMP_INNER_FOR_COND]]
+// CHECK: [[OMP_IV_2:%.+]] = load i32, i32* [[OMP_IV]]
+// CHECK: [[OMP_UB_4:%.+]] = load i32, i32* [[OMP_UB]]
+// CHECK: [[COMP_3:%.+]] = icmp sle i32 [[OMP_IV_2]], [[OMP_UB_4]]
+// CHECK: br i1 [[COMP_3]], label %[[OMP_INNER_FOR_BODY:.+]], label 
%[[OMP_INNER_FOR_END:.+]]
+
+// CHECK: [[OMP_INNER_FOR_BODY]]
+// CHECK: br label %[[OMP_BODY_CONTINUE:.+]]
+
+// CHECK: [[OMP_BODY_CONTINUE]]
+// CHECK: br label %[[OMP_INNER_FOR_INC:.+]]
+
+// CHECK: [[OMP_INNER_FOR_INC]]
+// CHECK: [[OMP_IV_3:%.+]] = load i32, i32* [[OMP_IV]]
+// CHECK: [[ADD_1:%.+]] = add nsw i32 [[OMP_IV_3]], 1
+// CHECK: store i32 [[ADD_1]], i32* [[OMP_IV]]
+// CHECK: br label %[[OMP_INNER_FOR_COND]]
+
+// CHECK: [[OMP_INNER_FOR_END]]
+// CHECK: call void @__kmpc_for_static_fini(
+// CHECK: ret void
+
+#endif


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


[PATCH] D53772: [NFC][OpenMP] Add new test for parallel for code generation.

2018-10-26 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rC Clang

https://reviews.llvm.org/D53772



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


[PATCH] D53772: [NFC][OpenMP] Add new test for parallel for code generation.

2018-10-26 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea created this revision.
gtbercea added reviewers: ABataev, caomhin.
Herald added subscribers: cfe-commits, guansong.

This is a simple test of the parallel for code generation. It will be used to 
showcase the change introduced by patch https://reviews.llvm.org/D53443.


Repository:
  rC Clang

https://reviews.llvm.org/D53772

Files:
  test/OpenMP/nvptx_parallel_for_codegen.cpp

Index: test/OpenMP/nvptx_parallel_for_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/nvptx_parallel_for_codegen.cpp
@@ -0,0 +1,101 @@
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+template
+tx ftemplate(int n) {
+  tx b[10];
+
+  #pragma omp target
+  {
+tx d = n;
+#pragma omp parallel for
+for(int i=0; i<10; i++) {
+  b[i] += d;
+}
+b[3] += 1;
+  }
+
+  return b[3];
+}
+
+int bar(int n){
+  int a = 0;
+
+  a += ftemplate(n);
+
+  return a;
+}
+
+// CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+template.+l12}}_worker()
+// CHECK: call void @llvm.nvvm.barrier0()
+// CHECK: call i1 @__kmpc_kernel_parallel(
+// CHECK: call void @__omp_outlined___wrapper(
+
+// CHECK: define weak void @__omp_offloading_{{.*}}l12(
+// CHECK: call void @__omp_offloading_{{.*}}l12_worker()
+// CHECK: call void @__kmpc_kernel_init(
+// CHECK: call void @__kmpc_data_sharing_init_stack()
+// CHECK: call i8* @__kmpc_data_sharing_push_stack(i64 4, i16 0)
+// CHECK: call void @__kmpc_kernel_prepare_parallel(
+// CHECK: call void @__kmpc_begin_sharing_variables({{.*}}, i64 2)
+// CHECK: call void @llvm.nvvm.barrier0()
+// CHECK: call void @llvm.nvvm.barrier0()
+// CHECK: call void @__kmpc_end_sharing_variables()
+// CHECK: call void @__kmpc_data_sharing_pop_stack(
+// CHECK: call void @__kmpc_kernel_deinit(i16 1)
+
+// CHECK: define internal void @__omp_outlined__(
+// CHECK: alloca
+// CHECK: alloca
+// CHECK: alloca
+// CHECK: alloca
+// CHECK: [[OMP_IV:%.*]] = alloca i32
+// CHECK: store i32 0, {{.*}} [[OMP_LB:%.+]],
+// CHECK: store i32 9, {{.*}} [[OMP_UB:%.+]],
+// CHECK: store i32 1, {{.*}} [[OMP_ST:%.+]],
+// CHECK: call void @__kmpc_for_static_init_4({{.*}} i32 34, {{.*}} [[OMP_LB]], {{.*}} [[OMP_UB]], {{.*}} [[OMP_ST]], i32 1, i32 1)
+// CHECK: [[OMP_UB_1:%.+]] = load {{.*}} [[OMP_UB]]
+// CHECK: [[COMP_1:%.+]] = icmp sgt {{.*}} [[OMP_UB_1]]
+// CHECK: br i1 [[COMP_1]], label %[[COND_TRUE:.+]], label %[[COND_FALSE:.+]]
+
+// CHECK: [[COND_TRUE]]
+// CHECK: br label %[[COND_END:.+]]
+
+// CHECK: [[COND_FALSE]]
+// CHECK: [[OMP_UB_2:%.+]] = load {{.*}}* [[OMP_UB]]
+// CHECK: br label %[[COND_END]]
+
+// CHECK: [[COND_END]]
+// CHECK: [[COND_RES:%.+]] = phi i32 [ 9, %[[COND_TRUE]] ], [ [[OMP_UB_2]], %[[COND_FALSE]] ]
+// CHECK: store i32 [[COND_RES]], i32* [[OMP_UB]]
+// CHECK: [[OMP_LB_1:%.+]] = load i32, i32* [[OMP_LB]]
+// CHECK: store i32 [[OMP_LB_1]], i32* [[OMP_IV]]
+// CHECK: br label %[[OMP_INNER_FOR_COND:.+]]
+
+// CHECK: [[OMP_INNER_FOR_COND]]
+// CHECK: [[OMP_IV_2:%.+]] = load i32, i32* [[OMP_IV]]
+// CHECK: [[OMP_UB_4:%.+]] = load i32, i32* [[OMP_UB]]
+// CHECK: [[COMP_3:%.+]] = icmp sle i32 [[OMP_IV_2]], [[OMP_UB_4]]
+// CHECK: br i1 [[COMP_3]], label %[[OMP_INNER_FOR_BODY:.+]], label %[[OMP_INNER_FOR_END:.+]]
+
+// CHECK: [[OMP_INNER_FOR_BODY]]
+// CHECK: br label %[[OMP_BODY_CONTINUE:.+]]
+
+// CHECK: [[OMP_BODY_CONTINUE]]
+// CHECK: br label %[[OMP_INNER_FOR_INC:.+]]
+
+// CHECK: [[OMP_INNER_FOR_INC]]
+// CHECK: [[OMP_IV_3:%.+]] = load i32, i32* [[OMP_IV]]
+// CHECK: [[ADD_1:%.+]] = add nsw i32 [[OMP_IV_3]], 1
+// CHECK: store i32 [[ADD_1]], i32* [[OMP_IV]]
+// CHECK: br label %[[OMP_INNER_FOR_COND]]
+
+// CHECK: [[OMP_INNER_FOR_END]]
+// CHECK: call void @__kmpc_for_static_fini(
+// CHECK: ret void
+
+#endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53206: Allow padding checker to traverse simple class hierarchies

2018-10-26 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/PaddingChecker.cpp:78-81
+// We need to be looking at a definition, not just any pointer to the
+// declaration.
+if (!(RD = RD->getDefinition()))
+  return;

tekknolagi wrote:
> tekknolagi wrote:
> > NoQ wrote:
> > > This check is already in `shouldSkipDecl()` (?)
> > Oh yes, you're right.
> Actually, I'm not sure if you're right. I think it's necessary here because 
> it's only tested for C++ classes in shouldSkipDecl(). This tests it for C 
> structs too.  Either we could lift that outside the C++ section of 
> shouldSkipDecl or repeat it here.
Hmm, indeed. Sry!


Repository:
  rC Clang

https://reviews.llvm.org/D53206



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


[PATCH] D53206: Allow padding checker to traverse simple class hierarchies

2018-10-26 Thread Max Bernstein via Phabricator via cfe-commits
tekknolagi added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/PaddingChecker.cpp:78-81
+// We need to be looking at a definition, not just any pointer to the
+// declaration.
+if (!(RD = RD->getDefinition()))
+  return;

tekknolagi wrote:
> NoQ wrote:
> > This check is already in `shouldSkipDecl()` (?)
> Oh yes, you're right.
Actually, I'm not sure if you're right. I think it's necessary here because 
it's only tested for C++ classes in shouldSkipDecl(). This tests it for C 
structs too.  Either we could lift that outside the C++ section of 
shouldSkipDecl or repeat it here.


Repository:
  rC Clang

https://reviews.llvm.org/D53206



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


[PATCH] D53200: [OpenCL] Fix serialization of OpenCLExtensionDecls

2018-10-26 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: test/SemaOpenCL/extension-begin.cl:43
   g(0); // expected-error {{no matching function for call to 'g'}}
-// expected-note@-26 {{candidate unavailable as it requires OpenCL 
extension 'my_ext' to be disabled}}
-// expected-note@-22 {{candidate function not viable: requires 0 
arguments, but 1 was provided}}
+// expected-note@extension-begin.h:18 {{candidate unavailable as it 
requires OpenCL extension 'my_ext' to be disabled}}
+// expected-note@extension-begin.h:23 {{candidate function not viable: 
requires 0 arguments, but 1 was provided}}

AlexeySachkov wrote:
> Anastasia wrote:
> > Is this a typo? Should this be 'enabled' instead of 'disabled'?
> I left the diagnostic message the same as it was. Looks like it is a bug in 
> the diagnostic. I can try to fix it, but I would like to do it in a separate 
> patch
Sure! Thanks!


https://reviews.llvm.org/D53200



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


[PATCH] D50860: [libc++][test] Remove non-portable assumption that thread's constructor allocates with ::new

2018-10-26 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter added a comment.

I'll put this explanation in the comments and push a change.




Comment at: 
test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp:121
 //allocations.
+int numAllocs;
+

EricWF wrote:
> Why?
`main` non-portably assumes that thread creation results in at least one call 
to `::operator new`. This change fixes that assumption by counting the number 
of calls to `::operator new` here for creation of a do-nothing thread, and 
communicating that count to `main` via `numAllocs`.



Comment at: 
test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp:171
 #ifndef TEST_HAS_NO_EXCEPTIONS
-{
+if (numAllocs > 0) {
 try

EricWF wrote:
> I'm not sure I understand this change either.
> 
If thread creation in `test_throwing_new_during_thread_creation` resulted in 
`0` calls to `::operator new`, the expectation is that the same will occur here 
when we create a thread. If `::operator new` isn't called, it can't throw the 
exception this test is expecting to catch.


https://reviews.llvm.org/D50860



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


[PATCH] D53771: [clang-tidy] Avoid C arrays check

2018-10-26 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments.



Comment at: docs/clang-tidy/checks/list.rst:13
abseil-redundant-strcat-calls
-   abseil-string-find-startswith
abseil-str-cat-append

spurious change



Comment at: docs/clang-tidy/checks/list.rst:154
hicpp-undelegated-constructor (redirects to 
bugprone-undelegated-constructor) 
+   hicpp-uppercase-literal-suffix (redirects to 
readability-uppercase-literal-suffix) 
hicpp-use-auto (redirects to modernize-use-auto) 

here as well



Comment at: docs/clang-tidy/checks/misc-avoid-c-arrays.rst:51
+  }
+
+  ...

The last two lines do not add value, i think you can safely remove them



Comment at: test/clang-tidy/misc-avoid-c-arrays.cpp:14
+
+template 
+class array {

Please add a case with templates, where `T` itself is the array type, maybe 
there are other fancy template tricks that could create an array implictly?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53771



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


[PATCH] D53771: [clang-tidy] Avoid C arrays check

2018-10-26 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

`modernize` would be a fitting module, wouldn't it?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53771



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


[PATCH] D53417: [Clang][Sema][PowerPC] Choose a better candidate in overload function call if there is a compatible vector conversion instead of ambiguous call error

2018-10-26 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/lib/Sema/SemaOverload.cpp:3913
+for (auto Type : Types) {
+  if (S.Context.getCanonicalType(Type)->getTypeClass() != Type::Vector)
+return false;

hubert.reinterpretcast wrote:
> wuzish wrote:
> > hubert.reinterpretcast wrote:
> > > wuzish wrote:
> > > > hubert.reinterpretcast wrote:
> > > > > wuzish wrote:
> > > > > > hubert.reinterpretcast wrote:
> > > > > > > Considering that this is a local lambda called in one place, are 
> > > > > > > we expecting cases where the canonical type is not something on 
> > > > > > > which we can call getVectorKind()? If not, then we do not need 
> > > > > > > this `if`.
> > > > > > Well, that's for ExtVectorType. I encounter some testcase failure 
> > > > > > because of that. So I just narrow the condition to only handle 
> > > > > > Type::Vector.
> > > > > > 
> > > > > > As the following comment said, so I treat it separately.
> > > > > > 
> > > > > > /// ExtVectorType - Extended vector type. This type is created using
> > > > > > /// __attribute__((ext_vector_type(n)), where "n" is the number of 
> > > > > > elements.
> > > > > > /// Unlike vector_size, ext_vector_type is only allowed on 
> > > > > > typedef's. This
> > > > > > /// class enables syntactic extensions, like Vector Components for 
> > > > > > accessing
> > > > > > /// points (as .xyzw), colors (as .rgba), and textures (modeled 
> > > > > > after OpenGL
> > > > > > /// Shading Language).
> > > > > An ExtVectorType is a VectorType, so what sort of failures are you 
> > > > > hitting?
> > > > Yes. But the TypeClass of ExtVectorType is ExtVector.
> > > > 
> > > > some test points check the error report for ambiguous call because of 
> > > > too many implicit cast choices from ext_vector_type to vector type. 
> > > > Such as blow.
> > > > 
> > > > 
> > > > ```
> > > > typedef char char16 __attribute__ ((__vector_size__ (16)));
> > > > typedef long long longlong16 __attribute__ ((__vector_size__ (16)));
> > > > typedef char char16_e __attribute__ ((__ext_vector_type__ (16)));
> > > > typedef long long longlong16_e __attribute__ ((__ext_vector_type__ 
> > > > (2)));
> > > > 
> > > > 
> > > > void f1_test(char16 c16, longlong16 ll16, char16_e c16e, longlong16_e 
> > > > ll16e) {
> > > >   int  = f1(c16);
> > > >   float  = f1(ll16);
> > > >   f1(c16e); // expected-error{{call to 'f1' is ambiguous}}
> > > >   f1(ll16e); // expected-error{{call to 'f1' is ambiguous}}
> > > > }
> > > > ```
> > > > 
> > > > If we are gonna widen the condition, we can make a follow-up patch. Or 
> > > > we need include this condition and do this together in this patch?
> > > The widening that has occurred is in allowing the scope of the change to 
> > > encompass cases where AltiVec vectors are not sufficiently involved. The 
> > > change in behaviour makes sense, and perhaps the community may want to 
> > > pursue it; however, the mandate to make that level of change has not been 
> > > given.
> > > 
> > > I do not believe that requiring that the TypeClass be VectorType is the 
> > > correct narrowing of the scope. Instead, we may want to consider 
> > > requiring that for each `SCS` in { `SCS1`, `SCS2` }, there is one AltiVec 
> > > type and one generic vector type in { `SCS.getFromType()`, 
> > > `SCS.getToType(2)` }.
> > > 
> > The key point is that ExtVector is a kind of typeclass, **and** its vector 
> > kind is generic vector type.
> > 
> > So you think we should encompass ext_vector cases as a part of the scope of 
> > this patch? And modify the above cases' expected behavior (remove the 
> > **expected-error**)?
> I gave a concrete suggested narrowing of the scope that does not exclude 
> ExtVectorType or other derived types of VectorType. It also does not change 
> the behaviour of the `f1_test` case above. We could pursue additional 
> discussion over that case (separable from the current patch) on the mailing 
> list.
> 
> I believe my suggestion does do something about this case:
> ```
> typedef unsigned int GccType __attribute__((__ext_vector_type__(16)));
> typedef __vector unsigned int AltiVecType;
> 
> typedef float GccOtherType __attribute__((__vector_size__(16)));
> 
> void f(GccType);
> void f(GccOtherType);
> 
> void g(AltiVecType v) { f(v); }
> ```
> 
> I think that addressing the latter case is within the realm of things that we 
> should consider for this patch. Either way, we should ensure that tests for 
> AltiVec/__ext_vector_type__ conversions are available.
Sorry, typo in the above case:
```
typedef unsigned int GccType __attribute__((__ext_vector_type__(4)));
```



https://reviews.llvm.org/D53417



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


[PATCH] D53025: [clang-tidy] implement new check for const return types.

2018-10-26 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel marked 2 inline comments as done.
ymandel added inline comments.



Comment at: clang-tidy/readability/ConstValueReturnCheck.cpp:107
+diag(Def->getInnerLocStart(), "return type %0 is 'const'-qualified "
+  "hindering compiler optimizations")
+<< Def->getReturnType();

aaron.ballman wrote:
> ymandel wrote:
> > aaron.ballman wrote:
> > > It seems strange to me that this is in the readability module but the 
> > > diagnostic here is about compiler optimizations. Should this be in the 
> > > performance module instead? Or should this diagnostic be reworded about 
> > > the readability concerns?
> > Good point. The readability angle is that the const clutters the code to no 
> > benefit.  That is, even if it was performance neutral, I'd still want to 
> > discourage this practice.  But, it does seem like the primary impact is 
> > performance. 
> > 
> > I'm fine either way -- moving it to performance or emphasizing the clutter 
> > of the unhelpful "const".  I'm inclined to moving it, but don't have good 
> > sense of how strict these hierarchies are. What do you think?
> I'm not sold that `const`-qualified return types always pessimize 
> optimizations. However, I'm also not sold that it's *always* a bad idea to 
> have a top-level cv-qualifier on a return type either (for instance, this is 
> one way to prevent callers from modifying a temp returned by a function). How 
> about leaving this in readability and changing the diagnostic into: 
> "top-level 'const' qualifier on a return type may reduce code readability 
> with limited benefit" or something equally weasely?
I talked this over with other google folks and seems like the consensus is:

1.  The readability benefits may be controversial.  Some folks might not view 
`const` as clutter and there are some corner cases where the qualifier may 
prevent something harmful.
2.  The performance implication is real, if not guaranteed to be a problem.

Based on this, seems best to move it to performance, but water down the 
performance claims.  That keeps the focus to an issue we can assume nearly 
everyone agrees on.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53025



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


[PATCH] D53771: [clang-tidy] Avoid C arrays check

2018-10-26 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri created this revision.
lebedev.ri added reviewers: aaron.ballman, JonasToth, alexfh, hokein, xazax.hun.
lebedev.ri added a project: clang-tools-extra.
Herald added subscribers: rnkovacs, mgorny.
lebedev.ri edited the summary of this revision.

PR39224 
As discussed, we can't always do the transform automatically due to that 
array-to-pointer decay of C array.
In order to detect whether we can do said transform, we'd need to be able to 
see all usages of said array,
which is, i would say, rather impossible if e.g. it is in the header.
Thus right now no fixit exists.

Also, is `misc` the best place for this check?

Exceptions: `extern "C"` code.

References:

- CPPCG ES.27: Use std::array or stack_array for arrays on the stack 

- CPPCG SL.con.1: Prefer using STL array or vector instead of a C array 

- HICPP `4.1.1 Ensure that a function argument does not undergo an 
array-to-pointer conversion`
- MISRA `5-2-12 An identifier with array type passed as a function argument 
shall not decay to a pointer`


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53771

Files:
  clang-tidy/misc/AvoidCArraysCheck.cpp
  clang-tidy/misc/AvoidCArraysCheck.h
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-avoid-c-arrays.rst
  test/clang-tidy/misc-avoid-c-arrays.cpp

Index: test/clang-tidy/misc-avoid-c-arrays.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-avoid-c-arrays.cpp
@@ -0,0 +1,35 @@
+// RUN: %check_clang_tidy %s misc-avoid-c-arrays %t
+
+int a[] = {1, 2};
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: do not declare C-style arrays, use std::array<> instead
+
+int b[1];
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: do not declare C-style arrays, use std::array<> instead
+
+void foo() {
+  int c[b[0]];
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: do not declare C-style arrays, use std::array<> instead
+}
+
+template 
+class array {
+  T d[Size];
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: do not declare C-style arrays, use std::array<> instead
+
+  int e[1];
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: do not declare C-style arrays, use std::array<> instead
+};
+
+// Some header
+extern "C" {
+
+int f[] = {1, 2};
+
+int j[1];
+
+inline void bar() {
+  {
+int j[j[0]];
+  }
+}
+}
Index: docs/clang-tidy/checks/misc-avoid-c-arrays.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-avoid-c-arrays.rst
@@ -0,0 +1,52 @@
+.. title:: clang-tidy - misc-avoid-c-arrays
+
+misc-avoid-c-arrays
+===
+
+Find C-style array delarations and recommend to use ``std::array<>``.
+All types of C arrays are diagnosed.
+
+Hoever, no fix-its are provided. Such transform would need to be able to
+observe *all* the uses of said declaration in order to decide whether it is
+safe to transform or not, and that is impossible in case of headers.
+
+.. code:: c++
+
+  int a[] = {1, 2}; // warning: do not declare C-style arrays, use std::array<> instead
+
+  int b[1]; // warning: do not declare C-style arrays, use std::array<> instead
+
+  void foo() {
+int c[b[0]]; // warning: do not declare C-style arrays, use std::array<> instead
+  }
+
+  template 
+  class array {
+T d[Size]; // warning: do not declare C-style arrays, use std::array<> instead
+
+int e[1]; // warning: do not declare C-style arrays, use std::array<> instead
+  };
+
+  ...
+
+However, the ``extern "C"`` code is ignored, since it is common to share
+such headers between C code, and C++ code.
+
+.. code:: c++
+
+  // Some header
+  extern "C" {
+
+  int f[] = {1, 2}; // not diagnosed
+
+  int j[1]; // not diagnosed
+
+  inline void bar() {
+{
+  int j[j[0]]; // not diagnosed
+}
+  }
+
+  }
+
+  ...
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -10,8 +10,8 @@
abseil-no-internal-dependencies
abseil-no-namespace
abseil-redundant-strcat-calls
-   abseil-string-find-startswith
abseil-str-cat-append
+   abseil-string-find-startswith
android-cloexec-accept
android-cloexec-accept4
android-cloexec-creat
@@ -151,19 +151,20 @@
hicpp-special-member-functions (redirects to cppcoreguidelines-special-member-functions) 
hicpp-static-assert (redirects to misc-static-assert) 
hicpp-undelegated-constructor (redirects to bugprone-undelegated-constructor) 
+   hicpp-uppercase-literal-suffix (redirects to readability-uppercase-literal-suffix) 

[PATCH] D53770: Support g++ headers in include/g++

2018-10-26 Thread David Greene via Phabricator via cfe-commits
greened created this revision.
greened added reviewers: danalbert, dlj, atanasyan, phosek.
Herald added a subscriber: cfe-commits.

Some gcc installations put C++ headers in PREFIX/include/g++ without indicating 
a gcc version at all.  Typically this is because the version is encoded 
somewhere in PREFIX.


Repository:
  rC Clang

https://reviews.llvm.org/D53770

Files:
  lib/Driver/ToolChains/Linux.cpp


Index: lib/Driver/ToolChains/Linux.cpp
===
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -924,6 +924,9 @@
   // Freescale SDK C++ headers are directly in /usr/include/c++,
   // without a subdirectory corresponding to the gcc version.
   LibDir.str() + "/../include/c++",
+  // Some gcc installations put headers under "g++" without a
+  // version suffix.
+  LibDir.str() + "/../include/g++",
   };
 
   for (const auto  : LibStdCXXIncludePathCandidates) {


Index: lib/Driver/ToolChains/Linux.cpp
===
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -924,6 +924,9 @@
   // Freescale SDK C++ headers are directly in /usr/include/c++,
   // without a subdirectory corresponding to the gcc version.
   LibDir.str() + "/../include/c++",
+  // Some gcc installations put headers under "g++" without a
+  // version suffix.
+  LibDir.str() + "/../include/g++",
   };
 
   for (const auto  : LibStdCXXIncludePathCandidates) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53417: [Clang][Sema][PowerPC] Choose a better candidate in overload function call if there is a compatible vector conversion instead of ambiguous call error

2018-10-26 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/lib/Sema/SemaOverload.cpp:3913
+for (auto Type : Types) {
+  if (S.Context.getCanonicalType(Type)->getTypeClass() != Type::Vector)
+return false;

wuzish wrote:
> hubert.reinterpretcast wrote:
> > wuzish wrote:
> > > hubert.reinterpretcast wrote:
> > > > wuzish wrote:
> > > > > hubert.reinterpretcast wrote:
> > > > > > Considering that this is a local lambda called in one place, are we 
> > > > > > expecting cases where the canonical type is not something on which 
> > > > > > we can call getVectorKind()? If not, then we do not need this `if`.
> > > > > Well, that's for ExtVectorType. I encounter some testcase failure 
> > > > > because of that. So I just narrow the condition to only handle 
> > > > > Type::Vector.
> > > > > 
> > > > > As the following comment said, so I treat it separately.
> > > > > 
> > > > > /// ExtVectorType - Extended vector type. This type is created using
> > > > > /// __attribute__((ext_vector_type(n)), where "n" is the number of 
> > > > > elements.
> > > > > /// Unlike vector_size, ext_vector_type is only allowed on typedef's. 
> > > > > This
> > > > > /// class enables syntactic extensions, like Vector Components for 
> > > > > accessing
> > > > > /// points (as .xyzw), colors (as .rgba), and textures (modeled after 
> > > > > OpenGL
> > > > > /// Shading Language).
> > > > An ExtVectorType is a VectorType, so what sort of failures are you 
> > > > hitting?
> > > Yes. But the TypeClass of ExtVectorType is ExtVector.
> > > 
> > > some test points check the error report for ambiguous call because of too 
> > > many implicit cast choices from ext_vector_type to vector type. Such as 
> > > blow.
> > > 
> > > 
> > > ```
> > > typedef char char16 __attribute__ ((__vector_size__ (16)));
> > > typedef long long longlong16 __attribute__ ((__vector_size__ (16)));
> > > typedef char char16_e __attribute__ ((__ext_vector_type__ (16)));
> > > typedef long long longlong16_e __attribute__ ((__ext_vector_type__ (2)));
> > > 
> > > 
> > > void f1_test(char16 c16, longlong16 ll16, char16_e c16e, longlong16_e 
> > > ll16e) {
> > >   int  = f1(c16);
> > >   float  = f1(ll16);
> > >   f1(c16e); // expected-error{{call to 'f1' is ambiguous}}
> > >   f1(ll16e); // expected-error{{call to 'f1' is ambiguous}}
> > > }
> > > ```
> > > 
> > > If we are gonna widen the condition, we can make a follow-up patch. Or we 
> > > need include this condition and do this together in this patch?
> > The widening that has occurred is in allowing the scope of the change to 
> > encompass cases where AltiVec vectors are not sufficiently involved. The 
> > change in behaviour makes sense, and perhaps the community may want to 
> > pursue it; however, the mandate to make that level of change has not been 
> > given.
> > 
> > I do not believe that requiring that the TypeClass be VectorType is the 
> > correct narrowing of the scope. Instead, we may want to consider requiring 
> > that for each `SCS` in { `SCS1`, `SCS2` }, there is one AltiVec type and 
> > one generic vector type in { `SCS.getFromType()`, `SCS.getToType(2)` }.
> > 
> The key point is that ExtVector is a kind of typeclass, **and** its vector 
> kind is generic vector type.
> 
> So you think we should encompass ext_vector cases as a part of the scope of 
> this patch? And modify the above cases' expected behavior (remove the 
> **expected-error**)?
I gave a concrete suggested narrowing of the scope that does not exclude 
ExtVectorType or other derived types of VectorType. It also does not change the 
behaviour of the `f1_test` case above. We could pursue additional discussion 
over that case (separable from the current patch) on the mailing list.

I believe my suggestion does do something about this case:
```
typedef unsigned int GccType __attribute__((__ext_vector_type__(16)));
typedef __vector unsigned int AltiVecType;

typedef float GccOtherType __attribute__((__vector_size__(16)));

void f(GccType);
void f(GccOtherType);

void g(AltiVecType v) { f(v); }
```

I think that addressing the latter case is within the realm of things that we 
should consider for this patch. Either way, we should ensure that tests for 
AltiVec/__ext_vector_type__ conversions are available.


https://reviews.llvm.org/D53417



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


[PATCH] D53768: Add VerboseOutputStream to CompilerInstance

2018-10-26 Thread Scott Linder via Phabricator via cfe-commits
scott.linder created this revision.
scott.linder added a reviewer: rsmith.
Herald added a subscriber: cfe-commits.

An attempt at removing one instance of a hardcoded output stream in 
`CompilerInstance::ExecuteAction`. There are still other cases of output being 
hard-coded to standard streams in `ExecuteCompilerInvocation`, but this patch 
attempts to cover some cases when no specific flags (e.g. -version or -help) 
are passed, namely the "X warnings and Y errors generated." diagnostic.


Repository:
  rC Clang

https://reviews.llvm.org/D53768

Files:
  include/clang/Frontend/CompilerInstance.h
  lib/Frontend/CompilerInstance.cpp
  unittests/Frontend/OutputStreamTest.cpp

Index: unittests/Frontend/OutputStreamTest.cpp
===
--- unittests/Frontend/OutputStreamTest.cpp
+++ unittests/Frontend/OutputStreamTest.cpp
@@ -10,6 +10,7 @@
 #include "clang/CodeGen/BackendUtil.h"
 #include "clang/CodeGen/CodeGenAction.h"
 #include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/FrontendTool/Utils.h"
 #include "clang/Lex/PreprocessorOptions.h"
 #include "gtest/gtest.h"
@@ -43,4 +44,29 @@
   EXPECT_TRUE(!IRBuffer.empty());
   EXPECT_TRUE(StringRef(IRBuffer.data()).startswith("BC"));
 }
+
+TEST(FrontendOutputTests, TestVerboseOutputStream) {
+  auto Invocation = std::make_shared();
+  Invocation->getPreprocessorOpts().addRemappedFile(
+  "test.cc", MemoryBuffer::getMemBuffer("invalid").release());
+  Invocation->getFrontendOpts().Inputs.push_back(
+  FrontendInputFile("test.cc", InputKind::CXX));
+  Invocation->getFrontendOpts().ProgramAction = EmitBC;
+  Invocation->getTargetOpts().Triple = "i386-unknown-linux-gnu";
+  CompilerInstance Compiler;
+
+  std::string VerboseBuffer;
+  raw_string_ostream VerboseStream(VerboseBuffer);
+
+  Compiler.setInvocation(std::move(Invocation));
+  IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
+  Compiler.createDiagnostics(
+  new TextDiagnosticPrinter(llvm::nulls(), &*DiagOpts), true);
+  Compiler.setVerboseOutputStream(VerboseStream);
+
+  bool Success = ExecuteCompilerInvocation();
+  EXPECT_FALSE(Success);
+  EXPECT_TRUE(!VerboseStream.str().empty());
+  EXPECT_TRUE(StringRef(VerboseBuffer.data()).contains("errors generated"));
+}
 }
Index: lib/Frontend/CompilerInstance.cpp
===
--- lib/Frontend/CompilerInstance.cpp
+++ lib/Frontend/CompilerInstance.cpp
@@ -70,6 +70,8 @@
 
 CompilerInstance::~CompilerInstance() {
   assert(OutputFiles.empty() && "Still output files in flight?");
+  if (OwnsVerboseOutputStream)
+delete VerboseOutputStream;
 }
 
 void CompilerInstance::setInvocation(
@@ -88,6 +90,12 @@
   Diagnostics = Value;
 }
 
+void CompilerInstance::setVerboseOutputStream(raw_ostream ,
+  bool OwnsOutputStream) {
+  OwnsVerboseOutputStream = OwnsOutputStream;
+  VerboseOutputStream = 
+}
+
 void CompilerInstance::setTarget(TargetInfo *Value) { Target = Value; }
 void CompilerInstance::setAuxTarget(TargetInfo *Value) { AuxTarget = Value; }
 
@@ -907,9 +915,7 @@
   assert(!getFrontendOpts().ShowHelp && "Client must handle '-help'!");
   assert(!getFrontendOpts().ShowVersion && "Client must handle '-version'!");
 
-  // FIXME: Take this as an argument, once all the APIs we used have moved to
-  // taking it as an input instead of hard-coding llvm::errs.
-  raw_ostream  = llvm::errs();
+  raw_ostream  = getVerboseOutputStream();
 
   if (!Act.PrepareToExecute(*this))
 return false;
Index: include/clang/Frontend/CompilerInstance.h
===
--- include/clang/Frontend/CompilerInstance.h
+++ include/clang/Frontend/CompilerInstance.h
@@ -161,6 +161,12 @@
   /// One or more modules failed to build.
   bool ModuleBuildFailed = false;
 
+  /// Whether we should delete VerboseOutputStream on destruction.
+  bool OwnsVerboseOutputStream = false;
+
+  /// The stream for verbose output.
+  raw_ostream *VerboseOutputStream = ::errs();
+
   /// Holds information about the output file.
   ///
   /// If TempFilename is not empty we must rename it to Filename at the end.
@@ -223,9 +229,6 @@
   /// \param Act - The action to execute.
   /// \return - True on success.
   //
-  // FIXME: This function should take the stream to write any debugging /
-  // verbose output to as an argument.
-  //
   // FIXME: Eliminate the llvm_shutdown requirement, that should either be part
   // of the context or else not CompilerInstance specific.
   bool ExecuteAction(FrontendAction );
@@ -356,6 +359,21 @@
   }
 
   /// }
+  /// @name VerboseOutputStream
+  /// }
+
+  /// Replace the current stream for verbose output.
+  ///
+  /// If not set, this stream defaults to \c llvm::errs().
+  void setVerboseOutputStream(raw_ostream ,
+  bool OwnsOutputStream = false);
+
+  /// Get the 

[PATCH] D53200: [OpenCL] Fix serialization of OpenCLExtensionDecls

2018-10-26 Thread Alexey Sachkov via Phabricator via cfe-commits
AlexeySachkov added inline comments.



Comment at: test/SemaOpenCL/extension-begin.cl:43
   g(0); // expected-error {{no matching function for call to 'g'}}
-// expected-note@-26 {{candidate unavailable as it requires OpenCL 
extension 'my_ext' to be disabled}}
-// expected-note@-22 {{candidate function not viable: requires 0 
arguments, but 1 was provided}}
+// expected-note@extension-begin.h:18 {{candidate unavailable as it 
requires OpenCL extension 'my_ext' to be disabled}}
+// expected-note@extension-begin.h:23 {{candidate function not viable: 
requires 0 arguments, but 1 was provided}}

Anastasia wrote:
> Is this a typo? Should this be 'enabled' instead of 'disabled'?
I left the diagnostic message the same as it was. Looks like it is a bug in the 
diagnostic. I can try to fix it, but I would like to do it in a separate patch


https://reviews.llvm.org/D53200



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


[PATCH] D52676: [clang-format] tweaked another case of lambda formatting

2018-10-26 Thread Oleg Smolsky via Phabricator via cfe-commits
oleg.smolsky added a comment.

Folks, are there any other comments/suggestions?


Repository:
  rC Clang

https://reviews.llvm.org/D52676



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


[PATCH] D53707: [Fixed Point Arithmetic] Refactor fixed point casts

2018-10-26 Thread Bjorn Pettersson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC345398: [Fixed Point Arithmetic] Refactor fixed point casts 
(authored by bjope, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D53707?vs=171113=171311#toc

Repository:
  rC Clang

https://reviews.llvm.org/D53707

Files:
  lib/CodeGen/CGExprScalar.cpp
  test/Frontend/fixed_point_conversions.c
  test/Frontend/fixed_point_to_bool.c

Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -1029,7 +1029,7 @@
   // We do not need to check the padding bit on unsigned types if unsigned
   // padding is enabled because overflow into this bit is undefined
   // behavior.
-  return Builder.CreateIsNotNull(Src);
+  return Builder.CreateIsNotNull(Src, "tobool");
 }
 
 llvm_unreachable(
@@ -1247,79 +1247,62 @@
   unsigned DstWidth = DstFPSema.getWidth();
   unsigned SrcScale = SrcFPSema.getScale();
   unsigned DstScale = DstFPSema.getScale();
-  bool IsSigned = SrcFPSema.isSigned();
+  bool SrcIsSigned = SrcFPSema.isSigned();
+  bool DstIsSigned = DstFPSema.isSigned();
+
+  llvm::Type *DstIntTy = Builder.getIntNTy(DstWidth);
 
   Value *Result = Src;
   unsigned ResultWidth = SrcWidth;
 
   if (!DstFPSema.isSaturated()) {
-// Downscale
-if (DstScale < SrcScale) {
-  if (IsSigned)
-Result = Builder.CreateAShr(Result, SrcScale - DstScale);
-  else
-Result = Builder.CreateLShr(Result, SrcScale - DstScale);
-}
+// Downscale.
+if (DstScale < SrcScale)
+  Result = SrcIsSigned ?
+  Builder.CreateAShr(Result, SrcScale - DstScale, "downscale") :
+  Builder.CreateLShr(Result, SrcScale - DstScale, "downscale");
 
-// Resize
-llvm::Type *DstIntTy = Builder.getIntNTy(DstWidth);
-if (IsSigned)
-  Result = Builder.CreateSExtOrTrunc(Result, DstIntTy);
-else
-  Result = Builder.CreateZExtOrTrunc(Result, DstIntTy);
+// Resize.
+Result = Builder.CreateIntCast(Result, DstIntTy, SrcIsSigned, "resize");
 
-// Upscale
+// Upscale.
 if (DstScale > SrcScale)
-  Result = Builder.CreateShl(Result, DstScale - SrcScale);
+  Result = Builder.CreateShl(Result, DstScale - SrcScale, "upscale");
   } else {
+// Adjust the number of fractional bits.
 if (DstScale > SrcScale) {
-  // Need to extend first before scaling up
   ResultWidth = SrcWidth + DstScale - SrcScale;
   llvm::Type *UpscaledTy = Builder.getIntNTy(ResultWidth);
-
-  if (IsSigned)
-Result = Builder.CreateSExt(Result, UpscaledTy);
-  else
-Result = Builder.CreateZExt(Result, UpscaledTy);
-
-  Result = Builder.CreateShl(Result, DstScale - SrcScale);
+  Result = Builder.CreateIntCast(Result, UpscaledTy, SrcIsSigned, "resize");
+  Result = Builder.CreateShl(Result, DstScale - SrcScale, "upscale");
 } else if (DstScale < SrcScale) {
-  if (IsSigned)
-Result = Builder.CreateAShr(Result, SrcScale - DstScale);
-  else
-Result = Builder.CreateLShr(Result, SrcScale - DstScale);
+  Result = SrcIsSigned ?
+  Builder.CreateAShr(Result, SrcScale - DstScale, "downscale") :
+  Builder.CreateLShr(Result, SrcScale - DstScale, "downscale");
 }
 
-if (DstFPSema.getIntegralBits() < SrcFPSema.getIntegralBits()) {
-  auto Max = ConstantInt::get(
+// Handle saturation.
+bool LessIntBits = DstFPSema.getIntegralBits() < SrcFPSema.getIntegralBits();
+if (LessIntBits) {
+  Value *Max = ConstantInt::get(
   CGF.getLLVMContext(),
   APFixedPoint::getMax(DstFPSema).getValue().extOrTrunc(ResultWidth));
-  Value *TooHigh = IsSigned ? Builder.CreateICmpSGT(Result, Max)
-: Builder.CreateICmpUGT(Result, Max);
-  Result = Builder.CreateSelect(TooHigh, Max, Result);
-
-  if (IsSigned) {
-// Cannot overflow min to dest type is src is unsigned since all fixed
-// point types can cover the unsigned min of 0.
-auto Min = ConstantInt::get(
-CGF.getLLVMContext(),
-APFixedPoint::getMin(DstFPSema).getValue().extOrTrunc(ResultWidth));
-Value *TooLow = Builder.CreateICmpSLT(Result, Min);
-Result = Builder.CreateSelect(TooLow, Min, Result);
-  }
-} else if (IsSigned && !DstFPSema.isSigned()) {
-  llvm::Type *ResultTy = Builder.getIntNTy(ResultWidth);
-  Value *Zero = ConstantInt::getNullValue(ResultTy);
-  Value *LTZero = Builder.CreateICmpSLT(Result, Zero);
-  Result = Builder.CreateSelect(LTZero, Zero, Result);
+  Value *TooHigh = SrcIsSigned ? Builder.CreateICmpSGT(Result, Max)
+   : Builder.CreateICmpUGT(Result, Max);
+  Result = Builder.CreateSelect(TooHigh, Max, Result, "satmax");
+}
+// Cannot overflow min to dest type if src is unsigned 

r345398 - [Fixed Point Arithmetic] Refactor fixed point casts

2018-10-26 Thread Bjorn Pettersson via cfe-commits
Author: bjope
Date: Fri Oct 26 09:12:12 2018
New Revision: 345398

URL: http://llvm.org/viewvc/llvm-project?rev=345398=rev
Log:
[Fixed Point Arithmetic] Refactor fixed point casts

Summary:
- Added names for some emitted values (such as "tobool" for
  the result of a cast to boolean).
- Replaced explicit IRBuilder request for doing sext/zext/trunc
  by using CreateIntCast instead.
- Simplify code for emitting satuation into one if-statement
  for clamping to max, and one if-statement for clamping to min.

Reviewers: leonardchan, ebevhan

Reviewed By: leonardchan

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/test/Frontend/fixed_point_conversions.c
cfe/trunk/test/Frontend/fixed_point_to_bool.c

Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=345398=345397=345398=diff
==
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Fri Oct 26 09:12:12 2018
@@ -1029,7 +1029,7 @@ Value *ScalarExprEmitter::EmitScalarConv
   // We do not need to check the padding bit on unsigned types if unsigned
   // padding is enabled because overflow into this bit is undefined
   // behavior.
-  return Builder.CreateIsNotNull(Src);
+  return Builder.CreateIsNotNull(Src, "tobool");
 }
 
 llvm_unreachable(
@@ -1247,79 +1247,62 @@ Value *ScalarExprEmitter::EmitFixedPoint
   unsigned DstWidth = DstFPSema.getWidth();
   unsigned SrcScale = SrcFPSema.getScale();
   unsigned DstScale = DstFPSema.getScale();
-  bool IsSigned = SrcFPSema.isSigned();
+  bool SrcIsSigned = SrcFPSema.isSigned();
+  bool DstIsSigned = DstFPSema.isSigned();
+
+  llvm::Type *DstIntTy = Builder.getIntNTy(DstWidth);
 
   Value *Result = Src;
   unsigned ResultWidth = SrcWidth;
 
   if (!DstFPSema.isSaturated()) {
-// Downscale
-if (DstScale < SrcScale) {
-  if (IsSigned)
-Result = Builder.CreateAShr(Result, SrcScale - DstScale);
-  else
-Result = Builder.CreateLShr(Result, SrcScale - DstScale);
-}
+// Downscale.
+if (DstScale < SrcScale)
+  Result = SrcIsSigned ?
+  Builder.CreateAShr(Result, SrcScale - DstScale, "downscale") :
+  Builder.CreateLShr(Result, SrcScale - DstScale, "downscale");
 
-// Resize
-llvm::Type *DstIntTy = Builder.getIntNTy(DstWidth);
-if (IsSigned)
-  Result = Builder.CreateSExtOrTrunc(Result, DstIntTy);
-else
-  Result = Builder.CreateZExtOrTrunc(Result, DstIntTy);
+// Resize.
+Result = Builder.CreateIntCast(Result, DstIntTy, SrcIsSigned, "resize");
 
-// Upscale
+// Upscale.
 if (DstScale > SrcScale)
-  Result = Builder.CreateShl(Result, DstScale - SrcScale);
+  Result = Builder.CreateShl(Result, DstScale - SrcScale, "upscale");
   } else {
+// Adjust the number of fractional bits.
 if (DstScale > SrcScale) {
-  // Need to extend first before scaling up
   ResultWidth = SrcWidth + DstScale - SrcScale;
   llvm::Type *UpscaledTy = Builder.getIntNTy(ResultWidth);
-
-  if (IsSigned)
-Result = Builder.CreateSExt(Result, UpscaledTy);
-  else
-Result = Builder.CreateZExt(Result, UpscaledTy);
-
-  Result = Builder.CreateShl(Result, DstScale - SrcScale);
+  Result = Builder.CreateIntCast(Result, UpscaledTy, SrcIsSigned, 
"resize");
+  Result = Builder.CreateShl(Result, DstScale - SrcScale, "upscale");
 } else if (DstScale < SrcScale) {
-  if (IsSigned)
-Result = Builder.CreateAShr(Result, SrcScale - DstScale);
-  else
-Result = Builder.CreateLShr(Result, SrcScale - DstScale);
+  Result = SrcIsSigned ?
+  Builder.CreateAShr(Result, SrcScale - DstScale, "downscale") :
+  Builder.CreateLShr(Result, SrcScale - DstScale, "downscale");
 }
 
-if (DstFPSema.getIntegralBits() < SrcFPSema.getIntegralBits()) {
-  auto Max = ConstantInt::get(
+// Handle saturation.
+bool LessIntBits = DstFPSema.getIntegralBits() < 
SrcFPSema.getIntegralBits();
+if (LessIntBits) {
+  Value *Max = ConstantInt::get(
   CGF.getLLVMContext(),
   APFixedPoint::getMax(DstFPSema).getValue().extOrTrunc(ResultWidth));
-  Value *TooHigh = IsSigned ? Builder.CreateICmpSGT(Result, Max)
-: Builder.CreateICmpUGT(Result, Max);
-  Result = Builder.CreateSelect(TooHigh, Max, Result);
-
-  if (IsSigned) {
-// Cannot overflow min to dest type is src is unsigned since all fixed
-// point types can cover the unsigned min of 0.
-auto Min = ConstantInt::get(
-CGF.getLLVMContext(),
-
APFixedPoint::getMin(DstFPSema).getValue().extOrTrunc(ResultWidth));
-Value *TooLow = Builder.CreateICmpSLT(Result, Min);
-

[PATCH] D53738: [Fixed Point Arithmetic] Fixed Point Addition

2018-10-26 Thread Bjorn Pettersson via Phabricator via cfe-commits
bjope added inline comments.



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:3208
+  if (LHSWidth < CommonWidth)
+LHS = LHSSign ? Builder.CreateSExt(LHS, CommonTy)
+  : Builder.CreateZExt(LHS, CommonTy);

`LHS = Builder.CreateIntCast(LHS, CommonTy, LHSSign);`

(I think that it even is possible to remove the condition and always do this 
(the cast will be a no-op if LHSWidth==CommonWidth))



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:3211
+  if (RHSWidth < CommonWidth)
+RHS = RHSSign ? Builder.CreateSExt(RHS, CommonTy)
+  : Builder.CreateZExt(RHS, CommonTy);

Same as above, this can be simplified as:
  RHS = Builder.CreateIntCast(RHS, CommonTy, RHSSign);




Comment at: clang/lib/CodeGen/CGExprScalar.cpp:3214
+
+  // Align scales
+  unsigned CommonScale = std::max({LHSScale, RHSScale, ResultScale});

Arithmetically I think that it would be enough to align the scale to
```
 std::max(std::min(LHSScale, RHSScale), ResultScale)
```
As adding low fractional bits outside the result precision, when we know that 
those bits are zero in either of the inputs, won't impact any more significant 
bits in the result.

Maybe your solution is easier and good enough for a first implementation. And 
maybe `opt` is smart enough to optimize this anyway. Or maybe codegen could be 
worse due to not using legal types. Or maybe codegen could be improved due to 
using sadd.sat in more cases?
Lots of "maybes", so I don't think you need to do anything about this right 
now. It is just an idea from my side.



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:3252
+  llvm::Function *intrinsic = CGF.CGM.getIntrinsic(IID, CommonTy);
+  Result = Builder.CreateCall(intrinsic, {LHS, RHS});
+}

It should be possible to do it like this (if you add some line wrapping):
```
Builder.CreateBinaryIntrinsic(ResultSign ? llvm::Intrinsic::sadd_sat : 
 llvm::Intrinsic::uadd_sat, LHS, RHS);

```


Repository:
  rC Clang

https://reviews.llvm.org/D53738



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


[PATCH] D44100: [ASTImporter] Reorder fields after structure import is finished

2018-10-26 Thread Aleksei Sidorin via Phabricator via cfe-commits
a_sidorin added a comment.

Hi Gabor,
I have tried to rebase it last week but there were some test failures. I hope 
to fix them this weekend and finally commit the patch.


Repository:
  rC Clang

https://reviews.llvm.org/D44100



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


[PATCH] D53443: [OpenMP][NVPTX] Enable default scheduling for parallel for in non-SPMD cases.

2018-10-26 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: test/OpenMP/nvptx_parallel_for_codegen.cpp:44
+// CHECK: call void @__kmpc_kernel_prepare_parallel(
+// CHECK: call void @__kmpc_begin_sharing_variables(i8*** %shared_arg_refs, 
i64 2)
+// CHECK: call void @llvm.nvvm.barrier0()

Do not use names of the IR vars, use regular expressions.


Repository:
  rC Clang

https://reviews.llvm.org/D53443



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


[PATCH] D53693: [ASTImporter] Typedef import brings in the complete type

2018-10-26 Thread Aleksei Sidorin via Phabricator via cfe-commits
a_sidorin added a comment.

Hi Gabor,
Thank you for the patch. I looks reasonable but I have some questions.




Comment at: lib/AST/ASTImporter.cpp:2310
+D->getUnderlyingType(), FoundTypedef->getUnderlyingType())) {
+  QualType FromUT = D->getUnderlyingType();
+  QualType FoundUT = FoundTypedef->getUnderlyingType();

We can move these two vars upper and use them in the condition.



Comment at: lib/AST/ASTImporter.cpp:2314
+  // already have a complete underlying type then return with that.
+  if (!FromUT->isIncompleteType() && !FoundUT->isIncompleteType())
 return Importer.MapImported(D, FoundTypedef);

This condition omits the case where both types are complete. Should we use 
`FromUT->isIncompleteType == FoundUT-isIncompleteType()` instead?


Repository:
  rC Clang

https://reviews.llvm.org/D53693



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


[PATCH] D53443: [OpenMP][NVPTX] Enable default scheduling for parallel for in non-SPMD cases.

2018-10-26 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 171310.
gtbercea added a comment.

  Add test.


Repository:
  rC Clang

https://reviews.llvm.org/D53443

Files:
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  test/OpenMP/nvptx_parallel_for_codegen.cpp

Index: test/OpenMP/nvptx_parallel_for_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/nvptx_parallel_for_codegen.cpp
@@ -0,0 +1,123 @@
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+template
+tx ftemplate(int n) {
+  tx b[10];
+
+  #pragma omp target
+  {
+tx d = n;
+#pragma omp parallel for
+for(int i=0; i<10; i++) {
+  b[i] += d;
+}
+b[3] += 1;
+  }
+
+  return b[3];
+}
+
+int bar(int n){
+  int a = 0;
+
+  a += ftemplate(n);
+
+  return a;
+}
+
+// CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+template.+l12}}_worker()
+// CHECK: call void @llvm.nvvm.barrier0()
+// CHECK: call i1 @__kmpc_kernel_parallel(
+// CHECK: call void @__omp_outlined___wrapper(
+
+// CHECK: define weak void @__omp_offloading_{{.*}}l12(
+// CHECK: call void @__omp_offloading_{{.*}}l12_worker()
+// CHECK: call void @__kmpc_kernel_init(
+// CHECK: call void @__kmpc_data_sharing_init_stack()
+// CHECK: call i8* @__kmpc_data_sharing_push_stack(i64 4, i16 0)
+// CHECK: call void @__kmpc_kernel_prepare_parallel(
+// CHECK: call void @__kmpc_begin_sharing_variables(i8*** %shared_arg_refs, i64 2)
+// CHECK: call void @llvm.nvvm.barrier0()
+// CHECK: call void @llvm.nvvm.barrier0()
+// CHECK: call void @__kmpc_end_sharing_variables()
+// CHECK: call void @__kmpc_data_sharing_pop_stack(
+// CHECK: call void @__kmpc_kernel_deinit(i16 1)
+
+// CHECK: define internal void @__omp_outlined__(
+// CHECK: alloca
+// CHECK: alloca
+// CHECK: alloca
+// CHECK: alloca
+// CHECK: [[OMP_IV:%.*]] = alloca i32
+// CHECK: store i32 0, {{.*}} [[OMP_LB:%.+]],
+// CHECK: store i32 9, {{.*}} [[OMP_UB:%.+]],
+// CHECK: store i32 1, {{.*}} [[OMP_ST:%.+]],
+// CHECK: call void @__kmpc_for_static_init_4({{.*}} i32 33, {{.*}} [[OMP_LB]], {{.*}} [[OMP_UB]], {{.*}} [[OMP_ST]], i32 1, i32 1)
+// CHECK: br label %[[OMP_DISPATCH_COND:.+]]
+
+// CHECK: [[OMP_DISPATCH_COND]]
+// CHECK: [[OMP_UB_1:%.+]] = load {{.*}} [[OMP_UB]]
+// CHECK: [[COMP_1:%.+]] = icmp sgt {{.*}} [[OMP_UB_1]]
+// CHECK: br i1 [[COMP_1]], label %[[COND_TRUE:.+]], label %[[COND_FALSE:.+]]
+
+// CHECK: [[COND_TRUE]]
+// CHECK: br label %[[COND_END:.+]]
+
+// CHECK: [[COND_FALSE]]
+// CHECK: [[OMP_UB_2:%.+]] = load {{.*}}* [[OMP_UB]]
+// CHECK: br label %[[COND_END]]
+
+// CHECK: [[COND_END]]
+// CHECK: [[COND_RES:%.+]] = phi i32 [ 9, %[[COND_TRUE]] ], [ [[OMP_UB_2]], %[[COND_FALSE]] ]
+// CHECK: store i32 [[COND_RES]], i32* [[OMP_UB]]
+// CHECK: [[OMP_LB_1:%.+]] = load i32, i32* [[OMP_LB]]
+// CHECK: store i32 [[OMP_LB_1]], i32* [[OMP_IV]]
+// CHECK: [[OMP_IV_1:%.+]] = load i32, i32* [[OMP_IV]]
+// CHECK: [[OMP_UB_3:%.+]] = load i32, i32* [[OMP_UB]]
+// CHECK: [[COMP_2:%.+]] = icmp sle i32 [[OMP_IV_1]], [[OMP_UB_3]]
+// CHECK: br i1 [[COMP_2]], label %[[DISPATCH_BODY:.+]], label %[[DISPATCH_END:.+]]
+
+// CHECK: [[DISPATCH_BODY]]
+// CHECK: br label %[[OMP_INNER_FOR_COND:.+]]
+
+// CHECK: [[OMP_INNER_FOR_COND]]
+// CHECK: [[OMP_IV_2:%.+]] = load i32, i32* [[OMP_IV]]
+// CHECK: [[OMP_UB_4:%.+]] = load i32, i32* [[OMP_UB]]
+// CHECK: [[COMP_3:%.+]] = icmp sle i32 [[OMP_IV_2]], [[OMP_UB_4]]
+// CHECK: br i1 [[COMP_3]], label %[[OMP_INNER_FOR_BODY:.+]], label %[[OMP_INNER_FOR_END:.+]]
+
+// CHECK: [[OMP_INNER_FOR_BODY]]
+// CHECK: br label %[[OMP_BODY_CONTINUE:.+]]
+
+// CHECK: [[OMP_BODY_CONTINUE]]
+// CHECK: br label %[[OMP_INNER_FOR_INC:.+]]
+
+// CHECK: [[OMP_INNER_FOR_INC]]
+// CHECK: [[OMP_IV_3:%.+]] = load i32, i32* [[OMP_IV]]
+// CHECK: [[ADD_1:%.+]] = add nsw i32 [[OMP_IV_3]], 1
+// CHECK: store i32 [[ADD_1]], i32* [[OMP_IV]]
+// CHECK: br label %[[OMP_INNER_FOR_COND]]
+
+// CHECK: [[OMP_INNER_FOR_COND]]
+// CHECK: br label %[[OMP_DISPATCH_INC:.+]]
+
+// CHECK: [[OMP_DISPATCH_INC]]
+// CHECK: [[OMP_LB_2:%.+]] = load i32, i32* [[OMP_LB]]
+// CHECK: [[OMP_ST_1:%.+]] = load i32, i32* [[OMP_ST]]
+// CHECK: [[ADD_2:%.+]] = add nsw i32 [[OMP_LB_2]], [[OMP_ST_1]]
+// CHECK: store i32 [[ADD_2]], i32* [[OMP_LB]]
+// CHECK: [[OMP_UB_5:%.+]] = load i32, i32* [[OMP_UB]]
+// CHECK: [[OMP_ST_2:%.+]] = load i32, i32* [[OMP_ST]]
+// CHECK: [[ADD_3:%.+]] = add nsw i32 [[OMP_UB_5]], [[OMP_ST_2]]
+// CHECK: store i32 [[ADD_3]], i32* [[OMP_UB]]
+
+// CHECK: [[DISPATCH_END]]
+// CHECK: call void 

[PATCH] D53023: Prototype OpenCL BIFs using Tablegen

2018-10-26 Thread Andrew Savonichev via Phabricator via cfe-commits
asavonic added inline comments.



Comment at: lib/Sema/SemaExpr.cpp:2247
   if (R.empty() && HasTrailingLParen && II && !getLangOpts().CPlusPlus) {
-NamedDecl *D = ImplicitlyDefineFunction(NameLoc, *II, S);
-if (D) R.addDecl(D);
+if (getLangOpts().OpenCL) {
+  auto Index =

It will be good to have a driver option to enable this feature.


https://reviews.llvm.org/D53023



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


[PATCH] D44100: [ASTImporter] Reorder fields after structure import is finished

2018-10-26 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

Ping. This is still not committed, however, essential for ctu analyse any C++ 
project. Aleksei, I am happy to commit it for you if you don't have time, just 
let me know.


Repository:
  rC Clang

https://reviews.llvm.org/D44100



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


[PATCH] D53023: Prototype OpenCL BIFs using Tablegen

2018-10-26 Thread Andrew Savonichev via Phabricator via cfe-commits
asavonic added a comment.

> TODO
>  Measure the performance / size impact

I looks like the total size of OpenCLBuiltinDecl table should be
~450KB (for ~15000 functions). I guess it can be reduced furthermore by:

1. Replacing return type with an index (you've mentioned this in TODO).
2. Replace extension and a version with a single index.
3. Same for NumArgs and ArgTableIndex - they seem to be really tied together, 
so maybe we can use a single identifier for them?

With these improvements the total size should become ~175KB, which
seems to be ok, considering that libclangSema.so takes 9.4MB.

In my opinion, even 450KB is a vast improvement over what we have now,
because opencl-c.h alone takes 786KB.




Comment at: lib/Sema/SemaExpr.cpp:2131
+  ParmVarDecl::Create(Context, NewFD, SourceLocation(),
+  SourceLocation(), PP.getIdentifierInfo(arg_name),
+  ArgTypes[i], nullptr, SC_None, nullptr));

This dummy identifier name actually makes a diagnostic a bit weird:

t/gid.cl:3:31: error: too many arguments to function call, expected single 
argument 'a0', have 2 arguments
uint gid = get_global_id(0, 2);

It seems to be better if you pass nullptr instead:
t/gid.cl:4:31: error: too many arguments to function call, expected 1, have 
2
uint gid = get_global_id(0, 1);




https://reviews.llvm.org/D53023



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


[PATCH] D53448: [OpenMP][NVPTX] Use single loops when generating code for distribute parallel for

2018-10-26 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG, with a nit




Comment at: lib/Sema/SemaOpenMP.cpp:5308
+
+// Build IV <= PrevEUB to be used in parallel for is in combination with
+// a distribute directive with schedule(static, 1)

Fix the comment here


Repository:
  rC Clang

https://reviews.llvm.org/D53448



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


[PATCH] D51484: [OpenCL] Add support of cl_intel_device_side_avc_motion_estimation extension

2018-10-26 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks!




Comment at: test/SemaOpenCL/intel-subgroup-avc-ext-types.cl:5
+
+// All intel_sub_group_avc_* types can only be used as argument or return value
+// of built-in functions defined in the extension.

Btw do you plan to implement this later:
  All intel_sub_group_avc_* types can only be used as argument or return value 
of built-in functions defined in the extension.


https://reviews.llvm.org/D51484



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


[PATCH] D53764: [OpenCL] Enable address spaces for references in C++

2018-10-26 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: lib/AST/Expr.cpp:1609
   case CK_AddressSpaceConversion:
-assert(getType()->isPointerType() || getType()->isBlockPointerType());
-assert(getSubExpr()->getType()->isPointerType() ||
-   getSubExpr()->getType()->isBlockPointerType());
-assert(getType()->getPointeeType().getAddressSpace() !=
-   getSubExpr()->getType()->getPointeeType().getAddressSpace());
-LLVM_FALLTHROUGH;
+assert(/*If pointer type then addr spaces for pointees must differ*/
+   (((getType()->isPointerType() &&

I don't like this assert now. Would adding extra variable be cleaner here?


https://reviews.llvm.org/D53764



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


[PATCH] D53764: [OpenCL] Enable address spaces for references in C++

2018-10-26 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia created this revision.
Anastasia added reviewers: rjmccall, yaxunl.

I first enabled AS deduction for references that allowed to inherit the right 
conversion diagnostics based on qualification conversion rules implemented 
earlier for the pointer type.

Then in order to tests the deduction rules fully, I had to enable some extra 
features from OpenCL 2.0 that are also valid in C++.

A number of ICEs fired in the `CodeGen` due to missing `addrspacecast`. Not 
convinced the current solution is good though. May be it would be cleaner to 
add a separate `CastKind` here - `CK_LValueAddressSpaceConversion`? Although I 
am not entirely clear about the benefits yet.


https://reviews.llvm.org/D53764

Files:
  lib/AST/Expr.cpp
  lib/CodeGen/CGExpr.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaInit.cpp
  lib/Sema/SemaType.cpp
  test/CodeGenOpenCLCXX/address-space-deduction.cl

Index: test/CodeGenOpenCLCXX/address-space-deduction.cl
===
--- /dev/null
+++ test/CodeGenOpenCLCXX/address-space-deduction.cl
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -O0 -emit-llvm -o - | FileCheck %s -check-prefixes=COMMON,PTR
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -O0 -emit-llvm -o - -DREF | FileCheck %s -check-prefixes=COMMON,REF
+
+#ifdef REF
+#define PTR &
+#define ADR(x) x
+#else
+#define PTR *
+#define ADR(x) 
+#endif
+
+//COMMON: @glob = addrspace(1) global i32
+int glob;
+//PTR: @glob_p = addrspace(1) global i32 addrspace(4)* addrspacecast (i32 addrspace(1)* @glob to i32 addrspace(4)*)
+//REF: @glob_p = addrspace(1) global i32 addrspace(4)* null
+int PTR glob_p = ADR(glob);
+
+//COMMON: @_ZZ3fooi{{P|R}}U3AS4iE6loc_st = internal addrspace(1) global i32
+//PTR: @_ZZ3fooiPU3AS4iE8loc_st_p = internal addrspace(1) global i32 addrspace(4)* addrspacecast (i32 addrspace(1)* @_ZZ3fooiPU3AS4iE6loc_st to i32 addrspace(4)*)
+//REF: @_ZZ3fooiRU3AS4iE8loc_st_p = internal addrspace(1) global i32 addrspace(4)* null
+//COMMON: @loc_ext_p = external addrspace(1) {{global|constant}} i32 addrspace(4)*
+//COMMON: @loc_ext = external addrspace(1) global i32
+
+//REF: store i32 addrspace(4)* addrspacecast (i32 addrspace(1)* @glob to i32 addrspace(4)*), i32 addrspace(4)* addrspace(1)* @glob_p
+
+//COMMON: define spir_func i32 @_Z3fooi{{P|R}}U3AS4i(i32 %par, i32 addrspace(4)*{{.*}} %par_p)
+int foo(int par, int PTR par_p){
+//COMMON: %loc = alloca i32
+  int loc;
+//COMMON: %loc_p = alloca i32 addrspace(4)*
+//COMMON: [[GAS:%[0-9]+]] = addrspacecast i32* %loc to i32 addrspace(4)*
+//COMMON: store i32 addrspace(4)* [[GAS]], i32 addrspace(4)** %loc_p
+  int PTR loc_p = ADR(loc);
+
+// CHECK directives for the following code are located above.
+  static int loc_st;
+  static int PTR loc_st_p = ADR(loc_st);
+  extern int loc_ext;
+  extern int PTR loc_ext_p;
+  (void)loc_ext_p;
+  return loc_ext;
+}
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -7177,7 +7177,8 @@
   bool IsPointee =
   ChunkIndex > 0 &&
   (D.getTypeObject(ChunkIndex - 1).Kind == DeclaratorChunk::Pointer ||
-   D.getTypeObject(ChunkIndex - 1).Kind == DeclaratorChunk::BlockPointer);
+   D.getTypeObject(ChunkIndex - 1).Kind == DeclaratorChunk::BlockPointer ||
+   D.getTypeObject(ChunkIndex - 1).Kind == DeclaratorChunk::Reference);
   bool IsFuncReturnType =
   ChunkIndex > 0 &&
   D.getTypeObject(ChunkIndex - 1).Kind == DeclaratorChunk::Function;
Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -7603,12 +7603,15 @@
 case SK_QualificationConversionRValue: {
   // Perform a qualification conversion; these can never go wrong.
   ExprValueKind VK =
-  Step->Kind == SK_QualificationConversionLValue ?
-  VK_LValue :
-  (Step->Kind == SK_QualificationConversionXValue ?
-   VK_XValue :
-   VK_RValue);
-  CurInit = S.ImpCastExprToType(CurInit.get(), Step->Type, CK_NoOp, VK);
+  Step->Kind == SK_QualificationConversionLValue
+  ? VK_LValue
+  : (Step->Kind == SK_QualificationConversionXValue ? VK_XValue
+: VK_RValue);
+  CastKind CK = (Step->Type.getAddressSpace() !=
+ CurInit.get()->getType().getAddressSpace())
+? CK_AddressSpaceConversion
+: CK_NoOp;
+  CurInit = S.ImpCastExprToType(CurInit.get(), Step->Type, CK, VK);
   break;
 }
 
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -4276,10 +4276,17 @@
   case 

[PATCH] D53763: [libc++] [test] Fix logic error in tests; enable for MSVC previews

2018-10-26 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter created this revision.
CaseyCarter added reviewers: EricWF, mclow.lists.

Fairly straightforward: these tests were written without an implementation of 
`<=>`, and they're incorrectly testing that `0 <=> foo` has the behavior that 
is required for `foo <=> 0`.


https://reviews.llvm.org/D53763

Files:
  test/std/language.support/cmp/cmp.partialord/partialord.pass.cpp
  test/std/language.support/cmp/cmp.strongord/strongord.pass.cpp
  test/std/language.support/cmp/cmp.weakord/weakord.pass.cpp
  test/support/test_macros.h


Index: test/support/test_macros.h
===
--- test/support/test_macros.h
+++ test/support/test_macros.h
@@ -203,8 +203,9 @@
 
 // FIXME: Fix this feature check when either (A) a compiler provides a complete
 // implementation, or (b) a feature check macro is specified
+#if !defined(_MSC_VER) || defined(__clang__) || _MSC_VER < 1920 || _MSVC_LANG 
<= 201703L
 #define TEST_HAS_NO_SPACESHIP_OPERATOR
-
+#endif
 
 #if TEST_STD_VER < 11
 #define ASSERT_NOEXCEPT(...)
Index: test/std/language.support/cmp/cmp.weakord/weakord.pass.cpp
===
--- test/std/language.support/cmp/cmp.weakord/weakord.pass.cpp
+++ test/std/language.support/cmp/cmp.weakord/weakord.pass.cpp
@@ -142,7 +142,7 @@
   };
   for (auto TC : SpaceshipTestCases)
   {
-std::weak_ordering Res = (0 <=> TC.Value);
+std::weak_ordering Res = (TC.Value <=> 0);
 switch (TC.Expect) {
 case ER_Equiv:
   assert(Res == 0);
Index: test/std/language.support/cmp/cmp.strongord/strongord.pass.cpp
===
--- test/std/language.support/cmp/cmp.strongord/strongord.pass.cpp
+++ test/std/language.support/cmp/cmp.strongord/strongord.pass.cpp
@@ -185,7 +185,7 @@
   };
   for (auto TC : SpaceshipTestCases)
   {
-std::strong_ordering Res = (0 <=> TC.Value);
+std::strong_ordering Res = (TC.Value <=> 0);
 switch (TC.Expect) {
 case ER_Equiv:
   assert(Res == 0);
Index: test/std/language.support/cmp/cmp.partialord/partialord.pass.cpp
===
--- test/std/language.support/cmp/cmp.partialord/partialord.pass.cpp
+++ test/std/language.support/cmp/cmp.partialord/partialord.pass.cpp
@@ -130,7 +130,7 @@
   };
   for (auto TC : SpaceshipTestCases)
   {
-std::partial_ordering Res = (0 <=> TC.Value);
+std::partial_ordering Res = (TC.Value <=> 0);
 switch (TC.Expect) {
 case ER_Equiv:
   assert(Res == 0);


Index: test/support/test_macros.h
===
--- test/support/test_macros.h
+++ test/support/test_macros.h
@@ -203,8 +203,9 @@
 
 // FIXME: Fix this feature check when either (A) a compiler provides a complete
 // implementation, or (b) a feature check macro is specified
+#if !defined(_MSC_VER) || defined(__clang__) || _MSC_VER < 1920 || _MSVC_LANG <= 201703L
 #define TEST_HAS_NO_SPACESHIP_OPERATOR
-
+#endif
 
 #if TEST_STD_VER < 11
 #define ASSERT_NOEXCEPT(...)
Index: test/std/language.support/cmp/cmp.weakord/weakord.pass.cpp
===
--- test/std/language.support/cmp/cmp.weakord/weakord.pass.cpp
+++ test/std/language.support/cmp/cmp.weakord/weakord.pass.cpp
@@ -142,7 +142,7 @@
   };
   for (auto TC : SpaceshipTestCases)
   {
-std::weak_ordering Res = (0 <=> TC.Value);
+std::weak_ordering Res = (TC.Value <=> 0);
 switch (TC.Expect) {
 case ER_Equiv:
   assert(Res == 0);
Index: test/std/language.support/cmp/cmp.strongord/strongord.pass.cpp
===
--- test/std/language.support/cmp/cmp.strongord/strongord.pass.cpp
+++ test/std/language.support/cmp/cmp.strongord/strongord.pass.cpp
@@ -185,7 +185,7 @@
   };
   for (auto TC : SpaceshipTestCases)
   {
-std::strong_ordering Res = (0 <=> TC.Value);
+std::strong_ordering Res = (TC.Value <=> 0);
 switch (TC.Expect) {
 case ER_Equiv:
   assert(Res == 0);
Index: test/std/language.support/cmp/cmp.partialord/partialord.pass.cpp
===
--- test/std/language.support/cmp/cmp.partialord/partialord.pass.cpp
+++ test/std/language.support/cmp/cmp.partialord/partialord.pass.cpp
@@ -130,7 +130,7 @@
   };
   for (auto TC : SpaceshipTestCases)
   {
-std::partial_ordering Res = (0 <=> TC.Value);
+std::partial_ordering Res = (TC.Value <=> 0);
 switch (TC.Expect) {
 case ER_Equiv:
   assert(Res == 0);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53025: [clang-tidy] implement new check for const return types.

2018-10-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/readability/ConstValueReturnCheck.cpp:107
+diag(Def->getInnerLocStart(), "return type %0 is 'const'-qualified "
+  "hindering compiler optimizations")
+<< Def->getReturnType();

ymandel wrote:
> aaron.ballman wrote:
> > It seems strange to me that this is in the readability module but the 
> > diagnostic here is about compiler optimizations. Should this be in the 
> > performance module instead? Or should this diagnostic be reworded about the 
> > readability concerns?
> Good point. The readability angle is that the const clutters the code to no 
> benefit.  That is, even if it was performance neutral, I'd still want to 
> discourage this practice.  But, it does seem like the primary impact is 
> performance. 
> 
> I'm fine either way -- moving it to performance or emphasizing the clutter of 
> the unhelpful "const".  I'm inclined to moving it, but don't have good sense 
> of how strict these hierarchies are. What do you think?
I'm not sold that `const`-qualified return types always pessimize 
optimizations. However, I'm also not sold that it's *always* a bad idea to have 
a top-level cv-qualifier on a return type either (for instance, this is one way 
to prevent callers from modifying a temp returned by a function). How about 
leaving this in readability and changing the diagnostic into: "top-level 
'const' qualifier on a return type may reduce code readability with limited 
benefit" or something equally weasely?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53025



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


[PATCH] D52742: [analyzer][PlistMacroExpansion] Part 1.: New expand-macros flag

2018-10-26 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus planned changes to this revision.
Szelethus added a comment.

@xazax.hun observed that the way `diagnostics` looks like is this:

  diagnostics
report 1
  notes
  macro_expansions
  path
  executed_lines
report 2
  ...

Bt, if I didn't insist on this structure, but rather print macros at the 
end of the report, we wouldn't need all this hackery (converting a immutable 
container, into a mutable one, and then actually modifying the path). This 
however does imply that macro pieces have to be collected, which would imply 
the need for adding //yet another// parameter to //every single function// in 
this file. I think the time has come to collect them in a class, so I'll put 
this patch on hold.

Mind you, the rest of the patches don't contain logic that depends on this 
patch.


https://reviews.llvm.org/D52742



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


[PATCH] D53200: [OpenCL] Fix serialization of OpenCLExtensionDecls

2018-10-26 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks!




Comment at: test/SemaOpenCL/extension-begin.cl:43
   g(0); // expected-error {{no matching function for call to 'g'}}
-// expected-note@-26 {{candidate unavailable as it requires OpenCL 
extension 'my_ext' to be disabled}}
-// expected-note@-22 {{candidate function not viable: requires 0 
arguments, but 1 was provided}}
+// expected-note@extension-begin.h:18 {{candidate unavailable as it 
requires OpenCL extension 'my_ext' to be disabled}}
+// expected-note@extension-begin.h:23 {{candidate function not viable: 
requires 0 arguments, but 1 was provided}}

Is this a typo? Should this be 'enabled' instead of 'disabled'?


https://reviews.llvm.org/D53200



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


[PATCH] D51949: [clang-tidy] new check 'readability-isolate-declaration'

2018-10-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Mostly minor nits that clean up wording and comments.




Comment at: clang-tidy/readability/IsolateDeclarationCheck.cpp:52
+ const LangOptions ) {
+  assert(Indirections >= 0 && "Indirections must be non-negative");
+  if (Indirections == 0)

JonasToth wrote:
> aaron.ballman wrote:
> > This assertion suggests that `Indirections` should be `unsigned` and that 
> > you perform the assertion before doing a decrement to ensure it isn't 
> > trying to decrement past 0.
> Because the decrement is post-fix it will decrement past 0 on the breaking 
> condition.
> Having `unsigned` will result in a wrap (is defined, but still slightly 
> non-obvious).
> 
> I could make a `do - while`, then the condition can be `--Indirections != 0`. 
> I would just like to follow the CPPCG that say 'don't use unsigned unless you 
> need modulo arithmetic'.
I disagree with this logic (personally, I think this is a code smell), but 
don't feel strongly enough about it to ask you to change it.



Comment at: clang-tidy/readability/IsolateDeclarationCheck.cpp:69
+static int countIndirections(const Type *T, int Indirections = 0) {
+  if (isa(T) && T->isFunctionPointerType()) {
+const auto *Pointee =

No need for the `isa<>` check -- `isFunctionPointerType()` already does the 
right thing.



Comment at: clang-tidy/readability/IsolateDeclarationCheck.cpp:71
+const auto *Pointee =
+T->getPointeeType().getTypePtr()->castAs();
+return countIndirections(

You don't need to call `getTypePtr()` -- `QualType` overloads `operator->()` to 
do this directly.



Comment at: clang-tidy/readability/IsolateDeclarationCheck.cpp:141
+
+  // FIXME: Member pointer are not transformed correctly right now, that's
+  // why they are treated as problematic here.

Member pointer -> Member pointers



Comment at: clang-tidy/readability/IsolateDeclarationCheck.cpp:191
+
+// FIXME: Member pointer are not transformed correctly right now, that's
+// why they are treated as problematic here.

Member pointer -> Member pointers



Comment at: clang-tidy/utils/LexerUtils.cpp:86
+
+if ((*Tok).is(tok::hash))
+  return false;

`Tok->is()`



Comment at: clang-tidy/utils/LexerUtils.h:78
+
+/// Relex the provide \p Range and return \c false if either a macro spanning
+/// multiple tokens, a pre-processor directive or failure to retrieve the

Relex the provide -> Re-lex the provided
spanning -> spans



Comment at: clang-tidy/utils/LexerUtils.h:81
+/// next token is found, otherwise \c true.
+bool saveFromPreProcessor(SourceRange Range, const SourceManager ,
+  const LangOptions );

I don't think the functionality is obvious from the name -- this is testing to 
see whether any token in the given range is either a macro or a preprocessor 
directive. How about reversing the logic to: 
`rangeContainsExpansionsOrDirectives()`



Comment at: docs/clang-tidy/checks/readability-isolate-declaration.rst:3
+
+readability-isolate-declarationaration
+==

Typo. declarationaration -> declaration

(Don't forget to fix the underlines as well.)



Comment at: docs/clang-tidy/checks/readability-isolate-declaration.rst:10
+The automatic code-transformation will use the same indentation as the original
+for every created statement and add a linebreak after each statement.
+

linebreak -> line break

I think it may also be important to point out that the declarations will remain 
in the same order as their original source order. For instance, you may run 
into code like: `int i = 5, j = i;` and it's crucial that it be transformed 
into `int i = 5; int j = i;`.



Comment at: docs/clang-tidy/checks/readability-isolate-declaration.rst:23
+
+The check does exclude places where it is necessary or commong to declare
+multiple variables in one statement and there is no other way supported in the

does exclude -> excludes
commong -> common



Comment at: docs/clang-tidy/checks/readability-isolate-declaration.rst:31
+  // before the loop will increase the scope of the variable 'Begin' and 'End'
+  // which is undesired in it's own.
+  for (int Begin = 0, End = 100; Begin < End; ++Begin);

undesired in it's own -> undesirable



Comment at: docs/clang-tidy/checks/readability-isolate-declaration.rst:45
+
+Global variables and member variables are excluded.
+

Why are global variables excluded from this check? It seems like they should 
have the exact same behavior as local variables in terms of the transformation, 
no?



[PATCH] D51949: [clang-tidy] new check 'readability-isolate-declaration'

2018-10-26 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: test/clang-tidy/readability-isolate-declaration.cpp:233
+  int member1, member2;
+  // TODO: Transform FieldDecl's as well
+};

Comment is misleading. Transform == fixit, at least for me.
But they are not even diagnosed.
So maybe
```
// TODO: Handle FieldDecl's as well
```


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51949



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


[PATCH] D53457: clang-cl: Add "/clang:" pass-through arg support.

2018-10-26 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

  One note about flag ordering: the /clang: flags are concatenated to the end of
  the argument list, so in cases where the last flag wins, the /clang: flags
  will be chosen regardless of their order relative to other flags on the driver
  command line.

This seems a little unfortunate. I wonder if it would be possible to not have 
this restriction, i.e. to process these in-line with the rest of the flags?

One way to achieve this would be to change Driver::ParseArgStrings() to handle 
the "/clang:" arguments. After doing the regular option parsing, it would look 
for "/clang:" options and substitute them for the underlying option. This has 
the downside of adding some option-specific logic to ParseArgStrings, but on 
the other hand it's less intrusive than passing around the IsCLMode bool. Do 
you think something like this could work?




Comment at: docs/UsersManual.rst:3100
+
+The /clang: Option
+

Thanks for thinking about the docs!

I think we should put this above the /fallback section, since this new flag is 
more important and /fallback shouldn't be used much these days.



Comment at: include/clang/Driver/CLCompatOptions.td:324
   HelpText<"Volatile loads and stores have acquire and release semantics">;
+def _SLASH_clang : CLJoinedOrSeparate<"clang:">,
+  HelpText<"Pass  to the clang driver">, MetaVarName<"">;

Do we really want the "OrSeparate" part of this? Is there any downside of 
limiting it to "/clang:-foo" rather than also allowing "/clang: -foo"?


https://reviews.llvm.org/D53457



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


[PATCH] D53025: [clang-tidy] implement new check for const return types.

2018-10-26 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added inline comments.



Comment at: clang-tidy/readability/ConstValueReturnCheck.cpp:107
+diag(Def->getInnerLocStart(), "return type %0 is 'const'-qualified "
+  "hindering compiler optimizations")
+<< Def->getReturnType();

aaron.ballman wrote:
> It seems strange to me that this is in the readability module but the 
> diagnostic here is about compiler optimizations. Should this be in the 
> performance module instead? Or should this diagnostic be reworded about the 
> readability concerns?
Good point. The readability angle is that the const clutters the code to no 
benefit.  That is, even if it was performance neutral, I'd still want to 
discourage this practice.  But, it does seem like the primary impact is 
performance. 

I'm fine either way -- moving it to performance or emphasizing the clutter of 
the unhelpful "const".  I'm inclined to moving it, but don't have good sense of 
how strict these hierarchies are. What do you think?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53025



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


[PATCH] D53025: [clang-tidy] implement new check for const return types.

2018-10-26 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 171293.
ymandel marked 4 inline comments as done.
ymandel added a comment.

Reword comment on the check, for clarity.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53025

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ConstValueReturnCheck.cpp
  clang-tidy/readability/ConstValueReturnCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/utils/LexerUtils.cpp
  clang-tidy/utils/LexerUtils.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-const-value-return.rst
  test/clang-tidy/readability-const-value-return.cpp

Index: test/clang-tidy/readability-const-value-return.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-const-value-return.cpp
@@ -0,0 +1,227 @@
+// RUN: %check_clang_tidy %s readability-const-value-return %t -- -- -isystem
+
+//  p# = positive test
+//  n# = negative test
+
+#include 
+
+const int p1() {
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const int' is 'const'-qualified hindering compiler optimizations
+// CHECK-FIXES: int p1() {
+  return 1;
+}
+
+const int p15();
+// CHECK-FIXES: int p15();
+
+template 
+const int p31(T v) { return 2; }
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const int' is 'const'-qu
+// CHECK-FIXES: int p31(T v) { return 2; }
+
+// We detect const-ness even without instantiating T.
+template 
+const T p32(T t) { return t; }
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const T' is 'const'-qual
+// CHECK-FIXES: T p32(T t) { return t; }
+
+// However, if the return type is itself a template instantiation, Clang does
+// not consider it const-qualified without knowing `T`.
+template 
+typename std::add_const::type n15(T v) { return v; }
+
+template 
+class Klazz {
+public:
+  Klazz(A) {}
+};
+
+class Clazz {
+ public:
+  Clazz *const p2() {
+// CHECK-MESSAGES: [[@LINE-1]]:3: warning: return type 'Clazz *const' is 'co
+// CHECK-FIXES: Clazz *p2() {
+return this;
+  }
+
+  Clazz *const p3();
+  // CHECK-FIXES: Clazz *p3();
+
+  const int p4() const {
+// CHECK-MESSAGES: [[@LINE-1]]:3: warning: return type 'const int' is 'const
+// CHECK-FIXES: int p4() const {
+return 4;
+  }
+
+  const Klazz* const p5() const;
+  // CHECK-FIXES: const Klazz* p5() const;
+
+  const Clazz operator++(int x) {  //  p12
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: return type 'const Clazz' is 'const
+  // CHECK-FIXES: Clazz operator++(int x) {
+  }
+
+  struct Strukt {
+int i;
+  };
+
+  const Strukt p6() {}
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: return type 'const Clazz::Strukt' i
+  // CHECK-FIXES: Strukt p6() {}
+
+  // No warning is emitted here, because this is only the declaration.  The
+  // warning will be associated with the definition, below.
+  const Strukt* const p7();
+  // CHECK-FIXES: const Strukt* p7();
+
+  // const-qualifier is the first `const` token, but not the first token.
+  static const int p8() {}
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: return type 'const int' is 'const'-
+  // CHECK-FIXES: static int p8() {}
+
+  static const Strukt p9() {}
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: return type 'const Clazz::Strukt' i
+  // CHECK-FIXES: static Strukt p9() {}
+
+  int n0() const { return 0; }
+  const Klazz& n11(const Klazz) const;
+};
+
+Clazz *const Clazz::p3() {
+  // CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'Clazz *const' is 'cons
+  // CHECK-FIXES: Clazz *Clazz::p3() {
+  return this;
+}
+
+const Klazz* const Clazz::p5() const {}
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const Klazz *
+// CHECK-FIXES: const Klazz* Clazz::p5() const {}
+
+const Clazz::Strukt* const Clazz::p7() {}
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const Clazz::Strukt *con
+// CHECK-FIXES: const Clazz::Strukt* Clazz::p7() {}
+
+Clazz *const p10();
+// CHECK-FIXES: Clazz *p10();
+
+Clazz *const p10() {
+  // CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'Clazz *const' is 'cons
+  // CHECK-FIXES: Clazz *p10() {
+  return new Clazz();
+}
+
+const Clazz bar;
+const Clazz *const p11() {
+  // CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const Clazz *const' is
+  // CHECK-FIXES: const Clazz *p11() {
+  return 
+}
+
+const Klazz p12() {}
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const Klazz'
+// CHECK-FIXES: Klazz p12() {}
+
+const Klazz* const p13() {}
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const Klazz *
+// CHECK-FIXES: const Klazz* p13() {}
+
+// re-declaration of p15.
+const int p15();
+// CHECK-FIXES: int p15();
+
+const int p15() {
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning:
+// CHECK-FIXES: int p15() {
+  return 0;
+}
+
+// Exercise the lexer.
+
+const /* comment */ /* another comment*/ int p16() { return 0; }
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning:
+// CHECK-FIXES: /* comment */ /* another comment*/ int 

[PATCH] D53717: [AST] Only store the needed data in ForStmt.

2018-10-26 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a comment.

In https://reviews.llvm.org/D53717#1276388, @rsmith wrote:

> In https://reviews.llvm.org/D53717#1276245, @rsmith wrote:
>
> > Do you have evidence that this complexity is worthwhile? (I wouldn't 
> > imagine we have very many `ForStmt`s per translation unit, so saving 16 
> > bytes for each of them seems unlikely to matter.)
>
>
> Strikes me that some data would be useful here, to help prioritize. Here's a 
> histogram of occurrence counts for a libc++ module:
>
>   Count# Bits b/Rec   % Abv  Record Kind
>   43731   5471391 125.1   87.46  EXPR_DECL_REF
>   35751822273  23.0  DECL_OMP_DECLARE_REDUCTION
>   29734   3431612 115.4  TYPE_TEMPLATE_SPECIALIZATION
>   25750   7472591 290.2   55.89  DECL_PARM_VAR
>   14986651081  43.4   98.81  EXPR_IMPLICIT_CAST
>   14847   1620549 109.1  EXPR_CALL
>   13153   1968371 149.7  TYPE_FUNCTION_PROTO
>   12605   3797017 301.2  100.00  DECL_CONTEXT_LEXICAL
>   12515715141  57.1  TYPE_TEMPLATE_TYPE_PARM
>   12480   2608644 209.0  DECL_TEMPLATE_TYPE_PARM
>   10571   1200811 113.6  EXPR_BINARY_OPERATOR
>   10300955610  92.8  STMT_COMPOUND
>   10254   9421030 918.8   17.66  DECL_CXX_METHOD
>   10220   2252926 220.4  EXPR_CXX_DEPENDENT_SCOPE_MEMBER
>   10083231909  23.0  STMT_NULL_PTR
>9731   5196865 534.1  EXPR_CXX_UNRESOLVED_LOOKUP
>8015580911  72.5   87.16  EXPR_INTEGER_LITERAL
>7935   3298497 415.7  EXPR_CXX_DEPENDENT_SCOPE_DECL_REF
>7934   3379054 425.9  DECL_CXX_RECORD
>7790946360 121.5  EXPR_CXX_THIS
>7508350806  46.7  LOCAL_REDECLARATIONS
>7155   1239819 173.3  EXPR_MEMBER
>6754   1264508 187.2  EXPR_CXX_OPERATOR_CALL
>6607   5819360 880.8  100.00  DECL_CONTEXT_VISIBLE
>6461736861 114.0  EXPR_UNARY_OPERATOR
>6117284391  46.5  TYPE_LVALUE_REFERENCE
>6081372753  61.3  STMT_RETURN
>6066   1964810 323.9   99.64  DECL_TYPEDEF
>5659249455  44.1  TYPE_RECORD
>5252   4884856 930.1  DECL_CLASS_TEMPLATE_SPECIALIZATION
>5196313722  60.4  TYPE_SUBST_TEMPLATE_TYPE_PARM
>5189532009 102.5  TYPE_DEPENDENT_NAME
>5083   2145083 422.01.65  DECL_VAR
>4886296440  60.7  TYPE_TYPEDEF
>4340473950 109.2  STMT_DECL
>4314   4078644 945.4  DECL_FUNCTION
>4150   1436618 346.2  DECL_FUNCTION_TEMPLATE
>3686343246  93.1  TYPE_ELABORATED
>3629144649  39.9  TYPE_POINTER
>3435   2907387 846.4  DECL_CXX_CONSTRUCTOR
>3341896701 268.4  DECL_CXX_BASE_SPECIFIERS
>2847376713 132.3  EXPR_PAREN
>2684271156 101.0  EXPR_CXX_BOOL_LITERAL
>2651208771  78.8  STMT_IF
>2053550511 268.1  EXPR_CXX_UNRESOLVED_CONSTRUCT
>1938268044 138.3  DECL_ACCESS_SPEC
>1725472401 273.9  DECL_NON_TYPE_TEMPLATE_PARM
>1647224673 136.4  EXPR_PAREN_LIST
>1610 64624  40.1  TYPE_RVALUE_REFERENCE
>1542380997 247.1   48.57  DECL_FIELD
>1446392676 271.6  EXPR_CXX_UNRESOLVED_MEMBER
>1411283553 201.0  DECL_USING_SHADOW
>1411 87833  62.2  TYPE_INJECTED_CLASS_NAME
>1339164195 122.6  EXPR_SUBST_NON_TYPE_TEMPLATE_PARM
>1226311278 253.9  DECL_CXX_CTOR_INITIALIZERS
>1110215604 194.2  EXPR_SIZEOF_PACK
>1054476456 452.0  DECL_CLASS_TEMPLATE
> 987112161 113.6  EXPR_CXX_MEMBER_CALL
> 943195005 206.8  EXPR_CXX_CONSTRUCT
> 941271069 288.1  EXPR_CXX_STATIC_CAST
> 879171231 194.8  EXPR_TYPE_TRAIT
> 771 40707  52.8  TYPE_PACK_EXPANSION
> 727106103 145.9  DECL_IMPORT
> 696146286 210.2  DECL_FRIEND
> 678136788 201.8  EXPR_CSTYLE_CAST
> 664 70292 105.9  EXPR_ARRAY_SUBSCRIPT
> 628 67550 107.6  EXPR_PACK_EXPANSION
> 601 84473 140.6  EXPR_COMPOUND_ASSIGN_OPERATOR
> 564 71760 127.2  STMT_FOR
> 557 57643 103.5  EXPR_CXX_NULL_PTR_LITERAL
> 545350959 644.0  DECL_CXX_DESTRUCTOR
> 5238679471659.6  
> DECL_CLASS_TEMPLATE_PARTIAL_SPECIALIZATION
> 495120219 242.9  DECL_USING
> 476 87196 183.2  EXPR_SIZEOF_ALIGN_OF
> 447292917 655.3  EXPR_STRING_LITERAL
> 434 32634  75.2  

[PATCH] D53621: Support for groups of attributes in #pragma clang attribute

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

LGTM aside from some small nits.




Comment at: clang/docs/LanguageExtensions.rst:2666
 
-  #pragma clang attribute push(__attribute__((annotate("custom"))), apply_to = 
function)
+  #pragma clang attribute push (__attribute__((annotate("custom"))), apply_to 
= function)
 

The whitespace changes here are not needed as part of this patch, right? (It's 
just changing the style of the docs?)



Comment at: clang/lib/Parse/ParsePragma.cpp:3149
   else {
-PP.Diag(Tok.getLocation(), diag::err_pragma_attribute_invalid_argument)
-<< PP.getSpelling(Tok);
-return;
+const auto *II = Tok.getIdentifierInfo();
+if (II->isStr("push"))

I'd prefer dropping the `auto` here.


https://reviews.llvm.org/D53621



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


[PATCH] D53751: [ASTImporter] Added Import functions for transition to new API.

2018-10-26 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 171292.
balazske added a comment.

- Added missing Import_New with Selector and DeclarationName.


Repository:
  rC Clang

https://reviews.llvm.org/D53751

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

Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -7656,6 +7656,12 @@
 
 ASTImporter::~ASTImporter() = default;
 
+Expected ASTImporter::Import_New(QualType FromT) {
+  QualType ToT = Import(FromT);
+  if (ToT.isNull() && !FromT.isNull())
+return make_error();
+  return ToT;
+}
 QualType ASTImporter::Import(QualType FromT) {
   if (FromT.isNull())
 return {};
@@ -7682,6 +7688,12 @@
   return ToContext.getQualifiedType(*ToTOrErr, FromT.getLocalQualifiers());
 }
 
+Expected ASTImporter::Import_New(TypeSourceInfo *FromTSI) {
+  TypeSourceInfo *ToTSI = Import(FromTSI);
+  if (!ToTSI && FromTSI)
+return llvm::make_error();
+  return ToTSI;
+}
 TypeSourceInfo *ASTImporter::Import(TypeSourceInfo *FromTSI) {
   if (!FromTSI)
 return FromTSI;
@@ -7696,8 +7708,12 @@
   T, Import(FromTSI->getTypeLoc().getBeginLoc()));
 }
 
+Expected ASTImporter::Import_New(const Attr *FromAttr) {
+  return Import(FromAttr);
+}
 Attr *ASTImporter::Import(const Attr *FromAttr) {
   Attr *ToAttr = FromAttr->clone(ToContext);
+  // NOTE: Import of SourceRange may fail.
   ToAttr->setRange(Import(FromAttr->getRange()));
   return ToAttr;
 }
@@ -7715,6 +7731,12 @@
   }
 }
 
+Expected ASTImporter::Import_New(Decl *FromD) {
+  Decl *ToD = Import(FromD);
+  if (!ToD && FromD)
+return llvm::make_error();
+  return ToD;
+}
 Decl *ASTImporter::Import(Decl *FromD) {
   if (!FromD)
 return nullptr;
@@ -7803,13 +7825,25 @@
   return ToDC;
 }
 
+Expected ASTImporter::Import_New(Expr *FromE) {
+  Expr *ToE = Import(FromE);
+  if (!ToE && FromE)
+return llvm::make_error();
+  return ToE;
+}
 Expr *ASTImporter::Import(Expr *FromE) {
   if (!FromE)
 return nullptr;
 
   return cast_or_null(Import(cast(FromE)));
 }
 
+Expected ASTImporter::Import_New(Stmt *FromS) {
+  Stmt *ToS = Import(FromS);
+  if (!ToS && FromS)
+return llvm::make_error();
+  return ToS;
+}
 Stmt *ASTImporter::Import(Stmt *FromS) {
   if (!FromS)
 return nullptr;
@@ -7845,6 +7879,12 @@
   return *ToSOrErr;
 }
 
+Expected ASTImporter::Import_New(NestedNameSpecifier *FromNNS) {
+  NestedNameSpecifier *ToNNS = Import(FromNNS);
+  if (!ToNNS && FromNNS)
+return llvm::make_error();
+  return ToNNS;
+}
 NestedNameSpecifier *ASTImporter::Import(NestedNameSpecifier *FromNNS) {
   if (!FromNNS)
 return nullptr;
@@ -7898,6 +7938,10 @@
   llvm_unreachable("Invalid nested name specifier kind");
 }
 
+Expected ASTImporter::Import_New(NestedNameSpecifierLoc FromNNS) {
+  NestedNameSpecifierLoc ToNNS = Import(FromNNS);
+  return ToNNS;
+}
 NestedNameSpecifierLoc ASTImporter::Import(NestedNameSpecifierLoc FromNNS) {
   // Copied from NestedNameSpecifier mostly.
   SmallVector NestedNames;
@@ -7969,6 +8013,12 @@
   return Builder.getWithLocInContext(getToContext());
 }
 
+Expected ASTImporter::Import_New(TemplateName From) {
+  TemplateName To = Import(From);
+  if (To.isNull() && !From.isNull())
+return llvm::make_error();
+  return To;
+}
 TemplateName ASTImporter::Import(TemplateName From) {
   switch (From.getKind()) {
   case TemplateName::Template:
@@ -8059,6 +8109,12 @@
   llvm_unreachable("Invalid template name kind");
 }
 
+Expected ASTImporter::Import_New(SourceLocation FromLoc) {
+  SourceLocation ToLoc = Import(FromLoc);
+  if (ToLoc.isInvalid() && !FromLoc.isInvalid())
+return llvm::make_error();
+  return ToLoc;
+}
 SourceLocation ASTImporter::Import(SourceLocation FromLoc) {
   if (FromLoc.isInvalid())
 return {};
@@ -8073,10 +8129,20 @@
   return ToSM.getComposedLoc(ToFileID, Decomposed.second);
 }
 
+Expected ASTImporter::Import_New(SourceRange FromRange) {
+  SourceRange ToRange = Import(FromRange);
+  return ToRange;
+}
 SourceRange ASTImporter::Import(SourceRange FromRange) {
   return SourceRange(Import(FromRange.getBegin()), Import(FromRange.getEnd()));
 }
 
+Expected ASTImporter::Import_New(FileID FromID) {
+  FileID ToID = Import(FromID);
+  if (ToID.isInvalid() && FromID.isValid())
+return llvm::make_error();
+  return ToID;
+}
 FileID ASTImporter::Import(FileID FromID) {
   llvm::DenseMap::iterator Pos = ImportedFileIDs.find(FromID);
   if (Pos != ImportedFileIDs.end())
@@ -8134,6 +8200,12 @@
   return ToID;
 }
 
+Expected ASTImporter::Import_New(CXXCtorInitializer *From) {
+  CXXCtorInitializer *To = Import(From);
+  if (!To && From)
+return llvm::make_error();
+  return To;
+}
 CXXCtorInitializer *ASTImporter::Import(CXXCtorInitializer *From) {
   Expr *ToExpr = Import(From->getInit());
   if (!ToExpr && From->getInit())
@@ -8179,6 +8251,12 @@
   }
 }
 
+Expected ASTImporter::Import_New(const CXXBaseSpecifier *From) {
+  CXXBaseSpecifier 

[PATCH] D53755: [ASTImporter] Remove import of definition from GetAlreadyImportedOrNull

2018-10-26 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added inline comments.



Comment at: lib/AST/ASTImporter.cpp:7716
   }
 }
 

This can be simplified by removing brace characters and removing `ToD`.


Repository:
  rC Clang

https://reviews.llvm.org/D53755



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


[PATCH] D52670: [clang-tidy] Add new 'readability-uppercase-literal-suffix' check (CERT DCL16-C, MISRA C:2012, 7.3, MISRA C++:2008, 2-13-4)

2018-10-26 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL345381: [clang-tidy] Re-commit: Add new 
readability-uppercase-literal-suffix check… (authored by lebedevri, 
committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D52670?vs=171279=171290#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D52670

Files:
  clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp
  clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp
  clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tools-extra/trunk/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
  clang-tools-extra/trunk/clang-tidy/readability/UppercaseLiteralSuffixCheck.h
  clang-tools-extra/trunk/clang-tidy/utils/ASTUtils.cpp
  clang-tools-extra/trunk/clang-tidy/utils/ASTUtils.h
  clang-tools-extra/trunk/docs/ReleaseNotes.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl16-c.rst
  
clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-uppercase-literal-suffix.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-uppercase-literal-suffix.rst
  
clang-tools-extra/trunk/test/clang-tidy/cert-uppercase-literal-suffix-integer.cpp
  
clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-floating-point-opencl-half.cpp
  
clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-floating-point.cpp
  
clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-hexadecimal-floating-point.cpp
  
clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-integer-custom-list.cpp
  
clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-integer-macro.cpp
  
clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-integer-ms.cpp
  
clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-integer.cpp
  clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix.h

Index: clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp
===
--- clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp
+++ clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp
@@ -16,6 +16,7 @@
 #include "../misc/StaticAssertCheck.h"
 #include "../misc/ThrowByValueCatchByReferenceCheck.h"
 #include "../performance/MoveConstructorInitCheck.h"
+#include "../readability/UppercaseLiteralSuffixCheck.h"
 #include "CommandProcessorCheck.h"
 #include "DontModifyStdNamespaceCheck.h"
 #include "FloatLoopCounter.h"
@@ -65,6 +66,8 @@
 // C checkers
 // DCL
 CheckFactories.registerCheck("cert-dcl03-c");
+CheckFactories.registerCheck(
+"cert-dcl16-c");
 // ENV
 CheckFactories.registerCheck("cert-env33-c");
 // FLP
@@ -78,6 +81,13 @@
 CheckFactories.registerCheck(
 "cert-msc32-c");
   }
+
+  ClangTidyOptions getModuleOptions() override {
+ClangTidyOptions Options;
+ClangTidyOptions::OptionMap  = Options.CheckOptions;
+Opts["cert-dcl16-c.NewSuffixes"] = "L;LL;LU;LLU";
+return Options;
+  }
 };
 
 } // namespace cert
Index: clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt
===
--- clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt
+++ clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt
@@ -24,5 +24,6 @@
   clangTidyGoogleModule
   clangTidyMiscModule
   clangTidyPerformanceModule
+  clangTidyReadabilityModule
   clangTidyUtils
   )
Index: clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp
===
--- clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp
+++ clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp
@@ -35,6 +35,7 @@
 #include "../readability/BracesAroundStatementsCheck.h"
 #include "../readability/FunctionSizeCheck.h"
 #include "../readability/IdentifierNamingCheck.h"
+#include "../readability/UppercaseLiteralSuffixCheck.h"
 #include "ExceptionBaseclassCheck.h"
 #include "MultiwayPathsCoveredCheck.h"
 #include "NoAssemblerCheck.h"
@@ -100,6 +101,8 @@
 "hicpp-use-nullptr");
 CheckFactories.registerCheck(
 "hicpp-use-override");
+CheckFactories.registerCheck(
+"hicpp-uppercase-literal-suffix");
 CheckFactories.registerCheck(
 "hicpp-vararg");
   }
Index: clang-tools-extra/trunk/clang-tidy/utils/ASTUtils.h
===
--- clang-tools-extra/trunk/clang-tidy/utils/ASTUtils.h
+++ clang-tools-extra/trunk/clang-tidy/utils/ASTUtils.h
@@ -27,6 +27,18 @@
 bool exprHasBitFlagWithSpelling(const Expr *Flags, const 

[PATCH] D53025: [clang-tidy] implement new check for const return types.

2018-10-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/readability/ConstValueReturnCheck.cpp:107
+diag(Def->getInnerLocStart(), "return type %0 is 'const'-qualified "
+  "hindering compiler optimizations")
+<< Def->getReturnType();

It seems strange to me that this is in the readability module but the 
diagnostic here is about compiler optimizations. Should this be in the 
performance module instead? Or should this diagnostic be reworded about the 
readability concerns?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53025



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


[clang-tools-extra] r345381 - [clang-tidy] Re-commit: Add new 'readability-uppercase-literal-suffix' check (CERT DCL16-C, MISRA C:2012, 7.3, MISRA C++:2008, 2-13-4)

2018-10-26 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Fri Oct 26 06:09:27 2018
New Revision: 345381

URL: http://llvm.org/viewvc/llvm-project?rev=345381=rev
Log:
[clang-tidy] Re-commit: Add new 'readability-uppercase-literal-suffix' check 
(CERT DCL16-C, MISRA C:2012, 7.3, MISRA C++:2008, 2-13-4)

Summary:
Detects when the integral literal or floating point (decimal or hexadecimal)
literal has non-uppercase suffix, and suggests to make the suffix uppercase,
with fix-it.

All valid combinations of suffixes are supported.

```
  auto x = 1;  // OK, no suffix.

  auto x = 1u; // warning: integer literal suffix 'u' is not upper-case

  auto x = 1U; // OK, suffix is uppercase.

  ...
```

This is a re-commit, the original was reverted by me in
rL345305 due to discovered bugs. (implicit code, template instantiation)
Tests were added, and the bugs were fixed.
I'm unable to find any further bugs, hopefully there aren't any..

References:
* [[ https://wiki.sei.cmu.edu/confluence/pages/viewpage.action?pageId=87152241 
| CERT DCL16-C ]]
* MISRA C:2012, 7.3 - The lowercase character "l" shall not be used in a 
literal suffix
* MISRA C++:2008, 2-13-4 - Literal suffixes shall be upper case

Reviewers: JonasToth, aaron.ballman, alexfh, hokein, xazax.hun

Reviewed By: aaron.ballman

Subscribers: Eugene.Zelenko, mgorny, rnkovacs, cfe-commits

Tags: #clang-tools-extra

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

Added:

clang-tools-extra/trunk/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/UppercaseLiteralSuffixCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/cert-dcl16-c.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-uppercase-literal-suffix.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/readability-uppercase-literal-suffix.rst

clang-tools-extra/trunk/test/clang-tidy/cert-uppercase-literal-suffix-integer.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-floating-point-opencl-half.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-floating-point.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-hexadecimal-floating-point.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-integer-custom-list.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-integer-macro.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-integer-ms.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-integer.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix.h
Modified:
clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/utils/ASTUtils.cpp
clang-tools-extra/trunk/clang-tidy/utils/ASTUtils.h
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp?rev=345381=345380=345381=diff
==
--- clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/cert/CERTTidyModule.cpp Fri Oct 26 
06:09:27 2018
@@ -16,6 +16,7 @@
 #include "../misc/StaticAssertCheck.h"
 #include "../misc/ThrowByValueCatchByReferenceCheck.h"
 #include "../performance/MoveConstructorInitCheck.h"
+#include "../readability/UppercaseLiteralSuffixCheck.h"
 #include "CommandProcessorCheck.h"
 #include "DontModifyStdNamespaceCheck.h"
 #include "FloatLoopCounter.h"
@@ -65,6 +66,8 @@ public:
 // C checkers
 // DCL
 CheckFactories.registerCheck("cert-dcl03-c");
+CheckFactories.registerCheck(
+"cert-dcl16-c");
 // ENV
 CheckFactories.registerCheck("cert-env33-c");
 // FLP
@@ -78,6 +81,13 @@ public:
 CheckFactories.registerCheck(
 "cert-msc32-c");
   }
+
+  ClangTidyOptions getModuleOptions() override {
+ClangTidyOptions Options;
+ClangTidyOptions::OptionMap  = Options.CheckOptions;
+Opts["cert-dcl16-c.NewSuffixes"] = "L;LL;LU;LLU";
+return Options;
+  }
 };
 
 } // namespace cert

Modified: clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/CMakeLists.txt?rev=345381=345380=345381=diff
==
--- 

Re: r345330 - Add MS ABI mangling for operator<=>.

2018-10-26 Thread Hans Wennborg via cfe-commits
It seems the generated MS mangling differs between 32- and 64-bit, and
the test expects the latter.

Let's revert in the meantime.. r345380


On Fri, Oct 26, 2018 at 1:10 PM, Peter Smith via cfe-commits
 wrote:
> This commit, specifically the changes made to
> CodeGenCXX/cxx2a-three-way-comparison.cpp, are failing on all the Arm
> and AArch64 builders that run check-clang and some of the other
> non-X86 builders as well like S390 and PPC.
>
> It seems to be the // RUN: not %clang_cc1 -std=c++2a -emit-llvm %s -o
> - -triple %ms_abi_triple 2>&1 | FileCheck %s --check-prefix=MSABI
> that is failing. I originally thought that this was due to our
> builders not having the X86 target configured but it seems to be
> reproducible on an Arm v7 machine (Cortex-A72) with the X86 backend
> included. The triple expands to -triple i686-pc-windows-msvc
>
> The failure appears to be common across all builders:
> /home/buildbots/ppc64le-clang-test/clang-ppc64le/llvm/tools/clang/test/CodeGenCXX/cxx2a-three-way-comparison.cpp:11:11:
> error: MSABI: expected string not found in input
> // MSABI: define {{.*}}@"??__MA@@QEAAXH@Z"(
>   ^
> :1:1: note: scanning from here
> ; ModuleID = 
> '/home/buildbots/ppc64le-clang-test/clang-ppc64le/llvm/tools/clang/test/CodeGenCXX/cxx2a-three-way-comparison.cpp'
> ^
> :9:23: note: possible intended match here
> define dso_local x86_thiscallcc void @"??__MA@@QAEXH@Z"(%struct.A*
> %this, i32) #0 align 2 {
>
> Could you take a look?
>
> Thanks in advance
>
> Peter
>
> Links to builders:
> http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick
> http://lab.llvm.org:8011/builders/clang-cmake-armv7-quick
> http://lab.llvm.org:8011/builders/clang-s390x-linux
> http://lab.llvm.org:8011/builders/clang-ppc64le-linux
> On Fri, 26 Oct 2018 at 00:23, Richard Smith via cfe-commits
>  wrote:
>>
>> I've already pointed Zach at this and I think he's going to handle it.
>>
>> On Thu, 25 Oct 2018 at 16:00, Nico Weber via cfe-commits 
>>  wrote:
>>>
>>> Could you update the demangler too?
>>>
>>> On Thu, Oct 25, 2018 at 6:53 PM Richard Smith via cfe-commits 
>>>  wrote:

 Author: rsmith
 Date: Thu Oct 25 15:51:16 2018
 New Revision: 345330

 URL: http://llvm.org/viewvc/llvm-project?rev=345330=rev
 Log:
 Add MS ABI mangling for operator<=>.

 Thanks to Cameron DaCamara at Microsoft for letting us know what their
 chosen mangling is here!

 Added:
 cfe/trunk/test/CodeGenCXX/mangle-ms-cxx2a.cpp
 Modified:
 cfe/trunk/lib/AST/MicrosoftMangle.cpp
 cfe/trunk/test/CodeGenCXX/cxx2a-three-way-comparison.cpp

 Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=345330=345329=345330=diff
 ==
 --- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
 +++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Thu Oct 25 15:51:16 2018
 @@ -1240,15 +1240,8 @@ void MicrosoftCXXNameMangler::mangleOper
case OO_Array_Delete: Out << "?_V"; break;
//  ::= ?__L # co_await
case OO_Coawait: Out << "?__L"; break;
 -
 -  case OO_Spaceship: {
 -// FIXME: Once MS picks a mangling, use it.
 -DiagnosticsEngine  = Context.getDiags();
 -unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
 -  "cannot mangle this three-way comparison operator yet");
 -Diags.Report(Loc, DiagID);
 -break;
 -  }
 +  //  ::= ?__M # <=>
 +  case OO_Spaceship: Out << "?__M"; break;

case OO_Conditional: {
  DiagnosticsEngine  = Context.getDiags();

 Modified: cfe/trunk/test/CodeGenCXX/cxx2a-three-way-comparison.cpp
 URL: 
 http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/cxx2a-three-way-comparison.cpp?rev=345330=345329=345330=diff
 ==
 --- cfe/trunk/test/CodeGenCXX/cxx2a-three-way-comparison.cpp (original)
 +++ cfe/trunk/test/CodeGenCXX/cxx2a-three-way-comparison.cpp Thu Oct 25 
 15:51:16 2018
 @@ -1,24 +1,28 @@
 -// RUN: %clang_cc1 -std=c++2a -emit-llvm %s -o - -triple 
 %itanium_abi_triple | FileCheck %s --check-prefix=ITANIUM
 -// RUN: not %clang_cc1 -std=c++2a -emit-llvm %s -o - -triple 
 %ms_abi_triple 2>&1 | FileCheck %s --check-prefix=MSABI
 +// RUN: %clang_cc1 -std=c++2a -emit-llvm %s -o - -triple 
 %itanium_abi_triple | FileCheck %s --check-prefixes=CHECK,ITANIUM
 +// RUN: %clang_cc1 -std=c++2a -emit-llvm %s -o - -triple %ms_abi_triple | 
 FileCheck %s --check-prefixes=CHECK,MSABI
  // RUN: not %clang_cc1 -std=c++2a -emit-llvm %s -o - -triple 
 %itanium_abi_triple -DBUILTIN 2>&1 | FileCheck %s --check-prefix=BUILTIN
 -// MSABI: cannot mangle this three-way comparison operator yet
 +// RUN: not %clang_cc1 

[PATCH] D52670: [clang-tidy] Add new 'readability-uppercase-literal-suffix' check (CERT DCL16-C, MISRA C:2012, 7.3, MISRA C++:2008, 2-13-4)

2018-10-26 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Rerun on clang-tools-extra+lld+clang codebase, nothing broken.
I'm gonna reland.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52670



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


  1   2   >