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

2019-05-09 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

If you feel strong about it, I can add back `-compress-debug-sections=`, but it 
is not used by anyone.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61777



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


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

2019-05-09 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added a reviewer: compnerd.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

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


Repository:
  rC Clang

https://reviews.llvm.org/D61777

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

Index: test/Driver/compress.c
===
--- test/Driver/compress.c
+++ test/Driver/compress.c
@@ -16,19 +16,19 @@
 
 // RUN: %clang -### -fintegrated-as -gz -x assembler -c %s 2>&1 | FileCheck -check-prefix CHECK-OPT_GZ %s
 // RUN: %clang -### -fintegrated-as -gz -c %s 2>&1 | FileCheck -check-prefix CHECK-OPT_GZ %s
-// CHECK-OPT_GZ: "-compress-debug-sections"
+// CHECK-OPT_GZ: "--compress-debug-sections"
 
 // RUN: %clang -### -fintegrated-as -gz=none -x assembler -c %s 2>&1 | FileCheck -check-prefix CHECK-OPT_GZ_EQ_NONE %s
 // RUN: %clang -### -fintegrated-as -gz=none -c %s 2>&1 | FileCheck -check-prefix CHECK-OPT_GZ_EQ_NONE %s
-// CHECK-OPT_GZ_EQ_NONE: "-compress-debug-sections=none"
+// CHECK-OPT_GZ_EQ_NONE: "--compress-debug-sections=none"
 
 // RUN: %clang -### -fintegrated-as -gz=zlib -x assembler -c %s 2>&1 | FileCheck -check-prefix CHECK-OPT_GZ_EQ_ZLIB %s
 // RUN: %clang -### -fintegrated-as -gz=zlib -c %s 2>&1 | FileCheck -check-prefix CHECK-OPT_GZ_EQ_ZLIB %s
-// CHECK-OPT_GZ_EQ_ZLIB: "-compress-debug-sections=zlib"
+// CHECK-OPT_GZ_EQ_ZLIB: "--compress-debug-sections=zlib"
 
 // RUN: %clang -### -fintegrated-as -gz=zlib-gnu -x assembler -c %s 2>&1 | FileCheck -check-prefix CHECK-OPT_GZ_EQ_ZLIB_GNU %s
 // RUN: %clang -### -fintegrated-as -gz=zlib-gnu -c %s 2>&1 | FileCheck -check-prefix CHECK-OPT_GZ_EQ_ZLIB_GNU %s
-// CHECK-OPT_GZ_EQ_ZLIB_GNU: "-compress-debug-sections=zlib-gnu"
+// CHECK-OPT_GZ_EQ_ZLIB_GNU: "--compress-debug-sections=zlib-gnu"
 
 // RUN: %clang -### -fintegrated-as -gz=invalid -x assembler -c %s 2>&1 | FileCheck -check-prefix CHECK-OPT_GZ_EQ_INVALID %s
 // RUN: %clang -### -fintegrated-as -gz=invalid -c %s 2>&1 | FileCheck -check-prefix CHECK-OPT_GZ_EQ_INVALID %s
Index: test/Driver/compress-noias.c
===
--- test/Driver/compress-noias.c
+++ test/Driver/compress-noias.c
@@ -17,19 +17,19 @@
 
 // RUN: %clang -### -target i686-unknown-linux-gnu -fno-integrated-as -gz -x assembler -c %s 2>&1 | FileCheck -check-prefix CHECK-OPT_GZ %s
 // RUN: %clang -### -target i686-unknown-linux-gnu -fno-integrated-as -gz -c %s 2>&1 | FileCheck -check-prefix CHECK-OPT_GZ %s
-// CHECK-OPT_GZ: "-compress-debug-sections"
+// CHECK-OPT_GZ: "--compress-debug-sections"
 
 // RUN: %clang -### -target i686-unknown-linux-gnu -fno-integrated-as -gz=none -x assembler -c %s 2>&1 | FileCheck -check-prefix CHECK-OPT_GZ_EQ_NONE %s
 // RUN: %clang -### -target i686-unknown-linux-gnu -fno-integrated-as -gz=none -c %s 2>&1 | FileCheck -check-prefix CHECK-OPT_GZ_EQ_NONE %s
-// CHECK-OPT_GZ_EQ_NONE: "-compress-debug-sections=none"
+// CHECK-OPT_GZ_EQ_NONE: "--compress-debug-sections=none"
 
 // RUN: %clang -### -target i686-unknown-linux-gnu -fno-integrated-as -gz=zlib -x assembler -c %s 2>&1 | FileCheck -check-prefix CHECK-OPT_GZ_EQ_ZLIB %s
 // RUN: %clang -### -target i686-unknown-linux-gnu -fno-integrated-as -gz=zlib -c %s 2>&1 | FileCheck -check-prefix CHECK-OPT_GZ_EQ_ZLIB %s
-// CHECK-OPT_GZ_EQ_ZLIB: "-compress-debug-sections=zlib"
+// CHECK-OPT_GZ_EQ_ZLIB: "--compress-debug-sections=zlib"
 
 // RUN: %clang -### -target i686-unknown-linux-gnu -fno-integrated-as -gz=zlib-gnu -x assembler -c %s 2>&1 | FileCheck -check-prefix CHECK-OPT_GZ_EQ_ZLIB_GNU %s
 // RUN: %clang -### -target i686-unknown-linux-gnu -fno-integrated-as -gz=zlib-gnu -c %s 2>&1 | FileCheck -check-prefix CHECK-OPT_GZ_EQ_ZLIB_GNU %s
-// CHECK-OPT_GZ_EQ_ZLIB_GNU: "-compress-debug-sections=zlib-gnu"
+// CHECK-OPT_GZ_EQ_ZLIB_GNU: "--compress-debug-sections=zlib-gnu"
 
 // RUN: %clang -### -target i686-unknown-linux-gnu -fno-integrated-as -gz=invalid -x assembler -c %s 2>&1 | FileCheck -check-prefix CHECK-OPT_GZ_EQ_INVALID %s
 // RUN: %clang -### -target i686-unknown-linux-gnu -fno-integrated-as -gz=invalid -c %s 2>&1 | FileCheck -check-prefix CHECK-OPT_GZ_EQ_INVALID %s
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -627,14 +627,12 @@
 
   if (const Arg *A = Args.getLastArg(options::OPT_gz, options::OPT_gz_EQ)) {
 if (A->getOption().getID() == options::OPT_gz) {
-  CmdArgs.push_back("-compress-debug-sections");
+  CmdArgs.push_back("--compress-debug-sections");
 } else {
   StringRef Value = A->getValue();
-  if (Value == "none") {
-CmdArgs.push_back("-compress-debug-sections=none");
-  } else if (Value == "zlib" || Value == 

[PATCH] D60974: Clang IFSO driver action.

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



Comment at: llvm/lib/TextAPI/ELF/TBEHandler.cpp:137
 IO.mapRequired("Arch", (ELFArchMapper &)Stub.Arch);
+IO.mapOptional("Endian", Stub.Endian);
 IO.mapOptional("NeededLibs", Stub.NeededLibs);

@jakehehrlich Here, I've added an Endian field to tbe. I think I can just 
generate the tbe that llvm-elfabi consumes. The experimental yaml output is 
more for debugging. Tell me what you think.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60974



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


[PATCH] D60974: Clang IFSO driver action.

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

renaming things from "ifso" to "interface stubs"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60974

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

Index: llvm/lib/TextAPI/ELF/TBEHandler.cpp
===
--- llvm/lib/TextAPI/ELF/TBEHandler.cpp
+++ llvm/lib/TextAPI/ELF/TBEHandler.cpp
@@ -134,6 +134,7 @@
 IO.mapRequired("TbeVersion", Stub.TbeVersion);
 IO.mapOptional("SoName", Stub.SoName);
 IO.mapRequired("Arch", (ELFArchMapper &)Stub.Arch);
+IO.mapOptional("Endian", Stub.Endian);
 IO.mapOptional("NeededLibs", Stub.NeededLibs);
 IO.mapRequired("Symbols", Stub.Symbols);
   }
Index: llvm/include/llvm/TextAPI/ELF/ELFStub.h
===
--- llvm/include/llvm/TextAPI/ELF/ELFStub.h
+++ llvm/include/llvm/TextAPI/ELF/ELFStub.h
@@ -55,6 +55,7 @@
   VersionTuple TbeVersion;
   Optional SoName;
   ELFArch Arch;
+  Optional Endian;
   std::vector NeededLibs;
   std::set Symbols;
 
Index: clang/test/IFSO/foo.cpp
===
--- /dev/null
+++ clang/test/IFSO/foo.cpp
@@ -0,0 +1,57 @@
+// Using %clang instead of %clang_cc1 because of -fvisibility
+// RUN: %clang -target x86_64-linux-gnu -emit-interface-stubs -interface-stub-version=tapi-tbe -fvisibility=hidden %s -o - | FileCheck --check-prefix=CHECK-HIDDEN %s
+// RUN: %clang -target x86_64-linux-gnu -emit-interface-stubs -interface-stub-version=tapi-tbe %s -o - | FileCheck %s
+
+// CHECK-HIDDEN-NOT: _Z4fbarff
+// CHECK: _Z4fbarff
+
+
+
+
+// CHECK-HIDDEN-NOT: _Z3fooii
+// CHECK-NOT:_Z3fooii
+
+
+
+#include "foo-inline.h"
+
+__attribute__ ((visibility ("hidden"))) int foo(int a, int b) { return a + b; }
+__attribute__ ((visibility ("default"))) int foo_default_visi(int a, int b) { return a + b; }
+
+
+__attribute__ ((visibility ("default"))) int fvih_1(int a, int b) { return a + fvih(); }
+
+
+__attribute__((weak)) int someWeakFunc() { return 42; }
+
+int dataA = 34;
+
+namespace baz {
+  template 
+  T add(T a, T b) {
+return a + b;
+  }
+}
+
+namespace n {
+  template 
+  struct __attribute__((__visibility__("default"))) S {
+S() = default;
+~S() = default;
+int __attribute__((__visibility__(("default" func() const { return 32; }
+int __attribute__((__visibility__(("hidden" operator()() const { return 53; }
+  };
+}
+
+template  T neverUsed(T t) { return t + 2; }
+
+template<> int neverUsed(int t);
+
+void g() { n::S()(); }
+
+namespace qux {
+int bar(int a, int b) { return baz::add(a, b); }
+}
+
+float fbar(float a, float b) { return baz::add(a, b); }
+
Index: clang/test/IFSO/foo-inline.h
===
--- /dev/null
+++ clang/test/IFSO/foo-inline.h
@@ -0,0 +1,6 @@
+
+inline int fvih() {
+static int fortytwo = 42;
+  return fortytwo;
+}
+
Index: clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -64,6 +64,10 @@
   case GenerateHeaderModule:
 return llvm::make_unique();
   case GeneratePCH:return llvm::make_unique();
+  case GenerateInterfaceYAMLExpV1:
+return llvm::make_unique();
+  case GenerateInterfaceTBEExpV1:
+return llvm::make_unique();
   case InitOnly:   return llvm::make_unique();
   case ParseSyntaxOnly:return llvm::make_unique();
   case ModuleFileInfo: return llvm::make_unique();
Index: clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
===
--- /dev/null
+++ clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
@@ -0,0 +1,305 @@
+//===--- InterfaceStubFunctionsConsumer.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include 

[PATCH] D61667: Assume `__cxa_allocate_exception` returns an under-aligned memory on Darwin if the version of libc++abi isn't new enough to include the fix in r319123

2019-05-09 Thread Akira Hatanaka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC360404: Assume `__cxa_allocate_exception` returns an 
under-aligned memory on (authored by ahatanak, committed by ).

Repository:
  rC Clang

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

https://reviews.llvm.org/D61667

Files:
  include/clang/AST/ASTContext.h
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/TargetInfo.h
  lib/Basic/Targets/OSTargets.h
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/Sema/SemaExprCXX.cpp
  test/CodeGenCXX/eh.cpp
  test/SemaCXX/warn-overaligned-type-thrown.cpp

Index: include/clang/AST/ASTContext.h
===
--- include/clang/AST/ASTContext.h
+++ include/clang/AST/ASTContext.h
@@ -2166,6 +2166,13 @@
   /// pointers and large arrays get extra alignment.
   CharUnits getDeclAlign(const Decl *D, bool ForAlignof = false) const;
 
+  /// Return the alignment (in bytes) of the thrown exception object. This is
+  /// only meaningful for targets that allocate C++ exceptions in a system
+  /// runtime, such as those using the Itanium C++ ABI.
+  CharUnits getExnObjectAlignment() const {
+return toCharUnitsFromBits(Target->getExnObjectAlignment());
+  }
+
   /// Get or compute information about the layout of the specified
   /// record (struct/union/class) \p D, which indicates its size and field
   /// position information.
Index: include/clang/Basic/TargetInfo.h
===
--- include/clang/Basic/TargetInfo.h
+++ include/clang/Basic/TargetInfo.h
@@ -637,6 +637,21 @@
   /// types for the given target.
   unsigned getSimdDefaultAlign() const { return SimdDefaultAlign; }
 
+  /// Return the alignment (in bits) of the thrown exception object. This is
+  /// only meaningful for targets that allocate C++ exceptions in a system
+  /// runtime, such as those using the Itanium C++ ABI.
+  virtual unsigned getExnObjectAlignment() const {
+// Itanium says that an _Unwind_Exception has to be "double-word"
+// aligned (and thus the end of it is also so-aligned), meaning 16
+// bytes.  Of course, that was written for the actual Itanium,
+// which is a 64-bit platform.  Classically, the ABI doesn't really
+// specify the alignment on other platforms, but in practice
+// libUnwind declares the struct with __attribute__((aligned)), so
+// we assume that alignment here.  (It's generally 16 bytes, but
+// some targets overwrite it.)
+return getDefaultAlignForAttributeAligned();
+  }
+
   /// Return the size of intmax_t and uintmax_t for this target, in bits.
   unsigned getIntMaxTWidth() const {
 return getTypeWidth(IntMaxType);
Index: include/clang/Basic/DiagnosticGroups.td
===
--- include/clang/Basic/DiagnosticGroups.td
+++ include/clang/Basic/DiagnosticGroups.td
@@ -408,6 +408,7 @@
 def ObjCFlexibleArray : DiagGroup<"objc-flexible-array">;
 def ObjCBoxing : DiagGroup<"objc-boxing">;
 def OpenCLUnsupportedRGBA: DiagGroup<"opencl-unsupported-rgba">;
+def UnderalignedExceptionObject : DiagGroup<"underaligned-exception-object">;
 def DeprecatedObjCIsaUsage : DiagGroup<"deprecated-objc-isa-usage">;
 def ExplicitInitializeCall : DiagGroup<"explicit-initialize-call">;
 def Packed : DiagGroup<"packed">;
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -6576,6 +6576,12 @@
   "cannot throw object of incomplete type %0">;
 def err_throw_incomplete_ptr : Error<
   "cannot throw pointer to object of incomplete type %0">;
+def warn_throw_underaligned_obj : Warning<
+  "underaligned exception object thrown">,
+  InGroup;
+def note_throw_underaligned_obj : Note<
+  "required alignment of type %0 (%1 bytes) is larger than the supported "
+  "alignment of C++ exception objects on this target (%2 bytes)">;
 def err_return_in_constructor_handler : Error<
   "return in the catch of a function try block of a constructor is illegal">;
 def warn_cdtor_function_try_handler_mem_expr : Warning<
Index: test/SemaCXX/warn-overaligned-type-thrown.cpp
===
--- test/SemaCXX/warn-overaligned-type-thrown.cpp
+++ test/SemaCXX/warn-overaligned-type-thrown.cpp
@@ -0,0 +1,66 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.99 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions -DUNDERALIGNED %s
+// RUN: %clang_cc1 -triple arm64-apple-ios10 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions -DUNDERALIGNED %s
+// RUN: %clang_cc1 -triple arm64-apple-tvos10 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions -DUNDERALIGNED %s
+// RUN: %clang_cc1 -triple arm64-apple-watchos4 -verify -fsyntax-only 

r360404 - Assume `__cxa_allocate_exception` returns an under-aligned memory on

2019-05-09 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Thu May  9 19:16:37 2019
New Revision: 360404

URL: http://llvm.org/viewvc/llvm-project?rev=360404=rev
Log:
Assume `__cxa_allocate_exception` returns an under-aligned memory on
Darwin if the version of libc++abi isn't new enough to include the fix
in r319123

This patch resurrects r264998, which was committed to work around a bug
in libc++abi that was causing _cxa_allocate_exception to return a memory
that wasn't double-word aligned.

http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20160328/154332.html

In addition, this patch makes clang issue a warning if the type of the
thrown object requires an alignment that is larger than the minimum
guaranteed by the target C++ runtime.

rdar://problem/49864414

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

Added:
cfe/trunk/test/SemaCXX/warn-overaligned-type-thrown.cpp
Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/lib/Basic/Targets/OSTargets.h
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/test/CodeGenCXX/eh.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=360404=360403=360404=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Thu May  9 19:16:37 2019
@@ -2166,6 +2166,13 @@ public:
   /// pointers and large arrays get extra alignment.
   CharUnits getDeclAlign(const Decl *D, bool ForAlignof = false) const;
 
+  /// Return the alignment (in bytes) of the thrown exception object. This is
+  /// only meaningful for targets that allocate C++ exceptions in a system
+  /// runtime, such as those using the Itanium C++ ABI.
+  CharUnits getExnObjectAlignment() const {
+return toCharUnitsFromBits(Target->getExnObjectAlignment());
+  }
+
   /// Get or compute information about the layout of the specified
   /// record (struct/union/class) \p D, which indicates its size and field
   /// position information.

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=360404=360403=360404=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Thu May  9 19:16:37 2019
@@ -408,6 +408,7 @@ def ObjCMultipleMethodNames : DiagGroup<
 def ObjCFlexibleArray : DiagGroup<"objc-flexible-array">;
 def ObjCBoxing : DiagGroup<"objc-boxing">;
 def OpenCLUnsupportedRGBA: DiagGroup<"opencl-unsupported-rgba">;
+def UnderalignedExceptionObject : DiagGroup<"underaligned-exception-object">;
 def DeprecatedObjCIsaUsage : DiagGroup<"deprecated-objc-isa-usage">;
 def ExplicitInitializeCall : DiagGroup<"explicit-initialize-call">;
 def Packed : DiagGroup<"packed">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=360404=360403=360404=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu May  9 19:16:37 
2019
@@ -6576,6 +6576,12 @@ def err_throw_incomplete : Error<
   "cannot throw object of incomplete type %0">;
 def err_throw_incomplete_ptr : Error<
   "cannot throw pointer to object of incomplete type %0">;
+def warn_throw_underaligned_obj : Warning<
+  "underaligned exception object thrown">,
+  InGroup;
+def note_throw_underaligned_obj : Note<
+  "required alignment of type %0 (%1 bytes) is larger than the supported "
+  "alignment of C++ exception objects on this target (%2 bytes)">;
 def err_return_in_constructor_handler : Error<
   "return in the catch of a function try block of a constructor is illegal">;
 def warn_cdtor_function_try_handler_mem_expr : Warning<

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=360404=360403=360404=diff
==
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Thu May  9 19:16:37 2019
@@ -637,6 +637,21 @@ public:
   /// types for the given target.
   unsigned getSimdDefaultAlign() const { return SimdDefaultAlign; }
 
+  /// Return the alignment (in bits) of the thrown exception object. This is
+  /// only meaningful for targets that allocate C++ exceptions in a system
+  /// runtime, such as those using the Itanium C++ ABI.
+  virtual 

[PATCH] D61689: Change -gz and -Wa,--compress-debug-sections to use gABI compression (SHF_COMPRESSED)

2019-05-09 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL360403: Change -gz and -Wa,--compress-debug-sections to use 
gABI compression… (authored by MaskRay, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D61689?vs=198970=198974#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D61689

Files:
  cfe/trunk/docs/ReleaseNotes.rst
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/tools/driver/cc1as_main.cpp


Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -1052,8 +1052,7 @@
   if (const Arg *A = Args.getLastArg(OPT_compress_debug_sections,
  OPT_compress_debug_sections_EQ)) {
 if (A->getOption().getID() == OPT_compress_debug_sections) {
-  // TODO: be more clever about the compression type auto-detection
-  Opts.setCompressDebugSections(llvm::DebugCompressionType::GNU);
+  Opts.setCompressDebugSections(llvm::DebugCompressionType::Z);
 } else {
   auto DCT = llvm::StringSwitch(A->getValue())
  .Case("none", llvm::DebugCompressionType::None)
Index: cfe/trunk/tools/driver/cc1as_main.cpp
===
--- cfe/trunk/tools/driver/cc1as_main.cpp
+++ cfe/trunk/tools/driver/cc1as_main.cpp
@@ -221,8 +221,7 @@
   if (const Arg *A = Args.getLastArg(OPT_compress_debug_sections,
  OPT_compress_debug_sections_EQ)) {
 if (A->getOption().getID() == OPT_compress_debug_sections) {
-  // TODO: be more clever about the compression type auto-detection
-  Opts.CompressDebugSections = llvm::DebugCompressionType::GNU;
+  Opts.CompressDebugSections = llvm::DebugCompressionType::Z;
 } else {
   Opts.CompressDebugSections =
   llvm::StringSwitch(A->getValue())
Index: cfe/trunk/docs/ReleaseNotes.rst
===
--- cfe/trunk/docs/ReleaseNotes.rst
+++ cfe/trunk/docs/ReleaseNotes.rst
@@ -77,7 +77,10 @@
 
 - `clang -dumpversion` now returns the version of Clang itself.
 
-- ...
+- On ELF, ``-gz`` now defaults to ``-gz=zlib``. It produces ``SHF_COMPRESSED``
+  style compression of debug information. GNU binutils 2.26 or newer, or lld is
+  required to link produced object files. Use ``-gz=zlib-gnu`` to get the old
+  behavior.
 
 New Pragmas in Clang
 


Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -1052,8 +1052,7 @@
   if (const Arg *A = Args.getLastArg(OPT_compress_debug_sections,
  OPT_compress_debug_sections_EQ)) {
 if (A->getOption().getID() == OPT_compress_debug_sections) {
-  // TODO: be more clever about the compression type auto-detection
-  Opts.setCompressDebugSections(llvm::DebugCompressionType::GNU);
+  Opts.setCompressDebugSections(llvm::DebugCompressionType::Z);
 } else {
   auto DCT = llvm::StringSwitch(A->getValue())
  .Case("none", llvm::DebugCompressionType::None)
Index: cfe/trunk/tools/driver/cc1as_main.cpp
===
--- cfe/trunk/tools/driver/cc1as_main.cpp
+++ cfe/trunk/tools/driver/cc1as_main.cpp
@@ -221,8 +221,7 @@
   if (const Arg *A = Args.getLastArg(OPT_compress_debug_sections,
  OPT_compress_debug_sections_EQ)) {
 if (A->getOption().getID() == OPT_compress_debug_sections) {
-  // TODO: be more clever about the compression type auto-detection
-  Opts.CompressDebugSections = llvm::DebugCompressionType::GNU;
+  Opts.CompressDebugSections = llvm::DebugCompressionType::Z;
 } else {
   Opts.CompressDebugSections =
   llvm::StringSwitch(A->getValue())
Index: cfe/trunk/docs/ReleaseNotes.rst
===
--- cfe/trunk/docs/ReleaseNotes.rst
+++ cfe/trunk/docs/ReleaseNotes.rst
@@ -77,7 +77,10 @@
 
 - `clang -dumpversion` now returns the version of Clang itself.
 
-- ...
+- On ELF, ``-gz`` now defaults to ``-gz=zlib``. It produces ``SHF_COMPRESSED``
+  style compression of debug information. GNU binutils 2.26 or newer, or lld is
+  required to link produced object files. Use ``-gz=zlib-gnu`` to get the old
+  behavior.
 
 New Pragmas in Clang
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r360403 - Change -gz and -Wa, --compress-debug-sections to use gABI compression (SHF_COMPRESSED)

2019-05-09 Thread Fangrui Song via cfe-commits
Author: maskray
Date: Thu May  9 19:08:21 2019
New Revision: 360403

URL: http://llvm.org/viewvc/llvm-project?rev=360403=rev
Log:
Change -gz and -Wa,--compress-debug-sections to use gABI compression 
(SHF_COMPRESSED)

Since July 15, 2015 (binutils-gdb commit
19a7fe52ae3d0971e67a134bcb1648899e21ae1c, included in 2.26), gas
--compress-debug-sections=zlib (gcc -gz) means zlib-gabi:
SHF_COMPRESSED. Before that it meant zlib-gnu (.zdebug).

clang's -gz was introduced in rC306115 (Jun 2017) to indicate zlib-gnu. It
is 2019 now and it is not unreasonable to assume users of the new
feature to have new linkers (ld.bfd/gold >= 2.26, lld >= rLLD273661).

Change clang's default accordingly to improve standard conformance.
zlib-gnu becomes out of fashion and gets poorer toolchain support.
Its mangled names confuse tools and are more likely to cause problems.

Reviewed By: compnerd

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

Modified:
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/tools/driver/cc1as_main.cpp

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=360403=360402=360403=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Thu May  9 19:08:21 2019
@@ -77,7 +77,10 @@ Modified Compiler Flags
 
 - `clang -dumpversion` now returns the version of Clang itself.
 
-- ...
+- On ELF, ``-gz`` now defaults to ``-gz=zlib``. It produces ``SHF_COMPRESSED``
+  style compression of debug information. GNU binutils 2.26 or newer, or lld is
+  required to link produced object files. Use ``-gz=zlib-gnu`` to get the old
+  behavior.
 
 New Pragmas in Clang
 

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=360403=360402=360403=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Thu May  9 19:08:21 2019
@@ -1052,8 +1052,7 @@ static bool ParseCodeGenArgs(CodeGenOpti
   if (const Arg *A = Args.getLastArg(OPT_compress_debug_sections,
  OPT_compress_debug_sections_EQ)) {
 if (A->getOption().getID() == OPT_compress_debug_sections) {
-  // TODO: be more clever about the compression type auto-detection
-  Opts.setCompressDebugSections(llvm::DebugCompressionType::GNU);
+  Opts.setCompressDebugSections(llvm::DebugCompressionType::Z);
 } else {
   auto DCT = llvm::StringSwitch(A->getValue())
  .Case("none", llvm::DebugCompressionType::None)

Modified: cfe/trunk/tools/driver/cc1as_main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1as_main.cpp?rev=360403=360402=360403=diff
==
--- cfe/trunk/tools/driver/cc1as_main.cpp (original)
+++ cfe/trunk/tools/driver/cc1as_main.cpp Thu May  9 19:08:21 2019
@@ -221,8 +221,7 @@ bool AssemblerInvocation::CreateFromArgs
   if (const Arg *A = Args.getLastArg(OPT_compress_debug_sections,
  OPT_compress_debug_sections_EQ)) {
 if (A->getOption().getID() == OPT_compress_debug_sections) {
-  // TODO: be more clever about the compression type auto-detection
-  Opts.CompressDebugSections = llvm::DebugCompressionType::GNU;
+  Opts.CompressDebugSections = llvm::DebugCompressionType::Z;
 } else {
   Opts.CompressDebugSections =
   llvm::StringSwitch(A->getValue())


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


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

2019-05-09 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added a reviewer: ilya-biryukov.
Herald added a subscriber: mgorny.
Herald added a project: clang.

NOTE: This is a preliminary revision for discussion; tests have not yet been 
provided.

The RangeSelector library defines a combinator language for specifying source
ranges based on bound id for AST nodes.  The combinator approach follows the
design of the AST matchers.  The RangeSelectors defined here will be used in
both RewriteRule, for specifying source affected by edit, and in Stencil for
specifying source to use constructively in a replacement.

This revision extends the SourceCode library with utility functions needed by
RangeSelector.  Some of them come are copied from clang-tidy/utils/LexUtils,
since clang/Tooling can't depend on clang-tidy libraries.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D61774

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

Index: clang/lib/Tooling/Refactoring/SourceCode.cpp
===
--- clang/lib/Tooling/Refactoring/SourceCode.cpp
+++ clang/lib/Tooling/Refactoring/SourceCode.cpp
@@ -14,18 +14,58 @@
 
 using namespace clang;
 
-StringRef clang::tooling::getText(CharSourceRange Range,
-  const ASTContext ) {
+StringRef tooling::getText(CharSourceRange Range, const ASTContext ) {
   return Lexer::getSourceText(Range, Context.getSourceManager(),
   Context.getLangOpts());
 }
 
-CharSourceRange clang::tooling::maybeExtendRange(CharSourceRange Range,
- tok::TokenKind Next,
- ASTContext ) {
+CharSourceRange tooling::maybeExtendRange(CharSourceRange Range,
+  tok::TokenKind Next,
+  ASTContext ) {
   Optional Tok = Lexer::findNextToken(
   Range.getEnd(), Context.getSourceManager(), Context.getLangOpts());
   if (!Tok || !Tok->is(Next))
 return Range;
   return CharSourceRange::getTokenRange(Range.getBegin(), Tok->getLocation());
 }
+
+SourceLocation tooling::findPreviousTokenStart(SourceLocation Start,
+   const SourceManager ,
+   const LangOptions ) {
+  if (Start.isInvalid() || Start.isMacroID())
+return SourceLocation();
+
+  SourceLocation BeforeStart = Start.getLocWithOffset(-1);
+  if (BeforeStart.isInvalid() || BeforeStart.isMacroID())
+return SourceLocation();
+
+  return Lexer::GetBeginningOfToken(BeforeStart, SM, LangOpts);
+}
+
+SourceLocation tooling::findPreviousTokenKind(SourceLocation Start,
+  const SourceManager ,
+  const LangOptions ,
+  tok::TokenKind TK) {
+  while (true) {
+SourceLocation L = findPreviousTokenStart(Start, SM, LangOpts);
+if (L.isInvalid() || L.isMacroID())
+  return SourceLocation();
+
+Token T;
+if (Lexer::getRawToken(L, T, SM, LangOpts, /*IgnoreWhiteSpace=*/true))
+  return SourceLocation();
+
+if (T.is(TK))
+  return T.getLocation();
+
+Start = L;
+  }
+}
+
+SourceLocation tooling::findOpenParen(const CallExpr ,
+  const SourceManager ,
+  const LangOptions ) {
+  SourceLocation EndLoc =
+  E.getNumArgs() == 0 ? E.getRParenLoc() : E.getArg(0)->getBeginLoc();
+  return findPreviousTokenKind(EndLoc, SM, LangOpts, tok::TokenKind::l_paren);
+}
Index: clang/lib/Tooling/Refactoring/RangeSelector.cpp
===
--- /dev/null
+++ clang/lib/Tooling/Refactoring/RangeSelector.cpp
@@ -0,0 +1,219 @@
+//===--- Transformer.cpp - Transformer library implementation ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Tooling/Refactoring/RangeSelector.h"
+#include "clang/AST/Expr.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Tooling/Refactoring/SourceCode.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Errc.h"
+#include "llvm/Support/Error.h"
+#include 
+#include 
+#include 
+
+using namespace clang;
+using namespace tooling;
+
+using ast_matchers::MatchFinder;
+using ast_type_traits::ASTNodeKind;
+using ast_type_traits::DynTypedNode;
+using 

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

2019-05-09 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

Ilya, this revision follows up from our discussion on the doc. It adds some 
more selectors.  If this change is to big, I'm happy to split it up (e.g. 
moving the changes to SourceCode to a separate revision and/or splitting up the 
RangeSelector changes).  Also, I have the diff updating Transformer ready if 
you want to see that. I can post a preview or created a stacked revision. Let 
me know...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61774



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


[PATCH] D61689: Change -gz and -Wa,--compress-debug-sections to use gABI compression (SHF_COMPRESSED)

2019-05-09 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 198970.
MaskRay edited the summary of this revision.
MaskRay added a comment.

Update release notes


Repository:
  rC Clang

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

https://reviews.llvm.org/D61689

Files:
  docs/ReleaseNotes.rst
  lib/Frontend/CompilerInvocation.cpp
  tools/driver/cc1as_main.cpp


Index: tools/driver/cc1as_main.cpp
===
--- tools/driver/cc1as_main.cpp
+++ tools/driver/cc1as_main.cpp
@@ -221,8 +221,7 @@
   if (const Arg *A = Args.getLastArg(OPT_compress_debug_sections,
  OPT_compress_debug_sections_EQ)) {
 if (A->getOption().getID() == OPT_compress_debug_sections) {
-  // TODO: be more clever about the compression type auto-detection
-  Opts.CompressDebugSections = llvm::DebugCompressionType::GNU;
+  Opts.CompressDebugSections = llvm::DebugCompressionType::Z;
 } else {
   Opts.CompressDebugSections =
   llvm::StringSwitch(A->getValue())
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1052,8 +1052,7 @@
   if (const Arg *A = Args.getLastArg(OPT_compress_debug_sections,
  OPT_compress_debug_sections_EQ)) {
 if (A->getOption().getID() == OPT_compress_debug_sections) {
-  // TODO: be more clever about the compression type auto-detection
-  Opts.setCompressDebugSections(llvm::DebugCompressionType::GNU);
+  Opts.setCompressDebugSections(llvm::DebugCompressionType::Z);
 } else {
   auto DCT = llvm::StringSwitch(A->getValue())
  .Case("none", llvm::DebugCompressionType::None)
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -77,7 +77,9 @@
 
 - `clang -dumpversion` now returns the version of Clang itself.
 
-- ...
+- ``-gz`` now defaults to ``-gz=zlib``. It produces ``SHF_COMPRESSED`` style
+  compression of debug information. GNU binutils 2.26 or newer, or lld is 
required
+  to link produced object files.
 
 New Pragmas in Clang
 


Index: tools/driver/cc1as_main.cpp
===
--- tools/driver/cc1as_main.cpp
+++ tools/driver/cc1as_main.cpp
@@ -221,8 +221,7 @@
   if (const Arg *A = Args.getLastArg(OPT_compress_debug_sections,
  OPT_compress_debug_sections_EQ)) {
 if (A->getOption().getID() == OPT_compress_debug_sections) {
-  // TODO: be more clever about the compression type auto-detection
-  Opts.CompressDebugSections = llvm::DebugCompressionType::GNU;
+  Opts.CompressDebugSections = llvm::DebugCompressionType::Z;
 } else {
   Opts.CompressDebugSections =
   llvm::StringSwitch(A->getValue())
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1052,8 +1052,7 @@
   if (const Arg *A = Args.getLastArg(OPT_compress_debug_sections,
  OPT_compress_debug_sections_EQ)) {
 if (A->getOption().getID() == OPT_compress_debug_sections) {
-  // TODO: be more clever about the compression type auto-detection
-  Opts.setCompressDebugSections(llvm::DebugCompressionType::GNU);
+  Opts.setCompressDebugSections(llvm::DebugCompressionType::Z);
 } else {
   auto DCT = llvm::StringSwitch(A->getValue())
  .Case("none", llvm::DebugCompressionType::None)
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -77,7 +77,9 @@
 
 - `clang -dumpversion` now returns the version of Clang itself.
 
-- ...
+- ``-gz`` now defaults to ``-gz=zlib``. It produces ``SHF_COMPRESSED`` style
+  compression of debug information. GNU binutils 2.26 or newer, or lld is required
+  to link produced object files.
 
 New Pragmas in Clang
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60974: Clang IFSO driver action.

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

cleaned  up VisitNamedDecl


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60974

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

Index: llvm/lib/TextAPI/ELF/TBEHandler.cpp
===
--- llvm/lib/TextAPI/ELF/TBEHandler.cpp
+++ llvm/lib/TextAPI/ELF/TBEHandler.cpp
@@ -134,6 +134,7 @@
 IO.mapRequired("TbeVersion", Stub.TbeVersion);
 IO.mapOptional("SoName", Stub.SoName);
 IO.mapRequired("Arch", (ELFArchMapper &)Stub.Arch);
+IO.mapOptional("Endian", Stub.Endian);
 IO.mapOptional("NeededLibs", Stub.NeededLibs);
 IO.mapRequired("Symbols", Stub.Symbols);
   }
Index: llvm/include/llvm/TextAPI/ELF/ELFStub.h
===
--- llvm/include/llvm/TextAPI/ELF/ELFStub.h
+++ llvm/include/llvm/TextAPI/ELF/ELFStub.h
@@ -55,6 +55,7 @@
   VersionTuple TbeVersion;
   Optional SoName;
   ELFArch Arch;
+  Optional Endian;
   std::vector NeededLibs;
   std::set Symbols;
 
Index: clang/test/IFSO/foo.cpp
===
--- /dev/null
+++ clang/test/IFSO/foo.cpp
@@ -0,0 +1,57 @@
+// Using %clang instead of %clang_cc1 because of -fvisibility
+// RUN: %clang -target x86_64-linux-gnu -emit-interface-stubs -interface-stubs-version=tapi-tbe -fvisibility=hidden %s -o - | FileCheck --check-prefix=CHECK-HIDDEN %s
+// RUN: %clang -target x86_64-linux-gnu -emit-interface-stubs -interface-stubs-version=tapi-tbe %s -o - | FileCheck %s
+
+// CHECK-HIDDEN-NOT: _Z4fbarff
+// CHECK: _Z4fbarff
+
+
+
+
+// CHECK-HIDDEN-NOT: _Z3fooii
+// CHECK-NOT:_Z3fooii
+
+
+
+#include "foo-inline.h"
+
+__attribute__ ((visibility ("hidden"))) int foo(int a, int b) { return a + b; }
+__attribute__ ((visibility ("default"))) int foo_default_visi(int a, int b) { return a + b; }
+
+
+__attribute__ ((visibility ("default"))) int fvih_1(int a, int b) { return a + fvih(); }
+
+
+__attribute__((weak)) int someWeakFunc() { return 42; }
+
+int dataA = 34;
+
+namespace baz {
+  template 
+  T add(T a, T b) {
+return a + b;
+  }
+}
+
+namespace n {
+  template 
+  struct __attribute__((__visibility__("default"))) S {
+S() = default;
+~S() = default;
+int __attribute__((__visibility__(("default" func() const { return 32; }
+int __attribute__((__visibility__(("hidden" operator()() const { return 53; }
+  };
+}
+
+template  T neverUsed(T t) { return t + 2; }
+
+template<> int neverUsed(int t);
+
+void g() { n::S()(); }
+
+namespace qux {
+int bar(int a, int b) { return baz::add(a, b); }
+}
+
+float fbar(float a, float b) { return baz::add(a, b); }
+
Index: clang/test/IFSO/foo-inline.h
===
--- /dev/null
+++ clang/test/IFSO/foo-inline.h
@@ -0,0 +1,6 @@
+
+inline int fvih() {
+static int fortytwo = 42;
+  return fortytwo;
+}
+
Index: clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -64,6 +64,10 @@
   case GenerateHeaderModule:
 return llvm::make_unique();
   case GeneratePCH:return llvm::make_unique();
+  case GenerateInterfaceYAMLExpV1:
+return llvm::make_unique();
+  case GenerateInterfaceTBEExpV1:
+return llvm::make_unique();
   case InitOnly:   return llvm::make_unique();
   case ParseSyntaxOnly:return llvm::make_unique();
   case ModuleFileInfo: return llvm::make_unique();
Index: clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
===
--- /dev/null
+++ clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
@@ -0,0 +1,303 @@
+//===--- InterfaceStubFunctionsConsumer.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include 

[PATCH] D61667: Assume `__cxa_allocate_exception` returns an under-aligned memory on Darwin if the version of libc++abi isn't new enough to include the fix in r319123

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

Thanks, LGTM.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61667



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


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

2019-05-09 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: clang/test/SemaCXX/aggregate-initialization.cpp:199
   void test0() {
-auto *y = new Y {}; // expected-error {{temporary of type 
'ElementDestructor::X' has private destructor}}
+auto *y = new Y {}; // expected-error {{calling a private destructor of 
class 'ElementDestructor::X}}
   }

Feel free to address this in a follow-up, but this seems like a regression.


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

https://reviews.llvm.org/D61165



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


[PATCH] D60974: Clang IFSO driver action.

2019-05-09 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi updated this revision to Diff 198963.
plotfi marked 9 inline comments as done.
plotfi added a comment.

removed all the template functions to handle decls.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60974

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

Index: llvm/lib/TextAPI/ELF/TBEHandler.cpp
===
--- llvm/lib/TextAPI/ELF/TBEHandler.cpp
+++ llvm/lib/TextAPI/ELF/TBEHandler.cpp
@@ -134,6 +134,7 @@
 IO.mapRequired("TbeVersion", Stub.TbeVersion);
 IO.mapOptional("SoName", Stub.SoName);
 IO.mapRequired("Arch", (ELFArchMapper &)Stub.Arch);
+IO.mapOptional("Endian", Stub.Endian);
 IO.mapOptional("NeededLibs", Stub.NeededLibs);
 IO.mapRequired("Symbols", Stub.Symbols);
   }
Index: llvm/include/llvm/TextAPI/ELF/ELFStub.h
===
--- llvm/include/llvm/TextAPI/ELF/ELFStub.h
+++ llvm/include/llvm/TextAPI/ELF/ELFStub.h
@@ -55,6 +55,7 @@
   VersionTuple TbeVersion;
   Optional SoName;
   ELFArch Arch;
+  Optional Endian;
   std::vector NeededLibs;
   std::set Symbols;
 
Index: clang/test/IFSO/foo.cpp
===
--- /dev/null
+++ clang/test/IFSO/foo.cpp
@@ -0,0 +1,57 @@
+// Using %clang instead of %clang_cc1 because of -fvisibility
+// RUN: %clang -target x86_64-linux-gnu -emit-interface-stubs -interface-stubs-version=tapi-tbe -fvisibility=hidden %s -o - | FileCheck --check-prefix=CHECK-HIDDEN %s
+// RUN: %clang -target x86_64-linux-gnu -emit-interface-stubs -interface-stubs-version=tapi-tbe %s -o - | FileCheck %s
+
+// CHECK-HIDDEN-NOT: _Z4fbarff
+// CHECK: _Z4fbarff
+
+
+
+
+// CHECK-HIDDEN-NOT: _Z3fooii
+// CHECK-NOT:_Z3fooii
+
+
+
+#include "foo-inline.h"
+
+__attribute__ ((visibility ("hidden"))) int foo(int a, int b) { return a + b; }
+__attribute__ ((visibility ("default"))) int foo_default_visi(int a, int b) { return a + b; }
+
+
+__attribute__ ((visibility ("default"))) int fvih_1(int a, int b) { return a + fvih(); }
+
+
+__attribute__((weak)) int someWeakFunc() { return 42; }
+
+int dataA = 34;
+
+namespace baz {
+  template 
+  T add(T a, T b) {
+return a + b;
+  }
+}
+
+namespace n {
+  template 
+  struct __attribute__((__visibility__("default"))) S {
+S() = default;
+~S() = default;
+int __attribute__((__visibility__(("default" func() const { return 32; }
+int __attribute__((__visibility__(("hidden" operator()() const { return 53; }
+  };
+}
+
+template  T neverUsed(T t) { return t + 2; }
+
+template<> int neverUsed(int t);
+
+void g() { n::S()(); }
+
+namespace qux {
+int bar(int a, int b) { return baz::add(a, b); }
+}
+
+float fbar(float a, float b) { return baz::add(a, b); }
+
Index: clang/test/IFSO/foo-inline.h
===
--- /dev/null
+++ clang/test/IFSO/foo-inline.h
@@ -0,0 +1,6 @@
+
+inline int fvih() {
+static int fortytwo = 42;
+  return fortytwo;
+}
+
Index: clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -64,6 +64,10 @@
   case GenerateHeaderModule:
 return llvm::make_unique();
   case GeneratePCH:return llvm::make_unique();
+  case GenerateInterfaceYAMLExpV1:
+return llvm::make_unique();
+  case GenerateInterfaceTBEExpV1:
+return llvm::make_unique();
   case InitOnly:   return llvm::make_unique();
   case ParseSyntaxOnly:return llvm::make_unique();
   case ModuleFileInfo: return llvm::make_unique();
Index: clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
===
--- /dev/null
+++ clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
@@ -0,0 +1,298 @@
+//===--- InterfaceStubFunctionsConsumer.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/AST/RecursiveASTVisitor.h"
+#include 

[PATCH] D60543: [clang] Update isDerivedFrom to support Objective-C classes 

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



Comment at: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp:566
+  notMatchesObjC("@interface Y @end typedef Y X; @interface Z : X @end",
+  ZIsDerivedFromX));
+  EXPECT_TRUE(

(note that there are unresolved formatting issues that I intend to fix after I 
establish which approach to pursue)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60543



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


[PATCH] D60543: [clang] Update isDerivedFrom to support Objective-C classes 

2019-05-09 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore added a comment.

I did some digging and I believe there are two approaches that we can take to 
extend `isDerivedFrom` to support Objective-C classes.

**Option 1: Match on Common Ancestor Declaration Type**:
Convert `isDerivedFrom` to match on the common ancestor declaration type, 
`NamedDecl`, and return `false` for
declaration types other than `CXXRecordDecl` and `ObjCInterfaceDecl`.

Advantages:
• Largely works in-place without requiring major changes to matchers built on 
top of `isDerivedFrom`.

Disadvantages:
• Allows nonsensical matchers, e.g., `functionDecl(isDerivedFrom("X"))`.

**Option 2: Convert to Polymorphic Matcher**:
Convert `isDerivedFrom` to a polymorphic matcher supporting `CXXRecordDecl` and 
`ObjCInterfaceDecl`.

Advantages:
• Restricts usage of `isDerivedFrom` to `CXXRecordDecl` and `ObjCInterfaceDecl`.

Disadvantages:
• Potentially requires many or all matchers using `isDerivedFrom` to refactor 
to adapt to the polymorphic matcher interface.

**Evaluation**
I have been going back and forth as to which approach is superior. Option 1 
promotes source stability at the cost of usability while
option 2 seems to promote usability at the cost of source stability. I exported 
a portrayal of option 1 for consideration as it
required less invasive changes. I can see arguments supporting both approaches.

What do you think? Which of the two approaches do you think we should go with? 
Is there another approach that I have not thought of?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60543



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


[PATCH] D61667: Assume `__cxa_allocate_exception` returns an under-aligned memory on Darwin if the version of libc++abi isn't new enough to include the fix in r319123

2019-05-09 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 198959.
ahatanak added a comment.

Update the comment in `CheckCXXThrowOperand`.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61667

Files:
  include/clang/AST/ASTContext.h
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/TargetInfo.h
  lib/Basic/Targets/OSTargets.h
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/Sema/SemaExprCXX.cpp
  test/CodeGenCXX/eh.cpp
  test/SemaCXX/warn-overaligned-type-thrown.cpp

Index: test/SemaCXX/warn-overaligned-type-thrown.cpp
===
--- /dev/null
+++ test/SemaCXX/warn-overaligned-type-thrown.cpp
@@ -0,0 +1,66 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.99 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions -DUNDERALIGNED %s
+// RUN: %clang_cc1 -triple arm64-apple-ios10 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions -DUNDERALIGNED %s
+// RUN: %clang_cc1 -triple arm64-apple-tvos10 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions -DUNDERALIGNED %s
+// RUN: %clang_cc1 -triple arm64-apple-watchos4 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions -DUNDERALIGNED %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.14 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s
+// RUN: %clang_cc1 -triple arm64-apple-ios12 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s
+// RUN: %clang_cc1 -triple arm64-apple-tvos12 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s
+// RUN: %clang_cc1 -triple arm64-apple-watchos5 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s
+// RUN: %clang_cc1 -triple arm-linux-gnueabi -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s
+// RUN: %clang_cc1 -triple aarch64-linux-gnueabi -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s
+// RUN: %clang_cc1 -triple mipsel-linux-gnu -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s
+// RUN: %clang_cc1 -triple mips64el-linux-gnu -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s
+// RUN: %clang_cc1 -triple wasm64-unknown-unknown -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.14 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions -Wno-underaligned-exception-object -DNODIAG %s
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions -DNODIAG %s
+
+struct S0 {
+  S0();
+  int m;
+};
+
+struct Overaligned1 {
+  Overaligned1();
+  int __attribute__((aligned(16))) m;
+};
+
+struct __attribute__((aligned(16))) Overaligned2 {
+  Overaligned2();
+  int m;
+};
+
+struct Overaligned3 {
+  Overaligned3();
+  int __attribute__((aligned(64))) m;
+};
+
+void test0() {
+  throw S0();
+}
+
+void test1() {
+  throw Overaligned1();
+}
+
+void test2() {
+  throw Overaligned2();
+}
+
+void test3() {
+  throw Overaligned3();
+}
+
+#if defined(NODIAG)
+// expected-no-diagnostics
+#elif defined(UNDERALIGNED)
+// expected-warning@-14 {{underaligned exception object thrown}}
+// expected-note@-15 {{(16 bytes) is larger than the supported alignment of C++ exception objects on this target (8 bytes)}}
+// expected-warning@-12 {{underaligned exception object thrown}}
+// expected-note@-13 {{(16 bytes) is larger than the supported alignment of C++ exception objects on this target (8 bytes)}}
+// expected-warning@-10 {{underaligned exception object thrown}}
+// expected-note@-11 {{(64 bytes) is larger than the supported alignment of C++ exception objects on this target (8 bytes)}}
+#else
+// expected-warning@-13 {{underaligned exception object thrown}}
+// expected-note@-14 {{(64 bytes) is larger than the supported alignment of C++ exception objects on this target (16 bytes)}}
+#endif
Index: test/CodeGenCXX/eh.cpp
===
--- test/CodeGenCXX/eh.cpp
+++ test/CodeGenCXX/eh.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -triple x86_64-apple-darwin -std=c++11 -emit-llvm %s -o - \
-// RUN:   | FileCheck %s
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -triple x86_64-apple-macosx10.13.99 -std=c++11 -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=UNALIGNED %s
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -triple x86_64-apple-macosx10.14 -std=c++11 -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=ALIGNED %s
 
 struct test1_D {
   double d;
@@ -13,7 +13,8 @@
 // CHECK:   [[EXNOBJ:%.*]] = call i8* @__cxa_allocate_exception(i64 8)
 // CHECK-NEXT:  [[EXN:%.*]] = bitcast i8* [[EXNOBJ]] to [[DSTAR:%[^*]*\*]]
 // CHECK-NEXT:  [[EXN2:%.*]] = bitcast [[DSTAR]] [[EXN]] to i8*
-// 

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

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



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:13121-13122
+  if (VD->isNoDestroy(getASTContext()) &&
+  !(VD->getType()->isArrayType() && getLangOpts().Exceptions &&
+VD->isStaticLocal()))
 return;

rjmccall wrote:
> erik.pilkington wrote:
> > rjmccall wrote:
> > > erik.pilkington wrote:
> > > > rjmccall wrote:
> > > > > rsmith wrote:
> > > > > > Hmm, perhaps it would be cleaner if the destructor for array 
> > > > > > elements were required by the initialization of the array, instead 
> > > > > > of here. That's how this works for struct aggregate initialization 
> > > > > > (see `InitListChecker::CheckStructUnionTypes`), and (indirectly) 
> > > > > > how it works for initialization by constructor, and so on. And it 
> > > > > > reflects the fact that it's the initialization process that needs 
> > > > > > the array element destructor, not the destruction of the variable 
> > > > > > (which never happens).
> > > > > > 
> > > > > > For the case of aggregate initialization of an array, we appear to 
> > > > > > fail to implement [dcl.init.aggr]/8:
> > > > > > 
> > > > > > """
> > > > > > The destructor for each element of class type is potentially 
> > > > > > invoked (11.3.6) from the context where the aggregate 
> > > > > > initialization occurs. [Note: This provision ensures that 
> > > > > > destructors can be called for fully-constructed subobjects in case 
> > > > > > an exception is thrown (14.2). — end note]
> > > > > > """
> > > > > > 
> > > > > > (But there doesn't appear to be any corresponding wording for 
> > > > > > default / value initialization of arrays. See also the special case 
> > > > > > at the end of `BuildCXXNewExpr`.)
> > > > > That makes sense to me.  The default/value initialization case seems 
> > > > > like an obvious oversight in the standard, but I think it might be a 
> > > > > distinction without a difference: the special cases for 
> > > > > base-or-member initializers and new-expressions might cover literally 
> > > > > every situation where initialization doesn't come with an adjacent 
> > > > > need for non-exceptional destruction.
> > > > Sure, done. Moving this to initialization time seems like a nice 
> > > > cleanup.
> > > Hmm.  What I just mentioned for the documentation is relevant here, 
> > > right?  We only need to check access to subobject destructors if 
> > > exceptions are enabled, so this attempt to avoid duplicate diagnostics 
> > > might leave us not flagging the use if exceptions are disabled.
> > > 
> > > Well, maybe the check isn't actually restricted that way, hmm.  Shouldn't 
> > > it be?
> > I thought we tried in general to keep `-fno-exceptions` as similar to 
> > normal C++ as possible, rather than invent new language rules for it (even 
> > when they make sense).
> There's at least one other place where `-fno-exceptions` changes the language 
> rules: we don't look for `operator delete` in a new-expression.  It does look 
> like that's all I was remembering, though, and that we don't generally apply 
> that same principle to destructors, so feel free to ignore my comment.
> 
> Still, could you make sure there's a test case that tests that we check 
> access to the destructor of an array variable even when exceptions are 
> disabled, since that's the interesting corner case created by this new 
> condition?
Sure, thats included in test/SemaCXX/no_destroy.cpp. Pretty much every test is 
running in -fno-exceptions mode, since thats the default in `-cc1` for some 
reason. All the more reason to keep the two modes as similar as possible I 
guess :)


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

https://reviews.llvm.org/D61165



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


[PATCH] D60543: [clang] Add matcher for subclasses of Objective-C interfaces 

2019-05-09 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore updated this revision to Diff 198956.
stephanemoore added a comment.

Present one potential option for making isDerivedFrom support Objective-C 
classes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60543

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

Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -536,6 +536,39 @@
 cxxRecordDecl(isDerivedFrom(namedDecl(hasName("X"));
 }
 
+TEST(DeclarationMatcher, ObjCClassIsDerived) {
+  DeclarationMatcher IsDerivedFromX = objcInterfaceDecl(isDerivedFrom("X"));
+  EXPECT_TRUE(matchesObjC("@interface X @end @interface Y : X @end", IsDerivedFromX));
+  EXPECT_TRUE(matchesObjC("@interface X @end @interface Y<__covariant ObjectType> : X @end", IsDerivedFromX));
+  EXPECT_TRUE(notMatchesObjC("@interface X @end", IsDerivedFromX));
+  EXPECT_TRUE(notMatchesObjC("@class X;", IsDerivedFromX));
+  EXPECT_TRUE(notMatchesObjC("@class Y;", IsDerivedFromX));
+
+  DeclarationMatcher IsAX = objcInterfaceDecl(isSameOrDerivedFrom("X"));
+  EXPECT_TRUE(matchesObjC("@interface X @end @interface Y : X @end", IsAX));
+  EXPECT_TRUE(matchesObjC("@interface X @end", IsAX));
+  EXPECT_TRUE(matchesObjC("@class X;", IsAX));
+  EXPECT_TRUE(notMatchesObjC("@interface Y @end", IsAX));
+  EXPECT_TRUE(notMatchesObjC("@class Y;", IsAX));
+
+  DeclarationMatcher ZIsDerivedFromX = objcInterfaceDecl(hasName("Z"), isDerivedFrom("X"));
+  EXPECT_TRUE(
+  matchesObjC("@interface X @end @interface Y : X @end @interface Z : Y @end",
+  ZIsDerivedFromX));
+  EXPECT_TRUE(
+  matchesObjC("@interface X @end typedef X Y; @interface Z : Y @end",
+  ZIsDerivedFromX));
+  EXPECT_TRUE(
+  matchesObjC("@interface X @end @interface Y : X @end typedef Y V; typedef V W; @interface Z : W @end",
+  ZIsDerivedFromX));
+  EXPECT_TRUE(
+  notMatchesObjC("@interface Y @end typedef Y X; @interface Z : X @end",
+  ZIsDerivedFromX));
+  EXPECT_TRUE(
+  notMatchesObjC("@interface Y @end @interface Y2 @end typedef Y2 X; @interface Z : Y @end",
+ ZIsDerivedFromX));
+}
+
 TEST(DeclarationMatcher, IsLambda) {
   const auto IsLambda = cxxMethodDecl(ofClass(cxxRecordDecl(isLambda(;
   EXPECT_TRUE(matches("auto x = []{};", IsLambda));
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -2600,8 +2600,9 @@
   AST_POLYMORPHIC_SUPPORTED_TYPES(CXXOperatorCallExpr, FunctionDecl)>(Name);
 }
 
-/// Matches C++ classes that are directly or indirectly derived from
-/// a class matching \c Base.
+/// Matches C++ classes that are directly or indirectly derived from a class
+/// matching \c Base, or Objective-C classes that directly or indirectly
+/// subclass a class matching \c Base.
 ///
 /// Note that a class is not considered to be derived from itself.
 ///
@@ -2621,28 +2622,49 @@
 ///   typedef Foo X;
 ///   class Bar : public Foo {};  // derived from a type that X is a typedef of
 /// \endcode
-AST_MATCHER_P(CXXRecordDecl, isDerivedFrom,
+///
+/// In the following example, Bar matches isDerivedFrom(hasName("NSObject"))
+/// \code
+///   @interface NSObject @end
+///   @interface Bar : NSObject @end
+/// \endcode
+AST_MATCHER_P(NamedDecl, isDerivedFrom,
   internal::Matcher, Base) {
-  return Finder->classIsDerivedFrom(, Base, Builder);
+  // Check if the node is a C++ struct/union/class.
+  if (const auto *RecordDecl = dyn_cast())
+return Finder->classIsDerivedFrom(RecordDecl, Base, Builder);
+
+  // Check if the node is an Objective-C class.
+  if (const auto *InterfaceDecl = dyn_cast()) {
+// Check if any of the superclasses of the class match.
+for (const ObjCInterfaceDecl *SuperClass = InterfaceDecl->getSuperClass();
+ SuperClass != nullptr; SuperClass = SuperClass->getSuperClass()) {
+  if (Base.matches(*SuperClass, Finder, Builder))
+return true;
+}
+  }
+
+  // No matches found.
+  return false;
 }
 
 /// Overloaded method as shortcut for \c isDerivedFrom(hasName(...)).
-AST_MATCHER_P_OVERLOAD(CXXRecordDecl, isDerivedFrom, std::string, BaseName, 1) {
+AST_MATCHER_P_OVERLOAD(NamedDecl, isDerivedFrom, std::string, BaseName, 1) {
   assert(!BaseName.empty());
   return isDerivedFrom(hasName(BaseName)).matches(Node, Finder, Builder);
 }
 
 /// Similar to \c isDerivedFrom(), but also matches classes that directly
 /// match \c Base.
-AST_MATCHER_P_OVERLOAD(CXXRecordDecl, isSameOrDerivedFrom,

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

2019-05-09 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington updated this revision to Diff 198944.
erik.pilkington marked an inline comment as done.
erik.pilkington added a comment.

Rename `hasAccessibleDestructor`.


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

https://reviews.llvm.org/D61165

Files:
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/test/CodeGenCXX/no_destroy.cpp
  clang/test/SemaCXX/aggregate-initialization.cpp
  clang/test/SemaCXX/no_destroy.cpp

Index: clang/test/SemaCXX/no_destroy.cpp
===
--- clang/test/SemaCXX/no_destroy.cpp
+++ clang/test/SemaCXX/no_destroy.cpp
@@ -1,11 +1,13 @@
-// RUN: %clang_cc1 -DNO_DTORS -fno-c++-static-destructors -verify %s
-// RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -DNO_DTORS -DNO_EXCEPTIONS -fno-c++-static-destructors -verify %s
+// RUN: %clang_cc1 -DNO_EXCEPTIONS -verify %s
+// RUN: %clang_cc1 -DNO_DTORS -fexceptions -fno-c++-static-destructors -verify %s
+// RUN: %clang_cc1 -fexceptions -verify %s
 
 struct SecretDestructor {
 #ifndef NO_DTORS
   // expected-note@+2 4 {{private}}
 #endif
-private: ~SecretDestructor(); // expected-note 2 {{private}}
+private: ~SecretDestructor(); // expected-note + {{private}}
 };
 
 SecretDestructor sd1;
@@ -44,3 +46,30 @@
 
 [[clang::no_destroy(0)]] int no_args; // expected-error{{'no_destroy' attribute takes no arguments}}
 [[clang::always_destroy(0)]] int no_args2; // expected-error{{'always_destroy' attribute takes no arguments}}
+
+// expected-error@+1 {{calling a private destructor of class 'SecretDestructor'}}
+SecretDestructor arr[10];
+
+void local_arrays() {
+  // expected-error@+1 {{calling a private destructor of class 'SecretDestructor'}}
+  static SecretDestructor arr2[10];
+  // expected-error@+1 {{calling a private destructor of class 'SecretDestructor'}}
+  thread_local SecretDestructor arr3[10];
+}
+
+struct Base {
+  ~Base();
+};
+struct Derived1 {
+  Derived1(int);
+  Base b;
+};
+struct Derived2 {
+  Derived1 b;
+};
+
+void dontcrash() {
+  [[clang::no_destroy]] static Derived2 d2[] = {0, 0};
+}
+
+[[clang::no_destroy]] Derived2 d2[] = {0, 0};
Index: clang/test/SemaCXX/aggregate-initialization.cpp
===
--- clang/test/SemaCXX/aggregate-initialization.cpp
+++ clang/test/SemaCXX/aggregate-initialization.cpp
@@ -196,7 +196,7 @@
   struct Y { X x; };
 
   void test0() {
-auto *y = new Y {}; // expected-error {{temporary of type 'ElementDestructor::X' has private destructor}}
+auto *y = new Y {}; // expected-error {{calling a private destructor of class 'ElementDestructor::X}}
   }
 
   struct S0 { int f; ~S0() = delete; }; // expected-note 3 {{'~S0' has been explicitly marked deleted here}}
Index: clang/test/CodeGenCXX/no_destroy.cpp
===
--- clang/test/CodeGenCXX/no_destroy.cpp
+++ clang/test/CodeGenCXX/no_destroy.cpp
@@ -1,11 +1,14 @@
-// RUN: %clang_cc1 %s -emit-llvm -triple x86_64-apple-macosx10.13.0 -o - | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -triple x86_64-apple-macosx10.13.0 -o - | FileCheck %s --check-prefixes=CHECK,NO_EXCEPTIONS
+// RUN: %clang_cc1 -fexceptions %s -emit-llvm -triple x86_64-apple-macosx10.13.0 -o - | FileCheck %s --check-prefixes=CHECK,EXCEPTIONS
 
 struct NonTrivial {
   ~NonTrivial();
 };
 
+// CHECK-LABEL: define internal void @__cxx_global_var_init
 // CHECK-NOT: __cxa_atexit{{.*}}_ZN10NonTrivialD1Ev
 [[clang::no_destroy]] NonTrivial nt1;
+// CHECK-LABEL: define internal void @__cxx_global_var_init
 // CHECK-NOT: _tlv_atexit{{.*}}_ZN10NonTrivialD1Ev
 [[clang::no_destroy]] thread_local NonTrivial nt2;
 
@@ -13,11 +16,14 @@
   ~NonTrivial2();
 };
 
+// CHECK-LABEL: define internal void @__cxx_global_var_init
 // CHECK: __cxa_atexit{{.*}}_ZN11NonTrivial2D1Ev
 NonTrivial2 nt21;
+// CHECK-LABEL: define internal void @__cxx_global_var_init
 // CHECK: _tlv_atexit{{.*}}_ZN11NonTrivial2D1Ev
 thread_local NonTrivial2 nt22;
 
+// CHECK-LABEL: define void @_Z1fv
 void f() {
   // CHECK: __cxa_atexit{{.*}}_ZN11NonTrivial2D1Ev
   static NonTrivial2 nt21;
@@ -25,7 +31,51 @@
   thread_local NonTrivial2 nt22;
 }
 
+// CHECK-LABEL: define void @_Z1gv
+void g() {
+  // CHECK-NOT: __cxa_atexit
+  [[clang::no_destroy]] static NonTrivial2 nt21;
+  // CHECK-NOT: _tlv_atexit
+  [[clang::no_destroy]] thread_local NonTrivial2 nt22;
+}
+
+// CHECK-LABEL: define internal void @__cxx_global_var_init
 // CHECK: __cxa_atexit{{.*}}_ZN10NonTrivialD1Ev
 [[clang::always_destroy]] NonTrivial nt3;
+// CHECK-LABEL: define internal void @__cxx_global_var_init
 // CHECK: _tlv_atexit{{.*}}_ZN10NonTrivialD1Ev
 [[clang::always_destroy]] thread_local NonTrivial nt4;
+
+
+struct NonTrivial3 {
+  NonTrivial3();
+  ~NonTrivial3();
+};
+
+[[clang::no_destroy]] NonTrivial3 arr[10];
+
+// CHECK-LABEL: define internal void @__cxx_global_var_init

[PATCH] D61667: Assume `__cxa_allocate_exception` returns an under-aligned memory on Darwin if the version of libc++abi isn't new enough to include the fix in r319123

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



Comment at: lib/Sema/SemaExprCXX.cpp:946
+  // is larger than the minimum alignment the libc++abi runtime guarantees.
+  if (Context.getTargetInfo().getTriple().isOSDarwin()) {
+CharUnits TypeAlign = Context.getTypeAlignInChars(Ty);

ahatanak wrote:
> rjmccall wrote:
> > Why is this a Darwin-specific check?  Seems like it ought to be an 
> > Itanium-specific check, but it's equally applicable on Linux to 
> > highly-aligned types.
> Except when the C++ ABI is Microsoft, this is always diagnosed.
Thanks.  Please don't refer to `libc++abi` in this comment, though, since this 
is a general Itanium issue and not specific to any particular implementation.  
How about something like:

  Under the Itanium C++ ABI, memory for the exception object is allocated by 
the runtime with no ability for the compiler to request additional alignment.  
Warn if the exception type requires alignment beyond the minimum guaranteed by 
the target C++ runtime.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61667



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


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

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



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:13121-13122
+  if (VD->isNoDestroy(getASTContext()) &&
+  !(VD->getType()->isArrayType() && getLangOpts().Exceptions &&
+VD->isStaticLocal()))
 return;

erik.pilkington wrote:
> rjmccall wrote:
> > erik.pilkington wrote:
> > > rjmccall wrote:
> > > > rsmith wrote:
> > > > > Hmm, perhaps it would be cleaner if the destructor for array elements 
> > > > > were required by the initialization of the array, instead of here. 
> > > > > That's how this works for struct aggregate initialization (see 
> > > > > `InitListChecker::CheckStructUnionTypes`), and (indirectly) how it 
> > > > > works for initialization by constructor, and so on. And it reflects 
> > > > > the fact that it's the initialization process that needs the array 
> > > > > element destructor, not the destruction of the variable (which never 
> > > > > happens).
> > > > > 
> > > > > For the case of aggregate initialization of an array, we appear to 
> > > > > fail to implement [dcl.init.aggr]/8:
> > > > > 
> > > > > """
> > > > > The destructor for each element of class type is potentially invoked 
> > > > > (11.3.6) from the context where the aggregate initialization occurs. 
> > > > > [Note: This provision ensures that destructors can be called for 
> > > > > fully-constructed subobjects in case an exception is thrown (14.2). — 
> > > > > end note]
> > > > > """
> > > > > 
> > > > > (But there doesn't appear to be any corresponding wording for default 
> > > > > / value initialization of arrays. See also the special case at the 
> > > > > end of `BuildCXXNewExpr`.)
> > > > That makes sense to me.  The default/value initialization case seems 
> > > > like an obvious oversight in the standard, but I think it might be a 
> > > > distinction without a difference: the special cases for base-or-member 
> > > > initializers and new-expressions might cover literally every situation 
> > > > where initialization doesn't come with an adjacent need for 
> > > > non-exceptional destruction.
> > > Sure, done. Moving this to initialization time seems like a nice cleanup.
> > Hmm.  What I just mentioned for the documentation is relevant here, right?  
> > We only need to check access to subobject destructors if exceptions are 
> > enabled, so this attempt to avoid duplicate diagnostics might leave us not 
> > flagging the use if exceptions are disabled.
> > 
> > Well, maybe the check isn't actually restricted that way, hmm.  Shouldn't 
> > it be?
> I thought we tried in general to keep `-fno-exceptions` as similar to normal 
> C++ as possible, rather than invent new language rules for it (even when they 
> make sense).
There's at least one other place where `-fno-exceptions` changes the language 
rules: we don't look for `operator delete` in a new-expression.  It does look 
like that's all I was remembering, though, and that we don't generally apply 
that same principle to destructors, so feel free to ignore my comment.

Still, could you make sure there's a test case that tests that we check access 
to the destructor of an array variable even when exceptions are disabled, since 
that's the interesting corner case created by this new condition?


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

https://reviews.llvm.org/D61165



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


[PATCH] D61769: [clang] Regenerate AST matcher docs 

2019-05-09 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The documentation seems to have been manually edited in 
https://reviews.llvm.org/rGa282bde69e375985edd4c371b79864f617380ad5.

This commit regenerates the documentation and commits the resulting diff.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D61769

Files:
  clang/docs/LibASTMatchersReference.html


Index: clang/docs/LibASTMatchersReference.html
===
--- clang/docs/LibASTMatchersReference.html
+++ clang/docs/LibASTMatchersReference.html
@@ -3616,30 +3616,6 @@
 
 
 
-Matcherhttps://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html;>ObjCMethodDeclisClassMethod
-Returns true when the 
Objective-C method declaration is a class method.
-
-Example
-matcher = objcMethodDecl(isClassMethod())
-matches
-  @interface I + (void)foo; @end
-but not
-  @interface I - (void)bar; @end
-
-
-
-Matcherhttps://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html;>ObjCMethodDeclisInstanceMethod
-Returns true when 
the Objective-C method declaration is an instance method.
-
-Example
-matcher = objcMethodDecl(isInstanceMethod())
-matches
-  @interface I - (void)bar; @end
-but not
-  @interface I + (void)foo; @end
-
-
-
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html;>ObjCMessageExprmatchesSelectorstd::string 
RegExp
 Matches ObjC 
selectors whose name contains
 a substring matched by the given RegExp.
@@ -3662,6 +3638,18 @@
 
 
 
+Matcherhttps://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html;>ObjCMethodDeclisClassMethod
+Returns true when the 
Objective-C method declaration is a class method.
+
+Example
+matcher = objcMethodDecl(isClassMethod())
+matches
+@interface I + (void)foo; @end
+but not
+@interface I - (void)bar; @end
+
+
+
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html;>ObjCMethodDeclisDefinition
 Matches if a 
declaration has a body attached.
 
@@ -3684,6 +3672,18 @@
 
 
 
+Matcherhttps://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html;>ObjCMethodDeclisInstanceMethod
+Returns true when 
the Objective-C method declaration is an instance method.
+
+Example
+matcher = objcMethodDecl(isInstanceMethod())
+matches
+@interface I - (void)bar; @end
+but not
+@interface I + (void)foo; @end
+
+
+
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html;>ParmVarDeclhasDefaultArgument
 Matches a 
declaration that has default arguments.
 


Index: clang/docs/LibASTMatchersReference.html
===
--- clang/docs/LibASTMatchersReference.html
+++ clang/docs/LibASTMatchersReference.html
@@ -3616,30 +3616,6 @@
 
 
 
-Matcherhttps://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html;>ObjCMethodDeclisClassMethod
-Returns true when the Objective-C method declaration is a class method.
-
-Example
-matcher = objcMethodDecl(isClassMethod())
-matches
-  @interface I + (void)foo; @end
-but not
-  @interface I - (void)bar; @end
-
-
-
-Matcherhttps://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html;>ObjCMethodDeclisInstanceMethod
-Returns true when the Objective-C method declaration is an instance method.
-
-Example
-matcher = objcMethodDecl(isInstanceMethod())
-matches
-  @interface I - (void)bar; @end
-but not
-  @interface I + (void)foo; @end
-
-
-
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html;>ObjCMessageExprmatchesSelectorstd::string RegExp
 Matches ObjC selectors whose name contains
 a substring matched by the given RegExp.
@@ -3662,6 +3638,18 @@
 
 
 
+Matcherhttps://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html;>ObjCMethodDeclisClassMethod
+Returns true when the Objective-C method declaration is a class method.
+
+Example
+matcher = objcMethodDecl(isClassMethod())
+matches
+@interface I + (void)foo; @end
+but not
+@interface I - (void)bar; @end
+
+
+
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html;>ObjCMethodDeclisDefinition
 Matches if a declaration has a body attached.
 
@@ -3684,6 +3672,18 @@
 
 
 
+Matcherhttps://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html;>ObjCMethodDeclisInstanceMethod
+Returns true when the Objective-C method declaration is an instance method.
+
+Example
+matcher = objcMethodDecl(isInstanceMethod())
+matches
+@interface I - (void)bar; @end
+but not
+@interface I + (void)foo; @end
+
+
+
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html;>ParmVarDeclhasDefaultArgument
 Matches a declaration that has default arguments.
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61667: Assume `__cxa_allocate_exception` returns an under-aligned memory on Darwin if the version of libc++abi isn't new enough to include the fix in r319123

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



Comment at: include/clang/Basic/TargetInfo.h:643
+  /// runtime, such as those using the Itanium C++ ABI.
+  virtual unsigned getExnObjectAlignment() const {
+// Itanium says that an _Unwind_Exception has to be "double-word"

rjmccall wrote:
> CharUnits?
I added a function to ASTContext that returns CharUnits.



Comment at: lib/Sema/SemaExprCXX.cpp:946
+  // is larger than the minimum alignment the libc++abi runtime guarantees.
+  if (Context.getTargetInfo().getTriple().isOSDarwin()) {
+CharUnits TypeAlign = Context.getTypeAlignInChars(Ty);

rjmccall wrote:
> Why is this a Darwin-specific check?  Seems like it ought to be an 
> Itanium-specific check, but it's equally applicable on Linux to 
> highly-aligned types.
Except when the C++ ABI is Microsoft, this is always diagnosed.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61667



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


[PATCH] D61667: Assume `__cxa_allocate_exception` returns an under-aligned memory on Darwin if the version of libc++abi isn't new enough to include the fix in r319123

2019-05-09 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 198939.
ahatanak marked 6 inline comments as done.
ahatanak added a comment.
Herald added a subscriber: aheejin.

Address review comments.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61667

Files:
  include/clang/AST/ASTContext.h
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/TargetInfo.h
  lib/Basic/Targets/OSTargets.h
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/Sema/SemaExprCXX.cpp
  test/CodeGenCXX/eh.cpp
  test/SemaCXX/warn-overaligned-type-thrown.cpp

Index: test/SemaCXX/warn-overaligned-type-thrown.cpp
===
--- /dev/null
+++ test/SemaCXX/warn-overaligned-type-thrown.cpp
@@ -0,0 +1,66 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.99 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions -DUNDERALIGNED %s
+// RUN: %clang_cc1 -triple arm64-apple-ios10 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions -DUNDERALIGNED %s
+// RUN: %clang_cc1 -triple arm64-apple-tvos10 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions -DUNDERALIGNED %s
+// RUN: %clang_cc1 -triple arm64-apple-watchos4 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions -DUNDERALIGNED %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.14 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s
+// RUN: %clang_cc1 -triple arm64-apple-ios12 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s
+// RUN: %clang_cc1 -triple arm64-apple-tvos12 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s
+// RUN: %clang_cc1 -triple arm64-apple-watchos5 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s
+// RUN: %clang_cc1 -triple arm-linux-gnueabi -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s
+// RUN: %clang_cc1 -triple aarch64-linux-gnueabi -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s
+// RUN: %clang_cc1 -triple mipsel-linux-gnu -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s
+// RUN: %clang_cc1 -triple mips64el-linux-gnu -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s
+// RUN: %clang_cc1 -triple wasm64-unknown-unknown -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.14 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions -Wno-underaligned-exception-object -DNODIAG %s
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions -DNODIAG %s
+
+struct S0 {
+  S0();
+  int m;
+};
+
+struct Overaligned1 {
+  Overaligned1();
+  int __attribute__((aligned(16))) m;
+};
+
+struct __attribute__((aligned(16))) Overaligned2 {
+  Overaligned2();
+  int m;
+};
+
+struct Overaligned3 {
+  Overaligned3();
+  int __attribute__((aligned(64))) m;
+};
+
+void test0() {
+  throw S0();
+}
+
+void test1() {
+  throw Overaligned1();
+}
+
+void test2() {
+  throw Overaligned2();
+}
+
+void test3() {
+  throw Overaligned3();
+}
+
+#if defined(NODIAG)
+// expected-no-diagnostics
+#elif defined(UNDERALIGNED)
+// expected-warning@-14 {{underaligned exception object thrown}}
+// expected-note@-15 {{(16 bytes) is larger than the supported alignment of C++ exception objects on this target (8 bytes)}}
+// expected-warning@-12 {{underaligned exception object thrown}}
+// expected-note@-13 {{(16 bytes) is larger than the supported alignment of C++ exception objects on this target (8 bytes)}}
+// expected-warning@-10 {{underaligned exception object thrown}}
+// expected-note@-11 {{(64 bytes) is larger than the supported alignment of C++ exception objects on this target (8 bytes)}}
+#else
+// expected-warning@-13 {{underaligned exception object thrown}}
+// expected-note@-14 {{(64 bytes) is larger than the supported alignment of C++ exception objects on this target (16 bytes)}}
+#endif
Index: test/CodeGenCXX/eh.cpp
===
--- test/CodeGenCXX/eh.cpp
+++ test/CodeGenCXX/eh.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -triple x86_64-apple-darwin -std=c++11 -emit-llvm %s -o - \
-// RUN:   | FileCheck %s
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -triple x86_64-apple-macosx10.13.99 -std=c++11 -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=UNALIGNED %s
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -triple x86_64-apple-macosx10.14 -std=c++11 -emit-llvm -o - %s | FileCheck --check-prefix=CHECK --check-prefix=ALIGNED %s
 
 struct test1_D {
   double d;
@@ -13,7 +13,8 @@
 // CHECK:   [[EXNOBJ:%.*]] = call i8* @__cxa_allocate_exception(i64 8)
 // CHECK-NEXT:  [[EXN:%.*]] = bitcast i8* [[EXNOBJ]] to [[DSTAR:%[^*]*\*]]
 // CHECK-NEXT:  

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

2019-05-09 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington marked 2 inline comments as done.
erik.pilkington added inline comments.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:13121-13122
+  if (VD->isNoDestroy(getASTContext()) &&
+  !(VD->getType()->isArrayType() && getLangOpts().Exceptions &&
+VD->isStaticLocal()))
 return;

rjmccall wrote:
> erik.pilkington wrote:
> > rjmccall wrote:
> > > rsmith wrote:
> > > > Hmm, perhaps it would be cleaner if the destructor for array elements 
> > > > were required by the initialization of the array, instead of here. 
> > > > That's how this works for struct aggregate initialization (see 
> > > > `InitListChecker::CheckStructUnionTypes`), and (indirectly) how it 
> > > > works for initialization by constructor, and so on. And it reflects the 
> > > > fact that it's the initialization process that needs the array element 
> > > > destructor, not the destruction of the variable (which never happens).
> > > > 
> > > > For the case of aggregate initialization of an array, we appear to fail 
> > > > to implement [dcl.init.aggr]/8:
> > > > 
> > > > """
> > > > The destructor for each element of class type is potentially invoked 
> > > > (11.3.6) from the context where the aggregate initialization occurs. 
> > > > [Note: This provision ensures that destructors can be called for 
> > > > fully-constructed subobjects in case an exception is thrown (14.2). — 
> > > > end note]
> > > > """
> > > > 
> > > > (But there doesn't appear to be any corresponding wording for default / 
> > > > value initialization of arrays. See also the special case at the end of 
> > > > `BuildCXXNewExpr`.)
> > > That makes sense to me.  The default/value initialization case seems like 
> > > an obvious oversight in the standard, but I think it might be a 
> > > distinction without a difference: the special cases for base-or-member 
> > > initializers and new-expressions might cover literally every situation 
> > > where initialization doesn't come with an adjacent need for 
> > > non-exceptional destruction.
> > Sure, done. Moving this to initialization time seems like a nice cleanup.
> Hmm.  What I just mentioned for the documentation is relevant here, right?  
> We only need to check access to subobject destructors if exceptions are 
> enabled, so this attempt to avoid duplicate diagnostics might leave us not 
> flagging the use if exceptions are disabled.
> 
> Well, maybe the check isn't actually restricted that way, hmm.  Shouldn't it 
> be?
I thought we tried in general to keep `-fno-exceptions` as similar to normal 
C++ as possible, rather than invent new language rules for it (even when they 
make sense).



Comment at: clang/lib/Sema/SemaInit.cpp:6328
+if (hasAccessibleDestructor(S.Context.getBaseElementType(AT), Loc, S))
+  return ExprError();
+

rjmccall wrote:
> There's no way that the right semantics are to return failure if the type has 
> an accessible destructor. :)  Looks like the function is misnamed.  Also, it 
> should also be named something that makes it clear that it's more than a 
> predicate, it's actually checking access to / marking the use of the 
> destructor.  I know this is an existing function, but could you take care of 
> that?
Yeah, the name doesn't make much sense. I'll update it...


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

https://reviews.llvm.org/D61165



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


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

2019-05-09 Thread Bernhard Manfred Gruber via Phabricator via cfe-commits
bernhardmgruber updated this revision to Diff 198937.
bernhardmgruber marked 3 inline comments as done.
bernhardmgruber added a comment.

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


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

https://reviews.llvm.org/D56160

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
  clang-tidy/modernize/UseTrailingReturnTypeCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-trailing-return-type.rst
  test/clang-tidy/modernize-use-trailing-return-type.cpp

Index: test/clang-tidy/modernize-use-trailing-return-type.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-trailing-return-type.cpp
@@ -0,0 +1,563 @@
+// RUN: %check_clang_tidy %s modernize-use-trailing-return-type %t -- -- --std=c++14 -fdeclspec -fexceptions
+
+namespace std {
+template 
+class vector;
+
+template 
+class array;
+
+class string;
+
+template 
+auto declval() -> T;
+}
+
+//
+// Functions
+//
+
+int f();
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
+// CHECK-FIXES: {{^}}auto f() -> int;{{$}}
+int ((f))();
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
+// CHECK-FIXES: {{^}}auto ((f))() -> int;{{$}}
+int f(int);
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
+// CHECK-FIXES: {{^}}auto f(int) -> int;{{$}}
+int f(int arg);
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
+// CHECK-FIXES: {{^}}auto f(int arg) -> int;{{$}}
+int f(int arg1, int arg2, int arg3);
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
+// CHECK-FIXES: {{^}}auto f(int arg1, int arg2, int arg3) -> int;{{$}}
+int f(int arg1, int arg2, int arg3, ...);
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
+// CHECK-FIXES: {{^}}auto f(int arg1, int arg2, int arg3, ...) -> int;{{$}}
+template  int f(T t);
+// CHECK-MESSAGES: :[[@LINE-1]]:27: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
+// CHECK-FIXES: {{^}}template  auto f(T t) -> int;{{$}}
+
+//
+// Functions with formatting
+//
+
+int a1() { return 42; }
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
+// CHECK-FIXES: {{^}}auto a1() -> int { return 42; }{{$}}
+int a2() {
+return 42;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
+// CHECK-FIXES: {{^}}auto a2() -> int {{{$}}
+int a3()
+{
+return 42;
+}
+// CHECK-MESSAGES: :[[@LINE-4]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
+// CHECK-FIXES: {{^}}auto a3() -> int{{$}}
+int a4(int   arg   )   ;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
+// CHECK-FIXES: {{^}}auto a4(int   arg   ) -> int   ;{{$}}
+int a5
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
+// CHECK-FIXES: {{^}}auto a5{{$}}
+(int arg);
+// CHECK-FIXES: {{^}}(int arg) -> int;{{$}}
+const
+int
+*
+a7
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
+()
+// CHECK-FIXES: {{^}}() -> const{{$}}
+// CHECK-FIXES: {{^}}int{{$}}
+// CHECK-FIXES: {{^}}*{{$}}
+;
+
+int*a7(int arg);
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
+// CHECK-FIXES: {{^}}auto a7(int arg) -> int*;{{$}}
+template class C>
+Ca8(int arg);
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
+// CHECK-FIXES: {{^}}auto a8(int arg) -> C;{{$}}
+
+
+//
+// Functions with qualifiers and specifiers
+//
+
+inline int d1(int arg);
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
+// CHECK-FIXES: {{^}}inline auto d1(int arg) -> int;{{$}}
+extern "C" int d2(int arg);
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
+// CHECK-FIXES: {{^}}extern "C" auto d2(int arg) -> int;{{$}}
+inline int d3(int arg) noexcept(true);
+// 

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

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



Comment at: clang/include/clang/Basic/AttrDocs.td:3915
+Here, if the construction of `array[9]` fails with an exception, `array[0..8]`
+will be destroyed, so the element's destructor needs to be accessible.
   }];

Probably worth adding somewhere in here that is only required if exceptions are 
enabled, since disabling exceptions is a pretty common configuration.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:13121-13122
+  if (VD->isNoDestroy(getASTContext()) &&
+  !(VD->getType()->isArrayType() && getLangOpts().Exceptions &&
+VD->isStaticLocal()))
 return;

erik.pilkington wrote:
> rjmccall wrote:
> > rsmith wrote:
> > > Hmm, perhaps it would be cleaner if the destructor for array elements 
> > > were required by the initialization of the array, instead of here. That's 
> > > how this works for struct aggregate initialization (see 
> > > `InitListChecker::CheckStructUnionTypes`), and (indirectly) how it works 
> > > for initialization by constructor, and so on. And it reflects the fact 
> > > that it's the initialization process that needs the array element 
> > > destructor, not the destruction of the variable (which never happens).
> > > 
> > > For the case of aggregate initialization of an array, we appear to fail 
> > > to implement [dcl.init.aggr]/8:
> > > 
> > > """
> > > The destructor for each element of class type is potentially invoked 
> > > (11.3.6) from the context where the aggregate initialization occurs. 
> > > [Note: This provision ensures that destructors can be called for 
> > > fully-constructed subobjects in case an exception is thrown (14.2). — end 
> > > note]
> > > """
> > > 
> > > (But there doesn't appear to be any corresponding wording for default / 
> > > value initialization of arrays. See also the special case at the end of 
> > > `BuildCXXNewExpr`.)
> > That makes sense to me.  The default/value initialization case seems like 
> > an obvious oversight in the standard, but I think it might be a distinction 
> > without a difference: the special cases for base-or-member initializers and 
> > new-expressions might cover literally every situation where initialization 
> > doesn't come with an adjacent need for non-exceptional destruction.
> Sure, done. Moving this to initialization time seems like a nice cleanup.
Hmm.  What I just mentioned for the documentation is relevant here, right?  We 
only need to check access to subobject destructors if exceptions are enabled, 
so this attempt to avoid duplicate diagnostics might leave us not flagging the 
use if exceptions are disabled.

Well, maybe the check isn't actually restricted that way, hmm.  Shouldn't it be?



Comment at: clang/lib/Sema/SemaInit.cpp:6328
+if (hasAccessibleDestructor(S.Context.getBaseElementType(AT), Loc, S))
+  return ExprError();
+

There's no way that the right semantics are to return failure if the type has 
an accessible destructor. :)  Looks like the function is misnamed.  Also, it 
should also be named something that makes it clear that it's more than a 
predicate, it's actually checking access to / marking the use of the 
destructor.  I know this is an existing function, but could you take care of 
that?


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

https://reviews.llvm.org/D61165



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


[PATCH] D61467: [Rewrite] Extend to further accept CharSourceRange

2019-05-09 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added inline comments.



Comment at: clang/unittests/Rewrite/RewriterTest.cpp:1
+//===- unittests/Rewrite/RewriteTest.cpp - RewriteBuffer tests 
===//
+//

Oops. Need to change the description here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61467



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


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

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

This always includes the declare file but not the define file, correct?

Could we have 4 tests that are compiled in target mode with:

  // with and without math.h/cmath (clang/clang++)
  #include 
  
  long abs(long __i) { return (__i < 0 ? -i : i); }


Repository:
  rC Clang

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

https://reviews.llvm.org/D61765



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


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

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

- Remove define.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61765

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

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

[PATCH] D61467: [Rewrite] Extend to further accept CharSourceRange

2019-05-09 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added a comment.

Ping.  This seems like a straight-forward extension to the Rewriter API.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61467



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


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

2019-05-09 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea created this revision.
gtbercea added reviewers: jdoerfert, ABataev, hfinkel, caomhin.
Herald added subscribers: cfe-commits, guansong, mgorny.
Herald added a project: clang.

This patches fixes an issue in which the __clang_cuda_cmath.h header is being 
included even when cmath or math.h headers are not included.


Repository:
  rC Clang

https://reviews.llvm.org/D61765

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

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

[PATCH] D61646: Include corecrt.h/vcruntime.h to improve MS compatibility

2019-05-09 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a subscriber: echristo.
rnk added a comment.

@echristo mentioned that this patch was also causing issues in another 
freestanding environment where _MSC_VER was defined, but no corecrt.h header 
existed on the system. So, I think it's likely that we don't want to do this in 
the long run. The compiler-provided headers and system headers are already too 
entangled, and this is one more dependency between them.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D61646



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


r360387 - Remember to decay arrays to pointers before checking whether the

2019-05-09 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu May  9 15:22:48 2019
New Revision: 360387

URL: http://llvm.org/viewvc/llvm-project?rev=360387=rev
Log:
Remember to decay arrays to pointers before checking whether the
left-hand side of an -> operator is a pointer to class type.

Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/test/Parser/cxx-class.cpp

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=360387=360386=360387=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Thu May  9 15:22:48 2019
@@ -6790,9 +6790,12 @@ ExprResult Sema::ActOnStartCXXMemberRefe
   FirstIteration = false;
 }
 
-if (OpKind == tok::arrow &&
-(BaseType->isPointerType() || BaseType->isObjCObjectPointerType()))
-  BaseType = BaseType->getPointeeType();
+if (OpKind == tok::arrow) {
+  if (BaseType->isPointerType())
+BaseType = BaseType->getPointeeType();
+  else if (auto *AT = Context.getAsArrayType(BaseType))
+BaseType = AT->getElementType();
+}
   }
 
   // Objective-C properties allow "." access on Objective-C pointer types,

Modified: cfe/trunk/test/Parser/cxx-class.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-class.cpp?rev=360387=360386=360387=diff
==
--- cfe/trunk/test/Parser/cxx-class.cpp (original)
+++ cfe/trunk/test/Parser/cxx-class.cpp Thu May  9 15:22:48 2019
@@ -283,6 +283,19 @@ struct C {} decltype(D())::c; // expecte
 #endif
 }
 
+namespace ArrayMemberAccess {
+  struct A {
+int x;
+template int f() const;
+  };
+  void f(const A ()[]) {
+// OK: not a template-id.
+bool cond = a->x < 10 && a->x > 0;
+// OK: a template-id.
+a->f();
+  }
+}
+
 // PR11109 must appear at the end of the source file
 class pr11109r3 { // expected-note{{to match this '{'}}
   public // expected-error{{expected ':'}} expected-error{{expected '}'}} 
expected-error{{expected ';' after class}}


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


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

2019-05-09 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington updated this revision to Diff 198916.
erik.pilkington marked 6 inline comments as done.
erik.pilkington added a comment.

Address review comments. Also remove the special case where we wouldn't check a 
destructor for an array in `-fno-exceptions` mode. This seems inconsistent with 
both how we're treating `-fno-exceptions` in general, and inconsistent with 
other cases of aggregate initialization (i.e. we still check struct members 
here).

In D61165#1494250 , @rjmccall wrote:

> All of the IRGen changes in this patch are unnecessary according to the model 
> we've worked out, right?  The fix is just to mark the destructor as still 
> used when we're constructing an array.


Yeah, the IRGen changes were to stop clang from referencing a non-existant dtor 
for a global no_destroy array, but if we're using it regardless then its not 
necessary. New patch removes it.


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

https://reviews.llvm.org/D61165

Files:
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/test/CodeGenCXX/no_destroy.cpp
  clang/test/SemaCXX/aggregate-initialization.cpp
  clang/test/SemaCXX/no_destroy.cpp

Index: clang/test/SemaCXX/no_destroy.cpp
===
--- clang/test/SemaCXX/no_destroy.cpp
+++ clang/test/SemaCXX/no_destroy.cpp
@@ -1,11 +1,13 @@
-// RUN: %clang_cc1 -DNO_DTORS -fno-c++-static-destructors -verify %s
-// RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -DNO_DTORS -DNO_EXCEPTIONS -fno-c++-static-destructors -verify %s
+// RUN: %clang_cc1 -DNO_EXCEPTIONS -verify %s
+// RUN: %clang_cc1 -DNO_DTORS -fexceptions -fno-c++-static-destructors -verify %s
+// RUN: %clang_cc1 -fexceptions -verify %s
 
 struct SecretDestructor {
 #ifndef NO_DTORS
   // expected-note@+2 4 {{private}}
 #endif
-private: ~SecretDestructor(); // expected-note 2 {{private}}
+private: ~SecretDestructor(); // expected-note + {{private}}
 };
 
 SecretDestructor sd1;
@@ -44,3 +46,30 @@
 
 [[clang::no_destroy(0)]] int no_args; // expected-error{{'no_destroy' attribute takes no arguments}}
 [[clang::always_destroy(0)]] int no_args2; // expected-error{{'always_destroy' attribute takes no arguments}}
+
+// expected-error@+1 {{calling a private destructor of class 'SecretDestructor'}}
+SecretDestructor arr[10];
+
+void local_arrays() {
+  // expected-error@+1 {{calling a private destructor of class 'SecretDestructor'}}
+  static SecretDestructor arr2[10];
+  // expected-error@+1 {{calling a private destructor of class 'SecretDestructor'}}
+  thread_local SecretDestructor arr3[10];
+}
+
+struct Base {
+  ~Base();
+};
+struct Derived1 {
+  Derived1(int);
+  Base b;
+};
+struct Derived2 {
+  Derived1 b;
+};
+
+void dontcrash() {
+  [[clang::no_destroy]] static Derived2 d2[] = {0, 0};
+}
+
+[[clang::no_destroy]] Derived2 d2[] = {0, 0};
Index: clang/test/SemaCXX/aggregate-initialization.cpp
===
--- clang/test/SemaCXX/aggregate-initialization.cpp
+++ clang/test/SemaCXX/aggregate-initialization.cpp
@@ -196,7 +196,7 @@
   struct Y { X x; };
 
   void test0() {
-auto *y = new Y {}; // expected-error {{temporary of type 'ElementDestructor::X' has private destructor}}
+auto *y = new Y {}; // expected-error {{calling a private destructor of class 'ElementDestructor::X}}
   }
 
   struct S0 { int f; ~S0() = delete; }; // expected-note 3 {{'~S0' has been explicitly marked deleted here}}
Index: clang/test/CodeGenCXX/no_destroy.cpp
===
--- clang/test/CodeGenCXX/no_destroy.cpp
+++ clang/test/CodeGenCXX/no_destroy.cpp
@@ -1,11 +1,14 @@
-// RUN: %clang_cc1 %s -emit-llvm -triple x86_64-apple-macosx10.13.0 -o - | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -triple x86_64-apple-macosx10.13.0 -o - | FileCheck %s --check-prefixes=CHECK,NO_EXCEPTIONS
+// RUN: %clang_cc1 -fexceptions %s -emit-llvm -triple x86_64-apple-macosx10.13.0 -o - | FileCheck %s --check-prefixes=CHECK,EXCEPTIONS
 
 struct NonTrivial {
   ~NonTrivial();
 };
 
+// CHECK-LABEL: define internal void @__cxx_global_var_init
 // CHECK-NOT: __cxa_atexit{{.*}}_ZN10NonTrivialD1Ev
 [[clang::no_destroy]] NonTrivial nt1;
+// CHECK-LABEL: define internal void @__cxx_global_var_init
 // CHECK-NOT: _tlv_atexit{{.*}}_ZN10NonTrivialD1Ev
 [[clang::no_destroy]] thread_local NonTrivial nt2;
 
@@ -13,11 +16,14 @@
   ~NonTrivial2();
 };
 
+// CHECK-LABEL: define internal void @__cxx_global_var_init
 // CHECK: __cxa_atexit{{.*}}_ZN11NonTrivial2D1Ev
 NonTrivial2 nt21;
+// CHECK-LABEL: define internal void @__cxx_global_var_init
 // CHECK: _tlv_atexit{{.*}}_ZN11NonTrivial2D1Ev
 thread_local NonTrivial2 nt22;
 
+// CHECK-LABEL: define void @_Z1fv
 void f() {
   // CHECK: __cxa_atexit{{.*}}_ZN11NonTrivial2D1Ev
   static NonTrivial2 nt21;
@@ 

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

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



Comment at: clang/include/clang/Basic/AttrDocs.td:3897-3900
+This works in almost all cases, but if ``no_destroy`` is applied to a 
``static``
+or ``thread_local`` local builtin array variable and exceptions are enabled, 
the
+destructor is still needed to perform cleanup if the construction of an element
+of the array throws. For instance:

rsmith wrote:
> I think this is the wrong way to think about and describe this. 
> `[[no_destroy]]` removes the need for the type of the variable to have a 
> usable destructor. But all immediate subobjects still need usable 
> destructors, in case an exception is thrown during the object's construction. 
> This is then identical to the constraints on `new T` -- subobjects of `T` 
> (including array elements) still need to be destructible, but `T` itself does 
> not.
Sure, that makes sense. The new patch rephrases this.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:13119
+  // variable is static local array and exceptions are enabled, since then we
+  // need to clean up the elements.
+  if (VD->isNoDestroy(getASTContext()) &&

rjmccall wrote:
> This isn't "emitting" the destructor, it's "using" it.  Also, the comment 
> should make it clear that this is about aggregate initialization in general, 
> and it should contain a FIXME if there's part of that rule we're not 
> implementing correctly.
Are you alluding to the CodeGen bug? That seems unrelated to this function. 



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:13121-13122
+  if (VD->isNoDestroy(getASTContext()) &&
+  !(VD->getType()->isArrayType() && getLangOpts().Exceptions &&
+VD->isStaticLocal()))
 return;

rjmccall wrote:
> rsmith wrote:
> > Hmm, perhaps it would be cleaner if the destructor for array elements were 
> > required by the initialization of the array, instead of here. That's how 
> > this works for struct aggregate initialization (see 
> > `InitListChecker::CheckStructUnionTypes`), and (indirectly) how it works 
> > for initialization by constructor, and so on. And it reflects the fact that 
> > it's the initialization process that needs the array element destructor, 
> > not the destruction of the variable (which never happens).
> > 
> > For the case of aggregate initialization of an array, we appear to fail to 
> > implement [dcl.init.aggr]/8:
> > 
> > """
> > The destructor for each element of class type is potentially invoked 
> > (11.3.6) from the context where the aggregate initialization occurs. [Note: 
> > This provision ensures that destructors can be called for fully-constructed 
> > subobjects in case an exception is thrown (14.2). — end note]
> > """
> > 
> > (But there doesn't appear to be any corresponding wording for default / 
> > value initialization of arrays. See also the special case at the end of 
> > `BuildCXXNewExpr`.)
> That makes sense to me.  The default/value initialization case seems like an 
> obvious oversight in the standard, but I think it might be a distinction 
> without a difference: the special cases for base-or-member initializers and 
> new-expressions might cover literally every situation where initialization 
> doesn't come with an adjacent need for non-exceptional destruction.
Sure, done. Moving this to initialization time seems like a nice cleanup.


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

https://reviews.llvm.org/D61165



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


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

2019-05-09 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added inline comments.



Comment at: lib/Frontend/DependencyFile.cpp:279
+  if (DependencyFilter.size() &&
+  strncmp(Filename, DependencyFilter.c_str(), DependencyFilter.size()) == 
0)
+// Remove dependencies that are prefixed by the Filter string.

mibintc wrote:
> I wasn't sure about using strncmp to do the prefix comparison, but i checked 
> around in the clang code and saw strncmp used in several places so I thought 
> it would be acceptable. 
DependencyFilter.compare(Filename)?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D61743



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


[PATCH] D60974: Clang IFSO driver action.

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

addressing a lot of @compnerd 's feedback. Still lots of templating.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60974

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

Index: llvm/lib/TextAPI/ELF/TBEHandler.cpp
===
--- llvm/lib/TextAPI/ELF/TBEHandler.cpp
+++ llvm/lib/TextAPI/ELF/TBEHandler.cpp
@@ -134,6 +134,7 @@
 IO.mapRequired("TbeVersion", Stub.TbeVersion);
 IO.mapOptional("SoName", Stub.SoName);
 IO.mapRequired("Arch", (ELFArchMapper &)Stub.Arch);
+IO.mapOptional("Endian", Stub.Endian);
 IO.mapOptional("NeededLibs", Stub.NeededLibs);
 IO.mapRequired("Symbols", Stub.Symbols);
   }
Index: llvm/include/llvm/TextAPI/ELF/ELFStub.h
===
--- llvm/include/llvm/TextAPI/ELF/ELFStub.h
+++ llvm/include/llvm/TextAPI/ELF/ELFStub.h
@@ -55,6 +55,7 @@
   VersionTuple TbeVersion;
   Optional SoName;
   ELFArch Arch;
+  Optional Endian;
   std::vector NeededLibs;
   std::set Symbols;
 
Index: clang/test/IFSO/foo.cpp
===
--- /dev/null
+++ clang/test/IFSO/foo.cpp
@@ -0,0 +1,57 @@
+// Using %clang instead of %clang_cc1 because of -fvisibility
+// RUN: %clang -target x86_64-linux-gnu -emit-interface-stubs -interface-stubs-version=tapi-tbe -fvisibility=hidden %s -o - | FileCheck --check-prefix=CHECK-HIDDEN %s
+// RUN: %clang -target x86_64-linux-gnu -emit-interface-stubs -interface-stubs-version=tapi-tbe %s -o - | FileCheck %s
+
+// CHECK-HIDDEN-NOT: _Z4fbarff
+// CHECK: _Z4fbarff
+
+
+
+
+// CHECK-HIDDEN-NOT: _Z3fooii
+// CHECK-NOT:_Z3fooii
+
+
+
+#include "foo-inline.h"
+
+__attribute__ ((visibility ("hidden"))) int foo(int a, int b) { return a + b; }
+__attribute__ ((visibility ("default"))) int foo_default_visi(int a, int b) { return a + b; }
+
+
+__attribute__ ((visibility ("default"))) int fvih_1(int a, int b) { return a + fvih(); }
+
+
+__attribute__((weak)) int someWeakFunc() { return 42; }
+
+int dataA = 34;
+
+namespace baz {
+  template 
+  T add(T a, T b) {
+return a + b;
+  }
+}
+
+namespace n {
+  template 
+  struct __attribute__((__visibility__("default"))) S {
+S() = default;
+~S() = default;
+int __attribute__((__visibility__(("default" func() const { return 32; }
+int __attribute__((__visibility__(("hidden" operator()() const { return 53; }
+  };
+}
+
+template  T neverUsed(T t) { return t + 2; }
+
+template<> int neverUsed(int t);
+
+void g() { n::S()(); }
+
+namespace qux {
+int bar(int a, int b) { return baz::add(a, b); }
+}
+
+float fbar(float a, float b) { return baz::add(a, b); }
+
Index: clang/test/IFSO/foo-inline.h
===
--- /dev/null
+++ clang/test/IFSO/foo-inline.h
@@ -0,0 +1,6 @@
+
+inline int fvih() {
+static int fortytwo = 42;
+  return fortytwo;
+}
+
Index: clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -64,6 +64,10 @@
   case GenerateHeaderModule:
 return llvm::make_unique();
   case GeneratePCH:return llvm::make_unique();
+  case GenerateInterfaceYAMLExpV1:
+return llvm::make_unique();
+  case GenerateInterfaceTBEExpV1:
+return llvm::make_unique();
   case InitOnly:   return llvm::make_unique();
   case ParseSyntaxOnly:return llvm::make_unique();
   case ModuleFileInfo: return llvm::make_unique();
Index: clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
===
--- /dev/null
+++ clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
@@ -0,0 +1,280 @@
+//===--- InterfaceStubFunctionsConsumer.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/AST/RecursiveASTVisitor.h"
+#include 

[PATCH] D61756: Add a __FILE_NAME__ macro.

2019-05-09 Thread Shawn Landden via Phabricator via cfe-commits
shawnl requested changes to this revision.
shawnl added a comment.
This revision now requires changes to proceed.

There is no documentation specific to the #include directive. 
https://docs.microsoft.com/en-us/cpp/preprocessor/hash-include-directive-c-cpp?view=vs-2019

However, fileio treats / and \ the same, *sometimes*. 
https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file


Repository:
  rC Clang

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

https://reviews.llvm.org/D61756



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


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

2019-05-09 Thread Melanie Blower via Phabricator via cfe-commits
mibintc marked an inline comment as done.
mibintc added a comment.

added an inline comment about the use of strncmp




Comment at: lib/Frontend/DependencyFile.cpp:279
+  if (DependencyFilter.size() &&
+  strncmp(Filename, DependencyFilter.c_str(), DependencyFilter.size()) == 
0)
+// Remove dependencies that are prefixed by the Filter string.

I wasn't sure about using strncmp to do the prefix comparison, but i checked 
around in the clang code and saw strncmp used in several places so I thought it 
would be acceptable. 


Repository:
  rL LLVM

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

https://reviews.llvm.org/D61743



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


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

2019-05-09 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Thanks, I would like to do this for the sanitizers as well, since this is a 
constant pain point for users, who have to come up with an 
architecture-dependent filename (`clang_rt.asan-dynamic-$arch.lib` or 
something).




Comment at: clang/lib/Driver/ToolChains/Clang.cpp:787
 CmdArgs.push_back("-fprofile-instrument=clang");
+if (TC.getTriple().isOSWindows()) {
+  // Add dependent lib for clang_rt.profile

This won't work with ld.bfd, so I would restrict this to a Windows MSVC 
environment. For mingw, I'd expect the user to call the compiler to link, and 
the right library path to be supplied to the linker by the compiler driver.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61742



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


[PATCH] D61756: Add a __FILE_NAME__ macro.

2019-05-09 Thread Shawn Landden via Phabricator via cfe-commits
shawnl added inline comments.



Comment at: lib/Lex/PPMacroExpansion.cpp:1509
+if (LastSep == StringRef::npos && LangOpts.MicrosoftExt)
+  LastSep = PLFileName.find_last_of('\\');
+

What is the path name uses both \ and / to separate paths? I think this needs 
to be:
```
if (LangOpts.MicrosoftExt) {
  size_t BackSlash = PLFileName.take_back(PLFileName.size() - 
LastSep).find_last_of('\\');
  if (BackSlash != StringRef::npos)
LastSep = BackSlash;
}
```


Repository:
  rC Clang

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

https://reviews.llvm.org/D61756



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


[PATCH] D60974: Clang IFSO driver action.

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



Comment at: clang/lib/Frontend/FrontendActions.cpp:223
+for (auto *I : cast(ND)->decls())
+  HandleNamedDecl(dyn_cast(I), Symbols, RDO);
+return true;

compnerd wrote:
> Hmm, do we have a guarantee that the decl is named?  Could you not hit a 
> `_Static_assert` or `static_assert` in this traversal?  Or if it is a C++ 
> context, an `extern "C"` block?  What about `#pragma comment(...)`?  Please 
> add test cases for these.
HandleNamedDecl bails when the NamedDecl is not a NamedDecl. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60974



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


[PATCH] D61758: [driver][xray] fix the macOS support checker by supporting -macos triple in addition to -darwin

2019-05-09 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.
arphaman added a reviewer: dberris.
Herald added subscribers: dexonsmith, jkorous.
Herald added a project: clang.

The previous check incorrectly checked for macOS support by allowing `-darwin` 
triples only, and `-macos` triple was not supported.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D61758

Files:
  clang/lib/Driver/XRayArgs.cpp
  clang/test/Driver/XRay/xray-instrument-macos.c


Index: clang/test/Driver/XRay/xray-instrument-macos.c
===
--- /dev/null
+++ clang/test/Driver/XRay/xray-instrument-macos.c
@@ -0,0 +1,4 @@
+// RUN: %clang -o /dev/null -v -fxray-instrument -target 
x86_64-apple-macos10.11 -c %s
+// RUN: %clang -o /dev/null -v -fxray-instrument -target x86_64-apple-darwin15 
-c %s
+// REQUIRES-ANY: x86_64, x86_64h
+typedef int a;
Index: clang/lib/Driver/XRayArgs.cpp
===
--- clang/lib/Driver/XRayArgs.cpp
+++ clang/lib/Driver/XRayArgs.cpp
@@ -52,7 +52,7 @@
 } else if (Triple.isOSFreeBSD() ||
Triple.isOSOpenBSD() ||
Triple.isOSNetBSD() ||
-   Triple.getOS() == llvm::Triple::Darwin) {
+   Triple.isMacOSX()) {
   if (Triple.getArch() != llvm::Triple::x86_64) {
 D.Diag(diag::err_drv_clang_unsupported)
 << (std::string(XRayInstrumentOption) + " on " + Triple.str());


Index: clang/test/Driver/XRay/xray-instrument-macos.c
===
--- /dev/null
+++ clang/test/Driver/XRay/xray-instrument-macos.c
@@ -0,0 +1,4 @@
+// RUN: %clang -o /dev/null -v -fxray-instrument -target x86_64-apple-macos10.11 -c %s
+// RUN: %clang -o /dev/null -v -fxray-instrument -target x86_64-apple-darwin15 -c %s
+// REQUIRES-ANY: x86_64, x86_64h
+typedef int a;
Index: clang/lib/Driver/XRayArgs.cpp
===
--- clang/lib/Driver/XRayArgs.cpp
+++ clang/lib/Driver/XRayArgs.cpp
@@ -52,7 +52,7 @@
 } else if (Triple.isOSFreeBSD() ||
Triple.isOSOpenBSD() ||
Triple.isOSNetBSD() ||
-   Triple.getOS() == llvm::Triple::Darwin) {
+   Triple.isMacOSX()) {
   if (Triple.getArch() != llvm::Triple::x86_64) {
 D.Diag(diag::err_drv_clang_unsupported)
 << (std::string(XRayInstrumentOption) + " on " + Triple.str());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r360374 - NFC, make XFAIL work on macOS correctly for test/Driver/XRay/xray-instrument-os.c

2019-05-09 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu May  9 13:35:41 2019
New Revision: 360374

URL: http://llvm.org/viewvc/llvm-project?rev=360374=rev
Log:
NFC, make XFAIL work on macOS correctly for 
test/Driver/XRay/xray-instrument-os.c

The test 'test/Driver/XRay/xray-instrument-os.c' is supposed to XFAIL on 
-darwin triples.
However, LLVM can be configured to be built with a -macos triple instead, which 
is equivalent
to -darwin. This commit updates the XFAIL condition to also XFAIL with a -macos 
host triple.

Modified:
cfe/trunk/test/Driver/XRay/xray-instrument-os.c

Modified: cfe/trunk/test/Driver/XRay/xray-instrument-os.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/XRay/xray-instrument-os.c?rev=360374=360373=360374=diff
==
--- cfe/trunk/test/Driver/XRay/xray-instrument-os.c (original)
+++ cfe/trunk/test/Driver/XRay/xray-instrument-os.c Thu May  9 13:35:41 2019
@@ -1,4 +1,4 @@
 // RUN: not %clang -o /dev/null -v -fxray-instrument -c %s
-// XFAIL: -linux-, -freebsd, -darwin
+// XFAIL: -linux-, -freebsd, -darwin, -macos
 // REQUIRES-ANY: amd64, x86_64, x86_64h, arm, aarch64, arm64
 typedef int a;


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


[PATCH] D61756: Add a __FILE_NAME__ macro.

2019-05-09 Thread Kristina Brooks via Phabricator via cfe-commits
kristina updated this revision to Diff 198894.
kristina added a comment.

Fix style, remove unnecessary braces, add missing newline.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61756

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

Index: test/Preprocessor/file_name_macro.c
===
--- test/Preprocessor/file_name_macro.c
+++ test/Preprocessor/file_name_macro.c
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -E %s -I%S/Inputs | FileCheck -strict-whitespace %s
+// RUN: %clang_cc1 -fms-compatibility -DMS -E %s -I%S/Inputs | FileCheck -check-prefix=CHECK-MS -strict-whitespace %s 
+// RUN: %clang_cc1 -E %s -I%S/Inputs -DBADINC -verify
+
+#ifdef BADINC
+
+// Paranoia.
+
+__FILE_NAME__
+#include  // expected-error {{file not found}}
+__FILE_NAME__
+
+#else
+
+// Reference.
+1: "file_name_macro.c"
+
+
+// Ensure it expands correctly for this file.
+2: __FILE_NAME__
+
+// CHECK: {{^}}1: "file_name_macro.c"
+// CHECK: {{^}}2: "file_name_macro.c"
+
+// Test if inclusion works right.
+#ifdef MS
+#include 
+#else
+#include 
+#endif
+
+#include 
+
+
+// CHECK: {{^}}3: "file_name_macro_include.h"
+// CHECK: {{^}}4: "file_name_macro_include.h"
+// CHECK-NOT: {{^}}5: "file_name_macro_include.h"
+// CHECK-MS: {{^}}5: "file_name_macro_include.h"
+// CHECK: {{^}}6: "h"
+
+#endif
Index: test/Preprocessor/Inputs/include-subdir/h
===
--- test/Preprocessor/Inputs/include-subdir/h
+++ test/Preprocessor/Inputs/include-subdir/h
@@ -0,0 +1 @@
+6: __FILE_NAME__
Index: test/Preprocessor/Inputs/include-subdir/file_name_macro_include.h
===
--- test/Preprocessor/Inputs/include-subdir/file_name_macro_include.h
+++ test/Preprocessor/Inputs/include-subdir/file_name_macro_include.h
@@ -0,0 +1,6 @@
+3: __FILE_NAME__
+4: "file_name_macro_include.h"
+#ifdef MS
+// Should be the same even when included with backslash.
+5: __FILE_NAME__
+#endif
Index: lib/Lex/PPMacroExpansion.cpp
===
--- lib/Lex/PPMacroExpansion.cpp
+++ lib/Lex/PPMacroExpansion.cpp
@@ -363,6 +363,7 @@
   }
 
   // Clang Extensions.
+  Ident__FILE_NAME__  = RegisterBuiltinMacro(*this, "__FILE_NAME__");
   Ident__has_feature  = RegisterBuiltinMacro(*this, "__has_feature");
   Ident__has_extension= RegisterBuiltinMacro(*this, "__has_extension");
   Ident__has_builtin  = RegisterBuiltinMacro(*this, "__has_builtin");
@@ -1474,7 +1475,8 @@
 // __LINE__ expands to a simple numeric value.
 OS << (PLoc.isValid()? PLoc.getLine() : 1);
 Tok.setKind(tok::numeric_constant);
-  } else if (II == Ident__FILE__ || II == Ident__BASE_FILE__) {
+  else if (II == Ident__FILE__ || II == Ident__BASE_FILE__ ||
+   II == Ident__FILE_NAME__) {
 // C99 6.10.8: "__FILE__: The presumed name of the current source file (a
 // character string literal)". This can be affected by #line.
 PresumedLoc PLoc = SourceMgr.getPresumedLoc(Tok.getLocation());
@@ -1495,7 +1497,26 @@
 // Escape this filename.  Turn '\' -> '\\' '"' -> '\"'
 SmallString<128> FN;
 if (PLoc.isValid()) {
-  FN += PLoc.getFilename();
+  // __FILE_NAME__ is a Clang-specific extension that expands to the
+  // the last part of __FILE__.
+  if (II == Ident__FILE_NAME__) {
+// Try to get the last path component.
+StringRef PLFileName = PLoc.getFilename(); 
+size_t LastSep = PLFileName.find_last_of('/');
+
+// With MS extensions, '\' is a valid path separator, try it as well.
+if (LastSep == StringRef::npos && LangOpts.MicrosoftExt)
+  LastSep = PLFileName.find_last_of('\\');
+
+// Skip the separator and get the last part, otherwise fall back on
+// returning the original full filename.
+if (LastSep != StringRef::npos)
+  FN += PLFileName.substr(LastSep+1);
+else
+  FN += PLFileName;
+  } else {
+FN += PLoc.getFilename();
+  }
   Lexer::Stringify(FN);
   OS << '"' << FN << '"';
 }
Index: include/clang/Lex/Preprocessor.h
===
--- include/clang/Lex/Preprocessor.h
+++ include/clang/Lex/Preprocessor.h
@@ -147,6 +147,7 @@
   IdentifierInfo *Ident__DATE__, *Ident__TIME__;   // __DATE__, __TIME__
   IdentifierInfo *Ident__INCLUDE_LEVEL__;  // __INCLUDE_LEVEL__
   IdentifierInfo *Ident__BASE_FILE__;  // __BASE_FILE__
+  IdentifierInfo *Ident__FILE_NAME__;  // __FILE_NAME__
   IdentifierInfo *Ident__TIMESTAMP__;  // __TIMESTAMP__
   IdentifierInfo 

[PATCH] D17741: adds __FILE_BASENAME__ builtin macro

2019-05-09 Thread Kristina Brooks via Phabricator via cfe-commits
kristina abandoned this revision.
kristina added a comment.

Superseded by D61756 


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

https://reviews.llvm.org/D17741



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


[PATCH] D61756: Add a __FILE_NAME__ macro.

2019-05-09 Thread Kristina Brooks via Phabricator via cfe-commits
kristina created this revision.
kristina added reviewers: aaron.ballman, rsmith, rnk.
Herald added a project: clang.

A much simplified version of D17741  which 
adds a new builtin macro `__FILE_NAME__` that is similar to `__FILE__` but only 
renders the last path component. It seems that this functionality is highly 
desired from the consensus on D17741  as a 
separate macro versus a much more complicated and niche patch originally 
proposed in that differential.


Repository:
  rC Clang

https://reviews.llvm.org/D61756

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

Index: test/Preprocessor/file_name_macro.c
===
--- test/Preprocessor/file_name_macro.c
+++ test/Preprocessor/file_name_macro.c
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -E %s -I%S/Inputs | FileCheck -strict-whitespace %s
+// RUN: %clang_cc1 -fms-compatibility -DMS -E %s -I%S/Inputs | FileCheck -check-prefix=CHECK-MS -strict-whitespace %s 
+// RUN: %clang_cc1 -E %s -I%S/Inputs -DBADINC -verify
+
+#ifdef BADINC
+
+// Paranoia.
+
+__FILE_NAME__
+#include  // expected-error {{file not found}}
+__FILE_NAME__
+
+#else
+
+// Reference.
+1: "file_name_macro.c"
+
+
+// Ensure it expands correctly for this file.
+2: __FILE_NAME__
+
+// CHECK: {{^}}1: "file_name_macro.c"
+// CHECK: {{^}}2: "file_name_macro.c"
+
+// Test if inclusion works right.
+#ifdef MS
+#include 
+#else
+#include 
+#endif
+
+#include 
+
+
+// CHECK: {{^}}3: "file_name_macro_include.h"
+// CHECK: {{^}}4: "file_name_macro_include.h"
+// CHECK-NOT: {{^}}5: "file_name_macro_include.h"
+// CHECK-MS: {{^}}5: "file_name_macro_include.h"
+// CHECK: {{^}}6: "h"
+
+#endif
Index: test/Preprocessor/Inputs/include-subdir/h
===
--- test/Preprocessor/Inputs/include-subdir/h
+++ test/Preprocessor/Inputs/include-subdir/h
@@ -0,0 +1 @@
+6: __FILE_NAME__
\ No newline at end of file
Index: test/Preprocessor/Inputs/include-subdir/file_name_macro_include.h
===
--- test/Preprocessor/Inputs/include-subdir/file_name_macro_include.h
+++ test/Preprocessor/Inputs/include-subdir/file_name_macro_include.h
@@ -0,0 +1,6 @@
+3: __FILE_NAME__
+4: "file_name_macro_include.h"
+#ifdef MS
+// Should be the same even when included with backslash.
+5: __FILE_NAME__
+#endif
Index: lib/Lex/PPMacroExpansion.cpp
===
--- lib/Lex/PPMacroExpansion.cpp
+++ lib/Lex/PPMacroExpansion.cpp
@@ -363,6 +363,7 @@
   }
 
   // Clang Extensions.
+  Ident__FILE_NAME__  = RegisterBuiltinMacro(*this, "__FILE_NAME__");
   Ident__has_feature  = RegisterBuiltinMacro(*this, "__has_feature");
   Ident__has_extension= RegisterBuiltinMacro(*this, "__has_extension");
   Ident__has_builtin  = RegisterBuiltinMacro(*this, "__has_builtin");
@@ -1474,7 +1475,8 @@
 // __LINE__ expands to a simple numeric value.
 OS << (PLoc.isValid()? PLoc.getLine() : 1);
 Tok.setKind(tok::numeric_constant);
-  } else if (II == Ident__FILE__ || II == Ident__BASE_FILE__) {
+  else if (II == Ident__FILE__ || II == Ident__BASE_FILE__ ||
+   II == Ident__FILE_NAME__) {
 // C99 6.10.8: "__FILE__: The presumed name of the current source file (a
 // character string literal)". This can be affected by #line.
 PresumedLoc PLoc = SourceMgr.getPresumedLoc(Tok.getLocation());
@@ -1495,7 +1497,25 @@
 // Escape this filename.  Turn '\' -> '\\' '"' -> '\"'
 SmallString<128> FN;
 if (PLoc.isValid()) {
-  FN += PLoc.getFilename();
+  // __FILE_NAME__ is a Clang-specific extension that expands to the
+  // the last part of __FILE__.
+  if (II == Ident__FILE_NAME__) {
+// Try to get the last path component.
+StringRef PLFileName = PLoc.getFilename(); 
+size_t LastSep = PLFileName.find_last_of('/');
+// With MS extensions, '\' is a valid path separator, try it as well.
+if (LastSep == StringRef::npos && LangOpts.MicrosoftExt)
+  LastSep = PLFileName.find_last_of('\\');
+// Skip the separator and get the last part, otherwise fall back on
+// returning the original full filename.
+if (LastSep != StringRef::npos) {
+  FN += PLFileName.substr(LastSep+1);
+} else {
+  FN += PLFileName;
+}
+  } else {
+FN += PLoc.getFilename();
+  }
   Lexer::Stringify(FN);
   OS << '"' << FN << '"';
 }
Index: include/clang/Lex/Preprocessor.h
===
--- include/clang/Lex/Preprocessor.h
+++ include/clang/Lex/Preprocessor.h
@@ -147,6 +147,7 @@
   IdentifierInfo 

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

2019-05-09 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added subscribers: JonasToth, Eugene.Zelenko.
Eugene.Zelenko added a comment.

@JonasToth tried to implement const check, so probably const and static part 
should be split. It's hard to tell about state of existing implementation, but 
you could continue it or at least borrow ideas and tests.




Comment at: 
clang-tools-extra/clang-tidy/readability/StaticConstMethodCheck.cpp:33
+  template  const T *getParent(const Expr *E) {
+auto Parents = Ctxt.getParents(*E);
+if (Parents.size() != 1)

Please don't use auto when type is not spelled explicitly in same statement or 
it's iterator.



Comment at: 
clang-tools-extra/clang-tidy/readability/StaticConstMethodCheck.cpp:101
+SourceRange Range) {
+  if (SourceMgr.getFileID(Range.getBegin()) !=
+  SourceMgr.getFileID(Range.getEnd())) {

Please elide braces.



Comment at: 
clang-tools-extra/clang-tidy/readability/StaticConstMethodCheck.cpp:103
+  SourceMgr.getFileID(Range.getEnd())) {
+return StringRef(); // Empty string.
+  }

You could return {}



Comment at: 
clang-tools-extra/clang-tidy/readability/StaticConstMethodCheck.cpp:124
+  // Find the exact position of "const".
+  auto Text = getStringFromRange(SourceMgr, LangOpts, Range);
+  auto Offset = Text.find("const");

Please don't use auto when type is not spelled explicitly in same statement or 
it's iterator.



Comment at: 
clang-tools-extra/clang-tidy/readability/StaticConstMethodCheck.cpp:129
+
+  auto Start = Range.getBegin().getLocWithOffset(Offset);
+  return {Start, Start.getLocWithOffset(strlen("const") - 1)};

Please don't use auto when type is not spelled explicitly in same statement or 
it's iterator.



Comment at: 
clang-tools-extra/clang-tidy/readability/StaticConstMethodCheck.cpp:134
+static SourceLocation getConstInsertionPoint(const CXXMethodDecl *M) {
+  auto TSI = M->getTypeSourceInfo();
+  if (!TSI)

Please don't use auto when type is not spelled explicitly in same statement or 
it's iterator.



Comment at: 
clang-tools-extra/clang-tidy/readability/StaticConstMethodCheck.cpp:183
+
+  auto Declaration = Definition->getCanonicalDecl();
+

Please don't use auto when type is not spelled explicitly in same statement or 
it's iterator.



Comment at: 
clang-tools-extra/clang-tidy/readability/StaticConstMethodCheck.cpp:199
+  !isa(Definition)) {
+auto Diag = diag(Definition->getLocation(), "method %0 can be made static")
+<< Definition;

Please don't use auto when type is not spelled explicitly in same statement or 
it's iterator.



Comment at: 
clang-tools-extra/clang-tidy/readability/StaticConstMethodCheck.cpp:213
+  if (Declaration != Definition) {
+auto DeclConst = getLocationOfConst(Declaration->getTypeSourceInfo(),
+*Result.SourceManager,

Please don't use auto when type is not spelled explicitly in same statement or 
it's iterator.



Comment at: 
clang-tools-extra/clang-tidy/readability/StaticConstMethodCheck.cpp:226
+Diag << FixItHint::CreateInsertion(Declaration->getBeginLoc(), "static ");
+
+  } else if (UsageOfThis.Usage <= Const && !Definition->isConst()) {

Unnecessary empty line.



Comment at: 
clang-tools-extra/clang-tidy/readability/StaticConstMethodCheck.cpp:228
+  } else if (UsageOfThis.Usage <= Const && !Definition->isConst()) {
+auto Diag = diag(Definition->getLocation(), "method %0 can be made const")
+<< Definition

Please don't use auto when type is not spelled explicitly in same statement or 
it's iterator.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:72
 
+- New :doc:`readability-static-const-method
+  ` check.

Please rebase from trunk.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61749



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


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

2019-05-09 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 198889.
leonardchan marked 2 inline comments as done.
leonardchan retitled this revision from "[NewPM] Port HWASan" to "[NewPM] Port 
HWASan and Kernel HWASan".
leonardchan edited the summary of this revision.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61709

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGen/hwasan-new-pm.c
  llvm/include/llvm/InitializePasses.h
  llvm/include/llvm/Transforms/Instrumentation.h
  llvm/include/llvm/Transforms/Instrumentation/HWAddressSanitizer.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
  llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
  llvm/test/Instrumentation/HWAddressSanitizer/basic.ll

Index: llvm/test/Instrumentation/HWAddressSanitizer/basic.ll
===
--- llvm/test/Instrumentation/HWAddressSanitizer/basic.ll
+++ llvm/test/Instrumentation/HWAddressSanitizer/basic.ll
@@ -5,6 +5,12 @@
 ; RUN: opt < %s -hwasan -hwasan-recover=0 -hwasan-mapping-offset=0 -S | FileCheck %s --check-prefixes=CHECK,ABORT,ABORT-ZERO-BASED-SHADOW
 ; RUN: opt < %s -hwasan -hwasan-recover=1 -hwasan-mapping-offset=0 -S | FileCheck %s --check-prefixes=CHECK,RECOVER,RECOVER-ZERO-BASED-SHADOW
 
+; Ensure than hwasan runs with the new PM pass
+; RUN: opt < %s -passes='function(hwasan)' -hwasan-recover=0 -hwasan-with-ifunc=1 -hwasan-with-tls=0 -S | FileCheck %s --check-prefixes=CHECK,ABORT,ABORT-DYNAMIC-SHADOW
+; RUN: opt < %s -passes='function(hwasan)' -hwasan-recover=1 -hwasan-with-ifunc=1 -hwasan-with-tls=0 -S | FileCheck %s --check-prefixes=CHECK,RECOVER,RECOVER-DYNAMIC-SHADOW
+; RUN: opt < %s -passes='function(hwasan)' -hwasan-recover=0 -hwasan-mapping-offset=0 -S | FileCheck %s --check-prefixes=CHECK,ABORT,ABORT-ZERO-BASED-SHADOW
+; RUN: opt < %s -passes='function(hwasan)' -hwasan-recover=1 -hwasan-mapping-offset=0 -S | FileCheck %s --check-prefixes=CHECK,RECOVER,RECOVER-ZERO-BASED-SHADOW
+
 ; CHECK: @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @hwasan.module_ctor, i8* bitcast (void ()* @hwasan.module_ctor to i8*) }]
 ; CHECK: @__hwasan = private constant [0 x i8] zeroinitializer, section "__hwasan_frames", comdat($hwasan.module_ctor)
 
Index: llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
===
--- llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
+++ llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
@@ -114,7 +114,7 @@
   initializeInstrOrderFileLegacyPassPass(Registry);
   initializeInstrProfilingLegacyPassPass(Registry);
   initializeMemorySanitizerLegacyPassPass(Registry);
-  initializeHWAddressSanitizerPass(Registry);
+  initializeHWAddressSanitizerLegacyPassPass(Registry);
   initializeThreadSanitizerLegacyPassPass(Registry);
   initializeSanitizerCoverageModulePass(Registry);
   initializeDataFlowSanitizerPass(Registry);
Index: llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
@@ -11,6 +11,7 @@
 /// based on tagged addressing.
 //===--===//
 
+#include "llvm/Transforms/Instrumentation/HWAddressSanitizer.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
@@ -164,22 +165,19 @@
 
 /// An instrumentation pass implementing detection of addressability bugs
 /// using tagged pointers.
-class HWAddressSanitizer : public FunctionPass {
+class HWAddressSanitizer {
 public:
-  // Pass identification, replacement for typeid.
-  static char ID;
-
-  explicit HWAddressSanitizer(bool CompileKernel = false, bool Recover = false)
-  : FunctionPass(ID) {
+  explicit HWAddressSanitizer(Module , bool CompileKernel = false,
+  bool Recover = false) {
 this->Recover = ClRecover.getNumOccurrences() > 0 ? ClRecover : Recover;
 this->CompileKernel = ClEnableKhwasan.getNumOccurrences() > 0 ?
 ClEnableKhwasan : CompileKernel;
-  }
 
-  StringRef getPassName() const override { return "HWAddressSanitizer"; }
+initializeWithModule(M);
+  }
 
-  bool runOnFunction(Function ) override;
-  bool doInitialization(Module ) override;
+  bool instrumentFunction(Function );
+  void initializeWithModule(Module );
 
   void initializeCallbacks(Module );
 
@@ -279,29 +277,61 @@
   GlobalValue *ThreadPtrGlobal = nullptr;
 };
 
+class HWAddressSanitizerLegacyPass : public FunctionPass {
+public:
+  // Pass identification, replacement for typeid.
+  static char ID;
+
+  explicit HWAddressSanitizerLegacyPass(bool 

r360369 - Simplify tracking of end of consumed decl-specifier sequence.

2019-05-09 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu May  9 12:45:46 2019
New Revision: 360369

URL: http://llvm.org/viewvc/llvm-project?rev=360369=rev
Log:
Simplify tracking of end of consumed decl-specifier sequence.

Patch by Tyker!

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

Modified:
cfe/trunk/lib/Parse/ParseDecl.cpp

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=360369=360368=360369=diff
==
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Thu May  9 12:45:46 2019
@@ -3004,12 +3004,12 @@ void Parser::ParseDeclarationSpecifiers(
   while (1) {
 bool isInvalid = false;
 bool isStorageClass = false;
-bool isAlreadyConsumed = false;
 const char *PrevSpec = nullptr;
 unsigned DiagID = 0;
 
-// This value need to be set when isAlreadyConsumed is set to true.
-SourceLocation RangeEnd;
+// This value needs to be set to the location of the last token if the last
+// token of the specifier is already consumed.
+SourceLocation ConsumedEnd;
 
 // HACK: MSVC doesn't consider _Atomic to be a keyword and its STL
 // implementation for VS2013 uses _Atomic as an identifier for one of the
@@ -3566,8 +3566,7 @@ void Parser::ParseDeclarationSpecifiers(
   SourceLocation ExplicitLoc = Loc;
   SourceLocation CloseParenLoc;
   ExplicitSpecifier ExplicitSpec(nullptr, ExplicitSpecKind::ResolvedTrue);
-  isAlreadyConsumed = true;
-  RangeEnd = ExplicitLoc;
+  ConsumedEnd = ExplicitLoc;
   ConsumeToken(); // kw_explicit
   if (Tok.is(tok::l_paren)) {
 if (getLangOpts().CPlusPlus2a) {
@@ -3575,7 +3574,7 @@ void Parser::ParseDeclarationSpecifiers(
   BalancedDelimiterTracker Tracker(*this, tok::l_paren);
   Tracker.consumeOpen();
   ExplicitExpr = ParseConstantExpression();
-  RangeEnd = Tok.getLocation();
+  ConsumedEnd = Tok.getLocation();
   if (ExplicitExpr.isUsable()) {
 CloseParenLoc = Tok.getLocation();
 Tracker.consumeClose();
@@ -3934,10 +3933,7 @@ void Parser::ParseDeclarationSpecifiers(
   continue;
 }
 
-assert((!isAlreadyConsumed || RangeEnd != SourceLocation()) &&
- "both or neither of isAlreadyConsumed and 
"
- "RangeEnd needs to be set");
-DS.SetRangeEnd(isAlreadyConsumed ? RangeEnd : Tok.getLocation());
+DS.SetRangeEnd(ConsumedEnd.isValid() ? ConsumedEnd : Tok.getLocation());
 
 // If the specifier wasn't legal, issue a diagnostic.
 if (isInvalid) {
@@ -3958,7 +3954,7 @@ void Parser::ParseDeclarationSpecifiers(
 Diag(Loc, DiagID) << PrevSpec;
 }
 
-if (DiagID != diag::err_bool_redeclaration && !isAlreadyConsumed)
+if (DiagID != diag::err_bool_redeclaration && ConsumedEnd.isInvalid())
   // After an error the next token can be an annotation token.
   ConsumeAnyToken();
 


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


r360370 - DR1872: don't allow any calls to virtual functions in constant

2019-05-09 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu May  9 12:45:49 2019
New Revision: 360370

URL: http://llvm.org/viewvc/llvm-project?rev=360370=rev
Log:
DR1872: don't allow any calls to virtual functions in constant
evaluation.

Not even in cases where we would not actually perform virtual dispatch.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p6.cpp
cfe/trunk/test/CXX/drs/dr13xx.cpp
cfe/trunk/test/CXX/drs/dr18xx.cpp
cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp
cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp
cfe/trunk/www/cxx_dr_status.html

Modified: cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td?rev=360370=360369=360370=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td Thu May  9 12:45:49 2019
@@ -31,7 +31,7 @@ def note_constexpr_invalid_inhctor : Not
 def note_constexpr_no_return : Note<
   "control reached end of constexpr function">;
 def note_constexpr_virtual_call : Note<
-  "cannot evaluate virtual function call in a constant expression">;
+  "cannot evaluate call to virtual function in a constant expression">;
 def note_constexpr_virtual_base : Note<
   "cannot construct object of type %0 with virtual base class "
   "in a constant expression">;

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=360370=360369=360370=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Thu May  9 12:45:49 2019
@@ -4381,6 +4381,14 @@ static bool CheckConstexprFunction(EvalI
 return false;
   }
 
+  // DR1872: An instantiated virtual constexpr function can't be called in a
+  // constant expression.
+  if (isa(Declaration) &&
+  cast(Declaration)->isVirtual()) {
+Info.FFDiag(CallLoc, diag::note_constexpr_virtual_call);
+return false;
+  }
+
   // Can we evaluate this function call?
   if (Definition && Definition->isConstexpr() &&
   !Definition->isInvalidDecl() && Body)
@@ -4999,12 +5007,6 @@ public:
 if (This && !This->checkSubobject(Info, E, CSK_This))
   return false;
 
-// DR1358 allows virtual constexpr functions in some cases. Don't allow
-// calls to such functions in constant expressions.
-if (This && !HasQualifier &&
-isa(FD) && cast(FD)->isVirtual())
-  return Error(E, diag::note_constexpr_virtual_call);
-
 const FunctionDecl *Definition = nullptr;
 Stmt *Body = FD->getBody(Definition);
 

Modified: cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p6.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p6.cpp?rev=360370=360369=360370=diff
==
--- cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p6.cpp (original)
+++ cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p6.cpp Thu May  9 
12:45:49 2019
@@ -27,9 +27,9 @@ template struct ImplicitVirt
   constexpr int ImplicitlyVirtual() const { return 0; }
 };
 
-constexpr int a = ImplicitVirtualFromDependentBase().ImplicitlyVirtual(); 
// expected-error {{constant expression}} expected-note {{cannot evaluate 
virtual function call}}
+constexpr int a = ImplicitVirtualFromDependentBase().ImplicitlyVirtual(); 
// expected-error {{constant expression}} expected-note {{cannot evaluate call 
to virtual function}}
 constexpr int b = ImplicitVirtualFromDependentBase().ImplicitlyVirtual(); 
// ok
-constexpr int c = 
ImplicitVirtualFromDependentBase().ImplicitVirtualFromDependentBase::ImplicitlyVirtual();
+constexpr int c = 
ImplicitVirtualFromDependentBase().ImplicitVirtualFromDependentBase::ImplicitlyVirtual();
 // expected-error {{constant expression}} expected-note {{cannot evaluate call 
to virtual function}}
 
 template struct ConstexprMember {
   constexpr R F() const { return 0; }

Modified: cfe/trunk/test/CXX/drs/dr13xx.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/drs/dr13xx.cpp?rev=360370=360369=360370=diff
==
--- cfe/trunk/test/CXX/drs/dr13xx.cpp (original)
+++ cfe/trunk/test/CXX/drs/dr13xx.cpp Thu May  9 12:45:49 2019
@@ -267,6 +267,42 @@ namespace dr1347 { // dr1347: yes
 #endif
 }
 
+namespace dr1358 { // dr1358: yes
+#if __cplusplus >= 201103L
+  struct Lit { constexpr operator int() const { return 0; } };
+  struct NonLit { NonLit(); operator int(); }; // expected-note 2{{no 
constexpr constructors}}
+  struct NonConstexprConv { constexpr operator int() const; };
+  struct Virt { virtual int f(int) const; };
+
+  

[PATCH] D61750: [Targets] Move soft-float-abi filtering to `initFeatureMap`

2019-05-09 Thread George Burgess IV via Phabricator via cfe-commits
george.burgess.iv created this revision.
george.burgess.iv added reviewers: michaelplatings, efriedma.
Herald added subscribers: kristof.beyls, javed.absar.
Herald added a project: clang.

I'm not convinced this is an excellent approach, in part because I'm unclear on 
where all we expect to funnel the results of `TargetInfo::initFeatureMap`. 
Thought I'd throw it out for review anyway, and see what people with actual 
context think. :)

The underlying problem I'm trying to solve is that, given the following code 
with a suitable ARM target,

  ___attribute__((target("crc"))) void foo() {}

clang ends up codegening a function with the '+soft-float-abi' target feature, 
which we go out of our way to remove in the frontend for the default target 
features, since the backend apparently tries to figure out whether the soft 
float ABI should be used on its own. This is more or less harmless on its own, 
but it causes the backend to emit a diagnostic directly to `errs()`. Rather 
than try to find a way to silence that diag, it seems better to not have to 
emit it in the first place.

An alternate fix would be to somehow try to filter this in cfe/lib/CodeGen, but 
there appear to be many callers of  `initFeatureMap`; I get the vague feeling 
that we shouldn't be letting `+soft-float-abi` slip through any of them. Again, 
could be wrong about that due to my lack of familiarity with `initFeatureMap`'s 
uses.

If we agree that this is a good way forward, there also appears to be 
`+neonfp`/`-neonfp` additions happening in `handleTargetFeatures` that should 
probably be happening in `initFeatureMap` instead? If that's the case, I'm 
happy to do that as a follow-up, and make it so that `handleTargetFeatures` no 
longer mutates its input (which comments indicate would be desirable, along 
with a more general move of all of this initialization stuff to the 
construction of our various `TargetInfo` subclasses).


Repository:
  rC Clang

https://reviews.llvm.org/D61750

Files:
  lib/Basic/Targets/ARM.cpp
  test/CodeGen/arm-soft-float-abi-filtering.c


Index: test/CodeGen/arm-soft-float-abi-filtering.c
===
--- /dev/null
+++ test/CodeGen/arm-soft-float-abi-filtering.c
@@ -0,0 +1,7 @@
+// REQUIRES: arm-registered-target
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-linux-gnueabi 
-target-feature "+soft-float-abi" %s | FileCheck %s
+
+// CHECK-NOT: +soft-float-abi
+
+void foo() {}
+__attribute__((target("crc"))) void bar() {}
Index: lib/Basic/Targets/ARM.cpp
===
--- lib/Basic/Targets/ARM.cpp
+++ lib/Basic/Targets/ARM.cpp
@@ -313,6 +313,8 @@
 this->MCountName = Opts.EABIVersion == llvm::EABI::GNU
? "\01__gnu_mcount_nc"
: "\01mcount";
+
+  SoftFloatABI = llvm::is_contained(Opts.FeaturesAsWritten, "+soft-float-abi");
 }
 
 StringRef ARMTargetInfo::getABI() const { return ABI; }
@@ -375,12 +377,21 @@
 
   // Convert user-provided arm and thumb GNU target attributes to
   // [-|+]thumb-mode target features respectively.
-  std::vector UpdatedFeaturesVec(FeaturesVec);
-  for (auto  : UpdatedFeaturesVec) {
-if (Feature.compare("+arm") == 0)
-  Feature = "-thumb-mode";
-else if (Feature.compare("+thumb") == 0)
-  Feature = "+thumb-mode";
+  std::vector UpdatedFeaturesVec;
+  for (const auto  : FeaturesVec) {
+// Skip soft-float-abi; it's something we only use to initialize a bit of
+// class state, and is otherwise unrecognized.
+if (Feature == "+soft-float-abi")
+  continue;
+
+StringRef FixedFeature;
+if (Feature == "+arm")
+  FixedFeature = "-thumb-mode";
+else if (Feature == "+thumb")
+  FixedFeature = "+thumb-mode";
+else
+  FixedFeature = Feature;
+UpdatedFeaturesVec.push_back(FixedFeature.str());
   }
 
   return TargetInfo::initFeatureMap(Features, Diags, CPU, UpdatedFeaturesVec);
@@ -394,7 +405,8 @@
   Crypto = 0;
   DSP = 0;
   Unaligned = 1;
-  SoftFloat = SoftFloatABI = false;
+  SoftFloat = false;
+  // Note that SoftFloatABI is initialized in our constructor.
   HWDiv = 0;
   DotProd = 0;
   HasFloat16 = true;
@@ -405,8 +417,6 @@
   for (const auto  : Features) {
 if (Feature == "+soft-float") {
   SoftFloat = true;
-} else if (Feature == "+soft-float-abi") {
-  SoftFloatABI = true;
 } else if (Feature == "+vfp2") {
   FPU |= VFP2FPU;
   HW_FP |= HW_FP_SP | HW_FP_DP;
@@ -475,11 +485,6 @@
   else if (FPMath == FP_VFP)
 Features.push_back("-neonfp");
 
-  // Remove front-end specific options which the backend handles differently.
-  auto Feature = llvm::find(Features, "+soft-float-abi");
-  if (Feature != Features.end())
-Features.erase(Feature);
-
   return true;
 }
 


Index: test/CodeGen/arm-soft-float-abi-filtering.c
===
--- /dev/null
+++ 

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

2019-05-09 Thread Matthias Gehre via Phabricator via cfe-commits
mgehre created this revision.
mgehre added reviewers: alexfh, aaron.ballman.
Herald added subscribers: xazax.hun, mgorny.
Herald added a project: clang.

Finds non-static member functions that can be made ``const`` or ``static``.
The check conservatively tries to preserve logical costness in favor of
physical costness. It will not recommend to make member functions ``const``
that call (const) member functions on a non-static data members,
e.g. ``std::unique_ptr::get`` because that might indicate logical
non-costness. Currently, it will only make member functions ``const`` if they
only access to ``this`` is to read members of builtin type.

I have run this check (repeatedly) over llvm-project. It made 1708 member 
functions
``static``. Out of those, I had to exclude 22 via ``NOLINT`` because their 
address
was taken and stored in a variable of pointer-to-member type (e.g. passed to
llvm::StringSwitch).
It also made 243 member functions ``const``. (This is currently very 
conservative
to have no false-positives and can hopefully be extended in the future.)

You can find the results here: 
https://github.com/mgehre/llvm-project/commits/static_const_eval


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D61749

Files:
  clang-tools-extra/clang-tidy/readability/CMakeLists.txt
  clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tools-extra/clang-tidy/readability/StaticConstMethodCheck.cpp
  clang-tools-extra/clang-tidy/readability/StaticConstMethodCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-static-const-method.rst
  clang-tools-extra/test/clang-tidy/readability-static-const-method.cpp

Index: clang-tools-extra/test/clang-tidy/readability-static-const-method.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/readability-static-const-method.cpp
@@ -0,0 +1,317 @@
+// RUN: %check_clang_tidy %s readability-static-const-method %t
+
+class DoNotMakeEmptyStatic {
+  void emptyMethod() {}
+  void empty_method_out_of_line();
+};
+
+void DoNotMakeEmptyStatic::empty_method_out_of_line() {}
+
+struct Str {
+  void const_method() const;
+  void non_const_method();
+};
+
+class A;
+
+void const_use(const A *);
+void non_const_use(A *);
+void const_use(const A &);
+void non_const_use(A &);
+
+class A {
+  int field;
+  const int const_field;
+  static int static_field;
+  Str S;
+  Str Sref;
+  Str *Sptr;
+
+  void no_use() {
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: method 'no_use' can be made static
+// CHECK-FIXES: {{^}}  static void no_use() {
+int i = 1;
+  }
+
+  int read_field() {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: method 'read_field' can be made const
+// CHECK-FIXES: {{^}}  int read_field() const {
+return field;
+  }
+
+  int read_const_field() {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: method 'read_const_field' can be made const
+// CHECK-FIXES: {{^}}  int read_const_field() const {
+return const_field;
+  }
+
+  void write_field() {
+field = 1;
+  }
+
+  int call_non_const_member() { return read_field(); }
+
+  int call_const_member() {
+// TODO: :[[@LINE-1]]:7: warning: method 'call_const_member' can be made const
+// TODO: {{^}}  int call_const_member() const {
+return already_const();
+  }
+
+  int call_static_member() {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: method 'call_static_member' can be made static
+// CHECK-FIXES: {{^}}  static int call_static_member() {
+already_static();
+  }
+
+  void call_non_const_member_on_field() { S.non_const_method(); }
+
+  void call_const_member_on_field() {
+// Technically, this method could be const-qualified,
+// but it might not be logically const.
+S.const_method();
+  }
+
+  void call_non_const_member_on_pointee() {
+Sptr->non_const_method();
+  }
+
+  void call_const_member_on_pointee() {
+// Technically, this method could be const-qualified,
+// but it might not be logically const.
+Sptr->const_method();
+  }
+
+  Str *return_pointer() {
+// Technically, this method could be const-qualified,
+// but it might not be logically const.
+return Sptr;
+  }
+
+  void call_non_const_member_on_ref() {
+Sref.non_const_method();
+  }
+
+  void call_const_member_on_ref() {
+// Technically, this method could be const-qualified,
+// but it might not be logically const.
+Sref.const_method();
+  }
+
+  void call_const_member_on_ref_of_ref() {
+const auto  = Sref;
+// Technically, this method could be const-qualified,
+// but it might not be logically const.
+L.const_method();
+  }
+
+  Str _ref() {
+// Technically, this method could be const-qualified,
+// but it might not be logically const.
+return Sref;
+  }
+
+  int read_static() {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: method 

[PATCH] D61621: [X86] Make `x86intrin.h`, `immintrin.h` includable with `-fno-gnu-inline-asm`.

2019-05-09 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm, thanks!

In D61621#1496978 , @vsapsai wrote:

> Didn't use `-fms-compatibility` in the test and it seems to be working fine.
>  Don't know if it is accidental and if I should add the flag.


`-fms-extensions` is probably all you need. That's the one that defines 
_MSC_VER.


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

https://reviews.llvm.org/D61621



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


r360365 - [OPENMP]Fix PR41767: diagnose DSA for variables in clauses with default(none).

2019-05-09 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu May  9 11:44:53 2019
New Revision: 360365

URL: http://llvm.org/viewvc/llvm-project?rev=360365=rev
Log:
[OPENMP]Fix PR41767: diagnose DSA for variables in clauses with default(none).

If the combined directive has default(none) clause and has clauses for
inner directive that reference some variables, for which data-sharing
attributes are not specified, the error messages should be emitted for
such variables.

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_ast_print.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_simd_ast_print.cpp
cfe/trunk/test/OpenMP/parallel_for_ast_print.cpp
cfe/trunk/test/OpenMP/parallel_for_schedule_messages.cpp
cfe/trunk/test/OpenMP/parallel_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_ast_print.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_ast_print.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_if_messages.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=360365=360364=360365=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Thu May  9 11:44:53 2019
@@ -750,7 +750,8 @@ bool isImplicitTaskingRegion(OpenMPDirec
 }
 
 bool isImplicitOrExplicitTaskingRegion(OpenMPDirectiveKind DKind) {
-  return isImplicitTaskingRegion(DKind) || isOpenMPTaskingDirective(DKind) || 
DKind == OMPD_unknown;
+  return isImplicitTaskingRegion(DKind) || isOpenMPTaskingDirective(DKind) ||
+ DKind == OMPD_unknown;
 }
 
 } // namespace
@@ -2575,9 +2576,17 @@ public:
 E->containsUnexpandedParameterPack() || E->isInstantiationDependent())
   return;
 if (auto *VD = dyn_cast(E->getDecl())) {
+  // Check the datasharing rules for the expressions in the clauses.
+  if (!CS) {
+if (auto *CED = dyn_cast(VD))
+  if (!CED->hasAttr()) {
+Visit(CED->getInit());
+return;
+  }
+  }
   VD = VD->getCanonicalDecl();
   // Skip internally declared variables.
-  if (VD->hasLocalStorage() && !CS->capturesVariable(VD))
+  if (VD->hasLocalStorage() && CS && !CS->capturesVariable(VD))
 return;
 
   DSAStackTy::DSAVarData DVar = Stack->getTopDSA(VD, /*FromParent=*/false);
@@ -2588,7 +2597,7 @@ public:
   // Skip internally declared static variables.
   llvm::Optional Res =
   OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD);
-  if (VD->hasGlobalStorage() && !CS->capturesVariable(VD) &&
+  if (VD->hasGlobalStorage() && CS && !CS->capturesVariable(VD) &&
   (!Res || *Res != OMPDeclareTargetDeclAttr::MT_Link))
 return;
 
@@ -4201,6 +4210,89 @@ StmtResult Sema::ActOnOpenMPExecutableDi
 
   ErrorFound = Res.isInvalid() || ErrorFound;
 
+  // Check variables in the clauses if default(none) was specified.
+  if (DSAStack->getDefaultDSA() == DSA_none) {
+DSAAttrChecker DSAChecker(DSAStack, *this, nullptr);
+for (OMPClause *C : Clauses) {
+  switch (C->getClauseKind()) {
+  case OMPC_num_threads:
+  case OMPC_dist_schedule:
+// Do not analyse if no parent teams directive.
+if (isOpenMPTeamsDirective(DSAStack->getCurrentDirective()))
+  break;
+continue;
+  case OMPC_if:
+if (isOpenMPTeamsDirective(DSAStack->getCurrentDirective()) &&
+cast(C)->getNameModifier() != OMPD_target)
+  break;
+continue;
+  case OMPC_schedule:
+break;
+  case OMPC_ordered:
+  case OMPC_device:
+  case OMPC_num_teams:
+  case OMPC_thread_limit:
+  case OMPC_priority:
+  case OMPC_grainsize:
+  case OMPC_num_tasks:
+  case OMPC_hint:
+  case OMPC_collapse:
+  case OMPC_safelen:
+  case OMPC_simdlen:
+  case OMPC_final:
+  case OMPC_default:
+  case OMPC_proc_bind:
+  case OMPC_private:
+  case OMPC_firstprivate:
+  case OMPC_lastprivate:
+  case OMPC_shared:
+  case OMPC_reduction:
+  case OMPC_task_reduction:
+  case OMPC_in_reduction:
+  case OMPC_linear:
+  case OMPC_aligned:
+  case OMPC_copyin:
+  case OMPC_copyprivate:
+  case OMPC_nowait:
+  case OMPC_untied:
+  case OMPC_mergeable:
+  case OMPC_allocate:
+  case OMPC_read:
+  case OMPC_write:
+  case OMPC_update:
+  case OMPC_capture:
+  case OMPC_seq_cst:
+  case OMPC_depend:
+  case OMPC_threads:
+  case OMPC_simd:
+  case OMPC_map:
+  case OMPC_nogroup:
+  case OMPC_defaultmap:
+  case OMPC_to:
+  case OMPC_from:
+  case OMPC_use_device_ptr:
+  case OMPC_is_device_ptr:
+continue;
+  case OMPC_allocator:
+  case OMPC_flush:
+  case OMPC_threadprivate:
+  case OMPC_uniform:
+  case OMPC_unknown:
+  case 

[PATCH] D61747: [clang-tidy] remove default header-filter for run-clang-tidy

2019-05-09 Thread Torbjörn Klatt via Phabricator via cfe-commits
torbjoernk created this revision.
torbjoernk added reviewers: alexfh, bkramer.
torbjoernk added a project: clang-tools-extra.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.

run-clang-tidy.py was enforcing '-header-filter' parameter with an
unfortunate default value when none was given. Thus, leading to
overwritten clang-tidy configuration (e.g. from .clang-tidy).

This change removes the default value for '-header-filter' resulting in
the default behaviour of clang-tidy itself.

Fixes PR#41426


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D61747

Files:
  clang-tools-extra/clang-tidy/tool/run-clang-tidy.py


Index: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
===
--- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -84,9 +84,6 @@
   start = [clang_tidy_binary]
   if header_filter is not None:
 start.append('-header-filter=' + header_filter)
-  else:
-# Show warnings in all in-project headers by default.
-start.append('-header-filter=^' + build_path + '/.*')
   if checks:
 start.append('-checks=' + checks)
   if tmpdir is not None:


Index: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
===
--- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -84,9 +84,6 @@
   start = [clang_tidy_binary]
   if header_filter is not None:
 start.append('-header-filter=' + header_filter)
-  else:
-# Show warnings in all in-project headers by default.
-start.append('-header-filter=^' + build_path + '/.*')
   if checks:
 start.append('-checks=' + checks)
   if tmpdir is not None:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r360363 - Specify target triple to fix the tests I committed in r360359 that are

2019-05-09 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Thu May  9 11:32:16 2019
New Revision: 360363

URL: http://llvm.org/viewvc/llvm-project?rev=360363=rev
Log:
Specify target triple to fix the tests I committed in r360359 that are
still failing.

Modified:
cfe/trunk/test/CodeGenObjC/externally-initialized-selectors.m
cfe/trunk/test/CodeGenObjC/forward-protocol-metadata-symbols.m
cfe/trunk/test/CodeGenObjCXX/externally-initialized-selectors.mm

Modified: cfe/trunk/test/CodeGenObjC/externally-initialized-selectors.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/externally-initialized-selectors.m?rev=360363=360362=360363=diff
==
--- cfe/trunk/test/CodeGenObjC/externally-initialized-selectors.m (original)
+++ cfe/trunk/test/CodeGenObjC/externally-initialized-selectors.m Thu May  9 
11:32:16 2019
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -fobjc-runtime=macosx-fragile-10.5 -o - -emit-llvm %s | 
FileCheck -check-prefix=FRAGILE %s
-// RUN: %clang_cc1 -fobjc-runtime=macosx-10.14 -o - -emit-llvm %s | FileCheck 
-check-prefix=NONFRAGILE %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-10.14 
-o - -emit-llvm %s | FileCheck -check-prefix=NONFRAGILE %s
 
 // NONFRAGILE: @OBJC_SELECTOR_REFERENCES_ = internal externally_initialized 
global
 // FRAGILE: @OBJC_SELECTOR_REFERENCES_ = private externally_initialized global

Modified: cfe/trunk/test/CodeGenObjC/forward-protocol-metadata-symbols.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/forward-protocol-metadata-symbols.m?rev=360363=360362=360363=diff
==
--- cfe/trunk/test/CodeGenObjC/forward-protocol-metadata-symbols.m (original)
+++ cfe/trunk/test/CodeGenObjC/forward-protocol-metadata-symbols.m Thu May  9 
11:32:16 2019
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fobjc-runtime=macosx-10.14 -emit-llvm -x objective-c %s -o 
- | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-10.14 
-emit-llvm -x objective-c %s -o - | FileCheck %s
 // rdar://16203115
 
 @interface NSObject @end

Modified: cfe/trunk/test/CodeGenObjCXX/externally-initialized-selectors.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/externally-initialized-selectors.mm?rev=360363=360362=360363=diff
==
--- cfe/trunk/test/CodeGenObjCXX/externally-initialized-selectors.mm (original)
+++ cfe/trunk/test/CodeGenObjCXX/externally-initialized-selectors.mm Thu May  9 
11:32:16 2019
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -fobjc-runtime=macosx-fragile-10.5 -o - -emit-llvm %s | 
FileCheck -check-prefix=FRAGILE %s
-// RUN: %clang_cc1 -fobjc-runtime=macosx-10.14 -o - -emit-llvm %s | FileCheck 
-check-prefix=NONFRAGILE %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-10.14 
-o - -emit-llvm %s | FileCheck -check-prefix=NONFRAGILE %s
 
 // NONFRAGILE: @OBJC_SELECTOR_REFERENCES_ = internal externally_initialized 
global
 // FRAGILE: @OBJC_SELECTOR_REFERENCES_ = private externally_initialized global


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


r360362 - [OPENMP]Fix PR41768: check DSA for globals with default(none) clauses.

2019-05-09 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu May  9 11:14:57 2019
New Revision: 360362

URL: http://llvm.org/viewvc/llvm-project?rev=360362=rev
Log:
[OPENMP]Fix PR41768: check DSA for globals with default(none) clauses.

If the default(none) was specified for the construct, we might miss
diagnostic for the globals without explicitly specified data-sharing
attributes. Patch fixes this problem.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_default_messages.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_messages.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_simd_default_messages.cpp
cfe/trunk/test/OpenMP/parallel_default_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_default_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_simd_default_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_simd_messages.cpp
cfe/trunk/test/OpenMP/parallel_messages.cpp
cfe/trunk/test/OpenMP/parallel_sections_default_messages.cpp
cfe/trunk/test/OpenMP/parallel_sections_messages.cpp
cfe/trunk/test/OpenMP/report_default_DSA.cpp
cfe/trunk/test/OpenMP/target_parallel_default_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_default_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_default_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_messages.cpp
cfe/trunk/test/OpenMP/target_teams_default_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_default_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_messages.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_default_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_messages.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_default_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_messages.cpp
cfe/trunk/test/OpenMP/target_teams_messages.cpp
cfe/trunk/test/OpenMP/task_default_messages.cpp
cfe/trunk/test/OpenMP/task_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/task_messages.cpp
cfe/trunk/test/OpenMP/teams_default_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_default_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_default_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_messages.cpp

cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_default_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_simd_default_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_simd_messages.cpp
cfe/trunk/test/OpenMP/teams_messages.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=360362=360361=360362=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu May  9 11:14:57 
2019
@@ -8821,6 +8821,8 @@ def err_omp_threadprivate_incomplete_typ
   "threadprivate variable with incomplete type %0">;
 def err_omp_no_dsa_for_variable : Error<
   "variable %0 must have explicitly specified data sharing attributes">;
+def note_omp_default_dsa_none : Note<
+  "explicit data sharing attribute requested here">;
 def err_omp_wrong_dsa : Error<
   "%0 variable cannot be %1">;
 def err_omp_variably_modified_type_not_supported : Error<

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=360362=360361=360362=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu May  9 11:14:57 2019
@@ -8890,7 +8890,8 @@ public:
   /// Check if the specified variable is used in one of the private
   /// clauses (private, firstprivate, lastprivate, reduction etc.) in OpenMP
   /// constructs.
-  VarDecl *isOpenMPCapturedDecl(ValueDecl *D);
+  VarDecl *isOpenMPCapturedDecl(ValueDecl *D, bool CheckScopeInfo = false,
+unsigned StopAt = 0);
   ExprResult getOpenMPCapturedExpr(VarDecl *Capture, ExprValueKind VK,
ExprObjectKind OK, SourceLocation Loc);
 

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=360362=360361=360362=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu May  9 

[PATCH] D61621: [X86] Make `x86intrin.h`, `immintrin.h` includable with `-fno-gnu-inline-asm`.

2019-05-09 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai updated this revision to Diff 198875.
vsapsai added a comment.

- Improve `-fno-gnu-inline-asm` support for MS-compatibility too.

Didn't use `-fms-compatibility` in the test and it seems to be working fine.
Don't know if it is accidental and if I should add the flag.


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

https://reviews.llvm.org/D61621

Files:
  clang/lib/Headers/immintrin.h
  clang/lib/Headers/pconfigintrin.h
  clang/lib/Headers/sgxintrin.h
  clang/test/Modules/compiler_builtins_x86.c


Index: clang/test/Modules/compiler_builtins_x86.c
===
--- clang/test/Modules/compiler_builtins_x86.c
+++ clang/test/Modules/compiler_builtins_x86.c
@@ -1,6 +1,8 @@
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -triple i686-unknown-unknown -fsyntax-only -fmodules 
-fimplicit-module-maps -fmodules-cache-path=%t %s -verify -ffreestanding
 // RUN: %clang_cc1 -triple i686-unknown-unknown -fsyntax-only -fmodules 
-fmodule-map-file=%resource_dir/module.modulemap -fmodules-cache-path=%t %s 
-verify -ffreestanding
+// RUN: %clang_cc1 -triple i686-unknown-unknown -fsyntax-only -fmodules 
-fimplicit-module-maps -fmodules-cache-path=%t %s -verify -ffreestanding 
-fno-gnu-inline-asm
+// RUN: %clang_cc1 -triple i686--windows -fsyntax-only -fmodules 
-fimplicit-module-maps -fmodules-cache-path=%t %s -verify -ffreestanding 
-fno-gnu-inline-asm -fms-extensions -fms-compatibility-version=17.00
 // expected-no-diagnostics
 
 #include
Index: clang/lib/Headers/sgxintrin.h
===
--- clang/lib/Headers/sgxintrin.h
+++ clang/lib/Headers/sgxintrin.h
@@ -14,6 +14,8 @@
 #ifndef __SGXINTRIN_H
 #define __SGXINTRIN_H
 
+#if __has_extension(gnu_asm)
+
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS \
   __attribute__((__always_inline__, __nodebug__,  __target__("sgx")))
@@ -53,4 +55,6 @@
 
 #undef __DEFAULT_FN_ATTRS
 
+#endif /* __has_extension(gnu_asm) */
+
 #endif
Index: clang/lib/Headers/pconfigintrin.h
===
--- clang/lib/Headers/pconfigintrin.h
+++ clang/lib/Headers/pconfigintrin.h
@@ -16,6 +16,8 @@
 
 #define __PCONFIG_KEY_PROGRAM 0x0001
 
+#if __has_extension(gnu_asm)
+
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS \
   __attribute__((__always_inline__, __nodebug__,  __target__("pconfig")))
@@ -33,4 +35,6 @@
 
 #undef __DEFAULT_FN_ATTRS
 
+#endif /* __has_extension(gnu_asm) */
+
 #endif
Index: clang/lib/Headers/immintrin.h
===
--- clang/lib/Headers/immintrin.h
+++ clang/lib/Headers/immintrin.h
@@ -421,7 +421,7 @@
 #include 
 #endif
 
-#ifdef _MSC_VER
+#if defined(_MSC_VER) && __has_extension(gnu_asm)
 /* Define the default attributes for these intrinsics */
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
 #ifdef __cplusplus
@@ -503,6 +503,6 @@
 
 #undef __DEFAULT_FN_ATTRS
 
-#endif /* _MSC_VER */
+#endif /* defined(_MSC_VER) && __has_extension(gnu_asm) */
 
 #endif /* __IMMINTRIN_H */


Index: clang/test/Modules/compiler_builtins_x86.c
===
--- clang/test/Modules/compiler_builtins_x86.c
+++ clang/test/Modules/compiler_builtins_x86.c
@@ -1,6 +1,8 @@
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -triple i686-unknown-unknown -fsyntax-only -fmodules -fimplicit-module-maps -fmodules-cache-path=%t %s -verify -ffreestanding
 // RUN: %clang_cc1 -triple i686-unknown-unknown -fsyntax-only -fmodules -fmodule-map-file=%resource_dir/module.modulemap -fmodules-cache-path=%t %s -verify -ffreestanding
+// RUN: %clang_cc1 -triple i686-unknown-unknown -fsyntax-only -fmodules -fimplicit-module-maps -fmodules-cache-path=%t %s -verify -ffreestanding -fno-gnu-inline-asm
+// RUN: %clang_cc1 -triple i686--windows -fsyntax-only -fmodules -fimplicit-module-maps -fmodules-cache-path=%t %s -verify -ffreestanding -fno-gnu-inline-asm -fms-extensions -fms-compatibility-version=17.00
 // expected-no-diagnostics
 
 #include
Index: clang/lib/Headers/sgxintrin.h
===
--- clang/lib/Headers/sgxintrin.h
+++ clang/lib/Headers/sgxintrin.h
@@ -14,6 +14,8 @@
 #ifndef __SGXINTRIN_H
 #define __SGXINTRIN_H
 
+#if __has_extension(gnu_asm)
+
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS \
   __attribute__((__always_inline__, __nodebug__,  __target__("sgx")))
@@ -53,4 +55,6 @@
 
 #undef __DEFAULT_FN_ATTRS
 
+#endif /* __has_extension(gnu_asm) */
+
 #endif
Index: clang/lib/Headers/pconfigintrin.h
===
--- clang/lib/Headers/pconfigintrin.h
+++ clang/lib/Headers/pconfigintrin.h
@@ -16,6 +16,8 @@
 
 #define __PCONFIG_KEY_PROGRAM 0x0001
 
+#if 

r360361 - Specify ObjC runtime to fix the tests I committed in r360359 that are

2019-05-09 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Thu May  9 11:05:17 2019
New Revision: 360361

URL: http://llvm.org/viewvc/llvm-project?rev=360361=rev
Log:
Specify ObjC runtime to fix the tests I committed in r360359 that are
failing.

Modified:
cfe/trunk/test/CodeGenObjC/externally-initialized-selectors.m
cfe/trunk/test/CodeGenObjC/forward-protocol-metadata-symbols.m
cfe/trunk/test/CodeGenObjCXX/externally-initialized-selectors.mm

Modified: cfe/trunk/test/CodeGenObjC/externally-initialized-selectors.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/externally-initialized-selectors.m?rev=360361=360360=360361=diff
==
--- cfe/trunk/test/CodeGenObjC/externally-initialized-selectors.m (original)
+++ cfe/trunk/test/CodeGenObjC/externally-initialized-selectors.m Thu May  9 
11:05:17 2019
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -fobjc-runtime=macosx-fragile-10.5 -o - -emit-llvm %s | 
FileCheck -check-prefix=FRAGILE %s
-// RUN: %clang_cc1 -o - -emit-llvm %s | FileCheck -check-prefix=NONFRAGILE %s
+// RUN: %clang_cc1 -fobjc-runtime=macosx-10.14 -o - -emit-llvm %s | FileCheck 
-check-prefix=NONFRAGILE %s
 
 // NONFRAGILE: @OBJC_SELECTOR_REFERENCES_ = internal externally_initialized 
global
 // FRAGILE: @OBJC_SELECTOR_REFERENCES_ = private externally_initialized global

Modified: cfe/trunk/test/CodeGenObjC/forward-protocol-metadata-symbols.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/forward-protocol-metadata-symbols.m?rev=360361=360360=360361=diff
==
--- cfe/trunk/test/CodeGenObjC/forward-protocol-metadata-symbols.m (original)
+++ cfe/trunk/test/CodeGenObjC/forward-protocol-metadata-symbols.m Thu May  9 
11:05:17 2019
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -emit-llvm -x objective-c %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fobjc-runtime=macosx-10.14 -emit-llvm -x objective-c %s -o 
- | FileCheck %s
 // rdar://16203115
 
 @interface NSObject @end

Modified: cfe/trunk/test/CodeGenObjCXX/externally-initialized-selectors.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/externally-initialized-selectors.mm?rev=360361=360360=360361=diff
==
--- cfe/trunk/test/CodeGenObjCXX/externally-initialized-selectors.mm (original)
+++ cfe/trunk/test/CodeGenObjCXX/externally-initialized-selectors.mm Thu May  9 
11:05:17 2019
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -fobjc-runtime=macosx-fragile-10.5 -o - -emit-llvm %s | 
FileCheck -check-prefix=FRAGILE %s
-// RUN: %clang_cc1 -o - -emit-llvm %s | FileCheck -check-prefix=NONFRAGILE %s
+// RUN: %clang_cc1 -fobjc-runtime=macosx-10.14 -o - -emit-llvm %s | FileCheck 
-check-prefix=NONFRAGILE %s
 
 // NONFRAGILE: @OBJC_SELECTOR_REFERENCES_ = internal externally_initialized 
global
 // FRAGILE: @OBJC_SELECTOR_REFERENCES_ = private externally_initialized global


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


[PATCH] D53072: [clang-format] Create a new tool for IDEs based on clang-format

2019-05-09 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added a comment.

In D53072#1496317 , @sammccall wrote:

> My feedback would be:
>
> - I definitely think more control over preserving line breaks would be 
> useful. Actually preserving *blank* lines is an important property. If you 
> see D60605 , there are a lot of cases where 
> clang-format wants to delete the line you just added. Maybe we can make 
> `MaxEmptyLinesToKeep: 999` work in more cases.
> - I'm not convinced you need/want to preserve *all* line breaks, isn't it 
> just one? (where the user pressed enter)
> - It's unclear why "extraformattingoptions" is needed, rather than just the 
> usual formatting options, or some other parameter. It would be nice to avoid 
> a new library entry point (overload) if possible.
> - as far as command-line interface goes, this definitely feels more like a 
> flag than a new tool


Thanks for the feedback!
'to preserve *all* line breaks, isn't it just one' - it's just much easier code 
wise, you don't need to take the current position into account. I can look how 
I can make it for only one line.
'unclear why "extraformattingoptions" is needed' - the idea behind is that we 
can add more ide-specific options later without introducing new reformat 
parameters.
I will definitely remove a separate tool, it seems nobody sees the need of such 
thing.


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

https://reviews.llvm.org/D53072



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


[PATCH] D50993: [clangd] Increase stack size of the new threads on macOS

2019-05-09 Thread Dmitry via Phabricator via cfe-commits
Dmitry.Kozhevnikov added a comment.

In D50993#1496946 , @ilya-biryukov 
wrote:

> I'd still put it into LLVM to avoid platform-specific code in clangd. 
>  Maybe `std::abort()` in the added `...Async` function if threads are 
> disabled? It's a bit unusual, but would allow keeping this function where it 
> belongs.


Yes, that’s probably a better way. I’ll be back at it in a few days.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D50993



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


[PATCH] D61454: [CodeGen][ObjC] Remove the leading 'l_' from ObjC symbols and make private symbols in the __DATA segment internal.

2019-05-09 Thread Akira Hatanaka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC360359: [CodeGen][ObjC] Remove the leading `l_` from ObjC 
symbols and make (authored by ahatanak, committed by ).

Repository:
  rC Clang

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

https://reviews.llvm.org/D61454

Files:
  lib/CodeGen/CGObjCMac.cpp
  test/CodeGenObjC/arc.m
  test/CodeGenObjC/boxing.m
  test/CodeGenObjC/exceptions-asm-attribute.m
  test/CodeGenObjC/externally-initialized-selectors.m
  test/CodeGenObjC/forward-protocol-metadata-symbols.m
  test/CodeGenObjC/instance-method-metadata.m
  test/CodeGenObjC/interface-layout-64.m
  test/CodeGenObjC/metadata-class-properties.m
  test/CodeGenObjC/metadata-symbols-32.m
  test/CodeGenObjC/metadata-symbols-64.m
  test/CodeGenObjC/metadata_symbols.m
  test/CodeGenObjC/mrc-weak.m
  test/CodeGenObjC/non-lazy-classes.m
  test/CodeGenObjC/private-extern-selector-reference.m
  test/CodeGenObjC/property-category-impl.m
  test/CodeGenObjC/property-list-in-class.m
  test/CodeGenObjC/property-list-in-extension.m
  test/CodeGenObjC/protocol-comdat.m
  test/CodeGenObjC/protocols.m
  test/CodeGenObjC/section-name.m
  test/CodeGenObjC/sections.m
  test/CodeGenObjCXX/externally-initialized-selectors.mm
  test/CodeGenObjCXX/mrc-weak.mm

Index: test/CodeGenObjC/externally-initialized-selectors.m
===
--- test/CodeGenObjC/externally-initialized-selectors.m
+++ test/CodeGenObjC/externally-initialized-selectors.m
@@ -1,7 +1,8 @@
-// RUN: %clang_cc1 -fobjc-runtime=macosx-fragile-10.5 -o - -emit-llvm %s | FileCheck %s
-// RUN: %clang_cc1 -o - -emit-llvm %s | FileCheck %s
+// RUN: %clang_cc1 -fobjc-runtime=macosx-fragile-10.5 -o - -emit-llvm %s | FileCheck -check-prefix=FRAGILE %s
+// RUN: %clang_cc1 -o - -emit-llvm %s | FileCheck -check-prefix=NONFRAGILE %s
 
-// CHECK: @OBJC_SELECTOR_REFERENCES_ = private externally_initialized global
+// NONFRAGILE: @OBJC_SELECTOR_REFERENCES_ = internal externally_initialized global
+// FRAGILE: @OBJC_SELECTOR_REFERENCES_ = private externally_initialized global
 
 void test(id x) {
   [x doSomething];
Index: test/CodeGenObjC/instance-method-metadata.m
===
--- test/CodeGenObjC/instance-method-metadata.m
+++ test/CodeGenObjC/instance-method-metadata.m
@@ -27,7 +27,7 @@
 @synthesize prop;
 @end
 
-// CHECK: l_OBJC_$_INSTANCE_METHODS_Bar:
+// CHECK: _OBJC_$_INSTANCE_METHODS_Bar:
 // CHECK-NEXT:.long   24
 // CHECK-NEXT:.long   2
 // CHECK-NEXT:.quad   L_OBJC_METH_VAR_NAME_
Index: test/CodeGenObjC/protocol-comdat.m
===
--- test/CodeGenObjC/protocol-comdat.m
+++ test/CodeGenObjC/protocol-comdat.m
@@ -20,8 +20,8 @@
 
 // CHECK: $"_OBJC_PROTOCOL_$_P" = comdat any
 // CHECK: $"_OBJC_LABEL_PROTOCOL_$_P" = comdat any
-// CHECK: $"\01l_OBJC_PROTOCOL_REFERENCE_$_Q" = comdat any
-// CHECK: $"\01l_OBJC_PROTOCOL_REFERENCE_$_R" = comdat any
+// CHECK: $"_OBJC_PROTOCOL_REFERENCE_$_Q" = comdat any
+// CHECK: $"_OBJC_PROTOCOL_REFERENCE_$_R" = comdat any
 
 // CHECK: @"_OBJC_PROTOCOL_$_P" = {{.*}}, comdat
 // CHECK: @"_OBJC_LABEL_PROTOCOL_$_P" = {{.*}}, comdat
Index: test/CodeGenObjC/non-lazy-classes.m
===
--- test/CodeGenObjC/non-lazy-classes.m
+++ test/CodeGenObjC/non-lazy-classes.m
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -Wno-objc-root-class -emit-llvm -o - %s | FileCheck %s
 
-// CHECK: @"OBJC_LABEL_NONLAZY_CLASS_$" = private global [3 x {{.*}}]{{.*}}@"OBJC_CLASS_$_A"{{.*}},{{.*}}@"OBJC_CLASS_$_D"{{.*}},{{.*}}"OBJC_CLASS_$_E"{{.*}} section "__DATA,__objc_nlclslist,regular,no_dead_strip", align 8
-// CHECK: @"OBJC_LABEL_NONLAZY_CATEGORY_$" = private global [2 x {{.*}}] {{.*}}@"\01l_OBJC_$_CATEGORY_A_$_Cat"{{.*}},{{.*}}@"\01l_OBJC_$_CATEGORY_E_$_MyCat"{{.*}}, section "__DATA,__objc_nlcatlist,regular,no_dead_strip", align 8
+// CHECK: @"OBJC_LABEL_NONLAZY_CLASS_$" = internal global [3 x {{.*}}]{{.*}}@"OBJC_CLASS_$_A"{{.*}},{{.*}}@"OBJC_CLASS_$_D"{{.*}},{{.*}}"OBJC_CLASS_$_E"{{.*}} section "__DATA,__objc_nlclslist,regular,no_dead_strip", align 8
+// CHECK: @"OBJC_LABEL_NONLAZY_CATEGORY_$" = internal global [2 x {{.*}}] {{.*}}@"_OBJC_$_CATEGORY_A_$_Cat"{{.*}},{{.*}}@"_OBJC_$_CATEGORY_E_$_MyCat"{{.*}}, section "__DATA,__objc_nlcatlist,regular,no_dead_strip", align 8
 
 @interface A @end
 @implementation A
Index: test/CodeGenObjC/metadata-symbols-64.m
===
--- test/CodeGenObjC/metadata-symbols-64.m
+++ test/CodeGenObjC/metadata-symbols-64.m
@@ -8,29 +8,29 @@
 // CHECK: @OBJC_CLASS_NAME_{{[0-9]*}} = private unnamed_addr constant {{.*}} section "__TEXT,__objc_classname,cstring_literals", align 1
 // CHECK: @OBJC_METH_VAR_NAME_{{[0-9]*}} = private unnamed_addr constant {{.*}} section 

r360359 - [CodeGen][ObjC] Remove the leading `l_` from ObjC symbols and make

2019-05-09 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Thu May  9 10:43:52 2019
New Revision: 360359

URL: http://llvm.org/viewvc/llvm-project?rev=360359=rev
Log:
[CodeGen][ObjC] Remove the leading `l_` from ObjC symbols and make
private symbols in the __DATA segment internal.

This prevents the linker from removing the symbol names. Keeping the
symbols visible enables tools to collect various information about the
symbols, for example, tools that discover whether or not a symbol gets
dirtied.

rdar://problem/48887111

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

Modified:
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/test/CodeGenObjC/arc.m
cfe/trunk/test/CodeGenObjC/boxing.m
cfe/trunk/test/CodeGenObjC/exceptions-asm-attribute.m
cfe/trunk/test/CodeGenObjC/externally-initialized-selectors.m
cfe/trunk/test/CodeGenObjC/forward-protocol-metadata-symbols.m
cfe/trunk/test/CodeGenObjC/instance-method-metadata.m
cfe/trunk/test/CodeGenObjC/interface-layout-64.m
cfe/trunk/test/CodeGenObjC/metadata-class-properties.m
cfe/trunk/test/CodeGenObjC/metadata-symbols-32.m
cfe/trunk/test/CodeGenObjC/metadata-symbols-64.m
cfe/trunk/test/CodeGenObjC/metadata_symbols.m
cfe/trunk/test/CodeGenObjC/mrc-weak.m
cfe/trunk/test/CodeGenObjC/non-lazy-classes.m
cfe/trunk/test/CodeGenObjC/private-extern-selector-reference.m
cfe/trunk/test/CodeGenObjC/property-category-impl.m
cfe/trunk/test/CodeGenObjC/property-list-in-class.m
cfe/trunk/test/CodeGenObjC/property-list-in-extension.m
cfe/trunk/test/CodeGenObjC/protocol-comdat.m
cfe/trunk/test/CodeGenObjC/protocols.m
cfe/trunk/test/CodeGenObjC/section-name.m
cfe/trunk/test/CodeGenObjC/sections.m
cfe/trunk/test/CodeGenObjCXX/externally-initialized-selectors.mm
cfe/trunk/test/CodeGenObjCXX/mrc-weak.mm

Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=360359=360358=360359=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Thu May  9 10:43:52 2019
@@ -1809,6 +1809,28 @@ static bool hasObjCExceptionAttribute(AS
   return false;
 }
 
+static llvm::GlobalValue::LinkageTypes
+getLinkageTypeForObjCMetadata(CodeGenModule , StringRef Section) {
+  if (CGM.getTriple().isOSBinFormatMachO() &&
+  (Section.empty() || Section.startswith("__DATA")))
+return llvm::GlobalValue::InternalLinkage;
+  return llvm::GlobalValue::PrivateLinkage;
+}
+
+/// A helper function to create an internal or private global variable.
+static llvm::GlobalVariable *
+finishAndCreateGlobal(ConstantInitBuilder::StructBuilder ,
+ const llvm::Twine , CodeGenModule ) {
+  std::string SectionName;
+  if (CGM.getTriple().isOSBinFormatMachO())
+SectionName = "__DATA, __objc_const";
+  auto *GV = Builder.finishAndCreateGlobal(
+  Name, CGM.getPointerAlign(), /*constant*/ false,
+  getLinkageTypeForObjCMetadata(CGM, SectionName));
+  GV->setSection(SectionName);
+  return GV;
+}
+
 /* *** CGObjCMac Public Interface *** */
 
 CGObjCMac::CGObjCMac(CodeGen::CodeGenModule ) : CGObjCCommonMac(cgm),
@@ -3105,7 +3127,7 @@ CGObjCMac::EmitProtocolExtension(const O
   values.add(classProperties);
 
   // No special section, but goes in llvm.used
-  return CreateMetadataVar("\01l_OBJC_PROTOCOLEXT_" + PD->getName(), values,
+  return CreateMetadataVar("_OBJC_PROTOCOLEXT_" + PD->getName(), values,
StringRef(), CGM.getPointerAlign(), true);
 }
 
@@ -3338,9 +3360,9 @@ void CGObjCMac::GenerateCategory(const O
 
   // If there is no category @interface then there can be no properties.
   if (Category) {
-Values.add(EmitPropertyList("\01l_OBJC_$_PROP_LIST_" + ExtName.str(),
+Values.add(EmitPropertyList("_OBJC_$_PROP_LIST_" + ExtName.str(),
 OCD, Category, ObjCTypes, false));
-Values.add(EmitPropertyList("\01l_OBJC_$_CLASS_PROP_LIST_" + ExtName.str(),
+Values.add(EmitPropertyList("_OBJC_$_CLASS_PROP_LIST_" + ExtName.str(),
 OCD, Category, ObjCTypes, true));
   } else {
 Values.addNullPointer(ObjCTypes.PropertyListPtrTy);
@@ -3686,8 +3708,8 @@ CGObjCMac::EmitClassExtension(const ObjC
 
   // Properties.
   llvm::Constant *propertyList =
-EmitPropertyList((isMetaclass ? Twine("\01l_OBJC_$_CLASS_PROP_LIST_")
-  : Twine("\01l_OBJC_$_PROP_LIST_"))
+EmitPropertyList((isMetaclass ? Twine("_OBJC_$_CLASS_PROP_LIST_")
+  : Twine("_OBJC_$_PROP_LIST_"))
 + ID->getName(),
  ID, ID->getClassInterface(), ObjCTypes, isMetaclass);
 
@@ -3935,9 +3957,10 @@ llvm::GlobalVariable *CGObjCCommonMac::C
  StringRef Section,
  CharUnits 

[PATCH] D50993: [clangd] Increase stack size of the new threads on macOS

2019-05-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

I'd still put it into LLVM to avoid platform-specific code in clangd. 
Maybe `std::abort()` in the added `...Async` function if threads are disabled? 
It's a bit unusual, but would allow keeping this function where it belongs.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D50993



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


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

2019-05-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 198868.
ilya-biryukov marked 2 inline comments as done.
ilya-biryukov added a comment.

- Use bsearch instead of upper_bound


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59887

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

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

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

2019-05-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov marked 3 inline comments as done.
ilya-biryukov added inline comments.



Comment at: clang/include/clang/Tooling/Syntax/Tokens.h:78
+  /// For debugging purposes.
+  std::string str() const;
+

sammccall wrote:
> ilya-biryukov wrote:
> > sammccall wrote:
> > > (do we need to have two names for this version?)
> > You mean to have distinct names for two different overloads?
> > I wouldn't do it, they both have fairly similar outputs, could add a small 
> > comment that the one with SourceManager should probably be preferred if you 
> > have one.
> > 
> No sorry, I meant do we need both str() and operator<<
one can type `str()` in debugger, `operator <<` is for convenience when one is 
already using streams.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59887



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


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

2019-05-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov marked 2 inline comments as done.
ilya-biryukov added inline comments.



Comment at: clang/include/clang/Tooling/Syntax/Tokens.h:62
+  SourceLocation location() const { return Location; }
+  SourceLocation endLocation() const {
+return Location.getLocWithOffset(Length);

sammccall wrote:
> ilya-biryukov wrote:
> > sammccall wrote:
> > > sadly, this would need documentation - it's the one-past-the-end 
> > > location, not the last character in the token, not the location of the 
> > > "next" token, or the location of the "next" character...
> > > 
> > > I do wonder whether this is actually the right function to expose...
> > >  Do you ever care about end but not start? (The reverse seems likelier). 
> > > Having two independent source location accessors obscures the invariant 
> > > that they have the same file ID.
> > > 
> > > I think exposing a `FileRange` accessor instead might be better, but for 
> > > now you could also make callers use 
> > > `Tok.location().getLocWithOffset(Tok.length())` until we know it's the 
> > > right pattern to encourage
> > Added a comment. With the comment and an implementation being inline and 
> > trivial, I don't think anyone would have trouble understanding what this 
> > method does.
> (this is ok. I do think a FileRange accessor would make client code more 
> readable/less error-prone. Let's discuss offline)
I've added a corresponding accessor (and a version of it that accepts a range 
of tokens) to D61681.
I'd keep it off this patch for now, will refactor in a follow-up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59887



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


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

2019-05-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 198867.
ilya-biryukov marked 5 inline comments as done.
ilya-biryukov added a comment.

- Check invariants on FileRange construction, unify access to all fields


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59887

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

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

[PATCH] D61689: Change -gz and -Wa,--compress-debug-sections to use gABI compression (SHF_COMPRESSED)

2019-05-09 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd accepted this revision.
compnerd added a comment.
This revision is now accepted and ready to land.

(Accepting with the condition that you will update the release notes before 
committing)


Repository:
  rC Clang

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

https://reviews.llvm.org/D61689



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


[PATCH] D61739: check_clang_tidy.py now passes `-format-style=none` to clang_tidy

2019-05-09 Thread Dmitri Gribenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL360358: check_clang_tidy.py now passes `-format-style=none` 
to clang_tidy (authored by gribozavr, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D61739?vs=198845=198865#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D61739

Files:
  clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py


Index: clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py
===
--- clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py
+++ clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py
@@ -69,20 +69,32 @@
   temp_file_name = temp_file_name + extension
 
   clang_tidy_extra_args = extra_args
-  if len(clang_tidy_extra_args) == 0:
-clang_tidy_extra_args = ['--']
+  clang_extra_args = []
+  if '--' in extra_args:
+i = clang_tidy_extra_args.index('--')
+clang_extra_args = clang_tidy_extra_args[i + 1:]
+clang_tidy_extra_args = clang_tidy_extra_args[:i]
+
+  # If the test does not specify a formatting style, force "none"; otherwise
+  # autodetection logic can discover a ".clang-tidy" file that is not related 
to
+  # the test.
+  if not any(
+  [arg.startswith('-format-style=') for arg in clang_tidy_extra_args]):
+clang_tidy_extra_args.append('-format-style=none')
+
+  if len(clang_extra_args) == 0:
 if extension in ['.cpp', '.hpp', '.mm']:
-  clang_tidy_extra_args.append('--std=c++11')
+  clang_extra_args.append('--std=c++11')
 if extension in ['.m', '.mm']:
-  clang_tidy_extra_args.extend(
+  clang_extra_args.extend(
   ['-fobjc-abi-version=2', '-fobjc-arc'])
 
   # Tests should not rely on STL being available, and instead provide mock
   # implementations of relevant APIs.
-  clang_tidy_extra_args.append('-nostdinc++')
+  clang_extra_args.append('-nostdinc++')
 
   if resource_dir is not None:
-clang_tidy_extra_args.append('-resource-dir=%s' % resource_dir)
+clang_extra_args.append('-resource-dir=%s' % resource_dir)
 
   with open(input_file_name, 'r') as input_file:
 input_text = input_file.read()
@@ -138,7 +150,7 @@
   write_file(original_file_name, cleaned_test)
 
   args = ['clang-tidy', temp_file_name, '-fix', '--checks=-*,' + check_name] + 
\
-clang_tidy_extra_args
+  clang_tidy_extra_args + ['--'] + clang_extra_args
   if expect_clang_tidy_error:
 args.insert(0, 'not')
   print('Running ' + repr(args) + '...')


Index: clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py
===
--- clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py
+++ clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py
@@ -69,20 +69,32 @@
   temp_file_name = temp_file_name + extension
 
   clang_tidy_extra_args = extra_args
-  if len(clang_tidy_extra_args) == 0:
-clang_tidy_extra_args = ['--']
+  clang_extra_args = []
+  if '--' in extra_args:
+i = clang_tidy_extra_args.index('--')
+clang_extra_args = clang_tidy_extra_args[i + 1:]
+clang_tidy_extra_args = clang_tidy_extra_args[:i]
+
+  # If the test does not specify a formatting style, force "none"; otherwise
+  # autodetection logic can discover a ".clang-tidy" file that is not related to
+  # the test.
+  if not any(
+  [arg.startswith('-format-style=') for arg in clang_tidy_extra_args]):
+clang_tidy_extra_args.append('-format-style=none')
+
+  if len(clang_extra_args) == 0:
 if extension in ['.cpp', '.hpp', '.mm']:
-  clang_tidy_extra_args.append('--std=c++11')
+  clang_extra_args.append('--std=c++11')
 if extension in ['.m', '.mm']:
-  clang_tidy_extra_args.extend(
+  clang_extra_args.extend(
   ['-fobjc-abi-version=2', '-fobjc-arc'])
 
   # Tests should not rely on STL being available, and instead provide mock
   # implementations of relevant APIs.
-  clang_tidy_extra_args.append('-nostdinc++')
+  clang_extra_args.append('-nostdinc++')
 
   if resource_dir is not None:
-clang_tidy_extra_args.append('-resource-dir=%s' % resource_dir)
+clang_extra_args.append('-resource-dir=%s' % resource_dir)
 
   with open(input_file_name, 'r') as input_file:
 input_text = input_file.read()
@@ -138,7 +150,7 @@
   write_file(original_file_name, cleaned_test)
 
   args = ['clang-tidy', temp_file_name, '-fix', '--checks=-*,' + check_name] + \
-clang_tidy_extra_args
+  clang_tidy_extra_args + ['--'] + clang_extra_args
   if expect_clang_tidy_error:
 args.insert(0, 'not')
   print('Running ' + repr(args) + '...')
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r360358 - check_clang_tidy.py now passes `-format-style=none` to clang_tidy

2019-05-09 Thread Dmitri Gribenko via cfe-commits
Author: gribozavr
Date: Thu May  9 10:08:10 2019
New Revision: 360358

URL: http://llvm.org/viewvc/llvm-project?rev=360358=rev
Log:
check_clang_tidy.py now passes `-format-style=none` to clang_tidy

Summary:
If the test does not specify a formatting style, force "none"; otherwise
autodetection logic can discover a ".clang-tidy" file that is not
related to the test.

Reviewers: alexfh

Subscribers: cfe-commits

Tags: #clang

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

Modified:
clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py

Modified: clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py?rev=360358=360357=360358=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py (original)
+++ clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy.py Thu May  9 
10:08:10 2019
@@ -69,20 +69,32 @@ def main():
   temp_file_name = temp_file_name + extension
 
   clang_tidy_extra_args = extra_args
-  if len(clang_tidy_extra_args) == 0:
-clang_tidy_extra_args = ['--']
+  clang_extra_args = []
+  if '--' in extra_args:
+i = clang_tidy_extra_args.index('--')
+clang_extra_args = clang_tidy_extra_args[i + 1:]
+clang_tidy_extra_args = clang_tidy_extra_args[:i]
+
+  # If the test does not specify a formatting style, force "none"; otherwise
+  # autodetection logic can discover a ".clang-tidy" file that is not related 
to
+  # the test.
+  if not any(
+  [arg.startswith('-format-style=') for arg in clang_tidy_extra_args]):
+clang_tidy_extra_args.append('-format-style=none')
+
+  if len(clang_extra_args) == 0:
 if extension in ['.cpp', '.hpp', '.mm']:
-  clang_tidy_extra_args.append('--std=c++11')
+  clang_extra_args.append('--std=c++11')
 if extension in ['.m', '.mm']:
-  clang_tidy_extra_args.extend(
+  clang_extra_args.extend(
   ['-fobjc-abi-version=2', '-fobjc-arc'])
 
   # Tests should not rely on STL being available, and instead provide mock
   # implementations of relevant APIs.
-  clang_tidy_extra_args.append('-nostdinc++')
+  clang_extra_args.append('-nostdinc++')
 
   if resource_dir is not None:
-clang_tidy_extra_args.append('-resource-dir=%s' % resource_dir)
+clang_extra_args.append('-resource-dir=%s' % resource_dir)
 
   with open(input_file_name, 'r') as input_file:
 input_text = input_file.read()
@@ -138,7 +150,7 @@ def main():
   write_file(original_file_name, cleaned_test)
 
   args = ['clang-tidy', temp_file_name, '-fix', '--checks=-*,' + check_name] + 
\
-clang_tidy_extra_args
+  clang_tidy_extra_args + ['--'] + clang_extra_args
   if expect_clang_tidy_error:
 args.insert(0, 'not')
   print('Running ' + repr(args) + '...')


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


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

2019-05-09 Thread Melanie Blower via Phabricator via cfe-commits
mibintc created this revision.
mibintc added reviewers: clang-c, fedor.sergeev.
mibintc added a project: clang.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Intel is developing an offload compiler based on clang (that will eventually be 
contributed to open source). In the course of the compilation many temporary .h 
files are generated in /tmp.  We'd like to have a way of eliding these 
dependencies from the -MD output. This new option -MD-filter=prefixstring is 
proposed.


Repository:
  rL LLVM

https://reviews.llvm.org/D61743

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

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

[PATCH] D61689: Change -gz and -Wa,--compress-debug-sections to use gABI compression (SHF_COMPRESSED)

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

I don't really have a problem with this change.  But, if we make this change, 
please include a change to the release notes *now*.  This is something which 
may catch users off guard and confuse them and require them to go looking for 
what happened.

As an aside, I think that it is high time that we consider the 
`-mlinker-version=` option coming over to Linux (and Windows?).  macOS has had 
this option for a long time, and it allows you to properly control the linker 
invocation because you know what version of the linker you are using (with a 
default version that is determined at runtime).


Repository:
  rC Clang

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

https://reviews.llvm.org/D61689



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


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

2019-05-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 198862.
ilya-biryukov marked 6 inline comments as done.
ilya-biryukov added a comment.

- Move filling the gaps at the end of files to a separate function


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59887

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

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

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

2019-05-09 Thread Russell Gallop via Phabricator via cfe-commits
russell.gallop created this revision.
russell.gallop added reviewers: rnk, bogner.
russell.gallop added a project: clang.

This is needed so lld-link can find clang_rt.profile when self hosting on 
Windows with PGO.

Trying to self host on Windows with PGO runs into undefined symbols as lld-link 
doesn't know to link clang_rt.profile as discussed here:
http://lists.llvm.org/pipermail/llvm-dev/2019-January/129500.html

Using clang-cl as a linker knows to add the library but self hosting, using 
-DCMAKE_LINKER=<...>/lld-link.exe doesn't.  I think that the cleanest way to 
make this work is to add a dependent library when using profile-instr-generate 
on Windows.

Note some cmake changes are also required to get PGO self hosting on Windows 
working. I will post them separately.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D61742

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


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


Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -66,7 +66,7 @@
 // RUN: %clang_cl -### /FA -fprofile-instr-generate=/tmp/somefile.profraw -- %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE-FILE %s
 // RUN: %clang_cl -### /FA -fprofile-instr-generate -fprofile-instr-use -- %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s
 // RUN: %clang_cl -### /FA -fprofile-instr-generate -fprofile-instr-use=file -- %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s
-// CHECK-PROFILE-GENERATE: "-fprofile-instrument=clang"
+// CHECK-PROFILE-GENERATE: "-fprofile-instrument=clang" "--dependent-lib={{[^"]*}}clang_rt.profile-{{[^"]*}}.lib"
 // CHECK-PROFILE-GENERATE-FILE: "-fprofile-instrument-path=/tmp/somefile.profraw"
 // CHECK-NO-MIX-GEN-USE: '{{[a-z=-]*}}' not allowed with '{{[a-z=-]*}}'
 
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -731,8 +731,9 @@
   Result.append(UID.begin(), UID.end());
 }
 
-static void addPGOAndCoverageFlags(Compilation , const Driver ,
-   const InputInfo , const ArgList ,
+static void addPGOAndCoverageFlags(const ToolChain , Compilation ,
+   const Driver , const InputInfo ,
+ 

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

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



Comment at: clang/lib/Tooling/Syntax/Tokens.cpp:130
+  OS << llvm::formatv(
+  "['{0}'_{1}, '{2}'_{3}) => ['{4}'_{5}, '{6}'_{7})\n",
+  PrintToken(File.SpelledTokens[M.BeginSpelled]), M.BeginSpelled,

ilya-biryukov wrote:
> sammccall wrote:
> > sammccall wrote:
> > > As predicted :-) I think these `_` suffixes are a maintenance 
> > > hazard.
> > > 
> > > In practice, the assertions are likely to add them by copy-pasting the 
> > > test output.
> > > 
> > > They guard against a class of error that doesn't seem very likely, and in 
> > > practice they don't even really prevent it (because of the copy/paste 
> > > issue).
> > > 
> > > I'd suggest just dropping them, and living with the test assertions being 
> > > slightly ambiguous.
> > > 
> > > Failing that, some slightly trickier formatting could give more context:
> > > 
> > > `A B C D E F` --> `A B  ... E F`
> > > 
> > > With special cases for smaller numbers of tokens. I don't like the 
> > > irregularity of that approach though.
> > (this one is still open)
> Will make sure to do something about it before submitting
As mentioned in the offline conversations, we both agree that we don't want to 
have ambiguous test-cases.
The proposed alternative was putting the counters of tokens **of the same 
kind** in the same token stream, with a goal of making updating test-cases 
simpler (now one would need to update only indicies of the tokens they 
changed). 

After playing around with the idea, I think this complicates the dumping 
function too much. The easiest way to update the test is to run it and 
copy-paste the expected output.
So I'd keep as is and avoiding the extra complexity if that's ok



Comment at: clang/lib/Tooling/Syntax/Tokens.cpp:226
+  TokenBuffer B(SourceMgr);
+  for (unsigned I = 0; I < Expanded.size(); ++I) {
+auto FID =

sammccall wrote:
> Is there a reason we do this at the end instead of as tokens are collected?
No strong reason, just wanted to keep the preprocessor callback minimal


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59887



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


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

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

- Move the constuction logic to a separate class, split into multiple methods.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59887

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

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

[PATCH] D61438: [ASTImporter] Use llvm::Expected and Error in the importer API

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



Comment at: clang/include/clang/AST/ASTImporter.h:203
 /// context, or the import error.
-llvm::Expected Import_New(TypeSourceInfo *FromTSI);
-// FIXME: Remove this version.
-TypeSourceInfo *Import(TypeSourceInfo *FromTSI);
+llvm::Expected Import(TypeSourceInfo *FromTSI);
 

Wouldn't it make more sense to return `Expected`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61438



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


[PATCH] D61739: check_clang_tidy.py now passes `-format-style=none` to clang_tidy

2019-05-09 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61739



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


[PATCH] D61739: check_clang_tidy.py now passes `-format-style=none` to clang_tidy

2019-05-09 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr created this revision.
gribozavr added a reviewer: alexfh.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

If the test does not specify a formatting style, force "none"; otherwise
autodetection logic can discover a ".clang-tidy" file that is not
related to the test.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D61739

Files:
  clang-tools-extra/test/clang-tidy/check_clang_tidy.py


Index: clang-tools-extra/test/clang-tidy/check_clang_tidy.py
===
--- clang-tools-extra/test/clang-tidy/check_clang_tidy.py
+++ clang-tools-extra/test/clang-tidy/check_clang_tidy.py
@@ -69,20 +69,32 @@
   temp_file_name = temp_file_name + extension
 
   clang_tidy_extra_args = extra_args
-  if len(clang_tidy_extra_args) == 0:
-clang_tidy_extra_args = ['--']
+  clang_extra_args = []
+  if '--' in extra_args:
+i = clang_tidy_extra_args.index('--')
+clang_extra_args = clang_tidy_extra_args[i + 1:]
+clang_tidy_extra_args = clang_tidy_extra_args[:i]
+
+  # If the test does not specify a formatting style, force "none"; otherwise
+  # autodetection logic can discover a ".clang-tidy" file that is not related 
to
+  # the test.
+  if not any(
+  [arg.startswith('-format-style=') for arg in clang_tidy_extra_args]):
+clang_tidy_extra_args.append('-format-style=none')
+
+  if len(clang_extra_args) == 0:
 if extension in ['.cpp', '.hpp', '.mm']:
-  clang_tidy_extra_args.append('--std=c++11')
+  clang_extra_args.append('--std=c++11')
 if extension in ['.m', '.mm']:
-  clang_tidy_extra_args.extend(
+  clang_extra_args.extend(
   ['-fobjc-abi-version=2', '-fobjc-arc'])
 
   # Tests should not rely on STL being available, and instead provide mock
   # implementations of relevant APIs.
-  clang_tidy_extra_args.append('-nostdinc++')
+  clang_extra_args.append('-nostdinc++')
 
   if resource_dir is not None:
-clang_tidy_extra_args.append('-resource-dir=%s' % resource_dir)
+clang_extra_args.append('-resource-dir=%s' % resource_dir)
 
   with open(input_file_name, 'r') as input_file:
 input_text = input_file.read()
@@ -138,7 +150,7 @@
   write_file(original_file_name, cleaned_test)
 
   args = ['clang-tidy', temp_file_name, '-fix', '--checks=-*,' + check_name] + 
\
-clang_tidy_extra_args
+  clang_tidy_extra_args + ['--'] + clang_extra_args
   if expect_clang_tidy_error:
 args.insert(0, 'not')
   print('Running ' + repr(args) + '...')


Index: clang-tools-extra/test/clang-tidy/check_clang_tidy.py
===
--- clang-tools-extra/test/clang-tidy/check_clang_tidy.py
+++ clang-tools-extra/test/clang-tidy/check_clang_tidy.py
@@ -69,20 +69,32 @@
   temp_file_name = temp_file_name + extension
 
   clang_tidy_extra_args = extra_args
-  if len(clang_tidy_extra_args) == 0:
-clang_tidy_extra_args = ['--']
+  clang_extra_args = []
+  if '--' in extra_args:
+i = clang_tidy_extra_args.index('--')
+clang_extra_args = clang_tidy_extra_args[i + 1:]
+clang_tidy_extra_args = clang_tidy_extra_args[:i]
+
+  # If the test does not specify a formatting style, force "none"; otherwise
+  # autodetection logic can discover a ".clang-tidy" file that is not related to
+  # the test.
+  if not any(
+  [arg.startswith('-format-style=') for arg in clang_tidy_extra_args]):
+clang_tidy_extra_args.append('-format-style=none')
+
+  if len(clang_extra_args) == 0:
 if extension in ['.cpp', '.hpp', '.mm']:
-  clang_tidy_extra_args.append('--std=c++11')
+  clang_extra_args.append('--std=c++11')
 if extension in ['.m', '.mm']:
-  clang_tidy_extra_args.extend(
+  clang_extra_args.extend(
   ['-fobjc-abi-version=2', '-fobjc-arc'])
 
   # Tests should not rely on STL being available, and instead provide mock
   # implementations of relevant APIs.
-  clang_tidy_extra_args.append('-nostdinc++')
+  clang_extra_args.append('-nostdinc++')
 
   if resource_dir is not None:
-clang_tidy_extra_args.append('-resource-dir=%s' % resource_dir)
+clang_extra_args.append('-resource-dir=%s' % resource_dir)
 
   with open(input_file_name, 'r') as input_file:
 input_text = input_file.read()
@@ -138,7 +150,7 @@
   write_file(original_file_name, cleaned_test)
 
   args = ['clang-tidy', temp_file_name, '-fix', '--checks=-*,' + check_name] + \
-clang_tidy_extra_args
+  clang_tidy_extra_args + ['--'] + clang_extra_args
   if expect_clang_tidy_error:
 args.insert(0, 'not')
   print('Running ' + repr(args) + '...')
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2019-05-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Here are some numbers from running `clang -cc1 -Eonly` on `SemaExpr.cpp`, it 
includes a whole ton of headers, including a rather large `TreeTransform.h`. 
This was run on my machine, so keep in mind it's rather noisy. Minimal times 
should be somewhat representative, though.

  Before:
Time (mean ± σ): 159.5 ms ±   7.3 ms[User: 137.3 ms, System: 22.1 
ms]
Range (min … max):   148.9 ms … 199.5 ms100 runs
  
  After (no callback specified):
Time (mean ± σ): 165.0 ms ±   7.5 ms[User: 142.8 ms, System: 22.2 
ms]
Range (min … max):   155.0 ms … 196.7 ms100 runs

And two more measurements with callbacks non-empty callbacks:

  Counting tokens:
Time (mean ± σ): 169.0 ms ±   9.5 ms[User: 147.3 ms, System: 21.7 
ms]
Range (min … max):   158.3 ms … 206.0 ms100 runs
  
  Saving tokens to a vector:
Time (mean ± σ): 191.0 ms ±   5.5 ms[User: 154.1 ms, System: 36.8 
ms]
Range (min … max):   180.4 ms … 221.0 ms100 runs

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59885



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


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

2019-05-09 Thread Micah S. via Phabricator via cfe-commits
micah-s added a comment.

@djasper @klimek @krasimir @sammccall @enyquist  Can I trouble you for an 
update?

In D28462#1492600 , @jkorous wrote:

> Hi @VelocityRa, just FYI - it's considered fine to ping your reviewers once 
> per week here if you've addressed their comments and there's no activity in 
> the review. Sometimes people just get distracted by other things.





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

https://reviews.llvm.org/D28462



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


[PATCH] D61734: [clangd] Bump index version and get rid of wrong assertion

2019-05-09 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE360349: [clangd] Bump index version and get rid of wrong 
assertion (authored by kadircet, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D61734?vs=198825=198828#toc

Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D61734

Files:
  clangd/index/FileIndex.cpp
  clangd/index/Serialization.cpp


Index: clangd/index/Serialization.cpp
===
--- clangd/index/Serialization.cpp
+++ clangd/index/Serialization.cpp
@@ -370,7 +370,7 @@
 // The current versioning scheme is simple - non-current versions are rejected.
 // If you make a breaking change, bump this version number to invalidate stored
 // data. Later we may want to support some backward compatibility.
-constexpr static uint32_t Version = 9;
+constexpr static uint32_t Version = 10;
 
 llvm::Expected readRIFF(llvm::StringRef Data) {
   auto RIFF = riff::readFile(Data);
Index: clangd/index/FileIndex.cpp
===
--- clangd/index/FileIndex.cpp
+++ clangd/index/FileIndex.cpp
@@ -138,7 +138,9 @@
 for (const RefSlab *Refs : MainFileRefs)
   for (const auto  : *Refs) {
 auto It = Merged.find(Sym.first);
-assert(It != Merged.end() && "Reference to unknown symbol");
+// This might happen while background-index is still running.
+if (It == Merged.end())
+  continue;
 It->getSecond().References += Sym.second.size();
   }
 SymsStorage.reserve(Merged.size());


Index: clangd/index/Serialization.cpp
===
--- clangd/index/Serialization.cpp
+++ clangd/index/Serialization.cpp
@@ -370,7 +370,7 @@
 // The current versioning scheme is simple - non-current versions are rejected.
 // If you make a breaking change, bump this version number to invalidate stored
 // data. Later we may want to support some backward compatibility.
-constexpr static uint32_t Version = 9;
+constexpr static uint32_t Version = 10;
 
 llvm::Expected readRIFF(llvm::StringRef Data) {
   auto RIFF = riff::readFile(Data);
Index: clangd/index/FileIndex.cpp
===
--- clangd/index/FileIndex.cpp
+++ clangd/index/FileIndex.cpp
@@ -138,7 +138,9 @@
 for (const RefSlab *Refs : MainFileRefs)
   for (const auto  : *Refs) {
 auto It = Merged.find(Sym.first);
-assert(It != Merged.end() && "Reference to unknown symbol");
+// This might happen while background-index is still running.
+if (It == Merged.end())
+  continue;
 It->getSecond().References += Sym.second.size();
   }
 SymsStorage.reserve(Merged.size());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60974: Clang IFSO driver action.

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



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:3590
+Twine("-interface-stubs-version=") +
+Args.getLastArgValue(options::OPT_ifso_version_EQ)));
+  }

compnerd wrote:
> Please ensure that the value being passed is valid or emit a diagnostic.
Couldn't I do this in the cc1 path? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60974



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


[PATCH] D50993: [clangd] Increase stack size of the new threads on macOS

2019-05-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D50993#1496638 , 
@Dmitry.Kozhevnikov wrote:

> In D50993#1496250 , @ilya-biryukov 
> wrote:
>
> > We should definitely land this.
> >
> > @Dmitry.Kozhevnikov, you don't have commit access, right? Should we land 
> > these two revisions for you?
>
>
> The depending review was never done for the Windows part, also I really don’t 
> like how it’ interacting with threading disabled (that’s something I’ve 
> realized after submitting the review) - so I’ve abandoned that, sorry. I 
> could make an another take next week - or should we wait for D61724 
> ?


D61724  has landed.

`LLVM_ENABLE_THREADS=Off` is now "officially" unsupported in clangd (rL360115 
), so if it's not sensible to have this in 
llvm/Support due to LLVM_ENABLE_THREADS then we can put it in clangd instead.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D50993



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


[PATCH] D50993: [clangd] Increase stack size of the new threads on macOS

2019-05-09 Thread Dmitry via Phabricator via cfe-commits
Dmitry.Kozhevnikov added a comment.

In D50993#1496250 , @ilya-biryukov 
wrote:

> We should definitely land this.
>
> @Dmitry.Kozhevnikov, you don't have commit access, right? Should we land 
> these two revisions for you?


The depending review was never done for the Windows part, also I really don’t 
like how it’ interacting with threading disabled (that’s something I’ve 
realized after submitting the review) - so I’ve abandoned that, sorry. I could 
make an another take next week - or should we wait for D61724 
?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D50993



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


[PATCH] D53866: [Preamble] Stop circular inclusion of main file when building preamble

2019-05-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov marked an inline comment as done.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LGTM. See the nit about naming of an error, though




Comment at: include/clang/Basic/DiagnosticLexKinds.td:429
   "error opening file '%0': %1">, DefaultFatal;
+def err_pp_including_mainfile_for_preamble : Error<
+  "main file cannot be included recursively when building a preamble">;

NIT: Maybe change to err_pp_including_mainfile_**in**_preamble?




Comment at: lib/Basic/SourceManager.cpp:1594
 SourceFileName = llvm::sys::path::filename(SourceFile->getName());
-if (*SourceFileName == llvm::sys::path::filename(MainFile->getName())) 
{
+if (MainFile && *SourceFileName == 
llvm::sys::path::filename(MainFile->getName())) {
   SourceFileUID = getActualFileUID(SourceFile);

nik wrote:
> ilya-biryukov wrote:
> > nik wrote:
> > > ilya-biryukov wrote:
> > > > Can this actually be`null`? 
> > > The comment for OrigEntry states that it might be null:
> > > 
> > > /// Reference to the file entry representing this ContentCache.
> > > ///
> > > /// This reference does not own the FileEntry object.
> > > ///
> > > /// It is possible for this to be NULL if the ContentCache 
> > > encapsulates
> > > /// an imaginary text buffer.
> > > const FileEntry *OrigEntry;
> > > 
> > > Note also that further down in this function, a null check for 
> > > MainContentCache->OrigEntry is done, so I believe that this was just 
> > > forgotten here (since there is also no assert) and we are the first one 
> > > running into this with the introduced call to 
> > > SourceMgr.translateFile(File).
> > > 
> > > I've tried to understand why we end up with a nullptr here, but this goes 
> > > beyond me in the time I've taken for this. What I've observed is that 
> > > module code path (LibclangReparseTest.ReparseWithModule vs 
> > > LibclangReparseTest.Reparse) creates at least a MemoryBuffer more (in 
> > > ModuleMap::parseModuleMapFile; possibly the one referred with "imaginary 
> > > text buffer" from the comment) and I suspect this to be somehow related 
> > > with the OrigEntry nullptr.
> > Should we check for equality of `MainContentCache->ContentsEntry` in that 
> > case? I guess this is what should be set for "imaginary" files.
> Does not help in this particular case as ContentsEntry is also a nullptr. All 
> the members of the ContentsCache seem to be either nullptr or 0 as that 
> particular point of execution.
> 
> How to continue?
> 
> a) Accept as is.
> b) Ask someone knowledgeable for whom this could be a no-brainer that could 
> respond hopefully soon. Any candidate?
> c) Or should I dig deeper? This can take quite some time as this area is new 
> for me.
> 
Wow, I guess I don't understand this code deep enough.
Your change looks ok, I'm happy to LGTM this. But if you're actually interested 
in digging deeper, that would be super-useful.

Based on what you're describe, it feels like "imaginary" main file works by 
accident rather than being properly handled in this function.

BTW, thanks for moving the check up, it definitely looks nicer this way.


Repository:
  rC Clang

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

https://reviews.llvm.org/D53866



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


[PATCH] D61497: [clangd] Introduce a structured hover response

2019-05-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Main comment is that I think the code is doing too much work to exactly 
reproduce the current output, and include as much information as possible.
Minimizing the diff is good all else equal, but one of the goals here is to 
have richer hovercards that are more consistent across the different codepaths 
that generate them.




Comment at: clang-tools-extra/clangd/XRefs.cpp:456
 
+// FIXME: Expose in AST/Decl ?
+void printSpecifiers(llvm::raw_ostream , const FunctionDecl *D) {

This has been pulled from DeclPrinter, so by definition duplicates info in the 
printed decl. We should only do this for info that's important, and I'm not 
sure most of this meets the bar.

 - that a function is virtual is certainly important (but isVirtual(), not 
isVirtualAsWritten())
 - that the declaration we found for a function is extern is certainly 
unimportant (it says something about the *decl*, not the function)
 - that a function is static means *something* important, but being a 
non-instance member is pretty different from being an internal helper function. 
Saying Kind=StaticMethod seems more useful for presentation than putting 
"static" next to the type again.

Aside from this, the current implementation puts these specifiers in the type, 
which they're not - functions don't return virtual ints or static strings.

I think we can probably drop these for now, and leave them in the printed decl 
only. We may want to revisit this as part of having Kind describe results more 
precisely.



Comment at: clang-tools-extra/clangd/XRefs.cpp:726
+llvm::raw_string_ostream OS(*P.Type);
+printSpecifiers(OS, PVD);
+PVD->getType().print(OS, Policy);

what are the storage class specifiers that are relevant to function parameters?



Comment at: clang-tools-extra/clangd/XRefs.cpp:737
+}
+if (FD->isVariadic()) {
+  HI.Parameters->emplace_back();

Not totally sure this is the best way to model variadics. We could consider 
leaving it out for now.



Comment at: clang-tools-extra/clangd/XRefs.cpp:1201
+
+  if (Kind == SymbolKind::String) {
+// We use SymbolKind::String for macro kinds

This really seems like the wrong idea to me.
"Kind" is a category description suitable to be shown to the user, it's 
supposed to be useful.
In odd cases we may choose to do things like not show the type if the kind is 
function.

But HoverInfo is basically a box of facts to render, and using totally 
different rendering strategies for different kinds (and assuming strings mean 
macros) cuts against this.



Comment at: clang-tools-extra/clangd/XRefs.cpp:1209
+else {
+  if (TemplateParameters) {
+Output.emplace_back();

why do we have this no-definition case?
Please avoid reinventing code to print C++ syntax if possible...



Comment at: clang-tools-extra/clangd/unittests/XRefsTests.cpp:940
   )cpp",
-  "class std::initializer_list",
+  "template<> class initializer_list {}",
   },

hmm, this is a bit weird - this uses specialization syntax but there's no 
actual specialization here right?
I think the old output without `template<>` is probably better if possible.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61497



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


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

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

In D56160#1496594 , @aaron.ballman 
wrote:

> In D56160#1496391 , @bernhardmgruber 
> wrote:
>
> > @aaron.ballman I do not have commit privileges and I would be very 
> > thankful, if you could commit this patch for me! Thank you!
>
>
> I've commit for you in r360345, thank you for the patch!


I had to revert in r360348 as the patch does not pass the testbots: 
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/48063/steps/test/logs/stdio

When you correct the issues, I'm happy to reapply the patch for you. If you 
could also fix up the link in the release notes as part of the cleanup, that 
would be great (it turned out there was a typo -- I've pointed it out in the 
review).




Comment at: docs/ReleaseNotes.rst:154-155
 
+- New :doc:`modernize-use-trailing-type-return
+  ` check.
+

These should be `modernize-use-trailing-return-type` instead (there's a typo).


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

https://reviews.llvm.org/D56160



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


[clang-tools-extra] r360349 - [clangd] Bump index version and get rid of wrong assertion

2019-05-09 Thread Kadir Cetinkaya via cfe-commits
Author: kadircet
Date: Thu May  9 08:07:53 2019
New Revision: 360349

URL: http://llvm.org/viewvc/llvm-project?rev=360349=rev
Log:
[clangd] Bump index version and get rid of wrong assertion

Summary:
After rL360344, BackgroundIndex expects symbols with zero refcounts.
Therefore existing index files are no longer valid.

Assertion regarding finding target of a reference was wrong, since
background-index might still be going on or we might've loaded only some part of
the shards and might be missing the declaring shards for the symbol.

Reviewers: ilya-biryukov

Subscribers: MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clangd/index/FileIndex.cpp
clang-tools-extra/trunk/clangd/index/Serialization.cpp

Modified: clang-tools-extra/trunk/clangd/index/FileIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/FileIndex.cpp?rev=360349=360348=360349=diff
==
--- clang-tools-extra/trunk/clangd/index/FileIndex.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/FileIndex.cpp Thu May  9 08:07:53 2019
@@ -138,7 +138,9 @@ FileSymbols::buildIndex(IndexType Type,
 for (const RefSlab *Refs : MainFileRefs)
   for (const auto  : *Refs) {
 auto It = Merged.find(Sym.first);
-assert(It != Merged.end() && "Reference to unknown symbol");
+// This might happen while background-index is still running.
+if (It == Merged.end())
+  continue;
 It->getSecond().References += Sym.second.size();
   }
 SymsStorage.reserve(Merged.size());

Modified: clang-tools-extra/trunk/clangd/index/Serialization.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Serialization.cpp?rev=360349=360348=360349=diff
==
--- clang-tools-extra/trunk/clangd/index/Serialization.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/Serialization.cpp Thu May  9 08:07:53 
2019
@@ -370,7 +370,7 @@ readRefs(Reader , llvm::ArrayRef readRIFF(llvm::StringRef Data) {
   auto RIFF = riff::readFile(Data);


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


[PATCH] D61734: [clangd] Bump index version and get rid of wrong assertion

2019-05-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61734



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


[clang-tools-extra] r360348 - Revert r360345 and r360346, as they are not passing the testbots.

2019-05-09 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Thu May  9 08:06:41 2019
New Revision: 360348

URL: http://llvm.org/viewvc/llvm-project?rev=360348=rev
Log:
Revert r360345 and r360346, as they are not passing the testbots.

http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/48063/steps/test/logs/stdio

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

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

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

Modified: clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt?rev=360348=360347=360348=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt Thu May  9 
08:06:41 2019
@@ -30,7 +30,6 @@ add_clang_library(clangTidyModernizeModu
   UseNoexceptCheck.cpp
   UseNullptrCheck.cpp
   UseOverrideCheck.cpp
-  UseTrailingReturnTypeCheck.cpp
   UseTransparentFunctorsCheck.cpp
   UseUncaughtExceptionsCheck.cpp
   UseUsingCheck.cpp

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

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

[clang-tools-extra] r360346 - Fixing a link in the release notes to appease the Sphinx bot.

2019-05-09 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Thu May  9 08:00:38 2019
New Revision: 360346

URL: http://llvm.org/viewvc/llvm-project?rev=360346=rev
Log:
Fixing a link in the release notes to appease the Sphinx bot.

Modified:
clang-tools-extra/trunk/docs/ReleaseNotes.rst

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=360346=360345=360346=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Thu May  9 08:00:38 2019
@@ -151,8 +151,8 @@ Improvements to clang-tidy
   finds and replaces cases that match the pattern ``var &&
   isa(var)``, where ``var`` is evaluated twice.
 
-- New :doc:`modernize-use-trailing-type-return
-  ` check.
+- New :doc:`modernize-use-trailing-return-type
+  ` check.
 
   Rewrites function signatures to use a trailing return type.
 


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


[PATCH] D61734: [clangd] Bump index version and get rid of wrong assertion

2019-05-09 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: ilya-biryukov.
Herald added subscribers: cfe-commits, arphaman, jkorous, MaskRay.
Herald added a project: clang.

After rL360344 , BackgroundIndex expects 
symbols with zero refcounts.
Therefore existing index files are no longer valid.

Assertion regarding finding target of a reference was wrong, since
background-index might still be going on or we might've loaded only some part of
the shards and might be missing the declaring shards for the symbol.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D61734

Files:
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/index/Serialization.cpp


Index: clang-tools-extra/clangd/index/Serialization.cpp
===
--- clang-tools-extra/clangd/index/Serialization.cpp
+++ clang-tools-extra/clangd/index/Serialization.cpp
@@ -370,7 +370,7 @@
 // The current versioning scheme is simple - non-current versions are rejected.
 // If you make a breaking change, bump this version number to invalidate stored
 // data. Later we may want to support some backward compatibility.
-constexpr static uint32_t Version = 9;
+constexpr static uint32_t Version = 10;
 
 llvm::Expected readRIFF(llvm::StringRef Data) {
   auto RIFF = riff::readFile(Data);
Index: clang-tools-extra/clangd/index/FileIndex.cpp
===
--- clang-tools-extra/clangd/index/FileIndex.cpp
+++ clang-tools-extra/clangd/index/FileIndex.cpp
@@ -138,7 +138,9 @@
 for (const RefSlab *Refs : MainFileRefs)
   for (const auto  : *Refs) {
 auto It = Merged.find(Sym.first);
-assert(It != Merged.end() && "Reference to unknown symbol");
+// This might happen while background-index is still running.
+if (It == Merged.end())
+  continue;
 It->getSecond().References += Sym.second.size();
   }
 SymsStorage.reserve(Merged.size());


Index: clang-tools-extra/clangd/index/Serialization.cpp
===
--- clang-tools-extra/clangd/index/Serialization.cpp
+++ clang-tools-extra/clangd/index/Serialization.cpp
@@ -370,7 +370,7 @@
 // The current versioning scheme is simple - non-current versions are rejected.
 // If you make a breaking change, bump this version number to invalidate stored
 // data. Later we may want to support some backward compatibility.
-constexpr static uint32_t Version = 9;
+constexpr static uint32_t Version = 10;
 
 llvm::Expected readRIFF(llvm::StringRef Data) {
   auto RIFF = riff::readFile(Data);
Index: clang-tools-extra/clangd/index/FileIndex.cpp
===
--- clang-tools-extra/clangd/index/FileIndex.cpp
+++ clang-tools-extra/clangd/index/FileIndex.cpp
@@ -138,7 +138,9 @@
 for (const RefSlab *Refs : MainFileRefs)
   for (const auto  : *Refs) {
 auto It = Merged.find(Sym.first);
-assert(It != Merged.end() && "Reference to unknown symbol");
+// This might happen while background-index is still running.
+if (It == Merged.end())
+  continue;
 It->getSecond().References += Sym.second.size();
   }
 SymsStorage.reserve(Merged.size());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2019-05-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D56160#1496391 , @bernhardmgruber 
wrote:

> @aaron.ballman I do not have commit privileges and I would be very thankful, 
> if you could commit this patch for me! Thank you!


I've commit for you in r360345, thank you for the patch!


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

https://reviews.llvm.org/D56160



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


[clang-tools-extra] r360345 - Add the modernize-use-trailing-return check to rewrite function signatures to use trailing return types.

2019-05-09 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Thu May  9 07:48:17 2019
New Revision: 360345

URL: http://llvm.org/viewvc/llvm-project?rev=360345=rev
Log:
Add the modernize-use-trailing-return check to rewrite function signatures to 
use trailing return types.

Patch by Bernhard Manfred Gruber.

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

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

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

Modified: clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt?rev=360345=360344=360345=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt Thu May  9 
07:48:17 2019
@@ -30,6 +30,7 @@ add_clang_library(clangTidyModernizeModu
   UseNoexceptCheck.cpp
   UseNullptrCheck.cpp
   UseOverrideCheck.cpp
+  UseTrailingReturnTypeCheck.cpp
   UseTransparentFunctorsCheck.cpp
   UseUncaughtExceptionsCheck.cpp
   UseUsingCheck.cpp

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

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

  1   2   >