[PATCH] D69933: [ASTImporter] Limit imports of structs

2020-01-21 Thread Jaroslav Sevcik via Phabricator via cfe-commits
jarin updated this revision to Diff 239235.
jarin added a comment.
Herald added a subscriber: lldb-commits.

I changed the diff so that it does not touch Clang's AST importer, instead it 
patches LLDB's wrapper of the AST importer.

The idea is to only import complete a record if the current evaluation asked 
for them to be completed. In particular, if the current evaluation has not ask 
for a record R to be completed and LLDB is being asked to import R, we supply 
an incomplete version of R even if we happen to have a complete definition of R 
lying around in parsed debug info.

This is achieved in a hacky way - if we have a complete record R, we pretend it 
is incomplete by temporarily clearing R's isCompleteDefinition bit. 
Interestingly, this hack is already used in 
ClangASTImporter::ASTImporterDelegate::ImportDefinitionTo.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69933

Files:
  lldb/include/lldb/Symbol/ClangASTImporter.h
  lldb/source/Symbol/ClangASTImporter.cpp


Index: lldb/source/Symbol/ClangASTImporter.cpp
===
--- lldb/source/Symbol/ClangASTImporter.cpp
+++ lldb/source/Symbol/ClangASTImporter.cpp
@@ -42,9 +42,12 @@
   if (!delegate_sp)
 return CompilerType();
 
+  delegate_sp->SetCompleted(src_qual_type->getAsTagDecl());
+
   ASTImporterDelegate::CxxModuleScope std_scope(*delegate_sp, &dst_clang_ast);
 
   llvm::Expected ret_or_error = delegate_sp->Import(src_qual_type);
+
   if (!ret_or_error) {
 Log *log =
   lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS);
@@ -252,6 +255,7 @@
   if (auto *tag_decl = dyn_cast(decl)) {
 if (auto *original_tag_decl = dyn_cast(original_decl)) {
   if (original_tag_decl->isCompleteDefinition()) {
+m_delegate->SetCompleted(original_tag_decl);
 m_delegate->ImportDefinitionTo(tag_decl, original_tag_decl);
 tag_decl->setCompleteDefinition(true);
   }
@@ -584,6 +588,8 @@
   ImporterDelegateSP delegate_sp(
   GetDelegate(&decl->getASTContext(), decl_origin.ctx));
 
+  delegate_sp->SetCompleted(decl_origin.decl);
+
   ASTImporterDelegate::CxxModuleScope std_scope(*delegate_sp,
 &decl->getASTContext());
   if (delegate_sp)
@@ -855,6 +861,10 @@
 
 ClangASTImporter::MapCompleter::~MapCompleter() { return; }
 
+void ClangASTImporter::ASTImporterDelegate::SetCompleted(Decl *from) {
+  m_completed_decls.insert(from);
+}
+
 llvm::Expected
 ClangASTImporter::ASTImporterDelegate::ImportImpl(Decl *From) {
   if (m_std_handler) {
@@ -903,7 +913,20 @@
 }
   }
 
-  return ASTImporter::ImportImpl(From);
+  CXXRecordDecl *record_decl_to_set_complete = nullptr;
+  if (CXXRecordDecl *record_decl = dyn_cast(From)) {
+if (record_decl->isCompleteDefinition() &&
+!record_decl->isAnonymousStructOrUnion() &&
+m_completed_decls.find(From) == m_completed_decls.end()) {
+  record_decl->setCompleteDefinition(false);
+  record_decl_to_set_complete = record_decl;
+}
+  }
+  llvm::Expected result = ASTImporter::ImportImpl(From);
+  if (record_decl_to_set_complete) {
+record_decl_to_set_complete->setCompleteDefinition(true);
+  }
+  return result;
 }
 
 void ClangASTImporter::ASTImporterDelegate::ImportDefinitionTo(
Index: lldb/include/lldb/Symbol/ClangASTImporter.h
===
--- lldb/include/lldb/Symbol/ClangASTImporter.h
+++ lldb/include/lldb/Symbol/ClangASTImporter.h
@@ -231,6 +231,8 @@
 
 clang::Decl *GetOriginalDecl(clang::Decl *To) override;
 
+void SetCompleted(clang::Decl *from);
+
 void SetImportListener(NewDeclListener *listener) {
   assert(m_new_decl_listener == nullptr && "Already attached a listener?");
   m_new_decl_listener = listener;
@@ -246,6 +248,7 @@
 /// were created from the 'std' C++ module to prevent that the Importer
 /// tries to sync them with the broken equivalent in the debug info AST.
 llvm::SmallPtrSet m_decls_to_ignore;
+llvm::SmallPtrSet m_completed_decls;
 ClangASTImporter &m_master;
 clang::ASTContext *m_source_ctx;
 CxxModuleHandler *m_std_handler = nullptr;
@@ -257,6 +260,7 @@
   typedef llvm::DenseMap DelegateMap;
   typedef llvm::DenseMap
   NamespaceMetaMap;
+  typedef std::set CompletedRecordSet;
 
   struct ASTContextMetadata {
 ASTContextMetadata(clang::ASTContext *dst_ctx)


Index: lldb/source/Symbol/ClangASTImporter.cpp
===
--- lldb/source/Symbol/ClangASTImporter.cpp
+++ lldb/source/Symbol/ClangASTImporter.cpp
@@ -42,9 +42,12 @@
   if (!delegate_sp)
 return CompilerType();
 
+  delegate_sp->SetCompleted(src_qual_type->getAsTagDecl());
+
   ASTImporterDelegate::CxxModuleScope std_scope(*delegate_sp, &dst_clang_ast);
 
   llvm::Expected ret_or_er

[PATCH] D71566: New checks for fortified sprintf

2020-01-21 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 239242.
serge-sans-paille added a comment.

More tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71566

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/warn-fortify-source.c

Index: clang/test/Sema/warn-fortify-source.c
===
--- clang/test/Sema/warn-fortify-source.c
+++ clang/test/Sema/warn-fortify-source.c
@@ -11,6 +11,8 @@
 extern "C" {
 #endif
 
+extern int sprintf(char *str, const char *format, ...);
+
 #if defined(USE_PASS_OBJECT_SIZE)
 void *memcpy(void *dst, const void *src, size_t c);
 static void *memcpy(void *dst __attribute__((pass_object_size(1))), const void *src, size_t c) __attribute__((overloadable)) __asm__("merp");
@@ -96,6 +98,59 @@
   __builtin_vsnprintf(buf, 11, "merp", list); // expected-warning {{'vsnprintf' size argument is too large; destination buffer has size 10, but size argument is 11}}
 }
 
+void call_sprintf_chk(char *buf) {
+  __builtin___sprintf_chk(buf, 1, 6, "hell\0 boy"); // expected-warning {{format string contains '\0' within the string body}}
+  __builtin___sprintf_chk(buf, 1, 2, "hell\0 boy"); // expected-warning {{format string contains '\0' within the string body}}
+  // expected-warning@-1 {{'sprintf' will always overflow; destination buffer has size 2, but format string expands to at least 5}}
+  __builtin___sprintf_chk(buf, 1, 6, "hello");
+  __builtin___sprintf_chk(buf, 1, 5, "hello"); // expected-warning {{'sprintf' will always overflow; destination buffer has size 5, but format string expands to at least 6}}
+  __builtin___sprintf_chk(buf, 1, 2, "%c", '9');
+  __builtin___sprintf_chk(buf, 1, 1, "%c", '9'); // expected-warning {{'sprintf' will always overflow; destination buffer has size 1, but format string expands to at least 2}}
+  __builtin___sprintf_chk(buf, 1, 2, "%d", 9);
+  __builtin___sprintf_chk(buf, 1, 1, "%d", 9); // expected-warning {{'sprintf' will always overflow; destination buffer has size 1, but format string expands to at least 2}}
+  __builtin___sprintf_chk(buf, 1, 2, "%%");
+  __builtin___sprintf_chk(buf, 1, 1, "%%"); // expected-warning {{'sprintf' will always overflow; destination buffer has size 1, but format string expands to at least 2}}
+  __builtin___sprintf_chk(buf, 1, 4, "%#x", 9);
+  __builtin___sprintf_chk(buf, 1, 3, "%#x", 9); // expected-warning {{'sprintf' will always overflow; destination buffer has size 3, but format string expands to at least 4}}
+  __builtin___sprintf_chk(buf, 1, 4, "%p", (void *)9);
+  __builtin___sprintf_chk(buf, 1, 3, "%p", (void *)9); // expected-warning {{'sprintf' will always overflow; destination buffer has size 3, but format string expands to at least 4}}
+  __builtin___sprintf_chk(buf, 1, 3, "%+d", 9);
+  __builtin___sprintf_chk(buf, 1, 2, "%+d", 9); // expected-warning {{'sprintf' will always overflow; destination buffer has size 2, but format string expands to at least 3}}
+  __builtin___sprintf_chk(buf, 1, 6, "%5d", 9);
+  __builtin___sprintf_chk(buf, 1, 5, "%5d", 9); // expected-warning {{'sprintf' will always overflow; destination buffer has size 5, but format string expands to at least 6}}
+  __builtin___sprintf_chk(buf, 1, 9, "%f", 9.f);
+  __builtin___sprintf_chk(buf, 1, 8, "%f", 9.f); // expected-warning {{'sprintf' will always overflow; destination buffer has size 8, but format string expands to at least 9}}
+  __builtin___sprintf_chk(buf, 1, 12, "%e", 9.f);
+  __builtin___sprintf_chk(buf, 1, 11, "%e", 9.f); // expected-warning {{'sprintf' will always overflow; destination buffer has size 11, but format string expands to at least 12}}
+}
+
+void call_sprintf() {
+  char buf[6];
+  sprintf(buf, "hell\0 boy"); // expected-warning {{format string contains '\0' within the string body}}
+  sprintf(buf, "hello b\0y"); // expected-warning {{format string contains '\0' within the string body}}
+  // expected-warning@-1 {{'sprintf' will always overflow; destination buffer has size 6, but format string expands to at least 8}}
+  sprintf(buf, "hello");
+  sprintf(buf, "hello!"); // expected-warning {{'sprintf' will always overflow; destination buffer has size 6, but format string expands to at least 7}}
+  sprintf(buf, "1234%%");
+  sprintf(buf, "12345%%"); // expected-warning {{'sprintf' will always overflow; destination buffer has size 6, but format string expands to at least 7}}
+  sprintf(buf, "1234%c", '9');
+  sprintf(buf, "12345%c", '9'); // expected-warning {{'sprintf' will always overflow; destination buffer has size 6, but format string expands to at least 7}}
+  sprintf(buf, "1234%d", 9);
+  sprintf(buf, "12345%d", 9); // expected-warning {{'sprintf' will always overflow; destination buffer has size 6, but format string expands to at least 7}}
+  sprintf(buf, "12%#x", 9);
+  sprintf(buf, "123%#x", 9); // expected-warning {{'spr

[PATCH] D71698: [AArch64][SVE] Add intrinsic for non-faulting loads

2020-01-21 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen accepted this revision.
sdesmalen added a comment.
This revision is now accepted and ready to land.

LGTM [with the caveat that we need to revisit the modelling of the `FFR` 
register and get rid fo the `PseudoInstExpansion` at a later point, as 
discussed during the previous sync-up call]


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

https://reviews.llvm.org/D71698



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


[PATCH] D71566: New checks for fortified sprintf

2020-01-21 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62043 tests passed, 0 failed 
and 783 were skipped.

{icon question-circle color=gray} clang-tidy: unknown.

{icon times-circle color=red} clang-format: fail. Please format your changes 
with clang-format by running `git-clang-format HEAD^` or applying this patch 
.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71566



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


[PATCH] D72825: Remove unused option that gcc ignored

2020-01-21 Thread Jim Lin via Phabricator via cfe-commits
Jim updated this revision to Diff 239246.
Jim retitled this revision from "[NFC] Fix options name typo" to "Remove unused 
option that gcc ignored".
Jim edited the summary of this revision.
Jim added a comment.

Address the comment. Delete the options.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72825

Files:
  clang/include/clang/Driver/Options.td
  clang/test/Driver/clang_f_opts.c


Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -292,9 +292,6 @@
 // RUN: -frename-registers\
 // RUN: -fschedule-insns2 \
 // RUN: -fsingle-precision-constant   \
-// RUN: -ftree_loop_im\
-// RUN: -ftree_loop_ivcanon   \
-// RUN: -ftree_loop_linear\
 // RUN: -funsafe-loop-optimizations   \
 // RUN: -fuse-linker-plugin   \
 // RUN: -fvect-cost-model \
@@ -432,9 +429,6 @@
 // CHECK-WARNING-DAG: optimization flag '-frename-registers' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fschedule-insns2' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fsingle-precision-constant' is not 
supported
-// CHECK-WARNING-DAG: optimization flag '-ftree_loop_im' is not supported
-// CHECK-WARNING-DAG: optimization flag '-ftree_loop_ivcanon' is not supported
-// CHECK-WARNING-DAG: optimization flag '-ftree_loop_linear' is not supported
 // CHECK-WARNING-DAG: optimization flag '-funsafe-loop-optimizations' is not 
supported
 // CHECK-WARNING-DAG: optimization flag '-fuse-linker-plugin' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fvect-cost-model' is not supported
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3306,9 +3306,6 @@
 defm tls_model : BooleanFFlag<"tls-model">, Group;
 defm tracer : BooleanFFlag<"tracer">, 
Group;
 defm tree_dce : BooleanFFlag<"tree-dce">, 
Group;
-defm tree_loop_im : BooleanFFlag<"tree_loop_im">,  
Group;
-defm tree_loop_ivcanon : BooleanFFlag<"tree_loop_ivcanon">,  
Group;
-defm tree_loop_linear : BooleanFFlag<"tree_loop_linear">,  
Group;
 defm tree_salias : BooleanFFlag<"tree-salias">, Group;
 defm tree_ter : BooleanFFlag<"tree-ter">, 
Group;
 defm tree_vectorizer_verbose : BooleanFFlag<"tree-vectorizer-verbose">, 
Group;


Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -292,9 +292,6 @@
 // RUN: -frename-registers\
 // RUN: -fschedule-insns2 \
 // RUN: -fsingle-precision-constant   \
-// RUN: -ftree_loop_im\
-// RUN: -ftree_loop_ivcanon   \
-// RUN: -ftree_loop_linear\
 // RUN: -funsafe-loop-optimizations   \
 // RUN: -fuse-linker-plugin   \
 // RUN: -fvect-cost-model \
@@ -432,9 +429,6 @@
 // CHECK-WARNING-DAG: optimization flag '-frename-registers' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fschedule-insns2' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fsingle-precision-constant' is not supported
-// CHECK-WARNING-DAG: optimization flag '-ftree_loop_im' is not supported
-// CHECK-WARNING-DAG: optimization flag '-ftree_loop_ivcanon' is not supported
-// CHECK-WARNING-DAG: optimization flag '-ftree_loop_linear' is not supported
 // CHECK-WARNING-DAG: optimization flag '-funsafe-loop-optimizations' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fuse-linker-plugin' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fvect-cost-model' is not supported
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3306,9 +3306,6 @@
 defm tls_model : BooleanFFlag<"tls-model">, Group;
 defm tracer : BooleanFFlag<"tracer">, Group;
 defm tree_dce : BooleanFFlag<"tree-dce">, Group;
-defm tree_loop_im : BooleanFFlag<"tree_loop

[PATCH] D73052: [clang-tidy] RenamerClangTidy now renames dependent member expr when the member can be resolved

2020-01-21 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 239253.
njames93 added a comment.

- Fix assertion causing failing tests in debug


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73052

Files:
  clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp
@@ -1,7 +1,8 @@
 // RUN: %check_clang_tidy %s readability-identifier-naming %t -- \
 // RUN:   -config='{CheckOptions: [ \
 // RUN: {key: readability-identifier-naming.MemberCase, value: CamelCase}, \
-// RUN: {key: readability-identifier-naming.ParameterCase, value: CamelCase} \
+// RUN: {key: readability-identifier-naming.ParameterCase, value: CamelCase}, \
+// RUN: {key: readability-identifier-naming.MethodCase, value: camelBack} \
 // RUN:  ]}' -- -fno-delayed-template-parsing
 
 int set_up(int);
@@ -83,12 +84,12 @@
 }; //NOLINT
 }; // namespace std
 
-class Foo { 
+class Foo {
   std::vector &stack;
   // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: invalid case style for member 'stack' [readability-identifier-naming]
 public:
   Foo(std::vector &stack)
-  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: invalid case style for parameter 'stack' [readability-identifier-naming]
+  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: invalid case style for parameter 'stack' [readability-identifier-naming]
   // CHECK-FIXES: {{^}}  Foo(std::vector &Stack)
   : stack(stack) {
 // CHECK-FIXES: {{^}}  : Stack(Stack) {
@@ -134,4 +135,94 @@
 void foo() {
   Container container;
 }
-}; // namespace CtorInits
+} // namespace CtorInits
+
+namespace resolved_dependance {
+template 
+struct A0 {
+  int value;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for member 'value'
+  A0 &operator=(const A0 &Other) {
+value = Other.value;   // A0
+this->value = Other.value; // A0
+// CHECK-FIXES:  {{^}}Value = Other.Value;   // A0
+// CHECK-FIXES-NEXT: {{^}}this->Value = Other.Value; // A0
+return *this;
+  }
+  void outOfLineReset();
+};
+
+template 
+void A0::outOfLineReset() {
+  this->value -= value; // A0
+  // CHECK-FIXES: {{^}}  this->Value -= Value; // A0
+}
+
+template 
+struct A1 {
+  int value; // A1
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for member 'value'
+  // CHECK-FIXES: {{^}}  int Value; // A1
+  int GetValue() const { return value; } // A1
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for method 'GetValue'
+  // CHECK-FIXES {{^}}  int getValue() const { return Value; } // A1
+  void SetValue(int Value) { this->value = Value; } // A1
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for method 'SetValue'
+  // CHECK-FIXES {{^}}  void setValue(int Value) { this->Value = Value; } // A1
+  A1 &operator=(const A1 &Other) {
+this->SetValue(Other.GetValue()); // A1
+this->value = Other.value;// A1
+// CHECK-FIXES:  {{^}}this->setValue(Other.getValue()); // A1
+// CHECK-FIXES-NEXT: {{^}}this->Value = Other.Value;// A1
+return *this;
+  }
+  void outOfLineReset();
+};
+
+template 
+void A1::outOfLineReset() {
+  this->value -= value; // A1
+  // CHECK-FIXES: {{^}}  this->Value -= Value; // A1
+}
+
+template 
+struct A2 {
+  int value; // A2
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for member 'value'
+  // CHECK-FIXES: {{^}}  int Value; // A2
+  A2 &operator=(const A2 &Other) {
+value = Other.value;   // A2
+this->value = Other.value; // A2
+// CHECK-FIXES:  {{^}}Value = Other.Value;   // A2
+// CHECK-FIXES-NEXT: {{^}}this->Value = Other.Value; // A2
+return *this;
+  }
+};
+
+// create some instances to check it works when instantiated.
+A1 AInt{};
+A1 BInt = (AInt.outOfLineReset(), AInt);
+A1 AUnsigned{};
+A1 BUnsigned = AUnsigned;
+} // namespace resolved_dependance
+
+namespace unresolved_dependance {
+template 
+struct DependentBase {
+  int depValue;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for member 'depValue'
+};
+
+template 
+struct Derived : DependentBase {
+  Derived &operator=(const Derived &Other) {
+this->depValue = Other.depValue;
+// CHECK-FIXES-NOT: {{^}}this->DepValue = Other.DepValue;
+return *this;
+  }
+};
+
+Derived AInt{};
+Derived BInt = AInt;
+
+} // namespace unresolved_dependance
Index: clang-tools-extra/docs/ReleaseNotes.rst
===

[PATCH] D73052: [clang-tidy] RenamerClangTidy now renames dependent member expr when the member can be resolved

2020-01-21 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62041 tests passed, 0 failed 
and 783 were skipped.

{icon question-circle color=gray} clang-tidy: unknown.

{icon times-circle color=red} clang-format: fail. Please format your changes 
with clang-format by running `git-clang-format HEAD^` or applying this patch 
.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73052



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


[PATCH] D68720: Support -fstack-clash-protection for x86

2020-01-21 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 239257.
serge-sans-paille added a comment.

Update warning category


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68720

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/DiagnosticCommonKinds.td
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/stack-clash-protection.c
  clang/test/Driver/stack-clash-protection.c
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/lib/Target/X86/X86CallFrameOptimization.cpp
  llvm/lib/Target/X86/X86FrameLowering.cpp
  llvm/lib/Target/X86/X86FrameLowering.h
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86ISelLowering.h
  llvm/lib/Target/X86/X86InstrCompiler.td
  llvm/lib/Target/X86/X86InstrInfo.td
  llvm/test/CodeGen/X86/stack-clash-dynamic-alloca.ll
  llvm/test/CodeGen/X86/stack-clash-large.ll
  llvm/test/CodeGen/X86/stack-clash-medium-natural-probes-mutliple-objects.ll
  llvm/test/CodeGen/X86/stack-clash-medium-natural-probes.ll
  llvm/test/CodeGen/X86/stack-clash-medium.ll
  llvm/test/CodeGen/X86/stack-clash-no-free-probe.ll
  llvm/test/CodeGen/X86/stack-clash-small.ll
  llvm/test/CodeGen/X86/stack-clash-unknown-call.ll

Index: llvm/test/CodeGen/X86/stack-clash-unknown-call.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/stack-clash-unknown-call.ll
@@ -0,0 +1,31 @@
+; RUN: llc < %s | FileCheck %s
+
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i1 immarg);
+
+define void @foo() local_unnamed_addr #0 {
+
+;CHECK-LABEL: foo:
+;CHECK: # %bb.0:
+;CHECK-NEXT:	subq	$4096, %rsp # imm = 0x1000
+; it's important that we don't use the call as a probe here
+;CHECK-NEXT:	movq	$0, (%rsp)
+;CHECK-NEXT:	subq	$3912, %rsp # imm = 0xF48
+;CHECK-NEXT:	.cfi_def_cfa_offset 8016
+;CHECK-NEXT:	movq	%rsp, %rdi
+;CHECK-NEXT:	movl	$8000, %edx # imm = 0x1F40
+;CHECK-NEXT:	xorl	%esi, %esi
+;CHECK-NEXT:	callq	memset
+;CHECK-NEXT:	addq	$8008, %rsp # imm = 0x1F48
+;CHECK-NEXT:	.cfi_def_cfa_offset 8
+;CHECK-NEXT:	retq
+
+  %a = alloca i8, i64 8000, align 16
+  call void @llvm.memset.p0i8.i64(i8* align 16 %a, i8 0, i64 8000, i1 false)
+  ret void
+}
+
+attributes #0 =  {"probe-stack"="inline-asm"}
Index: llvm/test/CodeGen/X86/stack-clash-small.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/stack-clash-small.ll
@@ -0,0 +1,25 @@
+; RUN: llc < %s | FileCheck %s
+
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define i32 @foo() local_unnamed_addr #0 {
+; CHECK-LABEL: foo:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:  subq	$280, %rsp # imm = 0x118
+; CHECK-NEXT:  .cfi_def_cfa_offset 288
+; CHECK-NEXT:  movl	$1, 264(%rsp)
+; CHECK-NEXT:  movl	-128(%rsp), %eax
+; CHECK-NEXT:  addq	$280, %rsp # imm = 0x118
+; CHECK-NEXT:  .cfi_def_cfa_offset 8
+; CHECK-NEXT:  retq
+
+  %a = alloca i32, i64 100, align 16
+  %b = getelementptr inbounds i32, i32* %a, i64 98
+  store volatile i32 1, i32* %b
+  %c = load volatile i32, i32* %a
+  ret i32 %c
+}
+
+attributes #0 =  {"probe-stack"="inline-asm"}
Index: llvm/test/CodeGen/X86/stack-clash-no-free-probe.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/stack-clash-no-free-probe.ll
@@ -0,0 +1,27 @@
+; RUN: llc < %s | FileCheck %s
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define i32 @foo(i64 %i) local_unnamed_addr #0 {
+; CHECK-LABEL: foo:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:  subq	$4096, %rsp # imm = 0x1000
+; CHECK-NEXT:  movq	$0, (%rsp)
+; CHECK-NEXT:  subq	$3784, %rsp # imm = 0xEC8
+; CHECK-NEXT:  .cfi_def_cfa_offset 7888
+; CHECK-NEXT:  movl	$1, -128(%rsp,%rdi,4)
+; CHECK-NEXT:  movl	-128(%rsp), %eax
+; CHECK-NEXT:  addq	$7880, %rsp # imm = 0x1EC8
+; CHECK-NEXT:  .cfi_def_cfa_offset 8
+; CHECK-NEXT:  retq
+
+  %a = alloca i32, i32 2000, align 16
+  %b = getelementptr inbounds i32, i32* %a, i64 %i
+  store volatile i32 1, i32* %b
+  %c = load volatile i32, i32* %a
+  ret i32 %c
+}
+
+attributes #0 =  {"probe-stack"="inline-asm"}
+
Index: llvm/test/CodeGen/X86/stack-clash-medium.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/stack-clash-medium.ll
@@ -0,0 +1,30 @@
+; RUN: llc < %s | FileCheck %s
+
+
+targe

[PATCH] D68720: Support -fstack-clash-protection for x86

2020-01-21 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon times-circle color=red} Unit tests: fail. 62059 tests passed, 1 failed 
and 783 were skipped.

  failed: Clang.CodeGen/stack-clash-protection.c

{icon question-circle color=gray} clang-tidy: unknown.

{icon times-circle color=red} clang-format: fail. Please format your changes 
with clang-format by running `git-clang-format HEAD^` or applying this patch 
.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68720



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


[PATCH] D73087: [Alignment][NFC] Use Align with CreateMaskedLoad

2020-01-21 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet created this revision.
gchatelet added a reviewer: courbet.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya.
Herald added projects: clang, LLVM.

This is patch is part of a series to introduce an Alignment type.
See this thread for context: 
http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73087

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  llvm/include/llvm/Analysis/VectorUtils.h
  llvm/include/llvm/IR/IRBuilder.h
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/IR/IRBuilder.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
===
--- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -2263,7 +2263,7 @@
   : ShuffledMask;
 }
 NewLoad =
-Builder.CreateMaskedLoad(AddrParts[Part], Group->getAlignment(),
+Builder.CreateMaskedLoad(AddrParts[Part], Group->getAlign(),
  GroupMask, UndefVec, "wide.masked.vec");
   }
   else
@@ -2475,8 +2475,8 @@
   auto *VecPtr = CreateVecPtr(Part, State.get(Addr, {0, 0}));
   if (isMaskRequired)
 NewLI = Builder.CreateMaskedLoad(
-VecPtr, Alignment.value(), BlockInMaskParts[Part],
-UndefValue::get(DataTy), "wide.masked.load");
+VecPtr, Alignment, BlockInMaskParts[Part], UndefValue::get(DataTy),
+"wide.masked.load");
   else
 NewLI = Builder.CreateAlignedLoad(DataTy, VecPtr, Alignment.value(),
   "wide.load");
Index: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -2945,9 +2945,8 @@
 if (PropagateShadow) {
   std::tie(ShadowPtr, OriginPtr) =
   getShadowOriginPtr(Addr, IRB, ShadowTy, Alignment, /*isStore*/ false);
-  setShadow(&I, IRB.CreateMaskedLoad(
-ShadowPtr, Alignment ? Alignment->value() : 0, Mask,
-getShadow(PassThru), "_msmaskedld"));
+  setShadow(&I, IRB.CreateMaskedLoad(ShadowPtr, *Alignment, Mask,
+ getShadow(PassThru), "_msmaskedld"));
 } else {
   setShadow(&I, getCleanShadow(&I));
 }
Index: llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
===
--- llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -1331,7 +1331,7 @@
 
   // The pass-through vector for an x86 masked load is a zero vector.
   CallInst *NewMaskedLoad =
-  IC.Builder.CreateMaskedLoad(PtrCast, 1, BoolMask, ZeroVec);
+  IC.Builder.CreateMaskedLoad(PtrCast, Align::None(), BoolMask, ZeroVec);
   return IC.replaceInstUsesWith(II, NewMaskedLoad);
 }
 
Index: llvm/lib/IR/IRBuilder.cpp
===
--- llvm/lib/IR/IRBuilder.cpp
+++ llvm/lib/IR/IRBuilder.cpp
@@ -466,14 +466,14 @@
 }
 
 /// Create a call to a Masked Load intrinsic.
-/// \p Ptr  - base pointer for the load
-/// \p Align- alignment of the source location
-/// \p Mask - vector of booleans which indicates what vector lanes should
-///   be accessed in memory
-/// \p PassThru - pass-through value that is used to fill the masked-off lanes
-///   of the result
-/// \p Name - name of the result variable
-CallInst *IRBuilderBase::CreateMaskedLoad(Value *Ptr, unsigned Align,
+/// \p Ptr   - base pointer for the load
+/// \p Alignment - alignment of the source location
+/// \p Mask  - vector of booleans which indicates what vector lanes should
+///be accessed in memory
+/// \p PassThru  - pass-through value that is used to fill the masked-off lanes
+///of the result
+/// \p Name  - name of the result variable
+CallInst *IRBuilderBase::CreateMaskedLoad(Value *Ptr, Align Alignment,
   Value *Mask, Value *PassThru,
   const Twine &Name) {
   auto *PtrTy = cast(Ptr->getType());
@@ -483,7 +483,7 @@
   if (!PassThru)
 PassThru = UndefValue::get(DataTy);
   Type *OverloadedTypes[] = { DataTy, PtrTy };
-  Value *Ops[] = { Ptr, getInt32(Align), Mask,  PassThru};
+  Value *Ops[] = {Ptr, getInt32(Alignment.value()), Mask, PassThru};
   return CreateMaskedIntrinsic(Intrinsic::masked_load, Ops,
   

[PATCH] D72867: [clangd] Support renaming designated initializers

2020-01-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/FindTarget.cpp:639
+void VisitDesignatedInitExpr(const DesignatedInitExpr *DIE) {
+  for (const DesignatedInitExpr::Designator &D : DIE->designators()) {
+if (!D.isFieldDesignator())

you're breaking after the first one - I think you'd like to report every one 
instead?
You'd test this with a DIE like `{ .Foo.Bar = 2 }` where `Foo` has struct type.

(targetDecl only reports the *last* one, because the Designator can't be a 
DynTypedNode, but we don't care about that here)



Comment at: clang-tools-extra/clangd/unittests/FindTargetTests.cpp:566
 TU.ExtraArgs.push_back("-fno-delayed-template-parsing");
-TU.ExtraArgs.push_back("-std=c++17");
+TU.ExtraArgs.push_back("-std=c++2a");
 

isn't this spelled c++20 yet?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72867



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


[PATCH] D72911: clang-format: fix spacing in `operator const char*()`

2020-01-21 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

@krasimir Thanks for fixing this, as it looks like I broke it.. its much 
appreciated


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72911



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


[PATCH] D71001: [clang-tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

2020-01-21 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment.

Let me know if you want me to commit this change for you.


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

https://reviews.llvm.org/D71001



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


[PATCH] D73088: [clangd] Capture the missing injected class names in findExplicitReferences.

2020-01-21 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added reviewers: kadircet, kbobyrev.
Herald added subscribers: usaxena95, arphaman, jkorous, MaskRay, ilya-biryukov.
Herald added a project: clang.

Fixes https://github.com/clangd/clangd/issues/237.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73088

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

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -525,7 +525,7 @@
 using $Typedef[[LVReference]] = $TemplateParameter[[T]] &;
 using $Typedef[[RVReference]] = $TemplateParameter[[T]]&&;
 using $Typedef[[Array]] = $TemplateParameter[[T]]*[3];
-using $Typedef[[MemberPointer]] = int (A::*)(int);
+using $Typedef[[MemberPointer]] = int ($Class[[A]]::*)(int);
 
 // Use various previously defined typedefs in a function type.
 void $Method[[func]](
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -1,4 +1,4 @@
-//===-- FindSymbolsTests.cpp -*- C++ -*===//
+//===-- FindTargetTests.cpp --*- C++ -*===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -553,8 +553,8 @@
 std::string DumpedReferences;
   };
 
-  /// Parses \p Code, finds function '::foo' and annotates its body with results
-  /// of findExplicitReferecnces.
+  /// Parses \p Code, finds function or namespace '::foo' and annotates its body
+  /// with results of findExplicitReferecnces.
   /// See actual tests for examples of annotation format.
   AllRefs annotateReferencesInFoo(llvm::StringRef Code) {
 TestTU TU;
@@ -574,12 +574,21 @@
 auto *TestDecl = &findDecl(AST, "foo");
 if (auto *T = llvm::dyn_cast(TestDecl))
   TestDecl = T->getTemplatedDecl();
-auto &Func = llvm::cast(*TestDecl);
 
 std::vector Refs;
-findExplicitReferences(Func.getBody(), [&Refs](ReferenceLoc R) {
-  Refs.push_back(std::move(R));
-});
+if (const auto *Func = llvm::dyn_cast(TestDecl))
+  findExplicitReferences(Func->getBody(), [&Refs](ReferenceLoc R) {
+Refs.push_back(std::move(R));
+  });
+else if (const auto *NS = llvm::dyn_cast(TestDecl))
+  findExplicitReferences(NS, [&Refs, &NS](ReferenceLoc R) {
+// Avoid adding the namespace foo decl to the results.
+if (R.Targets.size() == 1 && R.Targets.front() == NS)
+  return;
+Refs.push_back(std::move(R));
+  });
+else
+  ADD_FAILURE() << "Failed to find ::foo decl for test";
 
 auto &SM = AST.getSourceManager();
 llvm::sort(Refs, [&](const ReferenceLoc &L, const ReferenceLoc &R) {
@@ -720,6 +729,22 @@
 "1: targets = {vi}, decl\n"
 "2: targets = {valias}\n"
 "3: targets = {vb}, decl\n"},
+   // Injected class name.
+   {R"cpp(
+namespace foo {
+  template 
+  class $1^$2^Bar {
+~$3^Bar();
+void $4^f($5^Bar);
+  };
+}
+  )cpp",
+"0: targets = {foo::Bar::T}, decl\n"
+"1: targets = {foo::Bar}, decl\n"
+"2: targets = {foo::Bar}, decl\n"
+"3: targets = {foo::Bar}\n"
+"4: targets = {foo::Bar::f}, decl\n"
+"5: targets = {foo::Bar}\n"},
// MemberExpr should know their using declaration.
{R"cpp(
 struct X { void func(int); };
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -695,6 +695,13 @@
DeclRelation::Alias)};
 }
 
+void VisitInjectedClassNameTypeLoc(InjectedClassNameTypeLoc TL) {
+  Ref = ReferenceLoc{NestedNameSpecifierLoc(),
+ TL.getNameLoc(),
+ /*IsDecl=*/false,
+ {TL.getDecl()}};
+}
+
 void VisitDependentTemplateSpecializationTypeLoc(
 DependentTemplateSpecializationTypeLoc L) {
   Ref = ReferenceLoc{
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73088: [clangd] Capture the missing injected class names in findExplicitReferences.

2020-01-21 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62043 tests passed, 0 failed 
and 783 were skipped.

{icon question-circle color=gray} clang-tidy: unknown.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73088



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


[PATCH] D72041: [clangd] Handle go-to-definition in macro invocations where the target appears in the expansion multiple times

2020-01-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Thanks for fixing this. I think it could maybe use a further tweak, LMK if I'm 
missing something as my intuition around macros is pretty bad.




Comment at: clang-tools-extra/clangd/Selection.cpp:261
+  // consider it selected.
+  if (!SeenMacroCalls.insert(ArgStart).second) {
+return NoTokens;

Given the following program:
```
#define SQUARE(x) x * x;
int four = [[SQUARE(2)]];
```
We're going to now report the binary operator and one of the operands as 
selected and not the other, which doesn't seem desirable.

I think we want to accept macro-selected || arg-selected, so probably doing the 
current "non-argument macro expansion" first unconditionally or factoring it 
out into a function.

This will change the behavior of `int four = [[SQUARE]](2)` to consider the 
literal children selected too, I think this is fine.



Comment at: clang-tools-extra/clangd/Selection.cpp:261
+  // consider it selected.
+  if (!SeenMacroCalls.insert(ArgStart).second) {
+return NoTokens;

sammccall wrote:
> Given the following program:
> ```
> #define SQUARE(x) x * x;
> int four = [[SQUARE(2)]];
> ```
> We're going to now report the binary operator and one of the operands as 
> selected and not the other, which doesn't seem desirable.
> 
> I think we want to accept macro-selected || arg-selected, so probably doing 
> the current "non-argument macro expansion" first unconditionally or factoring 
> it out into a function.
> 
> This will change the behavior of `int four = [[SQUARE]](2)` to consider the 
> literal children selected too, I think this is fine.
I don't think it's a good idea to add hidden state and side-effects to 
testChunk() - it breaks a lot of assumptions that help reason about the code, 
and using `mutable` hides the violation of them.
(And a possible source of bugs - this is first in traversal order rather than 
first in source order - these are mostly but IIRC not always the same).

Instead I think you can do this statelessly: from the top-level spelling 
location, walk down with `SM.getMacroArgExpandedLocation` until you hit the 
target FileID (this is the first-expansion of first-expansion of 
first-expansion...) or the FileID stops changing (you've reached the innermost 
macro invocation, and your target location was on a different branch).



Comment at: clang-tools-extra/clangd/Selection.h:58
 // SelectionTree tries to behave sensibly in the presence of macros, but does
 // not model any preprocessor concepts: the output is a subset of the AST.
 //

Worth mentioning the new behavior here, IMO. e.g.

```
When a macro argument is specifically selected, only its first expansion is 
selected in the AST.
(Returning a selection forest is unreasonably difficult for callers to handle 
correctly).
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72041



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


[PATCH] D71001: [clang-tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

2020-01-21 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

In D71001#1830792 , @gribozavr2 wrote:

> Let me know if you want me to commit this change for you.


Thank you! I will commit it today.


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

https://reviews.llvm.org/D71001



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


[PATCH] D73088: [clangd] Capture the missing injected class names in findExplicitReferences.

2020-01-21 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/unittests/FindTargetTests.cpp:736
+  template 
+  class $1^$2^Bar {
+~$3^Bar();

looks like we are getting duplicates here


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73088



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


[PATCH] D73088: [clangd] Capture the missing injected class names in findExplicitReferences.

2020-01-21 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clang-tools-extra/clangd/unittests/FindTargetTests.cpp:736
+  template 
+  class $1^$2^Bar {
+~$3^Bar();

kadircet wrote:
> looks like we are getting duplicates here
looking at this again, this is actually not caused by this change, it was 
always there we just didn't notice it before since no one tested class 
templates.

could you put a fixme on it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73088



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


[PATCH] D72581: [Syntax] Add mapping from spelled to expanded tokens for TokenBuffer

2020-01-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/include/clang/Tooling/Syntax/Tokens.h:228
+  /// multiple times and this function will return multiple results in those
+  /// cases. This happens when \p Spelled is inside a macro argument.
+  ///

Nit: move the FIXME up here? Documenting this justifies the signature, but 
currently it *never* happens.



Comment at: clang/include/clang/Tooling/Syntax/Tokens.h:248
+  llvm::SmallVector, 1>
+  expandedForSpelled(llvm::ArrayRef Spelled) const;
+

out of curiosity, do you have a motivating use for this function?

I think it's clear enough that it will be useful, completeness dictates it 
should be here, and use cases aren't always the best way to think about 
designing these libraries. But it'd help me understand some of the details 
better.



Comment at: clang/lib/Tooling/Syntax/Tokens.cpp:198
+TokenBuffer::expandedForSpelled(llvm::ArrayRef Spelled) const {
+  assert(!Spelled.empty());
+  assert(Spelled.front().location().isFileID());

This is a little surprising (vs returning `{}`). 

It seems plausible that you'll map file offsets -> spelled tokens -> expanded 
tokens, and that the middle step might "accidentally" be empty. Caller can 
always check, but why require them to here?



Comment at: clang/lib/Tooling/Syntax/Tokens.cpp:205
+
+  auto &File = It->second;
+  assert(File.SpelledTokens.data() <= Spelled.data());

nit: mind spelling this type out? it's important, not particularly verbose, and 
long-lived



Comment at: clang/lib/Tooling/Syntax/Tokens.cpp:209
+
+  auto *FrontMapping = mappingStartingBeforeSpelled(File, &Spelled.front());
+  unsigned SpelledFrontI = &Spelled.front() - File.SpelledTokens.data();

This section could use some comments about how the index calculations relate to 
high-level concepts.

AIUI the branches are: spelled token precedes all PP usage, spelled token is 
transformed by PP (subcases: macro args and other PP usage), spelled token 
follows PP usage.

The next section probably only needs to comment about the purpose of the 
divergence (+1/End to refer to one-past the region of interest).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72581



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


[clang] bc29069 - [analyzer] Enable PlacementNewChecker by default

2020-01-21 Thread Gabor Marton via cfe-commits

Author: Gabor Marton
Date: 2020-01-21T13:23:10+01:00
New Revision: bc29069dc401572ba62f7dd692a3474c1ead76c9

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

LOG: [analyzer] Enable PlacementNewChecker by default

Added: 


Modified: 
clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
clang/test/Analysis/placement-new-user-defined.cpp
clang/test/Analysis/placement-new.cpp

Removed: 




diff  --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td 
b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index d235273cda41..fc1529f2ea1c 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -470,6 +470,12 @@ def NewDeleteLeaksChecker : Checker<"NewDeleteLeaks">,
   Dependencies<[NewDeleteChecker]>,
   Documentation;
 
+def PlacementNewChecker : Checker<"PlacementNew">,
+  HelpText<"Check if default placement new is provided with pointers to "
+   "sufficient storage capacity">,
+  Dependencies<[NewDeleteChecker]>,
+  Documentation;
+
 def CXXSelfAssignmentChecker : Checker<"SelfAssignment">,
   HelpText<"Checks C++ copy and move assignment operators for self 
assignment">,
   Documentation,
@@ -615,12 +621,6 @@ def MismatchedIteratorChecker : 
Checker<"MismatchedIterator">,
   Dependencies<[IteratorModeling]>,
   Documentation;
 
-def PlacementNewChecker : Checker<"PlacementNew">,
-  HelpText<"Check if default placement new is provided with pointers to "
-   "sufficient storage capacity">,
-  Dependencies<[NewDeleteChecker]>,
-  Documentation;
-
 } // end: "alpha.cplusplus"
 
 

diff  --git a/clang/test/Analysis/placement-new-user-defined.cpp 
b/clang/test/Analysis/placement-new-user-defined.cpp
index 47f0b459ea00..b3fe47057f8a 100644
--- a/clang/test/Analysis/placement-new-user-defined.cpp
+++ b/clang/test/Analysis/placement-new-user-defined.cpp
@@ -1,7 +1,7 @@
 // RUN: %clang_analyze_cc1 -std=c++11 %s \
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=cplusplus.NewDelete \
-// RUN:   -analyzer-checker=alpha.cplusplus.PlacementNew \
+// RUN:   -analyzer-checker=cplusplus.PlacementNew \
 // RUN:   -analyzer-output=text -verify \
 // RUN:   -triple x86_64-unknown-linux-gnu
 

diff  --git a/clang/test/Analysis/placement-new.cpp 
b/clang/test/Analysis/placement-new.cpp
index 0f5248410a41..37102b810d98 100644
--- a/clang/test/Analysis/placement-new.cpp
+++ b/clang/test/Analysis/placement-new.cpp
@@ -1,7 +1,7 @@
 // RUN: %clang_analyze_cc1 -std=c++11 %s \
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=cplusplus.NewDelete \
-// RUN:   -analyzer-checker=alpha.cplusplus.PlacementNew \
+// RUN:   -analyzer-checker=cplusplus.PlacementNew \
 // RUN:   -analyzer-output=text -verify \
 // RUN:   -triple x86_64-unknown-linux-gnu
 
@@ -93,6 +93,22 @@ void f() {
 }
 } // namespace testPtrToArrayWithOffsetAsPlace
 
+namespace testZeroSize {
+void f() {
+  int buf[3];  // expected-note {{'buf' initialized here}}
+  long *lp = ::new (buf + 3) long; // expected-warning{{Storage provided to 
placement new is only 0 bytes, whereas the allocated type requires 8 bytes}} 
expected-note 1 {{}}
+  (void)lp;
+}
+} // namespace testZeroSize
+
+namespace testNegativeSize {
+void f() {
+  int buf[3];  // expected-note {{'buf' initialized here}}
+  long *lp = ::new (buf + 4) long; // expected-warning{{Storage provided to 
placement new is only -4 bytes, whereas the allocated type requires 8 bytes}} 
expected-note 1 {{}}
+  (void)lp;
+}
+} // namespace testNegativeSize
+
 namespace testHeapAllocatedBuffer {
 void g2() {
   char *buf = new char[2]; // expected-note {{'buf' initialized here}}



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


[PATCH] D73088: [clangd] Capture the missing injected class names in findExplicitReferences.

2020-01-21 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added a comment.

It would also be great to have the original rename test from the linked issue 
since something might potentially go wrong in-between `findExplicitReferences` 
and rename action (and also to expand the testset because the existing one is 
not really extensive :().


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73088



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


[PATCH] D71612: [analyzer] Add PlacementNewChecker

2020-01-21 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

In D71612#1828059 , @NoQ wrote:

> This looks fantastic. Let's enable by it default!


Ok, I've done that: https://github.com/llvm/llvm-project/commit/bc29069dc40


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71612



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


[clang] bc8a1ab - [Alignment][NFC] Use Align with CreateMaskedLoad

2020-01-21 Thread Guillaume Chatelet via cfe-commits

Author: Guillaume Chatelet
Date: 2020-01-21T14:13:22+01:00
New Revision: bc8a1ab26fba5d5635467b9d0fd7ad9a0fd5bc6e

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

LOG: [Alignment][NFC] Use Align with CreateMaskedLoad

Summary:
This is patch is part of a series to introduce an Alignment type.
See this thread for context: 
http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790

Reviewers: courbet

Subscribers: hiraditya, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
llvm/include/llvm/Analysis/VectorUtils.h
llvm/include/llvm/IR/IRBuilder.h
llvm/lib/IR/AutoUpgrade.cpp
llvm/lib/IR/IRBuilder.cpp
llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 9986ea4cb94c..8d00d3d64f5c 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -9727,8 +9727,8 @@ static Value *EmitX86MaskedStore(CodeGenFunction &CGF,
   return CGF.Builder.CreateMaskedStore(Ops[1], Ptr, Align, MaskVec);
 }
 
-static Value *EmitX86MaskedLoad(CodeGenFunction &CGF,
-ArrayRef Ops, unsigned Align) {
+static Value *EmitX86MaskedLoad(CodeGenFunction &CGF, ArrayRef Ops,
+Align Alignment) {
   // Cast the pointer to right type.
   Value *Ptr = CGF.Builder.CreateBitCast(Ops[0],

llvm::PointerType::getUnqual(Ops[1]->getType()));
@@ -9736,7 +9736,7 @@ static Value *EmitX86MaskedLoad(CodeGenFunction &CGF,
   Value *MaskVec = getMaskVecValue(CGF, Ops[2],
Ops[1]->getType()->getVectorNumElements());
 
-  return CGF.Builder.CreateMaskedLoad(Ptr, Align, MaskVec, Ops[1]);
+  return CGF.Builder.CreateMaskedLoad(Ptr, Alignment, MaskVec, Ops[1]);
 }
 
 static Value *EmitX86ExpandLoad(CodeGenFunction &CGF,
@@ -10731,11 +10731,11 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned 
BuiltinID,
   case X86::BI__builtin_ia32_loaddqudi128_mask:
   case X86::BI__builtin_ia32_loaddqudi256_mask:
   case X86::BI__builtin_ia32_loaddqudi512_mask:
-return EmitX86MaskedLoad(*this, Ops, 1);
+return EmitX86MaskedLoad(*this, Ops, Align::None());
 
   case X86::BI__builtin_ia32_loadss128_mask:
   case X86::BI__builtin_ia32_loadsd128_mask:
-return EmitX86MaskedLoad(*this, Ops, 1);
+return EmitX86MaskedLoad(*this, Ops, Align::None());
 
   case X86::BI__builtin_ia32_loadaps128_mask:
   case X86::BI__builtin_ia32_loadaps256_mask:
@@ -10748,11 +10748,10 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned 
BuiltinID,
   case X86::BI__builtin_ia32_movdqa32load512_mask:
   case X86::BI__builtin_ia32_movdqa64load128_mask:
   case X86::BI__builtin_ia32_movdqa64load256_mask:
-  case X86::BI__builtin_ia32_movdqa64load512_mask: {
-unsigned Align =
-  getContext().getTypeAlignInChars(E->getArg(1)->getType()).getQuantity();
-return EmitX86MaskedLoad(*this, Ops, Align);
-  }
+  case X86::BI__builtin_ia32_movdqa64load512_mask:
+return EmitX86MaskedLoad(
+*this, Ops,
+
getContext().getTypeAlignInChars(E->getArg(1)->getType()).getAsAlign());
 
   case X86::BI__builtin_ia32_expandloaddf128_mask:
   case X86::BI__builtin_ia32_expandloaddf256_mask:

diff  --git a/llvm/include/llvm/Analysis/VectorUtils.h 
b/llvm/include/llvm/Analysis/VectorUtils.h
index dd42b4f5be93..8b465ca2983d 100644
--- a/llvm/include/llvm/Analysis/VectorUtils.h
+++ b/llvm/include/llvm/Analysis/VectorUtils.h
@@ -509,6 +509,7 @@ template  class InterleaveGroup {
   bool isReverse() const { return Reverse; }
   uint32_t getFactor() const { return Factor; }
   uint32_t getAlignment() const { return Alignment.value(); }
+  Align getAlign() const { return Alignment; }
   uint32_t getNumMembers() const { return Members.size(); }
 
   /// Try to insert a new member \p Instr with index \p Index and

diff  --git a/llvm/include/llvm/IR/IRBuilder.h 
b/llvm/include/llvm/IR/IRBuilder.h
index 6f6d6db31726..9341810c7b3b 100644
--- a/llvm/include/llvm/IR/IRBuilder.h
+++ b/llvm/include/llvm/IR/IRBuilder.h
@@ -727,7 +727,14 @@ class IRBuilderBase {
   CallInst *CreateInvariantStart(Value *Ptr, ConstantInt *Size = nullptr);
 
   /// Create a call to Masked Load intrinsic
-  CallInst *CreateMaskedLoad(Value *Ptr, unsigned Align, Value *Mask,
+  LLVM_ATTRIBUTE_DEPRECATED(
+  CallInst *CreateMaskedLoad(Value *Ptr, unsigned Alignment, Value *Mask,
+ Value *

[PATCH] D22221: Decide whether to enable plugin tests based on cmake variables

2020-01-21 Thread John Brawn via Phabricator via cfe-commits
john.brawn abandoned this revision.
john.brawn added a comment.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Abandoning this old obsolete patch.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D1



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


[PATCH] D72829: Implement -fsemantic-interposition

2020-01-21 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 239286.
serge-sans-paille added a comment.

Take into account review


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72829

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/IR/GlobalValue.h
  llvm/include/llvm/IR/Module.h
  llvm/lib/IR/Globals.cpp
  llvm/lib/IR/Module.cpp

Index: llvm/lib/IR/Module.cpp
===
--- llvm/lib/IR/Module.cpp
+++ llvm/lib/IR/Module.cpp
@@ -554,6 +554,20 @@
: getModuleFlag("ProfileSummary"));
 }
 
+bool Module::getSemanticInterposition() const {
+  auto *Val =
+  cast_or_null(getModuleFlag("SemanticInterposition"));
+
+  if (!Val)
+return false;
+
+  return cast(Val->getValue())->getZExtValue();
+}
+
+void Module::setSemanticInterposition(bool SI) {
+  addModuleFlag(ModFlagBehavior::Error, "SemanticInterposition", SI);
+}
+
 void Module::setOwnedMemoryBuffer(std::unique_ptr MB) {
   OwnedMemoryBuffer = std::move(MB);
 }
Index: llvm/lib/IR/Globals.cpp
===
--- llvm/lib/IR/Globals.cpp
+++ llvm/lib/IR/Globals.cpp
@@ -94,6 +94,20 @@
   llvm_unreachable("not a global");
 }
 
+bool GlobalValue::isInterposable() const {
+
+  if (isInterposableLinkage(getLinkage()))
+return true;
+
+  bool const HonorSemanticInterposition =
+  getParent() && getParent()->getSemanticInterposition();
+
+  if (HonorSemanticInterposition && !isDSOLocal())
+return true;
+
+  return false;
+}
+
 unsigned GlobalValue::getAlignment() const {
   if (auto *GA = dyn_cast(this)) {
 // In general we cannot compute this at the IR level, but we try.
Index: llvm/include/llvm/IR/Module.h
===
--- llvm/include/llvm/IR/Module.h
+++ llvm/include/llvm/IR/Module.h
@@ -848,6 +848,17 @@
   Metadata *getProfileSummary(bool IsCS);
   /// @}
 
+  /// @name Utility functions for querying and setting semantic interposition
+  /// @{
+
+  /// Returns whether semantic interposition is to be respected.
+  bool getSemanticInterposition() const;
+
+  /// Set whether semantic interposition is to be respected.
+  void setSemanticInterposition(bool);
+
+  /// @}
+
   /// Returns true if PLT should be avoided for RTLib calls.
   bool getRtLibUseGOT() const;
 
Index: llvm/include/llvm/IR/GlobalValue.h
===
--- llvm/include/llvm/IR/GlobalValue.h
+++ llvm/include/llvm/IR/GlobalValue.h
@@ -284,6 +284,8 @@
 return IsDSOLocal;
   }
 
+  bool isDSOPreemptable() const { return !IsDSOLocal; }
+
   bool hasPartition() const {
 return HasPartition;
   }
@@ -426,7 +428,7 @@
   /// *arbitrary* definition at link time.  We cannot do any IPO or inlinining
   /// across interposable call edges, since the callee can be replaced with
   /// something arbitrary at link time.
-  bool isInterposable() const { return isInterposableLinkage(getLinkage()); }
+  bool isInterposable() const;
 
   bool hasExternalLinkage() const { return isExternalLinkage(getLinkage()); }
   bool hasAvailableExternallyLinkage() const {
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2685,6 +2685,9 @@
 Opts.setValueVisibilityMode(DefaultVisibility);
   }
 
+  if (Args.hasArg(OPT_fsemantic_interposition))
+Opts.SemanticInterposition = 1;
+
   // The type-visibility mode defaults to the value-visibility mode.
   if (Arg *typeVisOpt = Args.getLastArg(OPT_ftype_visibility)) {
 Opts.setTypeVisibilityMode(parseVisibility(typeVisOpt, Args, Diags));
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5037,6 +5037,10 @@
   options::OPT_fno_emulated_tls);
   Args.AddLastArg(CmdArgs, options::OPT_fkeep_static_consts);
 
+  if (Args.hasFlag(options::OPT_fsemantic_interposition,
+   options::OPT_fno_semantic_interposition, false))
+CmdArgs.push_back("-fsemantic-interposition");
+
   // AltiVec-like language extensions aren't relevant for assembling.
   if (!isa(JA) || Output.getType() != types::TY_PP_Asm)
 Args.AddLastArg(CmdArgs, options::OPT_fzvector);
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -483,6 +483,11 @@
 getModule().addModuleFlag(llvm::Module::Max, "Dwarf Version",
  

[PATCH] D72829: Implement -fsemantic-interposition

2020-01-21 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

> Linkages which were not interposable before and can be interposable now: 
> available_externally, linkonce_odr, weak_odr, external, and appending.

@MaskRay I understand the motivation behind that sentence, but do we want that 
change to be non-conditional, i.e. not guarded by -fsemantic-interposition ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72829



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


[PATCH] D73087: [Alignment][NFC] Use Align with CreateMaskedLoad

2020-01-21 Thread Guillaume Chatelet via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbc8a1ab26fba: [Alignment][NFC] Use Align with 
CreateMaskedLoad (authored by gchatelet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73087

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  llvm/include/llvm/Analysis/VectorUtils.h
  llvm/include/llvm/IR/IRBuilder.h
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/IR/IRBuilder.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
===
--- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -2263,7 +2263,7 @@
   : ShuffledMask;
 }
 NewLoad =
-Builder.CreateMaskedLoad(AddrParts[Part], Group->getAlignment(),
+Builder.CreateMaskedLoad(AddrParts[Part], Group->getAlign(),
  GroupMask, UndefVec, "wide.masked.vec");
   }
   else
@@ -2475,8 +2475,8 @@
   auto *VecPtr = CreateVecPtr(Part, State.get(Addr, {0, 0}));
   if (isMaskRequired)
 NewLI = Builder.CreateMaskedLoad(
-VecPtr, Alignment.value(), BlockInMaskParts[Part],
-UndefValue::get(DataTy), "wide.masked.load");
+VecPtr, Alignment, BlockInMaskParts[Part], UndefValue::get(DataTy),
+"wide.masked.load");
   else
 NewLI = Builder.CreateAlignedLoad(DataTy, VecPtr, Alignment.value(),
   "wide.load");
Index: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -2945,9 +2945,8 @@
 if (PropagateShadow) {
   std::tie(ShadowPtr, OriginPtr) =
   getShadowOriginPtr(Addr, IRB, ShadowTy, Alignment, /*isStore*/ false);
-  setShadow(&I, IRB.CreateMaskedLoad(
-ShadowPtr, Alignment ? Alignment->value() : 0, Mask,
-getShadow(PassThru), "_msmaskedld"));
+  setShadow(&I, IRB.CreateMaskedLoad(ShadowPtr, *Alignment, Mask,
+ getShadow(PassThru), "_msmaskedld"));
 } else {
   setShadow(&I, getCleanShadow(&I));
 }
Index: llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
===
--- llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -1331,7 +1331,7 @@
 
   // The pass-through vector for an x86 masked load is a zero vector.
   CallInst *NewMaskedLoad =
-  IC.Builder.CreateMaskedLoad(PtrCast, 1, BoolMask, ZeroVec);
+  IC.Builder.CreateMaskedLoad(PtrCast, Align::None(), BoolMask, ZeroVec);
   return IC.replaceInstUsesWith(II, NewMaskedLoad);
 }
 
Index: llvm/lib/IR/IRBuilder.cpp
===
--- llvm/lib/IR/IRBuilder.cpp
+++ llvm/lib/IR/IRBuilder.cpp
@@ -466,14 +466,14 @@
 }
 
 /// Create a call to a Masked Load intrinsic.
-/// \p Ptr  - base pointer for the load
-/// \p Align- alignment of the source location
-/// \p Mask - vector of booleans which indicates what vector lanes should
-///   be accessed in memory
-/// \p PassThru - pass-through value that is used to fill the masked-off lanes
-///   of the result
-/// \p Name - name of the result variable
-CallInst *IRBuilderBase::CreateMaskedLoad(Value *Ptr, unsigned Align,
+/// \p Ptr   - base pointer for the load
+/// \p Alignment - alignment of the source location
+/// \p Mask  - vector of booleans which indicates what vector lanes should
+///be accessed in memory
+/// \p PassThru  - pass-through value that is used to fill the masked-off lanes
+///of the result
+/// \p Name  - name of the result variable
+CallInst *IRBuilderBase::CreateMaskedLoad(Value *Ptr, Align Alignment,
   Value *Mask, Value *PassThru,
   const Twine &Name) {
   auto *PtrTy = cast(Ptr->getType());
@@ -483,7 +483,7 @@
   if (!PassThru)
 PassThru = UndefValue::get(DataTy);
   Type *OverloadedTypes[] = { DataTy, PtrTy };
-  Value *Ops[] = { Ptr, getInt32(Align), Mask,  PassThru};
+  Value *Ops[] = {Ptr, getInt32(Alignment.value()), Mask, PassThru};
   return CreateMaskedIntrinsic(Intrinsic::masked_load, Ops,
OverloadedTypes, Name);
 }
Index: llvm/lib/IR/AutoUpgrade.cpp
===
--- llvm/lib/IR/AutoUpgrade.cpp
+

[clang-tools-extra] fccd0da - [clang-tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

2020-01-21 Thread Adam Balogh via cfe-commits

Author: Adam Balogh
Date: 2020-01-21T14:38:15+01:00
New Revision: fccd0da5ee6f4e337395f287edcf824a009e1b7e

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

LOG: [clang-tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

Finds cases where an integer expression is added to the result
of a memory allocation function instead of its argument.

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

Added: 

clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp

clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.h

clang-tools-extra/docs/clang-tidy/checks/bugprone-misplaced-pointer-arithmetic-in-alloc.rst

clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.c

clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.cpp

Modified: 
clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/list.rst

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index 831f5f4e3b62..86936c678562 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -30,6 +30,7 @@
 #include "MacroParenthesesCheck.h"
 #include "MacroRepeatedSideEffectsCheck.h"
 #include "MisplacedOperatorInStrlenInAllocCheck.h"
+#include "MisplacedPointerArithmeticInAllocCheck.h"
 #include "MisplacedWideningCastCheck.h"
 #include "MoveForwardingReferenceCheck.h"
 #include "MultipleStatementMacroCheck.h"
@@ -107,6 +108,8 @@ class BugproneModule : public ClangTidyModule {
 "bugprone-macro-repeated-side-effects");
 CheckFactories.registerCheck(
 "bugprone-misplaced-operator-in-strlen-in-alloc");
+CheckFactories.registerCheck(
+"bugprone-misplaced-pointer-arithmetic-in-alloc");
 CheckFactories.registerCheck(
 "bugprone-misplaced-widening-cast");
 CheckFactories.registerCheck(

diff  --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
index efb97a5318bb..c9078ed390d1 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -22,6 +22,7 @@ add_clang_library(clangTidyBugproneModule
   MacroParenthesesCheck.cpp
   MacroRepeatedSideEffectsCheck.cpp
   MisplacedOperatorInStrlenInAllocCheck.cpp
+  MisplacedPointerArithmeticInAllocCheck.cpp
   MisplacedWideningCastCheck.cpp
   MoveForwardingReferenceCheck.cpp
   MultipleStatementMacroCheck.cpp

diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp
 
b/clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp
new file mode 100644
index ..c6dc78622851
--- /dev/null
+++ 
b/clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp
@@ -0,0 +1,105 @@
+//===--- MisplacedPointerArithmeticInAllocCheck.cpp - 
clang-tidy---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "MisplacedPointerArithmeticInAllocCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace bugprone {
+
+void MisplacedPointerArithmeticInAllocCheck::registerMatchers(
+MatchFinder *Finder) {
+  const auto AllocFunc = functionDecl(
+  anyOf(hasName("::malloc"), hasName("std::malloc"), hasName("::alloca"),
+hasName("::calloc"), hasName("std::calloc"), hasName("::realloc"),
+hasName("std::realloc")));
+
+  const auto AllocFuncPtr =
+  varDecl(hasType(isConstQualified()),
+  hasInitializer(ignoringParenImpCasts(
+  declRefExpr(hasDeclaration(AllocFunc);
+
+  const auto AdditiveOperator =
+  binaryOperator(anyOf(hasOperatorName("+"), hasOperatorName("-")));
+
+  const auto IntExpr = expr(hasType(isInteger()));
+
+  const auto AllocCall = callExpr(callee(decl(anyOf(AllocFunc, 
AllocFuncPtr;
+
+  Finder->addMatcher(
+  binaryOperator(
+  AdditiveOperator,
+  hasLHS(anyOf(AllocCall, castExpr(hasSourceExpression(AllocCall,
+  hasRHS(IntExpr))
+  .bind("PtrArith"),
+  this);
+
+ 

[PATCH] D71001: [clang-tidy] New check: bugprone-misplaced-pointer-arithmetic-in-alloc

2020-01-21 Thread Balogh, Ádám via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfccd0da5ee6f: [clang-tidy] New check: 
bugprone-misplaced-pointer-arithmetic-in-alloc (authored by baloghadamsoftware).

Changed prior to commit:
  https://reviews.llvm.org/D71001?vs=239103&id=239290#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71001

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  
clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-misplaced-pointer-arithmetic-in-alloc.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.c
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.cpp
@@ -0,0 +1,53 @@
+// RUN: %check_clang_tidy %s bugprone-misplaced-pointer-arithmetic-in-alloc %t
+
+class C {
+  int num;
+public:
+  explicit C(int n) : num(n) {}
+};
+
+void bad_new(int n, int m) {
+  C *p = new C(n) + 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: arithmetic operation is applied to the result of operator new() instead of its size-like argument
+  // CHECK-FIXES: C *p = new C(n + 10);
+
+  p = new C(n) - 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new() instead of its size-like argument
+  // CHECK-FIXES: p = new C(n - 10);
+
+  p = new C(n) + m;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new() instead of its size-like argument
+  // CHECK-FIXES: p = new C(n + m);
+
+  p = new C(n) - (m + 10);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new() instead of its size-like argument
+  // CHECK-FIXES: p = new C(n - (m + 10));
+
+  p = new C(n) - m + 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new() instead of its size-like argument
+  // CHECK-FIXES: p = new C(n - m) + 10;
+  // FIXME: Should be p = new C(n - m + 10);
+}
+
+void bad_new_array(int n, int m) {
+  char *p = new char[n] + 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: arithmetic operation is applied to the result of operator new[]() instead of its size-like argument
+  // CHECK-FIXES: char *p = new char[n + 10];
+
+  p = new char[n] - 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new[]() instead of its size-like argument
+  // CHECK-FIXES: p = new char[n - 10];
+
+  p = new char[n] + m;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new[]() instead of its size-like argument
+  // CHECK-FIXES: p = new char[n + m];
+
+  p = new char[n] - (m + 10);
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new[]() instead of its size-like argument
+  // CHECK-FIXES: p = new char[n - (m + 10)];
+
+  p = new char[n] - m + 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of operator new[]() instead of its size-like argument
+  // CHECK-FIXES: p = new char[n - m] + 10;
+  // FIXME: should be p = new char[n - m + 10];
+}
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.c
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.c
@@ -0,0 +1,56 @@
+// RUN: %check_clang_tidy %s bugprone-misplaced-pointer-arithmetic-in-alloc %t
+
+typedef __typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+void *alloca(size_t);
+void *calloc(size_t, size_t);
+void *realloc(void *, size_t);
+
+void bad_malloc(int n) {
+  char *p = (char *)malloc(n) + 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: arithmetic operation is applied to the result of malloc() instead of its size-like argument
+  // CHECK-FIXES: char *p = (char *)malloc(n + 10);
+
+  p = (char *)malloc(n) - 10;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is applied to the result of malloc() instead of its size-like argument
+  // CHECK-FIXES: p = (char *)malloc(n - 10);
+
+  p = (char *)malloc(n) + n;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: arithmetic operation is appli

[PATCH] D72829: Implement -fsemantic-interposition

2020-01-21 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62055 tests passed, 0 failed 
and 784 were skipped.

{icon question-circle color=gray} clang-tidy: unknown.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72829



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


[PATCH] D73097: [AArch64][SVE] Add intrinsics for FFR manipulation

2020-01-21 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin created this revision.
kmclaughlin added reviewers: sdesmalen, efriedma, dancgr.
Herald added subscribers: psnobl, rkruppe, hiraditya, kristof.beyls, tschuett.
Herald added a reviewer: rengolin.
Herald added a project: LLVM.

Implements the following intrinsics:

- llvm.aarch64.sve.setffr
- llvm.aarch64.sve.rdffr
- llvm.aarch64.sve.rdffr.z
- llvm.aarch64.sve.wrffr


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73097

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve-intrinsics-ffr-manipulation.ll

Index: llvm/test/CodeGen/AArch64/sve-intrinsics-ffr-manipulation.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve-intrinsics-ffr-manipulation.ll
@@ -0,0 +1,50 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s
+
+;
+; RDFFR
+;
+
+define  @rdffr() {
+; CHECK-LABEL: rdffr:
+; CHECK: rdffr p0.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.rdffr()
+  ret  %out
+}
+
+define  @rdffr_z( %pg) {
+; CHECK-LABEL: rdffr_z:
+; CHECK: rdffr p0.b, p0/z
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.rdffr.z( %pg)
+  ret  %out
+}
+
+;
+; SETFFR
+;
+
+define void @set_ffr() {
+; CHECK-LABEL: set_ffr:
+; CHECK: setffr
+; CHECK-NEXT: ret
+  call void @llvm.aarch64.sve.setffr()
+  ret void
+}
+
+;
+; WRFFR
+;
+
+define void @wrffr( %a) {
+; CHECK-LABEL: wrffr:
+; CHECK: wrffr p0.b
+; CHECK-NEXT: ret
+  call void @llvm.aarch64.sve.wrffr( %a)
+  ret void
+}
+
+declare  @llvm.aarch64.sve.rdffr()
+declare  @llvm.aarch64.sve.rdffr.z()
+declare void @llvm.aarch64.sve.setffr()
+declare void @llvm.aarch64.sve.wrffr()
Index: llvm/lib/Target/AArch64/SVEInstrFormats.td
===
--- llvm/lib/Target/AArch64/SVEInstrFormats.td
+++ llvm/lib/Target/AArch64/SVEInstrFormats.td
@@ -5094,6 +5094,17 @@
   let Uses = [FFR];
 }
 
+multiclass sve_int_rdffr_pred {
+  def _REAL : sve_int_rdffr_pred;
+
+  // We need a layer of indirection because early machine code passes balk at
+  // physical register (i.e. FFR) uses that have no previous definition.
+  let hasSideEffects = 1, hasNoSchedulingInfo = 1 in {
+  def "" : Pseudo<(outs PPR8:$Pd), (ins PPRAny:$Pg), [(set (nxv16i1 PPR8:$Pd), (op (nxv16i1 PPRAny:$Pg)))]>,
+   PseudoInstExpansion<(!cast(NAME # _REAL) PPR8:$Pd, PPRAny:$Pg)>;
+  }
+}
+
 class sve_int_rdffr_unpred : I<
   (outs PPR8:$Pd), (ins),
   asm, "\t$Pd",
@@ -5106,11 +5117,22 @@
   let Uses = [FFR];
 }
 
-class sve_int_wrffr
+multiclass sve_int_rdffr_unpred {
+  def _REAL : sve_int_rdffr_unpred;
+
+  // We need a layer of indirection because early machine code passes balk at
+  // physical register (i.e. FFR) uses that have no previous definition.
+  let hasSideEffects = 1, hasNoSchedulingInfo = 1 in {
+  def "" : Pseudo<(outs PPR8:$Pd), (ins), [(set (nxv16i1 PPR8:$Pd), (op))]>,
+   PseudoInstExpansion<(!cast(NAME # _REAL) PPR8:$Pd)>;
+  }
+}
+
+class sve_int_wrffr
 : I<(outs), (ins PPR8:$Pn),
   asm, "\t$Pn",
   "",
-  []>, Sched<[]> {
+  [(op (nxv16i1 PPR8:$Pn))]>, Sched<[]> {
   bits<4> Pn;
   let Inst{31-9} = 0b00100101001010001001000;
   let Inst{8-5}  = Pn;
@@ -5120,11 +5142,11 @@
   let Defs = [FFR];
 }
 
-class sve_int_setffr
+class sve_int_setffr
 : I<(outs), (ins),
   asm, "",
   "",
-  []>, Sched<[]> {
+  [(op)]>, Sched<[]> {
   let Inst{31-0} = 0b00100101001011001001;
 
   let hasSideEffects = 1;
Index: llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
===
--- llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
+++ llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
@@ -78,11 +78,11 @@
 
 let Predicates = [HasSVE] in {
 
-  def RDFFR_PPz  : sve_int_rdffr_pred<0b0, "rdffr">;
-  def RDFFRS_PPz : sve_int_rdffr_pred<0b1, "rdffrs">;
-  def RDFFR_P: sve_int_rdffr_unpred<"rdffr">;
-  def SETFFR : sve_int_setffr<"setffr">;
-  def WRFFR  : sve_int_wrffr<"wrffr">;
+  defm RDFFR_PPz  : sve_int_rdffr_pred<0b0, "rdffr", int_aarch64_sve_rdffr_z>;
+  def  RDFFRS_PPz : sve_int_rdffr_pred<0b1, "rdffrs">;
+  defm RDFFR_P: sve_int_rdffr_unpred<"rdffr", int_aarch64_sve_rdffr>;
+  def  SETFFR : sve_int_setffr<"setffr", int_aarch64_sve_setffr>;
+  def  WRFFR  : sve_int_wrffr<"wrffr", int_aarch64_sve_wrffr>;
 
   defm ADD_ZZZ   : sve_int_bin_cons_arit_0<0b000, "add", add>;
   defm SUB_ZZZ   : sve_int_bin_cons_arit_0<0b001, "sub", sub>;
Index: llvm/include/llvm/IR/IntrinsicsAArch64.td
===
--- llvm/include/llvm/IR/IntrinsicsAArch64.td
+++ llvm/include/llvm/IR/IntrinsicsAArch64.td
@@ -1278,6 +1278,15 @@
 def int_aarch64_sve_cntp : AdvSIMD_SVE_CNTP_Intrinsic;
 
 //
+// FFR manipulation
+//
+
+def int_aarch64_sve_rdffr   : GCCBuiltin<"__builtin_sve_svrdffr">,   Intrinsic<[llvm_nxv

[PATCH] D31337: Use virtual functions in ParsedAttrInfo instead of function pointers

2020-01-21 Thread John Brawn via Phabricator via cfe-commits
john.brawn updated this revision to Diff 239292.
john.brawn added reviewers: erichkeane, aaron.ballman, rjmccall.
john.brawn set the repository for this revision to rG LLVM Github Monorepo.
john.brawn added a subscriber: llvm-commits.
john.brawn added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Resurrecting this old patch, with the intention of trying to get it committed 
this time. This is the first of four patches to make it possible for clang 
plugins to define attributes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D31337

Files:
  clang/lib/Sema/ParsedAttr.cpp
  clang/utils/TableGen/ClangAttrEmitter.cpp

Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -1801,7 +1801,7 @@
 
   void emitMatchRuleList(raw_ostream &OS);
 
-  std::string generateStrictConformsTo(const Record &Attr, raw_ostream &OS);
+  void generateStrictConformsTo(const Record &Attr, raw_ostream &OS);
 
   void generateParsingHelpers(raw_ostream &OS);
 };
@@ -1962,21 +1962,17 @@
   return Test;
 }
 
-std::string
+void
 PragmaClangAttributeSupport::generateStrictConformsTo(const Record &Attr,
   raw_ostream &OS) {
-  if (!isAttributedSupported(Attr))
-return "nullptr";
+  if (!isAttributedSupported(Attr) || Attr.isValueUnset("Subjects"))
+return;
   // Generate a function that constructs a set of matching rules that describe
   // to which declarations the attribute should apply to.
-  std::string FnName = "matchRulesFor" + Attr.getName().str();
-  OS << "static void " << FnName << "(llvm::SmallVectorImpl> &MatchRules, const LangOptions &LangOpts) {\n";
-  if (Attr.isValueUnset("Subjects")) {
-OS << "}\n\n";
-return FnName;
-  }
+ << ", bool>> &MatchRules, const LangOptions &LangOpts) const {\n";
   const Record *SubjectObj = Attr.getValueAsDef("Subjects");
   std::vector Subjects = SubjectObj->getValueAsListOfDefs("Subjects");
   for (const auto *Subject : Subjects) {
@@ -1993,7 +1989,6 @@
 }
   }
   OS << "}\n\n";
-  return FnName;
 }
 
 void PragmaClangAttributeSupport::generateParsingHelpers(raw_ostream &OS) {
@@ -3287,14 +3282,8 @@
 
   // If there is a variadic argument, we will set the optional argument count
   // to its largest value. Since it's currently a 4-bit number, we set it to 15.
-  OS << ArgCount << ", " << (HasVariadic ? 15 : OptCount);
-}
-
-static void GenerateDefaultAppertainsTo(raw_ostream &OS) {
-  OS << "static bool defaultAppertainsTo(Sema &, const ParsedAttr &,";
-  OS << "const Decl *) {\n";
-  OS << "  return true;\n";
-  OS << "}\n\n";
+  OS << "NumArgs = " << ArgCount << ";\n";
+  OS << "OptArgs = " << (HasVariadic ? 15 : OptCount) << ";\n";
 }
 
 static std::string GetDiagnosticSpelling(const Record &R) {
@@ -3408,11 +3397,12 @@
   return FnName;
 }
 
-static std::string GenerateAppertainsTo(const Record &Attr, raw_ostream &OS) {
+static void GenerateAppertainsTo(const Record &Attr, raw_ostream &SS,
+ raw_ostream &OS) {
   // If the attribute does not contain a Subjects definition, then use the
   // default appertainsTo logic.
   if (Attr.isValueUnset("Subjects"))
-return "defaultAppertainsTo";
+return;
 
   const Record *SubjectObj = Attr.getValueAsDef("Subjects");
   std::vector Subjects = SubjectObj->getValueAsListOfDefs("Subjects");
@@ -3420,22 +3410,19 @@
   // If the list of subjects is empty, it is assumed that the attribute
   // appertains to everything.
   if (Subjects.empty())
-return "defaultAppertainsTo";
+return;
 
   bool Warn = SubjectObj->getValueAsDef("Diag")->getValueAsBit("Warn");
 
   // Otherwise, generate an appertainsTo check specific to this attribute which
-  // checks all of the given subjects against the Decl passed in. Return the
-  // name of that check to the caller.
+  // checks all of the given subjects against the Decl passed in.
   //
   // If D is null, that means the attribute was not applied to a declaration
   // at all (for instance because it was applied to a type), or that the caller
   // has determined that the check should fail (perhaps prior to the creation
   // of the declaration).
-  std::string FnName = "check" + Attr.getName().str() + "AppertainsTo";
-  std::stringstream SS;
-  SS << "static bool " << FnName << "(Sema &S, const ParsedAttr &Attr, ";
-  SS << "const Decl *D) {\n";
+  SS << "virtual bool diagAppertainsToDecl(Sema &S, ";
+  SS << "const ParsedAttr &Attr, const Decl *D) const {\n";
   SS << "  if (!D || (";
   for (auto I = Subjects.begin(), E = Subjects.end(); I != E; ++I) {
 // If the subject has custom code associated with it, generate a function
@@ -3463,9 +3450,6 @@
   SS << "  }\n";
   SS << "  return true;\n";
   SS << "

[PATCH] D73098: [clang-tidy] readability-identifier-naming disregards parameters restrictions on main like functions

2020-01-21 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: aaron.ballman, JonasToth, alexfh, hokein.
njames93 added projects: clang, clang-tools-extra.
Herald added subscribers: kristof.beyls, xazax.hun.

Typically most main functions have the signature:

  int main(int argc, char *argv[])

To stick with convention when renaming parameters we should ignore the `argc` 
and `argv` names even if the parameter style says they should be renamed. This 
patch addresses this by checking all ParmVarDecls if they form part of a 
function with a signature that matches main `int name(int argc, char * argv[], 
(optional char *env[]))`


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73098

Files:
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-main-like.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-main-like.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-main-like.cpp
@@ -0,0 +1,51 @@
+// RUN: %check_clang_tidy %s readability-identifier-naming %t -- \
+// RUN:   -config='{CheckOptions: [ \
+// RUN: {key: readability-identifier-naming.ParameterCase, value: CamelCase} \
+// RUN:  ]}'
+
+int mainLike(int argc, char **argv);
+int mainLike(int argc, char **argv, const char **env);
+int mainLike(int argc, const char **argv);
+int mainLike(int argc, const char **argv, const char **env);
+int mainLike(int argc, char *argv[]);
+int mainLike(int argc, const char *argv[]);
+int mainLike(int argc, char *argv[], char *env[]);
+int mainLike(int argc, const char *argv[], const char *env[]);
+void notMain(int argc, char **argv);
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for parameter 'argc'
+// CHECK-MESSAGES: :[[@LINE-2]]:31: warning: invalid case style for parameter 'argv'
+void notMain(int argc, char **argv, char **env);
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for parameter 'argc'
+// CHECK-MESSAGES: :[[@LINE-2]]:31: warning: invalid case style for parameter 'argv'
+// CHECK-MESSAGES: :[[@LINE-3]]:44: warning: invalid case style for parameter 'env'
+int notMain(int argc, char **argv, char **env, int Extra);
+// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: invalid case style for parameter 'argc'
+// CHECK-MESSAGES: :[[@LINE-2]]:30: warning: invalid case style for parameter 'argv'
+// CHECK-MESSAGES: :[[@LINE-3]]:43: warning: invalid case style for parameter 'env'
+int notMain(int argc, char **argv, int Extra);
+// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: invalid case style for parameter 'argc'
+// CHECK-MESSAGES: :[[@LINE-2]]:30: warning: invalid case style for parameter 'argv'
+int notMain(int argc, char *argv);
+// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: invalid case style for parameter 'argc'
+// CHECK-MESSAGES: :[[@LINE-2]]:29: warning: invalid case style for parameter 'argv'
+int notMain(unsigned argc, char **argv);
+// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: invalid case style for parameter 'argc'
+// CHECK-MESSAGES: :[[@LINE-2]]:35: warning: invalid case style for parameter 'argv'
+int notMain(long argc, char *argv);
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for parameter 'argc'
+// CHECK-MESSAGES: :[[@LINE-2]]:30: warning: invalid case style for parameter 'argv'
+int notMain(int argc, char16_t **argv);
+// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: invalid case style for parameter 'argc'
+// CHECK-MESSAGES: :[[@LINE-2]]:34: warning: invalid case style for parameter 'argv'
+int notMain(int argc, char argv[]);
+// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: invalid case style for parameter 'argc'
+// CHECK-MESSAGES: :[[@LINE-2]]:28: warning: invalid case style for parameter 'argv'
+typedef char myFunChar;
+typedef int myFunInt;
+typedef char **myFunCharPtr;
+typedef long myFunLong;
+myFunInt mainLikeTypedef(myFunInt argc, myFunChar **argv);
+int mainLikeTypedef(int argc, myFunCharPtr argv);
+int notMainTypedef(myFunLong argc, char **argv);
+// CHECK-MESSAGES: :[[@LINE-1]]:30: warning: invalid case style for parameter 'argc'
+// CHECK-MESSAGES: :[[@LINE-2]]:43: warning: invalid case style for parameter 'argv'
Index: clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -324,6 +324,43 @@
   return Fixup;
 }
 
+static bool isParamInMainLikeFunction(const ParmVarDecl &ParmDecl) {
+  auto IsCharPtrPtr = [](QualType QType) {
+if (QType.isNull())
+  return false;
+if (QType = QType->getPointeeType(), QType.isNull())
+  return false;
+if (QType = QType->getPointeeType(), QType.isNull())
+  return false;
+return QType->isCharType();
+  };
+  auto IsI

[PATCH] D73099: [Alignment][NFC] Deprecate Align::None()

2020-01-21 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet created this revision.
gchatelet added reviewers: xbolva00, courbet.
Herald added subscribers: llvm-commits, cfe-commits, kerbowa, Jim, jsji, 
atanasyan, jrtc27, kbarton, hiraditya, nhaehnle, jvesely, nemanjai, sdardis, 
dylanmckay, arsenm.
Herald added a reviewer: bollu.
Herald added projects: clang, LLVM.

This is a follow up on https://reviews.llvm.org/D71473#inline-647262.
There's a caveat here that `Align(1)` relies on the compiler understanding of 
`Log2_64` implementation to produce good code. One could use `Align()` as a 
replacement but I believe it is less clear that the alignment is one in that 
case.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73099

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGObjCMac.cpp
  llvm/include/llvm/CodeGen/AsmPrinter.h
  llvm/include/llvm/CodeGen/TargetFrameLowering.h
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/include/llvm/Support/Alignment.h
  llvm/lib/Analysis/Loads.cpp
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
  llvm/lib/CodeGen/MIRPrinter.cpp
  llvm/lib/CodeGen/MachineBasicBlock.cpp
  llvm/lib/CodeGen/MachineFrameInfo.cpp
  llvm/lib/CodeGen/MachineOperand.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/ExecutionEngine/Orc/Speculation.cpp
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/IR/DataLayout.cpp
  llvm/lib/IR/IRBuilder.cpp
  llvm/lib/Target/AArch64/AArch64CompressJumpTables.cpp
  llvm/lib/Target/AMDGPU/AMDGPUFrameLowering.h
  llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp
  llvm/lib/Target/AMDGPU/R600FrameLowering.h
  llvm/lib/Target/AMDGPU/SIFrameLowering.h
  llvm/lib/Target/ARM/ARMBasicBlockInfo.cpp
  llvm/lib/Target/ARM/ARMBasicBlockInfo.h
  llvm/lib/Target/ARM/ARMConstantIslandPass.cpp
  llvm/lib/Target/AVR/AVRFrameLowering.cpp
  llvm/lib/Target/Hexagon/HexagonBranchRelaxation.cpp
  llvm/lib/Target/Hexagon/HexagonFixupHwLoops.cpp
  llvm/lib/Target/Hexagon/HexagonFrameLowering.h
  llvm/lib/Target/Hexagon/HexagonTargetTransformInfo.cpp
  llvm/lib/Target/Mips/MipsCallLowering.cpp
  llvm/lib/Target/Mips/MipsConstantIslandPass.cpp
  llvm/lib/Target/PowerPC/PPCBranchSelector.cpp
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
  llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
  llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
  llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
  llvm/lib/Transforms/Utils/InlineFunction.cpp
  llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
  llvm/unittests/Support/AlignmentTest.cpp
  polly/lib/CodeGen/LoopGeneratorsKMP.cpp

Index: polly/lib/CodeGen/LoopGeneratorsKMP.cpp
===
--- polly/lib/CodeGen/LoopGeneratorsKMP.cpp
+++ polly/lib/CodeGen/LoopGeneratorsKMP.cpp
@@ -468,7 +468,7 @@
 // Global Variable Definitions
 GlobalVariable *StrVar = new GlobalVariable(
 *M, ArrayType, true, GlobalValue::PrivateLinkage, 0, ".str.ident");
-StrVar->setAlignment(llvm::Align::None());
+StrVar->setAlignment(llvm::Align(1));
 
 SourceLocDummy = new GlobalVariable(
 *M, IdentTy, true, GlobalValue::PrivateLinkage, nullptr, LocName);
Index: llvm/unittests/Support/AlignmentTest.cpp
===
--- llvm/unittests/Support/AlignmentTest.cpp
+++ llvm/unittests/Support/AlignmentTest.cpp
@@ -52,7 +52,6 @@
 
 TEST(AlignmentTest, AlignDefaultCTor) {
   EXPECT_EQ(Align().value(), 1ULL);
-  EXPECT_EQ(Align::None().value(), 1ULL);
 }
 
 TEST(AlignmentTest, MaybeAlignDefaultCTor) {
Index: llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
===
--- llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
+++ llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
@@ -177,8 +177,7 @@
   if (!isOnlyUsedInComparisonWithZero(CI))
 return false;
 
-  if (!isDereferenceableAndAlignedPointer(Str, Align::None(), APInt(64, Len),
-  DL))
+  if (!isDereferenceableAndAlignedPointer(Str, Align(1), APInt(64, Len), DL))
 return false;
 
   if (CI->getFunction()->hasFnAttribute(Attribute::SanitizeMemory))
@@ -289,7 +288,7 @@
   // We have enough information to now generate the memcpy call to do the
   // concatenation for us.  Make a memcpy to copy the nul byte with align = 1.
   B.CreateMemCpy(
-  CpyDst, Align::None(), Src, Align::None(),
+  CpyDst, Align(1), Src, Align(1),
   ConstantInt::get(DL.getIntPtrType(Src->getContext()), Len + 1));
   return Dst;
 }
@@ -562,7 +561,7 @@
   // We have enough information to now generate the memcpy call to do the
   // copy for us.  Make a memcpy to copy the nul byte with align = 1.
   

[clang-tools-extra] f651c40 - [clangd] Capture the missing injected class names in findExplicitReferences.

2020-01-21 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-01-21T15:09:23+01:00
New Revision: f651c402a221a20f3bc6ea43f70b29326a357010

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

LOG: [clangd] Capture the missing injected class names in 
findExplicitReferences.

Summary: Fixes https://github.com/clangd/clangd/issues/237.

Reviewers: kadircet, kbobyrev

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/FindTarget.cpp
clang-tools-extra/clangd/unittests/FindTargetTests.cpp
clang-tools-extra/clangd/unittests/RenameTests.cpp
clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/FindTarget.cpp 
b/clang-tools-extra/clangd/FindTarget.cpp
index 0e3c30e16dd5..cbe83cc2cce4 100644
--- a/clang-tools-extra/clangd/FindTarget.cpp
+++ b/clang-tools-extra/clangd/FindTarget.cpp
@@ -695,6 +695,13 @@ llvm::SmallVector refInTypeLoc(TypeLoc L) 
{
DeclRelation::Alias)};
 }
 
+void VisitInjectedClassNameTypeLoc(InjectedClassNameTypeLoc TL) {
+  Ref = ReferenceLoc{NestedNameSpecifierLoc(),
+ TL.getNameLoc(),
+ /*IsDecl=*/false,
+ {TL.getDecl()}};
+}
+
 void VisitDependentTemplateSpecializationTypeLoc(
 DependentTemplateSpecializationTypeLoc L) {
   Ref = ReferenceLoc{

diff  --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp 
b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
index a420348fcda8..4c9fe120a8d6 100644
--- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -1,4 +1,4 @@
-//===-- FindSymbolsTests.cpp -*- C++ 
-*===//
+//===-- FindTargetTests.cpp --*- C++ 
-*===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -553,8 +553,8 @@ class FindExplicitReferencesTest : public ::testing::Test {
 std::string DumpedReferences;
   };
 
-  /// Parses \p Code, finds function '::foo' and annotates its body with 
results
-  /// of findExplicitReferecnces.
+  /// Parses \p Code, finds function or namespace '::foo' and annotates its 
body
+  /// with results of findExplicitReferecnces.
   /// See actual tests for examples of annotation format.
   AllRefs annotateReferencesInFoo(llvm::StringRef Code) {
 TestTU TU;
@@ -574,12 +574,21 @@ class FindExplicitReferencesTest : public ::testing::Test 
{
 auto *TestDecl = &findDecl(AST, "foo");
 if (auto *T = llvm::dyn_cast(TestDecl))
   TestDecl = T->getTemplatedDecl();
-auto &Func = llvm::cast(*TestDecl);
 
 std::vector Refs;
-findExplicitReferences(Func.getBody(), [&Refs](ReferenceLoc R) {
-  Refs.push_back(std::move(R));
-});
+if (const auto *Func = llvm::dyn_cast(TestDecl))
+  findExplicitReferences(Func->getBody(), [&Refs](ReferenceLoc R) {
+Refs.push_back(std::move(R));
+  });
+else if (const auto *NS = llvm::dyn_cast(TestDecl))
+  findExplicitReferences(NS, [&Refs, &NS](ReferenceLoc R) {
+// Avoid adding the namespace foo decl to the results.
+if (R.Targets.size() == 1 && R.Targets.front() == NS)
+  return;
+Refs.push_back(std::move(R));
+  });
+else
+  ADD_FAILURE() << "Failed to find ::foo decl for test";
 
 auto &SM = AST.getSourceManager();
 llvm::sort(Refs, [&](const ReferenceLoc &L, const ReferenceLoc &R) {
@@ -720,6 +729,25 @@ TEST_F(FindExplicitReferencesTest, All) {
 "1: targets = {vi}, decl\n"
 "2: targets = {valias}\n"
 "3: targets = {vb}, decl\n"},
+   // Injected class name.
+   {R"cpp(
+namespace foo {
+  template 
+  class $1^$2^Bar {
+~$3^Bar();
+void $4^f($5^Bar);
+  };
+}
+  )cpp",
+"0: targets = {foo::Bar::T}, decl\n"
+// FIXME: avoid the 2 duplicated foo::Bar references below, the first
+// one comes from ClassTemplateDecl; the second comes from the
+// underlying CXXRecordDecl.
+"1: targets = {foo::Bar}, decl\n"
+"2: targets = {foo::Bar}, decl\n"
+"3: targets = {foo::Bar}\n"
+"4: targets = {foo::Bar::f}, decl\n"
+"5: targets = {foo::Bar}\n"},
// MemberExpr should know their using declaration.
{R"cpp(
 struct X { void func(int); };

diff  --git a/clang-tools-extra/clangd/unittests/RenameTests.cpp 
b/clang

[PATCH] D73088: [clangd] Capture the missing injected class names in findExplicitReferences.

2020-01-21 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

In D73088#1830960 , @kbobyrev wrote:

> It would also be great to have the original rename test from the linked issue 
> since something might potentially go wrong in-between 
> `findExplicitReferences`.


Done.

> and rename action (and also to expand the testset because the existing one is 
> not really extensive :().

yeap, there is some room to improve the test code here (e.g. using an idea 
similar to `CodeContext` in `TweakTesting`), previously we put the test code to 
a wrapper `foo` function, it is sufficient for most cases, but not for this 
patch as defining a template class in a function body is forbidden in C++. I 
think we can adress this afterwards.




Comment at: clang-tools-extra/clangd/unittests/FindTargetTests.cpp:736
+  template 
+  class $1^$2^Bar {
+~$3^Bar();

kadircet wrote:
> kadircet wrote:
> > looks like we are getting duplicates here
> looking at this again, this is actually not caused by this change, it was 
> always there we just didn't notice it before since no one tested class 
> templates.
> 
> could you put a fixme on it?
Done.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73088



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


[PATCH] D73088: [clangd] Capture the missing injected class names in findExplicitReferences.

2020-01-21 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 239296.
hokein marked 2 inline comments as done.
hokein added a comment.

- add fixme
- add rename test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73088

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

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -525,7 +525,7 @@
 using $Typedef[[LVReference]] = $TemplateParameter[[T]] &;
 using $Typedef[[RVReference]] = $TemplateParameter[[T]]&&;
 using $Typedef[[Array]] = $TemplateParameter[[T]]*[3];
-using $Typedef[[MemberPointer]] = int (A::*)(int);
+using $Typedef[[MemberPointer]] = int ($Class[[A]]::*)(int);
 
 // Use various previously defined typedefs in a function type.
 void $Method[[func]](
Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -127,6 +127,16 @@
 void [[Foo]]::foo(int x) {}
   )cpp",
 
+  // Rename template class, including constructor/destructor.
+  R"cpp(
+template 
+class [[F^oo]] {
+  [[F^oo]]();
+  ~[[F^oo]]();
+  void f([[Foo]] x);
+};
+  )cpp",
+
   // Class in template argument.
   R"cpp(
 class [[F^oo]] {};
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -1,4 +1,4 @@
-//===-- FindSymbolsTests.cpp -*- C++ -*===//
+//===-- FindTargetTests.cpp --*- C++ -*===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -553,8 +553,8 @@
 std::string DumpedReferences;
   };
 
-  /// Parses \p Code, finds function '::foo' and annotates its body with results
-  /// of findExplicitReferecnces.
+  /// Parses \p Code, finds function or namespace '::foo' and annotates its body
+  /// with results of findExplicitReferecnces.
   /// See actual tests for examples of annotation format.
   AllRefs annotateReferencesInFoo(llvm::StringRef Code) {
 TestTU TU;
@@ -574,12 +574,21 @@
 auto *TestDecl = &findDecl(AST, "foo");
 if (auto *T = llvm::dyn_cast(TestDecl))
   TestDecl = T->getTemplatedDecl();
-auto &Func = llvm::cast(*TestDecl);
 
 std::vector Refs;
-findExplicitReferences(Func.getBody(), [&Refs](ReferenceLoc R) {
-  Refs.push_back(std::move(R));
-});
+if (const auto *Func = llvm::dyn_cast(TestDecl))
+  findExplicitReferences(Func->getBody(), [&Refs](ReferenceLoc R) {
+Refs.push_back(std::move(R));
+  });
+else if (const auto *NS = llvm::dyn_cast(TestDecl))
+  findExplicitReferences(NS, [&Refs, &NS](ReferenceLoc R) {
+// Avoid adding the namespace foo decl to the results.
+if (R.Targets.size() == 1 && R.Targets.front() == NS)
+  return;
+Refs.push_back(std::move(R));
+  });
+else
+  ADD_FAILURE() << "Failed to find ::foo decl for test";
 
 auto &SM = AST.getSourceManager();
 llvm::sort(Refs, [&](const ReferenceLoc &L, const ReferenceLoc &R) {
@@ -720,6 +729,25 @@
 "1: targets = {vi}, decl\n"
 "2: targets = {valias}\n"
 "3: targets = {vb}, decl\n"},
+   // Injected class name.
+   {R"cpp(
+namespace foo {
+  template 
+  class $1^$2^Bar {
+~$3^Bar();
+void $4^f($5^Bar);
+  };
+}
+  )cpp",
+"0: targets = {foo::Bar::T}, decl\n"
+// FIXME: avoid the 2 duplicated foo::Bar references below, the first
+// one comes from ClassTemplateDecl; the second comes from the
+// underlying CXXRecordDecl.
+"1: targets = {foo::Bar}, decl\n"
+"2: targets = {foo::Bar}, decl\n"
+"3: targets = {foo::Bar}\n"
+"4: targets = {foo::Bar::f}, decl\n"
+"5: targets = {foo::Bar}\n"},
// MemberExpr should know their using declaration.
{R"cpp(
 struct X { void func(int); };
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.c

[PATCH] D31338: Move ParsedAttrInfos into a registry and point to one in ParsedAttr

2020-01-21 Thread John Brawn via Phabricator via cfe-commits
john.brawn updated this revision to Diff 239295.
john.brawn retitled this revision from "Move ParsedAttrInfos into a registry 
and point to one in AttributeList" to "Move ParsedAttrInfos into a registry and 
point to one in ParsedAttr".
john.brawn added reviewers: erichkeane, aaron.ballman, rjmccall.
john.brawn set the repository for this revision to rG LLVM Github Monorepo.
john.brawn added a subscriber: cfe-commits.
john.brawn added a comment.
Herald added a project: clang.

Resurrecting this old patch, with a bunch of changes due to the changes around 
AttributeCommonInfo. This is the second of four patches to make it possible for 
clang plugins to define attributes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D31338

Files:
  clang/include/clang/Sema/CMakeLists.txt
  clang/include/clang/Sema/ParsedAttr.h
  clang/lib/Basic/Attributes.cpp
  clang/lib/Sema/ParsedAttr.cpp
  clang/utils/TableGen/ClangAttrEmitter.cpp
  clang/utils/TableGen/TableGen.cpp
  clang/utils/TableGen/TableGenBackends.h

Index: clang/utils/TableGen/TableGenBackends.h
===
--- clang/utils/TableGen/TableGenBackends.h
+++ clang/utils/TableGen/TableGenBackends.h
@@ -55,8 +55,6 @@
  llvm::raw_ostream &OS);
 void EmitClangAttrParsedAttrImpl(llvm::RecordKeeper &Records,
  llvm::raw_ostream &OS);
-void EmitClangAttrParsedAttrKinds(llvm::RecordKeeper &Records,
-  llvm::raw_ostream &OS);
 void EmitClangAttrTextNodeDump(llvm::RecordKeeper &Records,
llvm::raw_ostream &OS);
 void EmitClangAttrNodeTraverse(llvm::RecordKeeper &Records,
Index: clang/utils/TableGen/TableGen.cpp
===
--- clang/utils/TableGen/TableGen.cpp
+++ clang/utils/TableGen/TableGen.cpp
@@ -39,7 +39,6 @@
   GenClangAttrTemplateInstantiate,
   GenClangAttrParsedAttrList,
   GenClangAttrParsedAttrImpl,
-  GenClangAttrParsedAttrKinds,
   GenClangAttrTextNodeDump,
   GenClangAttrNodeTraverse,
   GenClangBasicReader,
@@ -122,9 +121,6 @@
 clEnumValN(GenClangAttrParsedAttrImpl,
"gen-clang-attr-parsed-attr-impl",
"Generate the clang parsed attribute helpers"),
-clEnumValN(GenClangAttrParsedAttrKinds,
-   "gen-clang-attr-parsed-attr-kinds",
-   "Generate a clang parsed attribute kinds"),
 clEnumValN(GenClangAttrTextNodeDump, "gen-clang-attr-text-node-dump",
"Generate clang attribute text node dumper"),
 clEnumValN(GenClangAttrNodeTraverse, "gen-clang-attr-node-traverse",
@@ -257,9 +253,6 @@
   case GenClangAttrParsedAttrImpl:
 EmitClangAttrParsedAttrImpl(Records, OS);
 break;
-  case GenClangAttrParsedAttrKinds:
-EmitClangAttrParsedAttrKinds(Records, OS);
-break;
   case GenClangAttrTextNodeDump:
 EmitClangAttrTextNodeDump(Records, OS);
 break;
Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -158,12 +158,14 @@
 typedef std::vector> ParsedAttrMap;
 
 static ParsedAttrMap getParsedAttrList(const RecordKeeper &Records,
-   ParsedAttrMap *Dupes = nullptr) {
+   ParsedAttrMap *Dupes = nullptr,
+   bool IncludeIgnored = false) {
   std::vector Attrs = Records.getAllDerivedDefinitions("Attr");
   std::set Seen;
   ParsedAttrMap R;
   for (const auto *Attr : Attrs) {
-if (Attr->getValueAsBit("SemaHandler")) {
+if (Attr->getValueAsBit("SemaHandler") ||
+(IncludeIgnored && Attr->getValueAsBit("Ignored"))) {
   std::string AN;
   if (Attr->isSubClassOf("TargetSpecificAttr") &&
   !Attr->isValueUnset("ParseKind")) {
@@ -3590,9 +3592,10 @@
   getPragmaAttributeSupport(Records);
 
   // Get the list of parsed attributes, and accept the optional list of
-  // duplicates due to the ParseKind.
+  // duplicates due to the ParseKind. We also want to include ignored
+  // attributes as we want them to be successfully matched.
   ParsedAttrMap Dupes;
-  ParsedAttrMap Attrs = getParsedAttrList(Records, &Dupes);
+  ParsedAttrMap Attrs = getParsedAttrList(Records, &Dupes, true);
 
   // Generate the appertainsTo diagnostic methods and write their names into
   // another mapping. At the same time, generate the AttrInfoMap object
@@ -3608,10 +3611,18 @@
 // the spellings are identical, and custom parsing rules match, etc.
 
 // We need to generate struct instances based off ParsedAttrInfo from
-// ParsedAttr.cpp.
+// ParsedAttr.h.
 const Record &Attr = *I->second;
-SS << "struct ParsedAttrInfo" << I->first <

[PATCH] D73088: [clangd] Capture the missing injected class names in findExplicitReferences.

2020-01-21 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf651c402a221: [clangd] Capture the missing injected class 
names in findExplicitReferences. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73088

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

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -525,7 +525,7 @@
 using $Typedef[[LVReference]] = $TemplateParameter[[T]] &;
 using $Typedef[[RVReference]] = $TemplateParameter[[T]]&&;
 using $Typedef[[Array]] = $TemplateParameter[[T]]*[3];
-using $Typedef[[MemberPointer]] = int (A::*)(int);
+using $Typedef[[MemberPointer]] = int ($Class[[A]]::*)(int);
 
 // Use various previously defined typedefs in a function type.
 void $Method[[func]](
Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -127,6 +127,16 @@
 void [[Foo]]::foo(int x) {}
   )cpp",
 
+  // Rename template class, including constructor/destructor.
+  R"cpp(
+template 
+class [[F^oo]] {
+  [[F^oo]]();
+  ~[[F^oo]]();
+  void f([[Foo]] x);
+};
+  )cpp",
+
   // Class in template argument.
   R"cpp(
 class [[F^oo]] {};
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -1,4 +1,4 @@
-//===-- FindSymbolsTests.cpp -*- C++ -*===//
+//===-- FindTargetTests.cpp --*- C++ -*===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -553,8 +553,8 @@
 std::string DumpedReferences;
   };
 
-  /// Parses \p Code, finds function '::foo' and annotates its body with results
-  /// of findExplicitReferecnces.
+  /// Parses \p Code, finds function or namespace '::foo' and annotates its body
+  /// with results of findExplicitReferecnces.
   /// See actual tests for examples of annotation format.
   AllRefs annotateReferencesInFoo(llvm::StringRef Code) {
 TestTU TU;
@@ -574,12 +574,21 @@
 auto *TestDecl = &findDecl(AST, "foo");
 if (auto *T = llvm::dyn_cast(TestDecl))
   TestDecl = T->getTemplatedDecl();
-auto &Func = llvm::cast(*TestDecl);
 
 std::vector Refs;
-findExplicitReferences(Func.getBody(), [&Refs](ReferenceLoc R) {
-  Refs.push_back(std::move(R));
-});
+if (const auto *Func = llvm::dyn_cast(TestDecl))
+  findExplicitReferences(Func->getBody(), [&Refs](ReferenceLoc R) {
+Refs.push_back(std::move(R));
+  });
+else if (const auto *NS = llvm::dyn_cast(TestDecl))
+  findExplicitReferences(NS, [&Refs, &NS](ReferenceLoc R) {
+// Avoid adding the namespace foo decl to the results.
+if (R.Targets.size() == 1 && R.Targets.front() == NS)
+  return;
+Refs.push_back(std::move(R));
+  });
+else
+  ADD_FAILURE() << "Failed to find ::foo decl for test";
 
 auto &SM = AST.getSourceManager();
 llvm::sort(Refs, [&](const ReferenceLoc &L, const ReferenceLoc &R) {
@@ -720,6 +729,25 @@
 "1: targets = {vi}, decl\n"
 "2: targets = {valias}\n"
 "3: targets = {vb}, decl\n"},
+   // Injected class name.
+   {R"cpp(
+namespace foo {
+  template 
+  class $1^$2^Bar {
+~$3^Bar();
+void $4^f($5^Bar);
+  };
+}
+  )cpp",
+"0: targets = {foo::Bar::T}, decl\n"
+// FIXME: avoid the 2 duplicated foo::Bar references below, the first
+// one comes from ClassTemplateDecl; the second comes from the
+// underlying CXXRecordDecl.
+"1: targets = {foo::Bar}, decl\n"
+"2: targets = {foo::Bar}, decl\n"
+"3: targets = {foo::Bar}\n"
+"4: targets = {foo::Bar::f}, decl\n"
+"5: targets = {foo::Bar}\n"},
// MemberExpr should know their using declaration.
{R"cpp(
 struct X { void func(int); };
Index: clang-tools-extra/clangd/FindTarget.cpp

[PATCH] D72557: Add pretty printers for llvm::PointerIntPair and llvm::PointerUnion.

2020-01-21 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62026 tests passed, 0 failed 
and 783 were skipped.

{icon question-circle color=gray} clang-tidy: unknown.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72557



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


[PATCH] D73098: [clang-tidy] readability-identifier-naming disregards parameters restrictions on main like functions

2020-01-21 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

For the record this convention appears everywhere in LLVM even though LLVM 
style is to have parameters starting with uppercase letters


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73098



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


[PATCH] D72557: Add pretty printers for llvm::PointerIntPair and llvm::PointerUnion.

2020-01-21 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62026 tests passed, 0 failed 
and 783 were skipped.

{icon question-circle color=gray} clang-tidy: unknown.

{icon times-circle color=red} clang-format: fail. Please format your changes 
with clang-format by running `git-clang-format HEAD^` or applying this patch 
.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72557



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


[PATCH] D72982: [Clang] Un-break scan-build after integrated-cc1 change

2020-01-21 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

Do you have commit access or need someone to commit on your behalf? Also, in 
case your change made it into the clang 10 release branch this will need to be 
cherry picked there as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72982



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


[PATCH] D73101: [clangd] Do not duplicate TemplatedDecls in findExplicitReferences

2020-01-21 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: hokein.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73101

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
@@ -733,18 +733,17 @@
{R"cpp(
 namespace foo {
   template 
-  class $1^$2^Bar {
-~$3^Bar();
-void $4^f($5^Bar);
+  class $1^Bar {
+~$2^Bar();
+void $3^f($4^Bar);
   };
 }
   )cpp",
 "0: targets = {foo::Bar::T}, decl\n"
 "1: targets = {foo::Bar}, decl\n"
-"2: targets = {foo::Bar}, decl\n"
-"3: targets = {foo::Bar}\n"
-"4: targets = {foo::Bar::f}, decl\n"
-"5: targets = {foo::Bar}\n"},
+"2: targets = {foo::Bar}\n"
+"3: targets = {foo::Bar::f}, decl\n"
+"4: targets = {foo::Bar}\n"},
// MemberExpr should know their using declaration.
{R"cpp(
 struct X { void func(int); };
@@ -1044,7 +1043,47 @@
   }
 )cpp",
"0: targets = {Test}\n"
-   "1: targets = {a}, decl\n"}};
+   "1: targets = {a}, decl\n"},
+   // Templates
+   {R"cpp(
+namespace foo {
+  template 
+  class $1^Bar {};
+}
+  )cpp",
+"0: targets = {foo::Bar::T}, decl\n"
+"1: targets = {foo::Bar}, decl\n"},
+   // Templates
+   {R"cpp(
+namespace foo {
+  template 
+  void $1^func();
+}
+  )cpp",
+"0: targets = {T}, decl\n"
+"1: targets = {foo::func}, decl\n"},
+   // Templates
+   {R"cpp(
+namespace foo {
+  template 
+  $1^T $2^x;
+}
+  )cpp",
+"0: targets = {foo::T}, decl\n"
+"1: targets = {foo::T}\n"
+"2: targets = {foo::x}, decl\n"},
+   // Templates
+   {R"cpp(
+template class vector {};
+namespace foo {
+  template 
+  using $1^V = $2^vector<$3^T>;
+}
+  )cpp",
+"0: targets = {foo::T}, decl\n"
+"1: targets = {foo::V}, decl\n"
+"2: targets = {vector}\n"
+"3: targets = {foo::T}\n"}};
 
   for (const auto &C : Cases) {
 llvm::StringRef ExpectedCode = C.first;
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -580,6 +580,11 @@
   {D->getAliasedNamespace()}});
 }
 
+void VisitRedeclarableTemplateDecl(const RedeclarableTemplateDecl *TD) {
+  // {Class,Function,Var,TypeAlias}TemplateDecls are visited as part of the
+  // NamedDecl below, we skip them here to not visit them twice.
+}
+
 void VisitNamedDecl(const NamedDecl *ND) {
   // FIXME: decide on how to surface destructors when we need them.
   if (llvm::isa(ND))


Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -733,18 +733,17 @@
{R"cpp(
 namespace foo {
   template 
-  class $1^$2^Bar {
-~$3^Bar();
-void $4^f($5^Bar);
+  class $1^Bar {
+~$2^Bar();
+void $3^f($4^Bar);
   };
 }
   )cpp",
 "0: targets = {foo::Bar::T}, decl\n"
 "1: targets = {foo::Bar}, decl\n"
-"2: targets = {foo::Bar}, decl\n"
-"3: targets = {foo::Bar}\n"
-"4: targets = {foo::Bar::f}, decl\n"
-"5: targets = {foo::Bar}\n"},
+"2: targets = {foo::Bar}\n"
+"3: targets = {foo::Bar::f}, decl\n"
+"4: targets = {foo::Bar}\n"},
// MemberExpr should know their using declaration.
{R"cpp(
 struct X { void func(int); };
@@ -1044,7 +1043,47 @@
   }
 )cpp",
"0: targets = {Test}\n"
-   "1: targets = {a}, decl\n"}};
+   "1: targets = {a}, decl\n"},
+   // Templates
+   {R"cpp(
+namespace foo {
+  template 
+  class $1^Bar {};
+}
+  )cpp",
+"0: targets = {foo::Bar::T}, decl\n"
+"1: targets = {foo::Bar}

[PATCH] D73088: [clangd] Capture the missing injected class names in findExplicitReferences.

2020-01-21 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon times-circle color=red} Unit tests: fail. 62042 tests passed, 1 failed 
and 783 were skipped.

  failed: 
libc++.std/thread/thread_mutex/thread_mutex_requirements/thread_sharedtimedmutex_requirements/thread_sharedtimedmutex_class/try_lock.pass.cpp

{icon question-circle color=gray} clang-tidy: unknown.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73088



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


[PATCH] D73098: [clang-tidy] readability-identifier-naming disregards parameters restrictions on main like functions

2020-01-21 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62058 tests passed, 0 failed 
and 784 were skipped.

{icon question-circle color=gray} clang-tidy: unknown.

{icon times-circle color=red} clang-format: fail. Please format your changes 
with clang-format by running `git-clang-format HEAD^` or applying this patch 
.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73098



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


[PATCH] D73101: [clangd] Do not duplicate TemplatedDecls in findExplicitReferences

2020-01-21 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon question-circle color=gray} Unit tests: unknown.

{icon question-circle color=gray} clang-tidy: unknown.

{icon question-circle color=gray} clang-format: unknown.

Build artifacts 
: 
diff.json 
,
 console-log.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73101



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


[PATCH] D31342: Add ParsedAttrInfo::handleDeclAttribute

2020-01-21 Thread John Brawn via Phabricator via cfe-commits
john.brawn updated this revision to Diff 239299.
john.brawn edited the summary of this revision.
john.brawn added reviewers: erichkeane, aaron.ballman, rjmccall.
john.brawn set the repository for this revision to rG LLVM Github Monorepo.
john.brawn added a subscriber: cfe-commits.
john.brawn added a comment.
Herald added a project: clang.

Resurrecting this old patch, plus take the opportunity to remove the need for 
some boilerplate code. This is the third of four patches to make it possible 
for clang plugins to define attributes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D31342

Files:
  clang/docs/ClangPlugins.rst
  clang/docs/InternalsManual.rst
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Sema/ParsedAttr.h
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/utils/TableGen/ClangAttrEmitter.cpp

Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -3576,6 +3576,20 @@
   OS << "}\n\n";
 }
 
+static void GenerateHandleDeclAttribute(const Record &Attr, raw_ostream &OS) {
+  // Only generate if Attr can be handled simply.
+  if (!Attr.getValueAsBit("SimpleHandler"))
+return;
+
+  // Generate a function which just converts from ParsedAttr to the Attr type.
+  OS << "virtual bool handleDeclAttribute(Sema &S, Decl *D,";
+  OS << "const ParsedAttr &Attr) const {\n";
+  OS << "  D->addAttr(::new (S.Context) " << Attr.getName();
+  OS << "Attr(S.Context, Attr));\n";
+  OS << "  return true;\n";
+  OS << "}\n\n";
+}
+
 static bool IsKnownToGCC(const Record &Attr) {
   // Look at the spellings for this subject; if there are any spellings which
   // claim to be known to GCC, the attribute is known to GCC.
@@ -3657,6 +3671,7 @@
 GenerateTargetRequirements(Attr, Dupes, SS);
 GenerateSpellingIndexToSemanticSpelling(Attr, SS);
 PragmaAttributeSupport.generateStrictConformsTo(*I->second, SS);
+GenerateHandleDeclAttribute(Attr, SS);
 SS << "};\n";
 SS << "static ParsedAttrInfoRegistry::Add<" << AttrInfoName << "> ";
 SS << AttrInfoName << "Instance(\"" << AttrName << "\",\"\");\n";
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -6698,6 +6698,9 @@
   if (handleCommonAttributeFeatures(S, D, AL))
 return;
 
+  if (AL.getInfo().handleDeclAttribute(S, D, AL))
+return;
+
   switch (AL.getKind()) {
   default:
 if (!AL.isStmtAttr()) {
@@ -6722,15 +6725,9 @@
 handleSimpleAttributeWithExclusions(S, D, AL);
 break;
-  case ParsedAttr::AT_NoMips16:
-handleSimpleAttribute(S, D, AL);
-break;
   case ParsedAttr::AT_MicroMips:
 handleSimpleAttributeWithExclusions(S, D, AL);
 break;
-  case ParsedAttr::AT_NoMicroMips:
-handleSimpleAttribute(S, D, AL);
-break;
   case ParsedAttr::AT_MipsLongCall:
 handleSimpleAttributeWithExclusions(
 S, D, AL);
@@ -6766,9 +6763,6 @@
   case ParsedAttr::AT_WebAssemblyImportName:
 handleWebAssemblyImportNameAttr(S, D, AL);
 break;
-  case ParsedAttr::AT_IBAction:
-handleSimpleAttribute(S, D, AL);
-break;
   case ParsedAttr::AT_IBOutlet:
 handleIBOutlet(S, D, AL);
 break;
@@ -6793,9 +6787,6 @@
   case ParsedAttr::AT_AlwaysInline:
 handleAlwaysInlineAttr(S, D, AL);
 break;
-  case ParsedAttr::AT_Artificial:
-handleSimpleAttribute(S, D, AL);
-break;
   case ParsedAttr::AT_AnalyzerNoReturn:
 handleAnalyzerNoReturnAttr(S, D, AL);
 break;
@@ -6827,9 +6818,6 @@
   case ParsedAttr::AT_Constructor:
 handleConstructorAttr(S, D, AL);
 break;
-  case ParsedAttr::AT_CXX11NoReturn:
-handleSimpleAttribute(S, D, AL);
-break;
   case ParsedAttr::AT_Deprecated:
 handleDeprecatedAttr(S, D, AL);
 break;
@@ -6857,15 +6845,9 @@
   case ParsedAttr::AT_OptimizeNone:
 handleOptimizeNoneAttr(S, D, AL);
 break;
-  case ParsedAttr::AT_FlagEnum:
-handleSimpleAttribute(S, D, AL);
-break;
   case ParsedAttr::AT_EnumExtensibility:
 handleEnumExtensibilityAttr(S, D, AL);
 break;
-  case ParsedAttr::AT_Flatten:
-handleSimpleAttribute(S, D, AL);
-break;
   case ParsedAttr::AT_SYCLKernel:
 handleSYCLKernelAttr(S, D, AL);
 break;
@@ -6901,27 +6883,9 @@
   case ParsedAttr::AT_Restrict:
 handleRestrictAttr(S, D, AL);
 break;
-  case ParsedAttr::AT_LifetimeBound:
-handleSimpleAttribute(S, D, AL);
-break;
-  case ParsedAttr::AT_MayAlias:
-handleSimpleAttribute(S, D, AL);
-break;
   case ParsedAttr::AT_Mode:
 handleModeAttr(S, D, AL);
 break;
-  case ParsedAttr::AT_NoAlias:
-handleSimpleAttribute(S, D, AL);
-break;
-  case ParsedAttr::AT_NoCommon:
-handleSimpleAttribute(S, D, AL);
-break;
-  case ParsedAttr::AT_NoSplitStac

[PATCH] D31343: Add an attribute plugin example

2020-01-21 Thread John Brawn via Phabricator via cfe-commits
john.brawn updated this revision to Diff 239307.
john.brawn added reviewers: erichkeane, aaron.ballman, rjmccall.
john.brawn set the repository for this revision to rG LLVM Github Monorepo.
john.brawn added a subscriber: cfe-commits.
john.brawn added a comment.
Herald added a project: clang.

Resurrecting this old patch. This is the fourth of four patches to make it 
possible for clang plugins to define attributes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D31343

Files:
  clang/examples/Attribute/Attribute.cpp
  clang/examples/Attribute/CMakeLists.txt
  clang/examples/CMakeLists.txt
  clang/test/CMakeLists.txt
  clang/test/Frontend/plugin-attribute.cpp

Index: clang/test/Frontend/plugin-attribute.cpp
===
--- /dev/null
+++ clang/test/Frontend/plugin-attribute.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang -fplugin=%llvmshlibdir/Attribute%pluginext -emit-llvm -S %s -o - | FileCheck %s --check-prefix=ATTRIBUTE
+// RUN: not %clang -fplugin=%llvmshlibdir/Attribute%pluginext -emit-llvm -DBAD_ATTRIBUTE -S %s -o - 2>&1 | FileCheck %s --check-prefix=BADATTRIBUTE
+// REQUIRES: plugins, examples
+
+// ATTRIBUTE: [[STR1_VAR:@.+]] = private unnamed_addr constant [10 x i8] c"example()\00"
+// ATTRIBUTE: [[STR2_VAR:@.+]] = private unnamed_addr constant [20 x i8] c"example(somestring)\00"
+// ATTRIBUTE: [[STR3_VAR:@.+]] = private unnamed_addr constant [21 x i8] c"example(otherstring)\00"
+// ATTRIBUTE: @llvm.global.annotations = {{.*}}@{{.*}}fn1a{{.*}}[[STR1_VAR]]{{.*}}@{{.*}}fn1b{{.*}}[[STR1_VAR]]{{.*}}@{{.*}}fn2{{.*}}[[STR2_VAR]]{{.*}}@{{.*}}var1{{.*}}[[STR3_VAR]]
+void fn1a() __attribute__((example)) { }
+[[example]] void fn1b() { }
+void fn2() __attribute__((example("somestring"))) { }
+int var1 __attribute__((example("otherstring"))) = 1;
+
+#ifdef BAD_ATTRIBUTE
+void fn3() {
+  // BADATTRIBUTE: error: 'example' attribute only allowed at file scop
+  int var2 __attribute__((example));
+}
+// BADATTRIBUTE: error: 'example' attribute requires a string
+void fn4() __attribute__((example(123))) { }
+// BADATTRIBUTE: error: 'example' attribute takes no more than 1 argument
+void fn5() __attribute__((example("a","b"))) { }
+#endif
Index: clang/test/CMakeLists.txt
===
--- clang/test/CMakeLists.txt
+++ clang/test/CMakeLists.txt
@@ -72,6 +72,7 @@
 
 if (CLANG_BUILD_EXAMPLES)
   list(APPEND CLANG_TEST_DEPS
+Attribute
 AnnotateFunctions
 clang-interpreter
 PrintFunctionNames
Index: clang/examples/CMakeLists.txt
===
--- clang/examples/CMakeLists.txt
+++ clang/examples/CMakeLists.txt
@@ -6,3 +6,4 @@
 add_subdirectory(clang-interpreter)
 add_subdirectory(PrintFunctionNames)
 add_subdirectory(AnnotateFunctions)
+add_subdirectory(Attribute)
Index: clang/examples/Attribute/CMakeLists.txt
===
--- /dev/null
+++ clang/examples/Attribute/CMakeLists.txt
@@ -0,0 +1,11 @@
+add_llvm_library(Attribute MODULE Attribute.cpp PLUGIN_TOOL clang)
+
+if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
+  target_link_libraries(AnnotateFunctions ${cmake_2_8_12_PRIVATE}
+clangAST
+clangBasic
+clangFrontend
+clangLex
+LLVMSupport
+)
+endif()
Index: clang/examples/Attribute/Attribute.cpp
===
--- /dev/null
+++ clang/examples/Attribute/Attribute.cpp
@@ -0,0 +1,66 @@
+//===- Attribute.cpp --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// Example clang plugin which adds an an annotation to file-scope declarations
+// with the 'example' attribute.
+//
+//===--===//
+
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Attr.h"
+#include "clang/Sema/ParsedAttr.h"
+#include "clang/Sema/Sema.h"
+#include "clang/Sema/SemaDiagnostic.h"
+#include "llvm/IR/Attributes.h"
+using namespace clang;
+
+namespace {
+
+struct ExampleAttrInfo : public ParsedAttrInfo {
+  ExampleAttrInfo() {
+// Set the kind to NoSemaHandlerAttribute to make sure clang doesn't assume
+// anything about what it does.
+AttrKind = ParsedAttr::NoSemaHandlerAttribute;
+// Can take an optional string argument.
+OptArgs = 1;
+// GNU-style __attribute__(("example")) and C++-style [[example]] supported.
+Spellings.push_back({ParsedAttr::AS_GNU, "example"});
+Spellings.push_back({ParsedAttr::AS_CXX11, "::example"});
+  }
+  virtual bool handleDeclAttribute(Sema &S, Dec

[PATCH] D73102: [clangd] Handle the missing injectedClassNameType in targetDecl.

2020-01-21 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added subscribers: usaxena95, kadircet, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73102

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
@@ -286,6 +286,14 @@
   )cpp";
   // FIXME: We don't do a good job printing TemplateTypeParmDecls, apparently!
   EXPECT_DECLS("SizeOfPackExpr", "");
+
+  Code = R"cpp(
+template 
+class Foo {
+  void f([[Foo]] x);
+};
+  )cpp";
+  EXPECT_DECLS("InjectedClassNameTypeLoc", "class Foo");
 }
 
 TEST_F(TargetDeclTest, ClassTemplate) {
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -374,6 +374,11 @@
   void VisitTagType(const TagType *TT) {
 Outer.add(TT->getAsTagDecl(), Flags);
   }
+
+  void VisitInjectedClassNameType(const InjectedClassNameType *ICNT) {
+Outer.add(ICNT->getDecl(), Flags);
+  }
+
   void VisitDecltypeType(const DecltypeType *DTT) {
 Outer.add(DTT->getUnderlyingType(), Flags | Rel::Underlying);
   }


Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -286,6 +286,14 @@
   )cpp";
   // FIXME: We don't do a good job printing TemplateTypeParmDecls, apparently!
   EXPECT_DECLS("SizeOfPackExpr", "");
+
+  Code = R"cpp(
+template 
+class Foo {
+  void f([[Foo]] x);
+};
+  )cpp";
+  EXPECT_DECLS("InjectedClassNameTypeLoc", "class Foo");
 }
 
 TEST_F(TargetDeclTest, ClassTemplate) {
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -374,6 +374,11 @@
   void VisitTagType(const TagType *TT) {
 Outer.add(TT->getAsTagDecl(), Flags);
   }
+
+  void VisitInjectedClassNameType(const InjectedClassNameType *ICNT) {
+Outer.add(ICNT->getDecl(), Flags);
+  }
+
   void VisitDecltypeType(const DecltypeType *DTT) {
 Outer.add(DTT->getUnderlyingType(), Flags | Rel::Underlying);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73025: [AArch64][SVE] Add first-faulting load intrinsic

2020-01-21 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin updated this revision to Diff 239303.
kmclaughlin added a comment.

- Rebased patch after changes made to parent revision


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

https://reviews.llvm.org/D73025

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.h
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve-intrinsics-loads-ff.ll

Index: llvm/test/CodeGen/AArch64/sve-intrinsics-loads-ff.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve-intrinsics-loads-ff.ll
@@ -0,0 +1,220 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s
+
+;
+; LDFF1B
+;
+
+define  @ldff1b( %pg, i8* %a) {
+; CHECK-LABEL: ldff1b:
+; CHECK: ldff1b { z0.b }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldff1.nxv16i8( %pg, i8* %a)
+  ret  %load
+}
+
+define  @ldff1b_h( %pg, i8* %a) {
+; CHECK-LABEL: ldff1b_h:
+; CHECK: ldff1b { z0.h }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldff1.nxv8i8( %pg, i8* %a)
+  %res = zext  %load to 
+  ret  %res
+}
+
+define  @ldff1b_s( %pg, i8* %a) {
+; CHECK-LABEL: ldff1b_s:
+; CHECK: ldff1b { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldff1.nxv4i8( %pg, i8* %a)
+  %res = zext  %load to 
+  ret  %res
+}
+
+define  @ldff1b_d( %pg, i8* %a) {
+; CHECK-LABEL: ldff1b_d:
+; CHECK: ldff1b { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldff1.nxv2i8( %pg, i8* %a)
+  %res = zext  %load to 
+  ret  %res
+}
+
+;
+; LDFF1SB
+;
+
+define  @ldff1sb_h( %pg, i8* %a) {
+; CHECK-LABEL: ldff1sb_h:
+; CHECK: ldff1sb { z0.h }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldff1.nxv8i8( %pg, i8* %a)
+  %res = sext  %load to 
+  ret  %res
+}
+
+define  @ldff1sb_s( %pg, i8* %a) {
+; CHECK-LABEL: ldff1sb_s:
+; CHECK: ldff1sb { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldff1.nxv4i8( %pg, i8* %a)
+  %res = sext  %load to 
+  ret  %res
+}
+
+define  @ldff1sb_d( %pg, i8* %a) {
+; CHECK-LABEL: ldff1sb_d:
+; CHECK: ldff1sb { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldff1.nxv2i8( %pg, i8* %a)
+  %res = sext  %load to 
+  ret  %res
+}
+
+;
+; LDFF1H
+;
+
+define  @ldff1h( %pg, i16* %a) {
+; CHECK-LABEL: ldff1h:
+; CHECK: ldff1h { z0.h }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldff1.nxv8i16( %pg, i16* %a)
+  ret  %load
+}
+
+define  @ldff1h_s( %pg, i16* %a) {
+; CHECK-LABEL: ldff1h_s:
+; CHECK: ldff1h { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldff1.nxv4i16( %pg, i16* %a)
+  %res = zext  %load to 
+  ret  %res
+}
+
+define  @ldff1h_d( %pg, i16* %a) {
+; CHECK-LABEL: ldff1h_d:
+; CHECK: ldff1h { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldff1.nxv2i16( %pg, i16* %a)
+  %res = zext  %load to 
+  ret  %res
+}
+
+define  @ldff1h_f16( %pg, half* %a) {
+; CHECK-LABEL: ldff1h_f16:
+; CHECK: ldff1h { z0.h }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldff1.nxv8f16( %pg, half* %a)
+  ret  %load
+}
+
+;
+; LDFF1SH
+;
+
+define  @ldff1sh_s( %pg, i16* %a) {
+; CHECK-LABEL: ldff1sh_s:
+; CHECK: ldff1sh { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldff1.nxv4i16( %pg, i16* %a)
+  %res = sext  %load to 
+  ret  %res
+}
+
+define  @ldff1sh_d( %pg, i16* %a) {
+; CHECK-LABEL: ldff1sh_d:
+; CHECK: ldff1sh { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldff1.nxv2i16( %pg, i16* %a)
+  %res = sext  %load to 
+  ret  %res
+}
+
+;
+; LDFF1W
+;
+
+define  @ldff1w( %pg, i32* %a) {
+; CHECK-LABEL: ldff1w:
+; CHECK: ldff1w { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldff1.nxv4i32( %pg, i32* %a)
+  ret  %load
+}
+
+define  @ldff1w_d( %pg, i32* %a) {
+; CHECK-LABEL: ldff1w_d:
+; CHECK: ldff1w { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldff1.nxv2i32( %pg, i32* %a)
+  %res = zext  %load to 
+  ret  %res
+}
+
+define  @ldff1w_f32( %pg, float* %a) {
+; CHECK-LABEL: ldff1w_f32:
+; CHECK: ldff1w { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldff1.nxv4f32( %pg, float* %a)
+  ret  %load
+}
+
+define  @ldff1w_2f32( %pg, float* %a) {
+; CHECK-LABEL: ldff1w_2f32:
+; CHECK: ldff1w { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldff1.nxv2f32( %pg, float* %a)
+  ret  %load
+}
+
+;
+; LDFF1SW
+;
+
+define  @ldff1sw_d( %pg, i32* %a) {
+; CHECK-LABEL: ldff1sw_d:
+; CHECK: ldff1sw { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldff1.nxv2i32( %pg, i32* %a)
+  %res = sext  %load to 
+  ret  %res
+}
+
+;
+; LDFF1D
+;
+
+define  @ldff1d( %pg, i64* %a) {
+; CHECK-LABEL: ldff

[PATCH] D72705: [clang][checkers] Added new checker 'alpha.unix.ErrorReturn'.

2020-01-21 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

Hello,

This checker is an alternative approach to our not yet published 
statistics-based checkers in a way: 2019 EuroLLVM Developers’ Meeting: A. 
Balogh “Statistics Based Checkers in the Clang Static Analyzer” 


There are two main differences: The first is that in the statistics-based 
Special Return Value checker we read the function names from a `YAML` file. 
There is no other way because the data was previously dynamically collected, 
but we can also add a static part to it which contains the functions hard-wired 
in your checker. I think that is a better approach.

The other, even more important difference is that in the Special Return Value 
checker we do not check explicitly whether the return value was compared to 
NULL pointer but we fork a new execution path where it is a `NULL` pointer and 
expect other checkers to report a bug on this path. I wonder which approach is 
the better one: Your approach also finds cases which our checkers can not, e.g. 
there is not enough memory for `malloc()`. However it also finds more false 
positives where the return value was left intentionally unchecked because in 
that particular case no error can happen.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72705



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


[PATCH] D73101: [clangd] Do not duplicate TemplatedDecls in findExplicitReferences

2020-01-21 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/FindTarget.cpp:584
+void VisitRedeclarableTemplateDecl(const RedeclarableTemplateDecl *TD) {
+  // {Class,Function,Var,TypeAlias}TemplateDecls are visited as part of the
+  // NamedDecl below, we skip them here to not visit them twice.

the code this is correct right now (since 
{Class,Function,Var,TypeAlias}TemplateDecls  are the decls that derive from 
`RedeclarableTemplateDecl`), but I would do this in another way -- just add a 
filter in the VisitNamedDecl below, like


```
void VisitNamedDecl(const NamedDecl *ND) {
   ...
   if (ND is one of the  {Class,Function,Var,TypeAlias}TemplateDecls)
 return;
}
```



Comment at: clang-tools-extra/clangd/unittests/FindTargetTests.cpp:744
 "1: targets = {foo::Bar}, decl\n"
-"2: targets = {foo::Bar}, decl\n"
-"3: targets = {foo::Bar}\n"

nit: the diff seems not to be the one I have submitted, there should be a FIXME 
here which should be removed in this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73101



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


[PATCH] D73101: [clangd] Do not duplicate TemplatedDecls in findExplicitReferences

2020-01-21 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 239310.
kadircet added a comment.

- Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73101

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
@@ -733,21 +733,17 @@
{R"cpp(
 namespace foo {
   template 
-  class $1^$2^Bar {
-~$3^Bar();
-void $4^f($5^Bar);
+  class $1^Bar {
+~$2^Bar();
+void $3^f($4^Bar);
   };
 }
   )cpp",
 "0: targets = {foo::Bar::T}, decl\n"
-// FIXME: avoid the 2 duplicated foo::Bar references below, the first
-// one comes from ClassTemplateDecl; the second comes from the
-// underlying CXXRecordDecl.
 "1: targets = {foo::Bar}, decl\n"
-"2: targets = {foo::Bar}, decl\n"
-"3: targets = {foo::Bar}\n"
-"4: targets = {foo::Bar::f}, decl\n"
-"5: targets = {foo::Bar}\n"},
+"2: targets = {foo::Bar}\n"
+"3: targets = {foo::Bar::f}, decl\n"
+"4: targets = {foo::Bar}\n"},
// MemberExpr should know their using declaration.
{R"cpp(
 struct X { void func(int); };
@@ -1047,7 +1043,47 @@
   }
 )cpp",
"0: targets = {Test}\n"
-   "1: targets = {a}, decl\n"}};
+   "1: targets = {a}, decl\n"},
+   // Templates
+   {R"cpp(
+namespace foo {
+  template 
+  class $1^Bar {};
+}
+  )cpp",
+"0: targets = {foo::Bar::T}, decl\n"
+"1: targets = {foo::Bar}, decl\n"},
+   // Templates
+   {R"cpp(
+namespace foo {
+  template 
+  void $1^func();
+}
+  )cpp",
+"0: targets = {T}, decl\n"
+"1: targets = {foo::func}, decl\n"},
+   // Templates
+   {R"cpp(
+namespace foo {
+  template 
+  $1^T $2^x;
+}
+  )cpp",
+"0: targets = {foo::T}, decl\n"
+"1: targets = {foo::T}\n"
+"2: targets = {foo::x}, decl\n"},
+   // Templates
+   {R"cpp(
+template class vector {};
+namespace foo {
+  template 
+  using $1^V = $2^vector<$3^T>;
+}
+  )cpp",
+"0: targets = {foo::T}, decl\n"
+"1: targets = {foo::V}, decl\n"
+"2: targets = {vector}\n"
+"3: targets = {foo::T}\n"}};
 
   for (const auto &C : Cases) {
 llvm::StringRef ExpectedCode = C.first;
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -580,6 +580,11 @@
   {D->getAliasedNamespace()}});
 }
 
+void VisitRedeclarableTemplateDecl(const RedeclarableTemplateDecl *TD) {
+  // {Class,Function,Var,TypeAlias}TemplateDecls are visited as part of the
+  // NamedDecl below, we skip them here to not visit them twice.
+}
+
 void VisitNamedDecl(const NamedDecl *ND) {
   // FIXME: decide on how to surface destructors when we need them.
   if (llvm::isa(ND))


Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -733,21 +733,17 @@
{R"cpp(
 namespace foo {
   template 
-  class $1^$2^Bar {
-~$3^Bar();
-void $4^f($5^Bar);
+  class $1^Bar {
+~$2^Bar();
+void $3^f($4^Bar);
   };
 }
   )cpp",
 "0: targets = {foo::Bar::T}, decl\n"
-// FIXME: avoid the 2 duplicated foo::Bar references below, the first
-// one comes from ClassTemplateDecl; the second comes from the
-// underlying CXXRecordDecl.
 "1: targets = {foo::Bar}, decl\n"
-"2: targets = {foo::Bar}, decl\n"
-"3: targets = {foo::Bar}\n"
-"4: targets = {foo::Bar::f}, decl\n"
-"5: targets = {foo::Bar}\n"},
+"2: targets = {foo::Bar}\n"
+"3: targets = {foo::Bar::f}, decl\n"
+"4: targets = {foo::Bar}\n"},
// MemberExpr should know their using declaration.
{R"cpp(
 struct X { void func(int); };
@@ -1047,7 +1043,47 @@
   }
 )cpp",
"0: ta

[PATCH] D73102: [clangd] Handle the missing injectedClassNameType in targetDecl.

2020-01-21 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62057 tests passed, 0 failed 
and 784 were skipped.

{icon question-circle color=gray} clang-tidy: unknown.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73102



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


[PATCH] D73104: [Attr][Doc][NFC] Fix code snippet formatting for attribute documentation

2020-01-21 Thread Alexey Bader via Phabricator via cfe-commits
bader created this revision.
bader added reviewers: aaron.ballman, Fznamznon.
Herald added subscribers: cfe-commits, ebevhan.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73104

Files:
  clang/include/clang/Basic/AttrDocs.td


Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -260,6 +260,7 @@
 to outline device code and to generate an OpenCL kernel.
 Here is a code example of the SYCL program, which demonstrates the compiler's
 outlining job:
+
 .. code-block:: c++
 
   int foo(int x) { return ++x; }
@@ -282,27 +283,29 @@
 specification Section 6.4.
 To show to the compiler entry point to the "device part" of the code, the SYCL
 runtime can use the ``sycl_kernel`` attribute in the following way:
+
 .. code-block:: c++
-namespace cl {
-namespace sycl {
-class handler {
-  template 
-  __attribute__((sycl_kernel)) void sycl_kernel_function(KernelType 
KernelFuncObj) {
-// ...
-KernelFuncObj();
-  }
 
-  template 
-  void parallel_for(range NumWorkItems, KernelType KernelFunc) {
-#ifdef __SYCL_DEVICE_ONLY__
-sycl_kernel_function(KernelFunc);
-#else
-// Host implementation
-#endif
-  }
-};
-} // namespace sycl
-} // namespace cl
+  namespace cl {
+  namespace sycl {
+  class handler {
+template 
+__attribute__((sycl_kernel)) void sycl_kernel_function(KernelType 
KernelFuncObj) {
+  // ...
+  KernelFuncObj();
+}
+
+template 
+void parallel_for(range NumWorkItems, KernelType KernelFunc) {
+  #ifdef __SYCL_DEVICE_ONLY__
+  sycl_kernel_function(KernelFunc);
+  #else
+  // Host implementation
+  #endif
+}
+  };
+  } // namespace sycl
+  } // namespace cl
 
 The compiler will also generate an OpenCL kernel using the function marked with
 the ``sycl_kernel`` attribute.


Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -260,6 +260,7 @@
 to outline device code and to generate an OpenCL kernel.
 Here is a code example of the SYCL program, which demonstrates the compiler's
 outlining job:
+
 .. code-block:: c++
 
   int foo(int x) { return ++x; }
@@ -282,27 +283,29 @@
 specification Section 6.4.
 To show to the compiler entry point to the "device part" of the code, the SYCL
 runtime can use the ``sycl_kernel`` attribute in the following way:
+
 .. code-block:: c++
-namespace cl {
-namespace sycl {
-class handler {
-  template 
-  __attribute__((sycl_kernel)) void sycl_kernel_function(KernelType KernelFuncObj) {
-// ...
-KernelFuncObj();
-  }
 
-  template 
-  void parallel_for(range NumWorkItems, KernelType KernelFunc) {
-#ifdef __SYCL_DEVICE_ONLY__
-sycl_kernel_function(KernelFunc);
-#else
-// Host implementation
-#endif
-  }
-};
-} // namespace sycl
-} // namespace cl
+  namespace cl {
+  namespace sycl {
+  class handler {
+template 
+__attribute__((sycl_kernel)) void sycl_kernel_function(KernelType KernelFuncObj) {
+  // ...
+  KernelFuncObj();
+}
+
+template 
+void parallel_for(range NumWorkItems, KernelType KernelFunc) {
+  #ifdef __SYCL_DEVICE_ONLY__
+  sycl_kernel_function(KernelFunc);
+  #else
+  // Host implementation
+  #endif
+}
+  };
+  } // namespace sycl
+  } // namespace cl
 
 The compiler will also generate an OpenCL kernel using the function marked with
 the ``sycl_kernel`` attribute.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71913: [LTO/WPD] Enable aggressive WPD under LTO option

2020-01-21 Thread Eugene Leviant via Phabricator via cfe-commits
evgeny777 added inline comments.



Comment at: clang/test/CodeGenCXX/lto-visibility-inference.cpp:73
   c1->f();
-  // ITANIUM-NOT: type.test{{.*}}!"_ZTS2C2"
+  // ITANIUM: type.test{{.*}}!"_ZTS2C2"
   // MS: type.test{{.*}}!"?AUC2@@"

tejohnson wrote:
> evgeny777 wrote:
> > What caused this and other changes in this file?
> Because we now will insert type tests for non-hidden vtables. This is enabled 
> by the changes to LTO to interpret these based on the vcall_visibility 
> metadata.
The results of this test case
```
%clang_cc1 -flto -triple x86_64-pc-windows-msvc -std=c++11 -fms-extensions 
-fwhole-program-vtables -flto-visibility-public-std -emit-llvm -o - %s | 
FileCheck --check-prefix=MS --check-prefix=MS-NOSTD %s
```
look not correct to me. I think you shouldn't generate type tests for standard 
library classes with  `-flto-visibility-public-std`. Currently if this flag is 
given, clang doesn't do this either even with `-fvisibility=hidden`



Comment at: clang/test/CodeGenCXX/thinlto-distributed-type-metadata.cpp:7
+// as expected.
+// RUN: %clang_cc1 -flto=thin -flto-unit -triple x86_64-unknown-linux 
-fvisibility hidden -fwhole-program-vtables -emit-llvm-bc -o %t.o %s
+// RUN: llvm-dis %t.o -o - | FileCheck --check-prefix=TT %s

I think, we no longer need `-fvisibility hidden` here, do we?



Comment at: llvm/lib/LTO/ThinLTOCodeGenerator.cpp:976
+  // via the internal option. Must be done before WPD below.
+  updateVCallVisibilityInIndex(*Index);
+

evgeny777 wrote:
> ditto
updateVCallVisibilityInIndex(*Index, /* WholeProgramVisibilityEnabledInLTO */ 
false) ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71913



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


[PATCH] D73101: [clangd] Do not duplicate TemplatedDecls in findExplicitReferences

2020-01-21 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet marked 3 inline comments as done.
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/FindTarget.cpp:584
+void VisitRedeclarableTemplateDecl(const RedeclarableTemplateDecl *TD) {
+  // {Class,Function,Var,TypeAlias}TemplateDecls are visited as part of the
+  // NamedDecl below, we skip them here to not visit them twice.

hokein wrote:
> the code this is correct right now (since 
> {Class,Function,Var,TypeAlias}TemplateDecls  are the decls that derive from 
> `RedeclarableTemplateDecl`), but I would do this in another way -- just add a 
> filter in the VisitNamedDecl below, like
> 
> 
> ```
> void VisitNamedDecl(const NamedDecl *ND) {
>...
>if (ND is one of the  {Class,Function,Var,TypeAlias}TemplateDecls)
>  return;
> }
> ```
these two have a slightly different behaviour though, I deliberately chose to 
stop this in here.

Eliminating here results in dropping template decl, the one containing template 
parameters.
Whereas eliminating inside `VisitNamedDecl`, would result in dropping the 
described template, the real definition coming after template parameters.

It is always possible to switch between the two using 
`get{TemplatedDecl,DescribedTemplate}` but I think eliminating the templatedecl 
aligns better with
current api, since at the specified position we actually have the 
`DescribedTemplate`, not the `TemplatedDecl` and template parameters are 
already being
reported independent from this.



Comment at: clang-tools-extra/clangd/unittests/FindTargetTests.cpp:744
 "1: targets = {foo::Bar}, decl\n"
-"2: targets = {foo::Bar}, decl\n"
-"3: targets = {foo::Bar}\n"

hokein wrote:
> nit: the diff seems not to be the one I have submitted, there should be a 
> FIXME here which should be removed in this patch.
yeah it wasn't rebased


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73101



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


[PATCH] D73062: [analyzer] Simplify BoolAssignmentChecker

2020-01-21 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Thanks!!! Small patches are so nice to review.




Comment at: clang/lib/StaticAnalyzer/Checkers/BoolAssignmentChecker.cpp:91
 
-  if (!greaterThanEqualToZero) {
-// The SValBuilder cannot construct a valid SVal for this condition.
-// This means we cannot properly reason about it.
-return;
-  }
-
-  ProgramStateRef stateLT, stateGE;
-  std::tie(stateGE, stateLT) = CM.assumeDual(state, *greaterThanEqualToZero);
-
-  // Is it possible for the value to be less than zero?
-  if (stateLT) {
-// It is possible for the value to be less than zero.  We only
-// want to emit a warning, however, if that value is fully constrained.
-// If it it possible for the value to be >= 0, then essentially the
-// value is underconstrained and there is nothing left to be done.
-if (!stateGE)
-  emitReport(stateLT, C);
-
-// In either case, we are done.
-return;
-  }
-
-  // If we reach here, it must be the case that the value is constrained
-  // to only be >= 0.
-  assert(stateGE == state);
-
-  // At this point we know that the value is >= 0.
-  // Now check to ensure that the value is <= 1.
-  DefinedSVal OneVal = svalBuilder.makeIntVal(1, valTy);
-  SVal lessThanEqToOneVal =
-svalBuilder.evalBinOp(state, BO_LE, *DV, OneVal,
-  svalBuilder.getConditionType());
-
-  Optional lessThanEqToOne =
-  lessThanEqToOneVal.getAs();
-
-  if (!lessThanEqToOne) {
-// The SValBuilder cannot construct a valid SVal for this condition.
-// This means we cannot properly reason about it.
-return;
-  }
-
-  ProgramStateRef stateGT, stateLE;
-  std::tie(stateLE, stateGT) = CM.assumeDual(state, *lessThanEqToOne);
-
-  // Is it possible for the value to be greater than one?
-  if (stateGT) {
-// It is possible for the value to be greater than one.  We only
-// want to emit a warning, however, if that value is fully constrained.
-// If it is possible for the value to be <= 1, then essentially the
-// value is underconstrained and there is nothing left to be done.
-if (!stateLE)
-  emitReport(stateGT, C);
-
-// In either case, we are done.
-return;
-  }
-
-  // If we reach here, it must be the case that the value is constrained
-  // to only be <= 1.
-  assert(stateLE == state);
+  if (StOut)
+emitReport(StOut, C);

I believe this should be `!StIn`. I.e., the right check to do is "the value is 
known to be not boolean" (this is definitely a buggy execution path the static 
analyzer managed to discover), whereas "the value is not known to be definitely 
boolean" is the wrong check to do (the static analyzer doesn't have enough 
information to conclude that the value is definitely boolean, which might be 
because the value may be non-boolean, but it's more likely that this happens 
because the static analyzer simply doesn't know enough about the program).

I think this change should fix the regressions on the test suite.


Repository:
  rC Clang

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

https://reviews.llvm.org/D73062



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


[PATCH] D71612: [analyzer] Add PlacementNewChecker

2020-01-21 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

🎉🎉🎉


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71612



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


[PATCH] D28955: [analyzer] Enable support for symbolic extension/truncation

2020-01-21 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Thanks for picking this up!~

Hmm, why did the change in `MallocChecker` tests disappear?

> clang is trying to match some strings printed by the ranged constraint manager

Are these state dump tests / `exploded-graph-rewriter` tests? We'll need to 
ignore/silence them in Z3 mode.


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

https://reviews.llvm.org/D28955



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


[PATCH] D73101: [clangd] Do not duplicate TemplatedDecls in findExplicitReferences

2020-01-21 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet marked 2 inline comments as done.
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/FindTarget.cpp:584
+void VisitRedeclarableTemplateDecl(const RedeclarableTemplateDecl *TD) {
+  // {Class,Function,Var,TypeAlias}TemplateDecls are visited as part of the
+  // NamedDecl below, we skip them here to not visit them twice.

kadircet wrote:
> hokein wrote:
> > the code this is correct right now (since 
> > {Class,Function,Var,TypeAlias}TemplateDecls  are the decls that derive from 
> > `RedeclarableTemplateDecl`), but I would do this in another way -- just add 
> > a filter in the VisitNamedDecl below, like
> > 
> > 
> > ```
> > void VisitNamedDecl(const NamedDecl *ND) {
> >...
> >if (ND is one of the  {Class,Function,Var,TypeAlias}TemplateDecls)
> >  return;
> > }
> > ```
> these two have a slightly different behaviour though, I deliberately chose to 
> stop this in here.
> 
> Eliminating here results in dropping template decl, the one containing 
> template parameters.
> Whereas eliminating inside `VisitNamedDecl`, would result in dropping the 
> described template, the real definition coming after template parameters.
> 
> It is always possible to switch between the two using 
> `get{TemplatedDecl,DescribedTemplate}` but I think eliminating the 
> templatedecl aligns better with
> current api, since at the specified position we actually have the 
> `DescribedTemplate`, not the `TemplatedDecl` and template parameters are 
> already being
> reported independent from this.
yeah actually re-thinking about it they will have the same affect since we can 
check for specific types, nvm this comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73101



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


[PATCH] D31337: Use virtual functions in ParsedAttrInfo instead of function pointers

2020-01-21 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/Sema/ParsedAttr.cpp:143
+  // otherwise return a default ParsedAttrInfo.
+  const ParsedAttrInfo *Info = AttrInfoMap[A.getKind()];
+  if (Info)

I don't think you can do this.  The only way to get Info as nullptr is to end 
up off the end of the array, which is UB.

Instead of the map lookup, this should check A.getKind against the range.



Comment at: clang/lib/Sema/ParsedAttr.cpp:146
+return *Info;
+  return DefaultParsedAttrInfo;
 }

Currently the behavior of this is to make an invalid attribute kind be UB.  
Presumably the point here is to make it so that is no longer the case?



Comment at: clang/utils/TableGen/ClangAttrEmitter.cpp:3400
 
-static std::string GenerateAppertainsTo(const Record &Attr, raw_ostream &OS) {
+static void GenerateAppertainsTo(const Record &Attr, raw_ostream &SS,
+ raw_ostream &OS) {

Why does this take SS AND OS.  What is the difference here?  Does this actually 
use OS anymore?



Comment at: clang/utils/TableGen/ClangAttrEmitter.cpp:3637
+SS << "ParsedAttrInfo" << I->first;
+SS << " parsedAttrInfo" << I->first << "Instance;\n\n";
   }

Should the instance be static? Perhaps a static variable in the class itself?  



Comment at: clang/utils/TableGen/ClangAttrEmitter.cpp:3641
 
-  OS << "static const ParsedAttrInfo AttrInfoMap[ParsedAttr::UnknownAttribute "
+  OS << "static const ParsedAttrInfo *AttrInfoMap[ParsedAttr::UnknownAttribute 
"
 "+ 1] = {\n";

Is there a good reason this doesn't return references?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D31337



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


[PATCH] D73106: [Alignment][NFC] Use Align with CreateMaskedStore

2020-01-21 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet created this revision.
gchatelet added a reviewer: courbet.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya.
Herald added projects: clang, LLVM.

This is patch is part of a series to introduce an Alignment type.
See this thread for context: 
http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73106

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  llvm/include/llvm/IR/IRBuilder.h
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/IR/IRBuilder.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
===
--- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -2343,7 +2343,7 @@
   Value *ShuffledMask = Builder.CreateShuffleVector(
   BlockInMaskPart, Undefs, RepMask, "interleaved.mask");
   NewStoreInstr = Builder.CreateMaskedStore(
-  IVec, AddrParts[Part], Group->getAlignment(), ShuffledMask);
+  IVec, AddrParts[Part], Group->getAlign(), ShuffledMask);
 }
 else
   NewStoreInstr = Builder.CreateAlignedStore(IVec, AddrParts[Part],
@@ -2449,8 +2449,8 @@
 }
 auto *VecPtr = CreateVecPtr(Part, State.get(Addr, {0, 0}));
 if (isMaskRequired)
-  NewSI = Builder.CreateMaskedStore(
-  StoredVal, VecPtr, Alignment.value(), BlockInMaskParts[Part]);
+  NewSI = Builder.CreateMaskedStore(StoredVal, VecPtr, Alignment,
+BlockInMaskParts[Part]);
 else
   NewSI =
   Builder.CreateAlignedStore(StoredVal, VecPtr, Alignment.value());
Index: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -2904,7 +2904,7 @@
 IRBuilder<> IRB(&I);
 Value *V = I.getArgOperand(0);
 Value *Addr = I.getArgOperand(1);
-const MaybeAlign Alignment(
+const Align Alignment(
 cast(I.getArgOperand(2))->getZExtValue());
 Value *Mask = I.getArgOperand(3);
 Value *Shadow = getShadow(V);
@@ -2921,21 +2921,20 @@
   insertShadowCheck(Mask, &I);
 }
 
-IRB.CreateMaskedStore(Shadow, ShadowPtr, Alignment ? Alignment->value() : 0,
-  Mask);
+IRB.CreateMaskedStore(Shadow, ShadowPtr, Alignment, Mask);
 
 if (MS.TrackOrigins) {
   auto &DL = F.getParent()->getDataLayout();
   paintOrigin(IRB, getOrigin(V), OriginPtr,
   DL.getTypeStoreSize(Shadow->getType()),
-  llvm::max(Alignment, kMinOriginAlignment));
+  std::max(Alignment, kMinOriginAlignment));
 }
   }
 
   bool handleMaskedLoad(IntrinsicInst &I) {
 IRBuilder<> IRB(&I);
 Value *Addr = I.getArgOperand(0);
-const MaybeAlign Alignment(
+const Align Alignment(
 cast(I.getArgOperand(1))->getZExtValue());
 Value *Mask = I.getArgOperand(2);
 Value *PassThru = I.getArgOperand(3);
@@ -2945,7 +2944,7 @@
 if (PropagateShadow) {
   std::tie(ShadowPtr, OriginPtr) =
   getShadowOriginPtr(Addr, IRB, ShadowTy, Alignment, /*isStore*/ false);
-  setShadow(&I, IRB.CreateMaskedLoad(ShadowPtr, *Alignment, Mask,
+  setShadow(&I, IRB.CreateMaskedLoad(ShadowPtr, Alignment, Mask,
  getShadow(PassThru), "_msmaskedld"));
 } else {
   setShadow(&I, getCleanShadow(&I));
Index: llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
===
--- llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -1372,7 +1372,7 @@
   // on each element's most significant bit (the sign bit).
   Constant *BoolMask = getNegativeIsTrueBoolVec(ConstMask);
 
-  IC.Builder.CreateMaskedStore(Vec, PtrCast, 1, BoolMask);
+  IC.Builder.CreateMaskedStore(Vec, PtrCast, Align::None(), BoolMask);
 
   // 'Replace uses' doesn't work for stores. Erase the original masked store.
   IC.eraseInstFromFunction(II);
Index: llvm/lib/IR/IRBuilder.cpp
===
--- llvm/lib/IR/IRBuilder.cpp
+++ llvm/lib/IR/IRBuilder.cpp
@@ -487,19 +487,19 @@
 }
 
 /// Create a call to a Masked Store intrinsic.
-/// \p Val   - data to be stored,
-/// \p Ptr   - base pointer for the store
-/// \p Align - alignment of the destination location
-/// \p Mask  - vector of booleans which indicates what vector lanes should
-///be accessed in memory
+/// \p Val   - data to be stored,
+//

[PATCH] D69825: [Clang][Driver] Re-use the calling process instead of creating a new process for the cc1 invocation

2020-01-21 Thread Bjorn Pettersson via Phabricator via cfe-commits
bjope added a comment.

When I build the clang on trunk, using clang 8.0 with asan enabled, and then 
run the clang lit tests I see lots of failures in Clang :: 
InterfaceStubs/driver-test.c and Clang :: InterfaceStubs/driver-test2.c (and 
maybe the faults I get in Clang :: Driver/cl-showfilenames.c comes from this 
patch as well).

The failures go away if I revert this patch (commit 
b4a99a061f517e60985667e39519f601 
). To make 
the revert I also needed to revert commit 
8e5018e990b701391e6c33ba85b012343df67272 
 which is 
based on this patch.

Examples of failures:

  ==130643==ERROR: LeakSanitizer: detected memory leaks
  
  Direct leak of 192 byte(s) in 3 object(s) allocated from:
  #0 0xd0ea38 in operator new(unsigned long) 
/workspace/llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:106
  #1 0x8153b36 in make_unique 
/proj/flexasic/app/llvm/8.0/bin/../include/c++/v1/memory:3132:28
  #2 0x8153b36 in CreateFrontendBaseAction 
/workspace//llvm-master-sanitize-asan/llvm/build-all-asan/../../clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:68
  #3 0x8153b36 in clang::CreateFrontendAction(clang::CompilerInstance&) 
/workspace//llvm-master-sanitize-asan/llvm/build-all-asan/../../clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:137
  #4 0x8156a22 in 
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) 
/workspace//llvm-master-sanitize-asan/llvm/build-all-asan/../../clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:287:39
  #5 0xd23349 in cc1_main(llvm::ArrayRef, char const*, void*) 
/workspace//llvm-master-sanitize-asan/llvm/build-all-asan/../../clang/tools/driver/cc1_main.cpp:239:15
  #6 0x7a0082e in operator() 
/workspace//llvm-master-sanitize-asan/llvm/build-all-asan/../../clang/lib/Driver/Job.cpp:402:34
  #7 0x7a0082e in void llvm::function_ref::callback_fn
 >, std::__1::basic_string, 
std::__1::allocator >*, bool*) const::$_1>(long) 
/workspace//llvm-master-sanitize-asan/llvm/build-all-asan/../include/llvm/ADT/STLExtras.h:108
  #8 0x6634feb in operator() 
/workspace//llvm-master-sanitize-asan/llvm/build-all-asan/../include/llvm/ADT/STLExtras.h:125:12
  #9 0x6634feb in 
llvm::CrashRecoveryContext::RunSafely(llvm::function_ref) 
/workspace//llvm-master-sanitize-asan/llvm/build-all-asan/../lib/Support/CrashRecoveryContext.cpp:396
  #10 0x79fefaf in 
clang::driver::CC1Command::Execute(llvm::ArrayRef
 >, std::__1::basic_string, 
std::__1::allocator >*, bool*) const 
/workspace//llvm-master-sanitize-asan/llvm/build-all-asan/../../clang/lib/Driver/Job.cpp:402:12
  #11 0x795265d in 
clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, 
clang::driver::Command const*&) const 
/workspace//llvm-master-sanitize-asan/llvm/build-all-asan/../../clang/lib/Driver/Compilation.cpp:182:15
  #12 0x7953922 in 
clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, 
llvm::SmallVectorImpl >&) 
const 
/workspace//llvm-master-sanitize-asan/llvm/build-all-asan/../../clang/lib/Driver/Compilation.cpp:233:19
  #13 0x79a4d0e in 
clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, 
llvm::SmallVectorImpl >&) 
/workspace//llvm-master-sanitize-asan/llvm/build-all-asan/../../clang/lib/Driver/Driver.cpp:1473:5
  #14 0xd19eac in main 
/workspace//llvm-master-sanitize-asan/llvm/build-all-asan/../../clang/tools/driver/driver.cpp:493:21
  #15 0x7f882be4e544 in __libc_start_main (/lib64/libc.so.6+0x22544)
  
  Direct leak of 184 byte(s) in 1 object(s) allocated from:
  #0 0xd0ea38 in operator new(unsigned long) 
/workspace/llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:106
  #1 0x81537b4 in make_unique 
/proj/flexasic/app/llvm/8.0/bin/../include/c++/v1/memory:3132:28
  #2 0x81537b4 in CreateFrontendBaseAction 
/workspace//llvm-master-sanitize-asan/llvm/build-all-asan/../../clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:52
  #3 0x81537b4 in clang::CreateFrontendAction(clang::CompilerInstance&) 
/workspace//llvm-master-sanitize-asan/llvm/build-all-asan/../../clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:137
  #4 0x8156a22 in 
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) 
/workspace//llvm-master-sanitize-asan/llvm/build-all-asan/../../clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:287:39
  #5 0xd23349 in cc1_main(llvm::ArrayRef, char const*, void*) 
/workspace//llvm-master-sanitize-asan/llvm/build-all-asan/../../clang/tools/driver/cc1_main.cpp:239:15
  #6 0x7a0082e in operator() 
/workspace//llvm-master-sanitize-asan/llvm/build-all-asan/../../clang/lib/Driver/Job.cpp:402:34
  #7 0x7a0082e in void llvm::function_ref::callback_fn
 >, std::__1::basic_string, 
std::__1::allocator >*, bool*) const::$_1>(long) 
/workspace//llvm-master-sanitize-asan/llvm/build-all-asan/../include/llvm/ADT/STLExtras.h:108

[PATCH] D73108: [docs][mips] 10.0 Release notes

2020-01-21 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan created this revision.
atanasyan added reviewers: hans, ruiu, Petar.Avramovic, mstojanovic, 
arichardson.
Herald added subscribers: jfb, sdardis.
Herald added projects: clang, LLVM.

MIPS specific part of LLVM 10.0 Release notes for LLVM, Clang and LLD.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73108

Files:
  clang/docs/ReleaseNotes.rst
  lld/docs/ReleaseNotes.rst
  llvm/docs/ReleaseNotes.rst


Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -122,8 +122,21 @@
 Changes to the MIPS Target
 --
 
- During this release ...
-
+* Improved support for ``octeon`` and added support for ``octeon+``
+  MIPS-family CPU.
+* ``min``, ``max``, ``umin``, ``umax`` atomics now supported on MIPS targets.
+* Now PC-relative relocations are generated for ``.eh_frame`` sections when
+  possible. That allows to link MIPS binaries without having to pass the
+  ``-Wl,-z,notext`` option.
+* Fix evaluating J-format branch (``j``, ``jal``, ...) targets when the
+  instruction is not in the first 256 MB region.
+* Fixed ``jal``, ``sc``, ``scs``, ``ll``, ``lld``, ``la``, ``lw``, ``sw``
+  instructions expanding. Now they accept more types of expression as 
arguments,
+  correctly handle load/store for ``XGOT`` model, expand using less 
instructions
+  or registers.
+* Generates ``_mcount`` calls using proper MIPS ABI.
+* Improved support of GlobalISel instruction selection framework. This feature
+  is still in experimental state for MIPS targets though.
 
 Changes to the PowerPC Target
 -
Index: lld/docs/ReleaseNotes.rst
===
--- lld/docs/ReleaseNotes.rst
+++ lld/docs/ReleaseNotes.rst
@@ -30,6 +30,14 @@
   with GNU now. (`r375051
   
`_)
 
+* New ``elf32btsmipn32_fbsd`` and ``elf32ltsmipn32_fbsd`` emulations
+  are supported.
+
+* Relax MIPS ``jalr``and ``jr`` instructions marked by the ``R_MIPS_JALR``
+  relocation.
+
+* Reduced size of linked MIPS binaries.
+
 COFF Improvements
 -
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -111,6 +111,9 @@
   In a future release of Clang, we intend to change the default to
   ``-fno-lax-vector-conversions``.
 
+* Improved support for ``octeon`` MIPS-family CPU. Added ``octeon+`` to
+  the list of of CPUs accepted by the driver.
+
 New Compiler Flags
 --
 


Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -122,8 +122,21 @@
 Changes to the MIPS Target
 --
 
- During this release ...
-
+* Improved support for ``octeon`` and added support for ``octeon+``
+  MIPS-family CPU.
+* ``min``, ``max``, ``umin``, ``umax`` atomics now supported on MIPS targets.
+* Now PC-relative relocations are generated for ``.eh_frame`` sections when
+  possible. That allows to link MIPS binaries without having to pass the
+  ``-Wl,-z,notext`` option.
+* Fix evaluating J-format branch (``j``, ``jal``, ...) targets when the
+  instruction is not in the first 256 MB region.
+* Fixed ``jal``, ``sc``, ``scs``, ``ll``, ``lld``, ``la``, ``lw``, ``sw``
+  instructions expanding. Now they accept more types of expression as arguments,
+  correctly handle load/store for ``XGOT`` model, expand using less instructions
+  or registers.
+* Generates ``_mcount`` calls using proper MIPS ABI.
+* Improved support of GlobalISel instruction selection framework. This feature
+  is still in experimental state for MIPS targets though.
 
 Changes to the PowerPC Target
 -
Index: lld/docs/ReleaseNotes.rst
===
--- lld/docs/ReleaseNotes.rst
+++ lld/docs/ReleaseNotes.rst
@@ -30,6 +30,14 @@
   with GNU now. (`r375051
   `_)
 
+* New ``elf32btsmipn32_fbsd`` and ``elf32ltsmipn32_fbsd`` emulations
+  are supported.
+
+* Relax MIPS ``jalr``and ``jr`` instructions marked by the ``R_MIPS_JALR``
+  relocation.
+
+* Reduced size of linked MIPS binaries.
+
 COFF Improvements
 -
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -111,6 +111,9 @@
   In a future release of Clang, we intend to change the default to
   ``-fno-lax-vector-conversions``.
 
+* Improved support for ``octeon`` MIPS-family CPU. Added ``octeon+`` to
+  the list of of CPUs accepted by the driver.
+
 New Compiler Flags
 --
 

[PATCH] D73101: [clangd] Do not duplicate TemplatedDecls in findExplicitReferences

2020-01-21 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62057 tests passed, 0 failed 
and 784 were skipped.

{icon question-circle color=gray} clang-tidy: unknown.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73101



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


[PATCH] D73101: [clangd] Do not duplicate TemplatedDecls in findExplicitReferences

2020-01-21 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 239320.
kadircet marked an inline comment as done.
kadircet added a comment.

- Filter out templateddecls in VisitNamedDecls, instead of defining a new Visit 
method.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73101

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
@@ -733,21 +733,17 @@
{R"cpp(
 namespace foo {
   template 
-  class $1^$2^Bar {
-~$3^Bar();
-void $4^f($5^Bar);
+  class $1^Bar {
+~$2^Bar();
+void $3^f($4^Bar);
   };
 }
   )cpp",
 "0: targets = {foo::Bar::T}, decl\n"
-// FIXME: avoid the 2 duplicated foo::Bar references below, the first
-// one comes from ClassTemplateDecl; the second comes from the
-// underlying CXXRecordDecl.
 "1: targets = {foo::Bar}, decl\n"
-"2: targets = {foo::Bar}, decl\n"
-"3: targets = {foo::Bar}\n"
-"4: targets = {foo::Bar::f}, decl\n"
-"5: targets = {foo::Bar}\n"},
+"2: targets = {foo::Bar}\n"
+"3: targets = {foo::Bar::f}, decl\n"
+"4: targets = {foo::Bar}\n"},
// MemberExpr should know their using declaration.
{R"cpp(
 struct X { void func(int); };
@@ -1047,7 +1043,47 @@
   }
 )cpp",
"0: targets = {Test}\n"
-   "1: targets = {a}, decl\n"}};
+   "1: targets = {a}, decl\n"},
+   // Templates
+   {R"cpp(
+namespace foo {
+  template 
+  class $1^Bar {};
+}
+  )cpp",
+"0: targets = {foo::Bar::T}, decl\n"
+"1: targets = {foo::Bar}, decl\n"},
+   // Templates
+   {R"cpp(
+namespace foo {
+  template 
+  void $1^func();
+}
+  )cpp",
+"0: targets = {T}, decl\n"
+"1: targets = {foo::func}, decl\n"},
+   // Templates
+   {R"cpp(
+namespace foo {
+  template 
+  $1^T $2^x;
+}
+  )cpp",
+"0: targets = {foo::T}, decl\n"
+"1: targets = {foo::T}\n"
+"2: targets = {foo::x}, decl\n"},
+   // Templates
+   {R"cpp(
+template class vector {};
+namespace foo {
+  template 
+  using $1^V = $2^vector<$3^T>;
+}
+  )cpp",
+"0: targets = {foo::T}, decl\n"
+"1: targets = {foo::V}, decl\n"
+"2: targets = {vector}\n"
+"3: targets = {foo::T}\n"}};
 
   for (const auto &C : Cases) {
 llvm::StringRef ExpectedCode = C.first;
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -581,6 +581,12 @@
 }
 
 void VisitNamedDecl(const NamedDecl *ND) {
+  // We choose to only visit TemplatedDecls for {Class, Function, Var,
+  // TypeAlias} TemplateDecls. As DescribedTemplates are covering the same
+  // range, but contains the duplication of template parameters that are
+  // already reported. Therefore we skip them here.
+  if (llvm::isa(ND))
+return;
   // FIXME: decide on how to surface destructors when we need them.
   if (llvm::isa(ND))
 return;


Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -733,21 +733,17 @@
{R"cpp(
 namespace foo {
   template 
-  class $1^$2^Bar {
-~$3^Bar();
-void $4^f($5^Bar);
+  class $1^Bar {
+~$2^Bar();
+void $3^f($4^Bar);
   };
 }
   )cpp",
 "0: targets = {foo::Bar::T}, decl\n"
-// FIXME: avoid the 2 duplicated foo::Bar references below, the first
-// one comes from ClassTemplateDecl; the second comes from the
-// underlying CXXRecordDecl.
 "1: targets = {foo::Bar}, decl\n"
-"2: targets = {foo::Bar}, decl\n"
-"3: targets = {foo::Bar}\n"
-"4: targets = {foo::Bar::f}, decl\n"
-"5: targets = {foo::Bar}\n"},
+"2: targets = {foo::Bar}\n"
+"3: targets = {foo::Bar::f}, decl\n"
+"4: targets = {foo::Bar}\n"},
// MemberExpr sho

[PATCH] D73098: [clang-tidy] readability-identifier-naming disregards parameters restrictions on main like functions

2020-01-21 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62058 tests passed, 0 failed 
and 784 were skipped.

{icon question-circle color=gray} clang-tidy: unknown.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73098



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


[clang] 6a24339 - [ARM] Follow AACPS standard for volatile bit-fields access width

2020-01-21 Thread Diogo Sampaio via cfe-commits

Author: Diogo Sampaio
Date: 2020-01-21T15:23:38Z
New Revision: 6a24339a45246b66bd3de88cc9c6a5b5e77c0645

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

LOG: [ARM] Follow AACPS standard for volatile bit-fields access width

Summary:
This patch resumes the work of D16586.
According to the AAPCS, volatile bit-fields should
be accessed using containers of the widht of their
declarative type. In such case:
```
struct S1 {
  short a : 1;
}
```
should be accessed using load and stores of the width
(sizeof(short)), where now the compiler does only load
the minimum required width (char in this case).
However, as discussed in D16586,
that could overwrite non-volatile bit-fields, which
conflicted with C and C++ object models by creating
data race conditions that are not part of the bit-field,
e.g.
```
struct S2 {
  short a;
  int  b : 16;
}
```
Accessing `S2.b` would also access `S2.a`.

The AAPCS Release 2019Q1.1
(https://static.docs.arm.com/ihi0042/g/aapcs32.pdf)
section 8.1 Data Types, page 35, "Volatile bit-fields -
preserving number and width of container accesses" has been
updated to avoid conflict with the C++ Memory Model.
Now it reads in the note:
```
This ABI does not place any restrictions on the access widths
of bit-fields where the container overlaps with a non-bit-field member.
 This is because the C/C++ memory model defines these as being separate
memory locations, which can be accessed by two threads
 simultaneously. For this reason, compilers must be permitted to use a
narrower memory access width (including splitting the access
 into multiple instructions) to avoid writing to a different memory location.
```

I've updated the patch D16586 to follow such behavior by verifying that we
only change volatile bit-field access when:
 - it won't overlap with any other non-bit-field member
 - we only access memory inside the bounds of the record

Regarding the number of memory accesses, that should be preserved, that will
be implemented by D67399.

Reviewers: rsmith, rjmccall, eli.friedman, ostannard

Subscribers: ostannard, kristof.beyls, cfe-commits, carwil, olista01

Tags: #clang

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

Added: 


Modified: 
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CGValue.h
clang/lib/CodeGen/CodeGenFunction.h
clang/test/CodeGen/aapcs-bitfield.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 8e0604181fb1..c4029c72dd5f 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -177,6 +177,11 @@ llvm::Value *CodeGenFunction::EvaluateExprAsBool(const 
Expr *E) {
Loc);
 }
 
+// Helper method to check if the underlying ABI is AAPCS
+static bool isAAPCS(const TargetInfo &TargetInfo) {
+  return TargetInfo.getABI().startswith("aapcs");
+}
+
 /// EmitIgnoredExpr - Emit code to compute the specified expression,
 /// ignoring the result.
 void CodeGenFunction::EmitIgnoredExpr(const Expr *E) {
@@ -4052,15 +4057,120 @@ static bool hasAnyVptr(const QualType Type, const 
ASTContext &Context) {
   return false;
 }
 
+// AAPCS requires volatile bitfield accesses to be performed using the
+// natural alignment / width of the bitfield declarative type, if that
+// won't cause overlap over a non-bitfield member nor access outside the
+// the data structure.
+bool CodeGenFunction::AdjustAAPCSBitfieldLValue(Address &Base,
+CGBitFieldInfo &Info,
+const FieldDecl *Field,
+const QualType FieldType,
+const CGRecordLayout &RL) {
+  llvm::Type *ResLTy = ConvertTypeForMem(FieldType);
+  // CGRecordLowering::setBitFieldInfo() pre-adjusts the bitfield offsets for
+  // big-endian targets, but it assumes a container of width Info.StorageSize.
+  // Since AAPCS uses a 
diff erent container size (width of the type), we first
+  // undo that calculation here and redo it once the bitfield offset within the
+  // new container is calculated
+  const bool BE = CGM.getTypes().getDataLayout().isBigEndian();
+  const unsigned OldOffset =
+  BE ? Info.StorageSize - (Info.Offset + Info.Size) : Info.Offset;
+  // Offset to the bitfield from the beginning of the struct
+  const unsigned AbsoluteOffset =
+  getContext().toBits(Info.StorageOffset) + OldOffset;
+
+  // Container size is the width of the bitfield type
+  const unsigned ContainerSize = ResLTy->getPrimitiveSizeInBits();
+  // Nothing to do if the access uses the desired
+  // container width and is naturally aligned
+  if (Info.StorageSize == ContainerSize && (OldOffset % ContainerSize == 0))
+return 

[clang] 2147703 - Revert "[ARM] Follow AACPS standard for volatile bit-fields access width"

2020-01-21 Thread Diogo Sampaio via cfe-commits

Author: Diogo Sampaio
Date: 2020-01-21T15:31:33Z
New Revision: 2147703bde1e1a7a1b89ccb66f55d36fd17620f1

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

LOG: Revert "[ARM] Follow AACPS standard for volatile bit-fields access width"

This reverts commit 6a24339a45246b66bd3de88cc9c6a5b5e77c0645.
Submitted using ide button by mistake

Added: 


Modified: 
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CGValue.h
clang/lib/CodeGen/CodeGenFunction.h
clang/test/CodeGen/aapcs-bitfield.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index c4029c72dd5f..8e0604181fb1 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -177,11 +177,6 @@ llvm::Value *CodeGenFunction::EvaluateExprAsBool(const 
Expr *E) {
Loc);
 }
 
-// Helper method to check if the underlying ABI is AAPCS
-static bool isAAPCS(const TargetInfo &TargetInfo) {
-  return TargetInfo.getABI().startswith("aapcs");
-}
-
 /// EmitIgnoredExpr - Emit code to compute the specified expression,
 /// ignoring the result.
 void CodeGenFunction::EmitIgnoredExpr(const Expr *E) {
@@ -4057,120 +4052,15 @@ static bool hasAnyVptr(const QualType Type, const 
ASTContext &Context) {
   return false;
 }
 
-// AAPCS requires volatile bitfield accesses to be performed using the
-// natural alignment / width of the bitfield declarative type, if that
-// won't cause overlap over a non-bitfield member nor access outside the
-// the data structure.
-bool CodeGenFunction::AdjustAAPCSBitfieldLValue(Address &Base,
-CGBitFieldInfo &Info,
-const FieldDecl *Field,
-const QualType FieldType,
-const CGRecordLayout &RL) {
-  llvm::Type *ResLTy = ConvertTypeForMem(FieldType);
-  // CGRecordLowering::setBitFieldInfo() pre-adjusts the bitfield offsets for
-  // big-endian targets, but it assumes a container of width Info.StorageSize.
-  // Since AAPCS uses a 
diff erent container size (width of the type), we first
-  // undo that calculation here and redo it once the bitfield offset within the
-  // new container is calculated
-  const bool BE = CGM.getTypes().getDataLayout().isBigEndian();
-  const unsigned OldOffset =
-  BE ? Info.StorageSize - (Info.Offset + Info.Size) : Info.Offset;
-  // Offset to the bitfield from the beginning of the struct
-  const unsigned AbsoluteOffset =
-  getContext().toBits(Info.StorageOffset) + OldOffset;
-
-  // Container size is the width of the bitfield type
-  const unsigned ContainerSize = ResLTy->getPrimitiveSizeInBits();
-  // Nothing to do if the access uses the desired
-  // container width and is naturally aligned
-  if (Info.StorageSize == ContainerSize && (OldOffset % ContainerSize == 0))
-return false;
-
-  // Offset within the container
-  unsigned MemberOffset = AbsoluteOffset & (ContainerSize - 1);
-
-  // Bail out if an aligned load of the container cannot cover the entire
-  // bitfield. This can happen for example, if the bitfield is part of a packed
-  // struct. AAPCS does not define access rules for such cases, we let clang to
-  // follow its own rules.
-  if (MemberOffset + Info.Size > ContainerSize) {
-return false;
-  }
-  // Re-adjust offsets for big-endian targets
-  if (BE)
-MemberOffset = ContainerSize - (MemberOffset + Info.Size);
-
-  const CharUnits NewOffset =
-  getContext().toCharUnitsFromBits(AbsoluteOffset & ~(ContainerSize - 1));
-  const CharUnits End = NewOffset +
-getContext().toCharUnitsFromBits(ContainerSize) -
-CharUnits::One();
-
-  const ASTRecordLayout &Layout =
-  getContext().getASTRecordLayout(Field->getParent());
-  // If we access outside memory outside the record, than bail out
-  const CharUnits RecordSize = Layout.getSize();
-  if (End >= RecordSize) {
-return false;
-  }
-
-  // Bail out if performing this load would access non-bitfields members
-
-  for (auto it : Field->getParent()->fields()) {
-const FieldDecl &F = *it;
-// We distinct allow bitfields overlaps
-if (F.isBitField())
-  continue;
-const CharUnits FOffset = getContext().toCharUnitsFromBits(
-Layout.getFieldOffset(F.getFieldIndex()));
-const CharUnits FEnd =
-FOffset +
-getContext().toCharUnitsFromBits(
-ConvertTypeForMem(F.getType())->getPrimitiveSizeInBits()) -
-CharUnits::One();
-if (End < FOffset) {
-  // The other field starts after the desired load end.
-  break;
-}
-if (FEnd < NewOffset) {
-  // The other field ends before the des

[PATCH] D73106: [Alignment][NFC] Use Align with CreateMaskedStore

2020-01-21 Thread Clement Courbet via Phabricator via cfe-commits
courbet added inline comments.



Comment at: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp:2907
 Value *Addr = I.getArgOperand(1);
-const MaybeAlign Alignment(
+const Align Alignment(
 cast(I.getArgOperand(2))->getZExtValue());

I think it's actually OK for this one to be a `MaybeAlign`, e.g. in 
`ARMTTIImpl::isLegalMaskedLoad`.



Comment at: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp:2937
 Value *Addr = I.getArgOperand(0);
-const MaybeAlign Alignment(
+const Align Alignment(
 cast(I.getArgOperand(1))->getZExtValue());

ditto


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73106



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


[PATCH] D73104: [Attr][Doc][NFC] Fix code snippet formatting for attribute documentation

2020-01-21 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62057 tests passed, 0 failed 
and 784 were skipped.

{icon question-circle color=gray} clang-tidy: unknown.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73104



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


[PATCH] D72932: [ARM] Follow AACPS standard for volatile bit-fields access width

2020-01-21 Thread Diogo N. Sampaio via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6a24339a4524: [ARM] Follow AACPS standard for volatile 
bit-fields access width (authored by dnsampaio).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72932

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGValue.h
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGen/aapcs-bitfield.c

Index: clang/test/CodeGen/aapcs-bitfield.c
===
--- clang/test/CodeGen/aapcs-bitfield.c
+++ clang/test/CodeGen/aapcs-bitfield.c
@@ -151,19 +151,19 @@
 
 // LE-LABEL: @st3_check_load(
 // LE-NEXT:  entry:
-// LE-NEXT:[[TMP0:%.*]] = getelementptr [[STRUCT_ST3:%.*]], %struct.st3* [[M:%.*]], i32 0, i32 0
-// LE-NEXT:[[BF_LOAD:%.*]] = load volatile i8, i8* [[TMP0]], align 2
-// LE-NEXT:[[BF_SHL:%.*]] = shl i8 [[BF_LOAD]], 1
-// LE-NEXT:[[BF_ASHR:%.*]] = ashr exact i8 [[BF_SHL]], 1
-// LE-NEXT:[[CONV:%.*]] = sext i8 [[BF_ASHR]] to i32
+// LE-NEXT:[[TMP0:%.*]] = bitcast %struct.st3* [[M:%.*]] to i16*
+// LE-NEXT:[[BF_LOAD:%.*]] = load volatile i16, i16* [[TMP0]], align 2
+// LE-NEXT:[[BF_SHL:%.*]] = shl i16 [[BF_LOAD]], 9
+// LE-NEXT:[[BF_ASHR:%.*]] = ashr exact i16 [[BF_SHL]], 9
+// LE-NEXT:[[CONV:%.*]] = sext i16 [[BF_ASHR]] to i32
 // LE-NEXT:ret i32 [[CONV]]
 //
 // BE-LABEL: @st3_check_load(
 // BE-NEXT:  entry:
-// BE-NEXT:[[TMP0:%.*]] = getelementptr [[STRUCT_ST3:%.*]], %struct.st3* [[M:%.*]], i32 0, i32 0
-// BE-NEXT:[[BF_LOAD:%.*]] = load volatile i8, i8* [[TMP0]], align 2
-// BE-NEXT:[[BF_ASHR:%.*]] = ashr i8 [[BF_LOAD]], 1
-// BE-NEXT:[[CONV:%.*]] = sext i8 [[BF_ASHR]] to i32
+// BE-NEXT:[[TMP0:%.*]] = bitcast %struct.st3* [[M:%.*]] to i16*
+// BE-NEXT:[[BF_LOAD:%.*]] = load volatile i16, i16* [[TMP0]], align 2
+// BE-NEXT:[[BF_ASHR:%.*]] = ashr i16 [[BF_LOAD]], 9
+// BE-NEXT:[[CONV:%.*]] = sext i16 [[BF_ASHR]] to i32
 // BE-NEXT:ret i32 [[CONV]]
 //
 int st3_check_load(struct st3 *m) {
@@ -172,20 +172,20 @@
 
 // LE-LABEL: @st3_check_store(
 // LE-NEXT:  entry:
-// LE-NEXT:[[TMP0:%.*]] = getelementptr [[STRUCT_ST3:%.*]], %struct.st3* [[M:%.*]], i32 0, i32 0
-// LE-NEXT:[[BF_LOAD:%.*]] = load volatile i8, i8* [[TMP0]], align 2
-// LE-NEXT:[[BF_CLEAR:%.*]] = and i8 [[BF_LOAD]], -128
-// LE-NEXT:[[BF_SET:%.*]] = or i8 [[BF_CLEAR]], 1
-// LE-NEXT:store volatile i8 [[BF_SET]], i8* [[TMP0]], align 2
+// LE-NEXT:[[TMP0:%.*]] = bitcast %struct.st3* [[M:%.*]] to i16*
+// LE-NEXT:[[BF_LOAD:%.*]] = load volatile i16, i16* [[TMP0]], align 2
+// LE-NEXT:[[BF_CLEAR:%.*]] = and i16 [[BF_LOAD]], -128
+// LE-NEXT:[[BF_SET:%.*]] = or i16 [[BF_CLEAR]], 1
+// LE-NEXT:store volatile i16 [[BF_SET]], i16* [[TMP0]], align 2
 // LE-NEXT:ret void
 //
 // BE-LABEL: @st3_check_store(
 // BE-NEXT:  entry:
-// BE-NEXT:[[TMP0:%.*]] = getelementptr [[STRUCT_ST3:%.*]], %struct.st3* [[M:%.*]], i32 0, i32 0
-// BE-NEXT:[[BF_LOAD:%.*]] = load volatile i8, i8* [[TMP0]], align 2
-// BE-NEXT:[[BF_CLEAR:%.*]] = and i8 [[BF_LOAD]], 1
-// BE-NEXT:[[BF_SET:%.*]] = or i8 [[BF_CLEAR]], 2
-// BE-NEXT:store volatile i8 [[BF_SET]], i8* [[TMP0]], align 2
+// BE-NEXT:[[TMP0:%.*]] = bitcast %struct.st3* [[M:%.*]] to i16*
+// BE-NEXT:[[BF_LOAD:%.*]] = load volatile i16, i16* [[TMP0]], align 2
+// BE-NEXT:[[BF_CLEAR:%.*]] = and i16 [[BF_LOAD]], 511
+// BE-NEXT:[[BF_SET:%.*]] = or i16 [[BF_CLEAR]], 512
+// BE-NEXT:store volatile i16 [[BF_SET]], i16* [[TMP0]], align 2
 // BE-NEXT:ret void
 //
 void st3_check_store(struct st3 *m) {
@@ -199,24 +199,22 @@
 
 // LE-LABEL: @st4_check_load(
 // LE-NEXT:  entry:
-// LE-NEXT:[[TMP0:%.*]] = getelementptr [[STRUCT_ST4:%.*]], %struct.st4* [[M:%.*]], i32 0, i32 0
-// LE-NEXT:[[BF_LOAD:%.*]] = load volatile i16, i16* [[TMP0]], align 4
-// LE-NEXT:[[BF_SHL:%.*]] = shl i16 [[BF_LOAD]], 2
-// LE-NEXT:[[BF_ASHR:%.*]] = ashr i16 [[BF_SHL]], 11
-// LE-NEXT:[[BF_CAST:%.*]] = zext i16 [[BF_ASHR]] to i32
-// LE-NEXT:[[SEXT:%.*]] = shl i32 [[BF_CAST]], 24
-// LE-NEXT:[[CONV:%.*]] = ashr exact i32 [[SEXT]], 24
+// LE-NEXT:[[TMP0:%.*]] = bitcast %struct.st4* [[M:%.*]] to i8*
+// LE-NEXT:[[TMP1:%.*]] = getelementptr inbounds i8, i8* [[TMP0]], i32 1
+// LE-NEXT:[[BF_LOAD:%.*]] = load volatile i8, i8* [[TMP1]], align 1
+// LE-NEXT:[[BF_SHL:%.*]] = shl i8 [[BF_LOAD]], 2
+// LE-NEXT:[[BF_ASHR:%.*]] = ashr i8 [[BF_SHL]], 3
+// LE-NEXT:[[CONV:%.*]] = sext i8 [[BF_ASHR]] to i32
 // LE-NEXT:ret i32 [[CONV]]
 //
 // BE-LABEL: @st4_check_load(
 // BE-NEXT:  entry:
-// BE-NEXT:[[TMP0:%.*]] = getelementptr [[STRUCT_ST4:%.*]], %struct.st4* [[M:%.*]], i32 0, i32 0
-// BE-NEXT:[[BF_LOAD:%.*]] = load vo

[PATCH] D72932: [ARM] Follow AACPS standard for volatile bit-fields access width

2020-01-21 Thread Diogo N. Sampaio via Phabricator via cfe-commits
dnsampaio reopened this revision.
dnsampaio added a comment.

Sorry, submitted using ide by mistake. Already reverted it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72932



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


[PATCH] D72897: List implicit operator== after implicit destructors in a vtable.

2020-01-21 Thread Alan Phipps via Phabricator via cfe-commits
alanphipps added a comment.

This test is still failing on the arm bots and also with my downstream ARM 
compiler validation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72897



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


[PATCH] D73109: [clang][index] Index the injected class name types.

2020-01-21 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman, ilya-biryukov.
Herald added a project: clang.

Currently, we (clangd) are missing this kind of references.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73109

Files:
  clang/lib/Index/IndexTypeSourceInfo.cpp
  clang/unittests/Index/IndexTests.cpp


Index: clang/unittests/Index/IndexTests.cpp
===
--- clang/unittests/Index/IndexTests.cpp
+++ clang/unittests/Index/IndexTests.cpp
@@ -293,6 +293,27 @@
 WrittenAt(Position(4, 8);
 }
 
+TEST(IndexTest, InjecatedNameClass) {
+  std::string Code = R"cpp(
+template 
+class Foo {
+  void f(Foo x);
+};
+  )cpp";
+  auto Index = std::make_shared();
+  IndexingOptions Opts;
+  tooling::runToolOnCode(std::make_unique(Index, Opts), Code);
+  EXPECT_THAT(
+  Index->Symbols,
+  UnorderedElementsAre(
+  AllOf(QName("Foo"), Kind(SymbolKind::Class),
+WrittenAt(Position(3, 11))),
+  AllOf(QName("Foo::f"), Kind(SymbolKind::InstanceMethod),
+WrittenAt(Position(4, 12))),
+  AllOf(QName("Foo"), Kind(SymbolKind::Class),
+HasRole(SymbolRole::Reference), WrittenAt(Position(4, 14);
+}
+
 } // namespace
 } // namespace index
 } // namespace clang
Index: clang/lib/Index/IndexTypeSourceInfo.cpp
===
--- clang/lib/Index/IndexTypeSourceInfo.cpp
+++ clang/lib/Index/IndexTypeSourceInfo.cpp
@@ -170,6 +170,12 @@
 return true;
   }
 
+  bool VisitInjectedClassNameTypeLoc(InjectedClassNameTypeLoc TL) {
+return IndexCtx.handleReference(TL.getDecl(), TL.getNameLoc(),
+Parent, ParentDC, SymbolRoleSet(),
+Relations);
+  }
+
   bool VisitDependentNameTypeLoc(DependentNameTypeLoc TL) {
 const DependentNameType *DNT = TL.getTypePtr();
 const NestedNameSpecifier *NNS = DNT->getQualifier();


Index: clang/unittests/Index/IndexTests.cpp
===
--- clang/unittests/Index/IndexTests.cpp
+++ clang/unittests/Index/IndexTests.cpp
@@ -293,6 +293,27 @@
 WrittenAt(Position(4, 8);
 }
 
+TEST(IndexTest, InjecatedNameClass) {
+  std::string Code = R"cpp(
+template 
+class Foo {
+  void f(Foo x);
+};
+  )cpp";
+  auto Index = std::make_shared();
+  IndexingOptions Opts;
+  tooling::runToolOnCode(std::make_unique(Index, Opts), Code);
+  EXPECT_THAT(
+  Index->Symbols,
+  UnorderedElementsAre(
+  AllOf(QName("Foo"), Kind(SymbolKind::Class),
+WrittenAt(Position(3, 11))),
+  AllOf(QName("Foo::f"), Kind(SymbolKind::InstanceMethod),
+WrittenAt(Position(4, 12))),
+  AllOf(QName("Foo"), Kind(SymbolKind::Class),
+HasRole(SymbolRole::Reference), WrittenAt(Position(4, 14);
+}
+
 } // namespace
 } // namespace index
 } // namespace clang
Index: clang/lib/Index/IndexTypeSourceInfo.cpp
===
--- clang/lib/Index/IndexTypeSourceInfo.cpp
+++ clang/lib/Index/IndexTypeSourceInfo.cpp
@@ -170,6 +170,12 @@
 return true;
   }
 
+  bool VisitInjectedClassNameTypeLoc(InjectedClassNameTypeLoc TL) {
+return IndexCtx.handleReference(TL.getDecl(), TL.getNameLoc(),
+Parent, ParentDC, SymbolRoleSet(),
+Relations);
+  }
+
   bool VisitDependentNameTypeLoc(DependentNameTypeLoc TL) {
 const DependentNameType *DNT = TL.getTypePtr();
 const NestedNameSpecifier *NNS = DNT->getQualifier();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72722: [FPEnv] [SystemZ] Platform-specific builtin constrained FP enablement

2020-01-21 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn marked an inline comment as done.
kpn added inline comments.



Comment at: clang/test/CodeGen/builtins-systemz-vector2-constrained.c:25
+  // CHECK: [[NEG:%[^ ]+]] = fneg <2 x double> {{.*}}
+  // CHECK:  [[RES:%[^ ]+]] = call <2 x double> 
@llvm.experimental.constrained.fma.v2f64(<2 x double> %{{.*}}, <2 x double> 
%{{.*}}, <2 x double> [[NEG]], metadata !{{.*}}, metadata !{{.*}})
+  // CHECK: fneg <2 x double> [[RES]]

uweigand wrote:
> Why is it that this one has metadata nodes and all the others do not?   Do 
> they really not have metadata (why?) or are you just not checking for them?
No reason, really. The regular expression will pick up the second metadata 
argument if present, so I could just eliminate the check for the second one 
here. This isn't a metadata test so precise testing of metadata arguments 
doesn't seem necessary? Consistency would be good, though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72722



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


[PATCH] D72996: [Sema] Attempt to perform call-size-specific `__attribute__((alloc_align(param_idx)))` validation

2020-01-21 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:4479
+const Expr *Arg = Args[AA->getParamIndex().getASTIndex()];
+if (!Arg->isTypeDependent() && !Arg->isValueDependent()) {
+  llvm::APSInt I(64);

Does this need to be isInstantionDependent?



Comment at: clang/lib/Sema/SemaChecking.cpp:4489
+// Alignment calculations can wrap around if it's greater than 2**29.
+unsigned MaximumAlignment = 536870912;
+if (I > MaximumAlignment)

I thought we had this stored somewhere else?  We probably should have this be a 
constant somewhere in the frontend.  I THINK I remember doing a review where I 
pulled this value into clang somewhere...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72996



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


[PATCH] D72722: [FPEnv] [SystemZ] Platform-specific builtin constrained FP enablement

2020-01-21 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn updated this revision to Diff 239324.
kpn added a comment.

Update for review comments.


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

https://reviews.llvm.org/D72722

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-systemz-vector-constrained.c
  clang/test/CodeGen/builtins-systemz-vector2-constrained.c
  clang/test/CodeGen/builtins-systemz-zvector-constrained.c
  clang/test/CodeGen/builtins-systemz-zvector2-constrained.c
  clang/test/CodeGen/builtins-systemz-zvector3-constrained.c

Index: clang/test/CodeGen/builtins-systemz-zvector3-constrained.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-systemz-zvector3-constrained.c
@@ -0,0 +1,109 @@
+// REQUIRES: systemz-registered-target
+// RUN: %clang_cc1 -target-cpu z15 -triple s390x-linux-gnu \
+// RUN: -O -fzvector -flax-vector-conversions=none \
+// RUN: -ffp-exception-behavior=strict \
+// RUN: -Wall -Wno-unused -Werror -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -target-cpu z15 -triple s390x-linux-gnu \
+// RUN: -O -fzvector -flax-vector-conversions=none \
+// RUN: -ffp-exception-behavior=strict \
+// RUN: -Wall -Wno-unused -Werror -S %s -o - | FileCheck %s --check-prefix=CHECK-ASM
+
+#include 
+
+volatile vector signed int vsi;
+volatile vector signed long long vsl;
+volatile vector unsigned int vui;
+volatile vector unsigned long long vul;
+volatile vector float vf;
+volatile vector double vd;
+
+volatile float f;
+volatile double d;
+
+const float * volatile cptrf;
+const double * volatile cptrd;
+
+float * volatile ptrf;
+double * volatile ptrd;
+
+volatile int idx;
+
+void test_core(void) {
+  // CHECK-ASM-LABEL: test_core
+  vector float vf2;
+  vector double vd2;
+
+  vf += vec_revb(vec_xl(idx, cptrf));
+  // CHECK-ASM: vlbrf
+  vd += vec_revb(vec_xl(idx, cptrd));
+  // CHECK-ASM: vlbrg
+
+  vec_xst(vec_revb(vf), idx, ptrf);
+  // CHECK-ASM: vstbrf
+  vec_xst(vec_revb(vd), idx, ptrd);
+  // CHECK-ASM: vstbrg
+
+  vf += vec_revb(vec_insert_and_zero(cptrf));
+  // CHECK-ASM: vllebrzf
+  vd += vec_revb(vec_insert_and_zero(cptrd));
+  // CHECK-ASM: vllebrzg
+
+  vf += vec_revb(vec_splats(f));
+  // CHECK-ASM: vlbrrepf
+  vd += vec_revb(vec_splats(d));
+  // CHECK-ASM: vlbrrepg
+
+  vf2 = vf;
+  vf += vec_revb(vec_insert(f, vec_revb(vf2), 0));
+  // CHECK-ASM: vlebrf
+  vd2 = vd;
+  vd += vec_revb(vec_insert(d, vec_revb(vd2), 0));
+  // CHECK-ASM: vlebrg
+
+  f = vec_extract(vec_revb(vf), 0);
+  // CHECK-ASM: vstebrf
+  d = vec_extract(vec_revb(vd), 0);
+  // CHECK-ASM: vstebrg
+
+  vf += vec_reve(vec_xl(idx, cptrf));
+  // CHECK-ASM: vlerf
+  vd += vec_reve(vec_xl(idx, cptrd));
+  // CHECK-ASM: vlerg
+
+  vec_xst(vec_reve(vf), idx, ptrf);
+  // CHECK-ASM: vsterf
+  vec_xst(vec_reve(vd), idx, ptrd);
+  // CHECK-ASM: vsterg
+}
+
+void test_float(void) {
+  // CHECK-ASM-LABEL: test_float
+
+  vd = vec_double(vsl);
+  // CHECK: call <2 x double> @llvm.experimental.constrained.sitofp.v2f64.v2i64(<2 x i64> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vcdgb
+  vd = vec_double(vul);
+  // CHECK: call <2 x double> @llvm.experimental.constrained.uitofp.v2f64.v2i64(<2 x i64> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vcdlgb
+  vf = vec_float(vsi);
+  // CHECK: call <4 x float> @llvm.experimental.constrained.sitofp.v4f32.v4i32(<4 x i32> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vcefb
+  vf = vec_float(vui);
+  // CHECK: call <4 x float> @llvm.experimental.constrained.uitofp.v4f32.v4i32(<4 x i32> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vcelfb
+
+  vsl = vec_signed(vd);
+  // CHECK: call <2 x i64> @llvm.experimental.constrained.fptosi.v2i64.v2f64(<2 x double> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vcgdb
+  vsi = vec_signed(vf);
+  // CHECK: call <4 x i32> @llvm.experimental.constrained.fptosi.v4i32.v4f32(<4 x float> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vcfeb
+  vul = vec_unsigned(vd);
+  // CHECK: call <2 x i64> @llvm.experimental.constrained.fptoui.v2i64.v2f64(<2 x double> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vclgdb
+  vui = vec_unsigned(vf);
+  // xHECK: fptoui <4 x float> %{{.*}} to <4 x i32>
+  // CHECK: call <4 x i32> @llvm.experimental.constrained.fptoui.v4i32.v4f32(<4 x float> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vclfeb
+}
+
Index: clang/test/CodeGen/builtins-systemz-zvector2-constrained.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-systemz-zvector2-constrained.c
@@ -0,0 +1,543 @@
+// REQUIRES: systemz-registered-target
+// RUN: %clang_cc1 -target-cpu z14 -triple s390x-linux-gnu \
+// RUN: -O -fzvector -flax-vector-conversions=none \
+// RUN: -ffp-exception-behavior=strict \
+// RUN: -Wall -Wno-unused -Werror -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -target-cpu z14 -triple s390x-linux-gnu \
+// RUN: -O -fzvector -flax-vector-conversions=none \
+// RUN: -ffp-exception-behavior=strict \
+// RUN: -Wall -Wno-unused -Werror -S %

[PATCH] D72722: [FPEnv] [SystemZ] Platform-specific builtin constrained FP enablement

2020-01-21 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn updated this revision to Diff 239325.
kpn added a comment.

Eliminate a blank line I thought I had already had gotten.


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

https://reviews.llvm.org/D72722

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-systemz-vector-constrained.c
  clang/test/CodeGen/builtins-systemz-vector2-constrained.c
  clang/test/CodeGen/builtins-systemz-zvector-constrained.c
  clang/test/CodeGen/builtins-systemz-zvector2-constrained.c
  clang/test/CodeGen/builtins-systemz-zvector3-constrained.c

Index: clang/test/CodeGen/builtins-systemz-zvector3-constrained.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-systemz-zvector3-constrained.c
@@ -0,0 +1,109 @@
+// REQUIRES: systemz-registered-target
+// RUN: %clang_cc1 -target-cpu z15 -triple s390x-linux-gnu \
+// RUN: -O -fzvector -flax-vector-conversions=none \
+// RUN: -ffp-exception-behavior=strict \
+// RUN: -Wall -Wno-unused -Werror -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -target-cpu z15 -triple s390x-linux-gnu \
+// RUN: -O -fzvector -flax-vector-conversions=none \
+// RUN: -ffp-exception-behavior=strict \
+// RUN: -Wall -Wno-unused -Werror -S %s -o - | FileCheck %s --check-prefix=CHECK-ASM
+
+#include 
+
+volatile vector signed int vsi;
+volatile vector signed long long vsl;
+volatile vector unsigned int vui;
+volatile vector unsigned long long vul;
+volatile vector float vf;
+volatile vector double vd;
+
+volatile float f;
+volatile double d;
+
+const float * volatile cptrf;
+const double * volatile cptrd;
+
+float * volatile ptrf;
+double * volatile ptrd;
+
+volatile int idx;
+
+void test_core(void) {
+  // CHECK-ASM-LABEL: test_core
+  vector float vf2;
+  vector double vd2;
+
+  vf += vec_revb(vec_xl(idx, cptrf));
+  // CHECK-ASM: vlbrf
+  vd += vec_revb(vec_xl(idx, cptrd));
+  // CHECK-ASM: vlbrg
+
+  vec_xst(vec_revb(vf), idx, ptrf);
+  // CHECK-ASM: vstbrf
+  vec_xst(vec_revb(vd), idx, ptrd);
+  // CHECK-ASM: vstbrg
+
+  vf += vec_revb(vec_insert_and_zero(cptrf));
+  // CHECK-ASM: vllebrzf
+  vd += vec_revb(vec_insert_and_zero(cptrd));
+  // CHECK-ASM: vllebrzg
+
+  vf += vec_revb(vec_splats(f));
+  // CHECK-ASM: vlbrrepf
+  vd += vec_revb(vec_splats(d));
+  // CHECK-ASM: vlbrrepg
+
+  vf2 = vf;
+  vf += vec_revb(vec_insert(f, vec_revb(vf2), 0));
+  // CHECK-ASM: vlebrf
+  vd2 = vd;
+  vd += vec_revb(vec_insert(d, vec_revb(vd2), 0));
+  // CHECK-ASM: vlebrg
+
+  f = vec_extract(vec_revb(vf), 0);
+  // CHECK-ASM: vstebrf
+  d = vec_extract(vec_revb(vd), 0);
+  // CHECK-ASM: vstebrg
+
+  vf += vec_reve(vec_xl(idx, cptrf));
+  // CHECK-ASM: vlerf
+  vd += vec_reve(vec_xl(idx, cptrd));
+  // CHECK-ASM: vlerg
+
+  vec_xst(vec_reve(vf), idx, ptrf);
+  // CHECK-ASM: vsterf
+  vec_xst(vec_reve(vd), idx, ptrd);
+  // CHECK-ASM: vsterg
+}
+
+void test_float(void) {
+  // CHECK-ASM-LABEL: test_float
+
+  vd = vec_double(vsl);
+  // CHECK: call <2 x double> @llvm.experimental.constrained.sitofp.v2f64.v2i64(<2 x i64> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vcdgb
+  vd = vec_double(vul);
+  // CHECK: call <2 x double> @llvm.experimental.constrained.uitofp.v2f64.v2i64(<2 x i64> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vcdlgb
+  vf = vec_float(vsi);
+  // CHECK: call <4 x float> @llvm.experimental.constrained.sitofp.v4f32.v4i32(<4 x i32> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vcefb
+  vf = vec_float(vui);
+  // CHECK: call <4 x float> @llvm.experimental.constrained.uitofp.v4f32.v4i32(<4 x i32> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vcelfb
+
+  vsl = vec_signed(vd);
+  // CHECK: call <2 x i64> @llvm.experimental.constrained.fptosi.v2i64.v2f64(<2 x double> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vcgdb
+  vsi = vec_signed(vf);
+  // CHECK: call <4 x i32> @llvm.experimental.constrained.fptosi.v4i32.v4f32(<4 x float> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vcfeb
+  vul = vec_unsigned(vd);
+  // CHECK: call <2 x i64> @llvm.experimental.constrained.fptoui.v2i64.v2f64(<2 x double> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vclgdb
+  vui = vec_unsigned(vf);
+  // xHECK: fptoui <4 x float> %{{.*}} to <4 x i32>
+  // CHECK: call <4 x i32> @llvm.experimental.constrained.fptoui.v4i32.v4f32(<4 x float> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vclfeb
+}
+
Index: clang/test/CodeGen/builtins-systemz-zvector2-constrained.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-systemz-zvector2-constrained.c
@@ -0,0 +1,543 @@
+// REQUIRES: systemz-registered-target
+// RUN: %clang_cc1 -target-cpu z14 -triple s390x-linux-gnu \
+// RUN: -O -fzvector -flax-vector-conversions=none \
+// RUN: -ffp-exception-behavior=strict \
+// RUN: -Wall -Wno-unused -Werror -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -target-cpu z14 -triple s390x-linux-gnu \
+// RUN: -O -fzvector -flax-vector-conversions=none \
+// RUN: -ffp-exception-behavior=strict \
+// RUN:

[PATCH] D73110: [clangd] Drop returntype/type when hovering over type-ish names

2020-01-21 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added reviewers: sammccall, ilya-biryukov.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay.
Herald added a project: clang.

Some names, e.g. constructor/destructor/conversions, already contain
the type info, no need to duplicate them in the hoverinfo.

Fixes https://github.com/clangd/clangd/issues/252


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73110

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -327,7 +327,6 @@
  HI.Name = "X";
  HI.LocalScope = "X::"; // FIXME: X::
  HI.Kind = index::SymbolKind::Constructor;
- HI.ReturnType = "X";
  HI.Definition = "X()";
  HI.Parameters.emplace();
}},
@@ -337,10 +336,18 @@
  HI.Name = "~X";
  HI.LocalScope = "X::";
  HI.Kind = index::SymbolKind::Destructor;
- HI.ReturnType = "void";
  HI.Definition = "~X()";
  HI.Parameters.emplace();
}},
+  {"class X { operator [[in^t]](); };",
+   [](HoverInfo &HI) {
+ HI.NamespaceScope = "";
+ HI.Name = "operator int";
+ HI.LocalScope = "X::";
+ HI.Kind = index::SymbolKind::ConversionFunction;
+ HI.Definition = "operator int()";
+ HI.Parameters.emplace();
+   }},
 
   // auto on lambda
   {R"cpp(
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -266,20 +266,19 @@
 }
   }
 
-  if (const auto *CCD = llvm::dyn_cast(FD)) {
-// Constructor's "return type" is the class type.
-HI.ReturnType = declaredType(CCD->getParent()).getAsString(Policy);
-// Don't provide any type for the constructor itself.
-  } else if (llvm::isa(FD)) {
-HI.ReturnType = "void";
-  } else {
-HI.ReturnType = printType(FD->getReturnType(), Policy);
+  // We don't want any type info, if name already contains it. This is true for
+  // constructors/destructors and conversion operators.
+  const auto NK = FD->getDeclName().getNameKind();
+  if (NK == DeclarationName::CXXConstructorName ||
+  NK == DeclarationName::CXXDestructorName ||
+  NK == DeclarationName::CXXConversionFunctionName)
+return;
 
-QualType QT = FD->getType();
-if (const VarDecl *VD = llvm::dyn_cast(D)) // Lambdas
-  QT = VD->getType().getDesugaredType(D->getASTContext());
-HI.Type = printType(QT, Policy);
-  }
+  HI.ReturnType = printType(FD->getReturnType(), Policy);
+  QualType QT = FD->getType();
+  if (const VarDecl *VD = llvm::dyn_cast(D)) // Lambdas
+QT = VD->getType().getDesugaredType(D->getASTContext());
+  HI.Type = printType(QT, Policy);
   // FIXME: handle variadics.
 }
 


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -327,7 +327,6 @@
  HI.Name = "X";
  HI.LocalScope = "X::"; // FIXME: X::
  HI.Kind = index::SymbolKind::Constructor;
- HI.ReturnType = "X";
  HI.Definition = "X()";
  HI.Parameters.emplace();
}},
@@ -337,10 +336,18 @@
  HI.Name = "~X";
  HI.LocalScope = "X::";
  HI.Kind = index::SymbolKind::Destructor;
- HI.ReturnType = "void";
  HI.Definition = "~X()";
  HI.Parameters.emplace();
}},
+  {"class X { operator [[in^t]](); };",
+   [](HoverInfo &HI) {
+ HI.NamespaceScope = "";
+ HI.Name = "operator int";
+ HI.LocalScope = "X::";
+ HI.Kind = index::SymbolKind::ConversionFunction;
+ HI.Definition = "operator int()";
+ HI.Parameters.emplace();
+   }},
 
   // auto on lambda
   {R"cpp(
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -266,20 +266,19 @@
 }
   }
 
-  if (const auto *CCD = llvm::dyn_cast(FD)) {
-// Constructor's "return type" is the class type.
-HI.ReturnType = declaredType(CCD->getParent()).getAsString(Policy);
-// Don't provide any type for the constructor itself.
-  } else if (llvm::isa(FD)) {
-HI.ReturnType = "void";
-  } else {
-HI.ReturnType = printType(FD->getReturnType(), Policy);
+  // We don't want any type info, if name already contains it. This is true for
+  // constructors/destructors and conversion operators.
+  const auto NK = FD->getDeclName().getNameKind();
+  if (NK == DeclarationNam

[PATCH] D73101: [clangd] Do not duplicate TemplatedDecls in findExplicitReferences

2020-01-21 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62057 tests passed, 0 failed 
and 784 were skipped.

{icon question-circle color=gray} clang-tidy: unknown.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73101



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


[PATCH] D72998: [IR] Attribute/AttrBuilder: use Value::MaximumAlignment magic constant

2020-01-21 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D72998#1828571 , @lebedev.ri wrote:

> In D72998#1828559 , @hfinkel wrote:
>
> > Can we, at least, put this constant in a header file so we don't repeat it 
> > in several places?
>
>
> Remember, we can't use `llvm::Value::MaximumAlignment` itself in clang sema.
>  Which header do you have in mind?
>
> > Also, can we write it as 0x2000 so that it's more obvious what the 
> > value is.
>
> Sure, will do.


I'd suggest just putting it as a constant in SEMA.  Also can you fix this one 
too? 
https://github.com/llvm-mirror/clang/commit/726918e196b413bcd80f08494c061fd6b3f26c94


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72998



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


[PATCH] D73109: [clang][index] Index the injected class name types.

2020-01-21 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62058 tests passed, 0 failed 
and 784 were skipped.

{icon question-circle color=gray} clang-tidy: unknown.

{icon times-circle color=red} clang-format: fail. Please format your changes 
with clang-format by running `git-clang-format HEAD^` or applying this patch 
.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73109



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


[PATCH] D71911: [ThinLTO] Summarize vcall_visibility metadata

2020-01-21 Thread Eugene Leviant via Phabricator via cfe-commits
evgeny777 added inline comments.



Comment at: llvm/include/llvm/IR/ModuleSummaryIndex.h:762
+bool ReadOnly, bool WriteOnly, bool Constant,
+GlobalObject::VCallVisibility Vis = 
GlobalObject::VCallVisibilityPublic)
 : MaybeReadOnly(ReadOnly), MaybeWriteOnly(WriteOnly),

I think using default parameter is error prone here. Can you please get rid of 
it and update all places of usage respectively?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71911



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


[PATCH] D73110: [clangd] Drop returntype/type when hovering over type-ish names

2020-01-21 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 62057 tests passed, 0 failed 
and 784 were skipped.

{icon question-circle color=gray} clang-tidy: unknown.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73110



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


[PATCH] D71907: [WPD/VFE] Always emit vcall_visibility metadata for -fwhole-program-vtables

2020-01-21 Thread Eugene Leviant via Phabricator via cfe-commits
evgeny777 added inline comments.



Comment at: clang/lib/CodeGen/ItaniumCXXABI.cpp:676
+  bool ShouldEmitWPDInfo = CGM.getCodeGenOpts().WholeProgramVTables &&
+   CGM.HasHiddenLTOVisibility(RD);
   llvm::Value *VirtualFn = nullptr;

Why are we checking for hidden visibility here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71907



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


[PATCH] D72998: [IR] Attribute/AttrBuilder: use Value::MaximumAlignment magic constant

2020-01-21 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D72998#1831377 , @erichkeane wrote:

> In D72998#1828571 , @lebedev.ri 
> wrote:
>
> > In D72998#1828559 , @hfinkel wrote:
> >
> > > Can we, at least, put this constant in a header file so we don't repeat 
> > > it in several places?
> >
> >
> > Remember, we can't use `llvm::Value::MaximumAlignment` itself in clang sema.
> >  Which header do you have in mind?
> >
> > > Also, can we write it as 0x2000 so that it's more obvious what the 
> > > value is.
> >
> > Sure, will do.
>
>
> I'd suggest just putting it as a constant in SEMA.  Also can you fix this one 
> too? 
> https://github.com/llvm-mirror/clang/commit/726918e196b413bcd80f08494c061fd6b3f26c94


Okay


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72998



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


[PATCH] D73109: [clang][index] Index the injected class name types.

2020-01-21 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

Thanks this LG (please apply clang-format fixes though)

Have you checked if this class is missing any other typelocs?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73109



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


[clang-tools-extra] 1fbb1d6 - [clangd] Drop returntype/type when hovering over type-ish names

2020-01-21 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-01-21T17:10:09+01:00
New Revision: 1fbb1d6df0113ca341f6d257bc72e07343dd861a

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

LOG: [clangd] Drop returntype/type when hovering over type-ish names

Summary:
Some names, e.g. constructor/destructor/conversions, already contain
the type info, no need to duplicate them in the hoverinfo.

Fixes https://github.com/clangd/clangd/issues/252

Reviewers: sammccall, ilya-biryukov

Subscribers: MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/Hover.cpp
clang-tools-extra/clangd/unittests/HoverTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/Hover.cpp 
b/clang-tools-extra/clangd/Hover.cpp
index ad715db4d5eb..1b7a48758533 100644
--- a/clang-tools-extra/clangd/Hover.cpp
+++ b/clang-tools-extra/clangd/Hover.cpp
@@ -266,20 +266,19 @@ void fillFunctionTypeAndParams(HoverInfo &HI, const Decl 
*D,
 }
   }
 
-  if (const auto *CCD = llvm::dyn_cast(FD)) {
-// Constructor's "return type" is the class type.
-HI.ReturnType = declaredType(CCD->getParent()).getAsString(Policy);
-// Don't provide any type for the constructor itself.
-  } else if (llvm::isa(FD)) {
-HI.ReturnType = "void";
-  } else {
-HI.ReturnType = printType(FD->getReturnType(), Policy);
+  // We don't want any type info, if name already contains it. This is true for
+  // constructors/destructors and conversion operators.
+  const auto NK = FD->getDeclName().getNameKind();
+  if (NK == DeclarationName::CXXConstructorName ||
+  NK == DeclarationName::CXXDestructorName ||
+  NK == DeclarationName::CXXConversionFunctionName)
+return;
 
-QualType QT = FD->getType();
-if (const VarDecl *VD = llvm::dyn_cast(D)) // Lambdas
-  QT = VD->getType().getDesugaredType(D->getASTContext());
-HI.Type = printType(QT, Policy);
-  }
+  HI.ReturnType = printType(FD->getReturnType(), Policy);
+  QualType QT = FD->getType();
+  if (const VarDecl *VD = llvm::dyn_cast(D)) // Lambdas
+QT = VD->getType().getDesugaredType(D->getASTContext());
+  HI.Type = printType(QT, Policy);
   // FIXME: handle variadics.
 }
 

diff  --git a/clang-tools-extra/clangd/unittests/HoverTests.cpp 
b/clang-tools-extra/clangd/unittests/HoverTests.cpp
index 9b6f2b185bf4..67257bac6398 100644
--- a/clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ b/clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -327,7 +327,6 @@ class Foo {})cpp";
  HI.Name = "X";
  HI.LocalScope = "X::"; // FIXME: X::
  HI.Kind = index::SymbolKind::Constructor;
- HI.ReturnType = "X";
  HI.Definition = "X()";
  HI.Parameters.emplace();
}},
@@ -337,10 +336,18 @@ class Foo {})cpp";
  HI.Name = "~X";
  HI.LocalScope = "X::";
  HI.Kind = index::SymbolKind::Destructor;
- HI.ReturnType = "void";
  HI.Definition = "~X()";
  HI.Parameters.emplace();
}},
+  {"class X { operator [[in^t]](); };",
+   [](HoverInfo &HI) {
+ HI.NamespaceScope = "";
+ HI.Name = "operator int";
+ HI.LocalScope = "X::";
+ HI.Kind = index::SymbolKind::ConversionFunction;
+ HI.Definition = "operator int()";
+ HI.Parameters.emplace();
+   }},
 
   // auto on lambda
   {R"cpp(



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


[PATCH] D73101: [clangd] Do not duplicate TemplatedDecls in findExplicitReferences

2020-01-21 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/FindTarget.cpp:585
+  // We choose to only visit TemplatedDecls for {Class, Function, Var,
+  // TypeAlias} TemplateDecls. As DescribedTemplates are covering the same
+  // range, but contains the duplication of template parameters that are

It took me a  while to understand this comment, I think not everyone is very 
familiar with `TemplatedDecls` and `DescribedTemplates` terms, how about?

`Avoid reporting references from {Class,Function,Var,TypeAlias}TemplateDecls to 
avoid duplicated results, as we will report references from their underlying 
decls which have the same range.`



Comment at: clang-tools-extra/clangd/FindTarget.cpp:588
+  // already reported. Therefore we skip them here.
+  if (llvm::isa(ND))
+return;

I would check it more elaborately (to reflect the comment above).

```
if (llvm::isa(ND) || llvm::isa(ND)..)
  return
```

or using `ND->getKind()`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73101



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


[PATCH] D71227: [cuda][hip] Fix function overload resolution in the global initiailizer.

2020-01-21 Thread Michael Liao via Phabricator via cfe-commits
hliao updated this revision to Diff 239328.
hliao marked 2 inline comments as done.
hliao added a comment.

- revise comment.
- add tests requiring tempate instantiation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71227

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Sema/SemaCUDA.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/SemaCUDA/function-overload.cu
  clang/test/SemaCUDA/global-initializers-host.cu
  clang/test/SemaCUDA/hip-pinned-shadow.cu

Index: clang/test/SemaCUDA/hip-pinned-shadow.cu
===
--- clang/test/SemaCUDA/hip-pinned-shadow.cu
+++ clang/test/SemaCUDA/hip-pinned-shadow.cu
@@ -13,13 +13,19 @@
 
 template 
 struct texture : public textureReference {
+// expected-note@-1{{candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 0 were provided}}
+// expected-note@-2{{candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 0 were provided}}
+// expected-note@-3{{candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 0 were provided}}
+// expected-note@-4{{candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 0 were provided}}
 texture() { a = 1; }
+// expected-note@-1{{candidate constructor not viable: call to __host__ function from __device__ function}}
+// expected-note@-2{{candidate constructor not viable: call to __host__ function from __device__ function}}
 };
 
 __hip_pinned_shadow__ texture tex;
 __device__ __hip_pinned_shadow__ texture tex2; // expected-error{{'hip_pinned_shadow' and 'device' attributes are not compatible}}
-// expected-error@-1{{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables}}
-// expected-note@-2{{conflicting attribute is here}}
+// expected-note@-1{{conflicting attribute is here}}
+// expected-error@-2{{no matching constructor for initialization of 'texture'}}
 __constant__ __hip_pinned_shadow__ texture tex3; // expected-error{{'hip_pinned_shadow' and 'constant' attributes are not compatible}}
-  // expected-error@-1{{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables}}
-  // expected-note@-2{{conflicting attribute is here}}
+  // expected-note@-1{{conflicting attribute is here}}
+  // expected-error@-2{{no matching constructor for initialization of 'texture'}}
Index: clang/test/SemaCUDA/global-initializers-host.cu
===
--- clang/test/SemaCUDA/global-initializers-host.cu
+++ clang/test/SemaCUDA/global-initializers-host.cu
@@ -6,12 +6,14 @@
 // module initializer.
 
 struct S {
+  // expected-note@-1 {{candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 0 were provided}}
+  // expected-note@-2 {{candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 0 were provided}}
   __device__ S() {}
-  // expected-note@-1 {{'S' declared here}}
+  // expected-note@-1 {{candidate constructor not viable: call to __device__ function from __host__ function}}
 };
 
 S s;
-// expected-error@-1 {{reference to __device__ function 'S' in global initializer}}
+// expected-error@-1 {{no matching constructor for initialization of 'S'}}
 
 struct T {
   __host__ __device__ T() {}
@@ -19,14 +21,17 @@
 T t;  // No error, this is OK.
 
 struct U {
+  // expected-note@-1 {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int' to 'const U' for 1st argument}}
+  // expected-note@-2 {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'int' to 'U' for 1st argument}}
   __host__ U() {}
+  // expected-note@-1 {{candidate constructor not viable: requires 0 arguments, but 1 was provided}}
   __device__ U(int) {}
-  // expected-note@-1 {{'U' declared here}}
+  // expected-note@-1 {{candidate constructor not viable: call to __device__ function from __host__ function}}
 };
 U u(42);
-// expected-error@-1 {{reference to __device__ function 'U' in global initializer}}
+// expected-error@-1 {{no matching constructor for initialization of 'U'}}
 
 __device__ int device_fn() { return 42; }
-// expected-note@-1 {{'device_fn' declared here}

[PATCH] D73110: [clangd] Drop returntype/type when hovering over type-ish names

2020-01-21 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1fbb1d6df011: [clangd] Drop returntype/type when hovering 
over type-ish names (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73110

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -327,7 +327,6 @@
  HI.Name = "X";
  HI.LocalScope = "X::"; // FIXME: X::
  HI.Kind = index::SymbolKind::Constructor;
- HI.ReturnType = "X";
  HI.Definition = "X()";
  HI.Parameters.emplace();
}},
@@ -337,10 +336,18 @@
  HI.Name = "~X";
  HI.LocalScope = "X::";
  HI.Kind = index::SymbolKind::Destructor;
- HI.ReturnType = "void";
  HI.Definition = "~X()";
  HI.Parameters.emplace();
}},
+  {"class X { operator [[in^t]](); };",
+   [](HoverInfo &HI) {
+ HI.NamespaceScope = "";
+ HI.Name = "operator int";
+ HI.LocalScope = "X::";
+ HI.Kind = index::SymbolKind::ConversionFunction;
+ HI.Definition = "operator int()";
+ HI.Parameters.emplace();
+   }},
 
   // auto on lambda
   {R"cpp(
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -266,20 +266,19 @@
 }
   }
 
-  if (const auto *CCD = llvm::dyn_cast(FD)) {
-// Constructor's "return type" is the class type.
-HI.ReturnType = declaredType(CCD->getParent()).getAsString(Policy);
-// Don't provide any type for the constructor itself.
-  } else if (llvm::isa(FD)) {
-HI.ReturnType = "void";
-  } else {
-HI.ReturnType = printType(FD->getReturnType(), Policy);
+  // We don't want any type info, if name already contains it. This is true for
+  // constructors/destructors and conversion operators.
+  const auto NK = FD->getDeclName().getNameKind();
+  if (NK == DeclarationName::CXXConstructorName ||
+  NK == DeclarationName::CXXDestructorName ||
+  NK == DeclarationName::CXXConversionFunctionName)
+return;
 
-QualType QT = FD->getType();
-if (const VarDecl *VD = llvm::dyn_cast(D)) // Lambdas
-  QT = VD->getType().getDesugaredType(D->getASTContext());
-HI.Type = printType(QT, Policy);
-  }
+  HI.ReturnType = printType(FD->getReturnType(), Policy);
+  QualType QT = FD->getType();
+  if (const VarDecl *VD = llvm::dyn_cast(D)) // Lambdas
+QT = VD->getType().getDesugaredType(D->getASTContext());
+  HI.Type = printType(QT, Policy);
   // FIXME: handle variadics.
 }
 


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -327,7 +327,6 @@
  HI.Name = "X";
  HI.LocalScope = "X::"; // FIXME: X::
  HI.Kind = index::SymbolKind::Constructor;
- HI.ReturnType = "X";
  HI.Definition = "X()";
  HI.Parameters.emplace();
}},
@@ -337,10 +336,18 @@
  HI.Name = "~X";
  HI.LocalScope = "X::";
  HI.Kind = index::SymbolKind::Destructor;
- HI.ReturnType = "void";
  HI.Definition = "~X()";
  HI.Parameters.emplace();
}},
+  {"class X { operator [[in^t]](); };",
+   [](HoverInfo &HI) {
+ HI.NamespaceScope = "";
+ HI.Name = "operator int";
+ HI.LocalScope = "X::";
+ HI.Kind = index::SymbolKind::ConversionFunction;
+ HI.Definition = "operator int()";
+ HI.Parameters.emplace();
+   }},
 
   // auto on lambda
   {R"cpp(
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -266,20 +266,19 @@
 }
   }
 
-  if (const auto *CCD = llvm::dyn_cast(FD)) {
-// Constructor's "return type" is the class type.
-HI.ReturnType = declaredType(CCD->getParent()).getAsString(Policy);
-// Don't provide any type for the constructor itself.
-  } else if (llvm::isa(FD)) {
-HI.ReturnType = "void";
-  } else {
-HI.ReturnType = printType(FD->getReturnType(), Policy);
+  // We don't want any type info, if name already contains it. This is true for
+  // constructors/destructors and conversion operators.
+  const auto NK = FD->getDeclName().getNameKind();
+  if (NK == DeclarationName::CXXConstructorName ||
+  NK == DeclarationName::CXXDestructorName ||
+  NK == DeclarationName::CXXCon

[PATCH] D71227: [cuda][hip] Fix function overload resolution in the global initiailizer.

2020-01-21 Thread Michael Liao via Phabricator via cfe-commits
hliao marked 2 inline comments as done.
hliao added a comment.

Sorry for the late reply. Really appreciate your feedback. Thanks!




Comment at: clang/include/clang/Sema/Sema.h:11198-11206
+  SmallVector CUDANonLocalVariableStack;
+
+  void pushCUDANonLocalVariable(const Decl *D);
+  void popCUDANonLocalVariable(const Decl *D);
+
+  const Decl *getCUDACurrentNonLocalVariable() const {
+return CUDANonLocalVariableStack.empty() ? nullptr

rsmith wrote:
> Does this really need to be CUDA-specific?
> 
> This is (at least) the third time we've needed this. We currently have a 
> `ManglingContextDecl` on `ExpressionEvaluationContextRecord` that tracks the 
> non-local variable whose initializer we're parsing. In addition to using this 
> as a lambda context declaration, we also (hackily) use it as the context 
> declaration for `DiagRuntimeBehavior`. It would seem sensible to use that 
> mechanism here too (and rename it to remove any suggestion that this is 
> specific to lambdas or mangling).
> 
> I think we only currently push `ExpressionEvaluationContext`s for variable 
> initializers in C++. That's presumably fine for CUDA's purposes.
I tried that before adding the new non-local variable stack. Using 
`ManglingContextDecl` on `ExpressionEvaluationContextRecord` could serve some 
cases, but it cannot fit the case where the constructor needs resolving as 
well. When resolving the constructor, `ManglingContextDecl` scope is already 
closed and cannot be used to check the target of the global variables. Says the 
following code

```
struct EC {
  int ec;
__device__ EC() {}
};
__device__ EC d_ec;
```

I also tried enlarging the scope of `ManglingContextDecl` but that triggers 
even more issues for the generic C++ compilation. I'd appreciate any better 
solution as I agree that adding CUDA specific facilities should be minimized.



Comment at: clang/lib/Parse/ParseDecl.cpp:2336
 
+  Actions.pushCUDANonLocalVariable(ThisDecl);
+

rsmith wrote:
> tra wrote:
> > @rsmith -- is this sufficient to catch all attempts to call an initializer 
> > for a global?
> > I wonder if there are other sneaky ways to call an initializer. 
> No, this is not sufficient; it's missing (at least) the template 
> instantiation case. (The `ExpressionEvaluationContextRecord` mechanism does 
> handle that case properly.)
> 
> You should also consider what should happen in default arguments (which are 
> sometimes parsed before we form a `FunctionDecl` for the function for which 
> they are parameters) and default member initializers (which are parsed after 
> we know whether the enclosing class has a user-declared default constructor, 
> so you could in principle consider the CUDA function kind of the declared 
> constructors, I suppose -- but the constructor bodies are not yet available, 
> so you can't tell which constructors would actually use the initializers). 
> Both of those cases are also tracked by the 
> `ExpressionEvaluationContextRecord` mechanism, though you may need to track 
> additional information to process default arguments in the same mode as the 
> function for which they are supplied.
Could you elaborate more? I added new test cases requiring template 
instantiation. The current code handle them correctly. Do you refer to template 
variables?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71227



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


[PATCH] D73108: [docs][mips] 10.0 Release notes

2020-01-21 Thread Miloš Stojanović via Phabricator via cfe-commits
mstojanovic added a comment.

Initial MIPS support was also added to `llvm-exegesis`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73108



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


[PATCH] D73108: [docs][mips] 10.0 Release notes

2020-01-21 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan added a comment.

In D73108#1831442 , @mstojanovic wrote:

> Initial MIPS support was also added to `llvm-exegesis`.


Oh, sorry. Good point, I'll add this note.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73108



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


[PATCH] D73108: [docs][mips] 10.0 Release notes

2020-01-21 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan updated this revision to Diff 239333.
atanasyan added a reviewer: mbrkusanin.
atanasyan added a comment.

- Add `llvm-exegesis` note.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73108

Files:
  clang/docs/ReleaseNotes.rst
  lld/docs/ReleaseNotes.rst
  llvm/docs/ReleaseNotes.rst


Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -122,8 +122,22 @@
 Changes to the MIPS Target
 --
 
- During this release ...
-
+* Improved support for ``octeon`` and added support for ``octeon+``
+  MIPS-family CPU.
+* ``min``, ``max``, ``umin``, ``umax`` atomics now supported on MIPS targets.
+* Now PC-relative relocations are generated for ``.eh_frame`` sections when
+  possible. That allows to link MIPS binaries without having to pass the
+  ``-Wl,-z,notext`` option.
+* Fix evaluating J-format branch (``j``, ``jal``, ...) targets when the
+  instruction is not in the first 256 MB region.
+* Fixed ``jal``, ``sc``, ``scs``, ``ll``, ``lld``, ``la``, ``lw``, ``sw``
+  instructions expanding. Now they accept more types of expression as 
arguments,
+  correctly handle load/store for ``XGOT`` model, expand using less 
instructions
+  or registers.
+* Initial MIPS support has been added to ``llvm-exegesis``.
+* Generates ``_mcount`` calls using proper MIPS ABI.
+* Improved support of GlobalISel instruction selection framework. This feature
+  is still in experimental state for MIPS targets though.
 
 Changes to the PowerPC Target
 -
Index: lld/docs/ReleaseNotes.rst
===
--- lld/docs/ReleaseNotes.rst
+++ lld/docs/ReleaseNotes.rst
@@ -30,6 +30,14 @@
   with GNU now. (`r375051
   
`_)
 
+* New ``elf32btsmipn32_fbsd`` and ``elf32ltsmipn32_fbsd`` emulations
+  are supported.
+
+* Relax MIPS ``jalr``and ``jr`` instructions marked by the ``R_MIPS_JALR``
+  relocation.
+
+* Reduced size of linked MIPS binaries.
+
 COFF Improvements
 -
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -111,6 +111,9 @@
   In a future release of Clang, we intend to change the default to
   ``-fno-lax-vector-conversions``.
 
+* Improved support for ``octeon`` MIPS-family CPU. Added ``octeon+`` to
+  the list of of CPUs accepted by the driver.
+
 New Compiler Flags
 --
 


Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -122,8 +122,22 @@
 Changes to the MIPS Target
 --
 
- During this release ...
-
+* Improved support for ``octeon`` and added support for ``octeon+``
+  MIPS-family CPU.
+* ``min``, ``max``, ``umin``, ``umax`` atomics now supported on MIPS targets.
+* Now PC-relative relocations are generated for ``.eh_frame`` sections when
+  possible. That allows to link MIPS binaries without having to pass the
+  ``-Wl,-z,notext`` option.
+* Fix evaluating J-format branch (``j``, ``jal``, ...) targets when the
+  instruction is not in the first 256 MB region.
+* Fixed ``jal``, ``sc``, ``scs``, ``ll``, ``lld``, ``la``, ``lw``, ``sw``
+  instructions expanding. Now they accept more types of expression as arguments,
+  correctly handle load/store for ``XGOT`` model, expand using less instructions
+  or registers.
+* Initial MIPS support has been added to ``llvm-exegesis``.
+* Generates ``_mcount`` calls using proper MIPS ABI.
+* Improved support of GlobalISel instruction selection framework. This feature
+  is still in experimental state for MIPS targets though.
 
 Changes to the PowerPC Target
 -
Index: lld/docs/ReleaseNotes.rst
===
--- lld/docs/ReleaseNotes.rst
+++ lld/docs/ReleaseNotes.rst
@@ -30,6 +30,14 @@
   with GNU now. (`r375051
   `_)
 
+* New ``elf32btsmipn32_fbsd`` and ``elf32ltsmipn32_fbsd`` emulations
+  are supported.
+
+* Relax MIPS ``jalr``and ``jr`` instructions marked by the ``R_MIPS_JALR``
+  relocation.
+
+* Reduced size of linked MIPS binaries.
+
 COFF Improvements
 -
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -111,6 +111,9 @@
   In a future release of Clang, we intend to change the default to
   ``-fno-lax-vector-conversions``.
 
+* Improved support for ``octeon`` MIPS-family CPU. Added ``octeon+`` to
+  the list of of CPUs 

[PATCH] D72857: [SYCL] Driver option to enable SYCL mode and select SYCL version

2020-01-21 Thread Ruyman via Phabricator via cfe-commits
Ruyk added a comment.

Maybe we should use the year of issue (2015 instead of 1.2.1) for the -sycl-std 
version? That would be more stable for the upcoming SYCL versions, and match 
somehow the C++ versioning.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72857



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


  1   2   3   >