[PATCH] D75890: [libunwind] Add flag to disable logging

2020-03-09 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.
Herald added a reviewer: mclow.lists.

I'd prefer to make this the behavior when just `NDEBUG` is set, I think it's 
rather unexpected to still get debug messages even after you set `NDEBUG`, but 
since that would be a breaking change, it deserves an email to llvm-dev to 
ensure that nobody is relying on the current behavior.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75890



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


[PATCH] D75890: [libunwind] Add flag to disable logging

2020-03-09 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan created this revision.
leonardchan added a reviewer: phosek.
Herald added subscribers: libcxx-commits, cfe-commits, mgorny.
Herald added projects: clang, libc++.

We were seeing non-deterministic binary size differences depending on which 
toolchain was used to build fuchsia. This is because libunwind embeded the 
__FILE__ path into a logging macro, even for release builds.

This adds a new flag so that release, non-baremetal builds can still opt for 
not using logging.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75890

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake
  clang/cmake/caches/Fuchsia.cmake
  libunwind/CMakeLists.txt
  libunwind/docs/BuildingLibunwind.rst
  libunwind/src/config.h

Index: libunwind/src/config.h
===
--- libunwind/src/config.h
+++ libunwind/src/config.h
@@ -114,7 +114,8 @@
 #define PPC64_HAS_VMX
 #endif
 
-#if defined(NDEBUG) && defined(_LIBUNWIND_IS_BAREMETAL)
+#if (defined(NDEBUG) && defined(_LIBUNWIND_IS_BAREMETAL)) ||   \
+defined(_LIBUNWIND_DISABLE_LOGGING)
 #define _LIBUNWIND_ABORT(msg)  \
   do { \
 abort();   \
@@ -129,7 +130,8 @@
   } while (0)
 #endif
 
-#if defined(NDEBUG) && defined(_LIBUNWIND_IS_BAREMETAL)
+#if (defined(NDEBUG) && defined(_LIBUNWIND_IS_BAREMETAL)) ||   \
+defined(_LIBUNWIND_DISABLE_LOGGING)
 #define _LIBUNWIND_LOG0(msg)
 #define _LIBUNWIND_LOG(msg, ...)
 #else
Index: libunwind/docs/BuildingLibunwind.rst
===
--- libunwind/docs/BuildingLibunwind.rst
+++ libunwind/docs/BuildingLibunwind.rst
@@ -100,6 +100,12 @@
 
   Toggle whether libunwind should be built with -m32.
 
+.. option:: LIBUNWIND_DISABLE_LOGGING:BOOL
+
+  **Default**: ``OFF``
+
+  Disable logging, regardless of if we're building for baremetal.
+
 .. option:: LIBUNWIND_ENABLE_ASSERTIONS:BOOL
 
   **Default**: ``ON``
Index: libunwind/CMakeLists.txt
===
--- libunwind/CMakeLists.txt
+++ libunwind/CMakeLists.txt
@@ -137,6 +137,7 @@
 option(LIBUNWIND_WEAK_PTHREAD_LIB "Use weak references to refer to pthread functions." OFF)
 option(LIBUNWIND_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF)
 option(LIBUNWIND_INCLUDE_DOCS "Build the libunwind documentation." ${LLVM_INCLUDE_DOCS})
+option(LIBUNWIND_DISABLE_LOGGING "Disable logging, even if we aren't on bare metal." OFF)
 
 set(LIBUNWIND_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING
 "Define suffix of library directory name (32/64)")
@@ -344,6 +345,10 @@
   endif()
 endif()
 
+if (LIBUNWIND_DISABLE_LOGGING)
+  add_compile_flags(-D_LIBUNWIND_DISABLE_LOGGING)
+endif()
+
 # Cross-unwinding
 if (NOT LIBUNWIND_ENABLE_CROSS_UNWINDING)
   add_compile_flags(-D_LIBUNWIND_IS_NATIVE_ONLY)
Index: clang/cmake/caches/Fuchsia.cmake
===
--- clang/cmake/caches/Fuchsia.cmake
+++ clang/cmake/caches/Fuchsia.cmake
@@ -42,6 +42,7 @@
 set(LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
 set(LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "")
 set(LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
+set(LIBUNWIND_DISABLE_LOGGING ON CACHE BOOL "")
 set(LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
 set(LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")
 set(LIBCXXABI_INSTALL_LIBRARY OFF CACHE BOOL "")
@@ -67,6 +68,7 @@
 set(RUNTIMES_${target}_LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "")
+set(RUNTIMES_${target}_LIBUNWIND_DISABLE_LOGGING ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -47,6 +47,7 @@
   set(LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
   set(LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "")
   set(LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
+  set(LIBUNWIND_DISABLE_LOGGING ON CACHE BOOL "")
   set(LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
   set(LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")
   set(LIBCXXABI_INSTALL_LIBRARY OFF CACHE BOOL "")
@@ -85,6 +86,7 @@
 set(RUNTIMES_${target}_LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "")
+set(RUNTIMES_${target}_LIBUNWIND_DISABLE_LOGGING ON 

[PATCH] D75323: Support relative dest paths in headermap files

2020-03-09 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno requested changes to this revision.
bruno added a comment.
This revision now requires changes to proceed.

I also want to understand why you want this change. I'm not convinced this is 
the behavior we want and it's not like we encourage people to use header maps 
in the first place. I'd be fine with such behavior under a CC1 flag though. 
Falling back to the filesystem is something that pertains more to a VFS kinda 
thing than header maps.


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

https://reviews.llvm.org/D75323



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


[PATCH] D57497: [RISCV] Passing small data limitation value to RISCV backend

2020-03-09 Thread Shiva Chen via Phabricator via cfe-commits
shiva0217 added a comment.

In D57497#1913473 , @apazos wrote:

> Shiva, we forgot about this patch. Can you rebase it so we move on with 
> merging.


Ok, I'll rebase the patch.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57497



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


[PATCH] D75579: [WIP] Replace MCTargetOptionsCommandFlags.inc and CommandFlags.inc by libraries

2020-03-09 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D75579#1912535 , @serge-sans-paille 
wrote:

> @MaskRay The library version prooved to be a bad path: we wanted clang-cpp to 
> always link to a shared library, which interacts in ungraceful ways with 
> BUILD_SHARED_LIBS.
>
> This is another attempt that looks better to me: all options are available in 
> LLVMCodeGen, but only registered if a given static constructor is called by 
> client code. Some doc and asserts are missing but that's the rough idea. Any 
> thoughts?


I think the patch is moving toward the correct direction and fixes some 
problems, so there is still value to land it. Placing static constructors in a 
header which may be included in two places in an application (application 
codegen; lld depended by the application) is bad. With this patch, at least the 
`-DBUILD_SHARED_LIBS=off` build (`libLLVM*.a`) will work now.

(A `-DBUILD_SHARED_LIBS=on` build will also work. In this case, the application 
should link against `libLLVM*.so` and `libclang*.so`, but no distribution has 
done this. The application will have to link against a number of 
`libclang*.so`, instead of a single `libclang-cpp.so`)

A copy of `libLLVMCoreGen.a` is linked into `libclang-cpp.so`. If the 
application depends on `libclang-cpp.so`, it cannot pull in another 
`libLLVMCodeGen.a`, because that will cause duplicate registration of 
`llvm::cl::opt` flags.
I agree that we have to let client code explicitly initialize (register) the 
flags.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75579



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


[PATCH] D75563: [clang][Parse] properly parse asm-qualifiers, asm inline

2020-03-09 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers planned changes to this revision.
nickdesaulniers marked 3 inline comments as done.
nickdesaulniers added a comment.

Sorry, got a little trigger happy with the refactoring.  Having a weekend to 
think about this more definitely helps.  It's nice to avoid instantiating a 
whole instance of `SemaDecl` and instead use a single `unsigned` bitfield!  I 
have a few more refactorings I'd like to do, but I'm working remote and my 
workstation is suddenly unavailable over SSH. Hopefully I can reboot it 
tomorrow.




Comment at: clang/include/clang/Parse/Parser.h:3214
+};
+GNUAsmQualifiers() : Qualifiers(0) {}
+static const char *getSpecifierName(const AQ AQ);

Might be nice to have an implicit constructor that takes a `GNUAsmQualifier` 
operand that defaults to `AQ_unspecified`.



Comment at: clang/include/clang/Parse/Parser.h:3215
+GNUAsmQualifiers() : Qualifiers(0) {}
+static const char *getSpecifierName(const AQ AQ);
+static AQ getQualifierForTokenKind(const tok::TokenKind K);

Now that we're not using `DeclSpec`, maybe we could drop this in preference of 
`operator<<`.



Comment at: clang/lib/Parse/ParseStmtAsm.cpp:358-359
+bool Parser::isGNUAsmQualifier(const Token ) const {
+  return TokAfterAsm.is(tok::kw_volatile) || TokAfterAsm.is(tok::kw_inline) ||
+ TokAfterAsm.is(tok::kw_goto);
 }

Can be implemented in terms of 
`Parser::GNUAsmQualifiers::getQualifierForTokenKind`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75563



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


[PATCH] D75563: [clang][Parse] properly parse asm-qualifiers, asm inline

2020-03-09 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 249254.
nickdesaulniers added a comment.
This revision is now accepted and ready to land.

- DRY up getting the Qualifier, and checking Tok.is


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75563

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Parse/Parser.h
  clang/lib/Parse/ParseStmtAsm.cpp
  clang/lib/Parse/Parser.cpp
  clang/test/CodeGen/inline-asm-mixed-style.c
  clang/test/Parser/asm-qualifiers.c
  clang/test/Parser/asm.c
  clang/test/Sema/asm.c

Index: clang/test/Sema/asm.c
===
--- clang/test/Sema/asm.c
+++ clang/test/Sema/asm.c
@@ -91,9 +91,6 @@
   return a;
 }
 
-// 
-asm volatile (""); // expected-warning {{meaningless 'volatile' on asm outside function}}
-
 // PR3904
 void test8(int i) {
   // A number in an input constraint can't point to a read-write constraint.
Index: clang/test/Parser/asm.c
===
--- clang/test/Parser/asm.c
+++ clang/test/Parser/asm.c
@@ -12,12 +12,6 @@
 void f2() {
   asm("foo" : "=r" (a)); // expected-error {{use of undeclared identifier 'a'}}
   asm("foo" : : "r" (b)); // expected-error {{use of undeclared identifier 'b'}} 
-
-  asm const (""); // expected-warning {{ignored const qualifier on asm}}
-  asm volatile ("");
-  asm restrict (""); // expected-warning {{ignored restrict qualifier on asm}}
-  // FIXME: Once GCC supports _Atomic, check whether it allows this.
-  asm _Atomic (""); // expected-warning {{ignored _Atomic qualifier on asm}}
 }
 
 void a() __asm__(""); // expected-error {{cannot use an empty string literal in 'asm'}}
Index: clang/test/Parser/asm-qualifiers.c
===
--- /dev/null
+++ clang/test/Parser/asm-qualifiers.c
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify %s
+
+void qualifiers(void) {
+  asm("");
+  asm volatile("");
+  asm inline("");
+  asm goto("" foo);
+foo:;
+}
+
+void unknown_qualifiers(void) {
+  asm noodle(""); // expected-error {{expected 'volatile', 'inline', 'goto', or '('}}
+  asm goto noodle("" foo); // expected-error {{expected 'volatile', 'inline', 'goto', or '('}}
+  asm volatile noodle inline(""); // expected-error {{expected 'volatile', 'inline', 'goto', or '('}}
+foo:;
+}
+
+void underscores(void) {
+  __asm__("");
+  __asm__ __volatile__("");
+  __asm__ __inline__("");
+  // Note: goto is not supported with underscore prefix+suffix.
+  __asm__ goto("" foo);
+foo:;
+}
+
+void permutations(void) {
+  asm goto inline volatile("" foo);
+  asm goto inline("");
+  asm goto volatile inline("" foo);
+  asm goto volatile("");
+  asm inline goto volatile("" foo);
+  asm inline goto("" foo);
+  asm inline volatile goto("" foo);
+  asm inline volatile("");
+  asm volatile goto("" foo);
+  asm volatile inline goto("" foo);
+  asm volatile inline("");
+foo:;
+}
+
+void duplicates(void) {
+  asm volatile volatile(""); // expected-error {{duplicate asm qualifier 'volatile'}}
+  __asm__ __volatile__ __volatile__(""); // expected-error {{duplicate asm qualifier 'volatile'}}
+  asm inline inline(""); // expected-error {{duplicate asm qualifier 'inline'}}
+  __asm__ __inline__ __inline__(""); // expected-error {{duplicate asm qualifier 'inline'}}
+  asm goto goto("" foo); // expected-error {{duplicate asm qualifier 'goto'}}
+  __asm__ goto goto("" foo); // expected-error {{duplicate asm qualifier 'goto'}}
+foo:;
+}
+
+// globals
+asm ("");
+// 
+asm volatile (""); // expected-error {{meaningless 'volatile' on asm outside function}}
+asm inline (""); // expected-error {{meaningless 'inline' on asm outside function}}
+asm goto (""noodle); // expected-error {{meaningless 'goto' on asm outside function}}
+// expected-error@-1 {{expected ')'}}
+// expected-note@-2 {{to match this '('}}
Index: clang/test/CodeGen/inline-asm-mixed-style.c
===
--- clang/test/CodeGen/inline-asm-mixed-style.c
+++ clang/test/CodeGen/inline-asm-mixed-style.c
@@ -14,11 +14,6 @@
   // CHECK: movl%ebx, %eax
   // CHECK: movl%ecx, %edx
 
-  __asm mov eax, ebx
-  __asm const ("movl %ecx, %edx"); // expected-warning {{ignored const qualifier on asm}} 
-  // CHECK: movl%ebx, %eax
-  // CHECK: movl%ecx, %edx
-
   __asm volatile goto ("movl %ecx, %edx");
   // CHECK: movl%ecx, %edx
 
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -1528,13 +1528,15 @@
   assert(Tok.is(tok::kw_asm) && "Not an asm!");
   SourceLocation Loc = 

[clang-tools-extra] 97572fa - [NFC] use hasAnyOperatorName and hasAnyOverloadedOperatorName functions in clang-tidy matchers

2020-03-09 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-03-10T00:42:21Z
New Revision: 97572fa6e9daecd648873496fd11f7d1e25a55f0

URL: 
https://github.com/llvm/llvm-project/commit/97572fa6e9daecd648873496fd11f7d1e25a55f0
DIFF: 
https://github.com/llvm/llvm-project/commit/97572fa6e9daecd648873496fd11f7d1e25a55f0.diff

LOG: [NFC] use hasAnyOperatorName and hasAnyOverloadedOperatorName functions in 
clang-tidy matchers

Added: 


Modified: 
clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
clang-tools-extra/clang-tidy/bugprone/IntegerDivisionCheck.cpp

clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp
clang-tools-extra/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp
clang-tools-extra/clang-tidy/bugprone/PosixReturnCheck.cpp
clang-tools-extra/clang-tidy/bugprone/SizeofContainerCheck.cpp
clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
clang-tools-extra/clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
clang-tools-extra/clang-tidy/bugprone/SuspiciousEnumUsageCheck.cpp
clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp
clang-tools-extra/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.cpp
clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
clang-tools-extra/clang-tidy/cert/PostfixOperatorCheck.cpp

clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp
clang-tools-extra/clang-tidy/hicpp/SignedBitwiseCheck.cpp
clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp
clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
clang-tools-extra/clang-tidy/readability/NonConstParameterCheck.cpp
clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp
clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
clang-tools-extra/clang-tidy/readability/StringCompareCheck.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp 
b/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
index 9fc7f7d36a6b..7c8f4d60dc06 100644
--- a/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
@@ -50,7 +50,7 @@ void StringFindStartswithCheck::registerMatchers(MatchFinder 
*Finder) {
   Finder->addMatcher(
   // Match [=!]= with a zero on one side and a string.find on the other.
   binaryOperator(
-  anyOf(hasOperatorName("=="), hasOperatorName("!=")),
+  hasAnyOperatorName("==", "!="),
   hasEitherOperand(ignoringParenImpCasts(ZeroLiteral)),
   hasEitherOperand(ignoringParenImpCasts(StringFind.bind("findexpr"
   .bind("expr"),

diff  --git a/clang-tools-extra/clang-tidy/bugprone/IntegerDivisionCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/IntegerDivisionCheck.cpp
index 670efe2a7b06..82993cb313ce 100644
--- a/clang-tools-extra/clang-tidy/bugprone/IntegerDivisionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/IntegerDivisionCheck.cpp
@@ -19,15 +19,11 @@ namespace bugprone {
 void IntegerDivisionCheck::registerMatchers(MatchFinder *Finder) {
   const auto IntType = hasType(isInteger());
 
-  const auto BinaryOperators = binaryOperator(anyOf(
-  hasOperatorName("%"), hasOperatorName("<<"), hasOperatorName(">>"),
-  hasOperatorName("<<"), hasOperatorName("^"), hasOperatorName("|"),
-  hasOperatorName("&"), hasOperatorName("||"), hasOperatorName("&&"),
-  hasOperatorName("<"), hasOperatorName(">"), hasOperatorName("<="),
-  hasOperatorName(">="), hasOperatorName("=="), hasOperatorName("!=")));
-
-  const auto UnaryOperators =
-  unaryOperator(anyOf(hasOperatorName("~"), hasOperatorName("!")));
+  const auto BinaryOperators = binaryOperator(
+  hasAnyOperatorName("%", "<<", ">>", "<<", "^", "|", "&", "||", "&&", "<",
+ ">", "<=", ">=", "==", "!="));
+
+  const auto UnaryOperators = unaryOperator(hasAnyOperatorName("~", "!"));
 
   const auto Exceptions =
   anyOf(BinaryOperators, conditionalOperator(), 
binaryConditionalOperator(),

diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp
 
b/clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp
index c6dc78622851..ca5209448b00 100644
--- 
a/clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp
+++ 
b/clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp
@@ -28,8 +28,7 @@ void MisplacedPointerArithmeticInAllocCheck::registerMatchers(
   hasInitializer(ignoringParenImpCasts(
   

[PATCH] D75841: [ASTMatchers] Add hasAnyOverloadedOperatorName matcher

2020-03-09 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG77eec38626cb: [ASTMatchers] Add hasAnyOverloadedOperatorName 
matcher (authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75841

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

Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -898,6 +898,12 @@
   DeclarationMatcher AnyOpStar = functionDecl(hasOverloadedOperatorName("*"));
   EXPECT_TRUE(matches("class Y; int operator*(Y &);", AnyOpStar));
   EXPECT_TRUE(matches("class Y { int operator*(); };", AnyOpStar));
+  DeclarationMatcher AnyAndOp =
+  functionDecl(hasAnyOverloadedOperatorName("&", "&&"));
+  EXPECT_TRUE(matches("class Y; Y operator&(Y &, Y &);", AnyAndOp));
+  EXPECT_TRUE(matches("class Y; Y operator&&(Y &, Y &);", AnyAndOp));
+  EXPECT_TRUE(matches("class Y { Y operator&(Y &); };", AnyAndOp));
+  EXPECT_TRUE(matches("class Y { Y operator&&(Y &); };", AnyAndOp));
 }
 
 
Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -244,6 +244,7 @@
   REGISTER_MATCHER(hasAnyDeclaration);
   REGISTER_MATCHER(hasAnyName);
   REGISTER_MATCHER(hasAnyOperatorName);
+  REGISTER_MATCHER(hasAnyOverloadedOperatorName);
   REGISTER_MATCHER(hasAnyParameter);
   REGISTER_MATCHER(hasAnyPlacementArg);
   REGISTER_MATCHER(hasAnySelector);
Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -378,6 +378,11 @@
   return HasOpNameMatcher(vectorFromRefs(NameRefs));
 }
 
+HasOverloadOpNameMatcher
+hasAnyOverloadedOperatorNameFunc(ArrayRef NameRefs) {
+  return HasOverloadOpNameMatcher(vectorFromRefs(NameRefs));
+}
+
 HasNameMatcher::HasNameMatcher(std::vector N)
 : UseUnqualifiedMatch(llvm::all_of(
   N, [](StringRef Name) { return Name.find("::") == Name.npos; })),
@@ -861,6 +866,9 @@
 const internal::VariadicFunction
 hasAnyOperatorName = {};
+const internal::VariadicFunction
+hasAnyOverloadedOperatorName = {};
 const internal::VariadicFunction, StringRef,
  internal::hasAnySelectorFunc>
 hasAnySelector = {};
Index: clang/include/clang/ASTMatchers/ASTMatchersInternal.h
===
--- clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -670,12 +670,12 @@
   static_assert(std::is_same::value ||
 std::is_base_of::value,
 "unsupported class for matcher");
-  static_assert(std::is_same::value,
-"argument type must be StringRef");
+  static_assert(std::is_same>::value,
+"argument type must be std::vector");
 
 public:
-  explicit HasOverloadedOperatorNameMatcher(const StringRef Name)
-  : SingleNodeMatcherInterface(), Name(Name) {}
+  explicit HasOverloadedOperatorNameMatcher(std::vector Names)
+  : SingleNodeMatcherInterface(), Names(std::move(Names)) {}
 
   bool matchesNode(const T ) const override {
 return matchesSpecialized(Node);
@@ -687,17 +687,18 @@
   /// so this function returns true if the call is to an operator of the given
   /// name.
   bool matchesSpecialized(const CXXOperatorCallExpr ) const {
-return getOperatorSpelling(Node.getOperator()) == Name;
+return llvm::is_contained(Names, getOperatorSpelling(Node.getOperator()));
   }
 
   /// Returns true only if CXXMethodDecl represents an overloaded
   /// operator and has the given operator name.
   bool matchesSpecialized(const FunctionDecl ) const {
 return Node.isOverloadedOperator() &&
-   getOperatorSpelling(Node.getOverloadedOperator()) == Name;
+   llvm::is_contained(
+   Names, getOperatorSpelling(Node.getOverloadedOperator()));
   }
 
-  std::string Name;
+  const std::vector Names;
 };
 
 /// Matches named declarations with a specific name.
@@ -1899,6 +1900,13 @@
 
 HasOpNameMatcher hasAnyOperatorNameFunc(ArrayRef NameRefs);
 
+using HasOverloadOpNameMatcher = PolymorphicMatcherWithParam1<
+HasOverloadedOperatorNameMatcher, std::vector,
+void(TypeList)>;
+
+HasOverloadOpNameMatcher
+hasAnyOverloadedOperatorNameFunc(ArrayRef 

[clang] 77eec38 - [ASTMatchers] Add hasAnyOverloadedOperatorName matcher

2020-03-09 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-03-10T00:11:27Z
New Revision: 77eec38626cb9e796f6cbb108ea9be5ee6e0ce81

URL: 
https://github.com/llvm/llvm-project/commit/77eec38626cb9e796f6cbb108ea9be5ee6e0ce81
DIFF: 
https://github.com/llvm/llvm-project/commit/77eec38626cb9e796f6cbb108ea9be5ee6e0ce81.diff

LOG: [ASTMatchers] Add hasAnyOverloadedOperatorName matcher

Reviewers: aaron.ballman

Reviewed By: aaron.ballman

Subscribers: cfe-commits

Tags: #clang

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

Added: 


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

Removed: 




diff  --git a/clang/docs/LibASTMatchersReference.html 
b/clang/docs/LibASTMatchersReference.html
index f0faed7f0f8f..f5208abf44bd 100644
--- a/clang/docs/LibASTMatchersReference.html
+++ b/clang/docs/LibASTMatchersReference.html
@@ -2599,6 +2599,18 @@ Narrowing Matchers
 
 
 
+Matcherhttps://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html;>CXXOperatorCallExprhasAnyOverloadedOperatorNameStringRef,
 ..., StringRef
+Matches overloaded operator names.
+
+Matches overloaded operator names specified in strings without the
+"operator" prefix: e.g. "".
+
+  hasAnyOverloadesOperatorName("+", "-")
+Is equivalent to
+  anyOf(hasOverloadedOperatorName("+"), hasOverloadedOperatorName("-"))
+
+
+
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html;>CXXOperatorCallExprhasOverloadedOperatorNameStringRef
 Name
 Matches 
overloaded operator names.
 
@@ -3178,6 +3190,18 @@ Narrowing Matchers
 
 
 
+Matcherhttps://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html;>FunctionDeclhasAnyOverloadedOperatorNameStringRef,
 ..., StringRef
+Matches overloaded operator names.
+
+Matches overloaded operator names specified in strings without the
+"operator" prefix: e.g. "".
+
+  hasAnyOverloadesOperatorName("+", "-")
+Is equivalent to
+  anyOf(hasOverloadedOperatorName("+"), hasOverloadedOperatorName("-"))
+
+
+
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html;>FunctionDeclhasDynamicExceptionSpec
 Matches 
functions that have a dynamic exception specification.
 

diff  --git a/clang/include/clang/ASTMatchers/ASTMatchers.h 
b/clang/include/clang/ASTMatchers/ASTMatchers.h
index 31138e47750c..989932b9c119 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -2749,14 +2749,30 @@ AST_MATCHER_P(NamedDecl, matchesName, std::string, 
RegExp) {
 ///
 /// Usable as: Matcher, Matcher
 inline internal::PolymorphicMatcherWithParam1<
-internal::HasOverloadedOperatorNameMatcher, StringRef,
+internal::HasOverloadedOperatorNameMatcher, std::vector,
 AST_POLYMORPHIC_SUPPORTED_TYPES(CXXOperatorCallExpr, FunctionDecl)>
 hasOverloadedOperatorName(StringRef Name) {
   return internal::PolymorphicMatcherWithParam1<
-  internal::HasOverloadedOperatorNameMatcher, StringRef,
-  AST_POLYMORPHIC_SUPPORTED_TYPES(CXXOperatorCallExpr, 
FunctionDecl)>(Name);
+  internal::HasOverloadedOperatorNameMatcher, std::vector,
+  AST_POLYMORPHIC_SUPPORTED_TYPES(CXXOperatorCallExpr, FunctionDecl)>(
+  {std::string(Name)});
 }
 
+/// Matches overloaded operator names.
+///
+/// Matches overloaded operator names specified in strings without the
+/// "operator" prefix: e.g. "<<".
+///
+///   hasAnyOverloadesOperatorName("+", "-")
+/// Is equivalent to
+///   anyOf(hasOverloadedOperatorName("+"), hasOverloadedOperatorName("-"))
+extern const internal::VariadicFunction<
+internal::PolymorphicMatcherWithParam1<
+internal::HasOverloadedOperatorNameMatcher, std::vector,
+AST_POLYMORPHIC_SUPPORTED_TYPES(CXXOperatorCallExpr, FunctionDecl)>,
+StringRef, internal::hasAnyOverloadedOperatorNameFunc>
+hasAnyOverloadedOperatorName;
+
 /// 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.

diff  --git a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h 
b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
index 6e4310fa0ee8..e363bdd9ae9c 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -670,12 +670,12 @@ class HasOverloadedOperatorNameMatcher : public 
SingleNodeMatcherInterface {
   static_assert(std::is_same::value ||
 std::is_base_of::value,
 "unsupported class for matcher");
-  static_assert(std::is_same::value,
-"argument type must be StringRef");
+  static_assert(std::is_same>::value,
+"argument type 

[clang] 6333cc2 - Revert "PR45083: Mark statement expressions as being dependent if they contain"

2020-03-09 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-03-09T17:03:56-07:00
New Revision: 6333cc2a12dc72d0cfaaac5ade00e9a1b9d6dbce

URL: 
https://github.com/llvm/llvm-project/commit/6333cc2a12dc72d0cfaaac5ade00e9a1b9d6dbce
DIFF: 
https://github.com/llvm/llvm-project/commit/6333cc2a12dc72d0cfaaac5ade00e9a1b9d6dbce.diff

LOG: Revert "PR45083: Mark statement expressions as being dependent if they 
contain"

This reverts commit 2669e41b7b9c1561a01048d5ed0aba3c62432dfc, which was
pushed by mistake.

Added: 


Modified: 
clang/include/clang/AST/Expr.h
clang/lib/AST/Expr.cpp
clang/test/SemaTemplate/dependent-expr.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index 75b7a5f6ecd3..7271dbb830a2 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -3959,8 +3959,14 @@ class StmtExpr : public Expr {
   Stmt *SubStmt;
   SourceLocation LParenLoc, RParenLoc;
 public:
-  StmtExpr(CompoundStmt *SubStmt, QualType T,
-   SourceLocation LParen, SourceLocation RParen);
+  // FIXME: Does type-dependence need to be computed 
diff erently?
+  // FIXME: Do we need to compute instantiation instantiation-dependence for
+  // statements? (ugh!)
+  StmtExpr(CompoundStmt *substmt, QualType T,
+   SourceLocation lp, SourceLocation rp) :
+Expr(StmtExprClass, T, VK_RValue, OK_Ordinary,
+ T->isDependentType(), false, false, false),
+SubStmt(substmt), LParenLoc(lp), RParenLoc(rp) { }
 
   /// Build an empty statement expression.
   explicit StmtExpr(EmptyShell Empty) : Expr(StmtExprClass, Empty) { }

diff  --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index feaa9e01f8eb..4eb7a177de00 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -4101,53 +4101,6 @@ void ExtVectorElementExpr::getEncodedElementAccess(
   }
 }
 
-StmtExpr::StmtExpr(CompoundStmt *SubStmt, QualType T, SourceLocation LParen,
-   SourceLocation RParen)
-: Expr(StmtExprClass, T, VK_RValue, OK_Ordinary, T->isDependentType(),
-   false, false, false),
-  SubStmt(SubStmt), LParenLoc(LParen), RParenLoc(RParen) {
-  llvm::SmallVector Queue(1, SubStmt);
-  while (!Queue.empty()) {
-Stmt *S = Queue.pop_back_val();
-if (!S)
-  continue;
-
-// If any subexpression is dependent, the statement expression is dependent
-// in the same way.
-if (Expr *E = dyn_cast(S)) {
-  addDependence(E->getDependence());
-  continue;
-}
-
-// FIXME: Need to properly compute whether DeclStmts contain unexpanded
-// parameter packs.
-if (DeclStmt *DS = dyn_cast(S)) {
-  for (Decl *D : DS->decls()) {
-// If any contained declaration is in a dependent context, then it
-// needs to be instantiated, so the statement expression itself is
-// instantiation-dependent.
-//
-// Note that we don't need to worry about the case where the context is
-// non-dependent but contains dependent entities here (eg, inside a
-// variable template or alias template): that can only happen at file
-// scope, where statement expressions are prohibited.
-if (D->getLexicalDeclContext()->isDependentContext())
-  addDependence(ExprDependence::Instantiation);
-
-// If any contained variable declaration has a dependent type, we can't
-// evaluate that declaration.
-if (auto *VD = dyn_cast(D))
-  if (VD->getType()->isDependentType())
-addDependence(ExprDependence::Value);
-  }
-}
-
-// Recurse to substatements.
-// FIXME: Should we skip the unchosen side of 'if constexpr' if known?
-Queue.insert(Queue.end(), S->child_begin(), S->child_end());
-  }
-}
-
 ShuffleVectorExpr::ShuffleVectorExpr(const ASTContext , ArrayRef args,
  QualType Type, SourceLocation BLoc,
  SourceLocation RP)

diff  --git a/clang/test/SemaTemplate/dependent-expr.cpp 
b/clang/test/SemaTemplate/dependent-expr.cpp
index 12a99acc21cd..bb1e239c3490 100644
--- a/clang/test/SemaTemplate/dependent-expr.cpp
+++ b/clang/test/SemaTemplate/dependent-expr.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++2a %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
 
 // PR5908
 template 
@@ -107,42 +108,3 @@ namespace PR18152 {
   };
   template struct A<0>;
 }
-
-template void stmt_expr_1() {
-  // GCC doesn't check this: it appears to treat statement-expressions as being
-  // value-dependent if they appear in a dependent context, regardless of their
-  // contents.
-  static_assert( ({ false; }), "" ); // expected-error {{failed}}
-}
-void stmt_expr_2() {
-  static_assert( ({ false; }), "" ); // expected-error {{failed}}
-}
-
-namespace PR45083 {
-  struct A { bool x; };
-
-  template struct B : A {
-void f() {
-  const 

[clang] 2669e41 - PR45083: Mark statement expressions as being dependent if they contain

2020-03-09 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-03-09T16:57:07-07:00
New Revision: 2669e41b7b9c1561a01048d5ed0aba3c62432dfc

URL: 
https://github.com/llvm/llvm-project/commit/2669e41b7b9c1561a01048d5ed0aba3c62432dfc
DIFF: 
https://github.com/llvm/llvm-project/commit/2669e41b7b9c1561a01048d5ed0aba3c62432dfc.diff

LOG: PR45083: Mark statement expressions as being dependent if they contain
dependent constructs.

We previously assumed they were neither value- nor
instantiation-dependent under any circumstances, which would lead to
crashes and other misbehavior.

This doesn't match GCC's behavior (where statement expressions appear to
be treated as value-dependent if they appear in a dependent context),
but seems to be the best thing we can do in the short term: it turns out
to be remarkably difficult for us to correctly determine whether we are
in a dependent context (and it's not even possible in some cases, such
as in a generic lambda where we might not have seen the 'auto' yet).

This was previously reverted in 8e4a867 for rejecting some code, but that
code was invalid and Clang was previously incorrectly accepting it.

Added: 


Modified: 
clang/include/clang/AST/Expr.h
clang/lib/AST/Expr.cpp
clang/test/SemaTemplate/dependent-expr.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index 7271dbb830a2..75b7a5f6ecd3 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -3959,14 +3959,8 @@ class StmtExpr : public Expr {
   Stmt *SubStmt;
   SourceLocation LParenLoc, RParenLoc;
 public:
-  // FIXME: Does type-dependence need to be computed 
diff erently?
-  // FIXME: Do we need to compute instantiation instantiation-dependence for
-  // statements? (ugh!)
-  StmtExpr(CompoundStmt *substmt, QualType T,
-   SourceLocation lp, SourceLocation rp) :
-Expr(StmtExprClass, T, VK_RValue, OK_Ordinary,
- T->isDependentType(), false, false, false),
-SubStmt(substmt), LParenLoc(lp), RParenLoc(rp) { }
+  StmtExpr(CompoundStmt *SubStmt, QualType T,
+   SourceLocation LParen, SourceLocation RParen);
 
   /// Build an empty statement expression.
   explicit StmtExpr(EmptyShell Empty) : Expr(StmtExprClass, Empty) { }

diff  --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 4eb7a177de00..feaa9e01f8eb 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -4101,6 +4101,53 @@ void ExtVectorElementExpr::getEncodedElementAccess(
   }
 }
 
+StmtExpr::StmtExpr(CompoundStmt *SubStmt, QualType T, SourceLocation LParen,
+   SourceLocation RParen)
+: Expr(StmtExprClass, T, VK_RValue, OK_Ordinary, T->isDependentType(),
+   false, false, false),
+  SubStmt(SubStmt), LParenLoc(LParen), RParenLoc(RParen) {
+  llvm::SmallVector Queue(1, SubStmt);
+  while (!Queue.empty()) {
+Stmt *S = Queue.pop_back_val();
+if (!S)
+  continue;
+
+// If any subexpression is dependent, the statement expression is dependent
+// in the same way.
+if (Expr *E = dyn_cast(S)) {
+  addDependence(E->getDependence());
+  continue;
+}
+
+// FIXME: Need to properly compute whether DeclStmts contain unexpanded
+// parameter packs.
+if (DeclStmt *DS = dyn_cast(S)) {
+  for (Decl *D : DS->decls()) {
+// If any contained declaration is in a dependent context, then it
+// needs to be instantiated, so the statement expression itself is
+// instantiation-dependent.
+//
+// Note that we don't need to worry about the case where the context is
+// non-dependent but contains dependent entities here (eg, inside a
+// variable template or alias template): that can only happen at file
+// scope, where statement expressions are prohibited.
+if (D->getLexicalDeclContext()->isDependentContext())
+  addDependence(ExprDependence::Instantiation);
+
+// If any contained variable declaration has a dependent type, we can't
+// evaluate that declaration.
+if (auto *VD = dyn_cast(D))
+  if (VD->getType()->isDependentType())
+addDependence(ExprDependence::Value);
+  }
+}
+
+// Recurse to substatements.
+// FIXME: Should we skip the unchosen side of 'if constexpr' if known?
+Queue.insert(Queue.end(), S->child_begin(), S->child_end());
+  }
+}
+
 ShuffleVectorExpr::ShuffleVectorExpr(const ASTContext , ArrayRef args,
  QualType Type, SourceLocation BLoc,
  SourceLocation RP)

diff  --git a/clang/test/SemaTemplate/dependent-expr.cpp 
b/clang/test/SemaTemplate/dependent-expr.cpp
index bb1e239c3490..12a99acc21cd 100644
--- a/clang/test/SemaTemplate/dependent-expr.cpp
+++ b/clang/test/SemaTemplate/dependent-expr.cpp
@@ -1,5 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
-// 

[PATCH] D75563: [clang][Parse] properly parse asm-qualifiers, asm inline

2020-03-09 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 249246.
nickdesaulniers added a comment.
This revision is now accepted and ready to land.

- rebase, divorce from DeclSpec


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75563

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Parse/Parser.h
  clang/lib/Parse/ParseStmtAsm.cpp
  clang/lib/Parse/Parser.cpp
  clang/test/CodeGen/inline-asm-mixed-style.c
  clang/test/Parser/asm-qualifiers.c
  clang/test/Parser/asm.c
  clang/test/Sema/asm.c

Index: clang/test/Sema/asm.c
===
--- clang/test/Sema/asm.c
+++ clang/test/Sema/asm.c
@@ -91,9 +91,6 @@
   return a;
 }
 
-// 
-asm volatile (""); // expected-warning {{meaningless 'volatile' on asm outside function}}
-
 // PR3904
 void test8(int i) {
   // A number in an input constraint can't point to a read-write constraint.
Index: clang/test/Parser/asm.c
===
--- clang/test/Parser/asm.c
+++ clang/test/Parser/asm.c
@@ -12,12 +12,6 @@
 void f2() {
   asm("foo" : "=r" (a)); // expected-error {{use of undeclared identifier 'a'}}
   asm("foo" : : "r" (b)); // expected-error {{use of undeclared identifier 'b'}} 
-
-  asm const (""); // expected-warning {{ignored const qualifier on asm}}
-  asm volatile ("");
-  asm restrict (""); // expected-warning {{ignored restrict qualifier on asm}}
-  // FIXME: Once GCC supports _Atomic, check whether it allows this.
-  asm _Atomic (""); // expected-warning {{ignored _Atomic qualifier on asm}}
 }
 
 void a() __asm__(""); // expected-error {{cannot use an empty string literal in 'asm'}}
Index: clang/test/Parser/asm-qualifiers.c
===
--- /dev/null
+++ clang/test/Parser/asm-qualifiers.c
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify %s
+
+void qualifiers(void) {
+  asm("");
+  asm volatile("");
+  asm inline("");
+  asm goto("" foo);
+foo:;
+}
+
+void unknown_qualifiers(void) {
+  asm noodle(""); // expected-error {{expected 'volatile', 'inline', 'goto', or '('}}
+  asm goto noodle("" foo); // expected-error {{expected 'volatile', 'inline', 'goto', or '('}}
+  asm volatile noodle inline(""); // expected-error {{expected 'volatile', 'inline', 'goto', or '('}}
+foo:;
+}
+
+void underscores(void) {
+  __asm__("");
+  __asm__ __volatile__("");
+  __asm__ __inline__("");
+  // Note: goto is not supported with underscore prefix+suffix.
+  __asm__ goto("" foo);
+foo:;
+}
+
+void permutations(void) {
+  asm goto inline volatile("" foo);
+  asm goto inline("");
+  asm goto volatile inline("" foo);
+  asm goto volatile("");
+  asm inline goto volatile("" foo);
+  asm inline goto("" foo);
+  asm inline volatile goto("" foo);
+  asm inline volatile("");
+  asm volatile goto("" foo);
+  asm volatile inline goto("" foo);
+  asm volatile inline("");
+foo:;
+}
+
+void duplicates(void) {
+  asm volatile volatile(""); // expected-error {{duplicate asm qualifier 'volatile'}}
+  __asm__ __volatile__ __volatile__(""); // expected-error {{duplicate asm qualifier 'volatile'}}
+  asm inline inline(""); // expected-error {{duplicate asm qualifier 'inline'}}
+  __asm__ __inline__ __inline__(""); // expected-error {{duplicate asm qualifier 'inline'}}
+  asm goto goto("" foo); // expected-error {{duplicate asm qualifier 'goto'}}
+  __asm__ goto goto("" foo); // expected-error {{duplicate asm qualifier 'goto'}}
+foo:;
+}
+
+// globals
+asm ("");
+// 
+asm volatile (""); // expected-error {{meaningless 'volatile' on asm outside function}}
+asm inline (""); // expected-error {{meaningless 'inline' on asm outside function}}
+asm goto (""noodle); // expected-error {{meaningless 'goto' on asm outside function}}
+// expected-error@-1 {{expected ')'}}
+// expected-note@-2 {{to match this '('}}
Index: clang/test/CodeGen/inline-asm-mixed-style.c
===
--- clang/test/CodeGen/inline-asm-mixed-style.c
+++ clang/test/CodeGen/inline-asm-mixed-style.c
@@ -14,11 +14,6 @@
   // CHECK: movl%ebx, %eax
   // CHECK: movl%ecx, %edx
 
-  __asm mov eax, ebx
-  __asm const ("movl %ecx, %edx"); // expected-warning {{ignored const qualifier on asm}} 
-  // CHECK: movl%ebx, %eax
-  // CHECK: movl%ecx, %edx
-
   __asm volatile goto ("movl %ecx, %edx");
   // CHECK: movl%ecx, %edx
 
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -1528,13 +1528,22 @@
   assert(Tok.is(tok::kw_asm) && "Not an asm!");
   SourceLocation Loc = ConsumeToken();
 
- 

[PATCH] D75563: [clang][Parse] properly parse asm-qualifiers, asm inline

2020-03-09 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers planned changes to this revision.
nickdesaulniers added a comment.

In D75563#1911375 , @aaron.ballman 
wrote:

> Thank you for working on this, this LGTM! If you wanted a follow-up patch 
> beyond adding semantic support for the `inline` keyword, I think it might 
> make sense to investigate divorcing the qualifier parsing from the `DeclSpec` 
> interface. These are ASM statements, not declarations, so the fact that we're 
> using a DeclSpec to smuggle the qualifiers around is a bit unexpected. 
> However, I don't think that work needs to hold up this patch.


I agree and I think that recommendation is in good taste. I'd rather do things 
the right way now and hopefully never need to revisit.  Also, there's no rush 
on this.  I'll declare a new class for the qualifiers, since we just need to 
know which qualifiers were used (what is essentially 3 booleans) and strings 
for each.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75563



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


[PATCH] D75563: [clang][Parse] properly parse asm-qualifiers, asm inline

2020-03-09 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers planned changes to this revision.
nickdesaulniers marked an inline comment as done.
nickdesaulniers added inline comments.



Comment at: clang/lib/Parse/Parser.cpp:1545
+Diag(Tok, diag::err_global_asm_qualifier_ignored)
+<< GNUAsmQualifiers::getSpecifierName(AQ)
+<< FixItHint::CreateRemoval(RemovalRange);

This pattern is repeated twice, let me see if I can DRY that up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75563



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


[PATCH] D75714: Add Optional overload to DiagnosticBuilder operator <

2020-03-09 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

In D75714#1913230 , @aaron.ballman 
wrote:

> Is there any code we can cleanup as a result of adding these overloads? I 
> would have expected to see some code changes justifying each additional 
> overload, which would also give us test coverage for the changes.


I planned to add usages in follow ups but I can add them here


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75714



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


[PATCH] D75491: [CodeGenObjC] Privatize some ObjC metadata symbols

2020-03-09 Thread Erik Pilkington via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7fbf15a8f2df: [CodeGenObjC] Privatize some ObjC metadata 
symbols (authored by erik.pilkington).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75491

Files:
  clang/lib/CodeGen/CGObjCMac.cpp
  clang/test/CodeGenObjC/class-stubs.m
  clang/test/CodeGenObjC/exceptions-asm-attribute.m
  clang/test/CodeGenObjC/metadata-symbols-64.m
  clang/test/CodeGenObjC/metadata_symbols.m
  clang/test/CodeGenObjC/non-lazy-classes.m
  clang/test/CodeGenObjC/sections.m

Index: clang/test/CodeGenObjC/sections.m
===
--- clang/test/CodeGenObjC/sections.m
+++ clang/test/CodeGenObjC/sections.m
@@ -61,15 +61,15 @@
 // CHECK-ELF: !{{[0-9]+}} = !{i32 1, !"Objective-C Image Info Section", !"objc_imageinfo"}
 
 // CHECK-MACHO: @"_OBJC_$_CLASS_METHODS_I" = internal {{.*}}, section "__DATA, __objc_const"
-// CHECK-MACHO: @"OBJC_CLASSLIST_SUP_REFS_$_" = internal {{.*}}, section "__DATA,__objc_superrefs,regular,no_dead_strip"
+// CHECK-MACHO: @"OBJC_CLASSLIST_SUP_REFS_$_" = private {{.*}}, section "__DATA,__objc_superrefs,regular,no_dead_strip"
 // CHECK-MACHO: @OBJC_SELECTOR_REFERENCES_ = internal {{.*}}, section "__DATA,__objc_selrefs,literal_pointers,no_dead_strip"
 // CHECK-MACHO: @"OBJC_CLASSLIST_REFERENCES_$_" = internal {{.*}}, section "__DATA,__objc_classrefs,regular,no_dead_strip"
 // CHECK-MACHO: @_objc_msgSend_fixup_class = {{.*}}, section "__DATA,__objc_msgrefs,coalesced"
 // CHECK-MACHO: @"_OBJC_LABEL_PROTOCOL_$_P" = {{.*}}, section "__DATA,__objc_protolist,coalesced,no_dead_strip"
 // CHECK-MACHO: @"_OBJC_PROTOCOL_REFERENCE_$_P" = {{.*}}, section "__DATA,__objc_protorefs,coalesced,no_dead_strip"
-// CHECK-MACHO: @"OBJC_LABEL_CLASS_$" = internal {{.*}}, section "__DATA,__objc_classlist,regular,no_dead_strip"
-// CHECK-MACHO: @"OBJC_LABEL_NONLAZY_CLASS_$" = internal {{.*}}, section "__DATA,__objc_nlclslist,regular,no_dead_strip"
-// CHECK-MACHO: @"OBJC_LABEL_CATEGORY_$" = internal {{.*}}, section "__DATA,__objc_catlist,regular,no_dead_strip"
-// CHECK-MACHO: @"OBJC_LABEL_NONLAZY_CATEGORY_$" = internal {{.*}}, section "__DATA,__objc_nlcatlist,regular,no_dead_strip"
+// CHECK-MACHO: @"OBJC_LABEL_CLASS_$" = private {{.*}}, section "__DATA,__objc_classlist,regular,no_dead_strip"
+// CHECK-MACHO: @"OBJC_LABEL_NONLAZY_CLASS_$" = private {{.*}}, section "__DATA,__objc_nlclslist,regular,no_dead_strip"
+// CHECK-MACHO: @"OBJC_LABEL_CATEGORY_$" = private {{.*}}, section "__DATA,__objc_catlist,regular,no_dead_strip"
+// CHECK-MACHO: @"OBJC_LABEL_NONLAZY_CATEGORY_$" = private {{.*}}, section "__DATA,__objc_nlcatlist,regular,no_dead_strip"
 // CHECK-MACHO: !{{[0-9]+}} = !{i32 1, !"Objective-C Image Info Section", !"__DATA,__objc_imageinfo,regular,no_dead_strip"}
 
Index: clang/test/CodeGenObjC/non-lazy-classes.m
===
--- clang/test/CodeGenObjC/non-lazy-classes.m
+++ clang/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_$" = 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
+// 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 {{.*}}] {{.*}}@"_OBJC_$_CATEGORY_A_$_Cat"{{.*}},{{.*}}@"_OBJC_$_CATEGORY_E_$_MyCat"{{.*}}, section "__DATA,__objc_nlcatlist,regular,no_dead_strip", align 8
 
 @interface A @end
 @implementation A
Index: clang/test/CodeGenObjC/metadata_symbols.m
===
--- clang/test/CodeGenObjC/metadata_symbols.m
+++ clang/test/CodeGenObjC/metadata_symbols.m
@@ -14,7 +14,7 @@
 // CHECK-X86_64: @"OBJC_EHTYPE_$_EH1" = weak global {{.*}}, align 8
 // CHECK-X86_64: @"OBJC_EHTYPE_$_EH2" = external global
 // CHECK-X86_64: @"OBJC_EHTYPE_$_EH3" = global {{.*}}, section "__DATA,__objc_const", align 8
-// CHECK-X86_64: @"OBJC_LABEL_CLASS_$" = internal global {{.*}}, section "__DATA,__objc_classlist,regular,no_dead_strip", align 8
+// CHECK-X86_64: @"OBJC_LABEL_CLASS_$" = private global {{.*}}, section "__DATA,__objc_classlist,regular,no_dead_strip", align 8
 // CHECK-X86_64: define internal void @"\01-[A im0]"
 // CHECK-X86_64: 

[PATCH] D74104: Remove test dependency on the presence of an assembler

2020-03-09 Thread Douglas Yung via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG54d82255fd27: Change tests to use -S instead of -c to work 
when an external assembler is used… (authored by dyung).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74104

Files:
  clang/test/Analysis/scan-build/exclude_directories.test
  clang/test/Analysis/scan-build/html_output.test
  clang/test/Analysis/scan-build/plist_html_output.test
  clang/test/Analysis/scan-build/plist_output.test


Index: clang/test/Analysis/scan-build/plist_output.test
===
--- clang/test/Analysis/scan-build/plist_output.test
+++ clang/test/Analysis/scan-build/plist_output.test
@@ -5,7 +5,7 @@
 UNSUPPORTED: system-windows
 
 RUN: rm -rf %t.output_dir && mkdir %t.output_dir
-RUN: %scan-build -plist -o %t.output_dir %clang -c 
%S/Inputs/single_null_dereference.c \
+RUN: %scan-build -plist -o %t.output_dir %clang -S 
%S/Inputs/single_null_dereference.c \
 RUN: | FileCheck %s -check-prefix CHECK-STDOUT
 
 // Test plist output
Index: clang/test/Analysis/scan-build/plist_html_output.test
===
--- clang/test/Analysis/scan-build/plist_html_output.test
+++ clang/test/Analysis/scan-build/plist_html_output.test
@@ -5,7 +5,7 @@
 UNSUPPORTED: system-windows
 
 RUN: rm -rf %t.output_dir && mkdir %t.output_dir
-RUN: %scan-build -plist-html -o %t.output_dir %clang -c 
%S/Inputs/single_null_dereference.c \
+RUN: %scan-build -plist-html -o %t.output_dir %clang -S 
%S/Inputs/single_null_dereference.c \
 RUN: | FileCheck %s -check-prefix CHECK-STDOUT
 
 // Test combined plist and html output with -plist-html
Index: clang/test/Analysis/scan-build/html_output.test
===
--- clang/test/Analysis/scan-build/html_output.test
+++ clang/test/Analysis/scan-build/html_output.test
@@ -5,7 +5,7 @@
 UNSUPPORTED: system-windows
 
 RUN: rm -rf %t.output_dir && mkdir %t.output_dir
-RUN: %scan-build -o %t.output_dir %clang -c 
%S/Inputs/single_null_dereference.c \
+RUN: %scan-build -o %t.output_dir %clang -S 
%S/Inputs/single_null_dereference.c \
 RUN: | FileCheck %s -check-prefix CHECK-STDOUT
 
 // Test html output
Index: clang/test/Analysis/scan-build/exclude_directories.test
===
--- clang/test/Analysis/scan-build/exclude_directories.test
+++ clang/test/Analysis/scan-build/exclude_directories.test
@@ -5,7 +5,7 @@
 UNSUPPORTED: system-windows
 
 RUN: rm -rf %t.output_dir && mkdir %t.output_dir
-RUN: %scan-build -o %t.output_dir %clang -c \
+RUN: %scan-build -o %t.output_dir %clang -S \
 RUN: %S/Inputs/multidirectory_project/directory1/file1.c \
 RUN: %S/Inputs/multidirectory_project/directory2/file2.c \
 RUN: | FileCheck %s -check-prefix CHECK-NO-EXCLUDE
@@ -21,7 +21,7 @@
 
 // Only one issue should be found when directory1 is excluded.
 RUN: rm -rf %t.output_dir && mkdir %t.output_dir
-RUN: %scan-build -o %t.output_dir --exclude directory1 %clang -c \
+RUN: %scan-build -o %t.output_dir --exclude directory1 %clang -S \
 RUN: %S/Inputs/multidirectory_project/directory1/file1.c \
 RUN: %S/Inputs/multidirectory_project/directory2/file2.c \
 RUN: | FileCheck %s -check-prefix CHECK-EXCLUDE1
@@ -31,7 +31,7 @@
 
 // When both directories are excluded, no issues should be reported.
 RUN: rm -rf %t.output_dir && mkdir %t.output_dir
-RUN: %scan-build -o %t.output_dir --exclude directory1 --exclude directory2 
%clang -c \
+RUN: %scan-build -o %t.output_dir --exclude directory1 --exclude directory2 
%clang -S \
 RUN: %S/Inputs/multidirectory_project/directory1/file1.c \
 RUN: %S/Inputs/multidirectory_project/directory2/file2.c \
 RUN: | FileCheck %s -check-prefix CHECK-EXCLUDE-BOTH


Index: clang/test/Analysis/scan-build/plist_output.test
===
--- clang/test/Analysis/scan-build/plist_output.test
+++ clang/test/Analysis/scan-build/plist_output.test
@@ -5,7 +5,7 @@
 UNSUPPORTED: system-windows
 
 RUN: rm -rf %t.output_dir && mkdir %t.output_dir
-RUN: %scan-build -plist -o %t.output_dir %clang -c %S/Inputs/single_null_dereference.c \
+RUN: %scan-build -plist -o %t.output_dir %clang -S %S/Inputs/single_null_dereference.c \
 RUN: | FileCheck %s -check-prefix CHECK-STDOUT
 
 // Test plist output
Index: clang/test/Analysis/scan-build/plist_html_output.test
===
--- clang/test/Analysis/scan-build/plist_html_output.test
+++ clang/test/Analysis/scan-build/plist_html_output.test
@@ -5,7 +5,7 @@
 UNSUPPORTED: system-windows
 
 RUN: rm -rf %t.output_dir && mkdir %t.output_dir
-RUN: %scan-build -plist-html -o %t.output_dir %clang -c %S/Inputs/single_null_dereference.c \
+RUN: %scan-build 

[PATCH] D57497: [RISCV] Passing small data limitation value to RISCV backend

2020-03-09 Thread Ana Pazos via Phabricator via cfe-commits
apazos added a comment.
Herald added subscribers: evandro, luismarques, sameer.abuasal, pzheng, 
s.egerton, lenary.

Shiva, we forgot about this patch. Can you rebase it so we move on with merging.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57497



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


[PATCH] D74669: [clang-tidy] New check: bugprone-suspicious-include

2020-03-09 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs marked 6 inline comments as done.
jroelofs added a comment.

https://github.com/llvm/llvm-project/commit/52bbdad7d63fd060d102b3591b433d116a982255


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74669



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


[clang-tools-extra] 52bbdad - [clang-tidy][docs] Post-commit feedback on D74669

2020-03-09 Thread Jonathan Roelofs via cfe-commits

Author: Jonathan Roelofs
Date: 2020-03-09T16:51:41-06:00
New Revision: 52bbdad7d63fd060d102b3591b433d116a982255

URL: 
https://github.com/llvm/llvm-project/commit/52bbdad7d63fd060d102b3591b433d116a982255
DIFF: 
https://github.com/llvm/llvm-project/commit/52bbdad7d63fd060d102b3591b433d116a982255.diff

LOG: [clang-tidy][docs] Post-commit feedback on D74669

Added: 


Modified: 
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-include.rst

Removed: 




diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index aa9ff71ef7f8..3da1433934c4 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -82,6 +82,13 @@ New checks
 
   Checks for usages of identifiers reserved for use by the implementation.
 
+- New :doc:`bugprone-suspicious-include
+  ` check.
+
+  Finds cases where an include refers to what appears to be an implementation
+  file, which often leads to hard-to-track-down ODR violations, and diagnoses
+  them.
+
 - New :doc:`cert-oop57-cpp
   ` check.
 
@@ -98,12 +105,6 @@ New checks
 
   Finds recursive functions and diagnoses them.
 
-- New :doc:`bugprone-suspicious-include
-  ` check.
-
-  Finds includes that appear to be referring to implementation files (which
-  tends to cause ODR violations), and diagnoses them.
-
 New check aliases
 ^
 

diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-include.rst 
b/clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-include.rst
index 95a90c4f1fb8..9d6c41da504e 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-include.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-include.rst
@@ -3,8 +3,8 @@
 bugprone-suspicious-include
 ===
 
-The checker detects various cases when an include refers to what appears to be
-an implementation file, which often leads to hard-to-track-down ODR violations.
+The check detects various cases when an include refers to what appears to be an
+implementation file, which often leads to hard-to-track-down ODR violations.
 
 Examples:
 
@@ -20,7 +20,7 @@ Options
 ---
 .. option:: HeaderFileExtensions
 
-   Default value: ";h;hh;hpp;hxx"
+   Default value: `";h;hh;hpp;hxx"`
A semicolon-separated list of filename extensions of header files (the
filename extensions should not contain a "." prefix). For extension-less
header files, use an empty string or leave an empty string between ";"
@@ -28,6 +28,6 @@ Options
 
 .. option:: ImplementationFileExtensions
 
-   Default value: "c;cc;cpp;cxx"
+   Default value: `"c;cc;cpp;cxx"`
Likewise, a semicolon-separated list of filename extensions of
implementation files.



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


[clang] 54d8225 - Change tests to use -S instead of -c to work when an external assembler is used that is not present. NFCI.

2020-03-09 Thread Douglas Yung via cfe-commits

Author: Douglas Yung
Date: 2020-03-09T15:45:00-07:00
New Revision: 54d82255fd270e87de5147e6b771b63d48552e71

URL: 
https://github.com/llvm/llvm-project/commit/54d82255fd270e87de5147e6b771b63d48552e71
DIFF: 
https://github.com/llvm/llvm-project/commit/54d82255fd270e87de5147e6b771b63d48552e71.diff

LOG: Change tests to use -S instead of -c to work when an external assembler is 
used that is not present. NFCI.

Reviewed By: NoQ

Subscribers: Charusso, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/test/Analysis/scan-build/exclude_directories.test
clang/test/Analysis/scan-build/html_output.test
clang/test/Analysis/scan-build/plist_html_output.test
clang/test/Analysis/scan-build/plist_output.test

Removed: 




diff  --git a/clang/test/Analysis/scan-build/exclude_directories.test 
b/clang/test/Analysis/scan-build/exclude_directories.test
index 56acbd15b8fb..60ea0aa002af 100644
--- a/clang/test/Analysis/scan-build/exclude_directories.test
+++ b/clang/test/Analysis/scan-build/exclude_directories.test
@@ -5,7 +5,7 @@ REQUIRES: shell
 UNSUPPORTED: system-windows
 
 RUN: rm -rf %t.output_dir && mkdir %t.output_dir
-RUN: %scan-build -o %t.output_dir %clang -c \
+RUN: %scan-build -o %t.output_dir %clang -S \
 RUN: %S/Inputs/multidirectory_project/directory1/file1.c \
 RUN: %S/Inputs/multidirectory_project/directory2/file2.c \
 RUN: | FileCheck %s -check-prefix CHECK-NO-EXCLUDE
@@ -21,7 +21,7 @@ CHECK-NO-EXCLUDE: scan-build: 2 bugs found.
 
 // Only one issue should be found when directory1 is excluded.
 RUN: rm -rf %t.output_dir && mkdir %t.output_dir
-RUN: %scan-build -o %t.output_dir --exclude directory1 %clang -c \
+RUN: %scan-build -o %t.output_dir --exclude directory1 %clang -S \
 RUN: %S/Inputs/multidirectory_project/directory1/file1.c \
 RUN: %S/Inputs/multidirectory_project/directory2/file2.c \
 RUN: | FileCheck %s -check-prefix CHECK-EXCLUDE1
@@ -31,7 +31,7 @@ CHECK-EXCLUDE1: scan-build: 1 bug found.
 
 // When both directories are excluded, no issues should be reported.
 RUN: rm -rf %t.output_dir && mkdir %t.output_dir
-RUN: %scan-build -o %t.output_dir --exclude directory1 --exclude directory2 
%clang -c \
+RUN: %scan-build -o %t.output_dir --exclude directory1 --exclude directory2 
%clang -S \
 RUN: %S/Inputs/multidirectory_project/directory1/file1.c \
 RUN: %S/Inputs/multidirectory_project/directory2/file2.c \
 RUN: | FileCheck %s -check-prefix CHECK-EXCLUDE-BOTH

diff  --git a/clang/test/Analysis/scan-build/html_output.test 
b/clang/test/Analysis/scan-build/html_output.test
index b3b8aa0cf2cf..b080b5f6a9c0 100644
--- a/clang/test/Analysis/scan-build/html_output.test
+++ b/clang/test/Analysis/scan-build/html_output.test
@@ -5,7 +5,7 @@ REQUIRES: shell
 UNSUPPORTED: system-windows
 
 RUN: rm -rf %t.output_dir && mkdir %t.output_dir
-RUN: %scan-build -o %t.output_dir %clang -c 
%S/Inputs/single_null_dereference.c \
+RUN: %scan-build -o %t.output_dir %clang -S 
%S/Inputs/single_null_dereference.c \
 RUN: | FileCheck %s -check-prefix CHECK-STDOUT
 
 // Test html output

diff  --git a/clang/test/Analysis/scan-build/plist_html_output.test 
b/clang/test/Analysis/scan-build/plist_html_output.test
index 4bd7c564a2c9..97997c243663 100644
--- a/clang/test/Analysis/scan-build/plist_html_output.test
+++ b/clang/test/Analysis/scan-build/plist_html_output.test
@@ -5,7 +5,7 @@ REQUIRES: shell
 UNSUPPORTED: system-windows
 
 RUN: rm -rf %t.output_dir && mkdir %t.output_dir
-RUN: %scan-build -plist-html -o %t.output_dir %clang -c 
%S/Inputs/single_null_dereference.c \
+RUN: %scan-build -plist-html -o %t.output_dir %clang -S 
%S/Inputs/single_null_dereference.c \
 RUN: | FileCheck %s -check-prefix CHECK-STDOUT
 
 // Test combined plist and html output with -plist-html

diff  --git a/clang/test/Analysis/scan-build/plist_output.test 
b/clang/test/Analysis/scan-build/plist_output.test
index 30f90a2d696e..2e14ba698bfc 100644
--- a/clang/test/Analysis/scan-build/plist_output.test
+++ b/clang/test/Analysis/scan-build/plist_output.test
@@ -5,7 +5,7 @@ REQUIRES: shell
 UNSUPPORTED: system-windows
 
 RUN: rm -rf %t.output_dir && mkdir %t.output_dir
-RUN: %scan-build -plist -o %t.output_dir %clang -c 
%S/Inputs/single_null_dereference.c \
+RUN: %scan-build -plist -o %t.output_dir %clang -S 
%S/Inputs/single_null_dereference.c \
 RUN: | FileCheck %s -check-prefix CHECK-STDOUT
 
 // Test plist output



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


[clang] 7fbf15a - [CodeGenObjC] Privatize some ObjC metadata symbols

2020-03-09 Thread Erik Pilkington via cfe-commits

Author: Erik Pilkington
Date: 2020-03-09T15:40:24-07:00
New Revision: 7fbf15a8f2df039cd47de7f2e98c4cd655d82e41

URL: 
https://github.com/llvm/llvm-project/commit/7fbf15a8f2df039cd47de7f2e98c4cd655d82e41
DIFF: 
https://github.com/llvm/llvm-project/commit/7fbf15a8f2df039cd47de7f2e98c4cd655d82e41.diff

LOG: [CodeGenObjC] Privatize some ObjC metadata symbols

Nobody needs these symbols, so there isn't any benefit in including them. This
saves some code-size in Objective-C binaries. Partially reverts:
https://reviews.llvm.org/D61454. rdar://56579760

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

Added: 


Modified: 
clang/lib/CodeGen/CGObjCMac.cpp
clang/test/CodeGenObjC/class-stubs.m
clang/test/CodeGenObjC/exceptions-asm-attribute.m
clang/test/CodeGenObjC/metadata-symbols-64.m
clang/test/CodeGenObjC/metadata_symbols.m
clang/test/CodeGenObjC/non-lazy-classes.m
clang/test/CodeGenObjC/sections.m

Removed: 




diff  --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp
index 547a1f352f94..d6cfe41a9c87 100644
--- a/clang/lib/CodeGen/CGObjCMac.cpp
+++ b/clang/lib/CodeGen/CGObjCMac.cpp
@@ -6247,11 +6247,9 @@ void CGObjCNonFragileABIMac::AddModuleClassList(
   assert((!CGM.getTriple().isOSBinFormatMachO() ||
   SectionName.startswith("__DATA")) &&
  "SectionName expected to start with __DATA on MachO");
-  llvm::GlobalValue::LinkageTypes LT =
-  getLinkageTypeForObjCMetadata(CGM, SectionName);
-  llvm::GlobalVariable *GV =
-new llvm::GlobalVariable(CGM.getModule(), Init->getType(), false, LT, Init,
- SymbolName);
+  llvm::GlobalVariable *GV = new llvm::GlobalVariable(
+  CGM.getModule(), Init->getType(), false,
+  llvm::GlobalValue::PrivateLinkage, Init, SymbolName);
   GV->setAlignment(
   llvm::Align(CGM.getDataLayout().getABITypeAlignment(Init->getType(;
   GV->setSection(SectionName);
@@ -7539,10 +7537,9 @@ 
CGObjCNonFragileABIMac::EmitSuperClassRef(CodeGenFunction ,
 llvm::Constant *ClassGV = GetClassGlobalForClassRef(ID);
 std::string SectionName =
 GetSectionName("__objc_superrefs", "regular,no_dead_strip");
-Entry = new llvm::GlobalVariable(
-CGM.getModule(), ClassGV->getType(), false,
-getLinkageTypeForObjCMetadata(CGM, SectionName), ClassGV,
-"OBJC_CLASSLIST_SUP_REFS_$_");
+Entry = new llvm::GlobalVariable(CGM.getModule(), ClassGV->getType(), 
false,
+ llvm::GlobalValue::PrivateLinkage, 
ClassGV,
+ "OBJC_CLASSLIST_SUP_REFS_$_");
 Entry->setAlignment(CGF.getPointerAlign().getAsAlign());
 Entry->setSection(SectionName);
 CGM.addCompilerUsedGlobal(Entry);
@@ -7563,10 +7560,9 @@ llvm::Value 
*CGObjCNonFragileABIMac::EmitMetaClassRef(CodeGenFunction ,
 auto MetaClassGV = GetClassGlobal(ID, /*metaclass*/ true, 
NotForDefinition);
 std::string SectionName =
 GetSectionName("__objc_superrefs", "regular,no_dead_strip");
-Entry = new llvm::GlobalVariable(
-CGM.getModule(), ObjCTypes.ClassnfABIPtrTy, false,
-getLinkageTypeForObjCMetadata(CGM, SectionName), MetaClassGV,
-"OBJC_CLASSLIST_SUP_REFS_$_");
+Entry = new llvm::GlobalVariable(CGM.getModule(), 
ObjCTypes.ClassnfABIPtrTy,
+ false, llvm::GlobalValue::PrivateLinkage,
+ MetaClassGV, 
"OBJC_CLASSLIST_SUP_REFS_$_");
 Entry->setAlignment(Align.getAsAlign());
 Entry->setSection(SectionName);
 CGM.addCompilerUsedGlobal(Entry);

diff  --git a/clang/test/CodeGenObjC/class-stubs.m 
b/clang/test/CodeGenObjC/class-stubs.m
index fadb4433b805..d5ed15c5a36b 100644
--- a/clang/test/CodeGenObjC/class-stubs.m
+++ b/clang/test/CodeGenObjC/class-stubs.m
@@ -11,18 +11,18 @@
 //
 // Metaclasses do not use the "stub" mechanism and are referenced statically.
 //
-// CHECK-LABEL: @"OBJC_CLASSLIST_SUP_REFS_$_" = internal global 
%struct._class_t* @"OBJC_METACLASS_$_Derived", section 
"__DATA,__objc_superrefs,regular,no_dead_strip", align 8
+// CHECK-LABEL: @"OBJC_CLASSLIST_SUP_REFS_$_" = private global 
%struct._class_t* @"OBJC_METACLASS_$_Derived", section 
"__DATA,__objc_superrefs,regular,no_dead_strip", align 8
 
 // -- classref for the super message send in anotherInstanceMethod()
 //
 // The class is declared with objc_class_stub, so LSB of the class pointer
 // must be set to 1.
 //
-// CHECK-LABEL: @"OBJC_CLASSLIST_SUP_REFS_$_.1" = internal global i8* 
getelementptr (i8, i8* bitcast (%struct._class_t* @"OBJC_CLASS_$_Derived" to 
i8*), i32 1), section "__DATA,__objc_superrefs,regular,no_dead_strip", align 8
+// CHECK-LABEL: @"OBJC_CLASSLIST_SUP_REFS_$_.1" = private global i8* 
getelementptr (i8, i8* bitcast (%struct._class_t* @"OBJC_CLASS_$_Derived" to 
i8*), i32 1), section 

[PATCH] D73967: Implement _ExtInt as an extended int type specifier.

2020-03-09 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Ping!


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

https://reviews.llvm.org/D73967



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


[PATCH] D74669: [clang-tidy] New check: bugprone-suspicious-include

2020-03-09 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:101
 
+- New :doc:`bugprone-suspicious-includei
+  ` check.

Please keep alphabetical order.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:104
+
+  Finds includes that appear to be referring to implementation files (which
+  tends to cause ODR violations), and diagnoses them.

Please synchronize with first statement in documentation.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-include.rst:6
+
+The checker detects various cases when an include refers to what appears to be
+an implementation file, which often leads to hard-to-track-down ODR violations.

Please omit //The checker//. Clang-tidy uses //check// in its terminology.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-include.rst:23
+
+   Default value: ";h;hh;hpp;hxx"
+   A semicolon-separated list of filename extensions of header files (the

Please use single back-ticks for option values. Same above.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74669



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


[clang-tools-extra] 2e9d33b - Add missing list.rst entry

2020-03-09 Thread Jonathan Roelofs via cfe-commits

Author: Jonathan Roelofs
Date: 2020-03-09T16:27:35-06:00
New Revision: 2e9d33bccd587763fc284098b5cc60cfb9c25251

URL: 
https://github.com/llvm/llvm-project/commit/2e9d33bccd587763fc284098b5cc60cfb9c25251
DIFF: 
https://github.com/llvm/llvm-project/commit/2e9d33bccd587763fc284098b5cc60cfb9c25251.diff

LOG: Add missing list.rst entry

Added: 


Modified: 
clang-tools-extra/docs/clang-tidy/checks/list.rst

Removed: 




diff  --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst 
b/clang-tools-extra/docs/clang-tidy/checks/list.rst
index 05741385615a..5a5140bcd429 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -80,6 +80,7 @@ Clang-Tidy Checks
`bugprone-string-integer-assignment 
`_, "Yes"
`bugprone-string-literal-with-embedded-nul 
`_,
`bugprone-suspicious-enum-usage `_,
+   `bugprone-suspicious-include `_,
`bugprone-suspicious-memset-usage 
`_, "Yes"
`bugprone-suspicious-missing-comma 
`_,
`bugprone-suspicious-semicolon `_, "Yes"



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


[clang-tools-extra] 698a127 - release notes: fix new check name

2020-03-09 Thread Jonathan Roelofs via cfe-commits

Author: Jonathan Roelofs
Date: 2020-03-09T16:11:35-06:00
New Revision: 698a12712920c214e39bb215fe26fad2e099425b

URL: 
https://github.com/llvm/llvm-project/commit/698a12712920c214e39bb215fe26fad2e099425b
DIFF: 
https://github.com/llvm/llvm-project/commit/698a12712920c214e39bb215fe26fad2e099425b.diff

LOG: release notes: fix new check name

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 4526cf251d8c..aa9ff71ef7f8 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -98,7 +98,7 @@ New checks
 
   Finds recursive functions and diagnoses them.
 
-- New :doc:`bugprone-suspicious-includei
+- New :doc:`bugprone-suspicious-include
   ` check.
 
   Finds includes that appear to be referring to implementation files (which



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


[PATCH] D74669: [clang-tidy] New check: bugprone-suspicious-include

2020-03-09 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs updated this revision to Diff 249224.
jroelofs added a comment.

Add missing release notes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74669

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.h
  clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
  clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-include.rst
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/a
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/a.cpp
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/a.hpp
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/c.c
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/c.cc
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/c.cxx
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/i.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp
@@ -0,0 +1,27 @@
+// RUN: %check_clang_tidy %s bugprone-suspicious-include %t -- -- -isystem %S/Inputs/Headers -fmodules
+
+// clang-format off
+
+// CHECK-MESSAGES: [[@LINE+4]]:11: warning: suspicious #include of file with '.cpp' extension
+// CHECK-MESSAGES: [[@LINE+3]]:11: note: did you mean to include 'a'?
+// CHECK-MESSAGES: [[@LINE+2]]:11: note: did you mean to include 'a.h'?
+// CHECK-MESSAGES: [[@LINE+1]]:11: note: did you mean to include 'a.hpp'?
+#include "a.cpp"
+
+// CHECK-MESSAGES: [[@LINE+2]]:11: warning: suspicious #include of file with '.cpp' extension
+// CHECK-MESSAGES: [[@LINE+1]]:11: note: did you mean to include 'i.h'?
+#include "i.cpp"
+
+#include "b.h"
+
+// CHECK-MESSAGES: [[@LINE+1]]:10: warning: suspicious #import of file with '.c' extension
+#import "c.c"
+
+// CHECK-MESSAGES: [[@LINE+1]]:16: warning: suspicious #include_next of file with '.c' extension
+#include_next 
+
+// CHECK-MESSAGES: [[@LINE+1]]:13: warning: suspicious #include of file with '.cc' extension
+# include  
+
+// CHECK-MESSAGES: [[@LINE+1]]:14: warning: suspicious #include of file with '.cxx' extension
+#  include  
Index: clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-include.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-include.rst
@@ -0,0 +1,33 @@
+.. title:: clang-tidy - bugprone-suspicious-include
+
+bugprone-suspicious-include
+===
+
+The checker detects various cases when an include refers to what appears to be
+an implementation file, which often leads to hard-to-track-down ODR violations.
+
+Examples:
+
+.. code-block:: c++
+
+  #include "Dinosaur.hpp" // OK, .hpp files tend not to have definitions.
+  #include "Pterodactyl.h"// OK, .h files tend not to have definitions.
+  #include "Velociraptor.cpp" // Warning, filename is suspicious.
+  #import "Stegosaurus.c" // Warning, fliename is suspicious.
+  #include_next  // Warning, filename is suspicious.
+
+Options
+---
+.. option:: HeaderFileExtensions
+
+   Default value: ";h;hh;hpp;hxx"
+   A semicolon-separated list of filename extensions of header files (the
+   filename extensions should not contain a "." prefix). For extension-less
+   header files, use an empty string or leave an empty string between ";"
+   if there are other filename extensions.
+
+.. option:: ImplementationFileExtensions
+
+   Default value: "c;cc;cpp;cxx"
+   Likewise, a semicolon-separated list of filename extensions of
+   implementation files.
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -98,6 +98,12 @@
 
   Finds recursive functions and diagnoses them.
 
+- New :doc:`bugprone-suspicious-includei
+  ` check.
+
+  Finds includes that appear to be referring to implementation files (which
+  tends to cause ODR violations), and diagnoses them.
+
 New check aliases
 ^
 
Index: clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
===
--- clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
+++ clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
@@ -11,6 +11,7 @@
 
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
+#include "llvm/ADT/Optional.h"
 #include 

[PATCH] D74669: [clang-tidy] New check: bugprone-suspicious-include

2020-03-09 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs updated this revision to Diff 249223.
jroelofs added a comment.

Implement review feedback.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74669

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.h
  clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
  clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
  clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-include.rst
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/a
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/a.cpp
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/a.hpp
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/c.c
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/c.cc
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/c.cxx
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/i.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp
@@ -0,0 +1,27 @@
+// RUN: %check_clang_tidy %s bugprone-suspicious-include %t -- -- -isystem %S/Inputs/Headers -fmodules
+
+// clang-format off
+
+// CHECK-MESSAGES: [[@LINE+4]]:11: warning: suspicious #include of file with '.cpp' extension
+// CHECK-MESSAGES: [[@LINE+3]]:11: note: did you mean to include 'a'?
+// CHECK-MESSAGES: [[@LINE+2]]:11: note: did you mean to include 'a.h'?
+// CHECK-MESSAGES: [[@LINE+1]]:11: note: did you mean to include 'a.hpp'?
+#include "a.cpp"
+
+// CHECK-MESSAGES: [[@LINE+2]]:11: warning: suspicious #include of file with '.cpp' extension
+// CHECK-MESSAGES: [[@LINE+1]]:11: note: did you mean to include 'i.h'?
+#include "i.cpp"
+
+#include "b.h"
+
+// CHECK-MESSAGES: [[@LINE+1]]:10: warning: suspicious #import of file with '.c' extension
+#import "c.c"
+
+// CHECK-MESSAGES: [[@LINE+1]]:16: warning: suspicious #include_next of file with '.c' extension
+#include_next 
+
+// CHECK-MESSAGES: [[@LINE+1]]:13: warning: suspicious #include of file with '.cc' extension
+# include  
+
+// CHECK-MESSAGES: [[@LINE+1]]:14: warning: suspicious #include of file with '.cxx' extension
+#  include  
Index: clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-include.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-include.rst
@@ -0,0 +1,33 @@
+.. title:: clang-tidy - bugprone-suspicious-include
+
+bugprone-suspicious-include
+===
+
+The checker detects various cases when an include refers to what appears to be
+an implementation file, which often leads to hard-to-track-down ODR violations.
+
+Examples:
+
+.. code-block:: c++
+
+  #include "Dinosaur.hpp" // OK, .hpp files tend not to have definitions.
+  #include "Pterodactyl.h"// OK, .h files tend not to have definitions.
+  #include "Velociraptor.cpp" // Warning, filename is suspicious.
+  #import "Stegosaurus.c" // Warning, fliename is suspicious.
+  #include_next  // Warning, filename is suspicious.
+
+Options
+---
+.. option:: HeaderFileExtensions
+
+   Default value: ";h;hh;hpp;hxx"
+   A semicolon-separated list of filename extensions of header files (the
+   filename extensions should not contain a "." prefix). For extension-less
+   header files, use an empty string or leave an empty string between ";"
+   if there are other filename extensions.
+
+.. option:: ImplementationFileExtensions
+
+   Default value: "c;cc;cpp;cxx"
+   Likewise, a semicolon-separated list of filename extensions of
+   implementation files.
Index: clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
===
--- clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
+++ clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
@@ -11,6 +11,7 @@
 
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/StringRef.h"
 
@@ -36,6 +37,12 @@
 /// extensions.
 inline StringRef defaultHeaderFileExtensions() { return ";h;hh;hpp;hxx"; }
 
+/// Returns recommended default value for the list of implementaiton file
+/// extensions.
+inline StringRef defaultImplementationFileExtensions() {
+  return "c;cc;cpp;cxx";
+}
+
 /// Returns recommended default value for the list of file extension
 /// delimiters.
 inline StringRef defaultFileExtensionDelimiters() { return ",;"; }
@@ -45,6 +52,11 @@
 

[PATCH] D74669: [clang-tidy] New check: bugprone-suspicious-include

2020-03-09 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs closed this revision.
jroelofs marked 7 inline comments as done.
jroelofs added a comment.

Thanks for the review!

https://github.com/llvm/llvm-project/commit/1e0669bfe05f0f48ee88152c4a1d581f484f8d67




Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp:10
+#include "a.cpp"
+
+#include "b.h"

aaron.ballman wrote:
> Can you add a test for:
> ```
> #include "i.cpp"
> ```
> to show that it suggests `i.h` (which already exists in-tree) but not `i` or 
> `i.hpp`?
happy to :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74669



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


[clang-tools-extra] 1e0669b - [clang-tidy] New check: bugprone-suspicious-include

2020-03-09 Thread Jonathan Roelofs via cfe-commits

Author: Jonathan Roelofs
Date: 2020-03-09T15:54:32-06:00
New Revision: 1e0669bfe05f0f48ee88152c4a1d581f484f8d67

URL: 
https://github.com/llvm/llvm-project/commit/1e0669bfe05f0f48ee88152c4a1d581f484f8d67
DIFF: 
https://github.com/llvm/llvm-project/commit/1e0669bfe05f0f48ee88152c4a1d581f484f8d67.diff

LOG: [clang-tidy] New check: bugprone-suspicious-include

Detects and fixes suspicious code like: `#include "foo.cpp"`.

Inspired by: https://twitter.com/lefticus/status/1228458240364687360?s=20

https://reviews.llvm.org/D74669

Added: 
clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp
clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.h
clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-include.rst
clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/a
clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/a.cpp
clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/a.hpp
clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/c.c
clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/c.cc
clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/c.cxx
clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/i.cpp
clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp

Modified: 
clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
clang-tools-extra/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index 86936c678562..9dcb315a257a 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -45,6 +45,7 @@
 #include "StringIntegerAssignmentCheck.h"
 #include "StringLiteralWithEmbeddedNulCheck.h"
 #include "SuspiciousEnumUsageCheck.h"
+#include "SuspiciousIncludeCheck.h"
 #include "SuspiciousMemsetUsageCheck.h"
 #include "SuspiciousMissingCommaCheck.h"
 #include "SuspiciousSemicolonCheck.h"
@@ -140,6 +141,8 @@ class BugproneModule : public ClangTidyModule {
 "bugprone-string-literal-with-embedded-nul");
 CheckFactories.registerCheck(
 "bugprone-suspicious-enum-usage");
+CheckFactories.registerCheck(
+"bugprone-suspicious-include");
 CheckFactories.registerCheck(
 "bugprone-suspicious-memset-usage");
 CheckFactories.registerCheck(

diff  --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
index c9078ed390d1..a24f3bc7eb0d 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -37,6 +37,7 @@ add_clang_library(clangTidyBugproneModule
   StringIntegerAssignmentCheck.cpp
   StringLiteralWithEmbeddedNulCheck.cpp
   SuspiciousEnumUsageCheck.cpp
+  SuspiciousIncludeCheck.cpp
   SuspiciousMemsetUsageCheck.cpp
   SuspiciousMissingCommaCheck.cpp
   SuspiciousSemicolonCheck.cpp

diff  --git a/clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp
new file mode 100644
index ..ade7b111fc9a
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp
@@ -0,0 +1,105 @@
+//===--- SuspiciousIncludeCheck.cpp - clang-tidy 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "SuspiciousIncludeCheck.h"
+#include "clang/AST/ASTContext.h"
+
+namespace clang {
+namespace tidy {
+namespace bugprone {
+
+namespace {
+class SuspiciousIncludePPCallbacks : public PPCallbacks {
+public:
+  explicit SuspiciousIncludePPCallbacks(SuspiciousIncludeCheck ,
+const SourceManager ,
+Preprocessor *PP)
+  : Check(Check), PP(PP) {}
+
+  void InclusionDirective(SourceLocation HashLoc, const Token ,
+  StringRef FileName, bool IsAngled,
+  CharSourceRange FilenameRange, const FileEntry *File,
+  StringRef SearchPath, StringRef RelativePath,
+  const Module *Imported,
+  SrcMgr::CharacteristicKind FileType) override;
+
+private:
+  SuspiciousIncludeCheck 
+  Preprocessor *PP;
+};
+} // namespace
+
+SuspiciousIncludeCheck::SuspiciousIncludeCheck(StringRef Name,
+

[clang] 6309334 - [OPENMP50]Codegen for depobj dependency kind.

2020-03-09 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-03-09T17:46:06-04:00
New Revision: 6309334b9574017523f73648da879fa5e6ef017a

URL: 
https://github.com/llvm/llvm-project/commit/6309334b9574017523f73648da879fa5e6ef017a
DIFF: 
https://github.com/llvm/llvm-project/commit/6309334b9574017523f73648da879fa5e6ef017a.diff

LOG: [OPENMP50]Codegen for depobj dependency kind.

Implemented codegen for depobj modifier in depend clauses.

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGOpenMPRuntime.h
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/test/OpenMP/task_codegen.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index e16dfbcddbe2..a115fe01a6e9 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -5236,7 +5236,36 @@ static void getDependTypes(ASTContext , QualType 
,
   }
 }
 
-Address CGOpenMPRuntime::emitDependClause(
+std::pair
+CGOpenMPRuntime::getDepobjElements(CodeGenFunction , LValue DepobjLVal,
+   SourceLocation Loc) {
+  ASTContext  = CGM.getContext();
+  QualType FlagsTy;
+  getDependTypes(C, KmpDependInfoTy, FlagsTy);
+  RecordDecl *KmpDependInfoRD =
+  cast(KmpDependInfoTy->getAsTagDecl());
+  LValue Base = CGF.EmitLoadOfPointerLValue(
+  DepobjLVal.getAddress(CGF),
+  C.getPointerType(C.VoidPtrTy).castAs());
+  QualType KmpDependInfoPtrTy = C.getPointerType(KmpDependInfoTy);
+  Address Addr = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
+  Base.getAddress(CGF), CGF.ConvertTypeForMem(KmpDependInfoPtrTy));
+  Base = CGF.MakeAddrLValue(Addr, KmpDependInfoTy, Base.getBaseInfo(),
+Base.getTBAAInfo());
+  llvm::Value *DepObjAddr = CGF.Builder.CreateGEP(
+  Addr.getPointer(),
+  llvm::ConstantInt::get(CGF.IntPtrTy, -1, /*isSigned=*/true));
+  LValue NumDepsBase = CGF.MakeAddrLValue(
+  Address(DepObjAddr, Addr.getAlignment()), KmpDependInfoTy,
+  Base.getBaseInfo(), Base.getTBAAInfo());
+  // NumDeps = deps[i].base_addr;
+  LValue BaseAddrLVal = CGF.EmitLValueForField(
+  NumDepsBase, *std::next(KmpDependInfoRD->field_begin(), BaseAddr));
+  llvm::Value *NumDeps = CGF.EmitLoadOfScalar(BaseAddrLVal, Loc);
+  return std::make_pair(NumDeps, Base);
+}
+
+std::pair CGOpenMPRuntime::emitDependClause(
 CodeGenFunction ,
 ArrayRef> Dependencies,
 bool ForDepobj, SourceLocation Loc) {
@@ -5244,21 +5273,42 @@ Address CGOpenMPRuntime::emitDependClause(
   ASTContext  = CGM.getContext();
   Address DependenciesArray = Address::invalid();
   unsigned NumDependencies = Dependencies.size();
+  llvm::Value *NumOfElements = nullptr;
   if (NumDependencies) {
 QualType FlagsTy;
 getDependTypes(C, KmpDependInfoTy, FlagsTy);
 RecordDecl *KmpDependInfoRD =
 cast(KmpDependInfoTy->getAsTagDecl());
 llvm::Type *LLVMFlagsTy = CGF.ConvertTypeForMem(FlagsTy);
+unsigned NumDepobjDependecies = 0;
+SmallVector, 4> Depobjs;
+llvm::Value *NumOfDepobjElements = llvm::ConstantInt::get(CGF.IntPtrTy, 0);
+// Calculate number of depobj dependecies.
+for (const std::pair  :
+ Dependencies) {
+  if (Pair.first != OMPC_DEPEND_depobj)
+continue;
+  LValue DepobjLVal = CGF.EmitLValue(Pair.second);
+  llvm::Value *NumDeps;
+  LValue Base;
+  std::tie(NumDeps, Base) = getDepobjElements(CGF, DepobjLVal, Loc);
+  NumOfDepobjElements =
+  CGF.Builder.CreateNUWAdd(NumOfDepobjElements, NumDeps);
+  Depobjs.emplace_back(NumDeps, Base);
+  ++NumDepobjDependecies;
+}
+
+QualType KmpDependInfoArrayTy;
 // Define type kmp_depend_info[];
 // For depobj reserve one extra element to store the number of elements.
 // It is required to handle depobj(x) update(in) construct.
-QualType KmpDependInfoArrayTy = C.getConstantArrayType(
-KmpDependInfoTy,
-llvm::APInt(/*numBits=*/64, NumDependencies + (ForDepobj ? 1 : 0)),
-nullptr, ArrayType::Normal, /*IndexTypeQuals=*/0);
 // kmp_depend_info[] deps;
 if (ForDepobj) {
+  assert(NumDepobjDependecies == 0 &&
+ "depobj dependency kind is not expected in depobj directive.");
+  KmpDependInfoArrayTy = C.getConstantArrayType(
+  KmpDependInfoTy, llvm::APInt(/*numBits=*/64, NumDependencies + 1),
+  nullptr, ArrayType::Normal, /*IndexTypeQuals=*/0);
   // Need to allocate on the dynamic memory.
   llvm::Value *ThreadID = getThreadID(CGF, Loc);
   // Use default allocator.
@@ -5273,9 +5323,38 @@ Address CGOpenMPRuntime::emitDependClause(
   Addr = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
   Addr, CGF.ConvertTypeForMem(KmpDependInfoArrayTy)->getPointerTo());
   DependenciesArray = Address(Addr, Align);
+  NumOfElements = llvm::ConstantInt::get(CGM.Int32Ty, NumDependencies,

[PATCH] D74669: [clang-tidy] New check: bugprone-suspicious-include

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

LGTM aside from some documentation and testing nits.




Comment at: 
clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-include.rst:15-17
+  #include "Velociraptor.cpp" // Warning, filename is suspicious
+  #import "Stegosaurus.c" // Warning, fliename is suspicious
+  #include_next  // Warning, filename is suspicious

Missing full stops at the end of the comments.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-include.rst:24
+   Default value: ";h;hh;hpp;hxx"
+   A semicolon-separated list of filename extensions of header files (The
+   filename extensions should not contain "." prefix). For extension-less

The -> the



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-include.rst:25
+   A semicolon-separated list of filename extensions of header files (The
+   filename extensions should not contain "." prefix). For extension-less
+   header files, using an empty string or leaving an empty string between ";"

contain "." -> contain a "."



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-include.rst:26
+   filename extensions should not contain "." prefix). For extension-less
+   header files, using an empty string or leaving an empty string between ";"
+   if there are other filename extensions.

using -> use
leaving -> leave



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-include.rst:29
+
+.. option:: HeaderFileExtensions
+

ImplementationFileExtensions ;-)



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp:7
+// CHECK-MESSAGES: [[@LINE+3]]:11: note: did you mean to include 'a'?
+// CHECK-MESSAGES: [[@LINE+2]]:11: note: did you mean to include 'a.h'?
+// CHECK-MESSAGES: [[@LINE+1]]:11: note: did you mean to include 'a.hpp'?

For those of you following along at home, `a.h` already exists on ToT (as does 
b.h). :-D



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp:10
+#include "a.cpp"
+
+#include "b.h"

Can you add a test for:
```
#include "i.cpp"
```
to show that it suggests `i.h` (which already exists in-tree) but not `i` or 
`i.hpp`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74669



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


[PATCH] D75470: [SVE] Auto-generate builtins and header for svld1.

2020-03-09 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:5292
+  { #NameBase, SVE::BI__builtin_sve_##NameBase, 0, 0, TypeModifier }
+static const NeonIntrinsicInfo AArch64SVEIntrinsicMap[] = {
+#define GET_SVE_LLVM_INTRINSIC_MAP

I am wondering if it is confusing/correct to use NeonInstrinsicInfo here?



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:7456
+
+  auto *Builtin = findNeonIntrinsicInMap(AArch64SVEIntrinsicMap, BuiltinID,
+ AArch64SVEIntrinsicsProvenSorted);

and the same here: findNeon...


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

https://reviews.llvm.org/D75470



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


[PATCH] D75844: [clang] Set begin loc on GNU attribute parsed attrs

2020-03-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Thank you for the patch! It should also have some test cases associated with 
it. I'd recommend adding a test to the `AST` directory that do AST dumps where 
you test the line and column information directly.




Comment at: clang/lib/Parse/ParseStmt.cpp:238-239
 GNUAttributeLoc = Tok.getLocation();
+Attrs.Range.setBegin(GNUAttributeLoc);
 ParseGNUAttributes(Attrs);
 goto Retry;

This seems wrong -- it may not be the first attribute in the statement (this is 
in `ParseStatementOrDeclarationAfterAttributes()`), so there may already be 
`[[]]` attributes that have been parsed, which this will overwrite. You would 
need to see if the start range is invalid and only set this in that case.

However, wouldn't it make more sense for `ParseGNUAttributes()` to accept a 
`ParsedAttributesWithRange` and properly set the range there? (This may have a 
larger impact though, because that function gets called in a lot more code 
paths than this switch case does. I suspect we have a fair amount of 
improvements we could make with attribute source ranges.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75844



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


[PATCH] D75811: [CUDA] Choose default architecture based on CUDA installation

2020-03-09 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In D75811#1913148 , @tambre wrote:

> > Magically changing compiler target based on something external to compiler 
> > is a bad idea IMO. I would expect a compilation with exactly the same 
> > compiler options to do exactly the same thing. If we magically change 
> > default target, that will not be the case.
>
> It'd be the same behaviour as NVCC, which compiles for the lowest 
> architecture it supports.


The difference is NVCC is closely tied to the CUDA SDK itself while clang is 
expected to work with all of the CUDA versions since 7.x. 
There's no way to match behavior of all NVCC versions at once. Bumping up the 
current default is fine. Matching particular NVCC version based on the CUDA SDK 
we happen to find is, IMO, somewhat similar to -march=native. We could 
implement it via --cuda-gpu-arch=auto or something like that, but I do not want 
it to be the default.

> I'm currently implementing Clang CUDA support for CMake and lack of this 
> behaviour compared to other languages and compilers complicates matters.
>  During compiler detection CMake compiles a simple program, which includes 
> preprocessor stuff for embedding compiler info in the output. Then it parses 
> that and determines the compiler vendor, version, etc.
> 
> The general assumption is that a compiler can compile a simple program for 
> its language without us having to do compiler-specific options, flags, etc.

Bumping up the default to sm_35 would satisfy this criteria.

> If the compiler fails on this simple program, it's considered broken.

I'm not sure how applicable this criteria for cross-compilation, which is 
effectively what clang does when we compile CUDA sources.
You are expected to provide correct path to the CUDA installation and correct 
set of target GPUs to compile for. Only the end user may know it. While we do 
hardcode few default CUDA locations and deal with quirks of some linux 
distributions, it does not remove the fact that in general cross-compilation 
does need the end-user to supply additional inputs.

> A limited list of flags is usually cycled through to support exotic compilers 
> and I could do the same here, but it'd require us invoking the compiler 
> multiple times and increasingly more as old architectures are deprecated.

You can use `--cuda-gpu-arch=sm_30` and that should cover all CUDA versions 
currently supported by clang.  Maybe, even sm_50 -- I can no longer find any 
docs for CUDA-7.0, so can't say if it did support Maxwell already.

> We could detect the CUDA installation ourselves and specify a list of arches 
> for each. This seems quite unnecessary when Clang already knows the version 
> and could select a default that at least compiles.
>  Note that this detection happens before any user CMake files are ran, so we 
> can't pass the user's preferred arch (which could also differ per file).

See above. Repeated iteration is indeed unnecessary and bumped up default 
target should do the job.

In general, though, relying on this check without taking into-account the 
information supplied by user will be rather fragile.
The CUDA version clang finds by default may not be correct or working and clang 
*relies* on it in order to do anything useful with CUDA. E.g. if I have an ARM 
version of CUDA installed under /usr/local/cuda where clang looks for CUDA by 
default. It will happily find it, but it will not be able to compile anything 
with it. It may work fine if it's pointed to the correct CUDA location via 
user-specified options.

Can you elaborate on what exactly does cmake attempts to establish with the 
test?
If it looks for a working end-to-end CUDA compilation, then it will need to 
rely on user input to make sure that correct CUDA location is used.
If it wants to check if clang is capable of CUDA compilation, then it should be 
told *not* to look for CUDA (though you will need to provide a bit of glue 
similar to what we use for tests 
https://github.com/llvm/llvm-project/blob/master/clang/test/Driver/cuda-simple.cu).
 Would something like that be sufficient?

The farthest you can push clang w/o relying on the CUDA SDK is by using 
`--cuda-gpu-arch=sm_30 --cuda-device-only -S` -- it will verify that clang does 
have NVPTX back-end compiled in and can generate PTX which will then be passed 
to CUDA's ptxas. If this part works, then clang is likely to work with any 
supported CUDA version.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75811



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


[PATCH] D68578: [HIP] Fix device stub name

2020-03-09 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
yaxunl marked 2 inline comments as done.
Closed by commit rG22c457a869d5: [HIP] Fix device stub name (authored by 
yaxunl).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D68578?vs=248927=249212#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68578

Files:
  clang/include/clang/AST/GlobalDecl.h
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/Mangle.cpp
  clang/lib/CodeGen/CGCUDANV.cpp
  clang/lib/CodeGen/CGCUDARuntime.h
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
  clang/test/CodeGenCUDA/kernel-stub-name.cu
  clang/test/CodeGenCUDA/unnamed-types.cu

Index: clang/test/CodeGenCUDA/unnamed-types.cu
===
--- clang/test/CodeGenCUDA/unnamed-types.cu
+++ clang/test/CodeGenCUDA/unnamed-types.cu
@@ -36,4 +36,4 @@
   }(p);
 }
 // HOST: @__hip_register_globals
-// HOST: __hipRegisterFunction{{.*}}@_Z2k0IZZ2f1PfENKUlS0_E_clES0_EUlfE_EvS0_T_{{.*}}@0
+// HOST: __hipRegisterFunction{{.*}}@_Z17__device_stub__k0IZZ2f1PfENKUlS0_E_clES0_EUlfE_EvS0_T_{{.*}}@0
Index: clang/test/CodeGenCUDA/kernel-stub-name.cu
===
--- clang/test/CodeGenCUDA/kernel-stub-name.cu
+++ clang/test/CodeGenCUDA/kernel-stub-name.cu
@@ -6,15 +6,50 @@
 
 #include "Inputs/cuda.h"
 
+extern "C" __global__ void ckernel() {}
+
+namespace ns {
+__global__ void nskernel() {}
+} // namespace ns
+
 template
 __global__ void kernelfunc() {}
 
+__global__ void kernel_decl();
+
+// Device side kernel names
+
+// CHECK: @[[CKERN:[0-9]*]] = {{.*}} c"ckernel\00"
+// CHECK: @[[NSKERN:[0-9]*]] = {{.*}} c"_ZN2ns8nskernelEv\00"
+// CHECK: @[[TKERN:[0-9]*]] = {{.*}} c"_Z10kernelfuncIiEvv\00"
+
+// Non-template kernel stub functions
+
+// CHECK: define{{.*}}@[[CSTUB:__device_stub__ckernel]]
+// CHECK: call{{.*}}@hipLaunchByPtr{{.*}}@[[CSTUB]]
+// CHECK: define{{.*}}@[[NSSTUB:_ZN2ns23__device_stub__nskernelEv]]
+// CHECK: call{{.*}}@hipLaunchByPtr{{.*}}@[[NSSTUB]]
+
 // CHECK-LABEL: define{{.*}}@_Z8hostfuncv()
-// CHECK: call void @[[STUB:_Z10kernelfuncIiEvv.stub]]()
-void hostfunc(void) { kernelfunc<<<1, 1>>>(); }
+// CHECK: call void @[[CSTUB]]()
+// CHECK: call void @[[NSSTUB]]()
+// CHECK: call void @[[TSTUB:_Z25__device_stub__kernelfuncIiEvv]]()
+// CHECK: call void @[[DSTUB:_Z26__device_stub__kernel_declv]]()
+void hostfunc(void) {
+  ckernel<<<1, 1>>>();
+  ns::nskernel<<<1, 1>>>();
+  kernelfunc<<<1, 1>>>();
+  kernel_decl<<<1, 1>>>();
+}
+
+// Template kernel stub functions
+
+// CHECK: define{{.*}}@[[TSTUB]]
+// CHECK: call{{.*}}@hipLaunchByPtr{{.*}}@[[TSTUB]]
 
-// CHECK: define{{.*}}@[[STUB]]
-// CHECK: call{{.*}}@hipLaunchByPtr{{.*}}@[[STUB]]
+// CHECK: declare{{.*}}@[[DSTUB]]
 
 // CHECK-LABEL: define{{.*}}@__hip_register_globals
-// CHECK: call{{.*}}@__hipRegisterFunction{{.*}}@[[STUB]]
+// CHECK: call{{.*}}@__hipRegisterFunction{{.*}}@[[CSTUB]]{{.*}}@[[CKERN]]
+// CHECK: call{{.*}}@__hipRegisterFunction{{.*}}@[[NSSTUB]]{{.*}}@[[NSKERN]]
+// CHECK: call{{.*}}@__hipRegisterFunction{{.*}}@[[TSTUB]]{{.*}}@[[TKERN]]
Index: clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
===
--- clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
+++ clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
@@ -13,19 +13,19 @@
 // HOST-NOT: %struct.T.coerce
 
 // CHECK: define amdgpu_kernel void  @_Z7kernel1Pi(i32 addrspace(1)* %x.coerce)
-// HOST: define void @_Z7kernel1Pi.stub(i32* %x)
+// HOST: define void @_Z22__device_stub__kernel1Pi(i32* %x)
 __global__ void kernel1(int *x) {
   x[0]++;
 }
 
 // CHECK: define amdgpu_kernel void  @_Z7kernel2Ri(i32 addrspace(1)* dereferenceable(4) %x.coerce)
-// HOST: define void @_Z7kernel2Ri.stub(i32* dereferenceable(4) %x)
+// HOST: define void @_Z22__device_stub__kernel2Ri(i32* dereferenceable(4) %x)
 __global__ void kernel2(int ) {
   x++;
 }
 
 // CHECK: define amdgpu_kernel void  @_Z7kernel3PU3AS2iPU3AS1i(i32 addrspace(2)* %x, i32 addrspace(1)* %y)
-// HOST: define void @_Z7kernel3PU3AS2iPU3AS1i.stub(i32 addrspace(2)* %x, i32 addrspace(1)* %y)
+// HOST: define void @_Z22__device_stub__kernel3PU3AS2iPU3AS1i(i32 addrspace(2)* %x, i32 addrspace(1)* %y)
 __global__ void kernel3(__attribute__((address_space(2))) int *x,
 __attribute__((address_space(1))) int *y) {
   y[0] = x[0];
@@ -43,7 +43,7 @@
 // `by-val` struct will be coerced into a similar struct with all generic
 // pointers lowerd into global ones.
 // CHECK: define amdgpu_kernel void @_Z7kernel41S(%struct.S.coerce %s.coerce)
-// HOST: define void @_Z7kernel41S.stub(i32* %s.coerce0, float* 

[PATCH] D75714: Add Optional overload to DiagnosticBuilder operator <

2020-03-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Is there any code we can cleanup as a result of adding these overloads? I would 
have expected to see some code changes justifying each additional overload, 
which would also give us test coverage for the changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75714



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


[PATCH] D75841: [ASTMatchers] Add hasAnyOverloadedOperatorName matcher

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

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75841



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


[PATCH] D68578: [HIP] Fix device stub name

2020-03-09 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 9 inline comments as done.
yaxunl added inline comments.



Comment at: clang/include/clang/AST/GlobalDecl.h:61
 assert(!isa(D) && "Use other ctor with dtor decls!");
+assert(!D->hasAttr() && "Use other ctor with HIP 
kernels!");
 

tra wrote:
> Wording inconsitency -- we're checking for `CUDAGlobalAttr` but complaining 
> about 'HIP kernels'. Just drop 'HIP' or replace with 'GPU'?
will use GPU kernel



Comment at: clang/lib/CodeGen/CGCUDARuntime.h:69
   virtual llvm::Function *makeModuleDtorFunction() = 0;
-
-  /// Construct and return the stub name of a kernel.
-  virtual std::string getDeviceStubName(llvm::StringRef Name) const = 0;
+  virtual std::string getDeviceSideName(const Decl *ND) = 0;
 };

tra wrote:
> Adding a descriptive comment would be great. Otherwise anyone looking at the 
> function decl without the context of this patch will be puzzled about its 
> meaning and purpose.
> 
> Also, perhaps the argument type should be a `NamedDecl` -- the function is 
> not used on or useful for regular `Decl`. It will save us few casts in other 
> places, too.
done


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

https://reviews.llvm.org/D68578



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


Re: [PATCH] D75811: [CUDA] Choose default architecture based on CUDA installation

2020-03-09 Thread Justin Lebar via cfe-commits
From the peanut gallery: Perhaps something like
--cuda_arch=min_supported would solve your problem while still meeting
tra's request not to change behavior of the compiler based on
something external.

On Mon, Mar 9, 2020 at 12:58 PM Raul Tambre via Phabricator
 wrote:
>
> tambre added a comment.
>
> > Magically changing compiler target based on something external to compiler 
> > is a bad idea IMO. I would expect a compilation with exactly the same 
> > compiler options to do exactly the same thing. If we magically change 
> > default target, that will not be the case.
>
> It'd be the same behaviour as NVCC, which compiles for the lowest 
> architecture it supports.
>
> I'm currently implementing Clang CUDA support for CMake and lack of this 
> behaviour compared to other languages and compilers complicates matters.
> During compiler detection CMake compiles a simple program, which includes 
> preprocessor stuff for embedding compiler info in the output. Then it parses 
> that and determines the compiler vendor, version, etc.
>
> The general assumption is that a compiler can compile a simple program for 
> its language without us having to do compiler-specific options, flags, etc. 
> If the compiler fails on this simple program, it's considered broken.
> A limited list of flags is usually cycled through to support exotic compilers 
> and I could do the same here, but it'd require us invoking the compiler 
> multiple times and increasingly more as old architectures are deprecated.
> We could detect the CUDA installation ourselves and specify a list of arches 
> for each. This seems quite unnecessary when Clang already knows the version 
> and could select a default that at least compiles.
> Note that this detection happens before any user CMake files are ran, so we 
> can't pass the user's preferred arch (which could also differ per file).
>
>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D75811/new/
>
> https://reviews.llvm.org/D75811
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] e32f8ef - Follow up of 3d9a0445cce3, clang driver defaulting to -fno-common

2020-03-09 Thread Sjoerd Meijer via cfe-commits

Author: Sjoerd Meijer
Date: 2020-03-09T20:43:05Z
New Revision: e32f8ef9277dbaaeef1fbabe9505683ff5e35edf

URL: 
https://github.com/llvm/llvm-project/commit/e32f8ef9277dbaaeef1fbabe9505683ff5e35edf
DIFF: 
https://github.com/llvm/llvm-project/commit/e32f8ef9277dbaaeef1fbabe9505683ff5e35edf.diff

LOG: Follow up of 3d9a0445cce3, clang driver defaulting to -fno-common

Attempt to pacify windows bot where this failed:

clang/test/CodeGen/vlt_to_pointer.c

Added: 


Modified: 
clang/test/CodeGen/vlt_to_pointer.c

Removed: 




diff  --git a/clang/test/CodeGen/vlt_to_pointer.c 
b/clang/test/CodeGen/vlt_to_pointer.c
index 129a1df3..d46d7275ac77 100644
--- a/clang/test/CodeGen/vlt_to_pointer.c
+++ b/clang/test/CodeGen/vlt_to_pointer.c
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
 
 int c[1][3*2];
-// CHECK: @{{.+}} = global [1 x [6 x {{i[0-9]+}}]] zeroinitializer
+// CHECK: @{{.+}} ={{.*}}global [1 x [6 x {{i[0-9]+}}]] zeroinitializer
 
 // CHECK-LABEL: @f
 int f(int * const m, int (**v)[*m * 2])



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


[clang] 22c457a - [HIP] Fix device stub name

2020-03-09 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2020-03-09T16:40:05-04:00
New Revision: 22c457a869d5dd9d7e6ca0f97e2a8408bf7326f2

URL: 
https://github.com/llvm/llvm-project/commit/22c457a869d5dd9d7e6ca0f97e2a8408bf7326f2
DIFF: 
https://github.com/llvm/llvm-project/commit/22c457a869d5dd9d7e6ca0f97e2a8408bf7326f2.diff

LOG: [HIP] Fix device stub name

HIP emits a device stub function for each kernel in host code.

The HIP debugger requires device stub function to have a different unmangled 
name as the kernel.

Currently the name of the device stub function is the mangled name with a 
postfix .stub. However,
this does not work with the HIP debugger since the unmangled name is the same 
as the kernel.

This patch adds prefix __device__stub__ to the unmangled name of the device 
stub before mangling,
therefore the device stub function has a valid mangled name which is different 
than the device kernel
name. The device side kernel name is kept unchanged. kernels with extern "C" 
also gets the prefix added
to the corresponding device stub function.

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

Added: 


Modified: 
clang/include/clang/AST/GlobalDecl.h
clang/lib/AST/Expr.cpp
clang/lib/AST/ItaniumMangle.cpp
clang/lib/AST/Mangle.cpp
clang/lib/CodeGen/CGCUDANV.cpp
clang/lib/CodeGen/CGCUDARuntime.h
clang/lib/CodeGen/CGDecl.cpp
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/CodeGenModule.h
clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
clang/test/CodeGenCUDA/kernel-stub-name.cu
clang/test/CodeGenCUDA/unnamed-types.cu

Removed: 




diff  --git a/clang/include/clang/AST/GlobalDecl.h 
b/clang/include/clang/AST/GlobalDecl.h
index 0945ebb56a48..d2b5566a4cfa 100644
--- a/clang/include/clang/AST/GlobalDecl.h
+++ b/clang/include/clang/AST/GlobalDecl.h
@@ -14,6 +14,7 @@
 #ifndef LLVM_CLANG_AST_GLOBALDECL_H
 #define LLVM_CLANG_AST_GLOBALDECL_H
 
+#include "clang/AST/Attr.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/DeclOpenMP.h"
@@ -33,6 +34,11 @@ enum class DynamicInitKind : unsigned {
   AtExit,
 };
 
+enum class KernelReferenceKind : unsigned {
+  Kernel = 0,
+  Stub = 1,
+};
+
 /// GlobalDecl - represents a global declaration. This can either be a
 /// CXXConstructorDecl and the constructor type (Base, Complete).
 /// a CXXDestructorDecl and the destructor type (Base, Complete),
@@ -52,6 +58,7 @@ class GlobalDecl {
   void Init(const Decl *D) {
 assert(!isa(D) && "Use other ctor with ctor decls!");
 assert(!isa(D) && "Use other ctor with dtor decls!");
+assert(!D->hasAttr() && "Use other ctor with GPU 
kernels!");
 
 Value.setPointer(D);
   }
@@ -73,6 +80,10 @@ class GlobalDecl {
   GlobalDecl(const CXXDestructorDecl *D, CXXDtorType Type) : Value(D, Type) {}
   GlobalDecl(const VarDecl *D, DynamicInitKind StubKind)
   : Value(D, unsigned(StubKind)) {}
+  GlobalDecl(const FunctionDecl *D, KernelReferenceKind Kind)
+  : Value(D, unsigned(Kind)) {
+assert(D->hasAttr() && "Decl is not a GPU kernel!");
+  }
 
   GlobalDecl getCanonicalDecl() const {
 GlobalDecl CanonGD;
@@ -103,13 +114,22 @@ class GlobalDecl {
   }
 
   unsigned getMultiVersionIndex() const {
-assert(isa(getDecl()) &&
+assert(isa(
+   getDecl()) &&
+   !cast(getDecl())->hasAttr() &&
!isa(getDecl()) &&
!isa(getDecl()) &&
"Decl is not a plain FunctionDecl!");
 return MultiVersionIndex;
   }
 
+  KernelReferenceKind getKernelReferenceKind() const {
+assert(isa(getDecl()) &&
+   cast(getDecl())->hasAttr() &&
+   "Decl is not a GPU kernel!");
+return static_cast(Value.getInt());
+  }
+
   friend bool operator==(const GlobalDecl , const GlobalDecl ) {
 return LHS.Value == RHS.Value &&
LHS.MultiVersionIndex == RHS.MultiVersionIndex;
@@ -125,6 +145,12 @@ class GlobalDecl {
 return GD;
   }
 
+  static GlobalDecl getDefaultKernelReference(const FunctionDecl *D) {
+return GlobalDecl(D, D->getASTContext().getLangOpts().CUDAIsDevice
+ ? KernelReferenceKind::Kernel
+ : KernelReferenceKind::Stub);
+  }
+
   GlobalDecl getWithDecl(const Decl *D) {
 GlobalDecl Result(*this);
 Result.Value.setPointer(D);
@@ -147,6 +173,7 @@ class GlobalDecl {
 
   GlobalDecl getWithMultiVersionIndex(unsigned Index) {
 assert(isa(getDecl()) &&
+   !cast(getDecl())->hasAttr() &&
!isa(getDecl()) &&
!isa(getDecl()) &&
"Decl is not a plain FunctionDecl!");
@@ -154,6 +181,15 @@ class GlobalDecl {
 Result.MultiVersionIndex = Index;
 return Result;
   }
+
+  GlobalDecl getWithKernelReferenceKind(KernelReferenceKind Kind) {
+assert(isa(getDecl()) &&
+   cast(getDecl())->hasAttr() &&
+   "Decl is 

[PATCH] D75643: [Sema] Don't emit pointer to int cast warnings under -Wmicrosoft-cast

2020-03-09 Thread Arthur Eubanks via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG51d7f645448b: Dont emit pointer to int cast warnings 
under -Wmicrosoft-cast (authored by aeubanks).

Changed prior to commit:
  https://reviews.llvm.org/D75643?vs=248306=249203#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75643

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaCast.cpp
  clang/test/Sema/MicrosoftExtensions.c


Index: clang/test/Sema/MicrosoftExtensions.c
===
--- clang/test/Sema/MicrosoftExtensions.c
+++ clang/test/Sema/MicrosoftExtensions.c
@@ -1,5 +1,4 @@
-// RUN: %clang_cc1 -triple i686-windows %s -fsyntax-only -Wno-unused-value 
-Wmicrosoft -verify -fms-extensions
-
+// RUN: %clang_cc1 -triple i686-windows %s -fsyntax-only -Wno-unused-value 
-Wno-pointer-to-int-cast -Wmicrosoft -verify -fms-extensions
 
 struct A
 {
@@ -93,13 +92,13 @@
 };
 
 void pointer_to_integral_type_conv(char* ptr) {
-   char ch = (char)ptr; // expected-warning{{cast to smaller integer type 
'char' from 'char *' is a Microsoft extension}}
-   short sh = (short)ptr; // expected-warning{{cast to smaller integer type 
'short' from 'char *' is a Microsoft extension}}
-   ch = (char)ptr; // expected-warning{{cast to smaller integer type 'char' 
from 'char *' is a Microsoft extension}}
-   sh = (short)ptr; // expected-warning{{cast to smaller integer type 'short' 
from 'char *' is a Microsoft extension}}
+  char ch = (char)ptr;
+  short sh = (short)ptr;
+  ch = (char)ptr;
+  sh = (short)ptr;
 
-   // This is valid ISO C.
-   _Bool b = (_Bool)ptr;
+  // This is valid ISO C.
+  _Bool b = (_Bool)ptr;
 }
 
 typedef struct {
Index: clang/lib/Sema/SemaCast.cpp
===
--- clang/lib/Sema/SemaCast.cpp
+++ clang/lib/Sema/SemaCast.cpp
@@ -2778,9 +2778,7 @@
   // is undefined. The result need not be in the range of values of any
   // integer type.
   unsigned Diag;
-  if (Self.getLangOpts().MicrosoftExt)
-Diag = diag::ext_ms_pointer_to_int_cast;
-  else if (SrcType->isVoidPointerType())
+  if (SrcType->isVoidPointerType())
 Diag = DestType->isEnumeralType() ? 
diag::warn_void_pointer_to_enum_cast
   : 
diag::warn_void_pointer_to_int_cast;
   else if (DestType->isEnumeralType())
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3682,9 +3682,6 @@
 def warn_void_pointer_to_enum_cast : Warning<
   warn_void_pointer_to_int_cast.Text>,
   InGroup;
-def ext_ms_pointer_to_int_cast : ExtWarn<
-  "cast to smaller integer type %1 from %0 is a Microsoft extension">,
-InGroup;
 
 def warn_attribute_ignored_for_field_of_type : Warning<
   "%0 attribute ignored for field of type %1">,


Index: clang/test/Sema/MicrosoftExtensions.c
===
--- clang/test/Sema/MicrosoftExtensions.c
+++ clang/test/Sema/MicrosoftExtensions.c
@@ -1,5 +1,4 @@
-// RUN: %clang_cc1 -triple i686-windows %s -fsyntax-only -Wno-unused-value -Wmicrosoft -verify -fms-extensions
-
+// RUN: %clang_cc1 -triple i686-windows %s -fsyntax-only -Wno-unused-value -Wno-pointer-to-int-cast -Wmicrosoft -verify -fms-extensions
 
 struct A
 {
@@ -93,13 +92,13 @@
 };
 
 void pointer_to_integral_type_conv(char* ptr) {
-   char ch = (char)ptr; // expected-warning{{cast to smaller integer type 'char' from 'char *' is a Microsoft extension}}
-   short sh = (short)ptr; // expected-warning{{cast to smaller integer type 'short' from 'char *' is a Microsoft extension}}
-   ch = (char)ptr; // expected-warning{{cast to smaller integer type 'char' from 'char *' is a Microsoft extension}}
-   sh = (short)ptr; // expected-warning{{cast to smaller integer type 'short' from 'char *' is a Microsoft extension}}
+  char ch = (char)ptr;
+  short sh = (short)ptr;
+  ch = (char)ptr;
+  sh = (short)ptr;
 
-   // This is valid ISO C.
-   _Bool b = (_Bool)ptr;
+  // This is valid ISO C.
+  _Bool b = (_Bool)ptr;
 }
 
 typedef struct {
Index: clang/lib/Sema/SemaCast.cpp
===
--- clang/lib/Sema/SemaCast.cpp
+++ clang/lib/Sema/SemaCast.cpp
@@ -2778,9 +2778,7 @@
   // is undefined. The result need not be in the range of values of any
   // integer type.
   unsigned Diag;
-  if (Self.getLangOpts().MicrosoftExt)
-Diag = diag::ext_ms_pointer_to_int_cast;
-  else if (SrcType->isVoidPointerType())
+  if (SrcType->isVoidPointerType())
 Diag = DestType->isEnumeralType() ? diag::warn_void_pointer_to_enum_cast
   : 

[clang] 51d7f64 - Don't emit pointer to int cast warnings under -Wmicrosoft-cast

2020-03-09 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2020-03-09T13:27:46-07:00
New Revision: 51d7f645448b49c7d3b029a60532bac019da1348

URL: 
https://github.com/llvm/llvm-project/commit/51d7f645448b49c7d3b029a60532bac019da1348
DIFF: 
https://github.com/llvm/llvm-project/commit/51d7f645448b49c7d3b029a60532bac019da1348.diff

LOG: Don't emit pointer to int cast warnings under -Wmicrosoft-cast

Summary:
MSVC also warns on this:
$ cat /tmp/a.c
int f(void* p) { return (int) p; }

$ cl /c /tmp/a.c
C:/src/tmp/a.c(1): warning C4311: 'type cast': pointer truncation from
'void *' to 'int'

Warnings originally added in https://reviews.llvm.org/D72231.

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaCast.cpp
clang/test/Sema/MicrosoftExtensions.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 6c73917e2eac..f4ed6b2e649e 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3682,9 +3682,6 @@ def warn_void_pointer_to_int_cast : Warning<
 def warn_void_pointer_to_enum_cast : Warning<
   warn_void_pointer_to_int_cast.Text>,
   InGroup;
-def ext_ms_pointer_to_int_cast : ExtWarn<
-  "cast to smaller integer type %1 from %0 is a Microsoft extension">,
-InGroup;
 
 def warn_attribute_ignored_for_field_of_type : Warning<
   "%0 attribute ignored for field of type %1">,

diff  --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp
index 8edff2439e0d..2d0a2298329e 100644
--- a/clang/lib/Sema/SemaCast.cpp
+++ b/clang/lib/Sema/SemaCast.cpp
@@ -2778,9 +2778,7 @@ void CastOperation::CheckCStyleCast() {
   // is undefined. The result need not be in the range of values of any
   // integer type.
   unsigned Diag;
-  if (Self.getLangOpts().MicrosoftExt)
-Diag = diag::ext_ms_pointer_to_int_cast;
-  else if (SrcType->isVoidPointerType())
+  if (SrcType->isVoidPointerType())
 Diag = DestType->isEnumeralType() ? 
diag::warn_void_pointer_to_enum_cast
   : 
diag::warn_void_pointer_to_int_cast;
   else if (DestType->isEnumeralType())

diff  --git a/clang/test/Sema/MicrosoftExtensions.c 
b/clang/test/Sema/MicrosoftExtensions.c
index 8e7087a57991..166ba7f6c0a2 100644
--- a/clang/test/Sema/MicrosoftExtensions.c
+++ b/clang/test/Sema/MicrosoftExtensions.c
@@ -1,5 +1,4 @@
-// RUN: %clang_cc1 -triple i686-windows %s -fsyntax-only -Wno-unused-value 
-Wmicrosoft -verify -fms-extensions
-
+// RUN: %clang_cc1 -triple i686-windows %s -fsyntax-only -Wno-unused-value 
-Wno-pointer-to-int-cast -Wmicrosoft -verify -fms-extensions
 
 struct A
 {
@@ -93,13 +92,13 @@ enum : long long {  // expected-warning{{enumeration types 
with a fixed underlyi
 };
 
 void pointer_to_integral_type_conv(char* ptr) {
-   char ch = (char)ptr; // expected-warning{{cast to smaller integer type 
'char' from 'char *' is a Microsoft extension}}
-   short sh = (short)ptr; // expected-warning{{cast to smaller integer type 
'short' from 'char *' is a Microsoft extension}}
-   ch = (char)ptr; // expected-warning{{cast to smaller integer type 'char' 
from 'char *' is a Microsoft extension}}
-   sh = (short)ptr; // expected-warning{{cast to smaller integer type 'short' 
from 'char *' is a Microsoft extension}}
+  char ch = (char)ptr;
+  short sh = (short)ptr;
+  ch = (char)ptr;
+  sh = (short)ptr;
 
-   // This is valid ISO C.
-   _Bool b = (_Bool)ptr;
+  // This is valid ISO C.
+  _Bool b = (_Bool)ptr;
 }
 
 typedef struct {



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


[PATCH] D73521: [analyzer][WIP] add-new-checker.py: Introduction

2020-03-09 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.
Herald added subscribers: martong, steakhal.

I didn't use it yet but i like it. The code is easy to understand, so i'll be 
happy to maintain it as it lands.

The example checker is nice and i like how you made sure it demonstrates modern 
API usage. I'm a bit worried that it may quickly get out of date as we update 
our APIs, because this happens like ~multiple times a year, much more often 
than in clang-tidy. Is there a way to write a test that tests that the 
generated checker //compiles//? I don't have any specific ideas but it would 
have been awesome.




Comment at: clang/utils/analyzer/add-new-checker.py:79-81
+data = subprocess.check_output(['llvm-tblgen', '-dump-json',
+checkers_path,
+'-I=' + checkers_include_path])

`llvm-tblgen` needs to be in the `PATH`, right? What if LLVM isn't installed on 
the host system or has the wrong version?

We might have to either tell the user to specify it explicitly in the 
invocation (and then update the LIT substitution to explicitly use the right 
binary), or, ideally, try to get the script installed into the build directory 
so that it could find the freshly built `llvm-tblgen` binary relative to itself.



Comment at: clang/utils/analyzer/add-new-checker.py:573
+
+REGISTER_MAP_WITH_PROGRAMSTATE(AwesomeMap, const MemRegion *, bool)
+

I think we should say explicitly that these are examples, not required code, 
because a lot of this may look like magic to a beginner.

I.e., "Here's how you define a state trait", etc.


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

https://reviews.llvm.org/D73521



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


[PATCH] D75638: [Hexagon] Support for Linux/Musl ABI.

2020-03-09 Thread Brian Cain via Phabricator via cfe-commits
bcain added a comment.

In general, I recommend qualifying metric and threshold values with their 
associated units: bits, bytes, pages, etc.  That way it's easy to see where the 
unit conversions are happening and easy to see whether the logic is correct 
without reasoning about how the value changes among lines.

Constants specified by the ABI should be designated with names and units 
[unless maybe this conflicts w/llvm project naming conventions?]




Comment at: clang/lib/CodeGen/TargetInfo.cpp:7592
+uint64_t Size = getContext().getTypeSize(Ty);
+if (Size <= 64)
+  HexagonAdjustRegsLeft(Size, RegsLeft);

This `64` should probably be named something like 
`HEXAGON_REGISTER_SIZE_BITS_MAX`?



Comment at: clang/lib/CodeGen/TargetInfo.cpp:7613
+  if (HexagonAdjustRegsLeft(Size, RegsLeft))
+Align = Size <= 32 ? 32 : 64;
+  if (Size <= Align) {

`32` here should be `HEXAGON_REGISTER_SIZE_BITS_MIN` maybe?



Comment at: clang/lib/CodeGen/TargetInfo.cpp:7705
+  // Round up to the minimum stack alignment for varargs which is 4 bytes.
+  uint64_t Offset = llvm::alignTo(CGF.getContext().getTypeSize(Ty) / 8, 4);
+

I suggest:


```
uint64_t Offset = llvm::alignTo(CGF.getContext().getTypeSize(Ty) / CHAR_BIT, 
HEXAGON_MIN_STACK_ALIGN_BYTES);
```



Comment at: clang/lib/CodeGen/TargetInfo.cpp:7748
+ QualType Ty) const {
+  int ArgSize = CGF.getContext().getTypeSize(Ty) / 8;
+



```
int ArgSizeBytes = CGF.getContext().getTypeSize(Ty) / CHAR_BIT;
if (ArgSizeBytes > HEXAGON_VA_REGISTER_LIMIT_BYTES)
return EmitVAArgFromMemory(CGF, VAListAddr, Ty);
```



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75638



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


[PATCH] D64464: [CodeGen] Emit destructor calls to destruct compound literals

2020-03-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.

Minor comments; otherwise LGTM.




Comment at: clang/lib/Sema/SemaExpr.cpp:6256
+// Compound literals that have automatic storage duration are destroyed at
+// the end of the scope.
+

Probably add "in C; in C++, they're just temporaries".



Comment at: lib/CodeGen/CGExpr.cpp:4100
+  if (E->getType().isDestructedType() == QualType::DK_nontrivial_c_struct)
+pushDestroy(QualType::DK_nontrivial_c_struct, DeclPtr, E->getType());
+

ahatanak wrote:
> rjmccall wrote:
> > ahatanak wrote:
> > > rjmccall wrote:
> > > > ahatanak wrote:
> > > > > rjmccall wrote:
> > > > > > ahatanak wrote:
> > > > > > > rjmccall wrote:
> > > > > > > > rjmccall wrote:
> > > > > > > > > Unfortunately, the lifetime of compound literals in C is not 
> > > > > > > > > this simple; they're like blocks in that they're destroyed at 
> > > > > > > > > the end of the enclosing scope rather than at the end of the 
> > > > > > > > > current statement. (The cleanup here will be popped at the 
> > > > > > > > > end of the full-expression if we've entered an 
> > > > > > > > > `ExprWithCleanups`.) And the l-value case is exactly the case 
> > > > > > > > > where this matters.
> > > > > > > > > 
> > > > > > > > > I think you need to do something like what we do with blocks, 
> > > > > > > > > where we record all the blocks in the full-expression on the 
> > > > > > > > > `ExprWithCleanups` so that we can push an inactive cleanup 
> > > > > > > > > for them and then activate it when we emit the block.
> > > > > > > > Can we make the check here something like (1) this is a 
> > > > > > > > block-scope compound literal and (2) it has a 
> > > > > > > > non-trivially-destructed type (of any kind)?  That way we're 
> > > > > > > > not conflating two potentially unrelated elements, the lifetime 
> > > > > > > > of the object and the kinds of types that can be constructed by 
> > > > > > > > the literal.
> > > > > > > > 
> > > > > > > > Oh, actually, there's a concrete reason to do this: C99 
> > > > > > > > compound literals are not required to have struct type; they 
> > > > > > > > can have any object type, including arrays but also scalars.  
> > > > > > > > So we could, even without non-trivial C structs, have a 
> > > > > > > > block-scope compound of type `__strong id[]`; I guess we've 
> > > > > > > > always just gotten this wrong.  Please add tests for this case. 
> > > > > > > > :)
> > > > > > > There is a check `E->isFileScope()` above this. Is that 
> > > > > > > sufficient to check for block-scoped compound literals?
> > > > > > That plus the C/C++ difference; compound literals in C++ are just 
> > > > > > temporaries.
> > > > > I haven't been able to come up with a piece of C++ code that executes 
> > > > > `EmitCompoundLiteralLValue`. The following code gets rejected because 
> > > > > you can't take the address of a temporary object in C++:
> > > > > 
> > > > > ```
> > > > > StrongSmall *p = &(StrongSmall){ 1, 0 };
> > > > > ```
> > > > > 
> > > > > If a bind a reference to it, 
> > > > > `AggExprEmitter::VisitCompoundLiteralExpr` is called.
> > > > That makes sense; they're not gl-values in C++.  It would be reasonable 
> > > > to assert that.  But the C++ point does apply elsewhere.
> > > It turns out this function is called in C++ when the compound literal is 
> > > a vector type, so I've just added a check for C++ instead of an assert.
> > Really?  Is the expression actually an l-value in this case somehow?
> I see this function being called when 
> `ScalarExprEmitter::VisitCompoundLiteralExpr` calls `EmitLoadOfLValue`.
Okay.  As a general rule, nothing should be calling `EmitLValue` on an 
expression that isn't actually an l-value.  It's a little more reasonable here 
because it's more like a helper routine.  If this is the cleanest way to handle 
this in C++, it's okay, but please leave a comment explaining that here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64464



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


[PATCH] D75068: libclang: Add static build support for Windows

2020-03-09 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

@thakis?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75068



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


[PATCH] D75811: [CUDA] Choose default architecture based on CUDA installation

2020-03-09 Thread Raul Tambre via Phabricator via cfe-commits
tambre added a comment.

> Magically changing compiler target based on something external to compiler is 
> a bad idea IMO. I would expect a compilation with exactly the same compiler 
> options to do exactly the same thing. If we magically change default target, 
> that will not be the case.

It'd be the same behaviour as NVCC, which compiles for the lowest architecture 
it supports.

I'm currently implementing Clang CUDA support for CMake and lack of this 
behaviour compared to other languages and compilers complicates matters.
During compiler detection CMake compiles a simple program, which includes 
preprocessor stuff for embedding compiler info in the output. Then it parses 
that and determines the compiler vendor, version, etc.

The general assumption is that a compiler can compile a simple program for its 
language without us having to do compiler-specific options, flags, etc. If the 
compiler fails on this simple program, it's considered broken.
A limited list of flags is usually cycled through to support exotic compilers 
and I could do the same here, but it'd require us invoking the compiler 
multiple times and increasingly more as old architectures are deprecated.
We could detect the CUDA installation ourselves and specify a list of arches 
for each. This seems quite unnecessary when Clang already knows the version and 
could select a default that at least compiles.
Note that this detection happens before any user CMake files are ran, so we 
can't pass the user's preferred arch (which could also differ per file).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75811



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


[PATCH] D66094: [CodeGen] Emit destructor calls for non-trivial C structs returned by function calls and loaded from volatile objects

2020-03-09 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 249190.
ahatanak marked an inline comment as done.
ahatanak added a comment.

Fix the way `IsExternallyDestructed` is used.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66094

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGCall.h
  clang/lib/CodeGen/CGClass.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CGVTables.cpp
  clang/lib/Parse/ParseObjc.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprObjC.cpp
  clang/test/CodeGenObjC/arc.m
  clang/test/CodeGenObjC/strong-in-c-struct.m

Index: clang/test/CodeGenObjC/strong-in-c-struct.m
===
--- clang/test/CodeGenObjC/strong-in-c-struct.m
+++ clang/test/CodeGenObjC/strong-in-c-struct.m
@@ -89,6 +89,13 @@
 void calleeStrongSmall(StrongSmall);
 void func(Strong *);
 
+@interface C
+-(StrongSmall)getStrongSmall;
++(StrongSmall)getStrongSmallClass;
+@end
+
+id g0;
+
 // CHECK: %[[STRUCT_STRONGOUTER:.*]] = type { %[[STRUCT_STRONG:.*]], i8*, double }
 // CHECK: %[[STRUCT_STRONG]] = type { %[[STRUCT_TRIVIAL:.*]], i8* }
 // CHECK: %[[STRUCT_TRIVIAL]] = type { [4 x i32] }
@@ -476,6 +483,18 @@
   getStrongSmall();
 }
 
+// CHECK: define void @test_destructor_ignored_result2(%{{.*}}* %[[C:.*]])
+// CHECK: %[[TMP:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8
+// CHECK: %[[CALL:.*]] = call [2 x i64]{{.*}}@objc_msgSend
+// CHECK: %[[V5:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[TMP]] to [2 x i64]*
+// CHECK: store [2 x i64] %[[CALL]], [2 x i64]* %[[V5]], align 8
+// CHECK: %[[V6:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[TMP]] to i8**
+// CHECK: call void @__destructor_8_s8(i8** %[[V6]])
+
+void test_destructor_ignored_result2(C *c) {
+  [c getStrongSmall];
+}
+
 // CHECK: define void @test_copy_constructor_StrongBlock(
 // CHECK: call void @__copy_constructor_8_8_sb0(
 // CHECK: call void @__destructor_8_sb0(
@@ -520,7 +539,9 @@
 
 // CHECK: define void @test_copy_constructor_StrongVolatile0(
 // CHECK: call void @__copy_constructor_8_8_t0w4_sv8(
+// CHECK-NOT: call
 // CHECK: call void @__destructor_8_sv8(
+// CHECK-NOT: call
 
 // CHECK: define linkonce_odr hidden void @__copy_constructor_8_8_t0w4_sv8(
 // CHECK: %[[V8:.*]] = load volatile i8*, i8** %{{.*}}, align 8
@@ -709,4 +730,62 @@
   VolatileArray t = *a;
 }
 
+// CHECK: define void @test_member_access(
+// CHECK: %[[TMP:.*]] = alloca %[[STRUCT_STRONGSMALL]],
+// CHECK: %[[V3:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[TMP]] to i8**
+// CHECK: call void @__destructor_8_s8(i8** %[[V3]])
+// CHECK: call void @func(
+
+void test_member_access(void) {
+  g0 = getStrongSmall().f1;
+  func(0);
+}
+
+// CHECK: define void @test_member_access2(%{{.*}}* %[[C:.*]])
+// CHECK: %[[COERCE:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8
+// CHECK: %[[V8:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[COERCE]] to i8**
+// CHECK: call void @__destructor_8_s8(i8** %[[V8]])
+// CHECK: call void @func(
+
+void test_member_access2(C *c) {
+  g0 = [c getStrongSmall].f1;
+  func(0);
+}
+
+// CHECK: define void @test_member_access3(
+// CHECK: %[[COERCE:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8
+// CHECK: %[[V8:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[COERCE]] to i8**
+// CHECK: call void @__destructor_8_s8(i8** %[[V8]])
+// CHECK: call void @func(
+
+void test_member_access3(void) {
+  g0 = [C getStrongSmallClass].f1;
+  func(0);
+}
+
+// CHECK: define void @test_member_access4()
+// CHECK: %[[COERCE:.*]] = alloca %[[STRUCT_STRONGSMALL]], align 8
+// CHECK: %[[V5:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[COERCE]] to i8**
+// CHECK: call void @__destructor_8_s8(i8** %[[V5]])
+// CHECK: call void @func(
+
+void test_member_access4(void) {
+  g0 = ^{ StrongSmall s; return s; }().f1;
+  func(0);
+}
+
+// CHECK: define void @test_volatile_variable_reference(
+// CHECK: %[[AGG_TMP_ENSURED:.*]] = alloca %[[STRUCT_STRONGSMALL]],
+// CHECK: %[[V1:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[AGG_TMP_ENSURED]] to i8**
+// CHECK: %[[V2:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %{{.*}} to i8**
+// CHECK: call void @__copy_constructor_8_8_tv0w32_sv8(i8** %[[V1]], i8** %[[V2]])
+// CHECK: %[[V3:.*]] = bitcast %[[STRUCT_STRONGSMALL]]* %[[AGG_TMP_ENSURED]] to i8**
+// CHECK: call void @__destructor_8_s8(i8** %[[V3]])
+// CHECK: call void @func(
+
+void test_volatile_variable_reference(volatile StrongSmall *a) {
+  (void)*a;
+  func(0);
+}
+
 #endif /* USESTRUCT */
Index: clang/test/CodeGenObjC/arc.m
===
--- clang/test/CodeGenObjC/arc.m
+++ clang/test/CodeGenObjC/arc.m
@@ -1536,12 +1536,13 @@
 
 // CHECK-LABEL: define void @test71
 void test71(void) {
-  // FIXME: It would be nice if the __destructor_8_s40 for the first call (and
-  // the following lifetime.end) came before the second call.
-  //
   // CHECK: %[[T:[^ ]+]] = bitcast 

[clang] 3d9a044 - Recommit #2 "[Driver] Default to -fno-common for all targets"

2020-03-09 Thread Sjoerd Meijer via cfe-commits

Author: Sjoerd Meijer
Date: 2020-03-09T19:57:03Z
New Revision: 3d9a0445cce368b55dc3a573bc91fe902bbb977f

URL: 
https://github.com/llvm/llvm-project/commit/3d9a0445cce368b55dc3a573bc91fe902bbb977f
DIFF: 
https://github.com/llvm/llvm-project/commit/3d9a0445cce368b55dc3a573bc91fe902bbb977f.diff

LOG: Recommit #2 "[Driver] Default to -fno-common for all targets"

After a first attempt to fix the test-suite failures, my first recommit
caused the same failures again. I had updated CMakeList.txt files of
tests that needed -fcommon, but it turns out that there are also
Makefiles which are used by some bots, so I've updated these Makefiles
now too.

See the original commit message for more details on this change:
0a9fc9233e172601e26381810d093e02ef410f65

Added: 
clang/test/Driver/no-common.c

Modified: 
clang/docs/ClangCommandLineReference.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CodeGen/2008-07-21-mixed-var-fn-decl.c
clang/test/CodeGen/2009-10-20-GlobalDebug.c
clang/test/CodeGen/aarch64-sve.c
clang/test/CodeGen/address-space.c
clang/test/CodeGen/alias.c
clang/test/CodeGen/align-systemz.c
clang/test/CodeGen/alignment.c
clang/test/CodeGen/asm-label.c
clang/test/CodeGen/attr-weak-import.c
clang/test/CodeGen/attr-weakref2.c
clang/test/CodeGen/attributes.c
clang/test/CodeGen/blocks-windows.c
clang/test/CodeGen/bool-convert.c
clang/test/CodeGen/c11atomics.c
clang/test/CodeGen/cfstring-elf-cfbuild-x86_64.c
clang/test/CodeGen/cfstring-windows.c
clang/test/CodeGen/default-address-space.c
clang/test/CodeGen/dllexport-1.c
clang/test/CodeGen/dllexport.c
clang/test/CodeGen/dllimport.c
clang/test/CodeGen/microsoft-no-common-align.c
clang/test/CodeGen/no-common.c
clang/test/CodeGen/pr25786.c
clang/test/CodeGen/pragma-pack-1.c
clang/test/CodeGen/pragma-weak.c
clang/test/CodeGen/private-extern-redef.c
clang/test/CodeGen/tentative-decls.c
clang/test/CodeGen/tls-model.c
clang/test/CodeGen/visibility.c
clang/test/CodeGen/vlt_to_pointer.c
clang/test/CodeGen/volatile-1.c
clang/test/CodeGen/windows-on-arm-dllimport-dllexport.c
clang/test/CodeGenCXX/clang-sections-tentative.c
clang/test/CodeGenObjC/constant-string-class.m
clang/test/CodeGenObjC/tentative-cfconstantstring.m
clang/test/CodeGenOpenCL/address-spaces.cl
clang/test/CodeGenOpenCL/amdgcn-large-globals.cl
clang/test/CodeGenOpenCL/amdgpu-nullptr.cl
clang/test/Driver/apple-kext-mkernel.c
clang/test/Driver/clang_f_opts.c
clang/test/Driver/fuchsia.c
clang/test/Driver/xcore-opts.c
clang/test/Frontend/ast-codegen.c
clang/test/Headers/xmmintrin.c
clang/test/PCH/chain-external-defs.c
clang/test/PCH/external-defs.c
clang/test/PCH/tentative-defs.c
clang/test/Parser/pragma-visibility2.c
compiler-rt/test/asan/TestCases/Linux/odr_c_test.c
compiler-rt/test/asan/TestCases/set_shadow_test.c

Removed: 
clang/test/CodeGen/weak-global.c



diff  --git a/clang/docs/ClangCommandLineReference.rst 
b/clang/docs/ClangCommandLineReference.rst
index 609e7fa66c00..5af9d64ae0fc 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -1307,6 +1307,10 @@ Use colors in diagnostics
 
 .. option:: -fcommon, -fno-common
 
+Place definitions of variables with no storage class and no initializer
+(tentative definitions) in a common block, instead of generating individual
+zero-initialized definitions (default -fno-common).
+
 .. option:: -fcompile-resource=, --resource , --resource=
 
 .. option:: -fconstant-cfstrings, -fno-constant-cfstrings

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ce121ebe6055..664ae4e4167c 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -84,6 +84,13 @@ future versions of Clang.
 Modified Compiler Flags
 ---
 
+- -fno-common has been enabled as the default for all targets.  Therefore, C
+  code that uses tentative definitions as definitions of a variable in multiple
+  translation units will trigger multiple-definition linker errors.  Generally,
+  this occurs when the use of the ``extern`` keyword is neglected in the 
declaration
+  of a variable in a header file. In some cases, no specific translation unit
+  provides a definition of the variable. The previous behavior can be restored 
by
+  specifying ``-fcommon``.
 
 New Pragmas in Clang
 

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 0d5cba8d682a..bdcd771ff713 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -848,7 +848,8 @@ def fno_record_command_line : Flag<["-"], 

[clang] d0ca104 - [Hexagon] Refactor handling of circular load/store builtins, NFC

2020-03-09 Thread Krzysztof Parzyszek via cfe-commits

Author: Krzysztof Parzyszek
Date: 2020-03-09T14:40:08-05:00
New Revision: d0ca1041ba0d2d6b8adc7f04d017502e44a118e3

URL: 
https://github.com/llvm/llvm-project/commit/d0ca1041ba0d2d6b8adc7f04d017502e44a118e3
DIFF: 
https://github.com/llvm/llvm-project/commit/d0ca1041ba0d2d6b8adc7f04d017502e44a118e3.diff

LOG: [Hexagon] Refactor handling of circular load/store builtins, NFC

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 952cc3f0c9b8..5a1fb5d391f1 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -15103,6 +15103,28 @@ getIntrinsicForHexagonNonGCCBuiltin(unsigned 
BuiltinID) {
   Info Infos[] = {
 #define CUSTOM_BUILTIN_MAPPING(x,s) \
   { Hexagon::BI__builtin_HEXAGON_##x, Intrinsic::hexagon_##x, s },
+CUSTOM_BUILTIN_MAPPING(L2_loadrub_pci, 0)
+CUSTOM_BUILTIN_MAPPING(L2_loadrb_pci, 0)
+CUSTOM_BUILTIN_MAPPING(L2_loadruh_pci, 0)
+CUSTOM_BUILTIN_MAPPING(L2_loadrh_pci, 0)
+CUSTOM_BUILTIN_MAPPING(L2_loadri_pci, 0)
+CUSTOM_BUILTIN_MAPPING(L2_loadrd_pci, 0)
+CUSTOM_BUILTIN_MAPPING(L2_loadrub_pcr, 0)
+CUSTOM_BUILTIN_MAPPING(L2_loadrb_pcr, 0)
+CUSTOM_BUILTIN_MAPPING(L2_loadruh_pcr, 0)
+CUSTOM_BUILTIN_MAPPING(L2_loadrh_pcr, 0)
+CUSTOM_BUILTIN_MAPPING(L2_loadri_pcr, 0)
+CUSTOM_BUILTIN_MAPPING(L2_loadrd_pcr, 0)
+CUSTOM_BUILTIN_MAPPING(S2_storerb_pci, 0)
+CUSTOM_BUILTIN_MAPPING(S2_storerh_pci, 0)
+CUSTOM_BUILTIN_MAPPING(S2_storerf_pci, 0)
+CUSTOM_BUILTIN_MAPPING(S2_storeri_pci, 0)
+CUSTOM_BUILTIN_MAPPING(S2_storerd_pci, 0)
+CUSTOM_BUILTIN_MAPPING(S2_storerb_pcr, 0)
+CUSTOM_BUILTIN_MAPPING(S2_storerh_pcr, 0)
+CUSTOM_BUILTIN_MAPPING(S2_storerf_pcr, 0)
+CUSTOM_BUILTIN_MAPPING(S2_storeri_pcr, 0)
+CUSTOM_BUILTIN_MAPPING(S2_storerd_pcr, 0)
 CUSTOM_BUILTIN_MAPPING(V6_vmaskedstoreq, 64)
 CUSTOM_BUILTIN_MAPPING(V6_vmaskedstorenq, 64)
 CUSTOM_BUILTIN_MAPPING(V6_vmaskedstorentq, 64)
@@ -15129,63 +15151,47 @@ getIntrinsicForHexagonNonGCCBuiltin(unsigned 
BuiltinID) {
 
 Value *CodeGenFunction::EmitHexagonBuiltinExpr(unsigned BuiltinID,
const CallExpr *E) {
-  SmallVector Ops;
   Intrinsic::ID ID;
   unsigned VecLen;
   std::tie(ID, VecLen) = getIntrinsicForHexagonNonGCCBuiltin(BuiltinID);
 
-  auto MakeCircLd = [&](unsigned IntID, bool HasImm) {
+  auto MakeCircOp = [this, E](unsigned IntID, bool IsLoad) {
 // The base pointer is passed by address, so it needs to be loaded.
-Address BP = EmitPointerWithAlignment(E->getArg(0));
-BP = Address(Builder.CreateBitCast(BP.getPointer(), Int8PtrPtrTy),
- BP.getAlignment());
+Address A = EmitPointerWithAlignment(E->getArg(0));
+Address BP = Address(
+Builder.CreateBitCast(A.getPointer(), Int8PtrPtrTy), A.getAlignment());
 llvm::Value *Base = Builder.CreateLoad(BP);
-// Operands are Base, Increment, Modifier, Start.
-if (HasImm)
-  Ops = { Base, EmitScalarExpr(E->getArg(1)), EmitScalarExpr(E->getArg(2)),
-  EmitScalarExpr(E->getArg(3)) };
-else
-  Ops = { Base, EmitScalarExpr(E->getArg(1)),
-  EmitScalarExpr(E->getArg(2)) };
+// The treatment of both loads and stores is the same: the arguments for
+// the builtin are the same as the arguments for the intrinsic.
+// Load:
+//   builtin(Base, Inc, Mod, Start) -> intr(Base, Inc, Mod, Start)
+//   builtin(Base, Mod, Start)  -> intr(Base, Mod, Start)
+// Store:
+//   builtin(Base, Inc, Mod, Val, Start) -> intr(Base, Inc, Mod, Val, 
Start)
+//   builtin(Base, Mod, Val, Start)  -> intr(Base, Mod, Val, Start)
+SmallVector Ops = { Base };
+for (unsigned i = 1, e = E->getNumArgs(); i != e; ++i)
+  Ops.push_back(EmitScalarExpr(E->getArg(i)));
 
 llvm::Value *Result = Builder.CreateCall(CGM.getIntrinsic(IntID), Ops);
-llvm::Value *NewBase = Builder.CreateExtractValue(Result, 1);
-llvm::Value *LV = Builder.CreateBitCast(EmitScalarExpr(E->getArg(0)),
-
NewBase->getType()->getPointerTo());
+// The load intrinsics generate two results (Value, NewBase), stores
+// generate one (NewBase). The new base address needs to be stored.
+llvm::Value *NewBase = IsLoad ? Builder.CreateExtractValue(Result, 1)
+  : Result;
+llvm::Value *LV = Builder.CreateBitCast(
+EmitScalarExpr(E->getArg(0)), NewBase->getType()->getPointerTo());
 Address Dest = EmitPointerWithAlignment(E->getArg(0));
-// The intrinsic generates two results. The new value for the base pointer
-// needs to be stored.
-Builder.CreateAlignedStore(NewBase, LV, Dest.getAlignment());
-return Builder.CreateExtractValue(Result, 0);
-  };
-
-  auto MakeCircSt = 

[clang] cc8390b - Permit attribute 'used' with 'target' multiversioning.

2020-03-09 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2020-03-09T12:38:03-07:00
New Revision: cc8390bfe30d08633d62a1b53e6669e386c95600

URL: 
https://github.com/llvm/llvm-project/commit/cc8390bfe30d08633d62a1b53e6669e386c95600
DIFF: 
https://github.com/llvm/llvm-project/commit/cc8390bfe30d08633d62a1b53e6669e386c95600.diff

LOG: Permit attribute 'used' with 'target' multiversioning.

This adds infrastructure for a multiversioning whitelist, plus adds
'used' to the allowed list with 'target'.  The behavior here mirrors the
implementation in GCC, where 'used' only applies to the single
declaration and doesn't apply to the ifunc or resolver.

This is not being applied to cpu_dispatch and cpu_specific, since the
rules are more complicated for cpu_specific, which emits multiple
symbols. Additionally, the author isn't currently aware of uses in the
wild of this combination, but is aware of a number of target+used
combinations.

Added: 


Modified: 
clang/lib/Sema/SemaDecl.cpp
clang/test/CodeGen/attr-target-mv.c
clang/test/Sema/attr-target-mv.c

Removed: 




diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 66359f4faf6a..da40ac188e54 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -9952,6 +9952,18 @@ static bool CheckMultiVersionValue(Sema , const 
FunctionDecl *FD) {
   return false;
 }
 
+// Provide a white-list of attributes that are allowed to be combined with
+// multiversion functions.
+static bool AttrCompatibleWithMultiVersion(attr::Kind Kind,
+   MultiVersionKind MVType) {
+  switch (Kind) {
+  default:
+return false;
+  case attr::Used:
+return MVType == MultiVersionKind::Target;
+  }
+}
+
 static bool HasNonMultiVersionAttributes(const FunctionDecl *FD,
  MultiVersionKind MVType) {
   for (const Attr *A : FD->attrs()) {
@@ -9967,7 +9979,9 @@ static bool HasNonMultiVersionAttributes(const 
FunctionDecl *FD,
 return true;
   break;
 default:
-  return true;
+  if (!AttrCompatibleWithMultiVersion(A->getKind(), MVType))
+return true;
+  break;
 }
   }
   return false;

diff  --git a/clang/test/CodeGen/attr-target-mv.c 
b/clang/test/CodeGen/attr-target-mv.c
index c089b06d238c..b273eb846e1d 100644
--- a/clang/test/CodeGen/attr-target-mv.c
+++ b/clang/test/CodeGen/attr-target-mv.c
@@ -50,6 +50,15 @@ void bar5() {
 int __attribute__((target("avx"))) changed_to_mv(void) { return 0;}
 int __attribute__((target("fma4"))) changed_to_mv(void) { return 1;}
 
+__attribute__((target("default"), used)) inline void foo_used(int i, double d) 
{}
+__attribute__((target("avx,sse4.2"))) inline void foo_used(int i, double d) {}
+
+__attribute__((target("default"))) inline void foo_used2(int i, double d) {}
+__attribute__((target("avx,sse4.2"), used)) inline void foo_used2(int i, 
double d) {}
+
+// LINUX: @llvm.used = appending global [2 x i8*] [i8* bitcast (void (i32, 
double)* @foo_used to i8*), i8* bitcast (void (i32, double)* 
@foo_used2.avx_sse4.2 to i8*)], section "llvm.metadata"
+// WINDOWS: @llvm.used = appending global [2 x i8*] [i8* bitcast (void (i32, 
double)* @foo_used to i8*), i8* bitcast (void (i32, double)* 
@foo_used2.avx_sse4.2 to i8*)], section "llvm.metadata"
+
 // LINUX: @foo.ifunc = weak_odr ifunc i32 (), i32 ()* ()* @foo.resolver
 // LINUX: @foo_inline.ifunc = weak_odr ifunc i32 (), i32 ()* ()* 
@foo_inline.resolver
 // LINUX: @foo_decls.ifunc = weak_odr ifunc void (), void ()* ()* 
@foo_decls.resolver
@@ -203,6 +212,16 @@ int __attribute__((target("fma4"))) changed_to_mv(void) { 
return 1;}
 // WINDOWS: define dso_local i32 @changed_to_mv.avx()
 // WINDOWS: define dso_local i32 @changed_to_mv.fma4()
 
+// LINUX: define linkonce void @foo_used(i32 %{{.*}}, double %{{.*}})
+// LINUX-NOT: @foo_used.avx_sse4.2(
+// LINUX-NOT: @foo_used2(
+// LINUX: define linkonce void @foo_used2.avx_sse4.2(i32 %{{.*}}, double 
%{{.*}})
+
+// WINDOWS: define linkonce_odr dso_local void @foo_used(i32 %{{.*}}, double 
%{{.*}})
+// WINDOWS-NOT: @foo_used.avx_sse4.2(
+// WINDOWS-NOT: @foo_used2(
+// WINDOWS: define linkonce_odr dso_local void @foo_used2.avx_sse4.2(i32 
%{{.*}}, double %{{.*}})
+
 // LINUX: declare i32 @foo.arch_sandybridge()
 // WINDOWS: declare dso_local i32 @foo.arch_sandybridge()
 

diff  --git a/clang/test/Sema/attr-target-mv.c 
b/clang/test/Sema/attr-target-mv.c
index 664ade1c0fa5..e9156a6c73e7 100644
--- a/clang/test/Sema/attr-target-mv.c
+++ b/clang/test/Sema/attr-target-mv.c
@@ -77,21 +77,22 @@ int prev_no_target2(void);
 int __attribute__((target("arch=ivybridge")))  prev_no_target2(void);
 
 void __attribute__((target("sse4.2"))) addtl_attrs(void);
-//expected-error@+1 {{attribute 'target' multiversioning cannot be combined}}
-void __attribute__((used,target("arch=sandybridge")))  addtl_attrs(void);
+//expected-error@+2 {{attribute 'target' 

[PATCH] D75842: [Analyzer] Bugfix for CheckerRegistry

2020-03-09 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 249187.
baloghadamsoftware added a comment.

Test added.


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

https://reviews.llvm.org/D75842

Files:
  clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
  clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp


Index: clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
===
--- clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
+++ clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
@@ -81,6 +81,68 @@
   runCheckerOnCode("void f() { int *p; (*p)++; }"));
 }
 
+//===--===//
+// Unfulfilled dependency
+//===--===//
+
+class PrerequisiteChecker : public Checker {
+public:
+  void checkASTCodeBody(const Decl *D, AnalysisManager ,
+BugReporter ) const {
+assert(false && "This checker should not be registered.");
+BR.EmitBasicReport(D, this, "Prerequisite", categories::LogicError,
+   "This is the prerequisite checker",
+   PathDiagnosticLocation(D, Mgr.getSourceManager()), {});
+  }
+};
+
+void registerPrerequisiteChecker(CheckerManager ) {
+  mgr.registerChecker();
+}
+
+bool shouldRegisterPrerequisiteChecker(const LangOptions ) {
+  return false;
+}
+
+class DependentChecker : public Checker {
+public:
+  void checkASTCodeBody(const Decl *D, AnalysisManager ,
+BugReporter ) const {
+assert(false &&
+   "This checker should not be registered due to missing dependency.");
+BR.EmitBasicReport(D, this, "Dependent", categories::LogicError,
+   "This is the Dependent Checker",
+   PathDiagnosticLocation(D, Mgr.getSourceManager()), {});
+  }
+};
+
+void registerDependentChecker(CheckerManager ) {
+  mgr.registerChecker();
+}
+
+bool shouldRegisterDependentChecker(const LangOptions ) {
+  return true;
+}
+
+void addDependentChecker(AnalysisASTConsumer ,
+ AnalyzerOptions ) {
+  AnOpts.CheckersAndPackages = {{"custom.Dependent", true}};
+  AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry ) {
+ Registry.addChecker(registerPrerequisiteChecker,
+ shouldRegisterPrerequisiteChecker,
+ "custom.Prerequisite", "Description", "", false);
+ Registry.addChecker(registerDependentChecker,
+ shouldRegisterDependentChecker,
+ "custom.Dependent", "Description", "", false);
+ Registry.addDependency("custom.Dependent", "custom.Prerequisite");
+});
+}
+
+TEST(RegisterDependentCheckers, RegisterChecker) {
+  std::string Diags;
+  EXPECT_TRUE(runCheckerOnCode("void f() {;}", Diags));
+}
+
 } // namespace
 } // namespace ento
 } // namespace clang
Index: clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
===
--- clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
+++ clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
@@ -166,7 +166,7 @@
 }
 
 bool isDisabled(const LangOptions ) const {
-  return State == StateFromCmdLine::State_Disabled && ShouldRegister(LO);
+  return State == StateFromCmdLine::State_Disabled || !ShouldRegister(LO);
 }
 
 // Since each checker must have a different full name, we can identify


Index: clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
===
--- clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
+++ clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
@@ -81,6 +81,68 @@
   runCheckerOnCode("void f() { int *p; (*p)++; }"));
 }
 
+//===--===//
+// Unfulfilled dependency
+//===--===//
+
+class PrerequisiteChecker : public Checker {
+public:
+  void checkASTCodeBody(const Decl *D, AnalysisManager ,
+BugReporter ) const {
+assert(false && "This checker should not be registered.");
+BR.EmitBasicReport(D, this, "Prerequisite", categories::LogicError,
+   "This is the prerequisite checker",
+   PathDiagnosticLocation(D, Mgr.getSourceManager()), {});
+  }
+};
+
+void registerPrerequisiteChecker(CheckerManager ) {
+  mgr.registerChecker();
+}
+
+bool shouldRegisterPrerequisiteChecker(const LangOptions ) {
+  return false;
+}
+
+class DependentChecker : public Checker {
+public:
+  void checkASTCodeBody(const Decl *D, AnalysisManager ,
+BugReporter ) const {
+assert(false &&
+   "This checker should not be 

[PATCH] D58164: Block+lambda: allow reference capture

2020-03-09 Thread Akira Hatanaka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe4dfc9f5bda3: Fix the type of the capture passed to 
LambdaIntroducer::addCapture in… (authored by ahatanak).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58164

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CodeGenObjCXX/block-nested-in-lambda.mm

Index: clang/test/CodeGenObjCXX/block-nested-in-lambda.mm
===
--- clang/test/CodeGenObjCXX/block-nested-in-lambda.mm
+++ clang/test/CodeGenObjCXX/block-nested-in-lambda.mm
@@ -1,6 +1,9 @@
-// RUN: %clang_cc1 -triple=x86_64-apple-darwin10 -emit-llvm -std=c++11 -fblocks -fobjc-arc -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple=x86_64-apple-darwin10 -emit-llvm -std=c++14 -fblocks -fobjc-arc -o - %s | FileCheck %s
 
 // CHECK: %[[STRUCT_BLOCK_DESCRIPTOR:.*]] = type { i64, i64 }
+// CHECK: %[[S:.*]] = type { i32 }
+// CHECK: %[[CLASS_ANON_2:.*]] = type { %[[S]]* }
+// CHECK: %[[CLASS_ANON_3:.*]] = type { %[[S]] }
 
 // CHECK: %[[BLOCK_CAPTURED0:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32*, i32* }>, <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32*, i32* }>* %[[BLOCK:.*]], i32 0, i32 5
 // CHECK: %[[V0:.*]] = getelementptr inbounds %[[LAMBDA_CLASS:.*]], %[[LAMBDA_CLASS]]* %[[THIS:.*]], i32 0, i32 0
@@ -33,7 +36,7 @@
 // reference.
 
 // CHECK-LABEL: define void @_ZN18CaptureByReference5test0Ev(
-// CHECK-LABEL: define internal void @"_ZZN18CaptureByReference5test0EvENK3$_1clEv"(
+// CHECK-LABEL: define internal void @"_ZZN18CaptureByReference5test0EvENK3$_3clEv"(
 // CHECK: %[[BLOCK_DESCRIPTOR:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8** }>, <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8** }>* %{{.*}}, i32 0, i32 4
 // CHECK: store %[[STRUCT_BLOCK_DESCRIPTOR]]* bitcast ({ i64, i64, i8*, i64 }* @"__block_descriptor_40_e5_v8\01?0ls32l8" to %[[STRUCT_BLOCK_DESCRIPTOR]]*), %[[STRUCT_BLOCK_DESCRIPTOR]]** %[[BLOCK_DESCRIPTOR]], align 8
 
@@ -46,10 +49,60 @@
 // is captured by reference.
 
 // CHECK-LABEL: define void @_ZN18CaptureByReference5test1Ev(
-// CHECK-LABEL: define internal void @"_ZZN18CaptureByReference5test1EvENK3$_2clEv"(
+// CHECK-LABEL: define internal void @"_ZZN18CaptureByReference5test1EvENK3$_4clEv"(
 // CHECK: %[[BLOCK_DESCRIPTOR:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8*, i8*, i8** }>, <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8*, i8*, i8** }>* %{{.*}}, i32 0, i32 4
 // CHECK: store %[[STRUCT_BLOCK_DESCRIPTOR]]* bitcast ({ i64, i64, i8*, i8*, i8*, i64 }* @"__block_descriptor_56_8_32s40s_e5_v8\01?0l" to %[[STRUCT_BLOCK_DESCRIPTOR]]*), %[[STRUCT_BLOCK_DESCRIPTOR]]** %[[BLOCK_DESCRIPTOR]], align 8
 
+void test1() {
+  id a = getObj(), b = getObj(), c = getObj();
+  [, b, c]{ ^{ a = 0; use(b); use(c); }(); }();
+}
+
+struct S {
+  int val() const;
+  int a;
+  S();
+  S(const S&);
+  S =(const S&);
+  S(S&&);
+  S =(S&&);
+};
+
+S getS();
+
+// CHECK: define internal i32 @"_ZZN18CaptureByReference5test2EvENK3$_1clIiEEDaT_"(%[[CLASS_ANON_2]]* %{{.*}}, i32 %{{.*}})
+// CHECK: %[[BLOCK:.*]] = alloca <{ i8*, i32, i32, i8*, %{{.*}}, %[[S]]* }>, align 8
+// CHECK: %[[BLOCK_CAPTURED:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %{{.*}}, %[[S]]* }>, <{ i8*, i32, i32, i8*, %{{.*}}, %[[S]]* }>* %[[BLOCK]], i32 0, i32 5
+// CHECK: %[[V0:.*]] = getelementptr inbounds %[[CLASS_ANON_2]], %[[CLASS_ANON_2]]* %{{.*}}, i32 0, i32 0
+// CHECK: %[[V1:.*]] = load %[[S]]*, %[[S]]** %[[V0]], align 8
+// CHECK: store %[[S]]* %[[V1]], %[[S]]** %[[BLOCK_CAPTURED]], align 8
+
+int test2() {
+  S s;
+  auto fn = [&](const auto a){
+return ^{
+  return s.val();
+}();
+  };
+  return fn(123);
+}
+
+// CHECK: define internal i32 @"_ZZN18CaptureByReference5test3EvENK3$_2clIiEEDaT_"(%[[CLASS_ANON_3]]* %{{.*}}, i32 %{{.*}})
+// CHECK: %[[BLOCK:.*]] = alloca <{ i8*, i32, i32, i8*, %{{.*}}*, %[[S]] }>, align 8
+// CHECK: %[[BLOCK_CAPTURED:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %{{.*}}*, %[[S]] }>, <{ i8*, i32, i32, i8*, %{{.*}}*, %[[S]] }>* %[[BLOCK]], i32 0, i32 5
+// CHECK: %[[V0:.*]] = getelementptr inbounds %[[CLASS_ANON_3]], %[[CLASS_ANON_3]]* %{{.*}}, i32 0, i32 0
+// CHECK: call void @_ZN18CaptureByReference1SC1ERKS0_(%[[S]]* %[[BLOCK_CAPTURED]], %[[S]]* {{.*}} %[[V0]])
+
+int test3() {
+  const S  = getS();
+  auto fn = [=](const auto a){
+return ^{
+  return s.val();
+}();
+  };
+  return fn(123);
+}
+
 // CHECK-LABEL: define linkonce_odr hidden void @__copy_helper_block_8_32s40s(
 // CHECK-NOT: call void @llvm.objc.storeStrong(
 // CHECK: %[[V4:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8*, i8*, i8** }>, <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8*, i8*, i8** }>* %{{.*}}, i32 0, 

[PATCH] D75740: [ASTImporter] Corrected import of repeated friend declarations.

2020-03-09 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

LGTM WDYT @teemperor




Comment at: clang/lib/AST/ASTImporter.cpp:3638
+  /// Number of similar looking friends.
+  unsigned int TotalCount;
+  /// Index of the specific FriendDecl.

`uint32_t`

Is there a reason to not prefer fixed width integer types?



Comment at: clang/lib/AST/ASTImporter.cpp:3640
+  /// Index of the specific FriendDecl.
+  unsigned int IndexOfDecl;
+};

`uint32_t`



Comment at: clang/lib/AST/ASTImporter.cpp:3644
+FriendCountAndIndex getFriendCountAndPosition(const FriendDecl *FD) {
+  unsigned int FriendCount = 0;
+  llvm::Optional FriendPosition;

`uint32_t`



Comment at: clang/lib/AST/ASTImporter.cpp:3660
+const Decl *CanDeclOfFriend = FD->getFriendDecl()->getCanonicalDecl();
+for (const FriendDecl *FoundFriend : RD->friends()) {
+  if (FoundFriend == FD) {

Can we refactor to not repeat code? They look identical. Duplicate code is a 
source for errors when once piece of code is fixed both the other is not etc



Comment at: clang/unittests/AST/ASTImporterTest.cpp:4009
+TEST_P(ImportFriendClasses, ImportOfRepeatedFriendType) {
+  auto Code =
+  R"(

a_sidorin wrote:
> clang-tidy wants this to be `const auto* Code`.
Does `auto` really buy us anything here? Why not use use `const char*`? 



Comment at: clang/unittests/AST/ASTImporterTest.cpp:4034
+TEST_P(ImportFriendClasses, ImportOfRepeatedFriendDecl) {
+  auto Code =
+  R"(

a_sidorin wrote:
> clang-tidy wants this to be `const auto* Code`.
`const char*`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75740



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


[clang] e4dfc9f - Fix the type of the capture passed to LambdaIntroducer::addCapture in

2020-03-09 Thread Akira Hatanaka via cfe-commits

Author: Akira Hatanaka
Date: 2020-03-09T12:25:28-07:00
New Revision: e4dfc9f5bda3171e159f2ff62390c8795d9497e7

URL: 
https://github.com/llvm/llvm-project/commit/e4dfc9f5bda3171e159f2ff62390c8795d9497e7
DIFF: 
https://github.com/llvm/llvm-project/commit/e4dfc9f5bda3171e159f2ff62390c8795d9497e7.diff

LOG: Fix the type of the capture passed to LambdaIntroducer::addCapture in
RebuildLambdaScopeInfo

Previously the type of the variable was being passed, which was causing
clang to crash when a non-reference variable was captured by reference
or a reference variable was captured by value by a lambda and a block
nested inside the lambda body was referencing the variable.

Original patch by JF Bastien.

rdar://problem/47550338

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

Added: 


Modified: 
clang/lib/Sema/SemaDecl.cpp
clang/test/CodeGenObjCXX/block-nested-in-lambda.mm

Removed: 




diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index ffe620b122bd..66359f4faf6a 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -13738,13 +13738,12 @@ static void RebuildLambdaScopeInfo(CXXMethodDecl 
*CallOperator,
   VarDecl *VD = C.getCapturedVar();
   if (VD->isInitCapture())
 S.CurrentInstantiationScope->InstantiatedLocal(VD, VD);
-  QualType CaptureType = VD->getType();
   const bool ByRef = C.getCaptureKind() == LCK_ByRef;
   LSI->addCapture(VD, /*IsBlock*/false, ByRef,
   /*RefersToEnclosingVariableOrCapture*/true, C.getLocation(),
   /*EllipsisLoc*/C.isPackExpansion()
  ? C.getEllipsisLoc() : SourceLocation(),
-  CaptureType, /*Invalid*/false);
+  I->getType(), /*Invalid*/false);
 
 } else if (C.capturesThis()) {
   LSI->addThisCapture(/*Nested*/ false, C.getLocation(), I->getType(),

diff  --git a/clang/test/CodeGenObjCXX/block-nested-in-lambda.mm 
b/clang/test/CodeGenObjCXX/block-nested-in-lambda.mm
index be1ad8117cd2..c7b9a043a9e9 100644
--- a/clang/test/CodeGenObjCXX/block-nested-in-lambda.mm
+++ b/clang/test/CodeGenObjCXX/block-nested-in-lambda.mm
@@ -1,6 +1,9 @@
-// RUN: %clang_cc1 -triple=x86_64-apple-darwin10 -emit-llvm -std=c++11 
-fblocks -fobjc-arc -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple=x86_64-apple-darwin10 -emit-llvm -std=c++14 
-fblocks -fobjc-arc -o - %s | FileCheck %s
 
 // CHECK: %[[STRUCT_BLOCK_DESCRIPTOR:.*]] = type { i64, i64 }
+// CHECK: %[[S:.*]] = type { i32 }
+// CHECK: %[[CLASS_ANON_2:.*]] = type { %[[S]]* }
+// CHECK: %[[CLASS_ANON_3:.*]] = type { %[[S]] }
 
 // CHECK: %[[BLOCK_CAPTURED0:.*]] = getelementptr inbounds <{ i8*, i32, i32, 
i8*, %struct.__block_descriptor*, i32*, i32* }>, <{ i8*, i32, i32, i8*, 
%struct.__block_descriptor*, i32*, i32* }>* %[[BLOCK:.*]], i32 0, i32 5
 // CHECK: %[[V0:.*]] = getelementptr inbounds %[[LAMBDA_CLASS:.*]], 
%[[LAMBDA_CLASS]]* %[[THIS:.*]], i32 0, i32 0
@@ -33,7 +36,7 @@ void block_in_lambda(int , int ) {
 // reference.
 
 // CHECK-LABEL: define void @_ZN18CaptureByReference5test0Ev(
-// CHECK-LABEL: define internal void 
@"_ZZN18CaptureByReference5test0EvENK3$_1clEv"(
+// CHECK-LABEL: define internal void 
@"_ZZN18CaptureByReference5test0EvENK3$_3clEv"(
 // CHECK: %[[BLOCK_DESCRIPTOR:.*]] = getelementptr inbounds <{ i8*, i32, i32, 
i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8** }>, <{ i8*, i32, i32, i8*, 
%[[STRUCT_BLOCK_DESCRIPTOR]]*, i8** }>* %{{.*}}, i32 0, i32 4
 // CHECK: store %[[STRUCT_BLOCK_DESCRIPTOR]]* bitcast ({ i64, i64, i8*, i64 }* 
@"__block_descriptor_40_e5_v8\01?0ls32l8" to %[[STRUCT_BLOCK_DESCRIPTOR]]*), 
%[[STRUCT_BLOCK_DESCRIPTOR]]** %[[BLOCK_DESCRIPTOR]], align 8
 
@@ -46,10 +49,60 @@ void test0() {
 // is captured by reference.
 
 // CHECK-LABEL: define void @_ZN18CaptureByReference5test1Ev(
-// CHECK-LABEL: define internal void 
@"_ZZN18CaptureByReference5test1EvENK3$_2clEv"(
+// CHECK-LABEL: define internal void 
@"_ZZN18CaptureByReference5test1EvENK3$_4clEv"(
 // CHECK: %[[BLOCK_DESCRIPTOR:.*]] = getelementptr inbounds <{ i8*, i32, i32, 
i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8*, i8*, i8** }>, <{ i8*, i32, i32, i8*, 
%[[STRUCT_BLOCK_DESCRIPTOR]]*, i8*, i8*, i8** }>* %{{.*}}, i32 0, i32 4
 // CHECK: store %[[STRUCT_BLOCK_DESCRIPTOR]]* bitcast ({ i64, i64, i8*, i8*, 
i8*, i64 }* @"__block_descriptor_56_8_32s40s_e5_v8\01?0l" to 
%[[STRUCT_BLOCK_DESCRIPTOR]]*), %[[STRUCT_BLOCK_DESCRIPTOR]]** 
%[[BLOCK_DESCRIPTOR]], align 8
 
+void test1() {
+  id a = getObj(), b = getObj(), c = getObj();
+  [, b, c]{ ^{ a = 0; use(b); use(c); }(); }();
+}
+
+struct S {
+  int val() const;
+  int a;
+  S();
+  S(const S&);
+  S =(const S&);
+  S(S&&);
+  S =(S&&);
+};
+
+S getS();
+
+// CHECK: define internal i32 
@"_ZZN18CaptureByReference5test2EvENK3$_1clIiEEDaT_"(%[[CLASS_ANON_2]]* 
%{{.*}}, i32 %{{.*}})
+// CHECK: %[[BLOCK:.*]] = alloca <{ i8*, i32, i32, i8*, %{{.*}}, %[[S]]* }>, 
align 8
+// CHECK: 

[PATCH] D75806: [CUDA] Add CUDA 10.2 detection

2020-03-09 Thread Raul Tambre via Phabricator via cfe-commits
tambre added a comment.

Thanks for the context!

To avoid other people stepping into this trap, maybe it'd make sense to reword 
this warning to say "unsupported" instead of "unknown"?
Or maybe add detection for newer versions, but introduce a separate warning for 
unsupported versions?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75806



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


[PATCH] D74104: Remove test dependency on the presence of an assembler

2020-03-09 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Interesting, indeed, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74104



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


[PATCH] D75524: [www] cxx_status: Update Reflection TS to Cologne draft

2020-03-09 Thread Hubert Tong via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdfaafbab4687: [www] cxx_status: Update Reflection TS to 
Cologne draft (authored by hubert.reinterpretcast).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75524

Files:
  clang/www/cxx_status.html


Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1321,7 +1321,7 @@
 
 
   [DRAFT TS] Reflection
-  https://wg21.link/n4746;>N4746
+  https://wg21.link/n4818;>N4818
   
   No
 


Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1321,7 +1321,7 @@
 
 
   [DRAFT TS] Reflection
-  https://wg21.link/n4746;>N4746
+  https://wg21.link/n4818;>N4818
   
   No
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75523: [www] cxx_status: Update title to mention C++20

2020-03-09 Thread Hubert Tong via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf4076ad64075: [www] cxx_status: Update title to mention 
C++20 (authored by hubert.reinterpretcast).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75523

Files:
  clang/www/cxx_status.html


Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -2,7 +2,7 @@
 
 
   
-  Clang - C++17, C++14, C++11 and C++98 Status
+  Clang - C++20, C++17, C++14, C++11 and C++98 Status
   
   
   

[PATCH] D73513: [memtag] Plug in stack safety analysis.

2020-03-09 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis updated this revision to Diff 249175.
eugenis added a comment.
Herald added a subscriber: danielkiss.

+ a test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73513

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/Driver/memtag.c
  llvm/include/llvm/Analysis/StackSafetyAnalysis.h
  llvm/lib/Analysis/StackSafetyAnalysis.cpp
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Target/AArch64/AArch64StackTagging.cpp
  llvm/test/Analysis/StackSafetyAnalysis/ipa-attr.ll
  llvm/test/CodeGen/AArch64/stack-tagging.ll

Index: llvm/test/CodeGen/AArch64/stack-tagging.ll
===
--- llvm/test/CodeGen/AArch64/stack-tagging.ll
+++ llvm/test/CodeGen/AArch64/stack-tagging.ll
@@ -33,6 +33,7 @@
   %x1 = alloca i32, align 4
   %x2 = alloca i8, align 4
   %x3 = alloca i32, i32 11, align 4
+  %x4 = alloca i32, align 4, !stack-safe !0
   call void @use32(i32* %x1)
   call void @use8(i8* %x2)
   call void @use32(i32* %x3)
@@ -49,6 +50,9 @@
 ; CHECK:  alloca { [11 x i32], [4 x i8] }, align 16
 ; CHECK:  call { [11 x i32], [4 x i8] }* @llvm.aarch64.tagp.{{.*}}({ [11 x i32], [4 x i8] }* {{.*}}, i64 2)
 ; CHECK:  call void @llvm.aarch64.settag(i8* {{.*}}, i64 48)
+; CHECK:  alloca i32, align 4
+; CHECK-NOT: @llvm.aarch64.tagp
+; CHECK-NOT: @llvm.aarch64.settag
 
 ; CHECK:  call void @use32(
 ; CHECK:  call void @use8(
@@ -185,3 +189,5 @@
 ; CHECK: call void @llvm.aarch64.settag(
 ; CHECK: call void @llvm.aarch64.settag(
 ; CHECK: ret void
+
+!0 = !{}
\ No newline at end of file
Index: llvm/test/Analysis/StackSafetyAnalysis/ipa-attr.ll
===
--- /dev/null
+++ llvm/test/Analysis/StackSafetyAnalysis/ipa-attr.ll
@@ -0,0 +1,34 @@
+; RUN: llvm-as %s -o %t0.bc
+; RUN: llvm-as %S/Inputs/ipa.ll -o %t1.bc
+; RUN: llvm-link -disable-lazy-loading %t0.bc %t1.bc -o %t.combined.bc
+; RUN: opt -S -passes="stack-safety-annotator" %t.combined.bc -o - 2>&1 | FileCheck %s
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+declare void @Write1(i8* %p)
+declare void @Write8(i8* %p)
+
+; Basic out-of-bounds.
+define void @f1() {
+; CHECK-LABEL: define void @f1() {
+; CHECK: alloca i32, align 4{{$}}
+entry:
+  %x = alloca i32, align 4
+  %x1 = bitcast i32* %x to i8*
+  call void @Write8(i8* %x1)
+  ret void
+}
+
+; Basic in-bounds.
+define void @f2() {
+; CHECK-LABEL: define void @f2() {
+; CHECK: alloca i32, align 4, !stack-safe ![[A:[0-9]+]]{{$}}
+entry:
+  %x = alloca i32, align 4
+  %x1 = bitcast i32* %x to i8*
+  call void @Write1(i8* %x1)
+  ret void
+}
+
+; CHECK: ![[A]] = !{}
Index: llvm/lib/Target/AArch64/AArch64StackTagging.cpp
===
--- llvm/lib/Target/AArch64/AArch64StackTagging.cpp
+++ llvm/lib/Target/AArch64/AArch64StackTagging.cpp
@@ -400,7 +400,9 @@
   // dynamic alloca instrumentation for them as well.
   !AI.isUsedWithInAlloca() &&
   // swifterror allocas are register promoted by ISel
-  !AI.isSwiftError();
+  !AI.isSwiftError() &&
+  // safe allocas are not interesting
+  !AI.getMetadata("stack-safe");
   return IsInteresting;
 }
 
Index: llvm/lib/Passes/PassRegistry.def
===
--- llvm/lib/Passes/PassRegistry.def
+++ llvm/lib/Passes/PassRegistry.def
@@ -92,6 +92,7 @@
 MODULE_PASS("kasan-module", ModuleAddressSanitizerPass(/*CompileKernel=*/true, false, true, false))
 MODULE_PASS("sancov-module", ModuleSanitizerCoveragePass())
 MODULE_PASS("poison-checking", PoisonCheckingPass())
+MODULE_PASS("stack-safety-annotator", StackSafetyGlobalAnnotatorPass())
 #undef MODULE_PASS
 
 #ifndef CGSCC_ANALYSIS
Index: llvm/lib/Analysis/StackSafetyAnalysis.cpp
===
--- llvm/lib/Analysis/StackSafetyAnalysis.cpp
+++ llvm/lib/Analysis/StackSafetyAnalysis.cpp
@@ -99,11 +99,11 @@
 }
 
 struct AllocaInfo {
-  const AllocaInst *AI = nullptr;
+  AllocaInst *AI = nullptr;
   uint64_t Size = 0;
   UseInfo Use;
 
-  AllocaInfo(unsigned PointerSize, const AllocaInst *AI, uint64_t Size)
+  AllocaInfo(unsigned PointerSize, AllocaInst *AI, uint64_t Size)
   : AI(AI), Size(Size), Use(PointerSize) {}
 
   StringRef getName() const { return AI->getName(); }
@@ -205,7 +205,7 @@
 namespace {
 
 class StackSafetyLocalAnalysis {
-  const Function 
+  Function 
   const DataLayout 
   ScalarEvolution 
   unsigned PointerSize = 0;
@@ -227,7 +227,7 @@
   }
 
 public:
-  StackSafetyLocalAnalysis(const Function , ScalarEvolution )
+  StackSafetyLocalAnalysis(Function , ScalarEvolution )
   : F(F), DL(F.getParent()->getDataLayout()), SE(SE),
 PointerSize(DL.getPointerSizeInBits()),
 UnknownRange(PointerSize, true) {}
@@ -653,17 +653,47 @@
   return PreservedAnalyses::all();
 

[PATCH] D64464: [CodeGen] Emit destructor calls to destruct compound literals

2020-03-09 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak marked an inline comment as done.
ahatanak added inline comments.



Comment at: clang/lib/CodeGen/CGBlocks.cpp:869
+  if (auto *BD = C.dyn_cast())
+enterBlockScope(*this, BD);
   }

rjmccall wrote:
> I wonder if we could just switch blocks to the same thing.
I think we can, but I haven't tried. We can fix it in a separate patch.



Comment at: clang/lib/CodeGen/CGExprAgg.cpp:664
+  // Block-scope compound literals are destroyed at the end of the enclosing
+  // scope in C.
+  bool Destruct =

I fixed the way `IsExternallyDestructed` is used based on the comment in the 
other review.



Comment at: clang/lib/Serialization/ASTWriterStmt.cpp:1729
+  Record.push_back(serialization::COK_CompoundLiteral);
+  Record.AddStmt(CLE);
+}

rjmccall wrote:
> Will this just serialize a second copy of the compound literal expression?
This should emit a `serialization::STMT_REF_PTR` record, which is a reference 
to the previously serialized compound literal (see `ASTWriter::WriteSubStmt`).



Comment at: lib/CodeGen/CGExpr.cpp:4100
+  if (E->getType().isDestructedType() == QualType::DK_nontrivial_c_struct)
+pushDestroy(QualType::DK_nontrivial_c_struct, DeclPtr, E->getType());
+

rjmccall wrote:
> ahatanak wrote:
> > rjmccall wrote:
> > > ahatanak wrote:
> > > > rjmccall wrote:
> > > > > ahatanak wrote:
> > > > > > rjmccall wrote:
> > > > > > > rjmccall wrote:
> > > > > > > > Unfortunately, the lifetime of compound literals in C is not 
> > > > > > > > this simple; they're like blocks in that they're destroyed at 
> > > > > > > > the end of the enclosing scope rather than at the end of the 
> > > > > > > > current statement. (The cleanup here will be popped at the end 
> > > > > > > > of the full-expression if we've entered an `ExprWithCleanups`.) 
> > > > > > > > And the l-value case is exactly the case where this matters.
> > > > > > > > 
> > > > > > > > I think you need to do something like what we do with blocks, 
> > > > > > > > where we record all the blocks in the full-expression on the 
> > > > > > > > `ExprWithCleanups` so that we can push an inactive cleanup for 
> > > > > > > > them and then activate it when we emit the block.
> > > > > > > Can we make the check here something like (1) this is a 
> > > > > > > block-scope compound literal and (2) it has a 
> > > > > > > non-trivially-destructed type (of any kind)?  That way we're not 
> > > > > > > conflating two potentially unrelated elements, the lifetime of 
> > > > > > > the object and the kinds of types that can be constructed by the 
> > > > > > > literal.
> > > > > > > 
> > > > > > > Oh, actually, there's a concrete reason to do this: C99 compound 
> > > > > > > literals are not required to have struct type; they can have any 
> > > > > > > object type, including arrays but also scalars.  So we could, 
> > > > > > > even without non-trivial C structs, have a block-scope compound 
> > > > > > > of type `__strong id[]`; I guess we've always just gotten this 
> > > > > > > wrong.  Please add tests for this case. :)
> > > > > > There is a check `E->isFileScope()` above this. Is that sufficient 
> > > > > > to check for block-scoped compound literals?
> > > > > That plus the C/C++ difference; compound literals in C++ are just 
> > > > > temporaries.
> > > > I haven't been able to come up with a piece of C++ code that executes 
> > > > `EmitCompoundLiteralLValue`. The following code gets rejected because 
> > > > you can't take the address of a temporary object in C++:
> > > > 
> > > > ```
> > > > StrongSmall *p = &(StrongSmall){ 1, 0 };
> > > > ```
> > > > 
> > > > If a bind a reference to it, `AggExprEmitter::VisitCompoundLiteralExpr` 
> > > > is called.
> > > That makes sense; they're not gl-values in C++.  It would be reasonable 
> > > to assert that.  But the C++ point does apply elsewhere.
> > It turns out this function is called in C++ when the compound literal is a 
> > vector type, so I've just added a check for C++ instead of an assert.
> Really?  Is the expression actually an l-value in this case somehow?
I see this function being called when 
`ScalarExprEmitter::VisitCompoundLiteralExpr` calls `EmitLoadOfLValue`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64464



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


[PATCH] D64464: [CodeGen] Emit destructor calls to destruct compound literals

2020-03-09 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 249173.
ahatanak marked 4 inline comments as done.
ahatanak added a comment.

Address review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64464

Files:
  clang/include/clang/AST/ASTImporter.h
  clang/include/clang/AST/ExprCXX.h
  clang/include/clang/AST/TextNodeDumper.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/CodeGen/CGBlocks.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/Sema/JumpDiagnostics.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/AST/ast-dump-objc-arc-json.m
  clang/test/AST/ast-dump-stmt.m
  clang/test/CodeGenObjC/arc-ternary-op.m
  clang/test/CodeGenObjC/arc.m
  clang/test/CodeGenObjC/strong-in-c-struct.m
  clang/test/Import/objc-arc/Inputs/cleanup-objects.m
  clang/test/Import/objc-arc/test-cleanup-object.m
  clang/test/PCH/non-trivial-c-compound-literal.m
  clang/test/SemaObjC/strong-in-c-struct.m
  clang/tools/clang-import-test/clang-import-test.cpp

Index: clang/tools/clang-import-test/clang-import-test.cpp
===
--- clang/tools/clang-import-test/clang-import-test.cpp
+++ clang/tools/clang-import-test/clang-import-test.cpp
@@ -64,6 +64,10 @@
   llvm::cl::desc("The language to parse (default: c++)"),
   llvm::cl::init("c++"));
 
+static llvm::cl::opt
+ObjCARC("objc-arc", llvm::cl::init(false),
+llvm::cl::desc("Emable ObjC ARC"));
+
 static llvm::cl::opt DumpAST("dump-ast", llvm::cl::init(false),
llvm::cl::desc("Dump combined AST"));
 
@@ -183,6 +187,8 @@
   Inv->getLangOpts()->ObjC = 1;
 }
   }
+  Inv->getLangOpts()->ObjCAutoRefCount = ObjCARC;
+
   Inv->getLangOpts()->Bool = true;
   Inv->getLangOpts()->WChar = true;
   Inv->getLangOpts()->Blocks = true;
Index: clang/test/SemaObjC/strong-in-c-struct.m
===
--- clang/test/SemaObjC/strong-in-c-struct.m
+++ clang/test/SemaObjC/strong-in-c-struct.m
@@ -54,3 +54,21 @@
   func(^{ func2(x); });
   goto *ips; // expected-error {{cannot jump}}
 }
+
+void test_compound_literal0(int cond, id x) {
+  switch (cond) {
+  case 0:
+(void)(Strong){ .a = x }; // expected-note {{jump enters lifetime of a compound literal that is non-trivial to destruct}}
+break;
+  default: // expected-error {{cannot jump from switch statement to this case label}}
+break;
+  }
+}
+
+void test_compound_literal1(id x) {
+  static void *ips[] = { & };
+L0:  // expected-note {{possible target of indirect goto}}
+  ;
+  (void)(Strong){ .a = x }; // expected-note {{jump exits lifetime of a compound literal that is non-trivial to destruct}}
+  goto *ips; // expected-error {{cannot jump}}
+}
Index: clang/test/PCH/non-trivial-c-compound-literal.m
===
--- /dev/null
+++ clang/test/PCH/non-trivial-c-compound-literal.m
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -x objective-c -fobjc-arc -emit-pch -o %t %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -x objective-c -fobjc-arc -include-pch %t -emit-llvm -o - %s | FileCheck %s
+
+#ifndef HEADER
+#define HEADER
+
+typedef struct {
+  id f;
+} S;
+
+static inline id getObj(id a) {
+  S *p = &(S){ .f = a };
+  return p->f;
+}
+
+#else
+
+// CHECK: %[[STRUCT_S:.*]] = type { i8* }
+
+// CHECK: define internal i8* @getObj(
+// CHECK: %[[_COMPOUNDLITERAL:.*]] = alloca %[[STRUCT_S]],
+// CHECK: %[[V5:.*]] = bitcast %[[STRUCT_S]]* %[[_COMPOUNDLITERAL]] to i8**
+// CHECK: call void @__destructor_8_s0(i8** %[[V5]])
+
+id test(id a) {
+  return getObj(a);
+}
+
+#endif
Index: clang/test/Import/objc-arc/test-cleanup-object.m
===
--- /dev/null
+++ clang/test/Import/objc-arc/test-cleanup-object.m
@@ -0,0 +1,10 @@
+// RUN: clang-import-test -x objective-c -objc-arc -import %S/Inputs/cleanup-objects.m -dump-ast -expression %s | FileCheck %s
+
+// CHECK: FunctionDecl {{.*}} getObj '
+// CHECK: ExprWithCleanups
+// CHECK-NEXT: cleanup CompoundLiteralExpr
+
+void test(int c, id a) {
+  (void)getObj(c, a);
+}
+
Index: clang/test/Import/objc-arc/Inputs/cleanup-objects.m
===
--- /dev/null
+++ clang/test/Import/objc-arc/Inputs/cleanup-objects.m
@@ -0,0 +1,10 @@
+typedef struct {
+  id x;
+} S;
+
+id getObj(int c, id a) {
+  // Commenting out the following line because AST importer crashes when trying
+  // to import a BlockExpr.
+  // return c ? ^{ return a; }() : ((S){ .x = a }).x;

[clang] f4076ad - [www] cxx_status: Update title to mention C++20

2020-03-09 Thread Hubert Tong via cfe-commits

Author: Hubert Tong
Date: 2020-03-09T14:51:11-04:00
New Revision: f4076ad6407594c0abedb4ff61f73abecce394f7

URL: 
https://github.com/llvm/llvm-project/commit/f4076ad6407594c0abedb4ff61f73abecce394f7
DIFF: 
https://github.com/llvm/llvm-project/commit/f4076ad6407594c0abedb4ff61f73abecce394f7.diff

LOG: [www] cxx_status: Update title to mention C++20

Summary:
The document covers the Clang implementation status of the "upcoming
C++20 standard". Update the title to match.

Reviewers: rsmith, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/www/cxx_status.html

Removed: 




diff  --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html
index 9e8322aaf281..4f479792264c 100755
--- a/clang/www/cxx_status.html
+++ b/clang/www/cxx_status.html
@@ -2,7 +2,7 @@
 
 
   
-  Clang - C++17, C++14, C++11 and C++98 Status
+  Clang - C++20, C++17, C++14, C++11 and C++98 Status
   
   
   

[clang] dfaafba - [www] cxx_status: Update Reflection TS to Cologne draft

2020-03-09 Thread Hubert Tong via cfe-commits

Author: Hubert Tong
Date: 2020-03-09T14:51:11-04:00
New Revision: dfaafbab4687676f8ad616a79d3d924267831cbd

URL: 
https://github.com/llvm/llvm-project/commit/dfaafbab4687676f8ad616a79d3d924267831cbd
DIFF: 
https://github.com/llvm/llvm-project/commit/dfaafbab4687676f8ad616a79d3d924267831cbd.diff

LOG: [www] cxx_status: Update Reflection TS to Cologne draft

Summary:
As of the 2019 Cologne meeting, according to its minutes (N4826), N4818
is the draft of the Reflection TS.

Reviewers: rsmith, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/www/cxx_status.html

Removed: 




diff  --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html
index 4f479792264c..39ada7f26a18 100755
--- a/clang/www/cxx_status.html
+++ b/clang/www/cxx_status.html
@@ -1321,7 +1321,7 @@ Technical specifications and standing 
documents
 
 
   [DRAFT TS] Reflection
-  https://wg21.link/n4746;>N4746
+  https://wg21.link/n4818;>N4818
   
   No
 



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


[PATCH] D75747: [clang-format] Correct indentation for `[key] = value,` entries in C++ object initialisers

2020-03-09 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcb3f20d27c9e: [clang-format] Correct indentation for `[key] 
= value,` entries in C++ object… (authored by Jonathan Coe 
jb...@google.com).

Changed prior to commit:
  https://reviews.llvm.org/D75747?vs=249155=249172#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75747

Files:
  clang/lib/Format/ContinuationIndenter.cpp
  clang/unittests/Format/FormatTestCSharp.cpp


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -551,6 +551,15 @@
   Scaler = (Shape shape) => { return new Transform.Resize(shape, 0.1); },
 };)",
Style);
+
+  // Dictionary initialisation.
+  verifyFormat(R"(//
+var myDict = new Dictionary {
+  ["name"] = _donald,
+  ["age"] = Convert.ToString(DateTime.Today.Year - 1934),
+  ["type"] = _duck,
+};)",
+   Style);
 }
 
 TEST_F(FormatTestCSharp, CSharpNamedArguments) {
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -1047,6 +1047,9 @@
   if (NextNonComment->is(TT_ArraySubscriptLSquare)) {
 if (State.Stack.back().StartOfArraySubscripts != 0)
   return State.Stack.back().StartOfArraySubscripts;
+else if (Style.isCSharp()) // C# allows `["key"] = value` inside object
+   // initializers.
+  return State.Stack.back().Indent;
 return ContinuationIndent;
   }
 


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -551,6 +551,15 @@
   Scaler = (Shape shape) => { return new Transform.Resize(shape, 0.1); },
 };)",
Style);
+
+  // Dictionary initialisation.
+  verifyFormat(R"(//
+var myDict = new Dictionary {
+  ["name"] = _donald,
+  ["age"] = Convert.ToString(DateTime.Today.Year - 1934),
+  ["type"] = _duck,
+};)",
+   Style);
 }
 
 TEST_F(FormatTestCSharp, CSharpNamedArguments) {
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -1047,6 +1047,9 @@
   if (NextNonComment->is(TT_ArraySubscriptLSquare)) {
 if (State.Stack.back().StartOfArraySubscripts != 0)
   return State.Stack.back().StartOfArraySubscripts;
+else if (Style.isCSharp()) // C# allows `["key"] = value` inside object
+   // initializers.
+  return State.Stack.back().Indent;
 return ContinuationIndent;
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74669: [clang-tidy] New check: bugprone-suspicious-include

2020-03-09 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs updated this revision to Diff 249164.
jroelofs added a comment.

Fix comment, add docs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74669

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.h
  clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
  clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
  clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-include.rst
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/a
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/a.cpp
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/a.hpp
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/c.c
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/c.cc
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/c.cxx
  clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp
@@ -0,0 +1,23 @@
+// RUN: %check_clang_tidy %s bugprone-suspicious-include %t -- -- -isystem %S/Inputs/Headers -fmodules
+
+// clang-format off
+
+// CHECK-MESSAGES: [[@LINE+4]]:11: warning: suspicious #include of file with '.cpp' extension
+// CHECK-MESSAGES: [[@LINE+3]]:11: note: did you mean to include 'a'?
+// CHECK-MESSAGES: [[@LINE+2]]:11: note: did you mean to include 'a.h'?
+// CHECK-MESSAGES: [[@LINE+1]]:11: note: did you mean to include 'a.hpp'?
+#include "a.cpp"
+
+#include "b.h"
+
+// CHECK-MESSAGES: [[@LINE+1]]:10: warning: suspicious #import of file with '.c' extension
+#import "c.c"
+
+// CHECK-MESSAGES: [[@LINE+1]]:16: warning: suspicious #include_next of file with '.c' extension
+#include_next 
+
+// CHECK-MESSAGES: [[@LINE+1]]:13: warning: suspicious #include of file with '.cc' extension
+# include  
+
+// CHECK-MESSAGES: [[@LINE+1]]:14: warning: suspicious #include of file with '.cxx' extension
+#  include  
Index: clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-include.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-include.rst
@@ -0,0 +1,33 @@
+.. title:: clang-tidy - bugprone-suspicious-include
+
+bugprone-suspicious-include
+===
+
+The checker detects various cases when an include refers to what appears to be
+an implementation file, which often leads to hard-to-track-down ODR violations.
+
+Examples:
+
+.. code-block:: c++
+
+  #include "Dinosaur.hpp" // OK, .hpp files tend not to have definitions.
+  #include "Pterodactyl.h"// OK, .h files tend not to have definitions.
+  #include "Velociraptor.cpp" // Warning, filename is suspicious
+  #import "Stegosaurus.c" // Warning, fliename is suspicious
+  #include_next  // Warning, filename is suspicious
+
+Options
+---
+.. option:: HeaderFileExtensions
+
+   Default value: ";h;hh;hpp;hxx"
+   A semicolon-separated list of filename extensions of header files (The
+   filename extensions should not contain "." prefix). For extension-less
+   header files, using an empty string or leaving an empty string between ";"
+   if there are other filename extensions.
+
+.. option:: HeaderFileExtensions
+
+   Default value: "c;cc;cpp;cxx"
+   Likewise, a semicolon-separated list of filename extensions of
+   implementation files.
Index: clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
===
--- clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
+++ clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
@@ -11,6 +11,7 @@
 
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/StringRef.h"
 
@@ -36,6 +37,12 @@
 /// extensions.
 inline StringRef defaultHeaderFileExtensions() { return ";h;hh;hpp;hxx"; }
 
+/// Returns recommended default value for the list of implementaiton file
+/// extensions.
+inline StringRef defaultImplementationFileExtensions() {
+  return "c;cc;cpp;cxx";
+}
+
 /// Returns recommended default value for the list of file extension
 /// delimiters.
 inline StringRef defaultFileExtensionDelimiters() { return ",;"; }
@@ -45,6 +52,11 @@
  FileExtensionsSet ,
  StringRef Delimiters);
 
+/// Decides whether a file has a header file extension.
+/// Returns the file extension, if included in the provided set.
+llvm::Optional
+getFileExtension(StringRef FileName, const 

[PATCH] D74669: [clang-tidy] New check: bugprone-suspicious-include

2020-03-09 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs marked 3 inline comments as done.
jroelofs added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h:9
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_HEADER_FILE_EXTENSIONS_UTILS_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_HEADER_FILE_EXTENSIONS_UTILS_H

aaron.ballman wrote:
> Can drop the `HEADER` from these macros.
Missed this one before. Oops.
https://github.com/llvm/llvm-project/commit/c71ef7a85d2447903ff9240aff649a57d70b050d


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74669



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


[PATCH] D75747: [clang-format] Correct indentation for `[key] = value,` entries in C++ object initialisers

2020-03-09 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir accepted this revision.
krasimir added a comment.
This revision is now accepted and ready to land.

Thank you!


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

https://reviews.llvm.org/D75747



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


[clang-tools-extra] c71ef7a - Drop HEADER_ per review feedback on D74669

2020-03-09 Thread Jonathan Roelofs via cfe-commits

Author: Jonathan Roelofs
Date: 2020-03-09T12:14:22-06:00
New Revision: c71ef7a85d2447903ff9240aff649a57d70b050d

URL: 
https://github.com/llvm/llvm-project/commit/c71ef7a85d2447903ff9240aff649a57d70b050d
DIFF: 
https://github.com/llvm/llvm-project/commit/c71ef7a85d2447903ff9240aff649a57d70b050d.diff

LOG: Drop HEADER_ per review feedback on D74669

Added: 


Modified: 
clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h 
b/clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
index 4b7810430427..43fc573aad65 100644
--- a/clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
+++ b/clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
@@ -6,8 +6,8 @@
 //
 
//===--===//
 
-#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_HEADER_FILE_EXTENSIONS_UTILS_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_HEADER_FILE_EXTENSIONS_UTILS_H
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_FILE_EXTENSIONS_UTILS_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_FILE_EXTENSIONS_UTILS_H
 
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
@@ -53,4 +53,4 @@ bool isFileExtension(StringRef FileName,
 } // namespace tidy
 } // namespace clang
 
-#endif // 
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_HEADER_FILE_EXTENSIONS_UTILS_H
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_FILE_EXTENSIONS_UTILS_H



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


[clang] cb3f20d - [clang-format] Correct indentation for `[key] = value,` entries in C++ object initialisers

2020-03-09 Thread Jonathan Coe via cfe-commits

Author: Jonathan Coe
Date: 2020-03-09T18:04:34Z
New Revision: cb3f20d27c9e91cb9f997f0401f388e62c4ba993

URL: 
https://github.com/llvm/llvm-project/commit/cb3f20d27c9e91cb9f997f0401f388e62c4ba993
DIFF: 
https://github.com/llvm/llvm-project/commit/cb3f20d27c9e91cb9f997f0401f388e62c4ba993.diff

LOG: [clang-format] Correct indentation for `[key] = value,` entries in C++ 
object initialisers

Summary: Do not use continuation indent for '[' in blocks in C# code.

Reviewers: krasimir

Reviewed By: krasimir

Subscribers: cfe-commits

Tags: #clang-format, #clang

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

Added: 


Modified: 
clang/lib/Format/ContinuationIndenter.cpp
clang/unittests/Format/FormatTestCSharp.cpp

Removed: 




diff  --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index a08f5a3df864..9a6d7877efaa 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -1047,6 +1047,9 @@ unsigned ContinuationIndenter::getNewLineColumn(const 
LineState ) {
   if (NextNonComment->is(TT_ArraySubscriptLSquare)) {
 if (State.Stack.back().StartOfArraySubscripts != 0)
   return State.Stack.back().StartOfArraySubscripts;
+else if (Style.isCSharp()) // C# allows `["key"] = value` inside object
+   // initializers.
+  return State.Stack.back().Indent;
 return ContinuationIndent;
   }
 

diff  --git a/clang/unittests/Format/FormatTestCSharp.cpp 
b/clang/unittests/Format/FormatTestCSharp.cpp
index a22f48676065..7f819a61c70e 100644
--- a/clang/unittests/Format/FormatTestCSharp.cpp
+++ b/clang/unittests/Format/FormatTestCSharp.cpp
@@ -549,6 +549,15 @@ Shape[] shapes = new[] { new Circle { Radius = 2.7281, 
Colour = Colours.Red },
 private Transformer _transformer = new X.Y {
   Filler = (Shape shape) => { return new Transform.Fill(shape, RED); },
   Scaler = (Shape shape) => { return new Transform.Resize(shape, 0.1); },
+};)",
+   Style);
+
+  // Dictionary initialisation.
+  verifyFormat(R"(//
+var myDict = new Dictionary {
+  ["name"] = _donald,
+  ["age"] = Convert.ToString(DateTime.Today.Year - 1934),
+  ["type"] = _duck,
 };)",
Style);
 }



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


[clang] 90e791d - Add test missed in r843a9778fcd5

2020-03-09 Thread Erich Keane via cfe-commits

Author: Jeremy Stenglein
Date: 2020-03-09T10:54:56-07:00
New Revision: 90e791d732dfb0e0ab8af13e49aa5f92aa4f349d

URL: 
https://github.com/llvm/llvm-project/commit/90e791d732dfb0e0ab8af13e49aa5f92aa4f349d
DIFF: 
https://github.com/llvm/llvm-project/commit/90e791d732dfb0e0ab8af13e49aa5f92aa4f349d.diff

LOG: Add test missed in r843a9778fcd5

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

Added: 
clang/test/Sema/builtin-returnaddress.c

Modified: 


Removed: 




diff  --git a/clang/test/Sema/builtin-returnaddress.c 
b/clang/test/Sema/builtin-returnaddress.c
new file mode 100644
index ..3ebbdc6048d8
--- /dev/null
+++ b/clang/test/Sema/builtin-returnaddress.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -Wframe-address -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wmost -verify %s
+
+void* a(unsigned x) {
+return __builtin_return_address(0);
+}
+
+void* b(unsigned x) {
+return __builtin_return_address(1); // expected-warning{{calling 
'__builtin_return_address' with a nonzero argument is unsafe}}
+}
+
+void* c(unsigned x) {
+return __builtin_frame_address(0);
+}
+
+void* d(unsigned x) {
+return __builtin_frame_address(1); // expected-warning{{calling 
'__builtin_frame_address' with a nonzero argument is unsafe}}
+}
+



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


[PATCH] D75768: Add a warning for builtin_return_address/frame_address with > 0 argument

2020-03-09 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG843a9778fcd5: Add a warning for 
builtin_return_address/frame_address with  0 argument (authored by 
jstenglein, committed by erichkeane).

Changed prior to commit:
  https://reviews.llvm.org/D75768?vs=248809=249161#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75768

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Misc/warning-wall.c


Index: clang/test/Misc/warning-wall.c
===
--- clang/test/Misc/warning-wall.c
+++ clang/test/Misc/warning-wall.c
@@ -16,6 +16,7 @@
 CHECK-NEXT:  -Wformat-y2k
 CHECK-NEXT:  -Wformat-invalid-specifier
 CHECK-NEXT:-Wfor-loop-analysis
+CHECK-NEXT:-Wframe-address
 CHECK-NEXT:-Wimplicit
 CHECK-NEXT:  -Wimplicit-function-declaration
 CHECK-NEXT:  -Wimplicit-int
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -1853,6 +1853,17 @@
   case Builtin::BI__builtin_return_address:
 if (SemaBuiltinConstantArgRange(TheCall, 0, 0, 0x))
   return ExprError();
+
+// -Wframe-address warning if non-zero passed to builtin
+// return/frame address.
+Expr::EvalResult Result;
+if (TheCall->getArg(0)->EvaluateAsInt(Result, getASTContext()) &&
+Result.Val.getInt() != 0)
+  Diag(TheCall->getBeginLoc(), diag::warn_frame_address)
+  << ((BuiltinID == Builtin::BI__builtin_return_address)
+  ? "__builtin_return_address"
+  : "__builtin_frame_address")
+  << TheCall->getSourceRange();
 break;
   }
 
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1780,6 +1780,11 @@
 def err_illegal_union_or_anon_struct_member : Error<
   "%select{anonymous struct|union}0 member %1 has a non-trivial "
   "%sub{select_special_member_kind}2">;
+
+def warn_frame_address : Warning<
+  "calling '%0' with a nonzero argument is unsafe">,
+  InGroup, DefaultIgnore;
+
 def warn_cxx98_compat_nontrivial_union_or_anon_struct_member : Warning<
   "%select{anonymous struct|union}0 member %1 with a non-trivial "
   "%sub{select_special_member_kind}2 is incompatible with C++98">,
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -99,6 +99,7 @@
   DiagGroup<"float-conversion", [FloatOverflowConversion,
  FloatZeroConversion]>;
 
+def FrameAddress : DiagGroup<"frame-address">;
 def DoublePromotion : DiagGroup<"double-promotion">;
 def EnumTooLarge : DiagGroup<"enum-too-large">;
 def UnsupportedNan : DiagGroup<"unsupported-nan">;
@@ -872,6 +873,7 @@
 DeleteNonVirtualDtor,
 Format,
 ForLoopAnalysis,
+FrameAddress,
 Implicit,
 InfiniteRecursion,
 IntInBoolContext,


Index: clang/test/Misc/warning-wall.c
===
--- clang/test/Misc/warning-wall.c
+++ clang/test/Misc/warning-wall.c
@@ -16,6 +16,7 @@
 CHECK-NEXT:  -Wformat-y2k
 CHECK-NEXT:  -Wformat-invalid-specifier
 CHECK-NEXT:-Wfor-loop-analysis
+CHECK-NEXT:-Wframe-address
 CHECK-NEXT:-Wimplicit
 CHECK-NEXT:  -Wimplicit-function-declaration
 CHECK-NEXT:  -Wimplicit-int
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -1853,6 +1853,17 @@
   case Builtin::BI__builtin_return_address:
 if (SemaBuiltinConstantArgRange(TheCall, 0, 0, 0x))
   return ExprError();
+
+// -Wframe-address warning if non-zero passed to builtin
+// return/frame address.
+Expr::EvalResult Result;
+if (TheCall->getArg(0)->EvaluateAsInt(Result, getASTContext()) &&
+Result.Val.getInt() != 0)
+  Diag(TheCall->getBeginLoc(), diag::warn_frame_address)
+  << ((BuiltinID == Builtin::BI__builtin_return_address)
+  ? "__builtin_return_address"
+  : "__builtin_frame_address")
+  << TheCall->getSourceRange();
 break;
   }
 
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1780,6 +1780,11 @@
 def err_illegal_union_or_anon_struct_member : Error<
  

[PATCH] D75731: [clang-format] C# does not indent braced initializers as continuations

2020-03-09 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGeb682b80274d: [clang-format] C# does not indent braced 
initializers as continuations (authored by Jonathan Coe 
jb...@google.com).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75731

Files:
  clang/lib/Format/FormatToken.h
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTestCSharp.cpp


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -527,31 +527,28 @@
 
   verifyFormat(R"(//
 Shape[] shapes = new[] {
-new Circle {
-Radius = 2.7281,
-Colour = Colours.Red,
-},
-new Square {
-Side = 101.1,
-Colour = Colours.Yellow,
-},
+  new Circle {
+Radius = 2.7281,
+Colour = Colours.Red,
+  },
+  new Square {
+Side = 101.1,
+Colour = Colours.Yellow,
+  },
 };)",
Style);
 
   // Omitted final `,`s will change the formatting.
   verifyFormat(R"(//
 Shape[] shapes = new[] { new Circle { Radius = 2.7281, Colour = Colours.Red },
- new Square {
- Side = 101.1,
- Colour = Colours.Yellow,
- } };)",
+ new Square { Side = 101.1, Colour = Colours.Yellow } 
};)",
Style);
 
   // Lambdas can be supplied as initialiser arguments.
   verifyFormat(R"(//
 private Transformer _transformer = new X.Y {
-Filler = (Shape shape) => { return new Transform.Fill(shape, RED); },
-Scaler = (Shape shape) => { return new Transform.Resize(shape, 0.1); },
+  Filler = (Shape shape) => { return new Transform.Fill(shape, RED); },
+  Scaler = (Shape shape) => { return new Transform.Resize(shape, 0.1); },
 };)",
Style);
 }
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1677,7 +1677,10 @@
   }
   break;
 case tok::l_square:
-  tryToParseLambda();
+  if (Style.isCSharp())
+parseSquare();
+  else
+tryToParseLambda();
   break;
 case tok::l_paren:
   parseParens();
Index: clang/lib/Format/FormatToken.h
===
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -509,6 +509,9 @@
   /// Returns \c true if this tokens starts a block-type list, i.e. a
   /// list that should be indented with a block indent.
   bool opensBlockOrBlockTypeList(const FormatStyle ) const {
+// C# Does not indent object initialisers as continuations.
+if (is(tok::l_brace) && BlockKind == BK_BracedInit && Style.isCSharp())
+  return true;
 if (is(TT_TemplateString) && opensScope())
   return true;
 return is(TT_ArrayInitializerLSquare) || is(TT_ProtoExtensionLSquare) ||


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -527,31 +527,28 @@
 
   verifyFormat(R"(//
 Shape[] shapes = new[] {
-new Circle {
-Radius = 2.7281,
-Colour = Colours.Red,
-},
-new Square {
-Side = 101.1,
-Colour = Colours.Yellow,
-},
+  new Circle {
+Radius = 2.7281,
+Colour = Colours.Red,
+  },
+  new Square {
+Side = 101.1,
+Colour = Colours.Yellow,
+  },
 };)",
Style);
 
   // Omitted final `,`s will change the formatting.
   verifyFormat(R"(//
 Shape[] shapes = new[] { new Circle { Radius = 2.7281, Colour = Colours.Red },
- new Square {
- Side = 101.1,
- Colour = Colours.Yellow,
- } };)",
+ new Square { Side = 101.1, Colour = Colours.Yellow } };)",
Style);
 
   // Lambdas can be supplied as initialiser arguments.
   verifyFormat(R"(//
 private Transformer _transformer = new X.Y {
-Filler = (Shape shape) => { return new Transform.Fill(shape, RED); },
-Scaler = (Shape shape) => { return new Transform.Resize(shape, 0.1); },
+  Filler = (Shape shape) => { return new Transform.Fill(shape, RED); },
+  Scaler = (Shape shape) => { return new Transform.Resize(shape, 0.1); },
 };)",
Style);
 }
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1677,7 +1677,10 @@
   }
   break;
 case tok::l_square:
-  

[PATCH] D14411: Use __attribute__((internal_linkage)) when available.

2020-03-09 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

I think this should be closed since the work we did on `internal_linkage` in 
2018. @eugenis


Repository:
  rL LLVM

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

https://reviews.llvm.org/D14411



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


[PATCH] D75856: [clang-format] cleanup from D75517

2020-03-09 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb28ed9cec8dd: [clang-format] cleanup from D75517 (authored 
by Jonathan Coe jb...@google.com).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75856

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


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -650,8 +650,15 @@
   FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
 
   // Do not format array subscript operators as attributes.
-  verifyFormat(R"(if (someThings[index].Contains(myThing)) {)", Style);
-  verifyFormat(R"(if (someThings[i][j][k].Contains(myThing)) {)", Style);
+  verifyFormat(R"(//
+if (someThings[index].Contains(myThing)) {
+})",
+   Style);
+
+  verifyFormat(R"(//
+if (someThings[i][j][k].Contains(myThing)) {
+})",
+   Style);
 }
 
 } // namespace format
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -373,7 +373,7 @@
 if (Tok.Previous && Tok.Previous->is(tok::identifier))
   return false;
 
-// Chains [] in of `identifier[i][j][k]` are not attributes.
+// Chains of [] in `identifier[i][j][k]` are not attributes.
 if (Tok.Previous && Tok.Previous->is(tok::r_square)) {
   auto *MatchingParen = Tok.Previous->MatchingParen;
   if (!MatchingParen || MatchingParen->is(TT_ArraySubscriptLSquare))


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -650,8 +650,15 @@
   FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
 
   // Do not format array subscript operators as attributes.
-  verifyFormat(R"(if (someThings[index].Contains(myThing)) {)", Style);
-  verifyFormat(R"(if (someThings[i][j][k].Contains(myThing)) {)", Style);
+  verifyFormat(R"(//
+if (someThings[index].Contains(myThing)) {
+})",
+   Style);
+
+  verifyFormat(R"(//
+if (someThings[i][j][k].Contains(myThing)) {
+})",
+   Style);
 }
 
 } // namespace format
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -373,7 +373,7 @@
 if (Tok.Previous && Tok.Previous->is(tok::identifier))
   return false;
 
-// Chains [] in of `identifier[i][j][k]` are not attributes.
+// Chains of [] in `identifier[i][j][k]` are not attributes.
 if (Tok.Previous && Tok.Previous->is(tok::r_square)) {
   auto *MatchingParen = Tok.Previous->MatchingParen;
   if (!MatchingParen || MatchingParen->is(TT_ArraySubscriptLSquare))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75489: [clang-tidy] Generalize HeaderFileExtensions.{h, cpp}. NFC

2020-03-09 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs closed this revision.
jroelofs added a comment.

https://github.com/llvm/llvm-project/commit/3486cc014b208df3897cf5656db0d0fdeae26d6b


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75489



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


[PATCH] D51762: First part of the calendar stuff

2020-03-09 Thread Louis Dionne via Phabricator via cfe-commits
ldionne closed this revision.
ldionne added a comment.

Like I said, this was committed in 5b08c1742a536f54bd5e270b00ff851cbc7314ef


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

https://reviews.llvm.org/D51762



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


[PATCH] D71018: [ASTImporter] Improved import of TypeSourceInfo (TypeLoc)

2020-03-09 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik accepted this revision.
shafik added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71018



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


[PATCH] D75747: [clang-format] Correct indentation for `[key] = value,` entries in C++ object initialisers

2020-03-09 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe updated this revision to Diff 249155.
jbcoe added a comment.

Format code.


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

https://reviews.llvm.org/D75747

Files:
  clang/lib/Format/ContinuationIndenter.cpp
  clang/unittests/Format/FormatTestCSharp.cpp


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -549,6 +549,15 @@
 private Transformer _transformer = new X.Y {
   Filler = (Shape shape) => { return new Transform.Fill(shape, RED); },
   Scaler = (Shape shape) => { return new Transform.Resize(shape, 0.1); },
+};)",
+   Style);
+
+  // Dictionary initialisation.
+  verifyFormat(R"(//
+var myDict = new Dictionary {
+  ["name"] = _donald,
+  ["age"] = Convert.ToString(DateTime.Today.Year - 1934),
+  ["type"] = _duck,
 };)",
Style);
 }
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -1047,6 +1047,9 @@
   if (NextNonComment->is(TT_ArraySubscriptLSquare)) {
 if (State.Stack.back().StartOfArraySubscripts != 0)
   return State.Stack.back().StartOfArraySubscripts;
+else if (Style.isCSharp()) // C# allows `["key"] = value` inside object
+   // initializers.
+  return State.Stack.back().Indent;
 return ContinuationIndent;
   }
 


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -549,6 +549,15 @@
 private Transformer _transformer = new X.Y {
   Filler = (Shape shape) => { return new Transform.Fill(shape, RED); },
   Scaler = (Shape shape) => { return new Transform.Resize(shape, 0.1); },
+};)",
+   Style);
+
+  // Dictionary initialisation.
+  verifyFormat(R"(//
+var myDict = new Dictionary {
+  ["name"] = _donald,
+  ["age"] = Convert.ToString(DateTime.Today.Year - 1934),
+  ["type"] = _duck,
 };)",
Style);
 }
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -1047,6 +1047,9 @@
   if (NextNonComment->is(TT_ArraySubscriptLSquare)) {
 if (State.Stack.back().StartOfArraySubscripts != 0)
   return State.Stack.back().StartOfArraySubscripts;
+else if (Style.isCSharp()) // C# allows `["key"] = value` inside object
+   // initializers.
+  return State.Stack.back().Indent;
 return ContinuationIndent;
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75621: [clang-tidy] Use ; as separator for HeaderFileExtensions

2020-03-09 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs closed this revision.
jroelofs added a comment.

https://github.com/llvm/llvm-project/commit/47caa69120e582bf1b795ec646f069c83b0e9456


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75621



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


[PATCH] D75529: [analyzer] Limit UCharMax to min of max uchar or max int

2020-03-09 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso accepted this revision.
Charusso added a comment.

In D75529#1912849 , @vabridgers wrote:

> @Charusso, I cannot find a way to create a test for this change, since this 
> was found using an architecture that supports 16-bit chars.


I really felt that we could write a test that using a target which behaves like 
that. I am not that awesome with triples, sorry. If I am right we are good to 
go without @NoQ's response (he is the maintainer of the Analyzer). Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75529



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


[PATCH] D75731: [clang-format] C# does not indent braced initializers as continuations

2020-03-09 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir accepted this revision.
krasimir added a comment.
This revision is now accepted and ready to land.

Thank you


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

https://reviews.llvm.org/D75731



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


[PATCH] D75643: [Sema] Don't emit pointer to int cast warnings under -Wmicrosoft-cast

2020-03-09 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I think I patched this in, ran tests, but didn't push. Feel free to push if you 
get the chance.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75643



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


[PATCH] D75760: [clang-format] Do not indent C# array initialisers as continuations

2020-03-09 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir requested changes to this revision.
krasimir added inline comments.
This revision now requires changes to proceed.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:1443
+if (Style.isCSharp())
+  FormatTok->BlockKind = BK_BracedInit;
 nextToken();

A more general approach might be to adapt parseBracedList() itself to mark the 
block kind `BK_BracedInit`:
https://github.com/llvm/llvm-project/blob/7d2fdd3f6639731284dd8b6b274f01f04fd19215/clang/lib/Format/UnwrappedLineParser.cpp#L1628

Could you try to see if it will be easy/possible to get the same effect by 
adapting that?
If that's hard or has unintended side effects, we can reconsider.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75760



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


[clang] 843a977 - Add a warning for builtin_return_address/frame_address with > 0 argument

2020-03-09 Thread Erich Keane via cfe-commits

Author: Jeremy Stenglein
Date: 2020-03-09T10:43:09-07:00
New Revision: 843a9778fcd5ef93804fc22de04af9ab8c8b20a9

URL: 
https://github.com/llvm/llvm-project/commit/843a9778fcd5ef93804fc22de04af9ab8c8b20a9
DIFF: 
https://github.com/llvm/llvm-project/commit/843a9778fcd5ef93804fc22de04af9ab8c8b20a9.diff

LOG: Add a warning for builtin_return_address/frame_address with > 0 argument

Clang is missing a warning for
builtin_return_address/builtin_frame_address called with > 0 argument.
Gcc provides a warning for this via -Wframe-address:

https://gcc.gnu.org/onlinedocs/gcc/Return-Address.html

As calling these functions with argument > 0 has caused several crashes
for us, we would like to have the same warning as gcc here. This diff
adds the warning and makes it part of -Wmost.

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaChecking.cpp
clang/test/Misc/warning-wall.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index ae3f882dd910..2b11298bfcfa 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -99,6 +99,7 @@ def FloatConversion :
   DiagGroup<"float-conversion", [FloatOverflowConversion,
  FloatZeroConversion]>;
 
+def FrameAddress : DiagGroup<"frame-address">;
 def DoublePromotion : DiagGroup<"double-promotion">;
 def EnumTooLarge : DiagGroup<"enum-too-large">;
 def UnsupportedNan : DiagGroup<"unsupported-nan">;
@@ -872,6 +873,7 @@ def Most : DiagGroup<"most", [
 DeleteNonVirtualDtor,
 Format,
 ForLoopAnalysis,
+FrameAddress,
 Implicit,
 InfiniteRecursion,
 IntInBoolContext,

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index b0338c44cca9..6c73917e2eac 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1780,6 +1780,11 @@ def note_due_to_dllexported_class : Note<
 def err_illegal_union_or_anon_struct_member : Error<
   "%select{anonymous struct|union}0 member %1 has a non-trivial "
   "%sub{select_special_member_kind}2">;
+
+def warn_frame_address : Warning<
+  "calling '%0' with a nonzero argument is unsafe">,
+  InGroup, DefaultIgnore;
+
 def warn_cxx98_compat_nontrivial_union_or_anon_struct_member : Warning<
   "%select{anonymous struct|union}0 member %1 with a non-trivial "
   "%sub{select_special_member_kind}2 is incompatible with C++98">,

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 106e90f4c44c..2e73fcac93e1 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -1853,6 +1853,17 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, 
unsigned BuiltinID,
   case Builtin::BI__builtin_return_address:
 if (SemaBuiltinConstantArgRange(TheCall, 0, 0, 0x))
   return ExprError();
+
+// -Wframe-address warning if non-zero passed to builtin
+// return/frame address.
+Expr::EvalResult Result;
+if (TheCall->getArg(0)->EvaluateAsInt(Result, getASTContext()) &&
+Result.Val.getInt() != 0)
+  Diag(TheCall->getBeginLoc(), diag::warn_frame_address)
+  << ((BuiltinID == Builtin::BI__builtin_return_address)
+  ? "__builtin_return_address"
+  : "__builtin_frame_address")
+  << TheCall->getSourceRange();
 break;
   }
 

diff  --git a/clang/test/Misc/warning-wall.c b/clang/test/Misc/warning-wall.c
index 737ed76859c4..d0a0172dff5f 100644
--- a/clang/test/Misc/warning-wall.c
+++ b/clang/test/Misc/warning-wall.c
@@ -16,6 +16,7 @@ CHECK-NEXT:  -Wformat-security
 CHECK-NEXT:  -Wformat-y2k
 CHECK-NEXT:  -Wformat-invalid-specifier
 CHECK-NEXT:-Wfor-loop-analysis
+CHECK-NEXT:-Wframe-address
 CHECK-NEXT:-Wimplicit
 CHECK-NEXT:  -Wimplicit-function-declaration
 CHECK-NEXT:  -Wimplicit-int



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


[clang] eb682b8 - [clang-format] C# does not indent braced initializers as continuations

2020-03-09 Thread Jonathan Coe via cfe-commits

Author: Jonathan Coe
Date: 2020-03-09T17:36:21Z
New Revision: eb682b80274d5486d062e3f53040969f592277e4

URL: 
https://github.com/llvm/llvm-project/commit/eb682b80274d5486d062e3f53040969f592277e4
DIFF: 
https://github.com/llvm/llvm-project/commit/eb682b80274d5486d062e3f53040969f592277e4.diff

LOG: [clang-format] C# does not indent braced initializers as continuations

Summary: C# treats object initializers as braced init blocks. Braced init 
blocks are no longer indented as continuations.

Reviewers: krasimir

Reviewed By: krasimir

Subscribers: cfe-commits

Tags: #clang-format, #clang

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

Added: 


Modified: 
clang/lib/Format/FormatToken.h
clang/lib/Format/UnwrappedLineParser.cpp
clang/unittests/Format/FormatTestCSharp.cpp

Removed: 




diff  --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h
index 072e1ad565c2..1b885b518f0d 100644
--- a/clang/lib/Format/FormatToken.h
+++ b/clang/lib/Format/FormatToken.h
@@ -509,6 +509,9 @@ struct FormatToken {
   /// Returns \c true if this tokens starts a block-type list, i.e. a
   /// list that should be indented with a block indent.
   bool opensBlockOrBlockTypeList(const FormatStyle ) const {
+// C# Does not indent object initialisers as continuations.
+if (is(tok::l_brace) && BlockKind == BK_BracedInit && Style.isCSharp())
+  return true;
 if (is(TT_TemplateString) && opensScope())
   return true;
 return is(TT_ArrayInitializerLSquare) || is(TT_ProtoExtensionLSquare) ||

diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index 58cc679af9e1..00447ebdf5a9 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -1677,7 +1677,10 @@ bool UnwrappedLineParser::parseBracedList(bool 
ContinueOnSemicolons,
   }
   break;
 case tok::l_square:
-  tryToParseLambda();
+  if (Style.isCSharp())
+parseSquare();
+  else
+tryToParseLambda();
   break;
 case tok::l_paren:
   parseParens();

diff  --git a/clang/unittests/Format/FormatTestCSharp.cpp 
b/clang/unittests/Format/FormatTestCSharp.cpp
index e3038898dcdd..a22f48676065 100644
--- a/clang/unittests/Format/FormatTestCSharp.cpp
+++ b/clang/unittests/Format/FormatTestCSharp.cpp
@@ -527,31 +527,28 @@ TEST_F(FormatTestCSharp, CSharpObjectInitializers) {
 
   verifyFormat(R"(//
 Shape[] shapes = new[] {
-new Circle {
-Radius = 2.7281,
-Colour = Colours.Red,
-},
-new Square {
-Side = 101.1,
-Colour = Colours.Yellow,
-},
+  new Circle {
+Radius = 2.7281,
+Colour = Colours.Red,
+  },
+  new Square {
+Side = 101.1,
+Colour = Colours.Yellow,
+  },
 };)",
Style);
 
   // Omitted final `,`s will change the formatting.
   verifyFormat(R"(//
 Shape[] shapes = new[] { new Circle { Radius = 2.7281, Colour = Colours.Red },
- new Square {
- Side = 101.1,
- Colour = Colours.Yellow,
- } };)",
+ new Square { Side = 101.1, Colour = Colours.Yellow } 
};)",
Style);
 
   // Lambdas can be supplied as initialiser arguments.
   verifyFormat(R"(//
 private Transformer _transformer = new X.Y {
-Filler = (Shape shape) => { return new Transform.Fill(shape, RED); },
-Scaler = (Shape shape) => { return new Transform.Resize(shape, 0.1); },
+  Filler = (Shape shape) => { return new Transform.Fill(shape, RED); },
+  Scaler = (Shape shape) => { return new Transform.Resize(shape, 0.1); },
 };)",
Style);
 }



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


[clang-tools-extra] 47caa69 - [clang-tidy] Use ; as separator for HeaderFileExtensions

2020-03-09 Thread Jonathan Roelofs via cfe-commits

Author: Jonathan Roelofs
Date: 2020-03-09T11:32:44-06:00
New Revision: 47caa69120e582bf1b795ec646f069c83b0e9456

URL: 
https://github.com/llvm/llvm-project/commit/47caa69120e582bf1b795ec646f069c83b0e9456
DIFF: 
https://github.com/llvm/llvm-project/commit/47caa69120e582bf1b795ec646f069c83b0e9456.diff

LOG: [clang-tidy] Use ; as separator for HeaderFileExtensions

... and deprecate use of ',' for the same.

https://reviews.llvm.org/D75621

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.cpp
clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.h
clang-tools-extra/clang-tidy/google/GlobalNamesInHeadersCheck.cpp
clang-tools-extra/clang-tidy/google/GlobalNamesInHeadersCheck.h
clang-tools-extra/clang-tidy/google/UnnamedNamespaceInHeaderCheck.cpp
clang-tools-extra/clang-tidy/google/UnnamedNamespaceInHeaderCheck.h
clang-tools-extra/clang-tidy/llvm/HeaderGuardCheck.h
clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.h
clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
clang-tools-extra/clang-tidy/utils/HeaderGuard.h
clang-tools-extra/docs/ReleaseNotes.rst

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.cpp
index 7403762122bd..d4d3ff9af75e 100644
--- a/clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.cpp
@@ -32,7 +32,8 @@ 
DynamicStaticInitializersCheck::DynamicStaticInitializersCheck(StringRef Name,
   RawStringHeaderFileExtensions(Options.getLocalOrGlobal(
 "HeaderFileExtensions", utils::defaultHeaderFileExtensions())) {
   if (!utils::parseFileExtensions(RawStringHeaderFileExtensions,
-  HeaderFileExtensions, ',')) {
+  HeaderFileExtensions,
+  utils::defaultFileExtensionDelimiters())) {
 llvm::errs() << "Invalid header file extension: "
  << RawStringHeaderFileExtensions << "\n";
   }

diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.h 
b/clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.h
index ac0d32202d61..f06b2d036386 100644
--- a/clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.h
+++ b/clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.h
@@ -19,11 +19,12 @@ namespace bugprone {
 /// Finds dynamically initialized static variables in header files.
 ///
 /// The check supports these options:
-///   - `HeaderFileExtensions`: a comma-separated list of filename extensions 
of
-/// header files (The filename extensions should not contain "." prefix).
-/// "h,hh,hpp,hxx" by default.
+///   - `HeaderFileExtensions`: a semicolon-separated list of filename
+/// extensions of header files (The filename extensions should not contain
+/// "." prefix). ";h;hh;hpp;hxx" by default.
+//
 /// For extension-less header files, using an empty string or leaving an
-/// empty string between "," if there are other filename extensions.
+/// empty string between ";" if there are other filename extensions.
 class DynamicStaticInitializersCheck : public ClangTidyCheck {
 public:
   DynamicStaticInitializersCheck(StringRef Name, ClangTidyContext *Context);

diff  --git a/clang-tools-extra/clang-tidy/google/GlobalNamesInHeadersCheck.cpp 
b/clang-tools-extra/clang-tidy/google/GlobalNamesInHeadersCheck.cpp
index 09eb266efb35..968adb882391 100644
--- a/clang-tools-extra/clang-tidy/google/GlobalNamesInHeadersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/google/GlobalNamesInHeadersCheck.cpp
@@ -25,7 +25,8 @@ 
GlobalNamesInHeadersCheck::GlobalNamesInHeadersCheck(StringRef Name,
   RawStringHeaderFileExtensions(Options.getLocalOrGlobal(
   "HeaderFileExtensions", utils::defaultHeaderFileExtensions())) {
   if (!utils::parseFileExtensions(RawStringHeaderFileExtensions,
-  HeaderFileExtensions, ',')) {
+  HeaderFileExtensions,
+  utils::defaultFileExtensionDelimiters())) {
 llvm::errs() << "Invalid header file extension: "
  << RawStringHeaderFileExtensions << "\n";
   }

diff  --git a/clang-tools-extra/clang-tidy/google/GlobalNamesInHeadersCheck.h 
b/clang-tools-extra/clang-tidy/google/GlobalNamesInHeadersCheck.h
index cd69df72962e..aa569dedcdb4 100644
--- a/clang-tools-extra/clang-tidy/google/GlobalNamesInHeadersCheck.h
+++ b/clang-tools-extra/clang-tidy/google/GlobalNamesInHeadersCheck.h
@@ -21,11 +21,12 @@ namespace 

[clang-tools-extra] 3486cc0 - [clang-tidy] Generalize HeaderFileExtensions.{h,cpp}. NFC

2020-03-09 Thread Jonathan Roelofs via cfe-commits

Author: Jonathan Roelofs
Date: 2020-03-09T11:32:44-06:00
New Revision: 3486cc014b208df3897cf5656db0d0fdeae26d6b

URL: 
https://github.com/llvm/llvm-project/commit/3486cc014b208df3897cf5656db0d0fdeae26d6b
DIFF: 
https://github.com/llvm/llvm-project/commit/3486cc014b208df3897cf5656db0d0fdeae26d6b.diff

LOG: [clang-tidy] Generalize HeaderFileExtensions.{h,cpp}. NFC

https://reviews.llvm.org/D75489

Added: 
clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h

Modified: 
clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.cpp
clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.h
clang-tools-extra/clang-tidy/google/GlobalNamesInHeadersCheck.cpp
clang-tools-extra/clang-tidy/google/GlobalNamesInHeadersCheck.h
clang-tools-extra/clang-tidy/google/UnnamedNamespaceInHeaderCheck.cpp
clang-tools-extra/clang-tidy/google/UnnamedNamespaceInHeaderCheck.h
clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.h
clang-tools-extra/clang-tidy/utils/CMakeLists.txt
clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp
clang-tools-extra/clang-tidy/utils/HeaderGuard.h

Removed: 
clang-tools-extra/clang-tidy/utils/HeaderFileExtensionsUtils.cpp
clang-tools-extra/clang-tidy/utils/HeaderFileExtensionsUtils.h



diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.cpp
index 1e2184e324fc..7403762122bd 100644
--- a/clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.cpp
@@ -31,8 +31,8 @@ 
DynamicStaticInitializersCheck::DynamicStaticInitializersCheck(StringRef Name,
 : ClangTidyCheck(Name, Context),
   RawStringHeaderFileExtensions(Options.getLocalOrGlobal(
 "HeaderFileExtensions", utils::defaultHeaderFileExtensions())) {
-  if (!utils::parseHeaderFileExtensions(RawStringHeaderFileExtensions,
-HeaderFileExtensions, ',')) {
+  if (!utils::parseFileExtensions(RawStringHeaderFileExtensions,
+  HeaderFileExtensions, ',')) {
 llvm::errs() << "Invalid header file extension: "
  << RawStringHeaderFileExtensions << "\n";
   }

diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.h 
b/clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.h
index 1cf6e408aa42..ac0d32202d61 100644
--- a/clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.h
+++ b/clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.h
@@ -10,7 +10,7 @@
 #define 
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_DYNAMIC_STATIC_INITIALIZERS_CHECK_H
 
 #include "../ClangTidyCheck.h"
-#include "../utils/HeaderFileExtensionsUtils.h"
+#include "../utils/FileExtensionsUtils.h"
 
 namespace clang {
 namespace tidy {
@@ -36,7 +36,7 @@ class DynamicStaticInitializersCheck : public ClangTidyCheck {
 
 private:
   const std::string RawStringHeaderFileExtensions;
-  utils::HeaderFileExtensionsSet HeaderFileExtensions;
+  utils::FileExtensionsSet HeaderFileExtensions;
 };
 
 } // namespace bugprone

diff  --git a/clang-tools-extra/clang-tidy/google/GlobalNamesInHeadersCheck.cpp 
b/clang-tools-extra/clang-tidy/google/GlobalNamesInHeadersCheck.cpp
index c6d72494243c..09eb266efb35 100644
--- a/clang-tools-extra/clang-tidy/google/GlobalNamesInHeadersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/google/GlobalNamesInHeadersCheck.cpp
@@ -24,8 +24,8 @@ 
GlobalNamesInHeadersCheck::GlobalNamesInHeadersCheck(StringRef Name,
 : ClangTidyCheck(Name, Context),
   RawStringHeaderFileExtensions(Options.getLocalOrGlobal(
   "HeaderFileExtensions", utils::defaultHeaderFileExtensions())) {
-  if (!utils::parseHeaderFileExtensions(RawStringHeaderFileExtensions,
-HeaderFileExtensions, ',')) {
+  if (!utils::parseFileExtensions(RawStringHeaderFileExtensions,
+  HeaderFileExtensions, ',')) {
 llvm::errs() << "Invalid header file extension: "
  << RawStringHeaderFileExtensions << "\n";
   }

diff  --git a/clang-tools-extra/clang-tidy/google/GlobalNamesInHeadersCheck.h 
b/clang-tools-extra/clang-tidy/google/GlobalNamesInHeadersCheck.h
index 730ef60c70fc..cd69df72962e 100644
--- a/clang-tools-extra/clang-tidy/google/GlobalNamesInHeadersCheck.h
+++ b/clang-tools-extra/clang-tidy/google/GlobalNamesInHeadersCheck.h
@@ -10,7 +10,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_GLOBALNAMESINHEADERSCHECK_H
 
 #include "../ClangTidyCheck.h"
-#include "../utils/HeaderFileExtensionsUtils.h"
+#include "../utils/FileExtensionsUtils.h"
 
 namespace 

[clang] b28ed9c - [clang-format] cleanup from D75517

2020-03-09 Thread Jonathan Coe via cfe-commits

Author: Jonathan Coe
Date: 2020-03-09T17:31:36Z
New Revision: b28ed9cec8dd7225164eb8c0884aa463654ef3fc

URL: 
https://github.com/llvm/llvm-project/commit/b28ed9cec8dd7225164eb8c0884aa463654ef3fc
DIFF: 
https://github.com/llvm/llvm-project/commit/b28ed9cec8dd7225164eb8c0884aa463654ef3fc.diff

LOG: [clang-format] cleanup from D75517

Summary:
Fix typo in comment.

Add closing brace to test text.

Reviewers: krasimir

Subscribers: cfe-commits

Tags: #clang-format, #clang

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

Added: 


Modified: 
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTestCSharp.cpp

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 2673dacfff13..db230583b6c9 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -373,7 +373,7 @@ class AnnotatingParser {
 if (Tok.Previous && Tok.Previous->is(tok::identifier))
   return false;
 
-// Chains [] in of `identifier[i][j][k]` are not attributes.
+// Chains of [] in `identifier[i][j][k]` are not attributes.
 if (Tok.Previous && Tok.Previous->is(tok::r_square)) {
   auto *MatchingParen = Tok.Previous->MatchingParen;
   if (!MatchingParen || MatchingParen->is(TT_ArraySubscriptLSquare))

diff  --git a/clang/unittests/Format/FormatTestCSharp.cpp 
b/clang/unittests/Format/FormatTestCSharp.cpp
index 7e60fdbdba26..e3038898dcdd 100644
--- a/clang/unittests/Format/FormatTestCSharp.cpp
+++ b/clang/unittests/Format/FormatTestCSharp.cpp
@@ -650,8 +650,15 @@ TEST_F(FormatTestCSharp, CSharpArraySubscripts) {
   FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
 
   // Do not format array subscript operators as attributes.
-  verifyFormat(R"(if (someThings[index].Contains(myThing)) {)", Style);
-  verifyFormat(R"(if (someThings[i][j][k].Contains(myThing)) {)", Style);
+  verifyFormat(R"(//
+if (someThings[index].Contains(myThing)) {
+})",
+   Style);
+
+  verifyFormat(R"(//
+if (someThings[i][j][k].Contains(myThing)) {
+})",
+   Style);
 }
 
 } // namespace format



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


[PATCH] D75731: [clang-format] C# does not indent braced initializers as continuations

2020-03-09 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe marked 2 inline comments as done.
jbcoe added inline comments.



Comment at: clang/unittests/Format/FormatTestCSharp.cpp:544
 Shape[] shapes = new[] { new Circle { Radius = 2.7281, Colour = Colours.Red },
- new Square {
- Side = 101.1,
- Colour = Colours.Yellow,
- } };)",
+ new Square { Side = 101.1, Colour = Colours.Yellow } 
};)",
Style);

krasimir wrote:
> krasimir wrote:
> > Please add test cases that demonstrate the +2 indent used when breaking 
> > inside C# object initializers.
> Consider also adding an example with a trailing comma if the behavior there 
> can be different than the one without a trailing comma.
The test at L 529 already covers 2 space indent and a trailing comma.


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

https://reviews.llvm.org/D75731



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


[PATCH] D75856: [clang-format] cleanup from D75517

2020-03-09 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe updated this revision to Diff 249148.

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

https://reviews.llvm.org/D75856

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


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -650,8 +650,15 @@
   FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
 
   // Do not format array subscript operators as attributes.
-  verifyFormat(R"(if (someThings[index].Contains(myThing)) {)", Style);
-  verifyFormat(R"(if (someThings[i][j][k].Contains(myThing)) {)", Style);
+  verifyFormat(R"(//
+if (someThings[index].Contains(myThing)) {
+})",
+   Style);
+
+  verifyFormat(R"(//
+if (someThings[i][j][k].Contains(myThing)) {
+})",
+   Style);
 }
 
 } // namespace format
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -373,7 +373,7 @@
 if (Tok.Previous && Tok.Previous->is(tok::identifier))
   return false;
 
-// Chains [] in of `identifier[i][j][k]` are not attributes.
+// Chains of [] in `identifier[i][j][k]` are not attributes.
 if (Tok.Previous && Tok.Previous->is(tok::r_square)) {
   auto *MatchingParen = Tok.Previous->MatchingParen;
   if (!MatchingParen || MatchingParen->is(TT_ArraySubscriptLSquare))


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -650,8 +650,15 @@
   FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
 
   // Do not format array subscript operators as attributes.
-  verifyFormat(R"(if (someThings[index].Contains(myThing)) {)", Style);
-  verifyFormat(R"(if (someThings[i][j][k].Contains(myThing)) {)", Style);
+  verifyFormat(R"(//
+if (someThings[index].Contains(myThing)) {
+})",
+   Style);
+
+  verifyFormat(R"(//
+if (someThings[i][j][k].Contains(myThing)) {
+})",
+   Style);
 }
 
 } // namespace format
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -373,7 +373,7 @@
 if (Tok.Previous && Tok.Previous->is(tok::identifier))
   return false;
 
-// Chains [] in of `identifier[i][j][k]` are not attributes.
+// Chains of [] in `identifier[i][j][k]` are not attributes.
 if (Tok.Previous && Tok.Previous->is(tok::r_square)) {
   auto *MatchingParen = Tok.Previous->MatchingParen;
   if (!MatchingParen || MatchingParen->is(TT_ArraySubscriptLSquare))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75858: [AArch64][SVE] Add SVE intrinsics for address calculations

2020-03-09 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen accepted this revision.
sdesmalen 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/D75858/new/

https://reviews.llvm.org/D75858



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


[PATCH] D75850: [ARM, CDE] Generalize MVE intrinsics infrastructure to support CDE

2020-03-09 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki added a comment.

In D75850#1912810 , @sdesmalen wrote:

>   but am happy to update my patch to reuse the generic 
> `__clang_arm_builtin_alias`!


Please do. It would be nicer to have a single attribute than 2 or 3 distinct 
ones which serve essentially the same goal.


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

https://reviews.llvm.org/D75850



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


[PATCH] D75529: [analyzer] Limit UCharMax to min of max uchar or max int

2020-03-09 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers added a comment.
Herald added a subscriber: danielkiss.

@Charusso, I cannot find a way to create a test for this change, since this was 
found using an architecture that supports 16-bit chars. I understand the need 
to create test cases for changes. In this case, I believe a rationale for 
accepting this change is to conform to the C Standard, and accept that upstream 
clang does not have a way to test for architectures supporting 16-bit 
characters, or otherwise "peculiar" datatypes.

Please do indicate if you're willing to accept this patch or not. If not, I 
need to know so I solve this problem for my customer in a different way.

Thank you - Vince


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75529



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


[PATCH] D75856: [clang-format] cleanup from D75517

2020-03-09 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir requested changes to this revision.
krasimir added a comment.
This revision now requires changes to proceed.

The new pre-merge checks are cool! Please clang-format the updated lines 
accordingly.


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

https://reviews.llvm.org/D75856



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


[PATCH] D75470: [SVE] Auto-generate builtins and header for svld1.

2020-03-09 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki added a comment.

In D75470#1910071 , @sdesmalen wrote:

> The SVE implementation now does more or less the same thing the MVE 
> implementation; `arm_sve.h` also uses `__attribute__((overloadable))` and 
> `__attribute__((arm_sve_alias("__builtin_...")))`, the latter only to declare 
> the overloaded intrinsics. That means we get the same benefits as Simon 
> described.


FYI: we are currently working on another M-profile extension, CDE. In my 
patches am reusing some of the MVE intrinsic machinery, and I decided to rename 
`__clang_arm_mve_alias` to `__clang_arm_builtin_alias`. You might want to reuse 
the same attribute name to reduce duplication, see 
https://reviews.llvm.org/D75850


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

https://reviews.llvm.org/D75470



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


[PATCH] D75850: [ARM, CDE] Generalize MVE intrinsics infrastructure to support CDE

2020-03-09 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added a comment.

In D75850#1912685 , @simon_tatham 
wrote:

> > Renames the 'clang_arm_mve_alias' attribute into 'clang_arm_builtin_alias' 
> > (it will be used with CDE intrinsics as well as MVE intrinsics)
>
> You might talk to @sdesmalen, who mentioned introducing an `arm_sve_alias` 
> attribute in a comment on D75470 . Probably 
> better if we all use the same one :-)


Thanks for pointing out! I added `arm_sve_alias` in D75861 
, but am happy to update my patch to reuse the 
generic `__clang_arm_builtin_alias`!


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

https://reviews.llvm.org/D75850



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


  1   2   3   >