[clang-tools-extra] 1603470 - [clangd] Fix clangd-indexeer builds after D84697

2020-07-29 Thread Kirill Bobyrev via cfe-commits

Author: Kirill Bobyrev
Date: 2020-07-29T10:27:11+02:00
New Revision: 1603470e59a99a39ebdc4bf62a3a16c8c4ebea36

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

LOG: [clangd] Fix clangd-indexeer builds after D84697

Some buildbots require explicit clangdSupport dependency:

http://lab.llvm.org:8011/builders/llvm-avr-linux/builds/3996/steps/build%20stage%201/logs/stdio

Added: 


Modified: 
clang-tools-extra/clangd/indexer/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/clangd/indexer/CMakeLists.txt 
b/clang-tools-extra/clangd/indexer/CMakeLists.txt
index edbced1410bb..ff110693c706 100644
--- a/clang-tools-extra/clangd/indexer/CMakeLists.txt
+++ b/clang-tools-extra/clangd/indexer/CMakeLists.txt
@@ -20,4 +20,5 @@ clang_target_link_libraries(clangd-indexer
 target_link_libraries(clangd-indexer
   PRIVATE
   clangDaemon
+  clangdSupport
 )



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


[libunwind] 380fee3 - [libunwind] Provide a way to set '_LIBUNWIND_IS_BAREMETAL' through cmake.

2020-07-29 Thread Hafiz Abid Qadeer via cfe-commits

Author: Hafiz Abid Qadeer
Date: 2020-07-29T11:48:28+01:00
New Revision: 380fee34d2794361f9e222fe3c8c065be3b9fff8

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

LOG: [libunwind] Provide a way to set '_LIBUNWIND_IS_BAREMETAL' through cmake.

Libunwind uses _LIBUNWIND_IS_BAREMETAL in a lot of places but there is no cmake 
variable to set it. This patch adds such a variable. It is quite like what 
LIBCXXABI_BAREMETAL does in libcxxabi.

Reviewed By: compnerd, #libunwind

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

Added: 


Modified: 
libunwind/CMakeLists.txt

Removed: 




diff  --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt
index c5b536532f3c..4606360f07ab 100644
--- a/libunwind/CMakeLists.txt
+++ b/libunwind/CMakeLists.txt
@@ -137,6 +137,7 @@ option(LIBUNWIND_ENABLE_THREADS "Build libunwind with 
threading support." ON)
 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_IS_BAREMETAL "Build libunwind for baremetal targets." OFF)
 
 set(LIBUNWIND_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING
 "Define suffix of library directory name (32/64)")
@@ -361,6 +362,10 @@ if (LIBUNWIND_ENABLE_ARM_WMMX)
   add_compile_flags(-D__ARM_WMMX)
 endif()
 
+if(LIBUNWIND_IS_BAREMETAL)
+  add_compile_definitions(_LIBUNWIND_IS_BAREMETAL)
+endif()
+
 # This is the _ONLY_ place where add_definitions is called.
 if (MSVC)
   add_definitions(-D_CRT_SECURE_NO_WARNINGS)



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


[PATCH] D84831: [clang-tidy] Fix RedundantStringCStrCheck with r values

2020-07-29 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: aaron.ballman, gribozavr2, alexfh.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.
njames93 requested review of this revision.

The previous fix for this, https://reviews.llvm.org/D76761, Passed test cases 
but failed in the real world as std::string has a non trivial destructor so 
creates a CXXBindTemporaryExpr.

This handles that shortfall and updates the test case std::basic_string 
implementation to use a non trivial destructor to reflect real world behaviour.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84831

Files:
  clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-cstr.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-cstr.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-cstr.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-cstr.cpp
@@ -15,6 +15,8 @@
   basic_string();
   basic_string(const C *p, const A &a = A());
 
+  ~basic_string();
+
   const C *c_str() const;
   const C *data() const;
 
Index: clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
@@ -92,16 +92,18 @@
 callee(memberExpr().bind("member")),
 callee(cxxMethodDecl(hasAnyName("c_str", "data"
   .bind("call");
-
+  const auto HasRValueTempParent =
+  hasParent(materializeTemporaryExpr(unless(isBoundToLValue(;
   // Detect redundant 'c_str()' calls through a string constructor.
   // If CxxConstructExpr is the part of some CallExpr we need to
   // check that matched ParamDecl of the ancestor CallExpr is not rvalue.
   Finder->addMatcher(
-  traverse(ast_type_traits::TK_AsIs,
-   cxxConstructExpr(StringConstructorExpr,
-hasArgument(0, StringCStrCallExpr),
-unless(hasParent(materializeTemporaryExpr(
-unless(isBoundToLValue())),
+  traverse(
+  ast_type_traits::TK_AsIs,
+  cxxConstructExpr(
+  StringConstructorExpr, hasArgument(0, StringCStrCallExpr),
+  unless(anyOf(HasRValueTempParent, hasParent(cxxBindTemporaryExpr(
+HasRValueTempParent)),
   this);
 
   // Detect: 's == str.c_str()'  ->  's == str'


Index: clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-cstr.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-cstr.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-cstr.cpp
@@ -15,6 +15,8 @@
   basic_string();
   basic_string(const C *p, const A &a = A());
 
+  ~basic_string();
+
   const C *c_str() const;
   const C *data() const;
 
Index: clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
@@ -92,16 +92,18 @@
 callee(memberExpr().bind("member")),
 callee(cxxMethodDecl(hasAnyName("c_str", "data"
   .bind("call");
-
+  const auto HasRValueTempParent =
+  hasParent(materializeTemporaryExpr(unless(isBoundToLValue(;
   // Detect redundant 'c_str()' calls through a string constructor.
   // If CxxConstructExpr is the part of some CallExpr we need to
   // check that matched ParamDecl of the ancestor CallExpr is not rvalue.
   Finder->addMatcher(
-  traverse(ast_type_traits::TK_AsIs,
-   cxxConstructExpr(StringConstructorExpr,
-hasArgument(0, StringCStrCallExpr),
-unless(hasParent(materializeTemporaryExpr(
-unless(isBoundToLValue())),
+  traverse(
+  ast_type_traits::TK_AsIs,
+  cxxConstructExpr(
+  StringConstructorExpr, hasArgument(0, StringCStrCallExpr),
+  unless(anyOf(HasRValueTempParent, hasParent(cxxBindTemporaryExpr(
+HasRValueTempParent)),
   this);
 
   // Detect: 's == str.c_str()'  ->  's == str'
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84812: [clang-tidy][NFC] Added convienence methods for getting optional options

2020-07-29 Thread Nathan James via Phabricator via cfe-commits
njames93 marked an inline comment as done.
njames93 added inline comments.



Comment at: clang-tools-extra/clang-tidy/ClangTidyCheck.cpp:224
+  else
+consumeError(ValueOr.takeError());
+  return llvm::None;

gribozavr2 wrote:
> Is this specialization defined only because parsing a string option can never 
> fail? I'd let this special case behavior fall out of the primary template if 
> possible.
It's because the call to get that returns a `std::string` isn't a template.
So in the actual template definition of `getOptional`, trying to call `get` 
when `T` is a `std::string` results in a compile time error.
Consuming the error makes sense knowing the it will always be a 
`MissingOptionError`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84812

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


[PATCH] D82948: [Driver][ARM] Disable unsupported features when nofp arch extension is used

2020-07-29 Thread Momchil Velikov via Phabricator via cfe-commits
chill accepted this revision.
chill added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!




Comment at: clang/lib/Driver/ToolChains/Arch/ARM.cpp:481
+{"-dotprod", "-fp16fml", "-bf16", "-mve.fp"});
+if (!hasIntegerMVE(Features)) {
   Features.emplace_back("-fpregs");

LLVM coding standards call for not using braces on single-statement bodies and 
that's also the style in this source file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82948

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


[PATCH] D84812: [clang-tidy][NFC] Added convienence methods for getting optional options

2020-07-29 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 281492.
njames93 added a comment.

Rename logOptionParsingError


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84812

Files:
  clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
  clang-tools-extra/clang-tidy/ClangTidyCheck.h

Index: clang-tools-extra/clang-tidy/ClangTidyCheck.h
===
--- clang-tools-extra/clang-tidy/ClangTidyCheck.h
+++ clang-tools-extra/clang-tidy/ClangTidyCheck.h
@@ -268,7 +268,7 @@
   if (llvm::Expected ValueOr = get(LocalName))
 return *ValueOr;
   else
-logErrToStdErr(ValueOr.takeError());
+logIfOptionParsingError(ValueOr.takeError());
   return Default;
 }
 
@@ -314,7 +314,7 @@
   if (llvm::Expected ValueOr = getLocalOrGlobal(LocalName))
 return *ValueOr;
   else
-logErrToStdErr(ValueOr.takeError());
+logIfOptionParsingError(ValueOr.takeError());
   return Default;
 }
 
@@ -353,7 +353,7 @@
   if (auto ValueOr = get(LocalName, IgnoreCase))
 return *ValueOr;
   else
-logErrToStdErr(ValueOr.takeError());
+logIfOptionParsingError(ValueOr.takeError());
   return Default;
 }
 
@@ -395,10 +395,35 @@
   if (auto ValueOr = getLocalOrGlobal(LocalName, IgnoreCase))
 return *ValueOr;
   else
-logErrToStdErr(ValueOr.takeError());
+logIfOptionParsingError(ValueOr.takeError());
   return Default;
 }
 
+/// Returns the value for the option \p LocalName represented as a ``T``.
+/// If the option is missing returns None, if the option can't be parsed
+/// as a ``T``, log that to stderr and return None.
+template 
+llvm::Optional getOptional(StringRef LocalName) const {
+  if (auto ValueOr = get(LocalName))
+return *ValueOr;
+  else
+logIfOptionParsingError(ValueOr.takeError());
+  return llvm::None;
+}
+
+/// Returns the value for the local or global option \p LocalName
+/// represented as a ``T``.
+/// If the option is missing returns None, if the
+/// option can't be parsed as a ``T``, log that to stderr and return None.
+template 
+llvm::Optional getOptionalLocalOrGlobal(StringRef LocalName) const {
+  if (auto ValueOr = getLocalOrGlobal(LocalName))
+return *ValueOr;
+  else
+logIfOptionParsingError(ValueOr.takeError());
+  return llvm::None;
+}
+
 /// Stores an option with the check-local name \p LocalName with
 /// string value \p Value to \p Options.
 void store(ClangTidyOptions::OptionMap &Options, StringRef LocalName,
@@ -456,7 +481,8 @@
 void storeInt(ClangTidyOptions::OptionMap &Options, StringRef LocalName,
   int64_t Value) const;
 
-static void logErrToStdErr(llvm::Error &&Err);
+/// Logs an Error to stderr if a \p Err is not a MissingOptionError.
+static void logIfOptionParsingError(llvm::Error &&Err);
 
 std::string NamePrefix;
 const ClangTidyOptions::OptionMap &CheckOptions;
@@ -524,6 +550,19 @@
 ClangTidyOptions::OptionMap &Options, StringRef LocalName,
 bool Value) const;
 
+/// Returns the value for the option \p LocalName.
+/// If the option is missing returns None.
+template <>
+Optional ClangTidyCheck::OptionsView::getOptional(
+StringRef LocalName) const;
+
+/// Returns the value for the local or global option \p LocalName.
+/// If the option is missing returns None.
+template <>
+Optional
+ClangTidyCheck::OptionsView::getOptionalLocalOrGlobal(
+StringRef LocalName) const;
+
 } // namespace tidy
 } // namespace clang
 
Index: clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
@@ -10,6 +10,7 @@
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/WithColor.h"
 #include "llvm/Support/raw_ostream.h"
 
 namespace clang {
@@ -126,7 +127,7 @@
   llvm::Expected ValueOr = get(LocalName);
   if (ValueOr)
 return *ValueOr;
-  logErrToStdErr(ValueOr.takeError());
+  logIfOptionParsingError(ValueOr.takeError());
   return Default;
 }
 
@@ -145,7 +146,7 @@
   llvm::Expected ValueOr = getLocalOrGlobal(LocalName);
   if (ValueOr)
 return *ValueOr;
-  logErrToStdErr(ValueOr.takeError());
+  logIfOptionParsingError(ValueOr.takeError());
   return Default;
 }
 
@@ -204,13 +205,36 @@
   Iter->second.Value);
 }
 
-void ClangTidyCheck::OptionsView::logErrToStdErr(llvm::Error &&Err) {
-  llvm::logAllUnhandledErrors(
-  llvm::handleErrors(std::move(Err),
- [](const MissingOptionError &) -> llvm::Error {
-   return llvm::Error::success();
-

[PATCH] D84814: [clang-tidy] readability-identifier-naming checks configs for included files

2020-07-29 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 281494.
njames93 added a comment.

- Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84814

Files:
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/global-style1/.clang-tidy
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/global-style1/header.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/global-style2/.clang-tidy
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/global-style2/header.h
  
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-case-violation.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-multiple-styles.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-multiple-styles.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-multiple-styles.cpp
@@ -0,0 +1,34 @@
+// Setup header directory
+
+// RUN: rm -rf %theaders
+// RUN: mkdir %theaders
+// RUN: cp -R %S/Inputs/readability-identifier-naming/. %theaders
+
+// C++11 isnt explicitly required, but failing to specify a standard means the
+// check will run multiple times for different standards. This will cause the
+// second test to fail as the header file will be changed during the first run.
+
+// RUN: %check_clang_tidy -std=c++11 %s readability-identifier-naming %t -- \
+// RUN:   -config='{ InheritParentConfig: true, CheckOptions: [ \
+// RUN: {key: readability-identifier-naming.FunctionCase, value: camelBack} \
+// RUN:  ]}' -header-filter='.*' -- -I%theaders
+
+#include "global-style1/header.h"
+#include "global-style2/header.h"
+// CHECK-MESSAGES-DAG: global-style1/header.h:5:6: warning: invalid case style for global function 'style1Bad'
+// CHECK-MESSAGES-DAG: global-style2/header.h:5:6: warning: invalid case style for global function 'style2Bad'
+
+void goodStyle() {
+  style1_good();
+  STYLE2_GOOD();
+}
+// CHECK-MESSAGES-DAG: :[[@LINE+1]]:6: warning: invalid case style for function 'bad_style'
+void bad_style() {
+  style1Bad();
+  style2Bad();
+}
+
+//  CHECK-FIXES: void badStyle() {
+// CHECK-FIXES-NEXT:   style1_bad();
+// CHECK-FIXES-NEXT:   STYLE2_BAD();
+// CHECK-FIXES-NEXT: }
Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-case-violation.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-case-violation.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-case-violation.cpp
@@ -5,11 +5,11 @@
 // RUN:   {key: readability-identifier-naming.ClassCase, value: UUPER_CASE}, \
 // RUN:   {key: readability-identifier-naming.StructCase, value: CAMEL}, \
 // RUN:   {key: readability-identifier-naming.EnumCase, value: AnY_cASe}, \
-// RUN:   ]}" 2>&1 | FileCheck %s --implicit-check-not warning
+// RUN:   ]}" 2>&1 | FileCheck %s --implicit-check-not error
 
-// CHECK-DAG: warning: invalid configuration value 'camelback' for option 'readability-identifier-naming.FunctionCase'; did you mean 'camelBack'?{{$}}
-// CHECK-DAG: warning: invalid configuration value 'UUPER_CASE' for option 'readability-identifier-naming.ClassCase'; did you mean 'UPPER_CASE'?{{$}}
+// CHECK-DAG: error: invalid configuration value 'camelback' for option 'readability-identifier-naming.FunctionCase'; did you mean 'camelBack'?{{$}}
+// CHECK-DAG: error: invalid configuration value 'UUPER_CASE' for option 'readability-identifier-naming.ClassCase'; did you mean 'UPPER_CASE'?{{$}}
 // Don't try to suggest an alternative for 'CAMEL'
-// CHECK-DAG: warning: invalid configuration value 'CAMEL' for option 'readability-identifier-naming.StructCase'{{$}}
+// CHECK-DAG: error: invalid configuration value 'CAMEL' for option 'readability-identifier-naming.StructCase'{{$}}
 // This fails on the EditDistance, but as it matches ignoring case suggest the correct value
-// CHECK-DAG: warning: invalid configuration value 'AnY_cASe' for option 'readability-identifier-naming.EnumCase'; did you mean 'aNy_CasE'?{{$}}
+// CHECK-DAG: error: invalid configuration value 'AnY_cASe' for option 'readability-identifier-naming.EnumCase'; did you mean 'aNy_CasE'?{{$}}
Index: clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/global-style2/header.h
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/Inputs/readability-identifier-naming/global-style2/header.h
@@ -0,0 +1,5 @@
+
+
+void STYLE2_GOOD();
+
+void style2Bad();
Index: clang-too

[PATCH] D84743: [Clang][AMDGCN] Universal device offloading macros header

2020-07-29 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

We probably do want a macro to indicate 'compiling for amdgcn as the device 
half of a combined host+device language'. I'm having a tough time with the 
control flow in this header so we probably want tests to check the overall 
behaviour is as intended. E.g. static assert + various language modes.

The header should be obviously implemention only so we can change it later. 
Maybe also provide an unset header and keep them out of application scope 
entirely to begin with. That's the advantage over the otherwise simpler design 
of clang always setting them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84743

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


[PATCH] D78704: [analyzer][NFC] Add unittest for FalsePositiveRefutationBRVisitor

2020-07-29 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

This commit breaks standalone clang builds.




Comment at: 
clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp:19
+#include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h"
+#include "llvm/Config/config.h"
+#include "gtest/gtest.h"

`config.h` is a private LLVM header and must not be used from clang.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78704

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


[PATCH] D84713: [DominatorTree] Simplify ChildrenGetter.

2020-07-29 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

This change had a significant negative compile-time impact: 
https://llvm-compile-time-tracker.com/compare.php?from=0b161def6cacff1a63d3cf1a1efe95b550814d7a&to=e22de4e46d1dd1aacc3a7060d24bcbe89908ba6c&stat=instructions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84713

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


[PATCH] D84613: [clang] Fix ConceptSpecializationExpr::getEndLoc()

2020-07-29 Thread Nathan Ridge via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG89247792c5bd: [clang] Fix 
ConceptSpecializationExpr::getEndLoc() (authored by nridge).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84613

Files:
  clang/include/clang/AST/ExprConcepts.h
  clang/test/AST/ast-dump-concepts.cpp


Index: clang/test/AST/ast-dump-concepts.cpp
===
--- clang/test/AST/ast-dump-concepts.cpp
+++ clang/test/AST/ast-dump-concepts.cpp
@@ -6,14 +6,22 @@
 // RUN: -ast-dump-all -ast-dump-filter Foo /dev/null \
 // RUN: | FileCheck --strict-whitespace %s
 
+template 
+concept unary_concept = true;
+
 template 
 concept binary_concept = true;
 
 template 
 struct Foo {
   // CHECK:  TemplateTypeParmDecl {{.*}} referenced Concept {{.*}} 
'binary_concept'
-  // CHECK-NEXT: |-ConceptSpecializationExpr {{.*}} 'bool'
+  // CHECK-NEXT: |-ConceptSpecializationExpr {{.*}}  'bool'
   // CHECK-NEXT: `-TemplateArgument {{.*}} type 'int'
   template  R>
   Foo(R);
+
+  // CHECK:  TemplateTypeParmDecl {{.*}} referenced Concept {{.*}} 
'unary_concept'
+  // CHECK-NEXT: `-ConceptSpecializationExpr {{.*}}  'bool'
+  template 
+  Foo(R);
 };
Index: clang/include/clang/AST/ExprConcepts.h
===
--- clang/include/clang/AST/ExprConcepts.h
+++ clang/include/clang/AST/ExprConcepts.h
@@ -126,7 +126,11 @@
   }
 
   SourceLocation getEndLoc() const LLVM_READONLY {
-return ArgsAsWritten->RAngleLoc;
+// If the ConceptSpecializationExpr is the ImmediatelyDeclaredConstraint
+// of a TypeConstraint written syntactically as a constrained-parameter,
+// there may not be a template argument list.
+return ArgsAsWritten->RAngleLoc.isValid() ? ArgsAsWritten->RAngleLoc
+  : ConceptName.getEndLoc();
   }
 
   // Iterators


Index: clang/test/AST/ast-dump-concepts.cpp
===
--- clang/test/AST/ast-dump-concepts.cpp
+++ clang/test/AST/ast-dump-concepts.cpp
@@ -6,14 +6,22 @@
 // RUN: -ast-dump-all -ast-dump-filter Foo /dev/null \
 // RUN: | FileCheck --strict-whitespace %s
 
+template 
+concept unary_concept = true;
+
 template 
 concept binary_concept = true;
 
 template 
 struct Foo {
   // CHECK:  TemplateTypeParmDecl {{.*}} referenced Concept {{.*}} 'binary_concept'
-  // CHECK-NEXT: |-ConceptSpecializationExpr {{.*}} 'bool'
+  // CHECK-NEXT: |-ConceptSpecializationExpr {{.*}}  'bool'
   // CHECK-NEXT: `-TemplateArgument {{.*}} type 'int'
   template  R>
   Foo(R);
+
+  // CHECK:  TemplateTypeParmDecl {{.*}} referenced Concept {{.*}} 'unary_concept'
+  // CHECK-NEXT: `-ConceptSpecializationExpr {{.*}}  'bool'
+  template 
+  Foo(R);
 };
Index: clang/include/clang/AST/ExprConcepts.h
===
--- clang/include/clang/AST/ExprConcepts.h
+++ clang/include/clang/AST/ExprConcepts.h
@@ -126,7 +126,11 @@
   }
 
   SourceLocation getEndLoc() const LLVM_READONLY {
-return ArgsAsWritten->RAngleLoc;
+// If the ConceptSpecializationExpr is the ImmediatelyDeclaredConstraint
+// of a TypeConstraint written syntactically as a constrained-parameter,
+// there may not be a template argument list.
+return ArgsAsWritten->RAngleLoc.isValid() ? ArgsAsWritten->RAngleLoc
+  : ConceptName.getEndLoc();
   }
 
   // Iterators
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81678: Introduce noundef attribute at call sites for stricter poison analysis

2020-07-29 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Looks good with suggestions applied, and with the portability problems in the 
test fixed. (Maybe just add a `-triple`? Though it would be good to also test 
`inalloca` and ARM constructor `this` returns and so on.)




Comment at: clang/include/clang/Driver/Options.td:3957
+def disable_noundef_args : Flag<["-"], "disable-noundef-args">,
+  HelpText<"Disable emitting noundef attribute in LLVM IR">;
 def load : Separate<["-"], "load">, MetaVarName<"">,

(since this doesn't affect return values)



Comment at: clang/lib/CodeGen/CGCall.cpp:2144
+  bool HasStrictReturn =
+  getLangOpts().CPlusPlus || getLangOpts().OpenCLCPlusPlus;
+  if (TargetDecl) {

`OpenCLCPlusPlus` should only ever be `true` when `CPlusPlus` is also `true`, 
so the second half of this `||` should be unnecessary.



Comment at: clang/lib/CodeGen/CGCall.cpp:2148-2150
+} else if (const VarDecl *VDecl = dyn_cast(TargetDecl)) {
+  // Function pointer
+  HasStrictReturn &= !VDecl->isExternC();

`TargetDecl` (the callee of a function call) should never be a variable. You 
shouldn't need this check.



Comment at: clang/test/CodeGen/attr-noundef.cpp:22
+// CHECK: define void @{{.*}}ret_nocopy{{.*}}(%"struct.check_structs::NoCopy"* 
noalias sret align 4 %
+// CHECK: define void 
@{{.*}}pass_nocopy{{.*}}(%"struct.check_structs::NoCopy"* noundef %
+

I think this test will fail on 32-bit Windows because `e` will be passed 
`inalloca`.



Comment at: clang/test/CodeGen/attr-noundef.cpp:78
+}
+// CHECK: define linkonce_odr void 
@{{.*}}Object{{.*}}(%"struct.check_this::Object"* noundef %
+// CHECK: define linkonce_odr noundef i32 
@{{.*}}Object{{.*}}getData{{.*}}(%"struct.check_this::Object"* noundef %

I believe this test will fail on ARM, due to constructors implicitly returning 
`this`. Consider either specifying a target for this test or weakening the 
`void` to `{{.*}}` here.



Comment at: clang/test/CodeGen/attr-noundef.cpp:79
+// CHECK: define linkonce_odr void 
@{{.*}}Object{{.*}}(%"struct.check_this::Object"* noundef %
+// CHECK: define linkonce_odr noundef i32 
@{{.*}}Object{{.*}}getData{{.*}}(%"struct.check_this::Object"* noundef %
+// CHECK: define linkonce_odr noundef %"struct.check_this::Object"* 
@{{.*}}Object{{.*}}getThis{{.*}}(%"struct.check_this::Object"* noundef %

I believe this test will fail on Windows, because `getData` and `Object` will 
appear in the opposite order in the mangling. Consider either specifying a 
target or matching these names either way around.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81678

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


[PATCH] D81678: Introduce noundef attribute at call sites for stricter poison analysis

2020-07-29 Thread Gui Andrade via Phabricator via cfe-commits
guiand updated this revision to Diff 281345.
guiand added a comment.

Fix typo in MayDropFunctionReturn


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81678

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/attr-noundef.cpp
  clang/test/CodeGen/indirect-noundef.cpp

Index: clang/test/CodeGen/indirect-noundef.cpp
===
--- /dev/null
+++ clang/test/CodeGen/indirect-noundef.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -x c++ -triple x86_64-unknown-unknown -O0 -emit-llvm -o - %s | FileCheck %s
+
+union u1 {
+  int val;
+};
+
+// CHECK: @indirect_callee_int_ptr = global i32 (i32)*
+int (*indirect_callee_int_ptr)(int);
+// CHECK: @indirect_callee_union_ptr = global i32 (i32)*
+union u1 (*indirect_callee_union_ptr)(union u1);
+
+// CHECK-LABEL: define noundef i32 @{{.*}}indirect_callee_int{{.*}}(i32 noundef %
+int indirect_callee_int(int a) { return a; }
+// CHECK-LABEL: define i32 @{{.*}}indirect_callee_union{{.*}}(i32 %
+union u1 indirect_callee_union(union u1 a) {
+  return a;
+}
+
+int main() {
+  // CHECK: call noundef i32 @{{.*}}indirect_callee_int{{.*}}(i32 noundef 0)
+  indirect_callee_int(0);
+  // CHECK: call i32 @{{.*}}indirect_callee_union{{.*}}(i32 %
+  indirect_callee_union((union u1){0});
+
+  indirect_callee_int_ptr = indirect_callee_int;
+  indirect_callee_union_ptr = indirect_callee_union;
+
+  // CHECK: call noundef i32 %{{.*}}(i32 noundef 0)
+  indirect_callee_int_ptr(0);
+  // CHECK: call i32 %{{.*}}(i32 %
+  indirect_callee_union_ptr((union u1){});
+
+  return 0;
+}
Index: clang/test/CodeGen/attr-noundef.cpp
===
--- /dev/null
+++ clang/test/CodeGen/attr-noundef.cpp
@@ -0,0 +1,152 @@
+// RUN: %clang_cc1 -x c++ -S -emit-llvm %s -o - | FileCheck %s
+
+// Passing structs by value
+// TODO: No structs may currently be marked noundef
+
+namespace check_structs {
+struct Trivial {
+  int a;
+};
+Trivial ret_trivial() { return {}; }
+void pass_trivial(Trivial e) {}
+// CHECK: define i32 @{{.*}}ret_trivial
+// CHECK: define void @{{.*}}pass_trivial{{.*}}(i32 %
+
+struct NoCopy {
+  int a;
+  NoCopy(NoCopy &) = delete;
+};
+NoCopy ret_nocopy() { return {}; }
+void pass_nocopy(NoCopy e) {}
+// CHECK: define void @{{.*}}ret_nocopy{{.*}}(%"struct.check_structs::NoCopy"* noalias sret align 4 %
+// CHECK: define void @{{.*}}pass_nocopy{{.*}}(%"struct.check_structs::NoCopy"* noundef %
+
+struct Huge {
+  int a[1024];
+};
+Huge ret_huge() { return {}; }
+void pass_huge(Huge h) {}
+// CHECK: define void @{{.*}}ret_huge{{.*}}(%"struct.check_structs::Huge"* noalias sret align 4 %
+// CHECK: define void @{{.*}}pass_huge{{.*}}(%"struct.check_structs::Huge"* noundef byval
+} // namespace check_structs
+
+// Passing unions by value
+// No unions may be marked noundef
+
+namespace check_unions {
+union Trivial {
+  int a;
+};
+Trivial ret_trivial() { return {}; }
+void pass_trivial(Trivial e) {}
+// CHECK: define i32 @{{.*}}ret_trivial
+// CHECK: define void @{{.*}}pass_trivial{{.*}}(i32 %
+
+union NoCopy {
+  int a;
+  NoCopy(NoCopy &) = delete;
+};
+NoCopy ret_nocopy() { return {}; }
+void pass_nocopy(NoCopy e) {}
+// CHECK: define void @{{.*}}ret_nocopy{{.*}}(%"union.check_unions::NoCopy"* noalias sret align 4 %
+// CHECK: define void @{{.*}}pass_nocopy{{.*}}(%"union.check_unions::NoCopy"* noundef %
+} // namespace check_unions
+
+// Passing `this` pointers
+// `this` pointer must always be defined
+
+namespace check_this {
+struct Object {
+  int data[];
+
+  Object() {
+this->data[0] = 0;
+  }
+  int getData() {
+return this->data[0];
+  }
+  Object *getThis() {
+return this;
+  }
+};
+
+void use_object() {
+  Object obj;
+  obj.getData();
+  obj.getThis();
+}
+// CHECK: define linkonce_odr void @{{.*}}Object{{.*}}(%"struct.check_this::Object"* noundef %
+// CHECK: define linkonce_odr noundef i32 @{{.*}}Object{{.*}}getData{{.*}}(%"struct.check_this::Object"* noundef %
+// CHECK: define linkonce_odr noundef %"struct.check_this::Object"* @{{.*}}Object{{.*}}getThis{{.*}}(%"struct.check_this::Object"* noundef %
+} // namespace check_this
+
+// Passing vector types
+
+namespace check_vecs {
+typedef int __attribute__((vector_size(12))) i32x3;
+i32x3 ret_vec() {
+  return {};
+}
+void pass_vec(i32x3 v) {
+}
+
+// CHECK: define noundef <3 x i32> @{{.*}}ret_vec{{.*}}()
+// CHECK: define void @{{.*}}pass_vec{{.*}}(<3 x i32> noundef %
+} // namespace check_vecs
+
+// Passing exotic types
+// Function/Array pointers, Function member / Data member pointers, nullptr_t, ExtInt types
+
+namespace check_exotic {
+struct Object {
+  int mfu

[PATCH] D82317: [Clang/Test]: Update tests where `noundef` attribute is necessary

2020-07-29 Thread Gui Andrade via Phabricator via cfe-commits
guiand updated this revision to Diff 281452.
guiand added a comment.

All tests up to date. Of particular note are the `ppc-*mmintrin.c` tests, which 
seemed to drastically change upon rerunning the test autogen script.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82317

Files:
  clang/test/ARCMT/objcmt-instancetype.m
  clang/test/ARCMT/objcmt-instancetype.m.result
  clang/test/ARCMT/objcmt-numeric-literals.m
  clang/test/ARCMT/objcmt-numeric-literals.m.result
  clang/test/CXX/except/except.spec/p14-ir.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/blocks-irgen.mm
  clang/test/CXX/modules-ts/codegen-basics.cppm
  clang/test/CXX/special/class.copy/p3.cpp
  clang/test/CodeGen/2004-02-13-Memset.c
  clang/test/CodeGen/2004-06-17-UnorderedCompares.c
  clang/test/CodeGen/2006-05-19-SingleEltReturn.c
  clang/test/CodeGen/2007-06-18-SextAttrAggregate.c
  clang/test/CodeGen/2009-02-13-zerosize-union-field.c
  clang/test/CodeGen/2009-05-04-EnumInreg.c
  clang/test/CodeGen/64bit-swiftcall.c
  clang/test/CodeGen/aapcs-align.cpp
  clang/test/CodeGen/aapcs-bitfield.c
  clang/test/CodeGen/aapcs64-align.cpp
  clang/test/CodeGen/aarch64-args.cpp
  clang/test/CodeGen/aarch64-bf16-getset-intrinsics.c
  clang/test/CodeGen/aarch64-byval-temp.c
  clang/test/CodeGen/aarch64-neon-3v.c
  clang/test/CodeGen/aarch64-neon-across.c
  clang/test/CodeGen/aarch64-neon-dot-product.c
  clang/test/CodeGen/aarch64-neon-extract.c
  clang/test/CodeGen/aarch64-neon-fcvt-intrinsics.c
  clang/test/CodeGen/aarch64-neon-fma.c
  clang/test/CodeGen/aarch64-neon-fp16fml.c
  clang/test/CodeGen/aarch64-neon-ldst-one.c
  clang/test/CodeGen/aarch64-neon-scalar-copy.c
  clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem.c
  clang/test/CodeGen/aarch64-neon-tbl.c
  clang/test/CodeGen/aarch64-neon-vcombine.c
  clang/test/CodeGen/aarch64-neon-vget-hilo.c
  clang/test/CodeGen/aarch64-neon-vget.c
  clang/test/CodeGen/aarch64-poly128.c
  clang/test/CodeGen/aarch64-poly64.c
  clang/test/CodeGen/aarch64-varargs.c
  clang/test/CodeGen/address-space-avr.c
  clang/test/CodeGen/address-space-field1.c
  clang/test/CodeGen/address-space.c
  clang/test/CodeGen/aggregate-assign-call.c
  clang/test/CodeGen/aix-return.c
  clang/test/CodeGen/aix-struct-arg.c
  clang/test/CodeGen/aix-vaargs.c
  clang/test/CodeGen/alias.c
  clang/test/CodeGen/align_value.cpp
  clang/test/CodeGen/alloc-align-attr.c
  clang/test/CodeGen/arc/arguments.c
  clang/test/CodeGen/arm-aapcs-vfp.c
  clang/test/CodeGen/arm-abi-vector.c
  clang/test/CodeGen/arm-arguments.c
  clang/test/CodeGen/arm-bf16-params-returns.c
  clang/test/CodeGen/arm-byval-align.c
  clang/test/CodeGen/arm-cmse-attr.c
  clang/test/CodeGen/arm-cmse-call.c
  clang/test/CodeGen/arm-float-helpers.c
  clang/test/CodeGen/arm-fp16-arguments.c
  clang/test/CodeGen/arm-homogenous.c
  clang/test/CodeGen/arm-mangle-bf16.cpp
  clang/test/CodeGen/arm-mve-intrinsics/vld24.c
  clang/test/CodeGen/arm-neon-directed-rounding.c
  clang/test/CodeGen/arm-neon-dot-product.c
  clang/test/CodeGen/arm-neon-fma.c
  clang/test/CodeGen/arm-neon-numeric-maxmin.c
  clang/test/CodeGen/arm-neon-vcvtX.c
  clang/test/CodeGen/arm-swiftcall.c
  clang/test/CodeGen/arm-varargs.c
  clang/test/CodeGen/arm-vector-arguments.c
  clang/test/CodeGen/arm-vfp16-arguments.c
  clang/test/CodeGen/arm-vfp16-arguments2.cpp
  clang/test/CodeGen/arm64-aapcs-arguments.c
  clang/test/CodeGen/arm64-abi-vector.c
  clang/test/CodeGen/arm64-arguments.c
  clang/test/CodeGen/arm64-microsoft-arguments.cpp
  clang/test/CodeGen/arm64-microsoft-intrinsics.c
  clang/test/CodeGen/arm64_32-vaarg.c
  clang/test/CodeGen/arm64_32.c
  clang/test/CodeGen/arm64_vcopy.c
  clang/test/CodeGen/arm64_vdupq_n_f64.c
  clang/test/CodeGen/arm_neon_intrinsics.c
  clang/test/CodeGen/armv7k-abi.c
  clang/test/CodeGen/asm-label.c
  clang/test/CodeGen/assume-aligned-and-alloc-align-attributes.c
  clang/test/CodeGen/atomic-arm64.c
  clang/test/CodeGen/atomic-ops-libcall.c
  clang/test/CodeGen/atomic-ops.c
  clang/test/CodeGen/atomic_ops.c
  clang/test/CodeGen/atomics-inlining.c
  clang/test/CodeGen/attr-func-def.c
  clang/test/CodeGen/attr-naked.c
  clang/test/CodeGen/attr-no-tail.c
  clang/test/CodeGen/attr-nomerge.cpp
  clang/test/CodeGen/attr-optnone.c
  clang/test/CodeGen/attr-target-mv-func-ptrs.c
  clang/test/CodeGen/attr-target-mv-va-args.c
  clang/test/CodeGen/attr-target-mv.c
  clang/test/CodeGen/attr-x86-interrupt.c
  clang/test/CodeGen/attributes.c
  clang/test/CodeGen/available-externally-hidden.cpp
  clang/test/CodeGen/available-externally-suppress.c
  clang/test/CodeGen/avx2-builtins.c
  clang/test/CodeGen/avx512-reduceMinMaxIntrin.c
  clang/test/CodeGen/big-atomic-ops.c
  clang/test/CodeGen/bittest-intrin.c
  clang/test/CodeGen/blocks.c
  clang/test/CodeGen/bool-convert.c
  clang/test/CodeGen/builtin-align-array.c
  clang/test/CodeGen/builtin-align.c
  clang/test/CodeGen/builtin-assume-aligned.c
  clang/test/C

[PATCH] D78704: [analyzer][NFC] Add unittest for FalsePositiveRefutationBRVisitor

2020-07-29 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added inline comments.



Comment at: 
clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp:19
+#include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h"
+#include "llvm/Config/config.h"
+#include "gtest/gtest.h"

mgorny wrote:
> `config.h` is a private LLVM header and must not be used from clang.
I'm not a CMake profession, but shouldn't it be declared private to the LLVM 
target in the corresponding CMakeLists file then?

How do you query whether clang has built with Z3 or not @mgorny?
I'm including that header only for that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78704

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


[PATCH] D84831: [clang-tidy] Fix RedundantStringCStrCheck with r values

2020-07-29 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added a comment.
This revision is now accepted and ready to land.

> Passed test cases but failed in the real world as std::string has a non 
> trivial destructor so creates a CXXBindTemporaryExpr.

An idea for a future change: move the std::string mock from this test into a 
header that is shared across all tests that need a std::string. That will 
hopefully allow us to combine forces when curating the standard library mocks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84831

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


[PATCH] D82739: [clangd] Improve heuristic resolution of dependent types in TargetFinder

2020-07-29 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/FindTarget.cpp:172
 std::vector resolveDependentExprToDecls(const Expr *E) {
   assert(E->isTypeDependent());
   if (const auto *ME = dyn_cast(E)) {

hokein wrote:
> @nridge, the assertion is not true anymore, since we have extended it to 
> support possibly-non-dependent expressions (`callExpr`, `MemberExpr`). 
> 
> we hit this assert when opening 
> `clang/include/clang/ASTMatchers/ASTMatchers.h`. I think we probably need to 
> remove it and rename related function names.
a reduce case:

```
template
class Foo {
public:
int foo();
};

class Bar {
public:
static void k();
template  T convert() const;
};

void func();
template 
void foo2(Foo t) {
Bar::k(t.foo()).template convert();
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82739

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


[PATCH] D84814: [clang-tidy] readability-identifier-naming checks configs for included files

2020-07-29 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h:76
+  /// Stores the style options for a given directory.
+  mutable llvm::StringMap>>
+  NamingStylesCache;

And could you please document what the indices for the vector are?



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-multiple-styles.cpp:7
+
+// C++11 isnt explicitly required, but failing to specify a standard means the
+// check will run multiple times for different standards. This will cause the

"isn't"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84814

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


[PATCH] D82898: [clang-tidy] Handled insertion only fixits when determining conflicts.

2020-07-29 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LG!




Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp:703
+  Apply[Event.ErrorId] = false;
+continue;
+  case Event::ET_Insert:

njames93 wrote:
> aaron.ballman wrote:
> > Similar here with `continue` and the unreachable.
> As this is in a loop, I'm torn whether using `break` makes it less readable. 
> WDYT?
I tend to prefer `break` to `continue` because it's terribly easy to miss the 
fact that the `switch` statement is continuing the loop should someone decide 
they want to stick some code below the `switch` but within the loop for some 
reason.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82898

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


[PATCH] D84658: [clang] Overload NamedDecl::printName to provide a user-friendly name for unnamed entities

2020-07-29 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, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84658

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


[PATCH] D84473: Dump Accumulator

2020-07-29 Thread James Henderson via Phabricator via cfe-commits
jhenderson requested changes to this revision.
jhenderson added a comment.
This revision now requires changes to proceed.

I'm assuming you need llvm-readobj to test your changes? In which case, the 
llvm-readobj change needs to come first, and then you can write tests using it 
to test this change (at the moment, the testing for this seems insufficient to 
me). Do you have a patch yet for the llvm-readobj side?

Could you add some documentation somewhere, either in code comments or 
somewhere else, explaining the output format you actually want this to be? From 
my casual reading (I'm not the most knowledgeable of people in this area), it 
looks like you're creating an ELF SHT_NOTE section, but don't use the SHT_NOTE 
ELF format (see 
https://www.sco.com/developers/gabi/latest/ch5.pheader.html#note_section for 
details). I would actually expect this to emit a section with a new section 
type, so that the consumer (llvm-readobj) can more easily identify it. 
Alternatively, it could just be a basic SHT_NOTE section, with a specific note 
type. Under no circumstances should consumers need to check the section header 
name to identify the section (string comparisons are expensive, and should be 
avoided where possible - the general intent for ELF is for different kinds of 
sections to be distinguished by their types and flags).




Comment at: llvm/include/llvm/Analysis/DumpAccumulator.h:56
+
+#include 
+

Spurious include?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84473

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


[PATCH] D84678: [clang] False line number in a function definition with "void" parameter

2020-07-29 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Sema/SemaType.cpp:5112
 if (FTI.NumParams != 1 || FTI.isVariadic) {
-  S.Diag(DeclType.Loc, diag::err_void_only_param);
+  S.Diag(FTI.Params[i].IdentLoc, diag::err_void_only_param);
   ParamTy = Context.IntTy;

Are you sure that all parameters will have a valid `IdentLoc`? I am worried 
about the common case where the `void` parameter is unnamed.



Comment at: clang/test/Sema/void-argument.cpp:9
+void f) // expected-error{{'void' must be the first and only parameter if 
specified}}
+{}

I'd like to see some additional testing:
```
void foo(
  int a,
  void,
  int b
);

void bar(
  void,
  ...
);

struct S {
  S(
void,
void
  );
};
```


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

https://reviews.llvm.org/D84678

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


[PATCH] D84005: Introduce ns_error_domain attribute.

2020-07-29 Thread Michael Forster via Phabricator via cfe-commits
MForster updated this revision to Diff 281525.
MForster marked 4 inline comments as done.
MForster added a comment.

Store the VarDecl instead of the identifier


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84005

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/ns_error_enum.m

Index: clang/test/Sema/ns_error_enum.m
===
--- /dev/null
+++ clang/test/Sema/ns_error_enum.m
@@ -0,0 +1,66 @@
+// RUN: %clang_cc1 -verify %s -x objective-c
+// RUN: %clang_cc1 -verify %s -x objective-c++
+
+
+#define CF_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
+#define NS_ENUM(_type, _name) CF_ENUM(_type, _name)
+
+#define NS_ERROR_ENUM(_type, _name, _domain)  \
+  enum _name : _type _name; enum __attribute__((ns_error_domain(_domain))) _name : _type
+
+typedef NS_ENUM(unsigned, MyEnum) {
+  MyFirst,
+  MySecond,
+};
+
+typedef NS_ENUM(invalidType, MyInvalidEnum) {
+// expected-error@-1{{unknown type name 'invalidType'}}
+// expected-error@-2{{unknown type name 'invalidType'}}
+  MyFirstInvalid,
+  MySecondInvalid,
+};
+
+@interface NSString
+@end
+
+extern NSString *const MyErrorDomain;
+typedef NS_ERROR_ENUM(unsigned char, MyErrorEnum, MyErrorDomain) {
+	MyErrFirst,
+	MyErrSecond,
+};
+
+typedef NSString *const NsErrorDomain;
+extern NsErrorDomain MyTypedefErrorDomain;
+typedef NS_ERROR_ENUM(unsigned char, MyTypedefErrorEnum, MyTypedefErrorDomain) {
+  MyTypedefErrFirst,
+  MyTypedefErrSecond,
+};
+
+extern char *const WrongErrorDomainType;
+enum __attribute__((ns_error_domain(WrongErrorDomainType))) MyWrongErrorDomainType { MyWrongErrorDomain };
+// expected-error@-1{{domain argument 'WrongErrorDomainType' does not point to an NSString constant}}
+
+struct __attribute__((ns_error_domain(MyErrorDomain))) MyStructWithErrorDomain {};
+// expected-error@-1{{'ns_error_domain' attribute only applies to enums}}
+
+int __attribute__((ns_error_domain(MyErrorDomain))) NotTagDecl;
+  // expected-error@-1{{'ns_error_domain' attribute only applies to enums}}
+
+enum __attribute__((ns_error_domain())) NoArg { NoArgError };
+// expected-error@-1{{'ns_error_domain' attribute takes one argument}}
+
+enum __attribute__((ns_error_domain(MyErrorDomain, MyErrorDomain))) TwoArgs { TwoArgsError };
+// expected-error@-1{{'ns_error_domain' attribute takes one argument}}
+
+typedef NS_ERROR_ENUM(unsigned char, MyErrorEnumInvalid, InvalidDomain) {
+	// expected-error@-1{{use of undeclared identifier 'InvalidDomain'}}
+	MyErrFirstInvalid,
+	MyErrSecondInvalid,
+};
+
+typedef NS_ERROR_ENUM(unsigned char, MyErrorEnumInvalid, "domain-string");
+  // expected-error@-1{{domain argument does not refer to global constant}}
+
+void foo() {}
+typedef NS_ERROR_ENUM(unsigned char, MyErrorEnumInvalidFunction, foo);
+  // expected-error@-1{{domain argument 'foo' does not refer to global constant}}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -80,6 +80,7 @@
 // CHECK-NEXT: MipsShortCall (SubjectMatchRule_function)
 // CHECK-NEXT: NSConsumed (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: NSConsumesSelf (SubjectMatchRule_objc_method)
+// CHECK-NEXT: NSErrorDomain (SubjectMatchRule_enum)
 // CHECK-NEXT: Naked (SubjectMatchRule_function)
 // CHECK-NEXT: NoBuiltin (SubjectMatchRule_function)
 // CHECK-NEXT: NoCommon (SubjectMatchRule_variable)
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -21,6 +21,7 @@
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/Mangle.h"
 #include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/AST/Type.h"
 #include "clang/Basic/CharInfo.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TargetBuiltins.h"
@@ -30,12 +31,15 @@
 #include "clang/Sema/DelayedDiagnostic.h"
 #include "clang/Sema/Initialization.h"
 #include "clang/Sema/Lookup.h"
+#include "clang/Sema/ParsedAttr.h"
 #include "clang/Sema/Scope.h"
 #include "clang/Sema/ScopeInfo.h"
 #include "clang/Sema/SemaInternal.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/MathExtras.h"
+#include "llvm/Support/raw_ostream.h"
 
 using namespace clang;
 using namespace sema;
@@ -5322,6 +5326,42 @@
   D->addAttr(::new (S.Context) ObjCRequiresSuperAttr(S.Context, Attrs));
 }
 
+static void handleNSErrorDomain(Sema &S, Decl *D, const ParsedAttr &AL) {
+  auto *E = AL.g

[PATCH] D84005: Introduce ns_error_domain attribute.

2020-07-29 Thread Michael Forster via Phabricator via cfe-commits
MForster added inline comments.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:5350
+
+  D->addAttr(::new (S.Context)
+ NSErrorDomainAttr(S.Context, AL, IdentLoc->Ident));

aaron.ballman wrote:
> MForster wrote:
> > aaron.ballman wrote:
> > > Shouldn't we also be validating that what we found is an NSString that 
> > > has the correct properties? (That doesn't seem like it should be a change 
> > > which risks breaking code based on what I understood from Doug's 
> > > description.)
> > > Shouldn't we also be validating that what we found is an NSString that 
> > > has the correct properties?
> > 
> > Is your suggestion to string-compare the name of the type?
> >>Shouldn't we also be validating that what we found is an NSString that has 
> >>the correct properties?
> > Is your suggestion to string-compare the name of the type?
> 
> You should be able to compare the `QualType` of the resulting `VarDecl` 
> against `ASTContext::getObjCNSStringType()` (accounting for qualifiers, 
> pointers, etc).
Turns out that this didn't work well. `ASTContext::getObjCNSStringType()` is 
only initialized if ObjC string literals are instantiated without an `NSString` 
type being defined. In our case there is an `NSString` type, because we need to 
declare a global variable of that type.

I've resorted to a string comparison after all.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84005

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


[PATCH] D84837: [clangd] Fix an assertion failure in TargetFinder's heuristic resolution of dependent type.

2020-07-29 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: nridge.
Herald added subscribers: usaxena95, kadircet, arphaman, jkorous.
Herald added a project: clang.
hokein requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

The assertion is not true anymore after D82739 
, this patch just removes
it, and rename related functions.

And also fixes a missing cases.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84837

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp

Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -627,6 +627,20 @@
 };
   )cpp";
   EXPECT_DECLS("CXXDependentScopeMemberExpr", "int ");
+
+  Code = R"cpp(
+class Foo {
+public:
+  static Foo k(int);
+  template  T convert() const;
+};
+template 
+void test() {
+  Foo::k(T()).template [[convert]]();
+}
+  )cpp";
+  EXPECT_DECLS("CXXDependentScopeMemberExpr",
+   "template  T convert() const");
 }
 
 TEST_F(TargetDeclTest, ObjC) {
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -163,13 +163,12 @@
 }
 
 // Forward declaration, needed as this function is mutually recursive
-// with resolveDependentExprToDecls.
-const Type *resolveDependentExprToType(const Expr *E);
+// with resolveExprToDecls.
+const Type *resolveExprToType(const Expr *E);
 
-// Try to heuristically resolve a dependent expression `E` to one
+// Try to heuristically resolve a possibly-dependent expression `E` to one
 // or more declarations that it likely references.
-std::vector resolveDependentExprToDecls(const Expr *E) {
-  assert(E->isTypeDependent());
+std::vector resolveExprToDecls(const Expr *E) {
   if (const auto *ME = dyn_cast(E)) {
 const Type *BaseType = ME->getBaseType().getTypePtrOrNull();
 if (ME->isArrow()) {
@@ -183,7 +182,7 @@
   // can get further by analyzing the depedent expression.
   Expr *Base = ME->isImplicitAccess() ? nullptr : ME->getBase();
   if (Base && BT->getKind() == BuiltinType::Dependent) {
-BaseType = resolveDependentExprToType(Base);
+BaseType = resolveExprToType(Base);
   }
 }
 return getMembersReferencedViaDependentName(
@@ -197,7 +196,7 @@
 /*IsNonstaticMember=*/false);
   }
   if (const auto *CE = dyn_cast(E)) {
-const auto *CalleeType = resolveDependentExprToType(CE->getCallee());
+const auto *CalleeType = resolveExprToType(CE->getCallee());
 if (!CalleeType)
   return {};
 if (const auto *FnTypePtr = CalleeType->getAs())
@@ -209,15 +208,16 @@
   }
 }
   }
-  if (const auto *ME = dyn_cast(E)) {
+  if (const auto *ME = dyn_cast(E))
 return {ME->getMemberDecl()};
-  }
+  if (const auto *DRE = dyn_cast(E))
+return {DRE->getFoundDecl()};
   return {};
 }
 
-// Try to heuristically resolve the type of a dependent expression `E`.
-const Type *resolveDependentExprToType(const Expr *E) {
-  std::vector Decls = resolveDependentExprToDecls(E);
+// Try to heuristically resolve the type of a possibly-dependent expression `E`.
+const Type *resolveExprToType(const Expr *E) {
+  std::vector Decls = resolveExprToDecls(E);
   if (Decls.size() != 1) // Names an overload set -- just bail.
 return nullptr;
   if (const auto *TD = dyn_cast(Decls[0])) {
@@ -426,12 +426,12 @@
   }
   void
   VisitCXXDependentScopeMemberExpr(const CXXDependentScopeMemberExpr *E) {
-for (const NamedDecl *D : resolveDependentExprToDecls(E)) {
+for (const NamedDecl *D : resolveExprToDecls(E)) {
   Outer.add(D, Flags);
 }
   }
   void VisitDependentScopeDeclRefExpr(const DependentScopeDeclRefExpr *E) {
-for (const NamedDecl *D : resolveDependentExprToDecls(E)) {
+for (const NamedDecl *D : resolveExprToDecls(E)) {
   Outer.add(D, Flags);
 }
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84005: Introduce ns_error_domain attribute.

2020-07-29 Thread Michael Forster via Phabricator via cfe-commits
MForster updated this revision to Diff 281531.
MForster added a comment.

Rebase against master


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84005

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/ns_error_enum.m

Index: clang/test/Sema/ns_error_enum.m
===
--- /dev/null
+++ clang/test/Sema/ns_error_enum.m
@@ -0,0 +1,66 @@
+// RUN: %clang_cc1 -verify %s -x objective-c
+// RUN: %clang_cc1 -verify %s -x objective-c++
+
+
+#define CF_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
+#define NS_ENUM(_type, _name) CF_ENUM(_type, _name)
+
+#define NS_ERROR_ENUM(_type, _name, _domain)  \
+  enum _name : _type _name; enum __attribute__((ns_error_domain(_domain))) _name : _type
+
+typedef NS_ENUM(unsigned, MyEnum) {
+  MyFirst,
+  MySecond,
+};
+
+typedef NS_ENUM(invalidType, MyInvalidEnum) {
+// expected-error@-1{{unknown type name 'invalidType'}}
+// expected-error@-2{{unknown type name 'invalidType'}}
+  MyFirstInvalid,
+  MySecondInvalid,
+};
+
+@interface NSString
+@end
+
+extern NSString *const MyErrorDomain;
+typedef NS_ERROR_ENUM(unsigned char, MyErrorEnum, MyErrorDomain) {
+	MyErrFirst,
+	MyErrSecond,
+};
+
+typedef NSString *const NsErrorDomain;
+extern NsErrorDomain MyTypedefErrorDomain;
+typedef NS_ERROR_ENUM(unsigned char, MyTypedefErrorEnum, MyTypedefErrorDomain) {
+  MyTypedefErrFirst,
+  MyTypedefErrSecond,
+};
+
+extern char *const WrongErrorDomainType;
+enum __attribute__((ns_error_domain(WrongErrorDomainType))) MyWrongErrorDomainType { MyWrongErrorDomain };
+// expected-error@-1{{domain argument 'WrongErrorDomainType' does not point to an NSString constant}}
+
+struct __attribute__((ns_error_domain(MyErrorDomain))) MyStructWithErrorDomain {};
+// expected-error@-1{{'ns_error_domain' attribute only applies to enums}}
+
+int __attribute__((ns_error_domain(MyErrorDomain))) NotTagDecl;
+  // expected-error@-1{{'ns_error_domain' attribute only applies to enums}}
+
+enum __attribute__((ns_error_domain())) NoArg { NoArgError };
+// expected-error@-1{{'ns_error_domain' attribute takes one argument}}
+
+enum __attribute__((ns_error_domain(MyErrorDomain, MyErrorDomain))) TwoArgs { TwoArgsError };
+// expected-error@-1{{'ns_error_domain' attribute takes one argument}}
+
+typedef NS_ERROR_ENUM(unsigned char, MyErrorEnumInvalid, InvalidDomain) {
+	// expected-error@-1{{use of undeclared identifier 'InvalidDomain'}}
+	MyErrFirstInvalid,
+	MyErrSecondInvalid,
+};
+
+typedef NS_ERROR_ENUM(unsigned char, MyErrorEnumInvalid, "domain-string");
+  // expected-error@-1{{domain argument does not refer to global constant}}
+
+void foo() {}
+typedef NS_ERROR_ENUM(unsigned char, MyErrorEnumInvalidFunction, foo);
+  // expected-error@-1{{domain argument 'foo' does not refer to global constant}}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -80,6 +80,7 @@
 // CHECK-NEXT: MipsShortCall (SubjectMatchRule_function)
 // CHECK-NEXT: NSConsumed (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: NSConsumesSelf (SubjectMatchRule_objc_method)
+// CHECK-NEXT: NSErrorDomain (SubjectMatchRule_enum)
 // CHECK-NEXT: Naked (SubjectMatchRule_function)
 // CHECK-NEXT: NoBuiltin (SubjectMatchRule_function)
 // CHECK-NEXT: NoCommon (SubjectMatchRule_variable)
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -21,6 +21,7 @@
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/Mangle.h"
 #include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/AST/Type.h"
 #include "clang/Basic/CharInfo.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TargetBuiltins.h"
@@ -30,12 +31,15 @@
 #include "clang/Sema/DelayedDiagnostic.h"
 #include "clang/Sema/Initialization.h"
 #include "clang/Sema/Lookup.h"
+#include "clang/Sema/ParsedAttr.h"
 #include "clang/Sema/Scope.h"
 #include "clang/Sema/ScopeInfo.h"
 #include "clang/Sema/SemaInternal.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/MathExtras.h"
+#include "llvm/Support/raw_ostream.h"
 
 using namespace clang;
 using namespace sema;
@@ -5322,6 +5326,42 @@
   D->addAttr(::new (S.Context) ObjCRequiresSuperAttr(S.Context, Attrs));
 }
 
+static void handleNSErrorDomain(Sema &S, Decl *D, const ParsedAttr &AL) {
+  auto *E = AL.getArgAsExpr(0);
+  auto Loc = E ? E->getBeginLoc() : AL.getLoc();

[PATCH] D84473: Dump Accumulator

2020-07-29 Thread James Henderson via Phabricator via cfe-commits
jhenderson added a comment.

By the way, has the design of this been discussed on llvm-dev? It seems like 
something should have an RFC if it hasn't already.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84473

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


[PATCH] D84767: [OPENMP]Fix PR46824: Global declare target pointer cannot be accessed in target region.

2020-07-29 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D84767#2180433 , @ye-luo wrote:

> In D84767#2180280 , @ye-luo wrote:
>
>> This patch
>> GPU activities:   96.99%  350.05ms10  35.005ms  1.5680us  350.00ms  
>> [CUDA memcpy HtoD]
>> before the July21 change
>> GPU activities:   95.33%  20.317ms 4  5.0793ms  1.6000us  20.305ms  
>> [CUDA memcpy HtoD]
>> Still more transfer than it should.
>
> @ABataev could you have a look? My July 21 compiler was built before 
> "[OPENMP]Fix PR46012: declare target pointer cannot be accessed in target 
> region." gets in.

Are you talking about the `number of calls` value? The total number of calls 
will increase after the patch anyway, PTR_AND_OBJ adds 1 extra mem transfer for 
transferring translated pointer address.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84767

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


[PATCH] D84839: Add document outline symbols from unnamed contexts, e.g. extern "C".

2020-07-29 Thread Ilya Golovenko via Phabricator via cfe-commits
ilya-golovenko created this revision.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous.
Herald added a project: clang.
ilya-golovenko requested review of this revision.

It is necessary to traverse children of unnamed declaration contexts
to get symbols which are currently missing in document outline, e.g.:

extern "C" {
void foo();
}


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84839

Files:
  clang-tools-extra/clangd/FindSymbols.cpp
  clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp


Index: clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -429,6 +429,26 @@
   EXPECT_THAT(getSymbols(TU.build()), IsEmpty());
 }
 
+TEST(DocumentSymbols, ExternContext) {
+  TestTU TU;
+  TU.Code = R"cpp(
+  extern "C" {
+  void foo();
+  class Foo {};
+  }
+  namespace ns {
+extern "C" {
+void bar();
+class Bar {};
+}
+  })cpp";
+
+  EXPECT_THAT(getSymbols(TU.build()),
+  ElementsAre(WithName("foo"), WithName("Foo"),
+  AllOf(WithName("ns"),
+Children(WithName("bar"), WithName("Bar");
+}
+
 TEST(DocumentSymbols, NoLocals) {
   TestTU TU;
   TU.Code = R"cpp(
Index: clang-tools-extra/clangd/FindSymbols.cpp
===
--- clang-tools-extra/clangd/FindSymbols.cpp
+++ clang-tools-extra/clangd/FindSymbols.cpp
@@ -197,8 +197,11 @@
 D = TD;
 }
 auto *ND = llvm::dyn_cast(D);
-if (!ND)
+if (!ND) {
+  // Traverse children of unnamed contexts, e.g. extern "C".
+  traverseChildren(D, Results);
   return;
+}
 VisitKind Visit = shouldVisit(ND);
 if (Visit == VisitKind::No)
   return;


Index: clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -429,6 +429,26 @@
   EXPECT_THAT(getSymbols(TU.build()), IsEmpty());
 }
 
+TEST(DocumentSymbols, ExternContext) {
+  TestTU TU;
+  TU.Code = R"cpp(
+  extern "C" {
+  void foo();
+  class Foo {};
+  }
+  namespace ns {
+extern "C" {
+void bar();
+class Bar {};
+}
+  })cpp";
+
+  EXPECT_THAT(getSymbols(TU.build()),
+  ElementsAre(WithName("foo"), WithName("Foo"),
+  AllOf(WithName("ns"),
+Children(WithName("bar"), WithName("Bar");
+}
+
 TEST(DocumentSymbols, NoLocals) {
   TestTU TU;
   TU.Code = R"cpp(
Index: clang-tools-extra/clangd/FindSymbols.cpp
===
--- clang-tools-extra/clangd/FindSymbols.cpp
+++ clang-tools-extra/clangd/FindSymbols.cpp
@@ -197,8 +197,11 @@
 D = TD;
 }
 auto *ND = llvm::dyn_cast(D);
-if (!ND)
+if (!ND) {
+  // Traverse children of unnamed contexts, e.g. extern "C".
+  traverseChildren(D, Results);
   return;
+}
 VisitKind Visit = shouldVisit(ND);
 if (Visit == VisitKind::No)
   return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D66035: [WebAssembly] WIP: Add support for reference types

2020-07-29 Thread Paulo Matos via Phabricator via cfe-commits
pmatos updated this revision to Diff 281540.
pmatos added a comment.

Update patch to compile against current master branch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66035

Files:
  .gitlab-ci.yml
  lld/wasm/WriterUtils.cpp
  llvm/include/llvm/BinaryFormat/Wasm.h
  llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
  llvm/test/CodeGen/WebAssembly/externref.ll


Index: llvm/test/CodeGen/WebAssembly/externref.ll
===
--- llvm/test/CodeGen/WebAssembly/externref.ll
+++ llvm/test/CodeGen/WebAssembly/externref.ll
@@ -9,7 +9,7 @@
 ; CHECK-LABEL: call_test:
 ; CHECK: .functype   call_test (externref) -> (externref)
 define i8 addrspace(256)* @call_test(i8 addrspace(256)*) {
-; CHECK: externref.call $push0=, test, $0
+; CHECK: call $push0=, test, $0
   %a = call i8 addrspace(256)* @test(i8 addrspace(256)* %0) 
   ret i8 addrspace(256)* %a
 }
Index: llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
===
--- llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
+++ llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
@@ -66,10 +66,6 @@
 Predicate<"Subtarget->hasReferenceTypes()">,
 AssemblerPredicate<(all_of FeatureReferenceTypes), "reference-types">;
 
-def HasReferenceTypes :
-Predicate<"Subtarget->hasReferenceTypes()">,
-AssemblerPredicate<"FeatureReferenceTypes", "reference-types">;
-
 
//===--===//
 // WebAssembly-specific DAG Node Types.
 
//===--===//
Index: llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
@@ -816,8 +816,6 @@
   ResultReg = createResultReg(&WebAssembly::EXNREFRegClass);
   break;
 case MVT::externref:
-  Opc = IsDirect ? WebAssembly::CALL_externref
- : WebAssembly::PCALL_INDIRECT_externref;
   ResultReg = createResultReg(&WebAssembly::EXTERNREFRegClass);
   break;
 default:
Index: llvm/include/llvm/BinaryFormat/Wasm.h
===
--- llvm/include/llvm/BinaryFormat/Wasm.h
+++ llvm/include/llvm/BinaryFormat/Wasm.h
@@ -231,7 +231,6 @@
   WASM_TYPE_F64 = 0x7C,
   WASM_TYPE_V128 = 0x7B,
   WASM_TYPE_FUNCREF = 0x70,
-  WASM_TYPE_EXTERNREF = 0x6F,
   WASM_TYPE_EXNREF = 0x68,
   WASM_TYPE_EXTERNREF = 0x6F,
   WASM_TYPE_FUNC = 0x60,
@@ -365,7 +364,6 @@
   FUNCREF = WASM_TYPE_FUNCREF,
   EXTERNREF = WASM_TYPE_EXTERNREF,
   EXNREF = WASM_TYPE_EXNREF,
-  EXTERNREF = WASM_TYPE_EXTERNREF,
 };
 
 struct WasmSignature {
Index: lld/wasm/WriterUtils.cpp
===
--- lld/wasm/WriterUtils.cpp
+++ lld/wasm/WriterUtils.cpp
@@ -36,8 +36,6 @@
 return "externref";
   case ValType::EXNREF:
 return "exnref";
-  case ValType::EXTERNREF:
-return "externref";
   }
   llvm_unreachable("Invalid wasm::ValType");
 }
Index: .gitlab-ci.yml
===
--- .gitlab-ci.yml
+++ /dev/null
@@ -1,17 +0,0 @@
-default:
-  image: debian:sid
-  before_script:
-- apt-get update
-- apt-get install -y git gcc cmake wget unzip g++ python libxml2-dev 
ninja-build python ruby python3-pip python3-psutil libz3-dev valgrind
-
-build-llvm:
-  tags:
-- linux
-- x86_64
-  script:
-- mkdir build
-- cd build
-- cmake -G 'Unix Makefiles' -DLLVM_TARGETS_TO_BUILD='X86;WebAssembly' 
-DLLVM_ENABLE_PROJECTS="clang;lld" -DCMAKE_BUILD_TYPE=Release 
-DLLVM_ENABLE_ASSERTIONS=On -DLLVM_BUILD_32_BITS=Off -DLLVM_ENABLE_BINDINGS=Off 
../llvm/
-- make -j$(nproc) -l$(nproc) 
-- make -j$(nproc) -l$(nproc) check-llvm-unit
-- make -j$(nproc) -l$(nproc) check-llvm


Index: llvm/test/CodeGen/WebAssembly/externref.ll
===
--- llvm/test/CodeGen/WebAssembly/externref.ll
+++ llvm/test/CodeGen/WebAssembly/externref.ll
@@ -9,7 +9,7 @@
 ; CHECK-LABEL: call_test:
 ; CHECK: .functype   call_test (externref) -> (externref)
 define i8 addrspace(256)* @call_test(i8 addrspace(256)*) {
-; CHECK: externref.call $push0=, test, $0
+; CHECK: call $push0=, test, $0
   %a = call i8 addrspace(256)* @test(i8 addrspace(256)* %0) 
   ret i8 addrspace(256)* %a
 }
Index: llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
===
--- llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
+++ llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
@@ -66,10 +66,6 @@
 Predicate<"Subtarget->hasReferen

[PATCH] D84005: Introduce ns_error_domain attribute.

2020-07-29 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added inline comments.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:5342
+S.Diag(Loc, diag::err_nserrordomain_invalid_decl)
+<< 1 << DRE->getNameInfo().getName();
+return;

Just send the declaration into the diagnostic. See the recent D84656 for the 
rationale.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:5358
+S.Diag(Loc, diag::err_nserrordomain_wrong_type)
+<< DRE->getNameInfo().getName();
+return;




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84005

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


[PATCH] D84839: Add document outline symbols from unnamed contexts, e.g. extern "C".

2020-07-29 Thread Ilya Golovenko via Phabricator via cfe-commits
ilya-golovenko updated this revision to Diff 281542.
ilya-golovenko added a comment.

Trigger new build


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84839

Files:
  clang-tools-extra/clangd/FindSymbols.cpp
  clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp


Index: clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -429,6 +429,26 @@
   EXPECT_THAT(getSymbols(TU.build()), IsEmpty());
 }
 
+TEST(DocumentSymbols, ExternContext) {
+  TestTU TU;
+  TU.Code = R"cpp(
+  extern "C" {
+  void foo();
+  class Foo {};
+  }
+  namespace ns {
+extern "C" {
+void bar();
+class Bar {};
+}
+  })cpp";
+
+  EXPECT_THAT(getSymbols(TU.build()),
+  ElementsAre(WithName("foo"), WithName("Foo"),
+  AllOf(WithName("ns"),
+Children(WithName("bar"), WithName("Bar");
+}
+
 TEST(DocumentSymbols, NoLocals) {
   TestTU TU;
   TU.Code = R"cpp(
Index: clang-tools-extra/clangd/FindSymbols.cpp
===
--- clang-tools-extra/clangd/FindSymbols.cpp
+++ clang-tools-extra/clangd/FindSymbols.cpp
@@ -197,8 +197,11 @@
 D = TD;
 }
 auto *ND = llvm::dyn_cast(D);
-if (!ND)
+if (!ND) {
+  // Traverse children of unnamed contexts, e.g. extern "C".
+  traverseChildren(D, Results);
   return;
+}
 VisitKind Visit = shouldVisit(ND);
 if (Visit == VisitKind::No)
   return;


Index: clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -429,6 +429,26 @@
   EXPECT_THAT(getSymbols(TU.build()), IsEmpty());
 }
 
+TEST(DocumentSymbols, ExternContext) {
+  TestTU TU;
+  TU.Code = R"cpp(
+  extern "C" {
+  void foo();
+  class Foo {};
+  }
+  namespace ns {
+extern "C" {
+void bar();
+class Bar {};
+}
+  })cpp";
+
+  EXPECT_THAT(getSymbols(TU.build()),
+  ElementsAre(WithName("foo"), WithName("Foo"),
+  AllOf(WithName("ns"),
+Children(WithName("bar"), WithName("Bar");
+}
+
 TEST(DocumentSymbols, NoLocals) {
   TestTU TU;
   TU.Code = R"cpp(
Index: clang-tools-extra/clangd/FindSymbols.cpp
===
--- clang-tools-extra/clangd/FindSymbols.cpp
+++ clang-tools-extra/clangd/FindSymbols.cpp
@@ -197,8 +197,11 @@
 D = TD;
 }
 auto *ND = llvm::dyn_cast(D);
-if (!ND)
+if (!ND) {
+  // Traverse children of unnamed contexts, e.g. extern "C".
+  traverseChildren(D, Results);
   return;
+}
 VisitKind Visit = shouldVisit(ND);
 if (Visit == VisitKind::No)
   return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75184: [clang-tidy] Optional inheritance of file configs from parent directories 

2020-07-29 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin added inline comments.



Comment at: clang-tools-extra/clang-tidy/ClangTidyOptions.cpp:116-121
+  unsigned Priority = 0;
   for (ClangTidyModuleRegistry::iterator I = ClangTidyModuleRegistry::begin(),
  E = ClangTidyModuleRegistry::end();
I != E; ++I)
-Options = Options.mergeWith(I->instantiate()->getModuleOptions());
+Options =
+Options.mergeWith(I->instantiate()->getModuleOptions(), ++Priority);

njames93 wrote:
> Is there a reason for incrementing the priority on each successive iteration, 
> Seems like a bug that will lead to the later registered modules having higher 
> priority for their options.
It seems that you are right and it is just a bug. Modules are registered as 
static object in different translation units so there is no guarantee about 
their order. But in general I didn't expect conflicting options here. If you 
have a diff, I'll be happy to stamp it; if not, I'll create the diff.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75184

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


[PATCH] D84839: Add document outline symbols from unnamed contexts, e.g. extern "C".

2020-07-29 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/FindSymbols.cpp:200
 auto *ND = llvm::dyn_cast(D);
-if (!ND)
+if (!ND) {
+  // Traverse children of unnamed contexts, e.g. extern "C".

this will result in traversal of other declcontexts like block/capturedecls.

i think we should rather change the VisitKind to `{No, Decl, Children}` and 
then make `shouldVisit` return a `VisitKindSet` and take a `Decl*` instead of a 
`NamedDecl`.
Later on we should first check for `LinkageSpecDecl` and return `Children` only 
while keeping the rest of the logic the same (i.e. try to cast to nameddecl and 
return `No` if it fails.
Finally logic in here should also be adjusted accordingly to visit children and 
the decl itself separately.

Do you have other cases apart from extern'd symbols?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84839

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


[PATCH] D78704: [analyzer][NFC] Add unittest for FalsePositiveRefutationBRVisitor

2020-07-29 Thread Whisperity via Phabricator via cfe-commits
whisperity added inline comments.



Comment at: 
clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp:19
+#include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h"
+#include "llvm/Config/config.h"
+#include "gtest/gtest.h"

steakhal wrote:
> mgorny wrote:
> > `config.h` is a private LLVM header and must not be used from clang.
> I'm not a CMake profession, but shouldn't it be declared private to the LLVM 
> target in the corresponding CMakeLists file then?
> 
> How do you query whether clang has built with Z3 or not @mgorny?
> I'm including that header only for that.
I've did a quick skim of the code, and it seems there is no way in it currently 
to query this.
Your best bet would be either adding an extra flag to Clang's CMake generated 
Config header that inherits this flag, or checking `llvm::CreateZ3Solver()` - 
right now, this method reports a fatal error, but you could create a bool 
function in the header which reports constant true or false, and turn the 
test's skip into a runtime condition?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78704

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


[PATCH] D84005: Introduce ns_error_domain attribute.

2020-07-29 Thread Michael Forster via Phabricator via cfe-commits
MForster updated this revision to Diff 281546.
MForster added a comment.

Use declaration in diagnostics instead of name


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84005

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/ns_error_enum.m

Index: clang/test/Sema/ns_error_enum.m
===
--- /dev/null
+++ clang/test/Sema/ns_error_enum.m
@@ -0,0 +1,66 @@
+// RUN: %clang_cc1 -verify %s -x objective-c
+// RUN: %clang_cc1 -verify %s -x objective-c++
+
+
+#define CF_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
+#define NS_ENUM(_type, _name) CF_ENUM(_type, _name)
+
+#define NS_ERROR_ENUM(_type, _name, _domain)  \
+  enum _name : _type _name; enum __attribute__((ns_error_domain(_domain))) _name : _type
+
+typedef NS_ENUM(unsigned, MyEnum) {
+  MyFirst,
+  MySecond,
+};
+
+typedef NS_ENUM(invalidType, MyInvalidEnum) {
+// expected-error@-1{{unknown type name 'invalidType'}}
+// expected-error@-2{{unknown type name 'invalidType'}}
+  MyFirstInvalid,
+  MySecondInvalid,
+};
+
+@interface NSString
+@end
+
+extern NSString *const MyErrorDomain;
+typedef NS_ERROR_ENUM(unsigned char, MyErrorEnum, MyErrorDomain) {
+	MyErrFirst,
+	MyErrSecond,
+};
+
+typedef NSString *const NsErrorDomain;
+extern NsErrorDomain MyTypedefErrorDomain;
+typedef NS_ERROR_ENUM(unsigned char, MyTypedefErrorEnum, MyTypedefErrorDomain) {
+  MyTypedefErrFirst,
+  MyTypedefErrSecond,
+};
+
+extern char *const WrongErrorDomainType;
+enum __attribute__((ns_error_domain(WrongErrorDomainType))) MyWrongErrorDomainType { MyWrongErrorDomain };
+// expected-error@-1{{domain argument 'WrongErrorDomainType' does not point to an NSString constant}}
+
+struct __attribute__((ns_error_domain(MyErrorDomain))) MyStructWithErrorDomain {};
+// expected-error@-1{{'ns_error_domain' attribute only applies to enums}}
+
+int __attribute__((ns_error_domain(MyErrorDomain))) NotTagDecl;
+  // expected-error@-1{{'ns_error_domain' attribute only applies to enums}}
+
+enum __attribute__((ns_error_domain())) NoArg { NoArgError };
+// expected-error@-1{{'ns_error_domain' attribute takes one argument}}
+
+enum __attribute__((ns_error_domain(MyErrorDomain, MyErrorDomain))) TwoArgs { TwoArgsError };
+// expected-error@-1{{'ns_error_domain' attribute takes one argument}}
+
+typedef NS_ERROR_ENUM(unsigned char, MyErrorEnumInvalid, InvalidDomain) {
+	// expected-error@-1{{use of undeclared identifier 'InvalidDomain'}}
+	MyErrFirstInvalid,
+	MyErrSecondInvalid,
+};
+
+typedef NS_ERROR_ENUM(unsigned char, MyErrorEnumInvalid, "domain-string");
+  // expected-error@-1{{domain argument does not refer to global constant}}
+
+void foo() {}
+typedef NS_ERROR_ENUM(unsigned char, MyErrorEnumInvalidFunction, foo);
+  // expected-error@-1{{domain argument 'foo' does not refer to global constant}}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -80,6 +80,7 @@
 // CHECK-NEXT: MipsShortCall (SubjectMatchRule_function)
 // CHECK-NEXT: NSConsumed (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: NSConsumesSelf (SubjectMatchRule_objc_method)
+// CHECK-NEXT: NSErrorDomain (SubjectMatchRule_enum)
 // CHECK-NEXT: Naked (SubjectMatchRule_function)
 // CHECK-NEXT: NoBuiltin (SubjectMatchRule_function)
 // CHECK-NEXT: NoCommon (SubjectMatchRule_variable)
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -21,6 +21,7 @@
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/Mangle.h"
 #include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/AST/Type.h"
 #include "clang/Basic/CharInfo.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TargetBuiltins.h"
@@ -30,12 +31,15 @@
 #include "clang/Sema/DelayedDiagnostic.h"
 #include "clang/Sema/Initialization.h"
 #include "clang/Sema/Lookup.h"
+#include "clang/Sema/ParsedAttr.h"
 #include "clang/Sema/Scope.h"
 #include "clang/Sema/ScopeInfo.h"
 #include "clang/Sema/SemaInternal.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/MathExtras.h"
+#include "llvm/Support/raw_ostream.h"
 
 using namespace clang;
 using namespace sema;
@@ -5322,6 +5326,40 @@
   D->addAttr(::new (S.Context) ObjCRequiresSuperAttr(S.Context, Attrs));
 }
 
+static void handleNSErrorDomain(Sema &S, Decl *D, const ParsedAttr &AL) {
+  auto *E = AL.getArgAsExpr(0);
+  auto Loc = E ? E->get

[PATCH] D83281: [OpenMP] Allow traits for the OpenMP context selector `isa`

2020-07-29 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG with a nit.




Comment at: clang/lib/AST/OpenMPClause.cpp:2304-2306
+  auto it = FeatureMap.find(RawString);
+  if (it != FeatureMap.end())
+return it->second;

`It`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83281

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


[clang] d1a3396 - [Driver][ARM] Disable unsupported features when nofp arch extension is used

2020-07-29 Thread Victor Campos via cfe-commits

Author: Victor Campos
Date: 2020-07-29T14:13:22+01:00
New Revision: d1a3396bfbc6fd6df927f2864c18d86e742cabff

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

LOG: [Driver][ARM] Disable unsupported features when nofp arch extension is used

A list of target features is disabled when there is no hardware
floating-point support. This is the case when one of the following
options is passed to clang:

 - -mfloat-abi=soft
 - -mfpu=none

This option list is missing, however, the extension "+nofp" that can be
specified in -march flags, such as "-march=armv8-a+nofp".

This patch also disables unsupported target features when nofp is passed
to -march.

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

Added: 
clang/test/Driver/arm-nofp-disabled-features.c

Modified: 
clang/lib/Driver/ToolChains/Arch/ARM.cpp
clang/test/CodeGen/arm-bf16-softfloat.c
llvm/include/llvm/Support/ARMTargetParser.h
llvm/lib/Support/ARMTargetParser.cpp
llvm/unittests/Support/TargetParserTest.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp 
b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
index afe896b4a65b..d74d5db0c083 100644
--- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -73,14 +73,15 @@ static unsigned getARMFPUFeatures(const Driver &D, const 
Arg *A,
 }
 
 // Decode ARM features from string like +[no]featureA+[no]featureB+...
-static bool DecodeARMFeatures(const Driver &D, StringRef text,
-  StringRef CPU, llvm::ARM::ArchKind ArchKind,
-  std::vector &Features) {
+static bool DecodeARMFeatures(const Driver &D, StringRef text, StringRef CPU,
+  llvm::ARM::ArchKind ArchKind,
+  std::vector &Features,
+  unsigned &ArgFPUID) {
   SmallVector Split;
   text.split(Split, StringRef("+"), -1, false);
 
   for (StringRef Feature : Split) {
-if (!appendArchExtFeatures(CPU, ArchKind, Feature, Features))
+if (!appendArchExtFeatures(CPU, ArchKind, Feature, Features, ArgFPUID))
   return false;
   }
   return true;
@@ -102,14 +103,14 @@ static void DecodeARMFeaturesFromCPU(const Driver &D, 
StringRef CPU,
 static void checkARMArchName(const Driver &D, const Arg *A, const ArgList 
&Args,
  llvm::StringRef ArchName, llvm::StringRef CPUName,
  std::vector &Features,
- const llvm::Triple &Triple) {
+ const llvm::Triple &Triple, unsigned &ArgFPUID) {
   std::pair Split = ArchName.split("+");
 
   std::string MArch = arm::getARMArch(ArchName, Triple);
   llvm::ARM::ArchKind ArchKind = llvm::ARM::parseArch(MArch);
   if (ArchKind == llvm::ARM::ArchKind::INVALID ||
-  (Split.second.size() && !DecodeARMFeatures(
-D, Split.second, CPUName, ArchKind, Features)))
+  (Split.second.size() && !DecodeARMFeatures(D, Split.second, CPUName,
+ ArchKind, Features, 
ArgFPUID)))
 D.Diag(clang::diag::err_drv_clang_unsupported) << A->getAsString(Args);
 }
 
@@ -117,15 +118,15 @@ static void checkARMArchName(const Driver &D, const Arg 
*A, const ArgList &Args,
 static void checkARMCPUName(const Driver &D, const Arg *A, const ArgList &Args,
 llvm::StringRef CPUName, llvm::StringRef ArchName,
 std::vector &Features,
-const llvm::Triple &Triple) {
+const llvm::Triple &Triple, unsigned &ArgFPUID) {
   std::pair Split = CPUName.split("+");
 
   std::string CPU = arm::getARMTargetCPU(CPUName, ArchName, Triple);
   llvm::ARM::ArchKind ArchKind =
 arm::getLLVMArchKindForARM(CPU, ArchName, Triple);
   if (ArchKind == llvm::ARM::ArchKind::INVALID ||
-  (Split.second.size() && !DecodeARMFeatures(
-D, Split.second, CPU, ArchKind, Features)))
+  (Split.second.size() &&
+   !DecodeARMFeatures(D, Split.second, CPU, ArchKind, Features, ArgFPUID)))
 D.Diag(clang::diag::err_drv_clang_unsupported) << A->getAsString(Args);
 }
 
@@ -347,6 +348,8 @@ void arm::getARMTargetFeatures(const Driver &D, const 
llvm::Triple &Triple,
   const Arg *CPUArg = Args.getLastArg(options::OPT_mcpu_EQ);
   StringRef ArchName;
   StringRef CPUName;
+  unsigned ArchArgFPUID = llvm::ARM::FK_INVALID;
+  unsigned CPUArgFPUID = llvm::ARM::FK_INVALID;
 
   // Check -mcpu. ClangAs gives preference to -Wa,-mcpu=.
   if (WaCPU) {
@@ -364,14 +367,14 @@ void arm::getARMTargetFeatures(const Driver &D, const 
llvm::Triple &Triple,
   D.Diag(clang::diag::warn_drv_unused_argument)
   << ArchArg->getAsString(Args);
 ArchName = StringRe

[PATCH] D82948: [Driver][ARM] Disable unsupported features when nofp arch extension is used

2020-07-29 Thread Victor Campos via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd1a3396bfbc6: [Driver][ARM] Disable unsupported features 
when nofp arch extension is used (authored by vhscampos).

Changed prior to commit:
  https://reviews.llvm.org/D82948?vs=280072&id=281549#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82948

Files:
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/test/CodeGen/arm-bf16-softfloat.c
  clang/test/Driver/arm-nofp-disabled-features.c
  llvm/include/llvm/Support/ARMTargetParser.h
  llvm/lib/Support/ARMTargetParser.cpp
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -668,9 +668,10 @@
 testArchExtDependency(const char *ArchExt,
   const std::initializer_list &Expected) {
   std::vector Features;
+  unsigned FPUID;
 
   if (!ARM::appendArchExtFeatures("", ARM::ArchKind::ARMV8_1MMainline, ArchExt,
-  Features))
+  Features, FPUID))
 return false;
 
   return llvm::all_of(Expected, [&](StringRef Ext) {
Index: llvm/lib/Support/ARMTargetParser.cpp
===
--- llvm/lib/Support/ARMTargetParser.cpp
+++ llvm/lib/Support/ARMTargetParser.cpp
@@ -490,9 +490,10 @@
   return ARM::FK_INVALID;
 }
 
-bool ARM::appendArchExtFeatures(
-  StringRef CPU, ARM::ArchKind AK, StringRef ArchExt,
-  std::vector &Features) {
+bool ARM::appendArchExtFeatures(StringRef CPU, ARM::ArchKind AK,
+StringRef ArchExt,
+std::vector &Features,
+unsigned &ArgFPUID) {
 
   size_t StartingNumFeatures = Features.size();
   const bool Negated = stripNegationPrefix(ArchExt);
@@ -527,6 +528,7 @@
 } else {
   FPUKind = getDefaultFPU(CPU, AK);
 }
+ArgFPUID = FPUKind;
 return ARM::getFPUFeatures(FPUKind, Features);
   }
   return StartingNumFeatures != Features.size();
Index: llvm/include/llvm/Support/ARMTargetParser.h
===
--- llvm/include/llvm/Support/ARMTargetParser.h
+++ llvm/include/llvm/Support/ARMTargetParser.h
@@ -250,7 +250,8 @@
 StringRef getArchExtName(uint64_t ArchExtKind);
 StringRef getArchExtFeature(StringRef ArchExt);
 bool appendArchExtFeatures(StringRef CPU, ARM::ArchKind AK, StringRef ArchExt,
-   std::vector &Features);
+   std::vector &Features,
+   unsigned &ArgFPUKind);
 StringRef getHWDivName(uint64_t HWDivKind);
 
 // Information by Name
Index: clang/test/Driver/arm-nofp-disabled-features.c
===
--- /dev/null
+++ clang/test/Driver/arm-nofp-disabled-features.c
@@ -0,0 +1,18 @@
+// RUN: %clang -target arm-arm-none-eabi -mfloat-abi=soft %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MFLOAT-ABI-SOFT
+// CHECK-MFLOAT-ABI-SOFT: "-target-feature" "-dotprod"
+// CHECK-MFLOAT-ABI-SOFT: "-target-feature" "-fp16fml"
+// CHECK-MFLOAT-ABI-SOFT: "-target-feature" "-bf16"
+// CHECK-MFLOAT-ABI-SOFT: "-target-feature" "-mve"
+// CHECK-MFLOAT-ABI-SOFT: "-target-feature" "-mve.fp"
+// CHECK-MFLOAT-ABI-SOFT: "-target-feature" "-fpregs"
+
+// RUN: %clang -target arm-arm-none-eabi -mfpu=none %s -### 2>&1 | FileCheck %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8-a+nofp %s -### 2>&1 | FileCheck %s
+// RUN: %clang -target arm-arm-none-eabi -mcpu=cortex-a35+nofp %s -### 2>&1 | FileCheck %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8-a+nofp+nomve %s -### 2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK-NOMVE
+// RUN: %clang -target arm-arm-none-eabi -mcpu=cortex-a35+nofp+nomve %s -### 2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK-NOMVE
+// CHECK: "-target-feature" "-dotprod"
+// CHECK: "-target-feature" "-fp16fml"
+// CHECK: "-target-feature" "-bf16"
+// CHECK: "-target-feature" "-mve.fp"
+// CHECK-NOMVE: "-target-feature" "-fpregs"
Index: clang/test/CodeGen/arm-bf16-softfloat.c
===
--- clang/test/CodeGen/arm-bf16-softfloat.c
+++ clang/test/CodeGen/arm-bf16-softfloat.c
@@ -1,4 +1,9 @@
-// RUN: not %clang -o %t.out -target arm-arm-eabi -march=armv8-a+bf16 -mfloat-abi=soft -c %s 2>&1 | FileCheck %s
+// RUN: not %clang -target arm-arm-none-eabi -march=armv8-a+bf16 -mfloat-abi=soft -c %s -o %t 2>&1 | FileCheck %s
+// RUN: not %clang -target arm-arm-none-eabi -march=armv8-a+bf16 -mfpu=none -c %s -o %t 2>&1 | FileCheck %s
+// RUN: not %clang -target arm-arm-none-eabi -march=armv8-a+bf16+nofp -c %s -o %t 2>&1 | FileCheck %

[PATCH] D84005: Introduce ns_error_domain attribute.

2020-07-29 Thread Michael Forster via Phabricator via cfe-commits
MForster updated this revision to Diff 281550.
MForster added a comment.

Apply ClangTidy suggestions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84005

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/ns_error_enum.m

Index: clang/test/Sema/ns_error_enum.m
===
--- /dev/null
+++ clang/test/Sema/ns_error_enum.m
@@ -0,0 +1,66 @@
+// RUN: %clang_cc1 -verify %s -x objective-c
+// RUN: %clang_cc1 -verify %s -x objective-c++
+
+
+#define CF_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
+#define NS_ENUM(_type, _name) CF_ENUM(_type, _name)
+
+#define NS_ERROR_ENUM(_type, _name, _domain)  \
+  enum _name : _type _name; enum __attribute__((ns_error_domain(_domain))) _name : _type
+
+typedef NS_ENUM(unsigned, MyEnum) {
+  MyFirst,
+  MySecond,
+};
+
+typedef NS_ENUM(invalidType, MyInvalidEnum) {
+// expected-error@-1{{unknown type name 'invalidType'}}
+// expected-error@-2{{unknown type name 'invalidType'}}
+  MyFirstInvalid,
+  MySecondInvalid,
+};
+
+@interface NSString
+@end
+
+extern NSString *const MyErrorDomain;
+typedef NS_ERROR_ENUM(unsigned char, MyErrorEnum, MyErrorDomain) {
+	MyErrFirst,
+	MyErrSecond,
+};
+
+typedef NSString *const NsErrorDomain;
+extern NsErrorDomain MyTypedefErrorDomain;
+typedef NS_ERROR_ENUM(unsigned char, MyTypedefErrorEnum, MyTypedefErrorDomain) {
+  MyTypedefErrFirst,
+  MyTypedefErrSecond,
+};
+
+extern char *const WrongErrorDomainType;
+enum __attribute__((ns_error_domain(WrongErrorDomainType))) MyWrongErrorDomainType { MyWrongErrorDomain };
+// expected-error@-1{{domain argument 'WrongErrorDomainType' does not point to an NSString constant}}
+
+struct __attribute__((ns_error_domain(MyErrorDomain))) MyStructWithErrorDomain {};
+// expected-error@-1{{'ns_error_domain' attribute only applies to enums}}
+
+int __attribute__((ns_error_domain(MyErrorDomain))) NotTagDecl;
+  // expected-error@-1{{'ns_error_domain' attribute only applies to enums}}
+
+enum __attribute__((ns_error_domain())) NoArg { NoArgError };
+// expected-error@-1{{'ns_error_domain' attribute takes one argument}}
+
+enum __attribute__((ns_error_domain(MyErrorDomain, MyErrorDomain))) TwoArgs { TwoArgsError };
+// expected-error@-1{{'ns_error_domain' attribute takes one argument}}
+
+typedef NS_ERROR_ENUM(unsigned char, MyErrorEnumInvalid, InvalidDomain) {
+	// expected-error@-1{{use of undeclared identifier 'InvalidDomain'}}
+	MyErrFirstInvalid,
+	MyErrSecondInvalid,
+};
+
+typedef NS_ERROR_ENUM(unsigned char, MyErrorEnumInvalid, "domain-string");
+  // expected-error@-1{{domain argument does not refer to global constant}}
+
+void foo() {}
+typedef NS_ERROR_ENUM(unsigned char, MyErrorEnumInvalidFunction, foo);
+  // expected-error@-1{{domain argument 'foo' does not refer to global constant}}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -80,6 +80,7 @@
 // CHECK-NEXT: MipsShortCall (SubjectMatchRule_function)
 // CHECK-NEXT: NSConsumed (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: NSConsumesSelf (SubjectMatchRule_objc_method)
+// CHECK-NEXT: NSErrorDomain (SubjectMatchRule_enum)
 // CHECK-NEXT: Naked (SubjectMatchRule_function)
 // CHECK-NEXT: NoBuiltin (SubjectMatchRule_function)
 // CHECK-NEXT: NoCommon (SubjectMatchRule_variable)
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -21,6 +21,7 @@
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/Mangle.h"
 #include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/AST/Type.h"
 #include "clang/Basic/CharInfo.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TargetBuiltins.h"
@@ -30,12 +31,15 @@
 #include "clang/Sema/DelayedDiagnostic.h"
 #include "clang/Sema/Initialization.h"
 #include "clang/Sema/Lookup.h"
+#include "clang/Sema/ParsedAttr.h"
 #include "clang/Sema/Scope.h"
 #include "clang/Sema/ScopeInfo.h"
 #include "clang/Sema/SemaInternal.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/MathExtras.h"
+#include "llvm/Support/raw_ostream.h"
 
 using namespace clang;
 using namespace sema;
@@ -5322,6 +5326,40 @@
   D->addAttr(::new (S.Context) ObjCRequiresSuperAttr(S.Context, Attrs));
 }
 
+static void handleNSErrorDomain(Sema &S, Decl *D, const ParsedAttr &AL) {
+  auto *E = AL.getArgAsExpr(0);
+  auto Loc = E ? E->getBeginLoc() : AL.get

[PATCH] D84005: Introduce ns_error_domain attribute.

2020-07-29 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added inline comments.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:3650
   S.Diag(Field->getLocation(),
  diag::warn_transparent_union_attribute_field_size_align)
   << isSize << *Field << FieldBits;

Please use spaces instead of tabs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84005

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


[clang] 71bf6dd - [Driver][ARM] Fix testcase that should only run on ARM

2020-07-29 Thread Victor Campos via cfe-commits

Author: Victor Campos
Date: 2020-07-29T14:35:14+01:00
New Revision: 71bf6dd682c03c8c29a365f602f5168d44757abe

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

LOG: [Driver][ARM] Fix testcase that should only run on ARM

Fix testcase introduced in d1a3396bfbc6fd6df927f2864c18d86e742cabff.

Added: 


Modified: 
clang/test/CodeGen/arm-bf16-softfloat.c

Removed: 




diff  --git a/clang/test/CodeGen/arm-bf16-softfloat.c 
b/clang/test/CodeGen/arm-bf16-softfloat.c
index 3ff4f465223c..1792a1e3c9ce 100644
--- a/clang/test/CodeGen/arm-bf16-softfloat.c
+++ b/clang/test/CodeGen/arm-bf16-softfloat.c
@@ -1,3 +1,4 @@
+// REQUIRES: arm-registered-target
 // RUN: not %clang -target arm-arm-none-eabi -march=armv8-a+bf16 
-mfloat-abi=soft -c %s -o %t 2>&1 | FileCheck %s
 // RUN: not %clang -target arm-arm-none-eabi -march=armv8-a+bf16 -mfpu=none -c 
%s -o %t 2>&1 | FileCheck %s
 // RUN: not %clang -target arm-arm-none-eabi -march=armv8-a+bf16+nofp -c %s -o 
%t 2>&1 | FileCheck %s



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


[PATCH] D66035: [WebAssembly] WIP: Add support for reference types

2020-07-29 Thread Paulo Matos via Phabricator via cfe-commits
pmatos added a comment.

I will be splitting the part enabling the target feature through clang into a 
separate revision as suggested by @tlively




Comment at: clang/lib/Basic/Targets/WebAssembly.cpp:43
   .Case("exception-handling", HasExceptionHandling)
+  .Case("reference-types", HasReferenceTypes)
   .Case("bulk-memory", HasBulkMemory)

tlively wrote:
> I would split the target-features changes out into a separate patch that we 
> can land right away. There is utility in having the feature flag available to 
> be put into the target-features section even if LLVM cannot itself emit 
> reference types usage yet.
Sure - I will create a separate revision for this bit then. 



Comment at: clang/lib/Basic/Targets/WebAssembly.cpp:183
+  HasReferenceTypes = true;
+  resetDataLayout("e-m:e-p:32:32-i64:64-n32:64-S128-ni:256");
+  continue;

tlively wrote:
> It would be good to have a comment about what is different in this data 
> layout string. Also, is it really necessary to have a different data layout 
> string when reference types are enabled?
ni will define 256 as a non-integral address space. This is required for 
externref but I don't think it hurts to have it even if reference types is 
disabled but it feels cleaner to not have it if not needed.



Comment at: llvm/include/llvm/CodeGen/ValueTypes.td:169
 def exnref: ValueType<0, 134>;  // WebAssembly's exnref type
+def externref: ValueType<0, 135>;   // WebAssembly's externref type
 def token  : ValueType<0  , 248>;   // TokenTy

tlively wrote:
> Do we need `funcref` here as well, or do we just use `externref` everywhere 
> and infer separate `funcref` types later?
That's the plan for now. I think I haven't seen the use of having funcref here 
as well so I haven't added it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66035

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


[PATCH] D84843: [Analyzer] Remove inclusion of uniqueing decl from diagnostic profile.

2020-07-29 Thread Balázs Kéri via Phabricator via cfe-commits
balazske created this revision.
Herald added subscribers: cfe-commits, ASDenysPetrov, martong, Charusso, 
gamesh411, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, 
baloghadamsoftware, xazax.hun.
Herald added a reviewer: Szelethus.
Herald added a project: clang.
balazske requested review of this revision.

The uniqueing decl in PathDiagnostic is the declaration with the
uniqueing loc, as stated by documentation comments.
It is enough to include the uniqueing loc in the profile. It is possible
to have objects with different uniqueing decl but same location, at
least with templates. These belong to the same class and should have
same profile.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84843

Files:
  clang/lib/Analysis/PathDiagnostic.cpp
  clang/test/Analysis/report-uniqueing.cpp


Index: clang/test/Analysis/report-uniqueing.cpp
===
--- /dev/null
+++ clang/test/Analysis/report-uniqueing.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_analyze_cc1 -verify %s \
+// RUN:   -analyzer-checker=security
+
+void bzero(void *, unsigned long);
+
+template  void foo(T l) {
+  // The warning comes from multiple instances and with
+  // different declarations that have same source location.
+  // One instance should be shown.
+  bzero(l, 1); // expected-warning{{The bzero() function is obsoleted}}
+}
+
+void p(int *p, unsigned *q) {
+  foo(p);
+  foo(q);
+}
Index: clang/lib/Analysis/PathDiagnostic.cpp
===
--- clang/lib/Analysis/PathDiagnostic.cpp
+++ clang/lib/Analysis/PathDiagnostic.cpp
@@ -1134,7 +1134,6 @@
 void PathDiagnostic::Profile(llvm::FoldingSetNodeID &ID) const {
   ID.Add(getLocation());
   ID.Add(getUniqueingLoc());
-  ID.AddPointer(getUniqueingLoc().isValid() ? getUniqueingDecl() : nullptr);
   ID.AddString(BugType);
   ID.AddString(VerboseDesc);
   ID.AddString(Category);


Index: clang/test/Analysis/report-uniqueing.cpp
===
--- /dev/null
+++ clang/test/Analysis/report-uniqueing.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_analyze_cc1 -verify %s \
+// RUN:   -analyzer-checker=security
+
+void bzero(void *, unsigned long);
+
+template  void foo(T l) {
+  // The warning comes from multiple instances and with
+  // different declarations that have same source location.
+  // One instance should be shown.
+  bzero(l, 1); // expected-warning{{The bzero() function is obsoleted}}
+}
+
+void p(int *p, unsigned *q) {
+  foo(p);
+  foo(q);
+}
Index: clang/lib/Analysis/PathDiagnostic.cpp
===
--- clang/lib/Analysis/PathDiagnostic.cpp
+++ clang/lib/Analysis/PathDiagnostic.cpp
@@ -1134,7 +1134,6 @@
 void PathDiagnostic::Profile(llvm::FoldingSetNodeID &ID) const {
   ID.Add(getLocation());
   ID.Add(getUniqueingLoc());
-  ID.AddPointer(getUniqueingLoc().isValid() ? getUniqueingDecl() : nullptr);
   ID.AddString(BugType);
   ID.AddString(VerboseDesc);
   ID.AddString(Category);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84736: [analyzer][RFC] Handle pointer difference of ElementRegion and SymbolicRegion

2020-07-29 Thread Balázs Benics via Phabricator via cfe-commits
steakhal updated this revision to Diff 281556.
steakhal marked 3 inline comments as done.
steakhal added a comment.

Reworked `ElementRegion` handling.
Previously it handled only element regions in the form of: `Element{X,n} OP 
Element{X,m}`
Now supports `Element{X,n} OP X` and `X OP Element{X,n}` as well.
Still misses nested ElementRegions though like: `Element{X,n} OP 
Element{Element{X,k},m}`.

No tests yet.
Regression test vs unit test - which should I prefer?


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

https://reviews.llvm.org/D84736

Files:
  clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp

Index: clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -1017,40 +1017,77 @@
   }
 }
 
-// Handle special cases for when both regions are element regions.
-const ElementRegion *RightER = dyn_cast(RightMR);
-const ElementRegion *LeftER = dyn_cast(LeftMR);
-if (RightER && LeftER) {
-  // Next, see if the two ERs have the same super-region and matching types.
-  // FIXME: This should do something useful even if the types don't match,
-  // though if both indexes are constant the RegionRawOffset path will
-  // give the correct answer.
-  if (LeftER->getSuperRegion() == RightER->getSuperRegion() &&
-  LeftER->getElementType() == RightER->getElementType()) {
-// Get the left index and cast it to the correct type.
-// If the index is unknown or undefined, bail out here.
-SVal LeftIndexVal = LeftER->getIndex();
-Optional LeftIndex = LeftIndexVal.getAs();
-if (!LeftIndex)
-  return UnknownVal();
-LeftIndexVal = evalCastFromNonLoc(*LeftIndex, ArrayIndexTy);
-LeftIndex = LeftIndexVal.getAs();
-if (!LeftIndex)
+// Handle: \forall MemRegion X, \forall NonLoc n, m:
+//  - Element{X,n} OP Element{X,m}
+//  - Element{X,n} OP X
+//  -X OP Element{X,n}
+// We don't handle here nested ElementRegions like in the this expression:
+// Element{Element{x,3,int [10]},5,int}  ==  Element{x,35,int}
+{
+  // Calculates the byte offset within the memory region to the referred
+  // element.
+  const auto ByteOffsetOfElement =
+  [this, state](const ElementRegion *ElemReg) -> NonLoc {
+NonLoc Index = evalCastFromNonLoc(ElemReg->getIndex(), ArrayIndexTy)
+   .castAs();
+CharUnits SingleElementSize =
+ElemReg->getContext().getTypeSizeInChars(ElemReg->getElementType());
+return evalBinOpNN(state, BO_Mul, Index,
+   makeArrayIndex(SingleElementSize.getQuantity()),
+   ArrayIndexTy)
+.castAs();
+  };
+
+  // If both has the same memory region, and the index has a concrete value,
+  // we can evaluate equality operators.
+  const auto EvaluateEqualityOperators =
+  [this, state, op, resultTy](NonLoc Index,
+  bool HasSameMemRegions) -> SVal {
+assert(BinaryOperator::isEqualityOp(op));
+const llvm::APSInt *Int = getKnownValue(state, Index);
+if (!Int)
   return UnknownVal();
 
-// Do the same for the right index.
-SVal RightIndexVal = RightER->getIndex();
-Optional RightIndex = RightIndexVal.getAs();
-if (!RightIndex)
-  return UnknownVal();
-RightIndexVal = evalCastFromNonLoc(*RightIndex, ArrayIndexTy);
-RightIndex = RightIndexVal.getAs();
-if (!RightIndex)
-  return UnknownVal();
+const bool EQResult = HasSameMemRegions && *Int == 0;
+return makeTruthVal(op == BO_EQ ? EQResult : !EQResult, resultTy);
+  };
+
+  const ElementRegion *RightER = dyn_cast(RightMR);
+  const ElementRegion *LeftER = dyn_cast(LeftMR);
+  if (RightER && LeftER) {
+// Next, see if the two ERs have the same super-region and matching
+// types.
+// FIXME: This should do something useful even if the types don't match,
+// though if both indexes are constant the RegionRawOffset path will
+// give the correct answer.
+if (LeftER->getSuperRegion() == RightER->getSuperRegion() &&
+LeftER->getElementType() == RightER->getElementType()) {
+  return evalBinOpNN(state, op, ByteOffsetOfElement(LeftER),
+ ByteOffsetOfElement(RightER), resultTy);
+}
+  } else if (LeftER && !RightER) {
+NonLoc LeftIndex = ByteOffsetOfElement(LeftER);
+const bool HasSameMemRegions = LeftER->getSuperRegion() == RightMR;
 
-// Actually perform the operation.
-// evalBinOpNN expects the two indexes to already be the right type.
-return evalBinOpNN(state, op, *Lef

[clang] 1ae63b4 - [clang][NFC] Pass the ASTContext to CXXRecordDecl::setCaptures

2020-07-29 Thread Bruno Ricci via cfe-commits

Author: Bruno Ricci
Date: 2020-07-29T14:55:15+01:00
New Revision: 1ae63b4179c222431cd6a4b2397abceaa5bc3d30

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

LOG: [clang][NFC] Pass the ASTContext to CXXRecordDecl::setCaptures

In general Decl::getASTContext() is relatively expensive and here the changes
are non-invasive. NFC.

Added: 


Modified: 
clang/include/clang/AST/DeclCXX.h
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/DeclCXX.cpp
clang/lib/Sema/SemaLambda.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 2b8d7e879a0a..20f058b87e7f 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -1025,7 +1025,7 @@ class CXXRecordDecl : public RecordDecl {
   }
 
   /// Set the captures for this lambda closure type.
-  void setCaptures(ArrayRef Captures);
+  void setCaptures(ASTContext &Context, ArrayRef Captures);
 
   /// For a closure type, retrieve the mapping from captured
   /// variables and \c this to the non-static data members that store the

diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index e0bca8f08bb4..12dcd14c06bf 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -1900,7 +1900,8 @@ Error ASTNodeImporter::ImportDefinition(
   else
 return ToCaptureOrErr.takeError();
 }
-cast(To)->setCaptures(ToCaptures);
+cast(To)->setCaptures(Importer.getToContext(),
+ ToCaptures);
   }
 
   Error Result = ImportDeclContext(From, /*ForceImport=*/true);

diff  --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index 6f1fd2f14ede..59ae5cb300f7 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -1383,8 +1383,8 @@ void 
CXXRecordDecl::finishedDefaultedOrDeletedMember(CXXMethodDecl *D) {
 data().DeclaredNonTrivialSpecialMembers |= SMKind;
 }
 
-void CXXRecordDecl::setCaptures(ArrayRef Captures) {
-  ASTContext &Context = getASTContext();
+void CXXRecordDecl::setCaptures(ASTContext &Context,
+ArrayRef Captures) {
   CXXRecordDecl::LambdaDefinitionData &Data = getLambdaData();
 
   // Copy captures.

diff  --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp
index dc74f6e2f7dc..c9f2854f7acc 100644
--- a/clang/lib/Sema/SemaLambda.cpp
+++ b/clang/lib/Sema/SemaLambda.cpp
@@ -1624,8 +1624,9 @@ FieldDecl *Sema::BuildCaptureField(RecordDecl *RD,
 
   // Build the non-static data member.
   FieldDecl *Field =
-  FieldDecl::Create(Context, RD, Loc, Loc, nullptr, FieldType, TSI, 
nullptr,
-false, ICIS_NoInit);
+  FieldDecl::Create(Context, RD, /*StartLoc=*/Loc, /*IdLoc=*/Loc,
+/*Id=*/nullptr, FieldType, TSI, /*BW=*/nullptr,
+/*Mutable=*/false, ICIS_NoInit);
   // If the variable being captured has an invalid type, mark the class as
   // invalid as well.
   if (!FieldType->isDependentType()) {
@@ -1785,7 +1786,7 @@ ExprResult Sema::BuildLambdaExpr(SourceLocation StartLoc, 
SourceLocation EndLoc,
 CUDACheckLambdaCapture(CallOperator, From);
 }
 
-Class->setCaptures(Captures);
+Class->setCaptures(Context, Captures);
 
 // C++11 [expr.prim.lambda]p6:
 //   The closure type for a lambda-expression with no lambda-capture



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


[clang] 517fe05 - [clang][NFC] clang-format fix after eb10b065f2a870b425dcc2040b9955e0eee464b4

2020-07-29 Thread Bruno Ricci via cfe-commits

Author: Bruno Ricci
Date: 2020-07-29T14:55:16+01:00
New Revision: 517fe058d42a1f937e14de4b61a5ac2ad326c850

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

LOG: [clang][NFC] clang-format fix after 
eb10b065f2a870b425dcc2040b9955e0eee464b4

Added: 


Modified: 
clang/lib/Sema/SemaDeclAttr.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 58602a4c58d4..d46c791b0e3a 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -3640,15 +3640,15 @@ static void handleTransparentUnionAttr(Sema &S, Decl 
*D, const ParsedAttr &AL) {
 S.Context.getTypeAlign(FieldType) > FirstAlign) {
   // Warn if we drop the attribute.
   bool isSize = S.Context.getTypeSize(FieldType) != FirstSize;
-  unsigned FieldBits = isSize? S.Context.getTypeSize(FieldType)
- : S.Context.getTypeAlign(FieldType);
+  unsigned FieldBits = isSize ? S.Context.getTypeSize(FieldType)
+  : S.Context.getTypeAlign(FieldType);
   S.Diag(Field->getLocation(),
  diag::warn_transparent_union_attribute_field_size_align)
   << isSize << *Field << FieldBits;
-  unsigned FirstBits = isSize? FirstSize : FirstAlign;
+  unsigned FirstBits = isSize ? FirstSize : FirstAlign;
   S.Diag(FirstField->getLocation(),
  diag::note_transparent_union_first_field_size_align)
-<< isSize << FirstBits;
+  << isSize << FirstBits;
   return;
 }
   }



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


[PATCH] D84005: Introduce ns_error_domain attribute.

2020-07-29 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added inline comments.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:3650
   S.Diag(Field->getLocation(),
  diag::warn_transparent_union_attribute_field_size_align)
   << isSize << *Field << FieldBits;

gribozavr2 wrote:
> Please use spaces instead of tabs.
Sorry about that, fixed in 517fe058d42a1f937e14de4b61a5ac2ad326c850


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84005

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


[PATCH] D78704: [analyzer][NFC] Add unittest for FalsePositiveRefutationBRVisitor

2020-07-29 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added inline comments.



Comment at: 
clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp:19
+#include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h"
+#include "llvm/Config/config.h"
+#include "gtest/gtest.h"

whisperity wrote:
> steakhal wrote:
> > mgorny wrote:
> > > `config.h` is a private LLVM header and must not be used from clang.
> > I'm not a CMake profession, but shouldn't it be declared private to the 
> > LLVM target in the corresponding CMakeLists file then?
> > 
> > How do you query whether clang has built with Z3 or not @mgorny?
> > I'm including that header only for that.
> I've did a quick skim of the code, and it seems there is no way in it 
> currently to query this.
> Your best bet would be either adding an extra flag to Clang's CMake generated 
> Config header that inherits this flag, or checking `llvm::CreateZ3Solver()` - 
> right now, this method reports a fatal error, but you could create a bool 
> function in the header which reports constant true or false, and turn the 
> test's skip into a runtime condition?
How could I use a //private// header in the first place?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78704

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


[PATCH] D83115: [Analyzer] Report every bug if only uniqueing location differs.

2020-07-29 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

Crash is fixed here: D84843 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83115

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


[PATCH] D84844: [OpenMP] Ensure testing for versions 4.5, 5.0, and default - Part 1

2020-07-29 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

I'm not sure if this is profitable. All these changes increase the time of the 
test execution significantly in many cases while execution goes the same 
control paths. Some smart changes are required, only for things changed from 
version to version.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84844

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


[PATCH] D84839: Add document outline symbols from unnamed contexts, e.g. extern "C".

2020-07-29 Thread Ilya Golovenko via Phabricator via cfe-commits
ilya-golovenko added inline comments.



Comment at: clang-tools-extra/clangd/FindSymbols.cpp:200
 auto *ND = llvm::dyn_cast(D);
-if (!ND)
+if (!ND) {
+  // Traverse children of unnamed contexts, e.g. extern "C".

kadircet wrote:
> this will result in traversal of other declcontexts like block/capturedecls.
> 
> i think we should rather change the VisitKind to `{No, Decl, Children}` and 
> then make `shouldVisit` return a `VisitKindSet` and take a `Decl*` instead of 
> a `NamedDecl`.
> Later on we should first check for `LinkageSpecDecl` and return `Children` 
> only while keeping the rest of the logic the same (i.e. try to cast to 
> nameddecl and return `No` if it fails.
> Finally logic in here should also be adjusted accordingly to visit children 
> and the decl itself separately.
> 
> Do you have other cases apart from extern'd symbols?
I have only C++20 `ExportDecl` in mind. Initially I wanted to make changes 
similar like you propose, but tried to minimize the diff :-) I will re-work the 
fix according to your proposal.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84839

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


[PATCH] D84846: [MC] Add support for generating missing GNU build notes

2020-07-29 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
Herald added subscribers: llvm-commits, cfe-commits, dang, hiraditya, emaste.
Herald added a reviewer: espindola.
Herald added projects: clang, LLVM.
tbaeder requested review of this revision.
Herald added a subscriber: MaskRay.

Add support for generating missing GNU build notes to the LLVM assembler.

This makes clang accept and pass through 
-Wa,--generate-missing-build-notes=[yes/no]. If =yes is passed (the default is 
no), then the assembler will check whether a .gnu.build.attributes section is 
present. If not, it will generate one for all relevant code sections.

This is the equivalent to what the GNU assembler gas is already doing in 
maybe_generate_build_notes() in gas/write.c: 
https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gas/write.c;h=0b43063bbaab76d21fe3bac5fb4643bfff3c72e2;hb=HEAD#l1954


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84846

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/tools/driver/cc1as_main.cpp
  llvm/include/llvm/MC/MCContext.h
  llvm/include/llvm/MC/MCTargetOptions.h
  llvm/lib/CodeGen/LLVMTargetMachine.cpp
  llvm/lib/MC/ELFObjectWriter.cpp
  llvm/lib/MC/MCContext.cpp
  llvm/lib/MC/MCTargetOptions.cpp
  llvm/test/MC/ELF/build-notes.s
  llvm/tools/llvm-mc/llvm-mc.cpp

Index: llvm/tools/llvm-mc/llvm-mc.cpp
===
--- llvm/tools/llvm-mc/llvm-mc.cpp
+++ llvm/tools/llvm-mc/llvm-mc.cpp
@@ -172,6 +172,10 @@
 static cl::opt NoExecStack("no-exec-stack",
  cl::desc("File doesn't need an exec stack"));
 
+static cl::opt
+GenerateMissingBuildNotes("generate-missing-build-notes",
+  cl::desc("Generate missing GNU build notes"));
+
 enum ActionType {
   AC_AsLex,
   AC_Assemble,
@@ -378,6 +382,9 @@
   if (SaveTempLabels)
 Ctx.setAllowTemporaryLabels(false);
 
+  if (GenerateMissingBuildNotes)
+Ctx.setGenerateMissingBuildNotes(true);
+
   Ctx.setGenDwarfForAssembly(GenDwarfForAssembly);
   // Default to 4 for dwarf version.
   unsigned DwarfVersion = MCOptions.DwarfVersion ? MCOptions.DwarfVersion : 4;
Index: llvm/test/MC/ELF/build-notes.s
===
--- /dev/null
+++ llvm/test/MC/ELF/build-notes.s
@@ -0,0 +1,55 @@
+// RUN: llvm-mc --generate-missing-build-notes -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | llvm-readobj -r --section-relocations --hex-dump=.gnu.build.attributes - | FileCheck %s
+// RUN: llvm-mc --generate-missing-build-notes -filetype=obj -triple i386-pc-linux-gnu %s -o - | llvm-readobj -r --section-relocations --hex-dump=.gnu.build.attributes - | FileCheck %s --check-prefix=i386
+// RUN: llvm-mc --generate-missing-build-notes -filetype=obj -triple armeb-pc-linux-gnu %s -o - | llvm-readobj -r --section-relocations --hex-dump=.gnu.build.attributes - | FileCheck %s --check-prefix=armbe32
+
+.text
+.dc.l 1
+
+.section .text.unused,"ax"
+.space 1025
+
+.section .gnu.linkonce,"ax"
+.dc.l 3
+
+// CHECK:  Relocations [
+// CHECK-NEXT:   Section {{.*}} .rela.gnu.build.attributes {
+// CHECK-NEXT: 0x14 R_X86_64_64 .text 0x0
+// CHECK-NEXT: 0x1C R_X86_64_64 .text 0x4
+// CHECK-NEXT: 0x38 R_X86_64_64 .text.unused 0x0
+// CHECK-NEXT: 0x40 R_X86_64_64 .text.unused 0x401
+// CHECK-NEXT:   }
+// CHECK-NEXT: ]
+// CHECK: Hex dump of section '.gnu.build.attributes':
+// CHECK-NEXT: 0x 0800 1000 0001 47412401 GA$.
+// CHECK-NEXT: 0x0010 33613200    3a2.
+// CHECK-NEXT: 0x0020  0800 1000 0001 
+// CHECK-NEXT: 0x0030 47412401 33613200   GA$.3a2.
+// CHECK-NEXT: 0x0040     
+
+// i386:  Relocations [
+// i386-NEXT:   Section {{.*}} .rel.gnu.build.attributes {
+// i386-NEXT: 0x14 R_386_32 .text 0x0
+// i386-NEXT: 0x18 R_386_32 .text 0x0
+// i386-NEXT: 0x30 R_386_32 .text.unused 0x0
+// i386-NEXT: 0x34 R_386_32 .text.unused 0x0
+// i386-NEXT:   }
+// i386-NEXT: ]
+// i386: Hex dump of section '.gnu.build.attributes':
+// i386-NEXT: 0x 0800 0800 0001 47412401 GA$.
+// i386-NEXT: 0x0010 33613200  0400 0800 3a2.
+// i386-NEXT: 0x0020 0800 0001 47412401 33613200 GA$.3a2.
+// i386-NEXT: 0x0030  0104   
+
+// armbe32:  Relocations [
+// armbe32-NEXT:   Section {{.*}} .rel.gnu.build.attributes {
+// armbe32-NEXT: 0x14 R_ARM_ABS32 .text 0x0
+// armbe32-NEXT: 0x18 R_ARM_ABS32 .text 0x0
+// armbe32-NEXT: 0x30 R_ARM_ABS32 .text.unused 0x0
+// armbe32-NEXT: 0x34 R_ARM_ABS32

[clang] 8d27be8 - [OpenCL] Add global_device and global_host address spaces

2020-07-29 Thread Alexey Bader via cfe-commits

Author: Alexey Bader
Date: 2020-07-29T17:24:53+03:00
New Revision: 8d27be8dbaffce0519ac41173d51923fc2524b1b

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

LOG: [OpenCL] Add global_device and global_host address spaces

This patch introduces 2 new address spaces in OpenCL: global_device and 
global_host
which are a subset of a global address space, so the address space scheme will 
be
looking like:

```
generic->global->host
  ->device
 ->private
 ->local
constant
```

Justification: USM allocations may be associated with both host and device 
memory. We
want to give users a way to tell the compiler the allocation type of a USM 
pointer for
optimization purposes. (Link to the Unified Shared Memory extension:
https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/USM/cl_intel_unified_shared_memory.asciidoc)

Before this patch USM pointer could be only in opencl_global
address space, hence a device backend can't tell if a particular pointer
points to host or device memory. On FPGAs at least we can generate more
efficient hardware code if the user tells us where the pointer can point -
being able to distinguish between these types of pointers at compile time
allows us to instantiate simpler load-store units to perform memory
transactions.

Patch by Dmitry Sidorov.

Reviewed By: Anastasia

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

Added: 
clang/test/SemaOpenCL/usm-address-spaces-conversions.cl

Modified: 
clang/include/clang/AST/Type.h
clang/include/clang/Basic/AddressSpaces.h
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Sema/ParsedAttr.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/ItaniumMangle.cpp
clang/lib/AST/MicrosoftMangle.cpp
clang/lib/AST/TypePrinter.cpp
clang/lib/Basic/Targets/AMDGPU.cpp
clang/lib/Basic/Targets/NVPTX.h
clang/lib/Basic/Targets/SPIR.h
clang/lib/Basic/Targets/TCE.h
clang/lib/Basic/Targets/X86.h
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/Sema/SemaType.cpp
clang/test/AST/language_address_space_attribute.cpp
clang/test/CodeGenCXX/mangle-address-space.cpp
clang/test/CodeGenOpenCL/address-spaces-conversions.cl
clang/test/CodeGenOpenCL/address-spaces.cl
clang/test/SemaTemplate/address_space-dependent.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 7fe652492b0e..7d943ebc78c0 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -480,6 +480,11 @@ class Qualifiers {
// Otherwise in OpenCLC v2.0 s6.5.5: every address space except
// for __constant can be used as __generic.
(A == LangAS::opencl_generic && B != LangAS::opencl_constant) ||
+   // We also define global_device and global_host address spaces,
+   // to distinguish global pointers allocated on host from pointers
+   // allocated on device, which are a subset of __global.
+   (A == LangAS::opencl_global && (B == LangAS::opencl_global_device ||
+   B == LangAS::opencl_global_host)) ||
// Consider pointer size address spaces to be equivalent to default.
((isPtrSizeAddressSpace(A) || A == LangAS::Default) &&
 (isPtrSizeAddressSpace(B) || B == LangAS::Default));

diff  --git a/clang/include/clang/Basic/AddressSpaces.h 
b/clang/include/clang/Basic/AddressSpaces.h
index faf7f303aa2d..a9db52dfcc9c 100644
--- a/clang/include/clang/Basic/AddressSpaces.h
+++ b/clang/include/clang/Basic/AddressSpaces.h
@@ -36,6 +36,8 @@ enum class LangAS : unsigned {
   opencl_constant,
   opencl_private,
   opencl_generic,
+  opencl_global_device,
+  opencl_global_host,
 
   // CUDA specific address spaces.
   cuda_device,

diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 0ee3c5188563..f9bf3f0acd55 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -1178,6 +1178,16 @@ def OpenCLGlobalAddressSpace : TypeAttr {
   let Documentation = [OpenCLAddressSpaceGlobalDocs];
 }
 
+def OpenCLGlobalDeviceAddressSpace : TypeAttr {
+  let Spellings = [Clang<"opencl_global_device">];
+  let Documentation = [OpenCLAddressSpaceGlobalExtDocs];
+}
+
+def OpenCLGlobalHostAddressSpace : TypeAttr {
+  let Spellings = [Clang<"opencl_global_host">];
+  let Documentation = [OpenCLAddressSpaceGlobalExtDocs];
+}
+
 def OpenCLLocalAddressSpace : TypeAttr {
   let Spellings = [Keyword<"__local">, Keyword<"local">, 
Clang<"opencl_local">];
   let Documentation = [OpenCLAddressSpaceLocalDocs];

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Ba

[PATCH] D82174: [OpenCL] Add global_device and global_host address spaces

2020-07-29 Thread Alexey Bader via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8d27be8dbaff: [OpenCL] Add global_device and global_host 
address spaces (authored by bader).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82174

Files:
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/AddressSpaces.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Sema/ParsedAttr.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/Basic/Targets/NVPTX.h
  clang/lib/Basic/Targets/SPIR.h
  clang/lib/Basic/Targets/TCE.h
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/AST/language_address_space_attribute.cpp
  clang/test/CodeGenCXX/mangle-address-space.cpp
  clang/test/CodeGenOpenCL/address-spaces-conversions.cl
  clang/test/CodeGenOpenCL/address-spaces.cl
  clang/test/SemaOpenCL/usm-address-spaces-conversions.cl
  clang/test/SemaTemplate/address_space-dependent.cpp

Index: clang/test/SemaTemplate/address_space-dependent.cpp
===
--- clang/test/SemaTemplate/address_space-dependent.cpp
+++ clang/test/SemaTemplate/address_space-dependent.cpp
@@ -43,7 +43,7 @@
 
 template 
 void tooBig() {
-  __attribute__((address_space(I))) int *bounds; // expected-error {{address space is larger than the maximum supported (8388595)}}
+  __attribute__((address_space(I))) int *bounds; // expected-error {{address space is larger than the maximum supported (8388593)}}
 }
 
 template 
@@ -101,7 +101,7 @@
   car<1, 2, 3>(); // expected-note {{in instantiation of function template specialization 'car<1, 2, 3>' requested here}}
   HasASTemplateFields<1> HASTF;
   neg<-1>(); // expected-note {{in instantiation of function template specialization 'neg<-1>' requested here}}
-  correct<0x73>();
+  correct<0x71>();
   tooBig<8388650>(); // expected-note {{in instantiation of function template specialization 'tooBig<8388650>' requested here}}
 
   __attribute__((address_space(1))) char *x;
Index: clang/test/SemaOpenCL/usm-address-spaces-conversions.cl
===
--- /dev/null
+++ clang/test/SemaOpenCL/usm-address-spaces-conversions.cl
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -cl-std=CL2.0
+// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -cl-std=CL2.0 -DGENERIC
+// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -cl-std=CL2.0 -DCONSTANT
+// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -cl-std=CL2.0 -DLOCAL
+
+/* USM (unified shared memory) extension for OpenCLC 2.0 adds two new address
+ * spaces: global_device and global_host that are a subset of __global address
+ * space. As ISO/IEC TR 18037 5.1.3 declares - it's possible to implicitly
+ * convert a subset address space to a superset address space, while conversion
+ * in a reversed direction could be achived only with an explicit cast */
+
+#ifdef GENERIC
+#define AS_COMP __generic
+#else
+#define AS_COMP __global
+#endif // GENERIC
+
+#ifdef CONSTANT
+#define AS_INCOMP __constant
+#elif LOCAL
+#define AS_INCOMP __local
+#else // PRIVATE
+#define AS_INCOMP __private
+#endif // CONSTANT
+
+void test(AS_COMP int *arg_comp,
+  __attribute__((opencl_global_device)) int *arg_device,
+  __attribute__((opencl_global_host)) int *arg_host) {
+  AS_COMP int *var_glob1 = arg_device;
+  AS_COMP int *var_glob2 = arg_host;
+  AS_COMP int *var_glob3 = (AS_COMP int *)arg_device;
+  AS_COMP int *var_glob4 = (AS_COMP int *)arg_host;
+  arg_device = (__attribute__((opencl_global_device)) int *)arg_comp;
+  arg_host = (__attribute__((opencl_global_host)) int *)arg_comp;
+#ifdef GENERIC
+  // expected-error@+6{{assigning '__generic int *__private' to '__global_device int *__private' changes address space of pointer}}
+  // expected-error@+6{{assigning '__generic int *__private' to '__global_host int *__private' changes address space of pointer}}
+#else
+  // expected-error@+3{{assigning '__global int *__private' to '__global_device int *__private' changes address space of pointer}}
+  // expected-error@+3{{assigning '__global int *__private' to '__global_host int *__private' changes address space of pointer}}
+#endif // GENERIC
+  arg_device = arg_comp;
+  arg_host = arg_comp;
+
+#ifdef CONSTANT
+  // expected-error@+15{{initializing '__constant int *__private' with an expression of type '__global_device int *__private' changes address space of pointer}}
+  // expected-error@+15{{initializing '__constant int *__private' wit

[PATCH] D71726: Let clang atomic builtins fetch add/sub support floating point types

2020-07-29 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

ping. I think I have addressed all the issues in FE. I think issues in 
AtomicExpandPass should be addressed by separate patches. Can we land this? 
Thanks.


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

https://reviews.llvm.org/D71726

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


[clang-tools-extra] b99630e - [clang-tidy] Fix RedundantStringCStrCheck with r values

2020-07-29 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-07-29T15:35:31+01:00
New Revision: b99630e432614d06b380afb15c45065eaa0a

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

LOG: [clang-tidy] Fix RedundantStringCStrCheck with r values

The previous fix for this, https://reviews.llvm.org/D76761, Passed test cases 
but failed in the real world as std::string has a non trivial destructor so 
creates a CXXBindTemporaryExpr.

This handles that shortfall and updates the test case std::basic_string 
implementation to use a non trivial destructor to reflect real world behaviour.

Reviewed By: gribozavr2

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp

clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-cstr.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
index bea02a6ba111..1f371eed2db8 100644
--- a/clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
@@ -92,16 +92,18 @@ void RedundantStringCStrCheck::registerMatchers(
 callee(memberExpr().bind("member")),
 callee(cxxMethodDecl(hasAnyName("c_str", "data"
   .bind("call");
-
+  const auto HasRValueTempParent =
+  hasParent(materializeTemporaryExpr(unless(isBoundToLValue(;
   // Detect redundant 'c_str()' calls through a string constructor.
   // If CxxConstructExpr is the part of some CallExpr we need to
   // check that matched ParamDecl of the ancestor CallExpr is not rvalue.
   Finder->addMatcher(
-  traverse(ast_type_traits::TK_AsIs,
-   cxxConstructExpr(StringConstructorExpr,
-hasArgument(0, StringCStrCallExpr),
-unless(hasParent(materializeTemporaryExpr(
-unless(isBoundToLValue())),
+  traverse(
+  ast_type_traits::TK_AsIs,
+  cxxConstructExpr(
+  StringConstructorExpr, hasArgument(0, StringCStrCallExpr),
+  unless(anyOf(HasRValueTempParent, hasParent(cxxBindTemporaryExpr(
+HasRValueTempParent)),
   this);
 
   // Detect: 's == str.c_str()'  ->  's == str'

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-cstr.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-cstr.cpp
index 2561b81805bd..e1df810b 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-cstr.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-cstr.cpp
@@ -15,6 +15,8 @@ struct basic_string {
   basic_string();
   basic_string(const C *p, const A &a = A());
 
+  ~basic_string();
+
   const C *c_str() const;
   const C *data() const;
 



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


[PATCH] D84831: [clang-tidy] Fix RedundantStringCStrCheck with r values

2020-07-29 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb99630e43261: [clang-tidy] Fix RedundantStringCStrCheck with 
r values (authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84831

Files:
  clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-cstr.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-cstr.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-cstr.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-cstr.cpp
@@ -15,6 +15,8 @@
   basic_string();
   basic_string(const C *p, const A &a = A());
 
+  ~basic_string();
+
   const C *c_str() const;
   const C *data() const;
 
Index: clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
@@ -92,16 +92,18 @@
 callee(memberExpr().bind("member")),
 callee(cxxMethodDecl(hasAnyName("c_str", "data"
   .bind("call");
-
+  const auto HasRValueTempParent =
+  hasParent(materializeTemporaryExpr(unless(isBoundToLValue(;
   // Detect redundant 'c_str()' calls through a string constructor.
   // If CxxConstructExpr is the part of some CallExpr we need to
   // check that matched ParamDecl of the ancestor CallExpr is not rvalue.
   Finder->addMatcher(
-  traverse(ast_type_traits::TK_AsIs,
-   cxxConstructExpr(StringConstructorExpr,
-hasArgument(0, StringCStrCallExpr),
-unless(hasParent(materializeTemporaryExpr(
-unless(isBoundToLValue())),
+  traverse(
+  ast_type_traits::TK_AsIs,
+  cxxConstructExpr(
+  StringConstructorExpr, hasArgument(0, StringCStrCallExpr),
+  unless(anyOf(HasRValueTempParent, hasParent(cxxBindTemporaryExpr(
+HasRValueTempParent)),
   this);
 
   // Detect: 's == str.c_str()'  ->  's == str'


Index: clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-cstr.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-cstr.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-cstr.cpp
@@ -15,6 +15,8 @@
   basic_string();
   basic_string(const C *p, const A &a = A());
 
+  ~basic_string();
+
   const C *c_str() const;
   const C *data() const;
 
Index: clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
@@ -92,16 +92,18 @@
 callee(memberExpr().bind("member")),
 callee(cxxMethodDecl(hasAnyName("c_str", "data"
   .bind("call");
-
+  const auto HasRValueTempParent =
+  hasParent(materializeTemporaryExpr(unless(isBoundToLValue(;
   // Detect redundant 'c_str()' calls through a string constructor.
   // If CxxConstructExpr is the part of some CallExpr we need to
   // check that matched ParamDecl of the ancestor CallExpr is not rvalue.
   Finder->addMatcher(
-  traverse(ast_type_traits::TK_AsIs,
-   cxxConstructExpr(StringConstructorExpr,
-hasArgument(0, StringCStrCallExpr),
-unless(hasParent(materializeTemporaryExpr(
-unless(isBoundToLValue())),
+  traverse(
+  ast_type_traits::TK_AsIs,
+  cxxConstructExpr(
+  StringConstructorExpr, hasArgument(0, StringCStrCallExpr),
+  unless(anyOf(HasRValueTempParent, hasParent(cxxBindTemporaryExpr(
+HasRValueTempParent)),
   this);
 
   // Detect: 's == str.c_str()'  ->  's == str'
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84743: [Clang][AMDGCN] Universal device offloading macros header

2020-07-29 Thread Greg Rodgers via Phabricator via cfe-commits
gregrodgers added a comment.

This is all excellent feedback.  Thank  you.  
I don't understand what I see on the godbolt link.  So far, we have only tested 
with clang.  We will test with gcc to understand the fail.  
I will make the change to use numeric values for _DEVICE_ARCH and change 
"UNKNOWN" to some integer (maybe -1).   The value _DEVICE_GPU is intended to be 
generational within a specific _DEVICE_ARCH.   
To be clear, this is primarily for users or library writers to implement device 
specific or host-only code.   This is not something that should be automatic.  
Users or library authors will opt-in with their own include.  So maybe it does 
not belong in clang/lib/Headers.  
As noted in the header comment, I expect the community to help keep this up to 
date as offloading technology evolves.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84743

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


[PATCH] D83242: [clang][BPF] support type existence/size and enum value relocations

2020-07-29 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song added a comment.

One potential missing relocation is to test whether a particular enum value 
(from an enum type) exists or not.

One way is to create a new relocation type ENUM_VALUE_EXISTENCE where 
"access_string" to encode the enum value. This is different from TYPE_EXISTENCE 
for enum type where the "access_string" is "0".

Alternatively, we could have TYPE_EXISTENCE to include enum value existence as 
well. "access_string" is say "0" for typedef/record/enum types and 
"0:" for enum value.

WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83242

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


[PATCH] D84850: [clang-tidy] Fix module options being registered with different priorities

2020-07-29 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added a reviewer: DmitryPolukhin.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.
njames93 requested review of this revision.

Not a bug that is ever likely to materialise, but still worth fixing


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84850

Files:
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp


Index: clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -114,11 +114,9 @@
   Options.SystemHeaders = false;
   Options.FormatStyle = "none";
   Options.User = llvm::None;
-  unsigned Priority = 0;
   for (const ClangTidyModuleRegistry::entry &Module :
ClangTidyModuleRegistry::entries())
-Options =
-Options.mergeWith(Module.instantiate()->getModuleOptions(), 
++Priority);
+Options = Options.mergeWith(Module.instantiate()->getModuleOptions(), 0);
   return Options;
 }
 


Index: clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -114,11 +114,9 @@
   Options.SystemHeaders = false;
   Options.FormatStyle = "none";
   Options.User = llvm::None;
-  unsigned Priority = 0;
   for (const ClangTidyModuleRegistry::entry &Module :
ClangTidyModuleRegistry::entries())
-Options =
-Options.mergeWith(Module.instantiate()->getModuleOptions(), ++Priority);
+Options = Options.mergeWith(Module.instantiate()->getModuleOptions(), 0);
   return Options;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84850: [clang-tidy] Fix module options being registered with different priorities

2020-07-29 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin accepted this revision.
DmitryPolukhin added a comment.
This revision is now accepted and ready to land.

Thank you for identifying and fixing!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84850

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


[PATCH] D84260: [OpenMP][AMDGCN] Support OpenMP offloading for AMDGCN architecture - Part 3

2020-07-29 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntimeAMDGCN.cpp:51
+
+/// Get the maximum number of threads in a block of the GPU.
+llvm::Value *CGOpenMPRuntimeAMDGCN::getGPUNumThreads(CodeGenFunction &CGF) {

Move these comments to the header instead and remove them from the .cpp module.



Comment at: clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:43
+
+/// Get the id of the current thread on the GPU.
+llvm::Value *CGOpenMPRuntimeNVPTX::getGPUThreadID(CodeGenFunction &CGF) {

Same, move these comments to the header.



Comment at: clang/test/OpenMP/amdgcn_target_codegen.cpp:13
+  // CHECK-LABEL: test_amdgcn_target_tid_threads
+  // CHECK-LABEL: entry:
+

`entry:` not always exist in the LLVM IR functions, better not to check for it.



Comment at: clang/test/OpenMP/amdgcn_target_codegen.cpp:19-20
+// CHECK-DAG: [[VAR1:%[0-9]+]] = trunc i64 %nvptx_num_threads to i32
+// CHECK-DAG: %thread_limit = sub nuw i32 [[VAR1]], 64
+// CHECK-DAG: %nvptx_tid{{[0-9]*}} = call i32 @llvm.amdgcn.workitem.id.x()
+#pragma omp target

Do not rely on names for the locals, some release builds do not generate them. 
Use regexps instead.



Comment at: clang/test/OpenMP/amdgcn_target_init_temp_alloca.cpp:15-16
+
+  // CHECK:  %arr.addr = alloca [100 x i32]*, align 8, addrspace(5)
+  // CHECK-NEXT: %arr.addr.ascast = addrspacecast [100 x i32]* addrspace(5)* 
%arr.addr to [100 x i32]**
+  // CHECK-DAG:  store [100 x i32]* %arr, [100 x i32]** %arr.addr.ascast, 
align 8

same, use regexps instead of %-like names


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84260

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


[PATCH] D84831: [clang-tidy] Fix RedundantStringCStrCheck with r values

2020-07-29 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

In D84831#2181336 , @gribozavr2 wrote:

>> Passed test cases but failed in the real world as std::string has a non 
>> trivial destructor so creates a CXXBindTemporaryExpr.
>
> An idea for a future change: move the std::string mock from this test into a 
> header that is shared across all tests that need a std::string. That will 
> hopefully allow us to combine forces when curating the standard library mocks.

That does sound like a good plan, could also add maybe vector

Also a future change for this specific check would be to replace the call to 
`c_str()` when its being bound to an r value with an explicit copy constructor 
call

   void foo(std::string &&);
   void bar(const std::string& S) {
  -  foo(S.c_str());
  +  foo(std::string(S));
   }

This would be more of a performance change though, basically save a call to 
strlen.
Though arguably it is slightly more readable, as you are explicitly saying you 
want to pass a copy of the string


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84831

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


[PATCH] D68997: Allow searching for prebuilt implicit modules.

2020-07-29 Thread Alexandre Rames via Phabricator via cfe-commits
arames updated this revision to Diff 281602.
arames added a comment.

Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68997

Files:
  clang/docs/Modules.rst
  clang/include/clang/Driver/Options.td
  clang/include/clang/Lex/HeaderSearch.h
  clang/include/clang/Lex/HeaderSearchOptions.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Lex/HeaderSearch.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/Modules/Inputs/prebuilt-implicit-module/a.h
  clang/test/Modules/Inputs/prebuilt-implicit-module/module.modulemap
  clang/test/Modules/prebuilt-implicit-modules.m

Index: clang/test/Modules/prebuilt-implicit-modules.m
===
--- /dev/null
+++ clang/test/Modules/prebuilt-implicit-modules.m
@@ -0,0 +1,27 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -x objective-c -fmodules %S/Inputs/prebuilt-implicit-module/module.modulemap -emit-module -fmodule-name=module_a -fmodules-cache-path=%t
+// RUN: find %t -name "module_a*.pcm" | grep module_a
+//
+// Check we use a prebuilt module when available, and do not build an implicit module.
+// RUN: rm -rf %t1
+// RUN: mkdir -p %t1
+// RUN: %clang_cc1 -x objective-c %s -I%S/Inputs/prebuilt-implicit-module -fmodules -fmodule-map-file=%S/Inputs/prebuilt-implicit-module/module.modulemap -fprebuilt-implicit-modules -fprebuilt-module-path=%t -fmodules-cache-path=%t1
+// RUN: find %t1 -name "module_a*.pcm" | not grep module_e
+//
+// Check that we correctly fall back to implicit modules if the prebuilt implicit module is not found.
+// RUN: %clang_cc1 -x objective-c %s -I%S/Inputs/prebuilt-implicit-module -fmodules -fmodule-map-file=%S/Inputs/prebuilt-implicit-module/module.modulemap -fprebuilt-implicit-modules -fprebuilt-module-path=%t -fmodules-cache-path=%t1 -fno-signed-char
+// RUN: find %t1 -name "module_a*.pcm" | grep module_a
+
+// Check that non-implicit prebuilt modules are always preferred to prebuilt implicit modules.
+// RUN: rm -rf %t2
+// RUN: mkdir -p %t2
+// RUN: %clang_cc1 -x objective-c -fmodules %S/Inputs/prebuilt-implicit-module/module.modulemap -emit-module -fmodule-name=module_a -fmodules-cache-path=%t
+// RUN: %clang_cc1 -x objective-c -fmodules %S/Inputs/prebuilt-implicit-module/module.modulemap -emit-module -fmodule-name=module_a -o %t/module_a.pcm -fno-signed-char
+// RUN: not %clang_cc1 -x objective-c %s -I%S/Inputs/prebuilt-implicit-module -fmodules -fmodule-map-file=%S/Inputs/prebuilt-implicit-module/module.modulemap -fprebuilt-implicit-modules -fprebuilt-module-path=%t -fmodules-cache-path=%t2
+// RUN: find %t2 -name "module_a*.pcm" | not grep module_a
+
+// expected-no-diagnostics
+@import module_a;
+int test() {
+  return a;
+}
Index: clang/test/Modules/Inputs/prebuilt-implicit-module/module.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/prebuilt-implicit-module/module.modulemap
@@ -0,0 +1 @@
+module module_a { header "a.h" }
Index: clang/test/Modules/Inputs/prebuilt-implicit-module/a.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/prebuilt-implicit-module/a.h
@@ -0,0 +1 @@
+const int a = 1;
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -1319,6 +1319,7 @@
   Record.push_back(HSOpts.DisableModuleHash);
   Record.push_back(HSOpts.ImplicitModuleMaps);
   Record.push_back(HSOpts.ModuleMapFileHomeIsCwd);
+  Record.push_back(HSOpts.EnablePrebuiltImplicitModules);
   Record.push_back(HSOpts.UseBuiltinIncludes);
   Record.push_back(HSOpts.UseStandardSystemIncludes);
   Record.push_back(HSOpts.UseStandardCXXIncludes);
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -5847,6 +5847,7 @@
   HSOpts.DisableModuleHash = Record[Idx++];
   HSOpts.ImplicitModuleMaps = Record[Idx++];
   HSOpts.ModuleMapFileHomeIsCwd = Record[Idx++];
+  HSOpts.EnablePrebuiltImplicitModules = Record[Idx++];
   HSOpts.UseBuiltinIncludes = Record[Idx++];
   HSOpts.UseStandardSystemIncludes = Record[Idx++];
   HSOpts.UseStandardCXXIncludes = Record[Idx++];
Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -164,14 +164,41 @@
   return {};
 }
 
+std::string HeaderSearch::getPrebuiltImplicitModuleFileName(Module *Module) {
+  const FileEntry *ModuleMap =
+  getModuleMap().getModuleMapFileForUniquing(Module);
+  StringRef ModuleName = Module->Name

[clang-tools-extra] 62beb7c - [clang-tidy] Fix module options being registered with different priorities

2020-07-29 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-07-29T16:19:07+01:00
New Revision: 62beb7c6f4f2288793751740f06edc0dc25d01f6

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

LOG: [clang-tidy] Fix module options being registered with different priorities

Not a bug that is ever likely to materialise, but still worth fixing

Reviewed By: DmitryPolukhin

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidyOptions.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
index 4c1f28673781..bb5a4b513967 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -114,11 +114,9 @@ ClangTidyOptions ClangTidyOptions::getDefaults() {
   Options.SystemHeaders = false;
   Options.FormatStyle = "none";
   Options.User = llvm::None;
-  unsigned Priority = 0;
   for (const ClangTidyModuleRegistry::entry &Module :
ClangTidyModuleRegistry::entries())
-Options =
-Options.mergeWith(Module.instantiate()->getModuleOptions(), 
++Priority);
+Options = Options.mergeWith(Module.instantiate()->getModuleOptions(), 0);
   return Options;
 }
 



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


[PATCH] D84850: [clang-tidy] Fix module options being registered with different priorities

2020-07-29 Thread Nathan James via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG62beb7c6f4f2: [clang-tidy] Fix module options being 
registered with different priorities (authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84850

Files:
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp


Index: clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -114,11 +114,9 @@
   Options.SystemHeaders = false;
   Options.FormatStyle = "none";
   Options.User = llvm::None;
-  unsigned Priority = 0;
   for (const ClangTidyModuleRegistry::entry &Module :
ClangTidyModuleRegistry::entries())
-Options =
-Options.mergeWith(Module.instantiate()->getModuleOptions(), 
++Priority);
+Options = Options.mergeWith(Module.instantiate()->getModuleOptions(), 0);
   return Options;
 }
 


Index: clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -114,11 +114,9 @@
   Options.SystemHeaders = false;
   Options.FormatStyle = "none";
   Options.User = llvm::None;
-  unsigned Priority = 0;
   for (const ClangTidyModuleRegistry::entry &Module :
ClangTidyModuleRegistry::entries())
-Options =
-Options.mergeWith(Module.instantiate()->getModuleOptions(), ++Priority);
+Options = Options.mergeWith(Module.instantiate()->getModuleOptions(), 0);
   return Options;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 7db017b - [OpenMP][Docs] Update Clang Support docs after D75591

2020-07-29 Thread Johannes Doerfert via cfe-commits

Author: Johannes Doerfert
Date: 2020-07-29T10:21:05-05:00
New Revision: 7db017bf3405c7fa43786fe27380d88702e19584

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

LOG: [OpenMP][Docs] Update Clang Support docs after D75591

Added: 


Modified: 
clang/docs/OpenMPSupport.rst

Removed: 




diff  --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index a1d1b120bcec..bda52e934c26 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -264,7 +264,7 @@ want to help with the implementation.
 
+==+==+==+===+
 | misc extension   | user-defined function variants with #ifdef 
protection| :part:`worked on`| D71179   
 |
 
+--+--+--+---+
-| misc extension   | default(firstprivate) & default(private)  
   | :part:`worked on`| 
  |
+| misc extension   | default(firstprivate) & default(private)  
   | :part:`partial`  | firstprivate done: D75591   
  |
 
+--+--+--+---+
 | loop extension   | Loop tiling transformation
   | :part:`claimed`  | 
  |
 
+--+--+--+---+



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


[clang] ee05167 - [OpenMP] Allow traits for the OpenMP context selector `isa`

2020-07-29 Thread Johannes Doerfert via cfe-commits

Author: Johannes Doerfert
Date: 2020-07-29T10:22:27-05:00
New Revision: ee05167cc42b95f70bc2ff1bd4402969f356f53b

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

LOG: [OpenMP] Allow traits for the OpenMP context selector `isa`

It was unclear what `isa` was supposed to mean so we did not provide any
traits for this context selector. With this patch we will allow *any*
string or identifier. We use the target attribute and target info to
determine if the trait matches. In other words, we will check if the
provided value is a target feature that is available (at the call site).

Fixes PR46338

Reviewed By: ABataev

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

Added: 
clang/test/OpenMP/declare_variant_device_isa_codegen_1.c

Modified: 
clang/include/clang/AST/OpenMPClause.h
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/AST/OpenMPClause.cpp
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/declare_variant_messages.c
llvm/include/llvm/Frontend/OpenMP/OMPContext.h
llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
llvm/lib/Frontend/OpenMP/OMPContext.cpp
llvm/unittests/Frontend/OpenMPContextTest.cpp

Removed: 




diff  --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index c649502f765b..4f94aa7074ee 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -7635,6 +7635,10 @@ class OMPClausePrinter final : public 
OMPClauseVisitor {
 
 struct OMPTraitProperty {
   llvm::omp::TraitProperty Kind = llvm::omp::TraitProperty::invalid;
+
+  /// The raw string as we parsed it. This is needed for the `isa` trait set
+  /// (which accepts anything) and (later) extensions.
+  StringRef RawString;
 };
 struct OMPTraitSelector {
   Expr *ScoreOrCondition = nullptr;
@@ -7692,6 +7696,23 @@ class OMPTraitInfo {
 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const OMPTraitInfo &TI);
 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const OMPTraitInfo *TI);
 
+/// Clang specific specialization of the OMPContext to lookup target features.
+struct TargetOMPContext final : public llvm::omp::OMPContext {
+
+  TargetOMPContext(ASTContext &ASTCtx,
+   std::function &&DiagUnknownTrait,
+   const FunctionDecl *CurrentFunctionDecl);
+  virtual ~TargetOMPContext() = default;
+
+  /// See llvm::omp::OMPContext::matchesISATrait
+  bool matchesISATrait(StringRef RawString) const override;
+
+private:
+  std::function FeatureValidityCheck;
+  std::function DiagUnknownTrait;
+  llvm::StringMap FeatureMap;
+};
+
 } // namespace clang
 
 #endif // LLVM_CLANG_AST_OPENMPCLAUSE_H

diff  --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 6138b27fb87f..08b91de31993 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1278,6 +1278,11 @@ def warn_omp_declare_variant_string_literal_or_identifier
   "%select{set|selector|property}0; "
   "%select{set|selector|property}0 skipped">,
   InGroup;
+def warn_unknown_begin_declare_variant_isa_trait
+: Warning<"isa trait '%0' is not known to the current target; verify the "
+  "spelling or consider restricting the context selector with the "
+  "'arch' selector further">,
+  InGroup;
 def note_omp_declare_variant_ctx_options
 : Note<"context %select{set|selector|property}0 options are: %1">;
 def warn_omp_declare_variant_expected

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 8093e7ed3fbe..ae693a08108c 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10320,6 +10320,11 @@ def warn_nested_declare_variant
 : Warning<"nesting `omp begin/end declare variant` is not supported yet; "
   "nested context ignored">,
   InGroup;
+def warn_unknown_declare_variant_isa_trait
+: Warning<"isa trait '%0' is not known to the current target; verify the "
+  "spelling or consider restricting the context selector with the "
+  "'arch' selector further">,
+  InGroup;
 def err_omp_non_pointer_type_array_shaping_base : Error<
   "expected expression with a pointer to a complete type as a base of an array 
"
   "shaping operation">;

diff  --git a/clang/lib/AST/OpenMPClause.cpp b/clang/lib/AST/OpenMPClause.cpp
index 6933c5742552..9caa691188fd 100644
--- a/clang/lib/AST/OpenMPClause.cpp
+++ b/clang/lib/AST/OpenMPClause.cpp
@@ -17,6 +17,7 @@
 #include "clang/

[PATCH] D83281: [OpenMP] Allow traits for the OpenMP context selector `isa`

2020-07-29 Thread Johannes Doerfert via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGee05167cc42b: [OpenMP] Allow traits for the OpenMP context 
selector `isa` (authored by jdoerfert).

Changed prior to commit:
  https://reviews.llvm.org/D83281?vs=280327&id=281606#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83281

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/declare_variant_device_isa_codegen_1.c
  clang/test/OpenMP/declare_variant_messages.c
  llvm/include/llvm/Frontend/OpenMP/OMPContext.h
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/lib/Frontend/OpenMP/OMPContext.cpp
  llvm/unittests/Frontend/OpenMPContextTest.cpp

Index: llvm/unittests/Frontend/OpenMPContextTest.cpp
===
--- llvm/unittests/Frontend/OpenMPContextTest.cpp
+++ llvm/unittests/Frontend/OpenMPContextTest.cpp
@@ -38,11 +38,13 @@
 #define OMP_TRAIT_PROPERTY(Enum, TraitSetEnum, TraitSelectorEnum, Str) \
   EXPECT_EQ(TraitProperty::Enum,   \
 getOpenMPContextTraitPropertyKind( \
-TraitSet::TraitSetEnum,\
-getOpenMPContextTraitPropertyName(TraitProperty::Enum)));  \
+TraitSet::TraitSetEnum, TraitSelector::TraitSelectorEnum,  \
+getOpenMPContextTraitPropertyName(TraitProperty::Enum, Str))); \
   EXPECT_EQ(Str, getOpenMPContextTraitPropertyName(\
- getOpenMPContextTraitPropertyKind(TraitSet::TraitSetEnum, \
-   Str))); \
+ getOpenMPContextTraitPropertyKind(\
+ TraitSet::TraitSetEnum,   \
+ TraitSelector::TraitSelectorEnum, Str),   \
+ Str));\
   EXPECT_EQ(TraitSet::TraitSetEnum,\
 getOpenMPContextTraitSetForProperty(TraitProperty::Enum)); \
   EXPECT_EQ(TraitSelector::TraitSelectorEnum,  \
@@ -77,31 +79,31 @@
   EXPECT_TRUE(isVariantApplicableInContext(Empty, DeviceNVPTX));
 
   VariantMatchInfo UserCondFalse;
-  UserCondFalse.addTrait(TraitProperty::user_condition_false);
+  UserCondFalse.addTrait(TraitProperty::user_condition_false, "");
   EXPECT_FALSE(isVariantApplicableInContext(UserCondFalse, HostLinux));
   EXPECT_FALSE(isVariantApplicableInContext(UserCondFalse, DeviceLinux));
   EXPECT_FALSE(isVariantApplicableInContext(UserCondFalse, HostNVPTX));
   EXPECT_FALSE(isVariantApplicableInContext(UserCondFalse, DeviceNVPTX));
 
   VariantMatchInfo DeviceArchArm;
-  DeviceArchArm.addTrait(TraitProperty::device_arch_arm);
+  DeviceArchArm.addTrait(TraitProperty::device_arch_arm, "");
   EXPECT_FALSE(isVariantApplicableInContext(DeviceArchArm, HostLinux));
   EXPECT_FALSE(isVariantApplicableInContext(DeviceArchArm, DeviceLinux));
   EXPECT_FALSE(isVariantApplicableInContext(DeviceArchArm, HostNVPTX));
   EXPECT_FALSE(isVariantApplicableInContext(DeviceArchArm, DeviceNVPTX));
 
   VariantMatchInfo LLVMHostUserCondTrue;
-  LLVMHostUserCondTrue.addTrait(TraitProperty::implementation_vendor_llvm);
-  LLVMHostUserCondTrue.addTrait(TraitProperty::device_kind_host);
-  LLVMHostUserCondTrue.addTrait(TraitProperty::device_kind_any);
-  LLVMHostUserCondTrue.addTrait(TraitProperty::user_condition_true);
+  LLVMHostUserCondTrue.addTrait(TraitProperty::implementation_vendor_llvm, "");
+  LLVMHostUserCondTrue.addTrait(TraitProperty::device_kind_host, "");
+  LLVMHostUserCondTrue.addTrait(TraitProperty::device_kind_any, "");
+  LLVMHostUserCondTrue.addTrait(TraitProperty::user_condition_true, "");
   EXPECT_TRUE(isVariantApplicableInContext(LLVMHostUserCondTrue, HostLinux));
   EXPECT_FALSE(isVariantApplicableInContext(LLVMHostUserCondTrue, DeviceLinux));
   EXPECT_TRUE(isVariantApplicableInContext(LLVMHostUserCondTrue, HostNVPTX));
   EXPECT_FALSE(isVariantApplicableInContext(LLVMHostUserCondTrue, DeviceNVPTX));
 
   VariantMatchInfo LLVMHostUserCondTrueCPU = LLVMHostUserCondTrue;
-  LLVMHostUserCondTrueCPU.addTrait(TraitProperty::device_kind_cpu);
+  LLVMHostUserCondTrueCPU.addTrait(TraitProperty::device_kind_cpu, "");
   EXPECT_TRUE(isVariantApplicableInContext(LLVMHostUserCondTrueCPU, HostLinux));
   EXPECT_FALSE(
   isVariantApplicableInContext(LLVMHostUserCondTrueCPU, DeviceLinux));
@@ -111,14 +

[PATCH] D83296: [clang-format] Add a MacroExpander.

2020-07-29 Thread Manuel Klimek via Phabricator via cfe-commits
klimek updated this revision to Diff 281611.
klimek marked 27 inline comments as done.
klimek added a comment.

Addressed code review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83296

Files:
  clang/lib/Format/CMakeLists.txt
  clang/lib/Format/FormatToken.h
  clang/lib/Format/MacroExpander.cpp
  clang/lib/Format/Macros.h
  clang/unittests/Format/CMakeLists.txt
  clang/unittests/Format/MacroExpanderTest.cpp
  clang/unittests/Format/TestLexer.h

Index: clang/unittests/Format/TestLexer.h
===
--- /dev/null
+++ clang/unittests/Format/TestLexer.h
@@ -0,0 +1,88 @@
+//===--- TestLexer.h - Format C++ code --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// \file
+/// This file contains a TestLexer to create FormatTokens from strings.
+///
+//===--===//
+
+#ifndef CLANG_UNITTESTS_FORMAT_TEST_LEXER_H
+#define CLANG_UNITTESTS_FORMAT_TEST_LEXER_H
+
+#include "../../lib/Format/FormatTokenLexer.h"
+
+#include "clang/Basic/FileManager.h"
+#include "clang/Basic/SourceManager.h"
+
+#include 
+#include 
+
+namespace clang {
+namespace format {
+
+typedef llvm::SmallVector TokenList;
+
+inline std::ostream &operator<<(std::ostream &Stream, const FormatToken &Tok) {
+  Stream << "(" << Tok.Tok.getName() << ", \"" << Tok.TokenText.str() << "\")";
+  return Stream;
+}
+inline std::ostream &operator<<(std::ostream &Stream, const TokenList &Tokens) {
+  Stream << "{";
+  for (size_t I = 0, E = Tokens.size(); I != E; ++I) {
+Stream << (I > 0 ? ", " : "") << *Tokens[I];
+  }
+  Stream << "}";
+  return Stream;
+}
+
+inline TokenList uneof(const TokenList &Tokens) {
+  assert(!Tokens.empty() && Tokens.back()->is(tok::eof));
+  return TokenList(Tokens.begin(), std::prev(Tokens.end()));
+}
+
+inline std::string text(llvm::ArrayRef Tokens) {
+  return std::accumulate(Tokens.begin(), Tokens.end(), std::string(),
+ [](const std::string &R, FormatToken *Tok) {
+   return (R + Tok->TokenText).str();
+ });
+}
+
+class TestLexer {
+public:
+  TestLexer() : SourceMgr("test.cpp", "") {}
+
+  TokenList lex(llvm::StringRef Code) {
+Buffers.push_back(
+llvm::MemoryBuffer::getMemBufferCopy(Code, ""));
+clang::FileID FID = SourceMgr.get().createFileID(SourceManager::Unowned,
+ Buffers.back().get());
+FormatTokenLexer Lex(SourceMgr.get(), FID, 0, Style, Encoding, Allocator,
+ IdentTable);
+auto Result = Lex.lex();
+return TokenList(Result.begin(), Result.end());
+  }
+
+  FormatToken *id(llvm::StringRef Code) {
+auto Result = uneof(lex(Code));
+assert(Result.size() == 1U && "Code must expand to 1 token.");
+return Result[0];
+  }
+
+  FormatStyle Style = getLLVMStyle();
+  encoding::Encoding Encoding = encoding::Encoding_UTF8;
+  std::vector> Buffers;
+  clang::SourceManagerForFile SourceMgr;
+  llvm::SpecificBumpPtrAllocator Allocator;
+  IdentifierTable IdentTable;
+};
+
+} // namespace format
+} // namespace clang
+
+#endif // LLVM_CLANG_UNITTESTS_FORMAT_TEST_LEXER_H
Index: clang/unittests/Format/MacroExpanderTest.cpp
===
--- /dev/null
+++ clang/unittests/Format/MacroExpanderTest.cpp
@@ -0,0 +1,170 @@
+#include "../../lib/Format/Macros.h"
+#include "TestLexer.h"
+#include "clang/Basic/FileManager.h"
+
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace format {
+
+namespace {
+
+class MacroExpanderTest : public ::testing::Test {
+public:
+  std::unique_ptr
+  create(const std::vector &MacroDefinitions) {
+return std::make_unique(MacroDefinitions,
+   Lex.SourceMgr.get(), Lex.Style,
+   Lex.Allocator, Lex.IdentTable);
+  }
+
+  std::string expand(MacroExpander &Macros, llvm::StringRef Name,
+ const std::vector &Args = {}) {
+EXPECT_TRUE(Macros.defined(Name));
+return text(Macros.expand(Lex.id(Name), lexArgs(Args)));
+  }
+
+  llvm::SmallVector
+  lexArgs(const std::vector &Args) {
+llvm::SmallVector Result;
+for (const auto &Arg : Args) {
+  Result.push_back(uneof(Lex.lex(Arg)));
+}
+return Result;
+  }
+
+  struct MacroAttributes {
+clang::tok::TokenKind Kind;
+MacroRole Role;
+unsigned Start;
+unsigned End;
+llvm::SmallVector ExpandedFrom;
+  };
+
+  void expectAttributes(const TokenList &Tokens,
+const std::vector &Attributes,

[PATCH] D82898: [clang-tidy] Handled insertion only fixits when determining conflicts.

2020-07-29 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbbc2ddecbd34: [clang-tidy] Handled insertion only fixits 
when determining conflicts. (authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82898

Files:
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-init-variables-conflict.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-init-variables-conflict.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-init-variables-conflict.cpp
@@ -0,0 +1,15 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-init-variables,readability-isolate-declaration %t
+
+void foo() {
+  int A, B, C;
+  // CHECK-MESSAGES-DAG: :[[@LINE-1]]:7: warning: variable 'A' is not initialized
+  // CHECK-MESSAGES-DAG: :[[@LINE-2]]:10: warning: variable 'B' is not initialized
+  // CHECK-MESSAGES-DAG: :[[@LINE-3]]:13: warning: variable 'C' is not initialized
+  // CHECK-MESSAGES-DAG: :[[@LINE-4]]:3: warning: multiple declarations in a single statement reduces readability
+
+  // Only the isolate declarations fix-it should be applied
+
+  //  CHECK-FIXES: int A;
+  // CHECK-FIXES-NEXT: int B;
+  // CHECK-FIXES-NEXT: int C;
+}
Index: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -31,6 +31,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringMap.h"
+#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Regex.h"
 #include 
@@ -590,6 +591,7 @@
 // An event can be either the begin or the end of an interval.
 enum EventType {
   ET_Begin = 1,
+  ET_Insert = 0,
   ET_End = -1,
 };
 
@@ -621,10 +623,17 @@
   //   one will be processed before, disallowing the second one, and the
   //   end point of the first one will also be processed before,
   //   disallowing the first one.
-  if (Type == ET_Begin)
+  switch (Type) {
+  case ET_Begin:
 Priority = std::make_tuple(Begin, Type, -End, -ErrorSize, ErrorId);
-  else
+break;
+  case ET_Insert:
+Priority = std::make_tuple(Begin, Type, -End, ErrorSize, ErrorId);
+break;
+  case ET_End:
 Priority = std::make_tuple(End, Type, -Begin, ErrorSize, ErrorId);
+break;
+  }
 }
 
 bool operator<(const Event &Other) const {
@@ -662,19 +671,19 @@
   }
 
   // Build events from error intervals.
-  std::map> FileEvents;
+  llvm::StringMap> FileEvents;
   for (unsigned I = 0; I < ErrorFixes.size(); ++I) {
 for (const auto &FileAndReplace : *ErrorFixes[I].second) {
   for (const auto &Replace : FileAndReplace.second) {
 unsigned Begin = Replace.getOffset();
 unsigned End = Begin + Replace.getLength();
-const std::string &FilePath = std::string(Replace.getFilePath());
-// FIXME: Handle empty intervals, such as those from insertions.
-if (Begin == End)
-  continue;
-auto &Events = FileEvents[FilePath];
-Events.emplace_back(Begin, End, Event::ET_Begin, I, Sizes[I]);
-Events.emplace_back(Begin, End, Event::ET_End, I, Sizes[I]);
+auto &Events = FileEvents[Replace.getFilePath()];
+if (Begin == End) {
+  Events.emplace_back(Begin, End, Event::ET_Insert, I, Sizes[I]);
+} else {
+  Events.emplace_back(Begin, End, Event::ET_Begin, I, Sizes[I]);
+  Events.emplace_back(Begin, End, Event::ET_End, I, Sizes[I]);
+}
   }
 }
   }
@@ -686,14 +695,20 @@
 llvm::sort(Events);
 int OpenIntervals = 0;
 for (const auto &Event : Events) {
-  if (Event.Type == Event::ET_End)
---OpenIntervals;
-  // This has to be checked after removing the interval from the count if it
-  // is an end event, or before adding it if it is a begin event.
-  if (OpenIntervals != 0)
-Apply[Event.ErrorId] = false;
-  if (Event.Type == Event::ET_Begin)
-++OpenIntervals;
+  switch (Event.Type) {
+  case Event::ET_Begin:
+if (OpenIntervals++ != 0)
+  Apply[Event.ErrorId] = false;
+break;
+  case Event::ET_Insert:
+if (OpenIntervals != 0)
+  Apply[Event.ErrorId] = false;
+break;
+  case Event::ET_End:
+if (--OpenIntervals != 0)
+  Apply[Event.ErrorId] = false;
+break;
+  }
 }
 assert(OpenIntervals == 0 && "Amount of begin/end points doesn't match");
   }
___
cfe-commits mail

[clang-tools-extra] bbc2dde - [clang-tidy] Handled insertion only fixits when determining conflicts.

2020-07-29 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-07-29T16:35:44+01:00
New Revision: bbc2ddecbd342d4502fe43466bd3658b89ddad7d

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

LOG: [clang-tidy] Handled insertion only fixits when determining conflicts.

Handle insertion fix-its when removing incompatible errors by introducting a 
new EventType `ET_Insert`
This has lower prioirty than End events, but higher than begin.
Idea being If an insert is at the same place as a begin event, the insert 
should be processed first to reduce unnecessary conflicts.
Likewise if its at the same place as an end event, process the end event first 
for the same reason.

This also fixes https://bugs.llvm.org/show_bug.cgi?id=46511.

Reviewed By: aaron.ballman

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

Added: 

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-init-variables-conflict.cpp

Modified: 
clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
index 521e6ef549b9..1471301a3431 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -31,6 +31,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringMap.h"
+#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Regex.h"
 #include 
@@ -590,6 +591,7 @@ void 
ClangTidyDiagnosticConsumer::removeIncompatibleErrors() {
 // An event can be either the begin or the end of an interval.
 enum EventType {
   ET_Begin = 1,
+  ET_Insert = 0,
   ET_End = -1,
 };
 
@@ -621,10 +623,17 @@ void 
ClangTidyDiagnosticConsumer::removeIncompatibleErrors() {
   //   one will be processed before, disallowing the second one, and the
   //   end point of the first one will also be processed before,
   //   disallowing the first one.
-  if (Type == ET_Begin)
+  switch (Type) {
+  case ET_Begin:
 Priority = std::make_tuple(Begin, Type, -End, -ErrorSize, ErrorId);
-  else
+break;
+  case ET_Insert:
+Priority = std::make_tuple(Begin, Type, -End, ErrorSize, ErrorId);
+break;
+  case ET_End:
 Priority = std::make_tuple(End, Type, -Begin, ErrorSize, ErrorId);
+break;
+  }
 }
 
 bool operator<(const Event &Other) const {
@@ -662,19 +671,19 @@ void 
ClangTidyDiagnosticConsumer::removeIncompatibleErrors() {
   }
 
   // Build events from error intervals.
-  std::map> FileEvents;
+  llvm::StringMap> FileEvents;
   for (unsigned I = 0; I < ErrorFixes.size(); ++I) {
 for (const auto &FileAndReplace : *ErrorFixes[I].second) {
   for (const auto &Replace : FileAndReplace.second) {
 unsigned Begin = Replace.getOffset();
 unsigned End = Begin + Replace.getLength();
-const std::string &FilePath = std::string(Replace.getFilePath());
-// FIXME: Handle empty intervals, such as those from insertions.
-if (Begin == End)
-  continue;
-auto &Events = FileEvents[FilePath];
-Events.emplace_back(Begin, End, Event::ET_Begin, I, Sizes[I]);
-Events.emplace_back(Begin, End, Event::ET_End, I, Sizes[I]);
+auto &Events = FileEvents[Replace.getFilePath()];
+if (Begin == End) {
+  Events.emplace_back(Begin, End, Event::ET_Insert, I, Sizes[I]);
+} else {
+  Events.emplace_back(Begin, End, Event::ET_Begin, I, Sizes[I]);
+  Events.emplace_back(Begin, End, Event::ET_End, I, Sizes[I]);
+}
   }
 }
   }
@@ -686,14 +695,20 @@ void 
ClangTidyDiagnosticConsumer::removeIncompatibleErrors() {
 llvm::sort(Events);
 int OpenIntervals = 0;
 for (const auto &Event : Events) {
-  if (Event.Type == Event::ET_End)
---OpenIntervals;
-  // This has to be checked after removing the interval from the count if 
it
-  // is an end event, or before adding it if it is a begin event.
-  if (OpenIntervals != 0)
-Apply[Event.ErrorId] = false;
-  if (Event.Type == Event::ET_Begin)
-++OpenIntervals;
+  switch (Event.Type) {
+  case Event::ET_Begin:
+if (OpenIntervals++ != 0)
+  Apply[Event.ErrorId] = false;
+break;
+  case Event::ET_Insert:
+if (OpenIntervals != 0)
+  Apply[Event.ErrorId] = false;
+break;
+  case Event::ET_End:
+if (--OpenIntervals != 0)
+  Apply[Event.ErrorId] = false;
+break;
+  }
 }
 assert(OpenIntervals == 0 && "Amount of begin/end points doesn't match");
   }

diff 

[PATCH] D84674: Allow users to specify a conditional to prevent parsing options with MarshallingInfo

2020-07-29 Thread Daniel Grumberg via Phabricator via cfe-commits
dang updated this revision to Diff 281614.
dang added a comment.

Ensure that the default value is assigned even if the option should not get
parsed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84674

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/Option/OptParser.td
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -66,6 +66,7 @@
   const char *MacroName;
   const Record &R;
   bool ShouldAlwaysEmit;
+  StringRef ShouldParse;
   StringRef KeyPath;
   StringRef DefaultValue;
   StringRef NormalizedValuesScope;
@@ -107,6 +108,8 @@
 OS << ", ";
 OS << ShouldAlwaysEmit;
 OS << ", ";
+OS << ShouldParse;
+OS << ", ";
 OS << KeyPath;
 OS << ", ";
 emitScopedNormalizedValue(OS, DefaultValue);
@@ -194,6 +197,7 @@
   }
 
   Ret->ShouldAlwaysEmit = R.getValueAsBit("ShouldAlwaysEmit");
+  Ret->ShouldParse = R.getValueAsString("ShouldParse");
   Ret->KeyPath = R.getValueAsString("KeyPath");
   Ret->DefaultValue = R.getValueAsString("DefaultValue");
   Ret->NormalizedValuesScope = R.getValueAsString("NormalizedValuesScope");
Index: llvm/include/llvm/Option/OptParser.td
===
--- llvm/include/llvm/Option/OptParser.td
+++ llvm/include/llvm/Option/OptParser.td
@@ -102,6 +102,7 @@
   code KeyPath = ?;
   code DefaultValue = ?;
   bit ShouldAlwaysEmit = 0;
+  code ShouldParse = "true";
   code NormalizedValuesScope = "";
   code Normalizer = "";
   code Denormalizer = "";
@@ -201,6 +202,7 @@
 class ValueMerger { code ValueMerger = merger; }
 class ValueExtractor { code ValueExtractor = extractor; }
 class DiagnosticArg { bit IsDiagnosticArg = 1; }
+class ShouldParseIf { code ShouldParse = shouldparse; }
 
 // Predefined options.
 
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1260,29 +1260,25 @@
 
 #define DIAG_OPTION_WITH_MARSHALLING(  \
 PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,\
-HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  \
-NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX)  \
-  {\
+HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, SHOULD_PARSE, KEYPATH,   \
+DEFAULT_VALUE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX)   \
+  Opts.KEYPATH = MERGER(Opts.KEYPATH, DEFAULT_VALUE);  \
+  if (SHOULD_PARSE)\
 if (auto MaybeValue = NORMALIZER(OPT_##ID, TABLE_INDEX, Args, Diags))  \
   Opts.KEYPATH = MERGER(Opts.KEYPATH,  \
-static_cast(*MaybeValue)); \
-else   \
-  Opts.KEYPATH = MERGER(Opts.KEYPATH, DEFAULT_VALUE);  \
-  }
+static_cast(*MaybeValue));
 
 #define DIAG_OPTION_WITH_MARSHALLING_BOOLEAN(  \
 PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,\
-HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  \
-NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX, NEG_ID,  \
-NEG_SPELLING)  \
-  {\
+HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, SHOULD_PARSE, KEYPATH,   \
+DEFAULT_VALUE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX,   \
+NEG_ID, NEG_SPELLING)  \
+  Opts.KEYPATH = MERGER(Opts.KEYPATH, DEFAULT_VALUE);  \
+  if (SHOULD_PARSE)\
 if (auto MaybeValue =  \
 NORMALIZER(OPT_##ID, OPT_##NEG_ID, TABLE_INDEX, Args, Diags))  \
   Opts.KEYPATH = MERGER(Opts.KEYPATH,  \
-static_cast(*MaybeValue)); \
-else   \
-  Opts.KEYPATH = MERGER(Opts.KEYPATH, DEFAULT_VALUE);  \
-  }
+static_cast(*MaybeValue));
 
 #include "clang/Driver/Options.inc"
 #undef DIAG_OPT

[PATCH] D83296: [clang-format] Add a MacroExpander.

2020-07-29 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added inline comments.



Comment at: clang/lib/Format/MacroExpander.cpp:35
+  SmallVector Params;
+  SmallVector Tokens;
+};

sammccall wrote:
> Tokens -> Expansion? (semantics rather than type)
Changed to "Body".



Comment at: clang/lib/Format/MacroExpander.cpp:81
+do {
+  Def.Tokens.push_back(Current);
+  nextToken();

sammccall wrote:
> this assumes the expansion is nonempty, which the grammar doesn't. while{} 
> instead?
I have no clue how this ever worked tbh O.O
Has been reworked as part of the move to use = to separate the macro signature 
from the body.



Comment at: clang/lib/Format/MacroExpander.cpp:113
+void MacroExpander::parseDefinitions(
+const std::vector &MacroExpander) {
+  for (const std::string &Macro : MacroExpander) {

sammccall wrote:
> weird param name!
Copy-paste gone wrong I assume.



Comment at: clang/lib/Format/MacroExpander.cpp:116
+Buffers.push_back(
+llvm::MemoryBuffer::getMemBufferCopy(Macro, ""));
+clang::FileID FID =

sammccall wrote:
> This is a slightly spooky buffer name - it's the magic name the PP uses for 
> pasted tokens.
> A closer fit for config is maybe "" (like macro definitions 
> passed with `-D`).
> Is it necessary to use one of clang's magic buffer names at all? If so, 
> comment! Else maybe "" or something?
We need source locations, and apparently only:
,  and 
are allowed to have source locations.




Comment at: clang/lib/Format/MacroExpander.cpp:133
+  ArgsList Args) {
+  assert(defined(ID->TokenText));
+  SmallVector Result;

sammccall wrote:
> is the caller responsible for checking the #args matches #params?
> If so, document and assert here?
> 
> Looking at the implementation, it seems you don't expand if there are too few 
> args, and expand if there are too many args (ignoring the last ones). Maybe 
> it doesn't matter, but it'd be nice to be more consistent here.
> 
> (Probably worth calling out somewhere explicitly that variadic macros are not 
> supported)
Added docs in the class comment for MacroExpander.
(so far I always expand, too few -> empty, too many -> ignore)



Comment at: clang/lib/Format/MacroExpander.cpp:194
+assert(New->MacroCtx.Role == MR_None);
+// Tokens that are not part of the user code do not need to be formatted.
+New->MacroCtx.Role = MR_Hidden;

sammccall wrote:
> (I don't know exactly how this is used, but consider whether you mean "do not 
> need to", "should not" or "cannot" here)
Replaced with "are not".



Comment at: clang/lib/Format/MacroExpander.h:10
+///
+/// \file
+/// This file contains the declaration of MacroExpander, which handles macro

sammccall wrote:
> I think this comment is too short (and doesn't really say much that you can't 
> get from the filename). IME many people's mental model of macros is based on 
> how they're used rather than how they formally work, so I think it's worth 
> spelling out even the obvious implementation choices.
> 
> I'd like to see:
>  - rough description of the scope/goal of the feature (clang-format doesn't 
> see macro definitions, so macro uses tend to be pseudo-parsed as function 
> calls. When this isn't appropriate [example], a macro definition can be 
> provided as part of the style. When such a macro is used in the code, 
> clang-format will expand it as the preprocessor would before determining the 
> role of tokens. [example])
>  - explicitly call out here that only a single level of expansion is 
> supported, which is a divergence from the real preprocessor. (This influences 
> both the implementation and the mental model)
>  - what the MacroExpander does and how it relates to MacroContext. I think 
> this should give the input and output token streams names, as it's often 
> important to clearly distinguish the two. (TokenBuffer uses "Spelled tokens" 
> and "Expanded tokens" for this, which is not the same as how these terms are 
> used in SourceManager, but related and hasn't been confusing in practice).
>  - a rough sketch of how the mismatch between what was annotated and what 
> must be formatted is resolved e.g. -- just guessing here -- the spelled 
> stream is formatted but for macro args, the annotations from the expanded 
> stream are used.
> 
> (I'm assuming this is the best file to talk about the implementation of this 
> feature in general - i'm really hoping that there is such a file. If there 
> are a bunch of related utilities you might even consider renaming the header 
> as an umbrella to make them easier to document. This is a question of 
> taste...)
Moved to Macros.h and added file comment that tries to address all of these.



Comment at: clang/lib/Format/MacroExpander.h:66
+  /// each element in \p Arg

[PATCH] D84843: [Analyzer] Remove inclusion of uniqueing decl from diagnostic profile.

2020-07-29 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko accepted this revision.
vsavchenko added a comment.
This revision is now accepted and ready to land.

LGTM!  Thanks for the fast fix!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84843

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


[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-07-29 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi updated this revision to Diff 281626.
yamauchi added a comment.

Address comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

Files:
  clang/test/CodeGen/Inputs/thinlto_expect1.proftext
  clang/test/CodeGen/Inputs/thinlto_expect2.proftext
  clang/test/CodeGenCXX/Inputs/profile-remap.proftext
  clang/test/CodeGenCXX/Inputs/profile-remap_entry.proftext
  clang/test/Profile/Inputs/gcc-flag-compatibility_IR.proftext
  clang/test/Profile/Inputs/gcc-flag-compatibility_IR_entry.proftext
  compiler-rt/test/profile/Linux/instrprof-value-merge.c
  llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
  llvm/test/Transforms/PGOProfile/Inputs/PR41279.proftext
  llvm/test/Transforms/PGOProfile/Inputs/PR41279_2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch1_large_count.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/branch2_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/criticaledge.proftext
  llvm/test/Transforms/PGOProfile/Inputs/criticaledge_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/cspgo.proftext
  llvm/test/Transforms/PGOProfile/Inputs/diag_no_value_sites.proftext
  llvm/test/Transforms/PGOProfile/Inputs/fix_entry_count.proftext
  llvm/test/Transforms/PGOProfile/Inputs/func_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirect_call.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirectbr.proftext
  llvm/test/Transforms/PGOProfile/Inputs/indirectbr_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/irreducible.proftext
  llvm/test/Transforms/PGOProfile/Inputs/irreducible_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/landingpad.proftext
  llvm/test/Transforms/PGOProfile/Inputs/landingpad_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/large_count_remarks.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop1_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/loop2_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/memop_size_annotation.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch-correct.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/multiple_hash_profile.proftext
  llvm/test/Transforms/PGOProfile/Inputs/noreturncall.proftext
  llvm/test/Transforms/PGOProfile/Inputs/remap.proftext
  llvm/test/Transforms/PGOProfile/Inputs/select1.proftext
  llvm/test/Transforms/PGOProfile/Inputs/select2.proftext
  llvm/test/Transforms/PGOProfile/Inputs/suppl-profile.proftext
  llvm/test/Transforms/PGOProfile/Inputs/switch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/switch_entry.proftext
  llvm/test/Transforms/PGOProfile/Inputs/thinlto_cs.proftext
  llvm/test/Transforms/PGOProfile/PR41279.ll
  llvm/test/Transforms/PGOProfile/PR41279_2.ll
  llvm/test/Transforms/PGOProfile/branch1.ll
  llvm/test/Transforms/PGOProfile/branch2.ll
  llvm/test/Transforms/PGOProfile/criticaledge.ll
  llvm/test/Transforms/PGOProfile/instr_entry_bb.ll
  llvm/test/Transforms/PGOProfile/landingpad.ll
  llvm/test/Transforms/PGOProfile/loop1.ll
  llvm/test/Transforms/PGOProfile/loop2.ll
  llvm/test/Transforms/PGOProfile/memop_size_from_strlen.ll
  llvm/test/Transforms/PGOProfile/single_bb.ll
  llvm/test/Transforms/PGOProfile/switch.ll

Index: llvm/test/Transforms/PGOProfile/switch.ll
===
--- llvm/test/Transforms/PGOProfile/switch.ll
+++ llvm/test/Transforms/PGOProfile/switch.ll
@@ -19,7 +19,7 @@
 entry:
 ; GEN: entry:
 ; NOTENTRY-NOT: call void @llvm.instrprof.increment
-; ENTRY: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn_test_switch, i32 0, i32 0), i64 46200943743, i32 4, i32 0)
+; ENTRY: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn_test_switch, i32 0, i32 0), i64 {{[0-9]+}}, i32 4, i32 0)
   switch i32 %i, label %sw.default [
 i32 1, label %sw.bb
 i32 2, label %sw.bb1
@@ -31,23 +31,23 @@
 
 sw.bb:
 ; GEN: sw.bb:
-; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn_test_switch, i32 0, i32 0), i64 46200943743, i32 4, i32 2)
+; GEN: call void @llvm.instrprof.increment(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @__profn_test_switch, i32 0, i32 0), i64 {{[0-9]+}}, i32 

[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-07-29 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi added inline comments.



Comment at: llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp:266
+PGOOldCFGHashing("pgo-instr-old-cfg-hashing", cl::init(false), cl::Hidden,
+ cl::desc("Use the old CFG function hashing."));
+

MaskRay wrote:
> Nit: descriptions usually don't end with a period
> 
> (I know that some descriptions in this file are not consistent)
Done.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

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


[PATCH] D84707: [DFSan][NewPM] Port DataFlowSanitizer to NewPM

2020-07-29 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse added inline comments.



Comment at: llvm/lib/Passes/PassRegistry.def:92
 MODULE_PASS("verify", VerifierPass())
+MODULE_PASS("dfsan", DataFlowSanitizerPass())
 MODULE_PASS("asan-module", ModuleAddressSanitizerPass(/*CompileKernel=*/false, 
false, true, false))

Nit:  maybe "dfsan-module" for consistency?



Comment at: llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp:778
+bool DataFlowSanitizer::runImpl(Module &M) {
+  init(M);
+

Do we need a bool to avoid calling `init` more than once?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84707

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


[PATCH] D79744: clang: Use byref for aggregate kernel arguments

2020-07-29 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:1997
   case ABIArgInfo::Ignore:
+  case ABIArgInfo::IndirectAliased:
 return false;

rjmccall wrote:
> In principle, this can be `inreg` just as much as Indirect can.
The IR verifier currently will reject byref + inreg



Comment at: clang/lib/CodeGen/TargetInfo.cpp:8816
+  // FIXME: Should use byref when promoting pointers in structs, but this
+  // requires adding implementing the coercion.
+  if (!getContext().getLangOpts().OpenCL && LTy == OrigLTy &&

rjmccall wrote:
> I don't see why you'd use `byref` when promoting pointers in structs.  Maybe 
> it works as a hack with your backend, but it seems *extremely* special-case 
> and should not be hacked into the general infrastructure.
The whole point is to reinterpret the address space of the pointers in memory 
since we know if it's a kernel argument it has to be an addrspace(1) pointer or 
garbage. We can't infer the address space of a generic pointer loaded from 
memory.

byref doesn't change that, it just makes the fact that these are passed in 
memory explicit



Comment at: clang/lib/CodeGen/TargetInfo.cpp:9383
   case ABIArgInfo::InAlloca:
+  case ABIArgInfo::IndirectAliased:
 llvm_unreachable("Unsupported ABI kind for va_arg");

rjmccall wrote:
> No reason not to use the Indirect code here.
I generally don't like speculatively adding handling for features I can't write 
a testcase for, but I've moved these


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

https://reviews.llvm.org/D79744

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


[PATCH] D79744: clang: Use byref for aggregate kernel arguments

2020-07-29 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm updated this revision to Diff 281629.
arsenm marked 5 inline comments as done.
arsenm added a comment.

Address comments


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

https://reviews.llvm.org/D79744

Files:
  clang/include/clang/CodeGen/CGFunctionInfo.h
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGenCUDA/kernel-args.cu
  clang/test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl

Index: clang/test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl
===
--- clang/test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl
+++ clang/test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl
@@ -67,7 +67,6 @@
 int i2;
 } struct_of_structs_arg_t;
 
-// CHECK: %union.transparent_u = type { i32 }
 typedef union
 {
   int b1;
@@ -237,7 +236,7 @@
 // CHECK: void @kernel_struct_of_structs_arg(%struct.struct_of_structs_arg %arg1.coerce)
 __kernel void kernel_struct_of_structs_arg(struct_of_structs_arg_t arg1) { }
 
-// CHECK: void @test_kernel_transparent_union_arg(%union.transparent_u %u.coerce)
+// CHECK: void @test_kernel_transparent_union_arg(i32 %u.coerce)
 __kernel void test_kernel_transparent_union_arg(transparent_u u) { }
 
 // CHECK: void @kernel_single_array_element_struct_arg(%struct.single_array_element_struct_arg %arg1.coerce)
Index: clang/test/CodeGenCUDA/kernel-args.cu
===
--- clang/test/CodeGenCUDA/kernel-args.cu
+++ clang/test/CodeGenCUDA/kernel-args.cu
@@ -8,14 +8,14 @@
   int a[32];
 };
 
-// AMDGCN: define amdgpu_kernel void @_Z6kernel1A(%struct.A %x.coerce)
+// AMDGCN: define amdgpu_kernel void @_Z6kernel1A(%struct.A addrspace(4)* byref(%struct.A) align 4 %{{.+}})
 // NVPTX: define void @_Z6kernel1A(%struct.A* byval(%struct.A) align 4 %x)
 __global__ void kernel(A x) {
 }
 
 class Kernel {
 public:
-  // AMDGCN: define amdgpu_kernel void @_ZN6Kernel12memberKernelE1A(%struct.A %x.coerce)
+  // AMDGCN: define amdgpu_kernel void @_ZN6Kernel12memberKernelE1A(%struct.A addrspace(4)* byref(%struct.A) align 4 %{{.+}})
   // NVPTX: define void @_ZN6Kernel12memberKernelE1A(%struct.A* byval(%struct.A) align 4 %x)
   static __global__ void memberKernel(A x){}
   template static __global__ void templateMemberKernel(T x) {}
@@ -29,11 +29,11 @@
 
 void test() {
   Kernel K;
-  // AMDGCN: define amdgpu_kernel void @_Z14templateKernelI1AEvT_(%struct.A %x.coerce)
+  // AMDGCN: define amdgpu_kernel void @_Z14templateKernelI1AEvT_(%struct.A addrspace(4)* byref(%struct.A) align 4 %{{.+}}
   // NVPTX: define void @_Z14templateKernelI1AEvT_(%struct.A* byval(%struct.A) align 4 %x)
   launch((void*)templateKernel);
 
-  // AMDGCN: define amdgpu_kernel void @_ZN6Kernel20templateMemberKernelI1AEEvT_(%struct.A %x.coerce)
+  // AMDGCN: define amdgpu_kernel void @_ZN6Kernel20templateMemberKernelI1AEEvT_(%struct.A addrspace(4)* byref(%struct.A) align 4 %{{.+}}
   // NVPTX: define void @_ZN6Kernel20templateMemberKernelI1AEEvT_(%struct.A* byval(%struct.A) align 4 %x)
   launch((void*)Kernel::templateMemberKernel);
 }
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -257,6 +257,11 @@
<< " ByVal=" << getIndirectByVal()
<< " Realign=" << getIndirectRealign();
 break;
+  case IndirectAliased:
+OS << "Indirect Align=" << getIndirectAlign().getQuantity()
+   << " AadrSpace=" << getIndirectAddrSpace()
+   << " Realign=" << getIndirectRealign();
+break;
   case Expand:
 OS << "Expand";
 break;
@@ -1989,6 +1994,7 @@
   case ABIArgInfo::InAlloca:
 return true;
   case ABIArgInfo::Ignore:
+  case ABIArgInfo::IndirectAliased:
 return false;
   case ABIArgInfo::Indirect:
   case ABIArgInfo::Direct:
@@ -8792,18 +8798,30 @@
 
   // TODO: Can we omit empty structs?
 
-  llvm::Type *LTy = nullptr;
   if (const Type *SeltTy = isSingleElementStruct(Ty, getContext()))
-LTy = CGT.ConvertType(QualType(SeltTy, 0));
+Ty = QualType(SeltTy, 0);
 
+  llvm::Type *OrigLTy = CGT.ConvertType(Ty);
+  llvm::Type *LTy = OrigLTy;
   if (getContext().getLangOpts().HIP) {
-if (!LTy)
-  LTy = CGT.ConvertType(Ty);
 LTy = coerceKernelArgumentType(
-LTy, /*FromAS=*/getContext().getTargetAddressSpace(LangAS::Default),
+OrigLTy, /*FromAS=*/getContext().getTargetAddressSpace(LangAS::Default),
 /*ToAS=*/getContext().getTargetAddressSpace(LangAS::cuda_device));
   }
 
+  // FIXME: Should also use this for OpenCL, but it requires addressing the
+  // problem of kernels being called.
+  //
+  // FIXME: Should use byref when promoting pointers in structs, but this
+  // requires adding implementing the coercion.
+  if (!getContext().getLangOpts().OpenCL && LTy == OrigLTy &&
+  isAggregateTypeForABI(Ty)) {
+return ABIArgInfo::getIndirectAliased(
+getContext().getTypeAlignInCha

[PATCH] D84707: [DFSan][NewPM] Port DataFlowSanitizer to NewPM

2020-07-29 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added inline comments.



Comment at: llvm/lib/Passes/PassRegistry.def:92
 MODULE_PASS("verify", VerifierPass())
+MODULE_PASS("dfsan", DataFlowSanitizerPass())
 MODULE_PASS("asan-module", ModuleAddressSanitizerPass(/*CompileKernel=*/false, 
false, true, false))

morehouse wrote:
> Nit:  maybe "dfsan-module" for consistency?
Almost all of the others have both a module and function pass, so the "-module" 
is to distinguish between those. I think sancov-module is the only one that 
doesn't fit that, and I actually did want to rename it to sancov.

I'd like to keep the name the same as the legacy pass for migration reasons 
(basically so I don't have to touch every dfsan test).



Comment at: llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp:778
+bool DataFlowSanitizer::runImpl(Module &M) {
+  init(M);
+

morehouse wrote:
> Do we need a bool to avoid calling `init` more than once?
A new `DataFlowSanitizer` is constructed for each `run`/`runOnModule` so that 
shouldn't be necessary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84707

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


[PATCH] D84494: [Analyzer] Use of BugType in DereferenceChecker (NFC).

2020-07-29 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 281631.
balazske added a comment.

Changed MemoryError back to LogicError.
Improved placement and text of changed comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84494

Files:
  clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp


Index: clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
@@ -30,8 +30,9 @@
 : public Checker< check::Location,
   check::Bind,
   EventDispatcher > {
-  mutable std::unique_ptr BT_null;
-  mutable std::unique_ptr BT_undef;
+  BugType BT_Null{this, "Dereference of null pointer", categories::LogicError};
+  BugType BT_Undef{this, "Dereference of undefined pointer value",
+   categories::LogicError};
 
   void reportBug(ProgramStateRef State, const Stmt *S, CheckerContext &C) 
const;
 
@@ -123,11 +124,6 @@
   if (!N)
 return;
 
-  // We know that 'location' cannot be non-null.  This is what
-  // we call an "explicit" null dereference.
-  if (!BT_null)
-BT_null.reset(new BuiltinBug(this, "Dereference of null pointer"));
-
   SmallString<100> buf;
   llvm::raw_svector_ostream os(buf);
 
@@ -180,7 +176,7 @@
   }
 
   auto report = std::make_unique(
-  *BT_null, buf.empty() ? BT_null->getDescription() : StringRef(buf), N);
+  BT_Null, buf.empty() ? BT_Null.getDescription() : StringRef(buf), N);
 
   bugreporter::trackExpressionValue(N, bugreporter::getDerefExpr(S), *report);
 
@@ -196,12 +192,8 @@
   // Check for dereference of an undefined value.
   if (l.isUndef()) {
 if (ExplodedNode *N = C.generateErrorNode()) {
-  if (!BT_undef)
-BT_undef.reset(
-new BuiltinBug(this, "Dereference of undefined pointer value"));
-
   auto report = std::make_unique(
-  *BT_undef, BT_undef->getDescription(), N);
+  BT_Undef, BT_Undef.getDescription(), N);
   bugreporter::trackExpressionValue(N, bugreporter::getDerefExpr(S), 
*report);
   C.emitReport(std::move(report));
 }
@@ -219,9 +211,10 @@
   ProgramStateRef notNullState, nullState;
   std::tie(notNullState, nullState) = state->assume(location);
 
-  // The explicit NULL case.
   if (nullState) {
 if (!notNullState) {
+  // We know that 'location' can only be null.  This is what
+  // we call an "explicit" null dereference.
   const Expr *expr = getDereferenceExpr(S);
   if (!suppressReport(expr)) {
 reportBug(nullState, expr, C);


Index: clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
@@ -30,8 +30,9 @@
 : public Checker< check::Location,
   check::Bind,
   EventDispatcher > {
-  mutable std::unique_ptr BT_null;
-  mutable std::unique_ptr BT_undef;
+  BugType BT_Null{this, "Dereference of null pointer", categories::LogicError};
+  BugType BT_Undef{this, "Dereference of undefined pointer value",
+   categories::LogicError};
 
   void reportBug(ProgramStateRef State, const Stmt *S, CheckerContext &C) const;
 
@@ -123,11 +124,6 @@
   if (!N)
 return;
 
-  // We know that 'location' cannot be non-null.  This is what
-  // we call an "explicit" null dereference.
-  if (!BT_null)
-BT_null.reset(new BuiltinBug(this, "Dereference of null pointer"));
-
   SmallString<100> buf;
   llvm::raw_svector_ostream os(buf);
 
@@ -180,7 +176,7 @@
   }
 
   auto report = std::make_unique(
-  *BT_null, buf.empty() ? BT_null->getDescription() : StringRef(buf), N);
+  BT_Null, buf.empty() ? BT_Null.getDescription() : StringRef(buf), N);
 
   bugreporter::trackExpressionValue(N, bugreporter::getDerefExpr(S), *report);
 
@@ -196,12 +192,8 @@
   // Check for dereference of an undefined value.
   if (l.isUndef()) {
 if (ExplodedNode *N = C.generateErrorNode()) {
-  if (!BT_undef)
-BT_undef.reset(
-new BuiltinBug(this, "Dereference of undefined pointer value"));
-
   auto report = std::make_unique(
-  *BT_undef, BT_undef->getDescription(), N);
+  BT_Undef, BT_Undef.getDescription(), N);
   bugreporter::trackExpressionValue(N, bugreporter::getDerefExpr(S), *report);
   C.emitReport(std::move(report));
 }
@@ -219,9 +211,10 @@
   ProgramStateRef notNullState, nullState;
   std::tie(notNullState, nullState) = state->assume(location);
 
-  // The explicit NULL case.
   if (nullState) {
 if (!notNullState) {
+  // We know that 'location' can only be null.  This is what
+  // we call an "explicit" null dereference.
   const Expr *expr = getDerefer

[PATCH] D84572: Allow .dSYM's to be directly placed in an alternate directory

2020-07-29 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84572

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


[PATCH] D79714: [Diagnostics] Restore -Wdeprecated warning when user-declared copy assignment operator is defined as deleted (PR45634)

2020-07-29 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticGroups.td:158
+def DeprecatedCopy : DiagGroup<"deprecated-copy", 
[DeprecatedCopyUserProvided]>;
+def DeprecatedCopyDtor : DiagGroup<"deprecated-copy-dtor", 
[DeprecatedCopyDtorUserProvided]>;
 def DeprecatedDeclarations : DiagGroup<"deprecated-declarations">;

xbolva00 wrote:
> Quuxplusone wrote:
> > If we're going to provide these options at all, I think it would be more 
> > grammatical to call them `-Wdeprecated-copy-with-deleted-copy` and 
> > `-Wdeprecated-copy-with-deleted-dtor`.
> > 
> > The existing code is already confusing by talking about a "copy dtor" as if 
> > that's a thing; I think it makes it even worse to talk about "deprecated 
> > copy user provided," since the actually deprecated thing is the 
> > //implicitly generated// copy.
> > 
> > I get that we're trying to be terse, and also somewhat hierarchical in 
> > putting all the `-Wdeprecated-copy`-related warnings under 
> > `-Wdeprecated-copy-foo-bar`; but the current names are too far into the 
> > ungrammatical realm for me personally.
> Yeah, better names are welcome :)
Do the current names match existing practice in GCC or anything?
I continue to opine that these options are poorly named. My best suggestion is
`deprecated-copy`, `deprecated-copy-with-dtor`, 
`deprecated-copy-with-deleted-copy`, `deprecated-copy-with-deleted-dtor` — 
operating on the (wrong?) assumption that absolutely the only difference 
between "user-declared" and "user-provided" corresponds to "user-declared as 
deleted."

Even if everything else remains the same, the internal identifier 
`warn_deprecated_copy_dtor_operation_user_provided` should certainly be 
`warn_deprecated_copy_operation_dtor_user_provided` — the phrase that goes 
together is "copy operation", not "dtor operation".

Your "deprecated-dtor-user-provided.cpp" passes 
`-Wdeprecated-copy-dtor-user-provided`, but the message text talks about 
"user-//declared//." Shouldn't the spelling of the option reflect the wording 
of the message text? This isn't important from the POV of someone who's just 
going to look at the message text and fix their code, but it's important from 
the POV of someone who's going to use `-Wno-` and wants to know exactly which 
bad situations they're ignoring. (Also, the name of the file should match the 
spelling of the option.)



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:13948
+S.Diag(UserDeclaredOperation->getLocation(), DiagID)
+<< RD << /*copy assignment*/ IsCopyAssignment;
   }

The `/* copy assignment */` comment is probably no longer useful.



Comment at: clang/test/SemaCXX/deprecated-copy.cpp:7
+#ifdef NO_USER_PROVIDED
+// expected-no-diagnostics
+#endif

Quuxplusone wrote:
> xbolva00 wrote:
> > xbolva00 wrote:
> > > Quuxplusone wrote:
> > > > I'm fairly confident this should just be two different test files. 
> > > > Also, if a test file has an un-ifdeffed `// expected-no-diagnostics` 
> > > > plus an un-ifdeffed `// expected-note ...`, which one wins?
> > > ifdef is here
> > > 
> > > and ifNdef is below :)
> > and DEPRECATED_COPY_DTOR is in own "code block"
> Ah, you're right, I had missed that line 18 was still controlled by the 
> `#ifdef DEPRECATED_COPY_DTOR` condition.
> I still think this should be three(!) different files. Line 2 doesn't even 
> look right to me: shouldn't it be `-Wdeprecated-copy 
> -Wno-deprecated-copy-user-provided`?
> 
> I just did a `git grep 'RUN:' | grep '[-]Wno-' | grep -v '[-]W[^n]'` and 
> found a massive number of tests that put `-Wno-foo` on the command line 
> without putting `-Wbar` anywhere on the same line; I suspect many of these 
> are bugs.
I've lost track of what I was trying to say here and whether I was right ;) but 
I assume we can consider this comment thread "resolved"?



Comment at: clang/test/SemaCXX/deprecated-dtor-user-provided.cpp:6
+  int *ptr;
+  ~A(); // expected-warning {{definition of implicit copy constructor for 'A' 
is deprecated because it has a user-declared destructor}}
+};

Do you have a test case for when an operation is defaulted as deleted?
I actually don't understand Clang's/GCC's current behavior in this area.
https://godbolt.org/z/9h3qqP
Of these three situations, do //any// of them rely on deprecated behavior?
(And vice versa, what if we delete the copy constructor and try to use the 
implicit copy-assignment operator?)



Comment at: clang/test/SemaCXX/deprecated.cpp:108
+  };// expected-warning@-1 {{definition of 
implicit copy assignment operator for 'DefaultedDtor' is deprecated because it 
has a user-declared destructor}}
+  DefaultedDtor d1, d2(d1); // expected-note {{in implicit copy 
constructor for 'DeprecatedCopy::DefaultedDtor' first required here}}
+  void h() { d1 = d2; } // expected-note {{in impl

[PATCH] D84782: [PGO] Include the mem ops into the function hash.

2020-07-29 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi added a comment.

In D84782#2180626 , @davidxl wrote:

> changes like in llvm/test/Transforms/PGOProfile/PR41279.ll etc can be 
> independently committed.

Uploaded D84865  for this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84782

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


[PATCH] D84494: [Analyzer] Use of BugType in DereferenceChecker (NFC).

2020-07-29 Thread Balázs Kéri via Phabricator via cfe-commits
balazske marked 2 inline comments as done.
balazske added a comment.

The category string seems to be not really important, better not to change it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84494

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


[clang] 9f2f3b9 - [OpenMP] Implement TR8 `present` motion modifier in Clang (1/2)

2020-07-29 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2020-07-29T12:18:45-04:00
New Revision: 9f2f3b9de6314a009322b6081c792ebf9a469460

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

LOG: [OpenMP] Implement TR8 `present` motion modifier in Clang (1/2)

This patch implements Clang front end support for the OpenMP TR8
`present` motion modifier for `omp target update` directives.  The
next patch in this series implements OpenMP runtime support.

Reviewed By: ABataev

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

Added: 


Modified: 
clang/include/clang/AST/OpenMPClause.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/OpenMPKinds.def
clang/include/clang/Basic/OpenMPKinds.h
clang/include/clang/Parse/Parser.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/OpenMPClause.cpp
clang/lib/Basic/OpenMPKinds.cpp
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/test/OpenMP/declare_mapper_ast_print.c
clang/test/OpenMP/declare_mapper_codegen.cpp
clang/test/OpenMP/target_update_ast_print.cpp
clang/test/OpenMP/target_update_codegen.cpp
clang/test/OpenMP/target_update_messages.cpp

Removed: 




diff  --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index 4f94aa7074ee..5b588f4b5740 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -6329,8 +6329,20 @@ class OMPToClause final : public 
OMPMappableExprListClause,
   friend OMPVarListClause;
   friend TrailingObjects;
 
+  /// Motion-modifiers for the 'to' clause.
+  OpenMPMotionModifierKind MotionModifiers[NumberOfOMPMotionModifiers] = {
+  OMPC_MOTION_MODIFIER_unknown, OMPC_MOTION_MODIFIER_unknown};
+
+  /// Location of motion-modifiers for the 'to' clause.
+  SourceLocation MotionModifiersLoc[NumberOfOMPMotionModifiers];
+
+  /// Colon location.
+  SourceLocation ColonLoc;
+
   /// Build clause with number of variables \a NumVars.
   ///
+  /// \param TheMotionModifiers Motion-modifiers.
+  /// \param TheMotionModifiersLoc Locations of motion-modifiers.
   /// \param MapperQualifierLoc C++ nested name specifier for the associated
   /// user-defined mapper.
   /// \param MapperIdInfo The identifier of associated user-defined mapper.
@@ -6342,13 +6354,24 @@ class OMPToClause final : public 
OMPMappableExprListClause,
   /// NumUniqueDeclarations: number of unique base declarations in this clause;
   /// 3) NumComponentLists: number of component lists in this clause; and 4)
   /// NumComponents: total number of expression components in the clause.
-  explicit OMPToClause(NestedNameSpecifierLoc MapperQualifierLoc,
+  explicit OMPToClause(ArrayRef TheMotionModifiers,
+   ArrayRef TheMotionModifiersLoc,
+   NestedNameSpecifierLoc MapperQualifierLoc,
DeclarationNameInfo MapperIdInfo,
const OMPVarListLocTy &Locs,
const OMPMappableExprListSizeTy &Sizes)
   : OMPMappableExprListClause(llvm::omp::OMPC_to, Locs, Sizes,
   /*SupportsMapper=*/true, &MapperQualifierLoc,
-  &MapperIdInfo) {}
+  &MapperIdInfo) {
+assert(llvm::array_lengthof(MotionModifiers) == TheMotionModifiers.size() 
&&
+   "Unexpected number of motion modifiers.");
+llvm::copy(TheMotionModifiers, std::begin(MotionModifiers));
+
+assert(llvm::array_lengthof(MotionModifiersLoc) ==
+   TheMotionModifiersLoc.size() &&
+   "Unexpected number of motion modifier locations.");
+llvm::copy(TheMotionModifiersLoc, std::begin(MotionModifiersLoc));
+  }
 
   /// Build an empty clause.
   ///
@@ -6361,6 +6384,29 @@ class OMPToClause final : public 
OMPMappableExprListClause,
   : OMPMappableExprListClause(llvm::omp::OMPC_to, OMPVarListLocTy(), Sizes,
   /*SupportsMapper=*/true) {}
 
+  /// Set motion-modifier for the clause.
+  ///
+  /// \param I index for motion-modifier.
+  /// \param T motion-modifier for the clause.
+  void setMotionModifier(unsigned I, OpenMPMotionModifierKind T) {
+assert(I < NumberOfOMPMotionModifiers &&
+   "Unexpected index to store motion modifier, exceeds array size.");
+MotionModifiers[I] = T;
+  }
+
+  /// Set location for the motion-modifier.
+  ///
+  /// \param I index for motion-modifier location.
+  /// \param TLoc motion-modifier location.
+  void setMotionModifierLoc(unsigned I, SourceLocation TLoc) {
+assert(I < NumberOfOMPMoti

[PATCH] D84868: [clang-tidy] Use StringMap for ClangTidyOptions::OptionsMap

2020-07-29 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: aaron.ballman, gribozavr2.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.
njames93 requested review of this revision.

Ordering of options isn't important so an `llvm::StringMap` is a much better 
container for this purpose.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84868

Files:
  clang-tools-extra/clang-tidy/ClangTidy.cpp
  clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.h
  clang-tools-extra/test/clang-tidy/checkers/google-module.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp

Index: clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
@@ -17,14 +17,10 @@
 // For this test we have to use names of the real checks because otherwise values are ignored.
 // RUN: clang-tidy -dump-config %S/Inputs/config-files/4/44/- -- | FileCheck %s -check-prefix=CHECK-CHILD4
 // CHECK-CHILD4: Checks: {{.*}}modernize-loop-convert,modernize-use-using,llvm-qualified-auto
-// CHECK-CHILD4: - key: llvm-qualified-auto.AddConstToQualified
-// CHECK-CHILD4-NEXT: value: 'true'
-// CHECK-CHILD4: - key: modernize-loop-convert.MaxCopySize
-// CHECK-CHILD4-NEXT: value: '20'
-// CHECK-CHILD4: - key: modernize-loop-convert.MinConfidence
-// CHECK-CHILD4-NEXT: value: reasonable
-// CHECK-CHILD4: - key: modernize-use-using.IgnoreMacros
-// CHECK-CHILD4-NEXT: value: 'false'
+// CHECK-CHILD4-DAG: - key: llvm-qualified-auto.AddConstToQualified{{ *[[:space:]] *}}value: 'true'
+// CHECK-CHILD4-DAG: - key: modernize-loop-convert.MaxCopySize{{ *[[:space:]] *}}value: '20'
+// CHECK-CHILD4-DAG: - key: modernize-loop-convert.MinConfidence{{ *[[:space:]] *}}value: reasonable
+// CHECK-CHILD4-DAG: - key: modernize-use-using.IgnoreMacros{{ *[[:space:]] *}}value: 'false'
 
 // RUN: clang-tidy --explain-config %S/Inputs/config-files/4/44/- -- | FileCheck %s -check-prefix=CHECK-EXPLAIN
 // CHECK-EXPLAIN: 'llvm-qualified-auto' is enabled in the {{.*}}{{[/\\]}}Inputs{{[/\\]}}config-files{{[/\\]}}4{{[/\\]}}44{{[/\\]}}.clang-tidy.
@@ -37,16 +33,13 @@
 // RUN: CheckOptions: [{key: modernize-loop-convert.MaxCopySize, value: 21}]}' \
 // RUN: %S/Inputs/config-files/4/44/- -- | FileCheck %s -check-prefix=CHECK-CHILD5
 // CHECK-CHILD5: Checks: {{.*}}modernize-loop-convert,modernize-use-using,llvm-qualified-auto,-llvm-qualified-auto
-// CHECK-CHILD5: - key: modernize-loop-convert.MaxCopySize
-// CHECK-CHILD5-NEXT: value: '21'
-// CHECK-CHILD5: - key: modernize-loop-convert.MinConfidence
-// CHECK-CHILD5-NEXT: value: reasonable
-// CHECK-CHILD5: - key: modernize-use-using.IgnoreMacros
-// CHECK-CHILD5-NEXT: value: 'false'
+// CHECK-CHILD5-DAG: - key: modernize-loop-convert.MaxCopySize{{ *[[:space:]] *}}value: '21'
+// CHECK-CHILD5-DAG: - key: modernize-loop-convert.MinConfidence{{ *[[:space:]] *}}value: reasonable
+// CHECK-CHILD5-DAG: - key: modernize-use-using.IgnoreMacros{{ *[[:space:]] *}}value: 'false'
 
 // RUN: clang-tidy -dump-config \
 // RUN: --config='{InheritParentConfig: false, \
 // RUN: Checks: -llvm-qualified-auto}' \
 // RUN: %S/Inputs/config-files/4/44/- -- | FileCheck %s -check-prefix=CHECK-CHILD6
-// CHECK-CHILD6: Checks: {{.*}}-llvm-qualified-auto
+// CHECK-CHILD6: Checks: {{.*-llvm-qualified-auto'? *$}}
 // CHECK-CHILD6-NOT: - key: modernize-use-using.IgnoreMacros
Index: clang-tools-extra/test/clang-tidy/checkers/google-module.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/google-module.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/google-module.cpp
@@ -1,10 +1,6 @@
 // RUN: clang-tidy -checks='-*,google*' -config='{}' -dump-config - -- | FileCheck %s
 // CHECK: CheckOptions:
-// CHECK: {{- key: *google-readability-braces-around-statements.ShortStatementLines}}
-// CHECK-NEXT: {{value: *'1'}}
-// CHECK: {{- key: *google-readability-function-size.StatementThreshold}}
-// CHECK-NEXT: {{value: *'800'}}
-// CHECK: {{- key: *google-readability-namespace-comments.ShortNamespaceLines}}
-// CHECK-NEXT: {{value: *'10'}}
-// CHECK: {{- key: *google-readability-namespace-comments.SpacesBeforeComments}}
-// CHECK-NEXT: {{value: *'2'}}
+// CHECK-DAG: {{- key: *google-readability-braces-around-statements.ShortStatementLines *[[:space:]] *value: *'1'}}
+// CHECK-DAG: {{- key: *google-readability-function-size.StatementThreshold *[[:space:]] *value: *'800'}}
+// CHECK-DAG: {{- key: *google-readability-namespace-comments.ShortNamespaceLines *[[:space:]] *value: *'10'}}
+// CHECK-DAG: {{- key: *google-readability-namespace-comments.SpacesBeforeComments *[[:space:]] *value: *'2'}}
Index: clang-tools-extra/clang-tidy/ClangTidyOptions.

[PATCH] D84868: [clang-tidy] Use StringMap for ClangTidyOptions::OptionsMap

2020-07-29 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 281639.
njames93 added a comment.

Missing call to getValue()


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84868

Files:
  clang-tools-extra/clang-tidy/ClangTidy.cpp
  clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.h
  clang-tools-extra/test/clang-tidy/checkers/google-module.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp

Index: clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
@@ -17,14 +17,10 @@
 // For this test we have to use names of the real checks because otherwise values are ignored.
 // RUN: clang-tidy -dump-config %S/Inputs/config-files/4/44/- -- | FileCheck %s -check-prefix=CHECK-CHILD4
 // CHECK-CHILD4: Checks: {{.*}}modernize-loop-convert,modernize-use-using,llvm-qualified-auto
-// CHECK-CHILD4: - key: llvm-qualified-auto.AddConstToQualified
-// CHECK-CHILD4-NEXT: value: 'true'
-// CHECK-CHILD4: - key: modernize-loop-convert.MaxCopySize
-// CHECK-CHILD4-NEXT: value: '20'
-// CHECK-CHILD4: - key: modernize-loop-convert.MinConfidence
-// CHECK-CHILD4-NEXT: value: reasonable
-// CHECK-CHILD4: - key: modernize-use-using.IgnoreMacros
-// CHECK-CHILD4-NEXT: value: 'false'
+// CHECK-CHILD4-DAG: - key: llvm-qualified-auto.AddConstToQualified{{ *[[:space:]] *}}value: 'true'
+// CHECK-CHILD4-DAG: - key: modernize-loop-convert.MaxCopySize{{ *[[:space:]] *}}value: '20'
+// CHECK-CHILD4-DAG: - key: modernize-loop-convert.MinConfidence{{ *[[:space:]] *}}value: reasonable
+// CHECK-CHILD4-DAG: - key: modernize-use-using.IgnoreMacros{{ *[[:space:]] *}}value: 'false'
 
 // RUN: clang-tidy --explain-config %S/Inputs/config-files/4/44/- -- | FileCheck %s -check-prefix=CHECK-EXPLAIN
 // CHECK-EXPLAIN: 'llvm-qualified-auto' is enabled in the {{.*}}{{[/\\]}}Inputs{{[/\\]}}config-files{{[/\\]}}4{{[/\\]}}44{{[/\\]}}.clang-tidy.
@@ -37,16 +33,13 @@
 // RUN: CheckOptions: [{key: modernize-loop-convert.MaxCopySize, value: 21}]}' \
 // RUN: %S/Inputs/config-files/4/44/- -- | FileCheck %s -check-prefix=CHECK-CHILD5
 // CHECK-CHILD5: Checks: {{.*}}modernize-loop-convert,modernize-use-using,llvm-qualified-auto,-llvm-qualified-auto
-// CHECK-CHILD5: - key: modernize-loop-convert.MaxCopySize
-// CHECK-CHILD5-NEXT: value: '21'
-// CHECK-CHILD5: - key: modernize-loop-convert.MinConfidence
-// CHECK-CHILD5-NEXT: value: reasonable
-// CHECK-CHILD5: - key: modernize-use-using.IgnoreMacros
-// CHECK-CHILD5-NEXT: value: 'false'
+// CHECK-CHILD5-DAG: - key: modernize-loop-convert.MaxCopySize{{ *[[:space:]] *}}value: '21'
+// CHECK-CHILD5-DAG: - key: modernize-loop-convert.MinConfidence{{ *[[:space:]] *}}value: reasonable
+// CHECK-CHILD5-DAG: - key: modernize-use-using.IgnoreMacros{{ *[[:space:]] *}}value: 'false'
 
 // RUN: clang-tidy -dump-config \
 // RUN: --config='{InheritParentConfig: false, \
 // RUN: Checks: -llvm-qualified-auto}' \
 // RUN: %S/Inputs/config-files/4/44/- -- | FileCheck %s -check-prefix=CHECK-CHILD6
-// CHECK-CHILD6: Checks: {{.*}}-llvm-qualified-auto
+// CHECK-CHILD6: Checks: {{.*-llvm-qualified-auto'? *$}}
 // CHECK-CHILD6-NOT: - key: modernize-use-using.IgnoreMacros
Index: clang-tools-extra/test/clang-tidy/checkers/google-module.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/google-module.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/google-module.cpp
@@ -1,10 +1,6 @@
 // RUN: clang-tidy -checks='-*,google*' -config='{}' -dump-config - -- | FileCheck %s
 // CHECK: CheckOptions:
-// CHECK: {{- key: *google-readability-braces-around-statements.ShortStatementLines}}
-// CHECK-NEXT: {{value: *'1'}}
-// CHECK: {{- key: *google-readability-function-size.StatementThreshold}}
-// CHECK-NEXT: {{value: *'800'}}
-// CHECK: {{- key: *google-readability-namespace-comments.ShortNamespaceLines}}
-// CHECK-NEXT: {{value: *'10'}}
-// CHECK: {{- key: *google-readability-namespace-comments.SpacesBeforeComments}}
-// CHECK-NEXT: {{value: *'2'}}
+// CHECK-DAG: {{- key: *google-readability-braces-around-statements.ShortStatementLines *[[:space:]] *value: *'1'}}
+// CHECK-DAG: {{- key: *google-readability-function-size.StatementThreshold *[[:space:]] *value: *'800'}}
+// CHECK-DAG: {{- key: *google-readability-namespace-comments.ShortNamespaceLines *[[:space:]] *value: *'10'}}
+// CHECK-DAG: {{- key: *google-readability-namespace-comments.SpacesBeforeComments *[[:space:]] *value: *'2'}}
Index: clang-tools-extra/clang-tidy/ClangTidyOptions.h
===
--- clang-tools-extra/clang-tidy/ClangTidyOptions.h
+++ clang-tools-extra/clang-

[PATCH] D84711: [OpenMP] Implement TR8 `present` motion modifier in Clang (1/2)

2020-07-29 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:8055
   for (const auto L : C->component_lists()) {
-InfoGen(std::get<0>(L), std::get<1>(L), OMPC_MAP_to, llvm::None,
+SmallVector MapModifiers;
+translateMotionModifiers(C->getMotionModifiers(), MapModifiers);

jdenny wrote:
> I haven't managed to locally reproduce the bot failures I saw today when 
> trying to push this patch.  Somehow they're dropping the present modifiers 
> during codegen.  I think it's due to memory corruption that my machines 
> aren't managing to experience.  The culprit seems to be that `MapModifiers` 
> is local here, but the `InfoGen` call below stores it in a `MapInfo` as an 
> `ArrayRef`, which becames a dangling ref by the time it's used.
> 
> One solution is to change `MapInfo` to store a `SmallVector` instead.  
> Another would be for `MapInfo` to store a second `ArrayRef` for 
> `C->getMotionModifiers()`, which would be translated to runtime map flags 
> later.  I'm planning to try the latter solution tomorrow.  I prefer it 
> because it seems more space efficient and because it translates motion 
> modifiers directly to runtime flags instead of translating to map type 
> modifiers first.
9f2f3b9de6314a009322b6081c792ebf9a469460 relands this patch with the latter 
solution.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84711

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


[PATCH] D80391: [Driver] Don't make -gsplit-dwarf imply -g2

2020-07-29 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D80391#2179182 , @MaskRay wrote:

> Ping...

Was hoping to get some more discussion on the general debug flag naming thread 
on the GCC list, but that hasn't happened - so I've replied/poked it a bit: 
https://gcc.gnu.org/pipermail/gcc/2020-July/233282.html (@echristo - sorry, 
thought you were on that thread, guess you got dropped somewhere along the way 
(I saw an "Eric" in the reply line and figured it was you) - wouldn't mind if 
you took a look/weighed in, if you've got anything to share on the topic)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80391

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


[PATCH] D84870: [DebugInfo] Fix to ctor homing to ignore classes with trivial ctors.

2020-07-29 Thread Amy Huang via Phabricator via cfe-commits
akhuang created this revision.
akhuang added a reviewer: dblaikie.
Herald added subscribers: cfe-commits, aprantl.
Herald added a project: clang.
akhuang requested review of this revision.

Previously ctor homing was omitting debug info for classes if they
have both trival and nontrivial constructors, but we should only omit debug
info if the class doesn't have any trivial constructors.

Also change to use completeUnusedClass so the debug info is added to the
retained types list.

bug: https://bugs.llvm.org/show_bug.cgi?id=46537


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84870

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-limited-ctor.cpp


Index: clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
===
--- clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
+++ clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
@@ -24,3 +24,9 @@
 struct E {
   constexpr E(){};
 } TestE;
+
+// CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: 
"F"{{.*}}DIFlagTypePassByValue
+struct F {
+  F() = default;
+  F(int) {}
+} TestF;
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1705,14 +1705,13 @@
   // info is emitted.
   if (DebugKind == codegenoptions::DebugInfoConstructor)
 if (const CXXConstructorDecl *CD = dyn_cast(Method))
-  completeClass(CD->getParent());
+  completeUnusedClass(*CD->getParent());
 
   llvm::DINodeArray TParamsArray = CollectFunctionTemplateParams(Method, Unit);
   llvm::DISubprogram *SP = DBuilder.createMethod(
   RecordTy, MethodName, MethodLinkageName, MethodDefUnit, MethodLine,
   MethodTy, VIndex, ThisAdjustment, ContainingType, Flags, SPFlags,
   TParamsArray.get());
-
   SPCache[Method->getCanonicalDecl()].reset(SP);
 
   return SP;
@@ -2296,12 +2295,19 @@
   // In constructor debug mode, only emit debug info for a class when its
   // constructor is emitted. Skip this optimization if the class or any of
   // its methods are marked dllimport.
+  //
+  // This applies to classes that don't have any trivial constructors and have
+  // at least one constructor.
   if (DebugKind == codegenoptions::DebugInfoConstructor &&
   !CXXDecl->isLambda() && !CXXDecl->hasConstexprNonCopyMoveConstructor() &&
-  !isClassOrMethodDLLImport(CXXDecl))
+  !isClassOrMethodDLLImport(CXXDecl)) {
+if (CXXDecl->ctors().empty())
+  return false;
 for (const auto *Ctor : CXXDecl->ctors())
-  if (Ctor->isUserProvided())
-return true;
+  if (Ctor->isTrivial() && !Ctor->isCopyOrMoveConstructor())
+return false;
+return true;
+  }
 
   TemplateSpecializationKind Spec = TSK_Undeclared;
   if (const auto *SD = dyn_cast(RD))


Index: clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
===
--- clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
+++ clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
@@ -24,3 +24,9 @@
 struct E {
   constexpr E(){};
 } TestE;
+
+// CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "F"{{.*}}DIFlagTypePassByValue
+struct F {
+  F() = default;
+  F(int) {}
+} TestF;
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1705,14 +1705,13 @@
   // info is emitted.
   if (DebugKind == codegenoptions::DebugInfoConstructor)
 if (const CXXConstructorDecl *CD = dyn_cast(Method))
-  completeClass(CD->getParent());
+  completeUnusedClass(*CD->getParent());
 
   llvm::DINodeArray TParamsArray = CollectFunctionTemplateParams(Method, Unit);
   llvm::DISubprogram *SP = DBuilder.createMethod(
   RecordTy, MethodName, MethodLinkageName, MethodDefUnit, MethodLine,
   MethodTy, VIndex, ThisAdjustment, ContainingType, Flags, SPFlags,
   TParamsArray.get());
-
   SPCache[Method->getCanonicalDecl()].reset(SP);
 
   return SP;
@@ -2296,12 +2295,19 @@
   // In constructor debug mode, only emit debug info for a class when its
   // constructor is emitted. Skip this optimization if the class or any of
   // its methods are marked dllimport.
+  //
+  // This applies to classes that don't have any trivial constructors and have
+  // at least one constructor.
   if (DebugKind == codegenoptions::DebugInfoConstructor &&
   !CXXDecl->isLambda() && !CXXDecl->hasConstexprNonCopyMoveConstructor() &&
-  !isClassOrMethodDLLImport(CXXDecl))
+  !isClassOrMethodDLLImport(CXXDecl)) {
+if (CXXDecl->ctors().empty())
+  return false;
 for (const auto *Ctor : CXXDecl->ctors())
-  if (Ctor->isUserProvided())
-return true;
+  if (Ctor->isTrivial() && !Ctor->isCopyOrMoveConstructor())
+return false;
+return true;
+  }
 
   TemplateSpec

[PATCH] D84678: [clang] False line number in a function definition with "void" parameter

2020-07-29 Thread Jaydeep Chauhan via Phabricator via cfe-commits
Jac1494 updated this revision to Diff 281644.
Jac1494 added a comment.

Address @aaron.ballman review comments.
I have added your test case that is passing as well.
This patch covers this scenario also.
Thanks @aaron.ballman


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

https://reviews.llvm.org/D84678

Files:
  clang/lib/Sema/SemaType.cpp
  clang/test/Sema/void-argument.cpp
  clang/test/Sema/void-unnamed.cpp


Index: clang/test/Sema/void-unnamed.cpp
===
--- /dev/null
+++ clang/test/Sema/void-unnamed.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void foo(
+int a,
+void, // expected-error{{'void' must be the first and only parameter if 
specified}}
+int b);
+
+void bar(
+void, // expected-error{{'void' must be the first and only parameter if 
specified}}
+...);
+
+struct S {
+  S(
+  void,  // expected-error{{'void' must be the first and only parameter if 
specified}}
+  void); // expected-error{{'void' must be the first and only parameter if 
specified}}
+};
Index: clang/test/Sema/void-argument.cpp
===
--- /dev/null
+++ clang/test/Sema/void-argument.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+void foo(
+void a, // expected-error{{'void' must be the first and only parameter if 
specified}}
+double b,
+int c,
+void d, // expected-error{{'void' must be the first and only parameter if 
specified}}
+int e,
+void f) // expected-error{{'void' must be the first and only parameter if 
specified}}
+{}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -5109,7 +5109,7 @@
 // is an incomplete type (C99 6.2.5p19) and function decls cannot
 // have parameters of incomplete type.
 if (FTI.NumParams != 1 || FTI.isVariadic) {
-  S.Diag(DeclType.Loc, diag::err_void_only_param);
+  S.Diag(FTI.Params[i].IdentLoc, diag::err_void_only_param);
   ParamTy = Context.IntTy;
   Param->setType(ParamTy);
 } else if (FTI.Params[i].Ident) {


Index: clang/test/Sema/void-unnamed.cpp
===
--- /dev/null
+++ clang/test/Sema/void-unnamed.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void foo(
+int a,
+void, // expected-error{{'void' must be the first and only parameter if specified}}
+int b);
+
+void bar(
+void, // expected-error{{'void' must be the first and only parameter if specified}}
+...);
+
+struct S {
+  S(
+  void,  // expected-error{{'void' must be the first and only parameter if specified}}
+  void); // expected-error{{'void' must be the first and only parameter if specified}}
+};
Index: clang/test/Sema/void-argument.cpp
===
--- /dev/null
+++ clang/test/Sema/void-argument.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+void foo(
+void a, // expected-error{{'void' must be the first and only parameter if specified}}
+double b,
+int c,
+void d, // expected-error{{'void' must be the first and only parameter if specified}}
+int e,
+void f) // expected-error{{'void' must be the first and only parameter if specified}}
+{}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -5109,7 +5109,7 @@
 // is an incomplete type (C99 6.2.5p19) and function decls cannot
 // have parameters of incomplete type.
 if (FTI.NumParams != 1 || FTI.isVariadic) {
-  S.Diag(DeclType.Loc, diag::err_void_only_param);
+  S.Diag(FTI.Params[i].IdentLoc, diag::err_void_only_param);
   ParamTy = Context.IntTy;
   Param->setType(ParamTy);
 } else if (FTI.Params[i].Ident) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84870: [DebugInfo] Fix to ctor homing to ignore classes with trivial ctors.

2020-07-29 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

I think it'd be good to separate these two issues/patches.

In part because I'm curious whether, even with a trivial ctor - if we did the 
retained types thing - would that be enough?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84870

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


[PATCH] D84837: [clangd] Fix an assertion failure in TargetFinder's heuristic resolution of dependent type.

2020-07-29 Thread Nathan Ridge via Phabricator via cfe-commits
nridge accepted this revision.
nridge added a comment.
This revision is now accepted and ready to land.

Thanks!




Comment at: clang-tools-extra/clangd/FindTarget.cpp:171
 // or more declarations that it likely references.
-std::vector resolveDependentExprToDecls(const Expr *E) {
-  assert(E->isTypeDependent());
+std::vector resolveExprToDecls(const Expr *E) {
   if (const auto *ME = dyn_cast(E)) {

I do think the "heuristic" nature of this function is an important part of its 
interface that's currently lost with this rename.

However, I think that's fine for now. In a future refactor (to get 
code-completion to use this machinery as well) I plan to move these functions 
into a `HeuristicResolver` class or a `heuristics` sub-namespace or something 
like that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84837

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


[PATCH] D84707: [DFSan][NewPM] Port DataFlowSanitizer to NewPM

2020-07-29 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse accepted this revision.
morehouse added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84707

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


[PATCH] D83281: [OpenMP] Allow traits for the OpenMP context selector `isa`

2020-07-29 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

This breaks check-clang on Windows: http://45.33.8.238/win/20850/step_7.txt

Please take a look, and revert while you investigate if it takes a while to fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83281

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


[PATCH] D84494: [Analyzer] Use of BugType in DereferenceChecker (NFC).

2020-07-29 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko accepted this revision.
vsavchenko added a comment.

Awesome, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84494

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


[PATCH] D84494: [Analyzer] Use of BugType in DereferenceChecker (NFC).

2020-07-29 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.

Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84494

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


  1   2   >