[PATCH] D73651: [OpenCL][CUDA][HIP][SYCL] Add norecurse

2020-01-30 Thread Alexey Bader via Phabricator via cfe-commits
bader accepted this revision.
bader added a comment.

Thanks!


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

https://reviews.llvm.org/D73651



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


[PATCH] D73543: [clang] Add support for __builtin_memcpy_inline

2020-01-30 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet updated this revision to Diff 241356.
gchatelet added a comment.

rebasing


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73543

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/Builtins.def
  clang/lib/CodeGen/CGBuilder.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-memcpy-inline.c
  clang/test/Sema/builtins-memcpy-inline.c
  llvm/include/llvm/IR/IRBuilder.h
  llvm/lib/IR/IRBuilder.cpp

Index: llvm/lib/IR/IRBuilder.cpp
===
--- llvm/lib/IR/IRBuilder.cpp
+++ llvm/lib/IR/IRBuilder.cpp
@@ -200,6 +200,30 @@
   return CI;
 }
 
+CallInst *IRBuilderBase::CreateMemCpyInline(Value *Dst, MaybeAlign DstAlign,
+Value *Src, MaybeAlign SrcAlign,
+Value *Size) {
+  Dst = getCastedInt8PtrValue(Dst);
+  Src = getCastedInt8PtrValue(Src);
+  Value *IsVolatile = getInt1(false);
+
+  Value *Ops[] = {Dst, Src, Size, IsVolatile};
+  Type *Tys[] = {Dst->getType(), Src->getType(), Size->getType()};
+  Function *F = BB->getParent();
+  Module *M = F->getParent();
+  Function *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memcpy_inline, Tys);
+
+  CallInst *CI = createCallHelper(TheFn, Ops, this);
+
+  auto *MCI = cast(CI);
+  if (DstAlign)
+MCI->setDestAlignment(*DstAlign);
+  if (SrcAlign)
+MCI->setSourceAlignment(*SrcAlign);
+
+  return CI;
+}
+
 CallInst *IRBuilderBase::CreateElementUnorderedAtomicMemCpy(
 Value *Dst, Align DstAlign, Value *Src, Align SrcAlign, Value *Size,
 uint32_t ElementSize, MDNode *TBAATag, MDNode *TBAAStructTag,
Index: llvm/include/llvm/IR/IRBuilder.h
===
--- llvm/include/llvm/IR/IRBuilder.h
+++ llvm/include/llvm/IR/IRBuilder.h
@@ -560,6 +560,9 @@
  MDNode *ScopeTag = nullptr,
  MDNode *NoAliasTag = nullptr);
 
+  CallInst *CreateMemCpyInline(Value *Dst, MaybeAlign DstAlign, Value *Src,
+   MaybeAlign SrcAlign, Value *Size);
+
   /// Create and insert an element unordered-atomic memcpy between the
   /// specified pointers.
   ///
Index: clang/test/Sema/builtins-memcpy-inline.c
===
--- /dev/null
+++ clang/test/Sema/builtins-memcpy-inline.c
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#define NULL ((char *)0)
+
+#if __has_feature(__builtin_memcpy_inline)
+#warning defined as expected
+// expected-warning@-1 {{defined as expected}}
+#endif
+
+void test_memcpy_inline_null_src(void *ptr) {
+  __builtin_memcpy_inline(ptr, NULL, 4); // expected-warning {{null passed to a callee that requires a non-null argument}}
+}
+
+void test_memcpy_inline_null_dst(void *ptr) {
+  __builtin_memcpy_inline(NULL, ptr, 4); // expected-warning {{null passed to a callee that requires a non-null argument}}
+}
+
+void test_memcpy_inline_null_buffers() {
+  __builtin_memcpy_inline(NULL, NULL, 4);
+  // expected-warning@-1 {{null passed to a callee that requires a non-null argument}}
+  // expected-warning@-2 {{null passed to a callee that requires a non-null argument}}
+}
+
+void test_memcpy_inline_null_buffer_is_ok_if_size_is_zero(void *ptr) {
+  __builtin_memcpy_inline(ptr, NULL, /*size */ 0);
+  __builtin_memcpy_inline(NULL, ptr, /*size */ 0);
+  __builtin_memcpy_inline(NULL, NULL, /*size */ 0);
+}
+
+void test_memcpy_inline_non_constant_size(void *dst, const void *src, unsigned size) {
+  __builtin_memcpy_inline(dst, src, size); // expected-error {{expression is not an integer constant expression}}
+}
Index: clang/test/CodeGen/builtins-memcpy-inline.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-memcpy-inline.c
@@ -0,0 +1,26 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -emit-llvm %s -o - | FileCheck %s
+
+// CHECK-LABEL: define void @test_memcpy_inline_0(i8* %dst, i8* %src)
+void test_memcpy_inline_0(void *dst, const void *src) {
+  // CHECK:   call void @llvm.memcpy.inline.p0i8.p0i8.i64(i8* align 1 %0, i8* align 1 %1, i64 0, i1 false)
+  __builtin_memcpy_inline(dst, src, 0);
+}
+
+// CHECK-LABEL: define void @test_memcpy_inline_1(i8* %dst, i8* %src)
+void test_memcpy_inline_1(void *dst, const void *src) {
+  // CHECK:   call void @llvm.memcpy.inline.p0i8.p0i8.i64(i8* align 1 %0, i8* align 1 %1, i64 1, i1 false)
+  __builtin_memcpy_inline(dst, src, 1);
+}
+
+// CHECK-LABEL: define void @test_memcpy_inline_4(i8* %dst, i8* %src)
+void test_memcpy_inline_4(void *dst, const void *src) {
+  // CHECK:   call void @llvm.memcpy.inline.p0i8.p0i8.i64(i8* align 1 %0, i8* align 1 %1, i64 4, i1 false)
+  __builtin_memcpy_inline(dst, src, 4);
+}
+
+// CHECK-LABEL: define void @te

[PATCH] D73543: [clang] Add support for __builtin_memcpy_inline

2020-01-30 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet added a comment.

@efriedma would you mind having a look?
It should be my last patch on that matter :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73543



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


[PATCH] D70818: [Analyzer] Model STL Algoirthms to improve the iterator checkers

2020-01-30 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 241364.
baloghadamsoftware added a comment.

Rebased.


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

https://reviews.llvm.org/D70818

Files:
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  clang/lib/StaticAnalyzer/Checkers/Iterator.cpp
  clang/lib/StaticAnalyzer/Checkers/Iterator.h
  clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/STLAlgorithmModeling.cpp
  clang/test/Analysis/Inputs/system-header-simulator-cxx.h
  clang/test/Analysis/stl-algorithm-modeling.cpp

Index: clang/test/Analysis/stl-algorithm-modeling.cpp
===
--- /dev/null
+++ clang/test/Analysis/stl-algorithm-modeling.cpp
@@ -0,0 +1,481 @@
+// RUN: %clang_analyze_cc1 -std=c++17 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorModeling,debug.DebugIteratorModeling,optin.cplusplus.STLAlgorithmModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true %s -verify
+
+#include "Inputs/system-header-simulator-cxx.h"
+
+void clang_analyzer_eval(bool);
+
+template 
+long clang_analyzer_iterator_position(const Iterator&);
+
+template  Iter return_any_iterator(const Iter &It);
+
+void test_find1(std::vector V, int n) {
+  const auto i1 = return_any_iterator(V.begin());
+  const auto i2 = return_any_iterator(V.begin());
+
+  const auto i3 = std::find(i1, i2, n);
+
+  clang_analyzer_eval(i3 == i2); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+
+  if (i3 != i2) {
+clang_analyzer_eval(clang_analyzer_iterator_position(i3) <
+clang_analyzer_iterator_position(i2)); // expected-warning@-1{{TRUE}}
+clang_analyzer_eval(clang_analyzer_iterator_position(i3) >=
+clang_analyzer_iterator_position(i2)); // expected-warning@-1{{FALSE}}
+  }
+}
+
+void test_find2(std::vector V, int n) {
+  const auto i1 = return_any_iterator(V.begin());
+  const auto i2 = return_any_iterator(V.begin());
+
+  const auto i3 = std::find(std::execution::sequenced_policy(), i1, i2, n);
+
+  clang_analyzer_eval(i3 == i2); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+
+  if (i3 != i2) {
+clang_analyzer_eval(clang_analyzer_iterator_position(i3) <
+clang_analyzer_iterator_position(i2)); // expected-warning@-1{{TRUE}}
+clang_analyzer_eval(clang_analyzer_iterator_position(i3) >=
+clang_analyzer_iterator_position(i2)); // expected-warning@-1{{FALSE}}
+  }
+}
+
+bool odd(int i) { return i % 2; }
+
+void test_find_if1(std::vector V) {
+  const auto i1 = return_any_iterator(V.begin());
+  const auto i2 = return_any_iterator(V.begin());
+
+  const auto i3 = std::find_if(i1, i2, odd);
+
+  clang_analyzer_eval(i3 == i2); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+
+  if (i3 != i2) {
+clang_analyzer_eval(clang_analyzer_iterator_position(i3) <
+clang_analyzer_iterator_position(i2)); // expected-warning@-1{{TRUE}}
+clang_analyzer_eval(clang_analyzer_iterator_position(i3) >=
+clang_analyzer_iterator_position(i2)); // expected-warning@-1{{FALSE}}
+  }
+}
+
+void test_find_if2(std::vector V) {
+  const auto i1 = return_any_iterator(V.begin());
+  const auto i2 = return_any_iterator(V.begin());
+
+  const auto i3 = std::find_if(std::execution::sequenced_policy(), i1, i2, odd);
+
+  clang_analyzer_eval(i3 == i2); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+
+  if (i3 != i2) {
+clang_analyzer_eval(clang_analyzer_iterator_position(i3) <
+clang_analyzer_iterator_position(i2)); // expected-warning@-1{{TRUE}}
+clang_analyzer_eval(clang_analyzer_iterator_position(i3) >=
+clang_analyzer_iterator_position(i2)); // expected-warning@-1{{FALSE}}
+  }
+}
+
+void test_find_if_not1(std::vector V) {
+  const auto i1 = return_any_iterator(V.begin());
+  const auto i2 = return_any_iterator(V.begin());
+
+  const auto i3 = std::find_if_not(i1, i2, odd);
+
+  clang_analyzer_eval(i3 == i2); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+
+  if (i3 != i2) {
+clang_analyzer_eval(clang_analyzer_iterator_position(i3) <
+clang_analyzer_iterator_position(i2)); // expected-warning@-1{{TRUE}}
+clang_analyzer_eval(clang_analyzer_iterator_position(i3) >=
+clang_analyzer_iterator_position(i2)); // expected-warning@-1{{FALSE}}
+  }
+}
+
+void test_find_if_not2(std::vector V) {
+  const auto i1 = return_any_iterator(V.begin());
+  const auto i2 = return_any_iterator(V.begin());
+
+  const auto i3 = std::find_if_not(std::execution::sequenced_policy(), i1, i2,
+   odd);
+
+  clang_analyzer_eval(i3 == i2); // expected-warning{{TRUE}} expected-warning{{FALSE}}
+
+  if (i3 != i2) {
+clang_analyzer_eval(clang_analyze

[PATCH] D72362: [clang-tidy] misc-no-recursion: a new check

2020-01-30 Thread Alexey Bader via Phabricator via cfe-commits
bader added a comment.

@lebedev.ri, thanks for the suggestion. We will investigate this option when we 
ready to upload clang diagnostics patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72362



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


[PATCH] D73548: [clang-tidy] Added option for disabling const qualifiers in readability-qualified-auto

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

- Streamline fixits
- Add documentation about double pointers, maybe a follow up patch to fix


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73548

Files:
  clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
  clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp
  clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-qualified-auto.rst
  clang-tools-extra/test/clang-tidy/checkers/llvm-qualified-auto.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/llvm-qualified-auto.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/llvm-qualified-auto.cpp
@@ -0,0 +1,21 @@
+// RUN: %check_clang_tidy %s llvm-qualified-auto %t
+
+// This check just ensures by default the llvm alias doesn't add const
+// qualifiers to decls, so no need to copy the entire test file from
+// readability-qualified-auto.
+
+int *getIntPtr();
+const int *getCIntPtr();
+
+void foo() {
+  auto NakedPtr = getIntPtr();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'auto NakedPtr' can be declared as 'auto *NakedPtr'
+  // CHECK-FIXES: {{^}}  auto *NakedPtr = getIntPtr();
+  auto NakedConstPtr = getCIntPtr();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'auto NakedConstPtr' can be declared as 'const auto *NakedConstPtr'
+  // CHECK-FIXES: {{^}}  const auto *NakedConstPtr = getCIntPtr();
+  auto *Ptr = getIntPtr();
+  auto *ConstPtr = getCIntPtr();
+  auto &NakedRef = *getIntPtr();
+  auto &NakedConstRef = *getCIntPtr();
+}
Index: clang-tools-extra/docs/clang-tidy/checks/readability-qualified-auto.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/readability-qualified-auto.rst
+++ clang-tools-extra/docs/clang-tidy/checks/readability-qualified-auto.rst
@@ -3,23 +3,16 @@
 readability-qualified-auto
 ==
 
-Adds pointer and ``const`` qualifications to ``auto``-typed variables that are deduced
-to pointers and ``const`` pointers.
+Adds pointer qualifications to ``auto``-typed variables that are deduced to 
+pointers.
 
-`LLVM Coding Standards `_ advises to
-make it obvious if a ``auto`` typed variable is a pointer, constant pointer or 
-constant reference. This check will transform ``auto`` to ``auto *`` when the 
-type is deduced to be a pointer, as well as adding ``const`` when applicable to
-``auto`` pointers or references
+`LLVM Coding Standards `_
+advises to make it obvious if a ``auto`` typed variable is a pointer. This 
+check will transform ``auto`` to ``auto *`` when the type is deduced to be a
+pointer.
 
 .. code-block:: c++
 
-  for (auto &Data : MutatableContainer) {
-change(Data);
-  }
-  for (auto &Data : ConstantContainer) {
-observe(Data);
-  }
   for (auto Data : MutatablePtrContainer) {
 change(*Data);
   }
@@ -31,12 +24,6 @@
 
 .. code-block:: c++
 
-  for (auto &Data : MutatableContainer) {
-change(Data);
-  }
-  for (const auto &Data : ConstantContainer) {
-observe(Data);
-  }
   for (auto *Data : MutatablePtrContainer) {
 change(*Data);
   }
@@ -44,21 +31,54 @@
 observe(*Data);
   }
 
-Note const volatile qualified types will retain their const and volatile qualifiers.
+Note ``const`` ``volatile`` qualified types will retain their ``const`` and 
+``volatile`` qualifiers. Pointers to pointers will not be fully qualified.
 
 .. code-block:: c++
 
-  const auto Foo = cast(Baz1);
-  const auto Bar = cast(Baz2);
-  volatile auto FooBar = cast(Baz3);
+   const auto Foo = cast(Baz1);
+   const auto Bar = cast(Baz2);
+   volatile auto FooBar = cast(Baz3);
+   auto BarFoo = cast(Baz4);
 
 Would be transformed into:
 
 .. code-block:: c++
 
-  auto *const Foo = cast(Baz1);
-  const auto *const Bar = cast(Baz2);
-  auto *volatile FooBar = cast(Baz3);
+   auto *const Foo = cast(Baz1);
+   const auto *const Bar = cast(Baz2);
+   auto *volatile FooBar = cast(Baz3);
+   auto *BarFoo = cast(Baz4);
+
+Options
+---
+
+.. option:: AddConstToQualified
+   
+   When set to `1` the check will add const qualifiers variables defined as
+   ``auto *`` or ``auto &`` when applicable.
+   Default value is '1'.
+
+.. code-block:: c++
+
+   auto Foo1 = cast(Bar1);
+   auto *Foo2 = cast(Bar2);
+   auto &Foo3 = cast(Bar3);
+
+   If AddConstToQualified is set to `0`,  it will be transformed into:
+
+.. code-block:: c++
+
+   const auto *Foo1 = cast(Bar1);
+   auto *Foo2 = cast(Bar2);
+   auto &Foo3 = cast(Bar3);
+
+   Otherwise it will be transformed into:
+
+.. code-block:: c++
+
+   const auto *Foo1 = cast(Bar1);
+   const auto *Foo2 = cast(Bar2);
+   const aut

[clang] a156a0e - [ASTMatchers] Add hasPlacementArg and hasAnyPlacementArg traversal matcher for CXXNewExpr

2020-01-30 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-01-30T10:16:04Z
New Revision: a156a0e28df4751f812c84437321339c2eb33af3

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

LOG: [ASTMatchers] Add hasPlacementArg and hasAnyPlacementArg traversal matcher 
for CXXNewExpr

Summary: Adds new traversal matchers called `hasPlacementArg` and 
`hasAnyPlacementArg` that matches on arguments to `placement new` operators.

Reviewers: aaron.ballman

Reviewed By: aaron.ballman

Subscribers: merge_guards_bot, mehdi_amini, hiraditya, steven_wu, dexonsmith, 
cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/cert/DefaultOperatorNewAlignmentCheck.cpp
clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
clang/docs/LibASTMatchersReference.html
clang/include/clang/ASTMatchers/ASTMatchers.h
clang/lib/ASTMatchers/Dynamic/Registry.cpp
clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/cert/DefaultOperatorNewAlignmentCheck.cpp 
b/clang-tools-extra/clang-tidy/cert/DefaultOperatorNewAlignmentCheck.cpp
index 48eee8e6949d..749b8f192aeb 100644
--- a/clang-tools-extra/clang-tidy/cert/DefaultOperatorNewAlignmentCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cert/DefaultOperatorNewAlignmentCheck.cpp
@@ -16,16 +16,13 @@ namespace clang {
 namespace tidy {
 namespace cert {
 
-AST_MATCHER(CXXNewExpr, isPlacementNew) {
-  return Node.getNumPlacementArgs() > 0;
-}
-
 void DefaultOperatorNewAlignmentCheck::registerMatchers(MatchFinder *Finder) {
   // Check not applicable in C++17 (or newer).
   if (getLangOpts().CPlusPlus17)
 return;
 
-  Finder->addMatcher(cxxNewExpr(unless(isPlacementNew())).bind("new"), this);
+  Finder->addMatcher(
+  cxxNewExpr(unless(hasAnyPlacementArg(anything(.bind("new"), this);
 }
 
 void DefaultOperatorNewAlignmentCheck::check(

diff  --git a/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
index 12d3f6290394..20a7c45c7cbc 100644
--- a/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -84,6 +84,8 @@ void 
MakeSmartPtrCheck::registerMatchers(ast_matchers::MatchFinder *Finder) {
   auto CanCallCtor = unless(has(ignoringImpCasts(
   cxxConstructExpr(hasDeclaration(decl(unless(isPublic(;
 
+  auto IsPlacement = hasAnyPlacementArg(anything());
+
   Finder->addMatcher(
   cxxBindTemporaryExpr(has(ignoringParenImpCasts(
   cxxConstructExpr(
@@ -91,7 +93,7 @@ void 
MakeSmartPtrCheck::registerMatchers(ast_matchers::MatchFinder *Finder) {
   hasArgument(0,
   
cxxNewExpr(hasType(pointsTo(qualType(hasCanonicalType(
  equalsBoundNode(PointerType),
- CanCallCtor)
+ CanCallCtor, unless(IsPlacement))
   .bind(NewExpression)),
   unless(isInTemplateInstantiation()))
   .bind(ConstructorCall,
@@ -101,7 +103,9 @@ void 
MakeSmartPtrCheck::registerMatchers(ast_matchers::MatchFinder *Finder) {
   cxxMemberCallExpr(
   thisPointerType(getSmartPointerTypeMatcher()),
   callee(cxxMethodDecl(hasName("reset"))),
-  hasArgument(0, cxxNewExpr(CanCallCtor).bind(NewExpression)),
+  hasArgument(
+  0,
+  cxxNewExpr(CanCallCtor, 
unless(IsPlacement)).bind(NewExpression)),
   unless(isInTemplateInstantiation()))
   .bind(ResetCall),
   this);
@@ -119,8 +123,6 @@ void MakeSmartPtrCheck::check(const 
MatchFinder::MatchResult &Result) {
   const auto *Type = Result.Nodes.getNodeAs(PointerType);
   const auto *New = Result.Nodes.getNodeAs(NewExpression);
 
-  if (New->getNumPlacementArgs() != 0)
-return;
   // Skip when this is a new-expression with `auto`, e.g. new auto(1)
   if (New->getType()->getPointeeType()->getContainedAutoType())
 return;

diff  --git a/clang/docs/LibASTMatchersReference.html 
b/clang/docs/LibASTMatchersReference.html
index 907353d1d9bb..95328dcd82eb 100644
--- a/clang/docs/LibASTMatchersReference.html
+++ b/clang/docs/LibASTMatchersReference.html
@@ -5311,6 +5311,16 @@ AST Traversal Matchers
 
 
 
+MatcherCXXNewExpr>hasAnyPlacementArgMatcherExpr> 
InnerMatcher
+Matches any 
placement new expression arguments.
+
+Given:
+  MyClass *p1 = new (Storage) MyClass();
+cxxNewExpr(hasAnyPlacementArg(anything()))
+  matches the expression 'new (Storage, 16) 

[PATCH] D73562: [ASTMatchers] Add hasPlacementArg and hasAnyPlacementArg traversal matcher for CXXNewExpr

2020-01-30 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa156a0e28df4: [ASTMatchers] Add hasPlacementArg and 
hasAnyPlacementArg traversal matcher for… (authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73562

Files:
  clang-tools-extra/clang-tidy/cert/DefaultOperatorNewAlignmentCheck.cpp
  clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -3124,5 +3124,45 @@
   EXPECT_TRUE(notMatches("template class A {};", Matcher));
 }
 
+TEST(CXXNewExpr, Array) {
+  StatementMatcher NewArray = cxxNewExpr(isArray());
+
+  EXPECT_TRUE(matches("void foo() { int *Ptr = new int[10]; }", NewArray));
+  EXPECT_TRUE(notMatches("void foo() { int *Ptr = new int; }", NewArray));
+
+  StatementMatcher NewArraySize10 =
+  cxxNewExpr(hasArraySize(integerLiteral(equals(10;
+  EXPECT_TRUE(
+  matches("void foo() { int *Ptr = new int[10]; }", NewArraySize10));
+  EXPECT_TRUE(
+  notMatches("void foo() { int *Ptr = new int[20]; }", NewArraySize10));
+}
+
+TEST(CXXNewExpr, PlacementArgs) {
+  StatementMatcher IsPlacementNew = cxxNewExpr(hasAnyPlacementArg(anything()));
+
+  EXPECT_TRUE(matches(R"(
+void* operator new(decltype(sizeof(void*)), void*); 
+int *foo(void* Storage) {
+  return new (Storage) int; 
+})",
+  IsPlacementNew));
+
+  EXPECT_TRUE(matches(R"(
+void* operator new(decltype(sizeof(void*)), void*, unsigned); 
+int *foo(void* Storage) {
+  return new (Storage, 16) int; 
+})",
+  cxxNewExpr(hasPlacementArg(
+  1, ignoringImpCasts(integerLiteral(equals(16)));
+
+  EXPECT_TRUE(notMatches(R"(
+void* operator new(decltype(sizeof(void*)), void*); 
+int *foo(void* Storage) {
+  return new int; 
+})",
+ IsPlacementNew));
+}
+
 } // namespace ast_matchers
 } // namespace clang
Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -243,6 +243,7 @@
   REGISTER_MATCHER(hasAnyDeclaration);
   REGISTER_MATCHER(hasAnyName);
   REGISTER_MATCHER(hasAnyParameter);
+  REGISTER_MATCHER(hasAnyPlacementArg);
   REGISTER_MATCHER(hasAnySelector);
   REGISTER_MATCHER(hasAnySubstatement);
   REGISTER_MATCHER(hasAnyTemplateArgument);
@@ -304,6 +305,7 @@
   REGISTER_MATCHER(hasReceiverType);
   REGISTER_MATCHER(hasReplacementType);
   REGISTER_MATCHER(hasReturnValue);
+  REGISTER_MATCHER(hasPlacementArg);
   REGISTER_MATCHER(hasSelector);
   REGISTER_MATCHER(hasSingleDecl);
   REGISTER_MATCHER(hasSize);
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -6783,6 +6783,35 @@
   return Node.isArray();
 }
 
+/// Matches placement new expression arguments.
+///
+/// Given:
+/// \code
+///   MyClass *p1 = new (Storage, 16) MyClass();
+/// \endcode
+/// cxxNewExpr(hasPlacementArg(1, integerLiteral(equals(16
+///   matches the expression 'new (Storage, 16) MyClass()'.
+AST_MATCHER_P2(CXXNewExpr, hasPlacementArg, unsigned, Index,
+   internal::Matcher, InnerMatcher) {
+  return Node.getNumPlacementArgs() > Index &&
+ InnerMatcher.matches(*Node.getPlacementArg(Index), Finder, Builder);
+}
+
+/// Matches any placement new expression arguments.
+///
+/// Given:
+/// \code
+///   MyClass *p1 = new (Storage) MyClass();
+/// \endcode
+/// cxxNewExpr(hasAnyPlacementArg(anything()))
+///   matches the expression 'new (Storage, 16) MyClass()'.
+AST_MATCHER_P(CXXNewExpr, hasAnyPlacementArg, internal::Matcher,
+  InnerMatcher) {
+  return llvm::any_of(Node.placement_arguments(), [&](const Expr *Arg) {
+return InnerMatcher.matches(*Arg, Finder, Builder);
+  });
+}
+
 /// Matches array new expressions with a given array size.
 ///
 /// Given:
Index: clang/docs/LibASTMatchersReference.html
===
--- clang/docs/LibASTMatchersReference.html
+++ clang/docs/LibASTMatchersReference.html
@@ -5311,6 +5311,16 @@
 
 
 
+MatcherCXXNewExpr>hasAnyPlacementArgMatcherExpr> InnerMatcher
+Matches 

[PATCH] D72717: [CMake] Disable libc++ filesystem tests in CrossWinToARMLinux cache file

2020-01-30 Thread Sergej Jaskiewicz via Phabricator via cfe-commits
broadwaylamb planned changes to this revision.
broadwaylamb added a comment.

In D72717#1848509 , @ldionne wrote:

> It's weird to mix Clang and libc++ test options because they test 
> fundamentally different things. But I don't mind about this patch since it 
> doesn't touch libc++ directly.


I understand that. This was supposed to be a temporary workaround.

I'm going to go with what @vvereschaka has proposed, although that will 
probably require some changes in libc++ CMake configuration.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72717



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


[clang-tools-extra] 9b71ec8 - [clangd][vscode] Get rid of the deprecated vscode module in the extension.

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

Author: Haojian Wu
Date: 2020-01-30T11:36:08+01:00
New Revision: 9b71ec899a1554210ec66756681c047a52866d39

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

LOG: [clangd][vscode] Get rid of the deprecated vscode module in the extension.

Summary:
The vscode module has been deprecated, and it doesn't work anymore after
we require the minimal VSCode version 1.41.0, this patch migrate to the
new @type/vscode and vscode-test modules, see
https://code.visualstudio.com/api/working-with-extensions/testing-extension#migrating-from-vscode

Reviewers: sammccall

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

Tags: #clang

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

Added: 
clang-tools-extra/clangd/clients/clangd-vscode/test/runTest.ts

Modified: 
clang-tools-extra/clangd/clients/clangd-vscode/package-lock.json
clang-tools-extra/clangd/clients/clangd-vscode/package.json
clang-tools-extra/clangd/clients/clangd-vscode/test/index.ts

Removed: 




diff  --git a/clang-tools-extra/clangd/clients/clangd-vscode/package-lock.json 
b/clang-tools-extra/clangd/clients/clangd-vscode/package-lock.json
index bbff586bbdca..ee69099568fd 100644
--- a/clang-tools-extra/clangd/clients/clangd-vscode/package-lock.json
+++ b/clang-tools-extra/clangd/clients/clangd-vscode/package-lock.json
@@ -4,181 +4,68 @@
 "lockfileVersion": 1,
 "requires": true,
 "dependencies": {
-"@types/mocha": {
-"version": "2.2.48",
-"resolved": 
"https://registry.npmjs.org/@types/mocha/-/mocha-2.2.48.tgz";,
-"integrity": 
"sha512-nlK/iyETgafGli8Zh9zJVCTicvU3iajSkRwOh3Hhiva598CMqNJ4NcVCGMTGKpGpTYj/9R8RLzS9NAykSSCqGw==",
-"dev": true
-},
-"@types/node": {
-"version": "6.14.2",
-"resolved": 
"https://registry.npmjs.org/@types/node/-/node-6.14.2.tgz";,
-"integrity": 
"sha512-JWB3xaVfsfnFY8Ofc9rTB/op0fqqTSqy4vBcVk1LuRJvta7KTX+D//fCkiTMeLGhdr2EbFZzQjC97gvmPilk9Q==",
-"dev": true
-},
-"ajv": {
-"version": "6.8.1",
-"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.8.1.tgz";,
-"integrity": 
"sha512-eqxCp82P+JfqL683wwsL73XmFs1eG6qjw+RD3YHx+Jll1r0jNd4dh8QG9NYAeNGA/hnZjeEDgtTskgJULbxpWQ==",
-"dev": true,
-"requires": {
-"fast-deep-equal": "^2.0.1",
-"fast-json-stable-stringify": "^2.0.0",
-"json-schema-traverse": "^0.4.1",
-"uri-js": "^4.2.2"
-}
-},
-"ansi-cyan": {
-"version": "0.1.1",
-"resolved": 
"https://registry.npmjs.org/ansi-cyan/-/ansi-cyan-0.1.1.tgz";,
-"integrity": "sha1-U4rlKK+JgvKK4w2G8vF0VtJgmHM=",
-"dev": true,
-"requires": {
-"ansi-wrap": "0.1.0"
-}
-},
-"ansi-red": {
-"version": "0.1.1",
-"resolved": 
"https://registry.npmjs.org/ansi-red/-/ansi-red-0.1.1.tgz";,
-"integrity": "sha1-jGOPnRCAgAo1PJwoyKgcpHBdlGw=",
-"dev": true,
-"requires": {
-"ansi-wrap": "0.1.0"
-}
-},
-"ansi-wrap": {
-"version": "0.1.0",
-"resolved": 
"https://registry.npmjs.org/ansi-wrap/-/ansi-wrap-0.1.0.tgz";,
-"integrity": "sha1-qCJQ3bABXponyoLoLqYDu/pF768=",
+"@types/events": {
+"version": "3.0.0",
+"resolved": 
"https://registry.npmjs.org/@types/events/-/events-3.0.0.tgz";,
+"integrity": 
"sha512-EaObqwIvayI5a8dCzhFrjKzVwKLxjoG9T6Ppd5CEo07LRKfQ8Yokw54r5+Wq7FaBQ+yXRvQAYPrHwya1/UFt9g==",
 "dev": true
 },
-"append-buffer": {
-"version": "1.0.2",
-"resolved": 
"https://registry.npmjs.org/append-buffer/-/append-buffer-1.0.2.tgz";,
-"integrity": "sha1-2CIM9GYIFSXv6lBhTz3mUU36WPE=",
-"dev": true,
-"requires": {
-"buffer-equal": "^1.0.0"
-}
-},
-"arr-
diff ": {
-"version": "1.1.0",
-"resolved": "https://registry.npmjs.org/arr-
diff /-/arr-
diff -1.1.0.tgz",
-"integrity": "sha1-aHwydYFjWI/vfeezb6vklesaOZo=",
+"@types/glob": {
+"version": "7.1.1",
+"resolved": 
"https://registry.npmjs.org/@types/glob/-/glob-7.1.1.tgz";,
+"integrity": 
"sha512-1Bh06cbWJUHMC97acuD6UMG29nMt0Aqz1vF3guLfG+kHHJhy3AyohZFFxYk2f7Q1SQIrNwvncxAE0N/9s70F2w==",
 "dev": true,
 "requires": {
-"arr-flatten": "^1.0.1",
-"array-slice": "^0.2.3"
+"@types/events": "*",
+ 

[PATCH] D73624: [clangd][vscode] Get rid of the deprecated vscode module in the extension.

2020-01-30 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9b71ec899a15: [clangd][vscode] Get rid of the deprecated 
vscode module in the extension. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73624

Files:
  clang-tools-extra/clangd/clients/clangd-vscode/package-lock.json
  clang-tools-extra/clangd/clients/clangd-vscode/package.json
  clang-tools-extra/clangd/clients/clangd-vscode/test/index.ts
  clang-tools-extra/clangd/clients/clangd-vscode/test/runTest.ts

Index: clang-tools-extra/clangd/clients/clangd-vscode/test/runTest.ts
===
--- /dev/null
+++ clang-tools-extra/clangd/clients/clangd-vscode/test/runTest.ts
@@ -0,0 +1,23 @@
+import * as path from 'path';
+
+import {runTests} from 'vscode-test';
+
+async function main() {
+  try {
+// The folder containing the Extension Manifest package.json
+// Passed to `--extensionDevelopmentPath`
+const extensionDevelopmentPath = path.resolve(__dirname, '../');
+
+// The path to the extension test script
+// Passed to --extensionTestsPath
+const extensionTestsPath = path.resolve(__dirname, './index');
+
+// Download VS Code, unzip it and run the integration test
+await runTests({extensionDevelopmentPath, extensionTestsPath});
+  } catch (err) {
+console.error('Failed to run tests');
+process.exit(1);
+  }
+}
+
+main();
Index: clang-tools-extra/clangd/clients/clangd-vscode/test/index.ts
===
--- clang-tools-extra/clangd/clients/clangd-vscode/test/index.ts
+++ clang-tools-extra/clangd/clients/clangd-vscode/test/index.ts
@@ -1,25 +1,35 @@
-//
-// PLEASE DO NOT MODIFY / DELETE UNLESS YOU KNOW WHAT YOU ARE DOING
-//
-// This file is providing the test runner to use when running extension tests.
-// By default the test runner in use is Mocha based.
-//
-// You can provide your own test runner if you want to override it by exporting
-// a function run(testRoot: string, clb: (error:Error) => void) that the
-// extension host can call to run the tests. The test runner is expected to use
-// console.log to report the results back to the caller. When the tests are
-// finished, return a possible error to the callback or null if none.
+import * as glob from 'glob';
+import * as Mocha from 'mocha';
+import * as path from 'path';
 
-var testRunner = require('vscode/lib/testrunner');
+export function run(): Promise {
+  // Create the mocha test
+  const mocha = new Mocha({ui : 'tdd'});
+  mocha.useColors(true);
 
-// You can directly control Mocha options by uncommenting the following lines
-// See
-// https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options
-// for more info
-testRunner.configure({
-  ui : 'tdd', // the TDD UI is being used in extension.test.ts (suite, test,
-  // etc.)
-  useColors : true // colored output from test results
-});
+  const testsRoot = path.resolve(__dirname, '..');
 
-module.exports = testRunner;
\ No newline at end of file
+  return new Promise((c, e) => {
+glob('**/**.test.js', {cwd : testsRoot}, (err, files) => {
+  if (err) {
+return e(err);
+  }
+
+  // Add files to the test suite
+  files.forEach(f => mocha.addFile(path.resolve(testsRoot, f)));
+
+  try {
+// Run the mocha test
+mocha.run(failures => {
+  if (failures > 0) {
+e(new Error(`${failures} tests failed.`));
+  } else {
+c();
+  }
+});
+  } catch (err) {
+e(err);
+  }
+});
+  });
+}
Index: clang-tools-extra/clangd/clients/clangd-vscode/package.json
===
--- clang-tools-extra/clangd/clients/clangd-vscode/package.json
+++ clang-tools-extra/clangd/clients/clangd-vscode/package.json
@@ -32,9 +32,8 @@
 "scripts": {
 "vscode:prepublish": "tsc -p ./",
 "compile": "tsc -watch -p ./",
-"postinstall": "node ./node_modules/vscode/bin/install",
 "format": "clang-format --style=LLVM -i --glob=\"{src,test}/*.ts\"",
-"test": "node ./node_modules/vscode/bin/test",
+"test": "tsc -p ./ && node ./out/test/runTest.js",
 "package": "vsce package --baseImagesUrl https://raw.githubusercontent.com/llvm/llvm-project/master/clang-tools-extra/clangd/clients/clangd-vscode/";,
 "publish": "vsce publish --baseImagesUrl https://raw.githubusercontent.com/llvm/llvm-project/master/clang-tools-extra/clangd/clients/clangd-vscode/";
 },
@@ -45,12 +44,15 @@
 "vscode-languageserver-types": "^3.15.1"
 },
 "devDependencies": {
+"@types/glob": "^7.1.1",
 "@types/mocha": "^2.2.32",
 "@types/node": "^6.0.40",
+"@types/vscode": "^1.41.0",
+"glob": "^7.1.4",
 "clang-form

[clang-tools-extra] 7fd7a9a - [clangd] Bump vscode-clangd v0.0.20

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

Author: Haojian Wu
Date: 2020-01-30T11:45:54+01:00
New Revision: 7fd7a9a6365f8026d84a89ec3e73d328a63742a0

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

LOG: [clangd] Bump vscode-clangd v0.0.20

CHANGELOG:
- update lsp dependencies to pickup the latest LSP 3.15
- better support for cu files

Added: 


Modified: 
clang-tools-extra/clangd/clients/clangd-vscode/package-lock.json
clang-tools-extra/clangd/clients/clangd-vscode/package.json

Removed: 




diff  --git a/clang-tools-extra/clangd/clients/clangd-vscode/package-lock.json 
b/clang-tools-extra/clangd/clients/clangd-vscode/package-lock.json
index ee69099568fd..8ca4d064fb84 100644
--- a/clang-tools-extra/clangd/clients/clangd-vscode/package-lock.json
+++ b/clang-tools-extra/clangd/clients/clangd-vscode/package-lock.json
@@ -1,6 +1,6 @@
 {
 "name": "vscode-clangd",
-"version": "0.0.19",
+"version": "0.0.20",
 "lockfileVersion": 1,
 "requires": true,
 "dependencies": {

diff  --git a/clang-tools-extra/clangd/clients/clangd-vscode/package.json 
b/clang-tools-extra/clangd/clients/clangd-vscode/package.json
index 44cffcc1cc34..70011bfba792 100644
--- a/clang-tools-extra/clangd/clients/clangd-vscode/package.json
+++ b/clang-tools-extra/clangd/clients/clangd-vscode/package.json
@@ -2,7 +2,7 @@
 "name": "vscode-clangd",
 "displayName": "vscode-clangd",
 "description": "Clang Language Server",
-"version": "0.0.19",
+"version": "0.0.20",
 "publisher": "llvm-vs-code-extensions",
 "homepage": "https://clang.llvm.org/extra/clangd.html";,
 "engines": {



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


[PATCH] D73687: [AArch64][SVE] Add SVE2 intrinsics for complex integer dot product

2020-01-30 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin created this revision.
kmclaughlin added reviewers: sdesmalen, efriedma, dancgr, c-rhodes.
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.cdot
- @llvm.aarch64.sve.cdot.lane


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73687

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve2-intrinsics-complex-dot.ll

Index: llvm/test/CodeGen/AArch64/sve2-intrinsics-complex-dot.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve2-intrinsics-complex-dot.ll
@@ -0,0 +1,61 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve2 < %s | FileCheck %s
+
+
+;
+; CDOT
+;
+
+define  @cdot_s( %a,  %b,  %c) {
+; CHECK-LABEL: cdot_s:
+; CHECK: cdot z0.s, z1.b, z2.b, #0
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.cdot.nxv4i32( %a,
+ %b,
+ %c,
+i32 0)
+  ret  %out
+}
+
+define  @cdot_d( %a,  %b,  %c) {
+; CHECK-LABEL: cdot_d:
+; CHECK: cdot z0.d, z1.h, z2.h, #90
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.cdot.nxv2i64( %a,
+ %b,
+ %c,
+i32 90)
+  ret  %out
+}
+
+;
+; CDOT(indexed)
+;
+
+define  @cdot_s_idx( %a,  %b,  %c) {
+; CHECK-LABEL: cdot_s_idx:
+; CHECK: cdot z0.s, z1.b, z2.b[0], #180
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.cdot.lane.nxv4i32( %a,
+  %b,
+  %c,
+ i32 0, i32 180)
+  ret  %out
+}
+
+
+define  @cdot_d_idx( %a,  %b,  %c) {
+; CHECK-LABEL: cdot_d_idx:
+; CHECK: cdot z0.d, z1.h, z2.h[1], #270
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.cdot.lane.nxv2i64( %a,
+  %b,
+  %c,
+ i32 1, i32 270)
+  ret  %out
+}
+
+
+declare  @llvm.aarch64.sve.cdot.nxv4i32(, , , i32)
+declare  @llvm.aarch64.sve.cdot.nxv2i64(, , , i32)
+declare  @llvm.aarch64.sve.cdot.lane.nxv4i32(, , , i32, i32)
+declare  @llvm.aarch64.sve.cdot.lane.nxv2i64(, , , i32, i32)
Index: llvm/lib/Target/AArch64/SVEInstrFormats.td
===
--- llvm/lib/Target/AArch64/SVEInstrFormats.td
+++ llvm/lib/Target/AArch64/SVEInstrFormats.td
@@ -2538,9 +2538,16 @@
   let ElementSize = ElementSizeNone;
 }
 
-multiclass sve2_cintx_dot {
+multiclass sve2_cintx_dot {
   def _S : sve2_complex_int_arith<0b10, 0b0001, asm, ZPR32, ZPR8>;
   def _D : sve2_complex_int_arith<0b11, 0b0001, asm, ZPR64, ZPR16>;
+
+  def : Pat<(nxv4i32 (op (nxv4i32 ZPR32:$Op1), (nxv16i8 ZPR8:$Op2), (nxv16i8 ZPR8:$Op3),
+ (i32 complexrotateop:$imm))),
+(!cast(NAME # "_S") ZPR32:$Op1, ZPR8:$Op2, ZPR8:$Op3, complexrotateop:$imm)>;
+  def : Pat<(nxv2i64 (op (nxv2i64 ZPR64:$Op1), (nxv8i16 ZPR16:$Op2), (nxv8i16 ZPR16:$Op3),
+ (i32 complexrotateop:$imm))),
+(!cast(NAME # "_D") ZPR64:$Op1, ZPR16:$Op2, ZPR16:$Op3, complexrotateop:$imm)>;
 }
 
 //===--===//
@@ -2580,19 +2587,26 @@
   let ElementSize = ElementSizeNone;
 }
 
-multiclass sve2_cintx_dot_by_indexed_elem {
-  def _S : sve2_complex_int_arith_indexed<0b10, 0b0100, asm, ZPR32, ZPR8, ZPR3b8, VectorIndexS> {
+multiclass sve2_cintx_dot_by_indexed_elem {
+  def _S : sve2_complex_int_arith_indexed<0b10, 0b0100, asm, ZPR32, ZPR8, ZPR3b8, VectorIndexS32b> {
 bits<2> iop;
 bits<3> Zm;
 let Inst{20-19} = iop;
 let Inst{18-16} = Zm;
   }
-  def _D : sve2_complex_int_arith_indexed<0b11, 0b0100, asm, ZPR64, ZPR16, ZPR4b16, VectorIndexD> {
+  def _D : sve2_complex_int_arith_indexed<0b11, 0b0100, asm, ZPR64, ZPR16, ZPR4b16, VectorIndexD32b> {
 bit iop;
 bits<4> Zm;
 let Inst{20} = iop;
 let Inst{19-16} = Zm;
   }
+
+  def : Pat<(nxv4i32 (op (nxv4i32 ZPR32:$Op1), (nxv16i8 ZPR8:$Op2), (nxv16i8 ZPR8:$Op3),
+ (i32 VectorIndexS32b_timm:$idx), (i32 complexrotateop:$imm))),
+(!cast(NAME # "_S") ZPR32:$Op1, ZPR8:$Op2, ZPR8:$Op3, VectorIndexS32b_timm:$idx, complexrotateop:$imm)>;
+  def : Pat<(nxv2i64 (op (nxv2i64 ZPR64:$Op1), (nxv8i1

[PATCH] D73548: [clang-tidy] Added option for disabling const qualifiers in readability-qualified-auto

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

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

  failed: Clang.CodeGenOpenCL/amdgpu-features.cl

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

{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-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73548



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


[PATCH] D73629: [analyzer] vfork checker: allow execve after vfork

2020-01-30 Thread Jan Včelák via Phabricator via cfe-commits
janvcelak added a comment.

In D73629#1847750 , @NoQ wrote:

> We should add a test for this (cf. `test/Analysis/vfork.c`).


There is already a test to check if the whitelist works by making sure that 
call to `execl` doesn't generate the warning. I think there is no point adding 
`execve` into the tests unless we want to add a test for each of the functions 
in the list. However, let me know if you want it added.


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

https://reviews.llvm.org/D73629



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


[PATCH] D73629: [analyzer] vfork checker: allow execve after vfork

2020-01-30 Thread Jan Včelák via Phabricator via cfe-commits
janvcelak added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp:109
   "execvpe",
+  "execve",
   nullptr

xazax.hun wrote:
> Well, this is not the case now, but I wonder if it would also make sense to 
> sort this list alphabetically. 
I had this idea as well. The list is currently not sorted but seems to match 
the order of the functions as they are listed in the `exec(3)` manual page so I 
kept it.

Let me know what is preferred and I can update the diff.


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

https://reviews.llvm.org/D73629



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


[clang-tools-extra] 4fb1adc - [clangd] Log directory when a CDB is loaded

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

Author: Kadir Cetinkaya
Date: 2020-01-30T12:15:04+01:00
New Revision: 4fb1adcde22c06d421598ed1925ee3c7c835abc4

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

LOG: [clangd] Log directory when a CDB is loaded

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

Reviewers: sammccall

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

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/GlobalCompilationDatabase.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp 
b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
index f2a6083b77e3..aa6727fc20f5 100644
--- a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -115,9 +115,11 @@ 
DirectoryBasedGlobalCompilationDatabase::getCDBInDirLocked(PathRef Dir) const {
   auto R = CompilationDatabases.try_emplace(Key);
   if (R.second) { // Cache miss, try to load CDB.
 CachedCDB &Entry = R.first->second;
-std::string Error = "";
+std::string Error;
 Entry.CDB = tooling::CompilationDatabase::loadFromDirectory(Dir, Error);
 Entry.Path = std::string(Dir);
+if (Entry.CDB)
+  log("Loaded compilation database from {0}", Dir);
   }
   return R.first->second;
 }



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


[PATCH] D73628: [clangd] Log directory when a CDB is loaded

2020-01-30 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 241388.
kadircet marked 2 inline comments as done.
kadircet added a comment.

- Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73628

Files:
  clang-tools-extra/clangd/GlobalCompilationDatabase.cpp


Index: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
===
--- clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -115,9 +115,11 @@
   auto R = CompilationDatabases.try_emplace(Key);
   if (R.second) { // Cache miss, try to load CDB.
 CachedCDB &Entry = R.first->second;
-std::string Error = "";
+std::string Error;
 Entry.CDB = tooling::CompilationDatabase::loadFromDirectory(Dir, Error);
 Entry.Path = std::string(Dir);
+if (Entry.CDB)
+  log("Loaded compilation database from {0}", Dir);
   }
   return R.first->second;
 }


Index: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
===
--- clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -115,9 +115,11 @@
   auto R = CompilationDatabases.try_emplace(Key);
   if (R.second) { // Cache miss, try to load CDB.
 CachedCDB &Entry = R.first->second;
-std::string Error = "";
+std::string Error;
 Entry.CDB = tooling::CompilationDatabase::loadFromDirectory(Dir, Error);
 Entry.Path = std::string(Dir);
+if (Entry.CDB)
+  log("Loaded compilation database from {0}", Dir);
   }
   return R.first->second;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73628: [clangd] Log directory when a CDB is loaded

2020-01-30 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4fb1adcde22c: [clangd] Log directory when a CDB is loaded 
(authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73628

Files:
  clang-tools-extra/clangd/GlobalCompilationDatabase.cpp


Index: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
===
--- clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -115,9 +115,11 @@
   auto R = CompilationDatabases.try_emplace(Key);
   if (R.second) { // Cache miss, try to load CDB.
 CachedCDB &Entry = R.first->second;
-std::string Error = "";
+std::string Error;
 Entry.CDB = tooling::CompilationDatabase::loadFromDirectory(Dir, Error);
 Entry.Path = std::string(Dir);
+if (Entry.CDB)
+  log("Loaded compilation database from {0}", Dir);
   }
   return R.first->second;
 }


Index: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
===
--- clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -115,9 +115,11 @@
   auto R = CompilationDatabases.try_emplace(Key);
   if (R.second) { // Cache miss, try to load CDB.
 CachedCDB &Entry = R.first->second;
-std::string Error = "";
+std::string Error;
 Entry.CDB = tooling::CompilationDatabase::loadFromDirectory(Dir, Error);
 Entry.Path = std::string(Dir);
+if (Entry.CDB)
+  log("Loaded compilation database from {0}", Dir);
   }
   return R.first->second;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73462: [dwarf-5] Support DebugInfo for Defaulted parameters for C++ templates

2020-01-30 Thread Awanish Pandey via Phabricator via cfe-commits
awpandey updated this revision to Diff 241391.
awpandey marked 7 inline comments as done.
awpandey added a comment.

Hi @dblaikie, I have incorporated your suggestions (renaming variables, test 
case modification).


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

https://reviews.llvm.org/D73462

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-template-parameter.cpp
  llvm/include/llvm/IR/DIBuilder.h
  llvm/include/llvm/IR/DebugInfoMetadata.h
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/Bitcode/Reader/MetadataLoader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/IR/DIBuilder.cpp
  llvm/lib/IR/DebugInfoMetadata.cpp
  llvm/lib/IR/LLVMContextImpl.h
  llvm/test/DebugInfo/X86/debug-info-template-parameter.ll
  llvm/unittests/IR/MetadataTest.cpp

Index: llvm/unittests/IR/MetadataTest.cpp
===
--- llvm/unittests/IR/MetadataTest.cpp
+++ llvm/unittests/IR/MetadataTest.cpp
@@ -2077,16 +2077,16 @@
   StringRef Name = "template";
   DIType *Type = getBasicType("basic");
 
-  auto *N = DITemplateTypeParameter::get(Context, Name, Type);
+  auto *N = DITemplateTypeParameter::get(Context, Name, Type, false);
 
   EXPECT_EQ(dwarf::DW_TAG_template_type_parameter, N->getTag());
   EXPECT_EQ(Name, N->getName());
   EXPECT_EQ(Type, N->getType());
-  EXPECT_EQ(N, DITemplateTypeParameter::get(Context, Name, Type));
+  EXPECT_EQ(N, DITemplateTypeParameter::get(Context, Name, Type, false));
 
-  EXPECT_NE(N, DITemplateTypeParameter::get(Context, "other", Type));
-  EXPECT_NE(N,
-DITemplateTypeParameter::get(Context, Name, getBasicType("other")));
+  EXPECT_NE(N, DITemplateTypeParameter::get(Context, "other", Type, false));
+  EXPECT_NE(N, DITemplateTypeParameter::get(Context, Name,
+getBasicType("other"), false));
 
   TempDITemplateTypeParameter Temp = N->clone();
   EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
@@ -2100,21 +2100,23 @@
   DIType *Type = getBasicType("basic");
   Metadata *Value = getConstantAsMetadata();
 
-  auto *N = DITemplateValueParameter::get(Context, Tag, Name, Type, Value);
+  auto *N =
+  DITemplateValueParameter::get(Context, Tag, Name, Type, false, Value);
   EXPECT_EQ(Tag, N->getTag());
   EXPECT_EQ(Name, N->getName());
   EXPECT_EQ(Type, N->getType());
   EXPECT_EQ(Value, N->getValue());
-  EXPECT_EQ(N, DITemplateValueParameter::get(Context, Tag, Name, Type, Value));
+  EXPECT_EQ(
+  N, DITemplateValueParameter::get(Context, Tag, Name, Type, false, Value));
 
   EXPECT_NE(N, DITemplateValueParameter::get(
Context, dwarf::DW_TAG_GNU_template_template_param, Name,
-   Type, Value));
-  EXPECT_NE(N,
-DITemplateValueParameter::get(Context, Tag, "other", Type, Value));
-  EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, Name,
- getBasicType("other"), Value));
-  EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, Name, Type,
+   Type, false, Value));
+  EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, "other", Type, false,
+ Value));
+  EXPECT_NE(N, DITemplateValueParameter::get(
+   Context, Tag, Name, getBasicType("other"), false, Value));
+  EXPECT_NE(N, DITemplateValueParameter::get(Context, Tag, Name, Type, false,
  getConstantAsMetadata()));
 
   TempDITemplateValueParameter Temp = N->clone();
Index: llvm/test/DebugInfo/X86/debug-info-template-parameter.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/X86/debug-info-template-parameter.ll
@@ -0,0 +1,90 @@
+; RUN: %llc_dwarf  %s -filetype=obj -o - | llvm-dwarfdump -v - | FileCheck %s
+
+; C++ source to regenerate:
+
+;template 
+;class foo {
+;};
+;
+;int main() {
+; foo f1;
+; foo<> f2;
+; return 0;
+;}
+
+; $ clang++ -O0 -gdwarf-5 -S -gdwarf-5 test.cpp 
+
+; CHECK: .debug_abbrev contents:
+; CHECK: DW_AT_default_value DW_FORM_flag_present
+
+; CHECK: debug_info contents:
+
+; CHECK: DW_AT_name {{.*}} "foo"
+; CHECK: DW_AT_type {{.*}} "int"
+; CHECK-NEXT: DW_AT_name {{.*}} "T"
+; CHECK-NOT: DW_AT_default_value
+; CHECK: DW_AT_type {{.*}} "int"
+; CHECK-NEXT: DW_AT_name {{.*}} "i"
+; CHECK-NOT: DW_AT_default_value
+
+; CHECK: DW_AT_name {{.*}} "foo"
+; CHECK: DW_AT_type {{.*}} "char"
+; CHECK-NEXT: DW_AT_name {{.*}} "T"
+; CHECK_NEXT: DW_AT_default_value {{.*}} true
+; CHECK: DW_AT_type {{.*}} "int"
+; CHECK-NEXT: DW_AT_name {{.*}} "i"
+; CHECK_NEXT: DW_AT_default_value {{.*}} true
+
+; ModuleID = '/dir/test.cpp'
+source_filename = "test.cpp"
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+%class.foo =

[PATCH] D73462: [dwarf-5] Support DebugInfo for Defaulted parameters for C++ templates

2020-01-30 Thread Awanish Pandey via Phabricator via cfe-commits
awpandey marked an inline comment as done and an inline comment as not done.
awpandey added inline comments.



Comment at: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1808-1809
   Record.push_back(VE.getMetadataOrNullID(N->getType()));
+  if (M.getDwarfVersion() >= 5)
+Record.push_back(N->getDefault());
   Record.push_back(VE.getMetadataOrNullID(N->getValue()));

dblaikie wrote:
> I don't think we should be using the DWARF version to decide on the schema - 
> there's no other use of that technique in the parsing/writing code & I can 
> think of some ways it might go poorly.
> 
> Better to encode it & it can be dropped during actual DWARF emission in the 
> backend if the version doesn't support it.
I am doing this for making record structure consistent with previous dwarf 
version.


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

https://reviews.llvm.org/D73462



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


[PATCH] D73690: [clangd] Make go-to-def jumps to overriden methods on `final` specifier.

2020-01-30 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/D73690

Files:
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -452,6 +452,11 @@
 class X : Y { void a() ^override {} };
   )cpp",
 
+  R"cpp(// Final specifier jumps to overridden method
+class Y { virtual void $decl[[a]]() = 0; };
+class X : Y { void a() ^final {} };
+  )cpp",
+
   R"cpp(// Heuristic resolution of dependent method
 template 
 struct S {
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -22,6 +22,7 @@
 #include "index/SymbolLocation.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Attr.h"
+#include "clang/AST/Attrs.inc"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclTemplate.h"
@@ -277,7 +278,9 @@
   for (const NamedDecl *D : getDeclAtPosition(AST, SourceLoc, Relations)) {
 // Special case: void foo() ^override: jump to the overridden method.
 if (const auto *CMD = llvm::dyn_cast(D)) {
-  const auto *Attr = D->getAttr();
+  const InheritableAttr* Attr = D->getAttr();
+  if (!Attr)
+Attr = D->getAttr();
   const syntax::Token *Tok =
   spelledIdentifierTouching(SourceLoc, AST.getTokens());
   if (Attr && Tok &&


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -452,6 +452,11 @@
 class X : Y { void a() ^override {} };
   )cpp",
 
+  R"cpp(// Final specifier jumps to overridden method
+class Y { virtual void $decl[[a]]() = 0; };
+class X : Y { void a() ^final {} };
+  )cpp",
+
   R"cpp(// Heuristic resolution of dependent method
 template 
 struct S {
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -22,6 +22,7 @@
 #include "index/SymbolLocation.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Attr.h"
+#include "clang/AST/Attrs.inc"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclTemplate.h"
@@ -277,7 +278,9 @@
   for (const NamedDecl *D : getDeclAtPosition(AST, SourceLoc, Relations)) {
 // Special case: void foo() ^override: jump to the overridden method.
 if (const auto *CMD = llvm::dyn_cast(D)) {
-  const auto *Attr = D->getAttr();
+  const InheritableAttr* Attr = D->getAttr();
+  if (!Attr)
+Attr = D->getAttr();
   const syntax::Token *Tok =
   spelledIdentifierTouching(SourceLoc, AST.getTokens());
   if (Attr && Tok &&
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 827f49e - [clangd] Make go-to-def jumps to overriden methods on `final` specifier.

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

Author: Haojian Wu
Date: 2020-01-30T12:49:30+01:00
New Revision: 827f49e3faf59f99082d0085de06dcbc09be8ba3

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

LOG: [clangd] Make go-to-def jumps to overriden methods on `final` specifier.

Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/XRefs.cpp
clang-tools-extra/clangd/unittests/XRefsTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/XRefs.cpp 
b/clang-tools-extra/clangd/XRefs.cpp
index b302a0d5396c..61dff3e99cae 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -22,6 +22,7 @@
 #include "index/SymbolLocation.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Attr.h"
+#include "clang/AST/Attrs.inc"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclTemplate.h"
@@ -277,7 +278,9 @@ std::vector locateSymbolAt(ParsedAST &AST, 
Position Pos,
   for (const NamedDecl *D : getDeclAtPosition(AST, SourceLoc, Relations)) {
 // Special case: void foo() ^override: jump to the overridden method.
 if (const auto *CMD = llvm::dyn_cast(D)) {
-  const auto *Attr = D->getAttr();
+  const InheritableAttr* Attr = D->getAttr();
+  if (!Attr)
+Attr = D->getAttr();
   const syntax::Token *Tok =
   spelledIdentifierTouching(SourceLoc, AST.getTokens());
   if (Attr && Tok &&

diff  --git a/clang-tools-extra/clangd/unittests/XRefsTests.cpp 
b/clang-tools-extra/clangd/unittests/XRefsTests.cpp
index 348613954a27..226213979b8b 100644
--- a/clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -452,6 +452,11 @@ TEST(LocateSymbol, All) {
 class X : Y { void a() ^override {} };
   )cpp",
 
+  R"cpp(// Final specifier jumps to overridden method
+class Y { virtual void $decl[[a]]() = 0; };
+class X : Y { void a() ^final {} };
+  )cpp",
+
   R"cpp(// Heuristic resolution of dependent method
 template 
 struct S {



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


[PATCH] D73360: [OpenCL] Restrict address space conversions in nested pointers

2020-01-30 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia marked an inline comment as done.
Anastasia added inline comments.



Comment at: clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl:521
+#else
+// expected-error@-5 {{assigning to '__generic int *__generic *' from 
incompatible type '__local int *__local *__private'}}
 #endif

rjmccall wrote:
> Can we specialize the diagnostic here so that we get the good diagnostic in 
> both language modes?
I am not sure of the approach so I am wondering if you have any good 
suggestions.

It seems in C++ Clang exits with quite generic `Incompatible` in the implicit 
conversion case because the functionality for doing the semantic checks doesn't 
generally set `Sema::AssignConvertType`.

https://clang.llvm.org/doxygen/SemaExpr_8cpp_source.html

```

Sema::CheckSingleAssignmentConstraints:


  if (getLangOpts().CPlusPlus) {
  if (!LHSType->isRecordType() && !LHSType->isAtomicType()) {
// C++ 5.17p3: If the left operand is not of class type, the
// expression is implicitly converted (C++ 4) to the
// cv-unqualified type of the left operand.
QualType RHSType = RHS.get()->getType();
if (Diagnose) {
  RHS = PerformImplicitConversion(RHS.get(), 
LHSType.getUnqualifiedType(),
  AA_Assigning);
} else {
  ...
}
if (RHS.isInvalid())
  return Incompatible;
```

However for example in `IsStandardConversion`  I can see that 
`Sema::AssignConvertType` is being set but only for classifying the conversion 
sequence. It is never propagated outside.

http://clang.llvm.org/doxygen/SemaOverload_8cpp_source.html


```
IsStandardConversion:


ExprResult ER = ExprResult{From};
Sema::AssignConvertType Conv =
S.CheckSingleAssignmentConstraints(ToType, ER,
   /*Diagnose=*/false,
   /*DiagnoseCFAudited=*/false,
   /*ConvertRHS=*/false);
ImplicitConversionKind SecondConv;
switch (Conv) {
case Sema::Compatible:
  SecondConv = ICK_C_Only_Conversion;
  break;
// For our purposes, discarding qualifiers is just as bad as using an
// incompatible pointer. Note that an IncompatiblePointer conversion can 
drop
// qualifiers, as well.
case Sema::CompatiblePointerDiscardsQualifiers:
case Sema::IncompatiblePointer:
case Sema::IncompatiblePointerSign:
  SecondConv = ICK_Incompatible_Pointer_Conversion;
  break;
default:
  return false;
}


```

In most of other places it's not being used for C++ mode. I feel like C++ flow 
was not written to set the conversion type failure. Maybe there is something 
else I could use in C++ mode to specialize this diagnostic? Otherwise, it seems 
like quite a lot of Sema would have to be modified for C++ flow because 
implicit conversions are used in many different places.


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

https://reviews.llvm.org/D73360



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


[PATCH] D73690: [clangd] Make go-to-def jumps to overriden methods on `final` specifier.

2020-01-30 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG827f49e3faf5: [clangd] Make go-to-def jumps to overriden 
methods on `final` specifier. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73690

Files:
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -452,6 +452,11 @@
 class X : Y { void a() ^override {} };
   )cpp",
 
+  R"cpp(// Final specifier jumps to overridden method
+class Y { virtual void $decl[[a]]() = 0; };
+class X : Y { void a() ^final {} };
+  )cpp",
+
   R"cpp(// Heuristic resolution of dependent method
 template 
 struct S {
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -22,6 +22,7 @@
 #include "index/SymbolLocation.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Attr.h"
+#include "clang/AST/Attrs.inc"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclTemplate.h"
@@ -277,7 +278,9 @@
   for (const NamedDecl *D : getDeclAtPosition(AST, SourceLoc, Relations)) {
 // Special case: void foo() ^override: jump to the overridden method.
 if (const auto *CMD = llvm::dyn_cast(D)) {
-  const auto *Attr = D->getAttr();
+  const InheritableAttr* Attr = D->getAttr();
+  if (!Attr)
+Attr = D->getAttr();
   const syntax::Token *Tok =
   spelledIdentifierTouching(SourceLoc, AST.getTokens());
   if (Attr && Tok &&


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -452,6 +452,11 @@
 class X : Y { void a() ^override {} };
   )cpp",
 
+  R"cpp(// Final specifier jumps to overridden method
+class Y { virtual void $decl[[a]]() = 0; };
+class X : Y { void a() ^final {} };
+  )cpp",
+
   R"cpp(// Heuristic resolution of dependent method
 template 
 struct S {
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -22,6 +22,7 @@
 #include "index/SymbolLocation.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Attr.h"
+#include "clang/AST/Attrs.inc"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclTemplate.h"
@@ -277,7 +278,9 @@
   for (const NamedDecl *D : getDeclAtPosition(AST, SourceLoc, Relations)) {
 // Special case: void foo() ^override: jump to the overridden method.
 if (const auto *CMD = llvm::dyn_cast(D)) {
-  const auto *Attr = D->getAttr();
+  const InheritableAttr* Attr = D->getAttr();
+  if (!Attr)
+Attr = D->getAttr();
   const syntax::Token *Tok =
   spelledIdentifierTouching(SourceLoc, AST.getTokens());
   if (Attr && Tok &&
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73690: [clangd] Make go-to-def jumps to overriden methods on `final` specifier.

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

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

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

{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-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73690



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


[PATCH] D73667: Speed up compilation of ASTImporter

2020-01-30 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a comment.
This revision is now accepted and ready to land.

Thanks for the patch! Looks good to me!




Comment at: clang/lib/AST/ASTImporter.cpp:192
+  // Don't attempt to import nodes if we hit an error earlier.
+  if (Err)
+return T{};

Thanks for thinking about it. This way we can keep the original behavior i.e. 
the import is stopped on the first error.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73667



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


[PATCH] D69221: [clang][darwin] Fix search path logic for C_INCLUDE_DIRS

2020-01-30 Thread Marco Hinz via Phabricator via cfe-commits
mhinz added a comment.

In D69221#1848425 , @ldionne wrote:

> Do you have commit access?


No. :)


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

https://reviews.llvm.org/D69221



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


[PATCH] D73675: Avoid many std::tie/tuple instantiations in ASTImporter

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

Thanks for this patch too!
However, I have a minor concern with this new approach:
If `importSeq` fails then a `ToSomething` still holds a value from the "From" 
context. This could cause problems if it is used later in creating the new AST 
node. Normally, this should not happen because we do check the return value of 
`importSeq`. But as the AST increases, new properties are added to a node, 
let's say `ToSomething2` and when we forget (by mistake) to add this to 
`importSeq` then we end up having a node that has a reference to something in 
the "From" context:

  auto ToSomething = From->getToSomething();
  auto ToSomething2 = From->getToSomething2();
  if (Error E = ImportSeq(ToSomething)) 
return std::move(E);
  createNewNodeInToCtx(ToSomething, ToSomething2);

In contrast to the original behavior where we would end up with an 
uninitialized value (pointer) which seems to be easier to recognize when 
someone uses the merged AST.
(I am not sure how could we force `ToSomething2` into `importSeq`, perhaps a 
clang-tidy checker could do that.)




Comment at: clang/lib/AST/ASTImporter.cpp:1265
+
+  if (Error E = importSeq(ToEPI.ExceptionSpec.NoexceptExpr,
+   ToEPI.ExceptionSpec.SourceDecl,

My concern here is that if `importSeq` fails here then 
`ToEPI.ExceptionSpec.NoexceptExpr` still holds a value from the "From" context 
and that can be a (fatal) problem later. The import should happen right after 
the initialization of these variables.
So, we should have something like this:
```
  ToEPI.ExceptionSpec.NoexceptExpr = FromEPI.ExceptionSpec.NoexceptExpr;
  ToEPI.ExceptionSpec.SourceDecl = FromEPI.ExceptionSpec.SourceDecl;
  ToEPI.ExceptionSpec.SourceTemplate = FromEPI.ExceptionSpec.SourceTemplate;
  if (Error E = 
importSeq(ToEPI.ExceptionSpec.NoexceptExpr,ToEPI.ExceptionSpec.SourceTemplate))
return std::move(E);
  ToEPI.ExtInfo = FromEPI.ExtInfo;
  ToEPI.Variadic = FromEPI.Variadic;
  ToEPI.HasTrailingReturn = FromEPI.HasTrailingReturn;
  ToEPI.TypeQuals = FromEPI.TypeQuals;
  ToEPI.RefQualifier = FromEPI.RefQualifier;
  ToEPI.ExceptionSpec.Type = FromEPI.ExceptionSpec.Type;
  ToEPI.ExceptionSpec.Exceptions = ExceptionTypes;
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73675



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


[PATCH] D73675: Avoid many std::tie/tuple instantiations in ASTImporter

2020-01-30 Thread Gabor Marton via Phabricator via cfe-commits
martong added a subscriber: gamesh411.
martong added inline comments.



Comment at: clang/lib/AST/ASTImporter.cpp:1152
+  if (Error E = importSeq(ToElementType, ToSizeExpr))
+return std::move(E);
 

Quuxplusone wrote:
> As the author of [P1155 "More Implicit Move"](https://wg21.link/p1155), I 
> would expect that you don't need `return std::move(E)` — `return E` should 
> just as well perform "implicit move" in C++11 and later, assuming that 
> `llvm::Expected` has a valid constructor from `llvm::Error&&`.
> 
> You're not seeing any compiler diagnostic that //suggests// you use 
> `std::move` here, are you?
I have some vague and obscure memory about that GCC 4.8 (or 5.2) required 
explicitly the && cast, otherwise we had a diagnostic (@gamesh411 maybe you 
help me to recall that?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73675



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


[PATCH] D73693: [clang][DeclPrinter] Implement visitors for {TemplateType,NonTypeTemplate}Parms

2020-01-30 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, 
kristof.beyls.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73693

Files:
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang/lib/AST/DeclPrinter.cpp

Index: clang/lib/AST/DeclPrinter.cpp
===
--- clang/lib/AST/DeclPrinter.cpp
+++ clang/lib/AST/DeclPrinter.cpp
@@ -105,6 +105,8 @@
 void VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D);
 void VisitOMPDeclareMapperDecl(OMPDeclareMapperDecl *D);
 void VisitOMPCapturedExprDecl(OMPCapturedExprDecl *D);
+void VisitTemplateTypeParmDecl(const TemplateTypeParmDecl *TTP);
+void VisitNonTypeTemplateParmDecl(const NonTypeTemplateParmDecl *NTTP);
 
 void printTemplateParameters(const TemplateParameterList *Params,
  bool OmitTemplateKW = false);
@@ -1051,37 +1053,10 @@
 else
   NeedComma = true;
 
-if (auto TTP = dyn_cast(Param)) {
-
-  if (const TypeConstraint *TC = TTP->getTypeConstraint())
-TC->print(Out, Policy);
-  else if (TTP->wasDeclaredWithTypename())
-Out << "typename";
-  else
-Out << "class";
-
-  if (TTP->isParameterPack())
-Out << " ...";
-  else if (!TTP->getName().empty())
-Out << ' ';
-
-  Out << *TTP;
-
-  if (TTP->hasDefaultArgument()) {
-Out << " = ";
-Out << TTP->getDefaultArgument().getAsString(Policy);
-  };
+if (const auto *TTP = dyn_cast(Param)) {
+  VisitTemplateTypeParmDecl(TTP);
 } else if (auto NTTP = dyn_cast(Param)) {
-  StringRef Name;
-  if (IdentifierInfo *II = NTTP->getIdentifier())
-Name = II->getName();
-  printDeclType(NTTP->getType(), Name, NTTP->isParameterPack());
-
-  if (NTTP->hasDefaultArgument()) {
-Out << " = ";
-NTTP->getDefaultArgument()->printPretty(Out, nullptr, Policy,
-Indentation);
-  }
+  VisitNonTypeTemplateParmDecl(NTTP);
 } else if (auto TTPD = dyn_cast(Param)) {
   VisitTemplateDecl(TTPD);
   // FIXME: print the default argument, if present.
@@ -1705,3 +1680,36 @@
   D->getInit()->printPretty(Out, nullptr, Policy, Indentation);
 }
 
+void DeclPrinter::VisitTemplateTypeParmDecl(const TemplateTypeParmDecl *TTP) {
+  if (const TypeConstraint *TC = TTP->getTypeConstraint())
+TC->print(Out, Policy);
+  else if (TTP->wasDeclaredWithTypename())
+Out << "typename";
+  else
+Out << "class";
+
+  if (TTP->isParameterPack())
+Out << " ...";
+  else if (!TTP->getName().empty())
+Out << ' ';
+
+  Out << *TTP;
+
+  if (TTP->hasDefaultArgument()) {
+Out << " = ";
+Out << TTP->getDefaultArgument().getAsString(Policy);
+  }
+}
+
+void DeclPrinter::VisitNonTypeTemplateParmDecl(
+const NonTypeTemplateParmDecl *NTTP) {
+  StringRef Name;
+  if (IdentifierInfo *II = NTTP->getIdentifier())
+Name = II->getName();
+  printDeclType(NTTP->getType(), Name, NTTP->isParameterPack());
+
+  if (NTTP->hasDefaultArgument()) {
+Out << " = ";
+NTTP->getDefaultArgument()->printPretty(Out, nullptr, Policy, Indentation);
+  }
+}
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -215,8 +215,7 @@
 template 
 int x = [[T::]]y;
   )cpp";
-  // FIXME: We don't do a good job printing TemplateTypeParmDecls, apparently!
-  EXPECT_DECLS("NestedNameSpecifierLoc", "");
+  EXPECT_DECLS("NestedNameSpecifierLoc", "typename T");
 
   Code = R"cpp(
 namespace a { int x; }
@@ -249,8 +248,7 @@
 template
 void foo() { [[T]] x; }
   )cpp";
-  // FIXME: We don't do a good job printing TemplateTypeParmDecls, apparently!
-  EXPECT_DECLS("TemplateTypeParmTypeLoc", "");
+  EXPECT_DECLS("TemplateTypeParmTypeLoc", "class T");
   Flags.clear();
 
   // FIXME: Auto-completion in a template requires disabling delayed template
@@ -283,8 +281,7 @@
   static const int size = sizeof...([[E]]);
 };
   )cpp";
-  // FIXME: We don't do a good job printing TemplateTypeParmDecls, apparently!
-  EXPECT_DECLS("SizeOfPackExpr", "");
+  EXPECT_DECLS("SizeOfPackExpr", "typename ...E");
 
   Code = R"cpp(
 template 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73696: [clang][Index] Introduce a TemplateParm SymbolKind

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

Currently template parameters has symbolkind `Unknown`. This patch
introduces a new kind `TemplateParm` for templatetemplate, templatetype and
nontypetemplate parameters.

Also adds tests in clangd hover feature.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73696

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Quality.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp
  clang/include/clang-c/Index.h
  clang/include/clang/Index/IndexSymbol.h
  clang/lib/Index/IndexSymbol.cpp
  clang/tools/c-index-test/c-index-test.c
  clang/tools/libclang/CXIndexDataConsumer.cpp
  clang/unittests/Index/IndexTests.cpp

Index: clang/unittests/Index/IndexTests.cpp
===
--- clang/unittests/Index/IndexTests.cpp
+++ clang/unittests/Index/IndexTests.cpp
@@ -248,9 +248,12 @@
   Opts.IndexTemplateParameters = true;
   Index->Symbols.clear();
   tooling::runToolOnCode(std::make_unique(Index, Opts), Code);
-  EXPECT_THAT(Index->Symbols,
-  AllOf(Contains(QName("Foo::T")), Contains(QName("Foo::I")),
-Contains(QName("Foo::C")), Contains(QName("Foo::NoRef";
+  EXPECT_THAT(
+  Index->Symbols,
+  AllOf(Contains(AllOf(QName("Foo::T"), Kind(SymbolKind::TemplateParm))),
+Contains(AllOf(QName("Foo::I"), Kind(SymbolKind::TemplateParm))),
+Contains(AllOf(QName("Foo::C"), Kind(SymbolKind::TemplateParm))),
+Contains(QName("Foo::NoRef";
 }
 
 TEST(IndexTest, UsingDecls) {
Index: clang/tools/libclang/CXIndexDataConsumer.cpp
===
--- clang/tools/libclang/CXIndexDataConsumer.cpp
+++ clang/tools/libclang/CXIndexDataConsumer.cpp
@@ -1284,6 +1284,7 @@
   case SymbolKind::Destructor: return CXIdxEntity_CXXDestructor;
   case SymbolKind::ConversionFunction: return CXIdxEntity_CXXConversionFunction;
   case SymbolKind::Parameter: return CXIdxEntity_Variable;
+  case SymbolKind::TemplateParm: return CXIdxEntity_CXXTemplateParm;
   }
   llvm_unreachable("invalid symbol kind");
 }
Index: clang/tools/c-index-test/c-index-test.c
===
--- clang/tools/c-index-test/c-index-test.c
+++ clang/tools/c-index-test/c-index-test.c
@@ -3471,6 +3471,7 @@
   case CXIdxEntity_CXXConversionFunction: return "conversion-func";
   case CXIdxEntity_CXXTypeAlias: return "type-alias";
   case CXIdxEntity_CXXInterface: return "c++-__interface";
+  case CXIdxEntity_CXXTemplateParm: return "c++-template-parm";
   }
   assert(0 && "Garbage entity kind");
   return 0;
Index: clang/lib/Index/IndexSymbol.cpp
===
--- clang/lib/Index/IndexSymbol.cpp
+++ clang/lib/Index/IndexSymbol.cpp
@@ -357,6 +357,11 @@
 case Decl::VarTemplate:
   llvm_unreachable("variables handled before");
   break;
+case Decl::TemplateTypeParm:
+case Decl::TemplateTemplateParm:
+case Decl::NonTypeTemplateParm:
+  Info.Kind = SymbolKind::TemplateParm;
+  break;
 // Other decls get the 'unknown' kind.
 default:
   break;
@@ -517,6 +522,7 @@
   case SymbolKind::ConversionFunction: return "conversion-func";
   case SymbolKind::Parameter: return "param";
   case SymbolKind::Using: return "using";
+  case SymbolKind::TemplateParm: return "template-param";
   }
   llvm_unreachable("invalid symbol kind");
 }
Index: clang/include/clang/Index/IndexSymbol.h
===
--- clang/include/clang/Index/IndexSymbol.h
+++ clang/include/clang/Index/IndexSymbol.h
@@ -54,6 +54,7 @@
 
   Parameter,
   Using,
+  TemplateParm,
 };
 
 enum class SymbolLanguage : uint8_t {
Index: clang/include/clang-c/Index.h
===
--- clang/include/clang-c/Index.h
+++ clang/include/clang-c/Index.h
@@ -6253,7 +6253,8 @@
   CXIdxEntity_CXXDestructor = 23,
   CXIdxEntity_CXXConversionFunction = 24,
   CXIdxEntity_CXXTypeAlias  = 25,
-  CXIdxEntity_CXXInterface  = 26
+  CXIdxEntity_CXXInterface  = 26,
+  CXIdxEntity_CXXTemplateParm   = 27
 
 } CXIdxEntityKind;
 
Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -573,6 +573,40 @@
  // pattern.
  HI.Documentation = "comment from primary";
}},
+  {// Template Type Parameter
+   R"cpp(
+  template  void foo();
+  )cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "T

[PATCH] D73644: [Mips] Add intrinsics for 4-byte and 8-byte MSA loads/stores.

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

Is it possible to emulate these new intrinsics using existing ones and some 
additional code? Is code generated in this case much larger/slower then the 
code generated by the new intrinsics?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73644



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


[PATCH] D73693: [clang][DeclPrinter] Implement visitors for {TemplateType,NonTypeTemplate}Parms

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

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

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

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

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


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73693



___
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-30 Thread Diogo N. Sampaio via Phabricator via cfe-commits
dnsampaio updated this revision to Diff 241421.
dnsampaio added a comment.
Herald added a subscriber: jfb.

- Moved computation of volatile accesses to the record layout builder


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/CGRecordLayout.h
  clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
  clang/test/CodeGen/aapcs-bitfield.c
  clang/test/CodeGen/bitfield-2.c

Index: clang/test/CodeGen/bitfield-2.c
===
--- clang/test/CodeGen/bitfield-2.c
+++ clang/test/CodeGen/bitfield-2.c
@@ -1,3 +1,4 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
 // RUN: %clang_cc1 -emit-llvm -triple x86_64 -O3 -o %t.opt.ll %s \
 // RUN:   -fdump-record-layouts > %t.dump.txt
 // RUN: FileCheck -check-prefix=CHECK-RECORD < %t.dump.txt %s
@@ -14,7 +15,7 @@
 // CHECK-RECORD:   LLVMType:%struct.s0 = type { [3 x i8] }
 // CHECK-RECORD:   IsZeroInitializable:1
 // CHECK-RECORD:   BitFields:[
-// CHECK-RECORD: 
+// CHECK-RECORD: 
-// CHECK-RECORD: 
+// CHECK-RECORD: 
+// CHECK-RECORD: 
-// CHECK-RECORD: 
+// CHECK-RECORD: 
 
 struct __attribute__((packed)) s9 {
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

[PATCH] D73696: [clang][Index] Introduce a TemplateParm SymbolKind

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

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

  failed: libc++.std/containers/sequences/array/array_creation/to_array.fail.cpp

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

{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-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73696



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


[clang] f9f0919 - [clang-format] Improve support for multiline C# strings

2020-01-30 Thread Jonathan Coe via cfe-commits

Author: Jonathan Coe
Date: 2020-01-30T13:45:48Z
New Revision: f9f0919db7ea033a205c87eb08c81c4baaecd846

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

LOG: [clang-format] Improve support for multiline C# strings

Reviewers: krasimir

Reviewed By: krasimir

Tags: #clang-format

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

Added: 


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

Removed: 




diff  --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index ec2de35ca0d2..1ea7eb031d36 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -1760,7 +1760,7 @@ ContinuationIndenter::createBreakableToken(const 
FormatToken &Current,
LineState &State, bool AllowBreak) {
   unsigned StartColumn = State.Column - Current.ColumnWidth;
   if (Current.isStringLiteral()) {
-// FIXME: String literal breaking is currently disabled for C#,Java and
+// FIXME: String literal breaking is currently disabled for C#, Java and
 // JavaScript, as it requires strings to be merged using "+" which we
 // don't support.
 if (Style.Language == FormatStyle::LK_Java ||

diff  --git a/clang/lib/Format/FormatTokenLexer.cpp 
b/clang/lib/Format/FormatTokenLexer.cpp
index ba0bbf68f12f..98650951c7d0 100644
--- a/clang/lib/Format/FormatTokenLexer.cpp
+++ b/clang/lib/Format/FormatTokenLexer.cpp
@@ -57,6 +57,10 @@ ArrayRef FormatTokenLexer::lex() {
 if (Style.Language == FormatStyle::LK_TextProto)
   tryParsePythonComment();
 tryMergePreviousTokens();
+if (Style.isCSharp())
+  // This needs to come after tokens have been merged so that C#
+  // string literals are correctly identified.
+  handleCSharpVerbatimAndInterpolatedStrings();
 if (Tokens.back()->NewlinesBefore > 0 || Tokens.back()->IsMultiline)
   FirstInLineIndex = Tokens.size() - 1;
   } while (Tokens.back()->Tok.isNot(tok::eof));
@@ -181,12 +185,12 @@ bool FormatTokenLexer::tryMergeJSPrivateIdentifier() {
 // Search for verbatim or interpolated string literals @"ABC" or
 // $"a{abc}a" i and mark the token as TT_CSharpStringLiteral, and to
 // prevent splitting of @, $ and ".
+// Merging of multiline verbatim strings with embedded '"' is handled in
+// handleCSharpVerbatimAndInterpolatedStrings with lower-level lexing.
 bool FormatTokenLexer::tryMergeCSharpStringLiteral() {
   if (Tokens.size() < 2)
 return false;
 
-  auto &CSharpStringLiteral = *(Tokens.end() - 2);
-
   // Interpolated strings could contain { } with " characters inside.
   // $"{x ?? "null"}"
   // should not be split into $"{x ?? ", null, "}" but should treated as a
@@ -236,27 +240,12 @@ bool FormatTokenLexer::tryMergeCSharpStringLiteral() {
 }
   }
 
-  // verbatim strings could contain "" which C# sees as an escaped ".
-  // @"""Hello""" will have been tokenized as @"" "Hello" "" and needs
-  // merging into a single string literal.
+  // Look for @"aa" or $"aa".
   auto &String = *(Tokens.end() - 1);
   if (!String->is(tok::string_literal))
 return false;
 
-  if (CSharpStringLiteral->Type == TT_CSharpStringLiteral &&
-  (CSharpStringLiteral->TokenText.startswith(R"(@")") ||
-   CSharpStringLiteral->TokenText.startswith(R"($@")"))) {
-CSharpStringLiteral->TokenText = StringRef(
-CSharpStringLiteral->TokenText.begin(),
-String->TokenText.end() - CSharpStringLiteral->TokenText.begin());
-CSharpStringLiteral->ColumnWidth += String->ColumnWidth;
-Tokens.erase(Tokens.end() - 1);
-return true;
-  }
-
   auto &At = *(Tokens.end() - 2);
-
-  // Look for @"aa" or $"aa".
   if (!(At->is(tok::at) || At->TokenText == "$"))
 return false;
 
@@ -498,6 +487,68 @@ void FormatTokenLexer::tryParseJSRegexLiteral() {
   resetLexer(SourceMgr.getFileOffset(Lex->getSourceLocation(Offset)));
 }
 
+void FormatTokenLexer::handleCSharpVerbatimAndInterpolatedStrings() {
+  FormatToken *CSharpStringLiteral = Tokens.back();
+
+  if (CSharpStringLiteral->Type != TT_CSharpStringLiteral)
+return;
+
+  // Deal with multiline strings.
+  if (!(CSharpStringLiteral->TokenText.startswith(R"(@")") ||
+CSharpStringLiteral->TokenText.startswith(R"($@")")))
+return;
+
+  const char *StrBegin =
+  Lex->getBufferLocation() - CSharpStringLiteral->TokenText.size();
+  const char *Offset = StrBegin;
+  if (CSharpStringLiteral->TokenText.startswith(R"(@")"))
+Offset += 2;
+  else // CSharpStringLiteral->TokenText.startswith(R"($@")")
+Offset += 3;
+
+  // Look for a terminating '"' in the curr

[PATCH] D73622: [clang-format] Improve support for multiline C# strings

2020-01-30 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf9f0919db7ea: [clang-format] Improve support for multiline 
C# strings (authored by Jonathan Coe ).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73622

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

Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -412,9 +412,9 @@
 TEST_F(FormatTestCSharp, CSharpEscapedQuotesInVerbatimStrings) {
   FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
 
-  verifyFormat(R"(string str = @)", Style);
-  verifyFormat(R"(string str = @"""Hello world""")", Style);
-  verifyFormat(R"(string str = $@"""Hello {friend}""")", Style);
+  verifyFormat(R"(string str = @;)", Style);
+  verifyFormat(R"(string str = @"""Hello world""";)", Style);
+  verifyFormat(R"(string str = $@"""Hello {friend}""";)", Style);
 }
 
 TEST_F(FormatTestCSharp, CSharpQuotesInInterpolatedStrings) {
@@ -425,5 +425,37 @@
   verifyFormat(R"(string str3 = $"{braceCount}}} braces";)", Style);
 }
 
+TEST_F(FormatTestCSharp, CSharpNewlinesInVerbatimStrings) {
+  // Use MS style as Google Style inserts a line break before multiline strings.
+
+  // verifyFormat does not understand multiline C# string-literals
+  // so check the format explicitly.
+
+  FormatStyle Style = getMicrosoftStyle(FormatStyle::LK_CSharp);
+
+  std::string Code = R"(string s1 = $@"some code:
+  class {className} {{
+{className}() {{}}
+  }}";)";
+
+  EXPECT_EQ(Code, format(Code, Style));
+
+  // Multiline string in the middle of a function call.
+  Code = R"(
+var x = foo(className, $@"some code:
+  class {className} {{
+{className}() {{}}
+  }}",
+y);)"; // y aligned with `className` arg.
+
+  EXPECT_EQ(Code, format(Code, Style));
+
+  // Interpolated string with embedded multiline string.
+  Code = R"(Console.WriteLine($"{string.Join(@",
+		", values)}");)";
+
+  EXPECT_EQ(Code, format(Code, Style));
+}
+
 } // namespace format
 } // end namespace clang
Index: clang/lib/Format/FormatTokenLexer.h
===
--- clang/lib/Format/FormatTokenLexer.h
+++ clang/lib/Format/FormatTokenLexer.h
@@ -79,6 +79,8 @@
   // nested template parts by balancing curly braces.
   void handleTemplateStrings();
 
+  void handleCSharpVerbatimAndInterpolatedStrings();
+
   void tryParsePythonComment();
 
   bool tryMerge_TMacro();
Index: clang/lib/Format/FormatTokenLexer.cpp
===
--- clang/lib/Format/FormatTokenLexer.cpp
+++ clang/lib/Format/FormatTokenLexer.cpp
@@ -57,6 +57,10 @@
 if (Style.Language == FormatStyle::LK_TextProto)
   tryParsePythonComment();
 tryMergePreviousTokens();
+if (Style.isCSharp())
+  // This needs to come after tokens have been merged so that C#
+  // string literals are correctly identified.
+  handleCSharpVerbatimAndInterpolatedStrings();
 if (Tokens.back()->NewlinesBefore > 0 || Tokens.back()->IsMultiline)
   FirstInLineIndex = Tokens.size() - 1;
   } while (Tokens.back()->Tok.isNot(tok::eof));
@@ -181,12 +185,12 @@
 // Search for verbatim or interpolated string literals @"ABC" or
 // $"a{abc}a" i and mark the token as TT_CSharpStringLiteral, and to
 // prevent splitting of @, $ and ".
+// Merging of multiline verbatim strings with embedded '"' is handled in
+// handleCSharpVerbatimAndInterpolatedStrings with lower-level lexing.
 bool FormatTokenLexer::tryMergeCSharpStringLiteral() {
   if (Tokens.size() < 2)
 return false;
 
-  auto &CSharpStringLiteral = *(Tokens.end() - 2);
-
   // Interpolated strings could contain { } with " characters inside.
   // $"{x ?? "null"}"
   // should not be split into $"{x ?? ", null, "}" but should treated as a
@@ -236,27 +240,12 @@
 }
   }
 
-  // verbatim strings could contain "" which C# sees as an escaped ".
-  // @"""Hello""" will have been tokenized as @"" "Hello" "" and needs
-  // merging into a single string literal.
+  // Look for @"aa" or $"aa".
   auto &String = *(Tokens.end() - 1);
   if (!String->is(tok::string_literal))
 return false;
 
-  if (CSharpStringLiteral->Type == TT_CSharpStringLiteral &&
-  (CSharpStringLiteral->TokenText.startswith(R"(@")") ||
-   CSharpStringLiteral->TokenText.startswith(R"($@")"))) {
-CSharpStringLiteral->TokenText = StringRef(
-CSharpStringLiteral->TokenText.begin(),
-String->TokenText.end() - CSharpStringLiteral->TokenText.begin());
-CSharpStringLiteral->C

[PATCH] D73622: [clang-format] Improve support for multiline C# strings

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

these are great patches you are making...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73622



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


[PATCH] D72222: [Driver][CodeGen] Add -fpatchable-function-entry=N[,0]

2020-01-30 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.



> I created D73680  to place the patch label 
> after BTI.
> 
> @hans Is there still time to cherry pick the patch to release/10.x? See 
> above, Linux developers really want the Clang release to have compatible 
> behavior with GCC.

Yes, there is still time. Just let me know which commits to cherry-pick.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D7



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


[PATCH] D73701: [clang] fix linkage of nested lambda

2020-01-30 Thread Philippe Daouadi via Phabricator via cfe-commits
blastrock created this revision.
blastrock added reviewers: rjmccall, hliao.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This is an attempt to fix https://bugs.llvm.org/show_bug.cgi?id=44368

I don't know why the comment said that we should take the linkage of the 
outermost lambda's parent. That would be the foo() function in the test, which 
has external linkage. But we want the symbol to have internal linkage because 
it is nested in an instantiation of the generic lambda with a template 
parameter that is a closure from a static function.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73701

Files:
  clang/lib/AST/Decl.cpp
  clang/test/CodeGenCXX/lambda-expressions-nested-linkage.cpp


Index: clang/test/CodeGenCXX/lambda-expressions-nested-linkage.cpp
===
--- clang/test/CodeGenCXX/lambda-expressions-nested-linkage.cpp
+++ clang/test/CodeGenCXX/lambda-expressions-nested-linkage.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fblocks -emit-llvm -o - 
%s -fexceptions -std=c++11 | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fblocks -emit-llvm -o - 
%s -fexceptions -std=c++14 | FileCheck %s
 
 // CHECK-LABEL: define void @_ZN19non_inline_function3fooEv()
 // CHECK-LABEL: define internal void 
@"_ZZN19non_inline_function3fooEvENK3$_0clEi"(%class.anon
@@ -51,3 +51,16 @@
 }
 int use = foo();
 }
+
+// CHECK-LABEL: define internal void 
@"_ZZZN32lambda_capture_in_generic_lambda3fooIiEEDavENKUlT_E_clIZNS_L1fEvE3$_1EEDaS1_ENKUlvE_clEv"
+namespace lambda_capture_in_generic_lambda {
+template  auto foo() {
+  return [](auto func) {
+[func] { func(); }();
+  };
+}
+static void f() {
+  foo()([] { });
+}
+void f1() { f(); }
+}
Index: clang/lib/AST/Decl.cpp
===
--- clang/lib/AST/Decl.cpp
+++ clang/lib/AST/Decl.cpp
@@ -1399,7 +1399,7 @@
 // This lambda has its linkage/visibility determined:
 //  - either by the outermost lambda if that lambda has no mangling
 //number.
-//  - or by the parent of the outer most lambda
+//  - or by the parent of the current lambda
 // This prevents infinite recursion in settings such as nested lambdas
 // used in NSDMI's, for e.g.
 //  struct L {
@@ -1413,8 +1413,8 @@
   return getInternalLinkageFor(D);
 
 return getLVForClosure(
-  OuterMostLambda->getDeclContext()->getRedeclContext(),
-  OuterMostLambda->getLambdaContextDecl(), computation);
+  Record->getDeclContext()->getRedeclContext(),
+  Record->getLambdaContextDecl(), computation);
   }
 
   break;


Index: clang/test/CodeGenCXX/lambda-expressions-nested-linkage.cpp
===
--- clang/test/CodeGenCXX/lambda-expressions-nested-linkage.cpp
+++ clang/test/CodeGenCXX/lambda-expressions-nested-linkage.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fblocks -emit-llvm -o - %s -fexceptions -std=c++11 | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fblocks -emit-llvm -o - %s -fexceptions -std=c++14 | FileCheck %s
 
 // CHECK-LABEL: define void @_ZN19non_inline_function3fooEv()
 // CHECK-LABEL: define internal void @"_ZZN19non_inline_function3fooEvENK3$_0clEi"(%class.anon
@@ -51,3 +51,16 @@
 }
 int use = foo();
 }
+
+// CHECK-LABEL: define internal void @"_ZZZN32lambda_capture_in_generic_lambda3fooIiEEDavENKUlT_E_clIZNS_L1fEvE3$_1EEDaS1_ENKUlvE_clEv"
+namespace lambda_capture_in_generic_lambda {
+template  auto foo() {
+  return [](auto func) {
+[func] { func(); }();
+  };
+}
+static void f() {
+  foo()([] { });
+}
+void f1() { f(); }
+}
Index: clang/lib/AST/Decl.cpp
===
--- clang/lib/AST/Decl.cpp
+++ clang/lib/AST/Decl.cpp
@@ -1399,7 +1399,7 @@
 // This lambda has its linkage/visibility determined:
 //  - either by the outermost lambda if that lambda has no mangling
 //number.
-//  - or by the parent of the outer most lambda
+//  - or by the parent of the current lambda
 // This prevents infinite recursion in settings such as nested lambdas
 // used in NSDMI's, for e.g.
 //  struct L {
@@ -1413,8 +1413,8 @@
   return getInternalLinkageFor(D);
 
 return getLVForClosure(
-  OuterMostLambda->getDeclContext()->getRedeclContext(),
-  OuterMostLambda->getLambdaContextDecl(), computation);
+  Record->getDeclContext()->getRedeclContext(),
+  Record->getLambdaContextDecl(), computation);
   }
 
   break;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/l

[PATCH] D73437: [mlir][spirv] Convert linalg.generic for reduction to SPIR-V ops

2020-01-30 Thread Lei Zhang via Phabricator via cfe-commits
antiagainst updated this revision to Diff 241431.
antiagainst marked 16 inline comments as done.
antiagainst added a comment.

Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73437

Files:
  mlir/include/mlir/Conversion/LinalgToSPIRV/LinalgToSPIRV.h
  mlir/include/mlir/Conversion/LinalgToSPIRV/LinalgToSPIRVPass.h
  mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td
  mlir/include/mlir/Dialect/Linalg/IR/LinalgTraits.h
  mlir/include/mlir/Dialect/Linalg/Utils/Utils.h
  mlir/include/mlir/Dialect/SPIRV/SPIRVAtomicOps.td
  mlir/include/mlir/Dialect/SPIRV/SPIRVControlFlowOps.td
  mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.h
  mlir/include/mlir/Dialect/SPIRV/TargetAndABI.h
  mlir/lib/Conversion/CMakeLists.txt
  mlir/lib/Conversion/LinalgToSPIRV/CMakeLists.txt
  mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp
  mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRVPass.cpp
  mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp
  mlir/lib/Dialect/Linalg/Utils/Utils.cpp
  mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp
  mlir/lib/Dialect/SPIRV/SPIRVOps.cpp
  mlir/lib/Dialect/SPIRV/TargetAndABI.cpp
  mlir/test/Conversion/LinalgToSPIRV/linalg-to-spirv.mlir
  mlir/tools/mlir-opt/CMakeLists.txt

Index: mlir/tools/mlir-opt/CMakeLists.txt
===
--- mlir/tools/mlir-opt/CMakeLists.txt
+++ mlir/tools/mlir-opt/CMakeLists.txt
@@ -40,6 +40,7 @@
   MLIRQuantOps
   MLIRROCDLIR
   MLIRSPIRV
+  MLIRLinalgToSPIRVTransforms
   MLIRStandardToSPIRVTransforms
   MLIRSPIRVTestPasses
   MLIRSPIRVTransforms
Index: mlir/test/Conversion/LinalgToSPIRV/linalg-to-spirv.mlir
===
--- /dev/null
+++ mlir/test/Conversion/LinalgToSPIRV/linalg-to-spirv.mlir
@@ -0,0 +1,162 @@
+// RUN: mlir-opt -split-input-file -convert-linalg-to-spirv -canonicalize -verify-diagnostics %s -o - | FileCheck %s
+
+//===--===//
+// Single workgroup reduction
+//===--===//
+
+#single_workgroup_reduction_trait = {
+  args_in = 1,
+  args_out = 1,
+  iterator_types = ["reduction"],
+  indexing_maps = [
+affine_map<(i) -> (i)>,
+affine_map<(i) -> (0)>
+  ]
+}
+
+module attributes {
+  spv.target_env = {
+version = 3 : i32,
+extensions = [],
+capabilities = [1: i32, 63: i32] // Shader, GroupNonUniformArithmetic
+  }
+} {
+
+// CHECK:  spv.globalVariable
+// CHECK-SAME: built_in("LocalInvocationId")
+
+// CHECK:  func @single_workgroup_reduction
+// CHECK-SAME: (%[[INPUT:.+]]: !spv.ptr{{.+}}, %[[OUTPUT:.+]]: !spv.ptr{{.+}})
+
+// CHECK:%[[ZERO:.+]] = spv.constant 0 : i32
+// CHECK:%[[ID:.+]] = spv.Load "Input" %{{.+}} : vector<3xi32>
+// CHECK:%[[X:.+]] = spv.CompositeExtract %[[ID]][0 : i32]
+
+// CHECK:%[[INPTR:.+]] = spv.AccessChain %[[INPUT]][%[[ZERO]], %[[X]]]
+// CHECK:%[[VAL:.+]] = spv.Load "StorageBuffer" %[[INPTR]] : i32
+// CHECK:%[[ADD:.+]] = spv.GroupNonUniformIAdd "Subgroup" "Reduce" %[[VAL]] : i32
+
+// CHECK:%[[OUTPTR:.+]] = spv.AccessChain %[[OUTPUT]][%[[ZERO]], %[[ZERO]]]
+// CHECK:%[[ELECT:.+]] = spv.GroupNonUniformElect "Subgroup" : i1
+
+// CHECK:spv.selection {
+// CHECK:  spv.BranchConditional %[[ELECT]], ^bb1, ^bb2
+// CHECK:^bb1:
+// CHECK:  spv.AtomicIAdd "Device" "AcquireRelease" %[[OUTPTR]], %[[ADD]]
+// CHECK:  spv.Branch ^bb2
+// CHECK:^bb2:
+// CHECK:  spv._merge
+// CHECK:}
+// CHECK:spv.Return
+
+func @single_workgroup_reduction(%input: memref<16xi32>, %output: memref<1xi32>) attributes {
+  spv.entry_point_abi = {local_size = dense<[16, 1, 1]>: vector<3xi32>}
+} {
+  linalg.generic #single_workgroup_reduction_trait %input, %output {
+^bb(%in: i32, %out: i32):
+  %sum = addi %in, %out : i32
+  linalg.yield %sum : i32
+  } : memref<16xi32>, memref<1xi32>
+  spv.Return
+}
+}
+
+// -
+
+// Missing shader entry point ABI
+
+#single_workgroup_reduction_trait = {
+  args_in = 1,
+  args_out = 1,
+  iterator_types = ["reduction"],
+  indexing_maps = [
+affine_map<(i) -> (i)>,
+affine_map<(i) -> (0)>
+  ]
+}
+
+module attributes {
+  spv.target_env = {
+version = 3 : i32,
+extensions = [],
+capabilities = [1: i32, 63: i32] // Shader, GroupNonUniformArithmetic
+  }
+} {
+func @single_workgroup_reduction(%input: memref<16xi32>, %output: memref<1xi32>) {
+  // expected-error @+1 {{failed to legalize operation 'linalg.generic'}}
+  linalg.generic #single_workgroup_reduction_trait %input, %output {
+^bb(%in: i32, %out: i32):
+  %sum = addi %in, %out : i32
+  linalg.yield %sum : i32
+  } : memref<16xi32>, memref<1xi32>
+  return
+}
+}
+
+// -
+
+// Mismatch between shader entry poi

[PATCH] D73437: [mlir][spirv] Convert linalg.generic for reduction to SPIR-V ops

2020-01-30 Thread Lei Zhang via Phabricator via cfe-commits
antiagainst added inline comments.



Comment at: mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp:182
+  // Perform the group reduction operation.
+  Value groupOperation = rewriter.create(
+  loc, originalInputType.getElementType(), spirv::Scope::Subgroup,

mravishankar wrote:
> mravishankar wrote:
> > antiagainst wrote:
> > > mravishankar wrote:
> > > > This is hard-wiring to IAdd. We probably need to structure this 
> > > > differently. We need to have a pattern to lower the linalg.generic with 
> > > > reduction iterator into the kernel generated here, and then lower the 
> > > > operations within the region separately.
> > > It was intentional to only support IAdd. I've re-structured this a bit so 
> > > it's extensible to other binary op kinds.
> > The way I see this structured is
> > 
> > 1) You check the "structure" of the linalg.generic op to see if it is a 1D 
> > reduction. You assume that the body of the generic op represents a binary 
> > operation that can be used for the reduction.
> > 2) You write a separate pattern that converts the operations of the body 
> > itself into the spirv::GroupNonUniform*Op.
> > 
> > The dialect conversion will first convert the generic op, and then it will 
> > attempt to convert the body of the op. The way this is strucutred, it can 
> > only handle straight-forward binary operations. THere could be more 
> > complicated operations in the region of a generic op that implements the 
> > reduction, which would be hard to incorporate in this approach.
> > 
> > With your updated changes, it is easy to extend to other ops, but I think a 
> > more general solution is needed where we are not constrained in handling 
> > just simple reductions. It might need some more careful design though, 
> > which I dont have a full picture of right now. So for now this OK, but 
> > please leave a TODO to say something like "handle more general reductions".
> Thought about this a little bit more. It will be a more sane strategy to not 
> handle cases where the region is "inlined" into the generic op, but rather 
> the region is specified as a function using the `fun` attribute of the 
> `linalg.generic` op. Then we can split the lowering of the generic op and the 
> lowering of the function that does the reduction separately.
> This too not needed for this CL. Should revisit this
Yeah, right now linalg.generic is an integrated entity; I'm not sure how we can 
easily convert part of it (the "structure") and then the inlined scalar region. 
I guess it's fine for now to overfit a bit until later we see concrete cases 
that we want to support, which will give us a more tangible problem to solve. 



Comment at: mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp:27
+/// types.
+static bool areAllValuesMemref(Operation *op) {
+  auto isOfMemrefType = [](Value val) {

nicolasvasilache wrote:
> Please use `LinalgOp::hasBufferSemantics` instead of rolling your own
Oh, didn't know we have that. Thanks!



Comment at: mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp:80
+  auto ®ion = op.region();
+  if (region.empty() || !has_single_element(region.getBlocks()))
+return BinaryOpKind::Unknown;

rriddle wrote:
> You should be able to remove the .empty() call as well as the .getBlocks()
Nice, thanks!



Comment at: mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp:125
+
+PatternMatchResult SingleWorkgroupReduction::matchAndRewrite(
+linalg::GenericOp genericOp, ArrayRef operands,

nicolasvasilache wrote:
> Please split this into a precondition and an apply that must succeed so we 
> can use the precondition as a Constraint and the apply as a simple Rewrite.
> I have found this split to be crucial to write custom fused passes with DRR.
> I claim this is generally the way we should be writing transformations when 
> we can, which is the case for Linalg ops. 
I feel I don't have all the backgrounds here so I'd appreciate some explanation 
as for why it's necessary to separate the match and rewrite. I think that's the 
original design of patterns (that we have `match` and `rewrite` separately) and 
then later we found it's too cumbersome to carry over a large matched state 
between them and then came up with `matchAndRewrite`? IIUC, every pattern is 
applied as a whole. I can understand that the match/rewrite side can be 
potentially reusable across patterns as components if they are exposed as 
helper functions, but that's more from a library organization and code reuse's 
perspective; I feel you've more reasons than that so I'd like to learn about 
them. :) 

Another question here is that I've matches that is generally useful to other 
patterns (checking whether this is a linalg doing reduction) and matches that 
is only useful to SPIR-V here (checking whether the workload can be fit in one 
local workgroup). How do you handle such cases?

For now I 

[PATCH] D73242: [WPD/LowerTypeTests] Delay lowering/removal of type tests until after ICP

2020-01-30 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson marked an inline comment as done.
tejohnson added a comment.

In D73242#1847051 , @evgeny777 wrote:

> > This is an enabler for upcoming enhancements to indirect call promotion, 
> > for example streamlined promotion guard sequences that compare against 
> > vtable address instead of the target function
>
> Can you please describe the whole approach in more detail? At the moment ICP 
> is capable to do (a sort of) devirtualization is replacing indirect vtbl call 
> with sequence of function address comparisons and direct calls.
>  Are you going to speedup this by means of comparing vtable pointers instead 
> of function pointers (thus eliminating a single load per each vtbl call) or 
> there is also something else in mind?


That's exactly what we want to do here. We found a relatively significant 
number of cycles are being spent on virtual function pointer loads in these 
sequences, and by doing a vtable comparison instead, that is moved off the 
critical path. I had prototyped something like this in ICP awhile back and 
found a speedup in an important app.

> If that's true, what's the next
>  step? Make ICP pass analyze type test intrinsics?

There are a few ways to do the alternate ICP compare sequences, one is using 
statically available info from the vtable definitions in the module that 
utilize the profiled target. This relies on ThinLTO to import all the relevant 
vtable definitions. The other is to profile vtable addresses with FDO (not just 
the target function pointer) - I've got the type profiling implemented, but it 
needs some cleanup before I send for review. Both of these approaches need the 
type tests to determine the correct address point offset (the offset in the 
type test) to use in the compare sequence. And in both cases you want to trade 
off the number of comparisons needed for the two approaches to determine 
whether a vtable compare or a target function compare is better. I.e. if there 
are a lot of vtable definitions that utilize a hot target, it is likely better 
to do a single target function comparison.




Comment at: llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp:1660
+cast(CI->getArgOperand(1))->getMetadata();
 // If we found any, add them to CallSlots.
 if (!Assumes.empty()) {

evgeny777 wrote:
> This change seems to be unrelated
It is needed to have the TypeId available outside this if statement (see the 
map check below).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73242



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


[PATCH] D73675: Avoid many std::tie/tuple instantiations in ASTImporter

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



Comment at: clang/lib/AST/ASTImporter.cpp:1152
+  if (Error E = importSeq(ToElementType, ToSizeExpr))
+return std::move(E);
 

martong wrote:
> Quuxplusone wrote:
> > As the author of [P1155 "More Implicit Move"](https://wg21.link/p1155), I 
> > would expect that you don't need `return std::move(E)` — `return E` should 
> > just as well perform "implicit move" in C++11 and later, assuming that 
> > `llvm::Expected` has a valid constructor from `llvm::Error&&`.
> > 
> > You're not seeing any compiler diagnostic that //suggests// you use 
> > `std::move` here, are you?
> I have some vague and obscure memory about that GCC 4.8 (or 5.2) required 
> explicitly the && cast, otherwise we had a diagnostic (@gamesh411 maybe you 
> help me to recall that?)
Ah, you are absolutely correct: GCC 4.9.4 does not do implicit move in this 
situation, whereas GCC 5.1 and later do do it.
https://godbolt.org/z/YDHtTH
I didn't realize that portability back to GCC 4.9 was still a concern for 
LLVM/Clang. If it is, then please feel free to keep the `std::move` here and 
throughout (but maybe mention it in the commit message for the benefit of 
others who might think as I did).  If portability back to pre-GCC-5 is //not// 
a concern, then I would continue to recommend removing the `std::move`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73675



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


[PATCH] D73437: [mlir][spirv] Convert linalg.generic for reduction to SPIR-V ops

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

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

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

{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-tidy.txt 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73437



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


[clang] 601687b - [analyzer] DynamicSize: Remove 'getExtent()' from regions

2020-01-30 Thread via cfe-commits

Author: Charusso
Date: 2020-01-30T16:05:18+01:00
New Revision: 601687bf731a33364a7de0ece7acd1c17c9dd60d

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

LOG: [analyzer] DynamicSize: Remove 'getExtent()' from regions

Summary:
This patch introduces a placeholder for representing the dynamic size of
regions. It also moves the `getExtent()` method of `SubRegions` to the
`MemRegionManager` as `getStaticSize()`.

Reviewed By: NoQ

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

Added: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h
clang/lib/StaticAnalyzer/Core/DynamicSize.cpp

Modified: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
clang/lib/StaticAnalyzer/Checkers/CastSizeChecker.cpp
clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp
clang/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp
clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
clang/lib/StaticAnalyzer/Core/CMakeLists.txt
clang/lib/StaticAnalyzer/Core/MemRegion.cpp
clang/lib/StaticAnalyzer/Core/RegionStore.cpp
clang/lib/StaticAnalyzer/Core/SymbolManager.cpp

Removed: 




diff  --git 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h
new file mode 100644
index ..05d41bbd010c
--- /dev/null
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h
@@ -0,0 +1,32 @@
+//===- DynamicSize.h - Dynamic size related APIs *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+//  This file defines APIs that track and query dynamic size information.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICSIZE_H
+#define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICSIZE_H
+
+#include "clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState_Fwd.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h"
+
+namespace clang {
+namespace ento {
+
+/// Get the stored dynamic size for the region \p MR.
+DefinedOrUnknownSVal getDynamicSize(ProgramStateRef State, const MemRegion *MR,
+SValBuilder &SVB);
+
+} // namespace ento
+} // namespace clang
+
+#endif // LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_DYNAMICSIZE_H

diff  --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
index 71cbbe28fc25..f2ba900fd05e 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
@@ -112,7 +112,7 @@ class MemRegion : public llvm::FoldingSetNode {
 
   virtual void Profile(llvm::FoldingSetNodeID& ID) const = 0;
 
-  virtual MemRegionManager* getMemRegionManager() const = 0;
+  virtual MemRegionManager &getMemRegionManager() const = 0;
 
   const MemSpaceRegion *getMemorySpace() const;
 
@@ -198,14 +198,13 @@ class MemRegion : public llvm::FoldingSetNode {
 ///  for example, the set of global variables, the stack frame, etc.
 class MemSpaceRegion : public MemRegion {
 protected:
-  MemRegionManager *Mgr;
+  MemRegionManager &Mgr;
 
-  MemSpaceRegion(MemRegionManager *mgr, Kind k) : MemRegion(k), Mgr(mgr) {
+  MemSpaceRegion(MemRegionManager &mgr, Kind k) : MemRegion(k), Mgr(mgr) {
 assert(classof(this));
-assert(mgr);
   }
 
-  MemRegionManager* getMemRegionManager() const override { return Mgr; }
+  MemRegionManager &getMemRegionManager() const override { return Mgr; }
 
 public:
   bool isBoundable() const override { return false; }
@@ -223,7 +222,7 @@ class MemSpaceRegion : public MemRegion {
 class CodeSpaceRegion : public MemSpaceRegion {
   friend class MemRegionManager;
 
-  CodeSpaceRegion(MemRegionManager *mgr)
+  CodeSpaceRegion(MemRegionManager &mgr)
   : MemSpaceRegion(mgr,

[PATCH] D73551: [AArch64][SVE] Add remaining SVE2 intrinsics for uniform DSP operations

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

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73551



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


[PATCH] D73636: [AArch64][SVE] SVE2 intrinsics for complex integer arithmetic

2020-01-30 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added inline comments.



Comment at: llvm/include/llvm/IR/IntrinsicsAArch64.td:1116
+ LLVMMatchType<0>,
+ llvm_i32_ty],
+[IntrNoMem]>;

missing ImmArg



Comment at: llvm/include/llvm/IR/IntrinsicsAArch64.td:1124
+ LLVMMatchType<0>,
+ llvm_i32_ty],
+[IntrNoMem]>;

missing ImmArg


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73636



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


[PATCH] D69540: [analyzer] DynamicSize: Remove 'getExtent()' from regions

2020-01-30 Thread Csaba Dabis via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG601687bf731a: [analyzer] DynamicSize: Remove 
'getExtent()' from regions (authored by Charusso).

Changed prior to commit:
  https://reviews.llvm.org/D69540?vs=227013&id=241447#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69540

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
  clang/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
  clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/CastSizeChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp
  clang/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  clang/lib/StaticAnalyzer/Core/CMakeLists.txt
  clang/lib/StaticAnalyzer/Core/DynamicSize.cpp
  clang/lib/StaticAnalyzer/Core/MemRegion.cpp
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp
  clang/lib/StaticAnalyzer/Core/SymbolManager.cpp

Index: clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
+++ clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
@@ -329,7 +329,7 @@
 }
 
 QualType SymbolExtent::getType() const {
-  ASTContext &Ctx = R->getMemRegionManager()->getContext();
+  ASTContext &Ctx = R->getMemRegionManager().getContext();
   return Ctx.getSizeType();
 }
 
Index: clang/lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -23,6 +23,7 @@
 #include "clang/Basic/TargetInfo.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
@@ -876,7 +877,7 @@
 
   // Find the length (in bits) of the region being invalidated.
   uint64_t Length = UINT64_MAX;
-  SVal Extent = Top->getExtent(SVB);
+  SVal Extent = Top->getMemRegionManager().getStaticSize(Top, SVB);
   if (Optional ExtentCI =
   Extent.getAs()) {
 const llvm::APSInt &ExtentInt = ExtentCI->getValue();
@@ -1394,7 +1395,7 @@
 RegionStoreManager::getSizeInElements(ProgramStateRef state,
   const MemRegion *R,
   QualType EleTy) {
-  SVal Size = cast(R)->getExtent(svalBuilder);
+  DefinedOrUnknownSVal Size = getDynamicSize(state, R, svalBuilder);
   const llvm::APSInt *SizeInt = svalBuilder.getKnownValue(state, Size);
   if (!SizeInt)
 return UnknownVal();
Index: clang/lib/StaticAnalyzer/Core/MemRegion.cpp
===
--- clang/lib/StaticAnalyzer/Core/MemRegion.cpp
+++ clang/lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -142,7 +142,7 @@
   return false;
 }
 
-MemRegionManager* SubRegion::getMemRegionManager() const {
+MemRegionManager &SubRegion::getMemRegionManager() const {
   const SubRegion* r = this;
   do {
 const MemRegion *superRegion = r->getSuperRegion();
@@ -159,56 +159,6 @@
   return SSR ? SSR->getStackFrame() : nullptr;
 }
 
-//===--===//
-// Region extents.
-//===--===//
-
-DefinedOrUnknownSVal TypedValueRegion::getExtent(SValBuilder &svalBuilder) const {
-  ASTContext &Ctx = svalBuilder.getContext();
-  QualType T = getDesugaredValueType(Ctx);
-
-  if (isa(T))
-return nonloc::SymbolVal(svalBuilder.getSymbolManager().getExtentSymbol(this));
-  if (T->isIncompleteType())
-return UnknownVal();
-
-  CharUnits size = Ctx.getTypeSizeInChars(T);
-  QualType sizeTy = svalBuilder.getArrayIndexType();
-  return svalBuilder.makeIntVal(size.getQuantity(), sizeTy);
-}
-
-DefinedOrUnknownSVal FieldRegion::getExtent(SValBuilder &svalBuilder) const {
-  // Force callers to deal with bitfields explicitly.
-  if (getDecl()->isBitField())
-return UnknownVal();
-
-  DefinedOrUnknownSVal Extent = DeclRegion::getExtent(svalBuilder);
-
-  // A zero-length array at the end of a struct often stands for dynamically-
-  // allocated extra memory.
-  if (Extent.isZeroConstant()) {
-QualType T = getDesugaredValueType(svalBuilder.getContext());
-
-  

[PATCH] D73090: [clang-tidy] Fix PR#44528 'modernize-use-using and enums'

2020-01-30 Thread Karasev Nikita via Phabricator via cfe-commits
f00kat marked 4 inline comments as done.
f00kat added a comment.

I have changed the code to work with tagDecl. It`s work fine on simple test 
cases such as

  typedef enum { ea, eb } EnumT;

But not work with

  #include 
  typedef enum { ea, eb } EnumT;

It is not related with new tagDecl matcher. I simplify this case:

1. Create file Header.h
2. Header.h

  typedef size_t sometype;

3. main.cpp

  #include "Header.h"
  using EnumT = enum { ea, eb };

It`s happens because in class UseUsingCheck we have variable LastReplacementEnd 
and it may contains SourceLocation for another file.
First time AST matcher trigger on file Header.h and we remember SourceLocation 
for code "typedef size_t sometype". 
Then AST matcher trigger on "using EnumT = enum { ea, eb };" in main.cpp and we 
trying to use the value of LastReplacementEnd storing SourceLocation for 
Header.h.

So this 'if case' does not execute

  if (ReplaceRange.getBegin().isMacroID() ||
 ReplaceRange.getBegin() >= LastReplacementEnd) {

execute this one

  // This is additional TypedefDecl in a comma-separated typedef declaration.
  // Start replacement *after* prior replacement and separate with semicolon.
  ReplaceRange.setBegin(LastReplacementEnd);

Simple fix

  if (ReplaceRange.getBegin().isMacroID() ||
 (Result.SourceManager->getFileID(ReplaceRange.getBegin()) != 
Result.SourceManager->getFileID(LastReplacementEnd)) || \\ new check
 (ReplaceRange.getBegin() >= LastReplacementEnd)) {

But maybe I wrong. I don`t know API well enough.




Comment at: clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp:28
  this);
-  // This matcher used to find structs defined in source code within typedefs.
+  // This matcher`s used to find structs/enums defined in source code within 
typedefs.
   // They appear in the AST just *prior* to the typedefs.

aaron.ballman wrote:
> It looks like there's a backtick in the comment rather than a quotation mark, 
> that should probably be `matcher's` instead. Also, instead of `struct/enums`, 
> I think it should be `tag declarations` (unions count, for instance).
Ok



Comment at: clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp:30-31
   // They appear in the AST just *prior* to the typedefs.
-  Finder->addMatcher(cxxRecordDecl(unless(isImplicit())).bind("struct"), this);
+  Finder->addMatcher(cxxRecordDecl(unless(isImplicit())).bind("tagdecl"), 
this);
+  Finder->addMatcher(enumDecl(unless(isImplicit())).bind("tagdecl"), this);
 }

aaron.ballman wrote:
> Rather than matching on these, I think it would make more sense to add a new 
> matcher for `tagDecl()`. It can be local to the check for now, or you can add 
> it to the AST matchers header as a separate patch and then base this patch 
> off that work.
"Add new AST Matcher" - it's the Jedi level :)
Where can I find some manual that describe this? Or maybe some example(git 
commit).

"you can add it to the AST matchers header as a separate patch and then base 
this patch off that work."
So the sequencing will be:
1. I create another new patch with new AST matcher 'tagDecl'
2. Wait until you reviewed it
3. Merge to master
4. Pull latest master
4. Modify code and update this patch
?



Comment at: clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp:30-31
   // They appear in the AST just *prior* to the typedefs.
-  Finder->addMatcher(cxxRecordDecl(unless(isImplicit())).bind("struct"), this);
+  Finder->addMatcher(cxxRecordDecl(unless(isImplicit())).bind("tagdecl"), 
this);
+  Finder->addMatcher(enumDecl(unless(isImplicit())).bind("tagdecl"), this);
 }

f00kat wrote:
> aaron.ballman wrote:
> > Rather than matching on these, I think it would make more sense to add a 
> > new matcher for `tagDecl()`. It can be local to the check for now, or you 
> > can add it to the AST matchers header as a separate patch and then base 
> > this patch off that work.
> "Add new AST Matcher" - it's the Jedi level :)
> Where can I find some manual that describe this? Or maybe some example(git 
> commit).
> 
> "you can add it to the AST matchers header as a separate patch and then base 
> this patch off that work."
> So the sequencing will be:
> 1. I create another new patch with new AST matcher 'tagDecl'
> 2. Wait until you reviewed it
> 3. Merge to master
> 4. Pull latest master
> 4. Modify code and update this patch
> ?
I add new TagDecl matcher in this patch https://reviews.llvm.org/D73464. Check 
please.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/modernize-use-using.cpp:274
+// CHECK-FIXES: using EnumT = enum { ea, eb };
\ No newline at end of file


njames93 wrote:
> Can you put a new line here.
Yeah


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

https://reviews.llvm.org/D73090



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
h

[PATCH] D73090: [clang-tidy] Fix PR#44528 'modernize-use-using and enums'

2020-01-30 Thread Karasev Nikita via Phabricator via cfe-commits
f00kat updated this revision to Diff 241448.
f00kat added a comment.

1. Apply new tagDecl matcher
2. Trying to fix some bug


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73090

Files:
  clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseUsingCheck.h
  clang-tools-extra/test/clang-tidy/checkers/modernize-use-using.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/modernize-use-using.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize-use-using.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-use-using.cpp
@@ -267,3 +267,7 @@
 // CHECK-MESSAGES: :[[@LINE-2]]:30: warning: use 'using' instead of 'typedef'
 // CHECK-FIXES: using R_t = struct { int a; };
 // CHECK-FIXES-NEXT: using R_p = R_t*;
+
+typedef enum { ea, eb } EnumT;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: using EnumT = enum { ea, eb };
Index: clang-tools-extra/clang-tidy/modernize/UseUsingCheck.h
===
--- clang-tools-extra/clang-tidy/modernize/UseUsingCheck.h
+++ clang-tools-extra/clang-tidy/modernize/UseUsingCheck.h
@@ -23,7 +23,7 @@
 
   const bool IgnoreMacros;
   SourceLocation LastReplacementEnd;
-  SourceRange LastCxxDeclRange;
+  SourceRange LastTagDeclRange;
   std::string FirstTypedefType;
   std::string FirstTypedefName;
 
Index: clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
@@ -25,18 +25,17 @@
 return;
   Finder->addMatcher(typedefDecl(unless(isInstantiated())).bind("typedef"),
  this);
-  // This matcher used to find structs defined in source code within typedefs.
+  // This matcher used to find tag declarations in source code within typedefs.
   // They appear in the AST just *prior* to the typedefs.
-  Finder->addMatcher(cxxRecordDecl(unless(isImplicit())).bind("struct"), this);
+  Finder->addMatcher(tagDecl(unless(isImplicit())).bind("tagdecl"), this);
 }
 
 void UseUsingCheck::check(const MatchFinder::MatchResult &Result) {
   // Match CXXRecordDecl only to store the range of the last non-implicit full
   // declaration, to later check whether it's within the typdef itself.
-  const auto *MatchedCxxRecordDecl =
-  Result.Nodes.getNodeAs("struct");
-  if (MatchedCxxRecordDecl) {
-LastCxxDeclRange = MatchedCxxRecordDecl->getSourceRange();
+  const auto *MatchedTagDecl = Result.Nodes.getNodeAs("tagdecl");
+  if (MatchedTagDecl) {
+LastTagDeclRange = MatchedTagDecl->getSourceRange();
 return;
   }
 
@@ -72,7 +71,8 @@
   // the end of the current TypedefDecl definition.
   std::string Using = "using ";
   if (ReplaceRange.getBegin().isMacroID() ||
-  ReplaceRange.getBegin() >= LastReplacementEnd) {
+  (Result.SourceManager->getFileID(ReplaceRange.getBegin()) != 
Result.SourceManager->getFileID(LastReplacementEnd)) ||
+  (ReplaceRange.getBegin() >= LastReplacementEnd)) {
 // This is the first (and possibly the only) TypedefDecl in a typedef. Save
 // Type and Name in case we find subsequent TypedefDecl's in this typedef.
 FirstTypedefType = Type;
@@ -95,11 +95,11 @@
 
   auto Diag = diag(ReplaceRange.getBegin(), UseUsingWarning);
 
-  // If typedef contains a full struct/class declaration, extract its full 
text.
-  if (LastCxxDeclRange.isValid() && 
ReplaceRange.fullyContains(LastCxxDeclRange)) {
+  // If typedef contains a full tag declaration, extract its full text.
+  if (LastTagDeclRange.isValid() && 
ReplaceRange.fullyContains(LastTagDeclRange)) {
 bool Invalid;
 Type = std::string(
-Lexer::getSourceText(CharSourceRange::getTokenRange(LastCxxDeclRange),
+Lexer::getSourceText(CharSourceRange::getTokenRange(LastTagDeclRange),
  *Result.SourceManager, getLangOpts(), &Invalid));
 if (Invalid)
   return;


Index: clang-tools-extra/test/clang-tidy/checkers/modernize-use-using.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize-use-using.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-use-using.cpp
@@ -267,3 +267,7 @@
 // CHECK-MESSAGES: :[[@LINE-2]]:30: warning: use 'using' instead of 'typedef'
 // CHECK-FIXES: using R_t = struct { int a; };
 // CHECK-FIXES-NEXT: using R_p = R_t*;
+
+typedef enum { ea, eb } EnumT;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: using EnumT = enum { ea, eb };
Index: clang-tools-extra/clang-tidy/modernize/UseUsingCheck.h
===
--- clang-tools-extra/cla

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

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

- Aggressive dependent lookup option added


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/bugprone/ReservedIdentifierCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.h
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h
  clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
  clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.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,9 @@
 // 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: {key: readability-identifier-naming.AggressiveDependentMemberLookup, value: 1} \
 // RUN:  ]}' -- -fno-delayed-template-parsing
 
 int set_up(int);
@@ -63,32 +65,24 @@
   // CHECK-FIXES: {{^}}  int getBar2() const { return this->BarBaz; } // comment-9
 };
 
-TempTest x; //force an instantiation
-
-int blah() {
-  return x.getBar2(); // gotta have a reference to the getBar2 so that the
-  // compiler will generate the function and resolve
-  // the DependantScopeMemberExpr
-}
-
 namespace Bug41122 {
 namespace std {
 
 // for this example we aren't bothered about how std::vector is treated
 template  //NOLINT
-class vector { //NOLINT
+class vector {//NOLINT
 public:
   void push_back(bool); //NOLINT
-  void pop_back(); //NOLINT
-}; //NOLINT
-}; // namespace std
+  void pop_back();  //NOLINT
+};  //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 +128,92 @@
 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
+}
+
+te

[PATCH] D73642: [Clang][Bundler] Reduce fat object size

2020-01-30 Thread Sergey Dmitriev via Phabricator via cfe-commits
sdmitriev added a comment.

@ABataev, do you have any additional comments?


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

https://reviews.llvm.org/D73642



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


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

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

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

{icon times-circle color=red} clang-tidy: fail. clang-tidy found 0 errors and 1 
warnings 
.
 0 of them are added as review comments below (why? 
).

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

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


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


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


[clang] af3d0d1 - [analyzer] DynamicSize: Remove 'getSizeInElements()' from store

2020-01-30 Thread via cfe-commits

Author: Charusso
Date: 2020-01-30T16:51:48+01:00
New Revision: af3d0d16286aecdd19356a3505d4a87f54a2f7e9

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

LOG: [analyzer] DynamicSize: Remove 'getSizeInElements()' from store

Summary:
This patch uses the new `DynamicSize.cpp` to serve dynamic information.
Previously it was static and probably imprecise data.

Reviewed By: NoQ

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

Added: 


Modified: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
clang/lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp
clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp
clang/lib/StaticAnalyzer/Checkers/ReturnPointerRangeChecker.cpp
clang/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
clang/lib/StaticAnalyzer/Core/DynamicSize.cpp
clang/lib/StaticAnalyzer/Core/RegionStore.cpp

Removed: 




diff  --git 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h
index 05d41bbd010c..b48914c53d82 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h
@@ -26,6 +26,12 @@ namespace ento {
 DefinedOrUnknownSVal getDynamicSize(ProgramStateRef State, const MemRegion *MR,
 SValBuilder &SVB);
 
+/// Get the stored element count of the region \p MR.
+DefinedOrUnknownSVal getDynamicElementCount(ProgramStateRef State,
+const MemRegion *MR,
+SValBuilder &SVB,
+QualType ElementTy);
+
 } // namespace ento
 } // namespace clang
 

diff  --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
index cbff29953944..c3b590e4784e 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
@@ -148,14 +148,6 @@ class StoreManager {
 
   virtual SVal getLValueElement(QualType elementType, NonLoc offset, SVal 
Base);
 
-  // FIXME: This should soon be eliminated altogether; clients should deal with
-  // region extents directly.
-  virtual DefinedOrUnknownSVal getSizeInElements(ProgramStateRef state,
- const MemRegion *region,
- QualType EleTy) {
-return UnknownVal();
-  }
-
   /// ArrayToPointer - Used by ExprEngine::VistCast to handle implicit
   ///  conversions between arrays and pointers.
   virtual SVal ArrayToPointer(Loc Array, QualType ElementTy) = 0;

diff  --git a/clang/lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp
index 8d4793e0802f..716571c59277 100644
--- a/clang/lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp
@@ -16,6 +16,7 @@
 #include "clang/StaticAnalyzer/Core/Checker.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
 
 using namespace clang;
@@ -54,12 +55,11 @@ void ArrayBoundChecker::checkLocation(SVal l, bool isLoad, 
const Stmt* LoadS,
   ProgramStateRef state = C.getState();
 
   // Get the size of the array.
-  DefinedOrUnknownSVal NumElements
-= C.getStoreManager().getSizeInElements(state, ER->getSuperRegion(),
-ER->getValueType());
+  DefinedOrUnknownSVal ElementCount = getDynamicElementCount(
+  state, ER->getSuperRegion(), C.getSValBuilder(), ER->getValueType());
 
-  ProgramStateRef StInBound = state->assumeInBound(Idx, NumElements, true);
-  ProgramStateRef StOutBound = state->assumeInBound(Idx, NumElements, false);
+  ProgramStateRef StInBound = state->assumeInBound(Idx, ElementCount, true);
+  ProgramStateRef StOutBound = state->assumeInBound(Idx, ElementCount, false);
   if (StOutBound && !StInBound) {
 ExplodedNode *N = C.generateErrorNode(StOutBound);
 if (!N)

diff  --git a/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp
index 7815a6f72eb8..cde5ee3cbac3 100644
--- a/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp
@@ -16,6 +16,7 @@
 
 #include "MPIChecker.h"
 #include "clang/St

[PATCH] D73644: [Mips] Add intrinsics for 4-byte and 8-byte MSA loads/stores.

2020-01-30 Thread Mirko Brkusanin via Phabricator via cfe-commits
mbrkusanin added a comment.

We could do that for loads. For example on Mips32r5 (where we need most 
instructions) for intrinsic **ldr_d** instead of:

lwr $1, 16($5)
lwl $1, 19($5)
lwr $2, 20($5)
lwl $2, 23($5)
fill.w  $w0, $1
insert.w$w0[1], $2

We could use already available **ld.d** and then fix up **$w0[2]** and 
**$w0[3]** manually (when working with **MSA128WRegClass** / **v4i32**). 
**ld.d** has no alignment restrictions.

ld.d$w0, 16($5)
copy_s.w$1, $w0[0]
insert.w$w0[2], $1
insert.w$w0[3], $1

Optionally if we don't care what values are loaded in elements other then first 
we could just use **ld.d** and **ld.w** for **ldr_d** and **ldrq_w** 
respectively.

For stores however we cannot use **st.d** or **st.w** because we would write to 
memory we are not supposed to (we write to void* not necessarily v2i64 or 
v4i32).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73644



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


[PATCH] D73642: [Clang][Bundler] Reduce fat object size

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

LG


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

https://reviews.llvm.org/D73642



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


[PATCH] D69599: [analyzer] DynamicSize: Remove 'getSizeInElements()' from store

2020-01-30 Thread Csaba Dabis via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaf3d0d16286a: [analyzer] DynamicSize: Remove 
'getSizeInElements()' from store (authored by Charusso).

Changed prior to commit:
  https://reviews.llvm.org/D69599?vs=227546&id=241460#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69599

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
  clang/lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/ReturnPointerRangeChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
  clang/lib/StaticAnalyzer/Core/DynamicSize.cpp
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp

Index: clang/lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -623,15 +623,6 @@
   SymbolReaper& SymReaper) override;
 
   //===--===//
-  // Region "extents".
-  //===--===//
-
-  // FIXME: This method will soon be eliminated; see the note in Store.h.
-  DefinedOrUnknownSVal getSizeInElements(ProgramStateRef state,
- const MemRegion* R,
- QualType EleTy) override;
-
-  //===--===//
   // Utility methods.
   //===--===//
 
@@ -1388,37 +1379,6 @@
 }
 
 //===--===//
-// Extents for regions.
-//===--===//
-
-DefinedOrUnknownSVal
-RegionStoreManager::getSizeInElements(ProgramStateRef state,
-  const MemRegion *R,
-  QualType EleTy) {
-  DefinedOrUnknownSVal Size = getDynamicSize(state, R, svalBuilder);
-  const llvm::APSInt *SizeInt = svalBuilder.getKnownValue(state, Size);
-  if (!SizeInt)
-return UnknownVal();
-
-  CharUnits RegionSize = CharUnits::fromQuantity(SizeInt->getSExtValue());
-
-  if (Ctx.getAsVariableArrayType(EleTy)) {
-// FIXME: We need to track extra state to properly record the size
-// of VLAs.  Returning UnknownVal here, however, is a stop-gap so that
-// we don't have a divide-by-zero below.
-return UnknownVal();
-  }
-
-  CharUnits EleSize = Ctx.getTypeSizeInChars(EleTy);
-
-  // If a variable is reinterpreted as a type that doesn't fit into a larger
-  // type evenly, round it down.
-  // This is a signed value, since it's used in arithmetic with signed indices.
-  return svalBuilder.makeIntVal(RegionSize / EleSize,
-svalBuilder.getArrayIndexType());
-}
-
-//===--===//
 // Location and region casting.
 //===--===//
 
Index: clang/lib/StaticAnalyzer/Core/DynamicSize.cpp
===
--- clang/lib/StaticAnalyzer/Core/DynamicSize.cpp
+++ clang/lib/StaticAnalyzer/Core/DynamicSize.cpp
@@ -11,6 +11,7 @@
 //===--===//
 
 #include "clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h"
+#include "clang/AST/Expr.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
@@ -26,5 +27,22 @@
   return MR->getMemRegionManager().getStaticSize(MR, SVB);
 }
 
+DefinedOrUnknownSVal getDynamicElementCount(ProgramStateRef State,
+const MemRegion *MR,
+SValBuilder &SVB,
+QualType ElementTy) {
+  MemRegionManager &MemMgr = MR->getMemRegionManager();
+  ASTContext &Ctx = MemMgr.getContext();
+
+  DefinedOrUnknownSVal Size = getDynamicSize(State, MR, SVB);
+  SVal ElementSizeV = SVB.makeIntVal(
+  Ctx.getTypeSizeInChars(ElementTy).getQuantity(), SVB.getArrayIndexType());
+
+  SVal DivisionV =
+  SVB.evalBinOp(State, BO_Div, Size, ElementSizeV, SVB.getArrayIndexType());
+
+  return DivisionV.castAs();
+}
+
 } // namespace ento
 } // namespace clang
Index: clang/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
+++ clang/lib/StaticAn

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

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

- Fix clang tidy warning


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/bugprone/ReservedIdentifierCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.h
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h
  clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
  clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.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,9 @@
 // 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: {key: readability-identifier-naming.AggressiveDependentMemberLookup, value: 1} \
 // RUN:  ]}' -- -fno-delayed-template-parsing
 
 int set_up(int);
@@ -63,32 +65,23 @@
   // CHECK-FIXES: {{^}}  int getBar2() const { return this->BarBaz; } // comment-9
 };
 
-TempTest x; //force an instantiation
-
-int blah() {
-  return x.getBar2(); // gotta have a reference to the getBar2 so that the
-  // compiler will generate the function and resolve
-  // the DependantScopeMemberExpr
-}
-
 namespace Bug41122 {
 namespace std {
 
 // for this example we aren't bothered about how std::vector is treated
-template  //NOLINT
-class vector { //NOLINT
-public:
-  void push_back(bool); //NOLINT
-  void pop_back(); //NOLINT
-}; //NOLINT
-}; // namespace std
+template// NOLINT
+struct vector { // NOLINT
+  void push_back(bool); // NOLINT
+  void pop_back();  // NOLINT
+};  // 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 +127,92 @@
 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

[PATCH] D69726: [analyzer] DynamicSize: Store the dynamic size

2020-01-30 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso abandoned this revision.
Charusso marked an inline comment as done.
Charusso added a comment.

Let us say, we do not need this patch. In case we would need it, I will reopen.


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

https://reviews.llvm.org/D69726



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


[clang] 38ab3b8 - [analyzer] CheckerContext: Make the Preprocessor available

2020-01-30 Thread via cfe-commits

Author: Charusso
Date: 2020-01-30T17:05:52+01:00
New Revision: 38ab3b876baaa899b92dda9113a4d1d4b56c2e79

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

LOG: [analyzer] CheckerContext: Make the Preprocessor available

Summary:
This patch hooks the `Preprocessor` trough `BugReporter` to the
`CheckerContext` so the checkers could look for macro definitions.

Reviewed By: NoQ

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

Added: 


Modified: 
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp
clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
clang/unittests/StaticAnalyzer/Reusables.h

Removed: 




diff  --git a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h 
b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
index 69593e2b6c93..1b39cdf12c80 100644
--- a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
+++ b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
@@ -17,12 +17,13 @@
 #include "clang/Analysis/PathDiagnostic.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/SourceLocation.h"
+#include "clang/Lex/Preprocessor.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h"
-#include "clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/FoldingSet.h"
@@ -566,6 +567,7 @@ class BugReporterData {
   virtual ASTContext &getASTContext() = 0;
   virtual SourceManager &getSourceManager() = 0;
   virtual AnalyzerOptions &getAnalyzerOptions() = 0;
+  virtual Preprocessor &getPreprocessor() = 0;
 };
 
 /// BugReporter is a utility class for generating PathDiagnostics for analysis.
@@ -608,6 +610,8 @@ class BugReporter {
 
   const AnalyzerOptions &getAnalyzerOptions() { return D.getAnalyzerOptions(); 
}
 
+  Preprocessor &getPreprocessor() { return D.getPreprocessor(); }
+
   /// Add the given report to the set of reports tracked by BugReporter.
   ///
   /// The reports are usually generated by the checkers. Further, they are

diff  --git 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
index d605a6a667f6..c76e9c0326af 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
@@ -16,6 +16,7 @@
 
 #include "clang/Analysis/AnalysisDeclContext.h"
 #include "clang/Analysis/PathDiagnostic.h"
+#include "clang/Lex/Preprocessor.h"
 #include "clang/StaticAnalyzer/Core/AnalyzerOptions.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
 #include "clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h"
@@ -32,6 +33,7 @@ class AnalysisManager : public BugReporterData {
   AnalysisDeclContextManager AnaCtxMgr;
 
   ASTContext &Ctx;
+  Preprocessor &PP;
   const LangOptions &LangOpts;
   PathDiagnosticConsumers PathConsumers;
 
@@ -44,7 +46,7 @@ class AnalysisManager : public BugReporterData {
 public:
   AnalyzerOptions &options;
 
-  AnalysisManager(ASTContext &ctx,
+  AnalysisManager(ASTContext &ctx, Preprocessor &PP,
   const PathDiagnosticConsumers &Consumers,
   StoreManagerCreator storemgr,
   ConstraintManagerCreator constraintmgr,
@@ -61,6 +63,8 @@ class AnalysisManager : public BugReporterData {
 return AnaCtxMgr;
   }
 
+  Preprocessor &getPreprocessor() override { return PP; }
+
   StoreManagerCreator getStoreManagerCreator() {
 return CreateStoreMgr;
   }

diff  --git 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
index 286b5b2b2b07..aee26db95fd1 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
@@ -107,6 +107,8 @@ class CheckerContext {
 return getBugReporter().getSourceManager();
   }
 
+  Preprocessor &getPreprocessor() { return getBugReporter().getPreprocessor(); 
}
+
   SValBuilder &getSValBuilder() {
 return Eng.getSValBuilder();
   }

diff  --git a/clang/lib/StaticAnalyzer/Cor

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

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

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

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

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

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


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


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] D73715: - Update .clang-tidy to ignore parameters of main like functions for naming violations in clang and llvm directory

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



Comment at: clang/.clang-tidy:23
+  - key: readability-identifier-naming.IgnoreMainLikeFunctions
+value:   1
 

Although identifier-naming is disabled, its still a good idea to include this 
just in case people run clang tidy manually


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73715



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


[PATCH] D73715: - Update .clang-tidy to ignore parameters of main like functions for naming violations in clang and llvm directory

2020-01-30 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: alexfh, hokein.
Herald added subscribers: llvm-commits, cfe-commits, aheejin.
Herald added projects: clang, LLVM.
njames93 marked an inline comment as done.
njames93 added inline comments.



Comment at: clang/.clang-tidy:23
+  - key: readability-identifier-naming.IgnoreMainLikeFunctions
+value:   1
 

Although identifier-naming is disabled, its still a good idea to include this 
just in case people run clang tidy manually


Every call to a main like function in llvm and clang lib violates the naming 
convention for parameters. This prevents clang-tidy warning on such breaches.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73715

Files:
  .clang-tidy
  clang/.clang-tidy
  llvm/.clang-tidy


Index: llvm/.clang-tidy
===
--- llvm/.clang-tidy
+++ llvm/.clang-tidy
@@ -14,4 +14,6 @@
 value:   CamelCase
   - key: readability-identifier-naming.VariableCase
 value:   CamelCase
+  - key: readability-identifier-naming.IgnoreMainLikeFunctions
+value:   1
 
Index: clang/.clang-tidy
===
--- clang/.clang-tidy
+++ clang/.clang-tidy
@@ -19,4 +19,6 @@
 value:   CamelCase
   - key: readability-identifier-naming.VariableCase
 value:   CamelCase
+  - key: readability-identifier-naming.IgnoreMainLikeFunctions
+value:   1
 
Index: .clang-tidy
===
--- .clang-tidy
+++ .clang-tidy
@@ -14,4 +14,6 @@
 value:   CamelCase
   - key: readability-identifier-naming.VariableCase
 value:   CamelCase
+  - key: readability-identifier-naming.IgnoreMainLikeFunctions
+value:   1
 


Index: llvm/.clang-tidy
===
--- llvm/.clang-tidy
+++ llvm/.clang-tidy
@@ -14,4 +14,6 @@
 value:   CamelCase
   - key: readability-identifier-naming.VariableCase
 value:   CamelCase
+  - key: readability-identifier-naming.IgnoreMainLikeFunctions
+value:   1
 
Index: clang/.clang-tidy
===
--- clang/.clang-tidy
+++ clang/.clang-tidy
@@ -19,4 +19,6 @@
 value:   CamelCase
   - key: readability-identifier-naming.VariableCase
 value:   CamelCase
+  - key: readability-identifier-naming.IgnoreMainLikeFunctions
+value:   1
 
Index: .clang-tidy
===
--- .clang-tidy
+++ .clang-tidy
@@ -14,4 +14,6 @@
 value:   CamelCase
   - key: readability-identifier-naming.VariableCase
 value:   CamelCase
+  - key: readability-identifier-naming.IgnoreMainLikeFunctions
+value:   1
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69731: [analyzer] CheckerContext: Make the Preprocessor available

2020-01-30 Thread Csaba Dabis via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG38ab3b876baa: [analyzer] CheckerContext: Make the 
Preprocessor available (authored by Charusso).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69731

Files:
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
  clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp
  clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  clang/unittests/StaticAnalyzer/Reusables.h

Index: clang/unittests/StaticAnalyzer/Reusables.h
===
--- clang/unittests/StaticAnalyzer/Reusables.h
+++ clang/unittests/StaticAnalyzer/Reusables.h
@@ -58,7 +58,7 @@
   ExprEngineConsumer(CompilerInstance &C)
   : C(C), ChkMgr(C.getASTContext(), *C.getAnalyzerOpts()), CTU(C),
 Consumers(),
-AMgr(C.getASTContext(), Consumers,
+AMgr(C.getASTContext(), C.getPreprocessor(), Consumers,
  CreateRegionStoreManager, CreateRangeConstraintManager, &ChkMgr,
  *C.getAnalyzerOpts()),
 VisitedCallees(), FS(),
Index: clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===
--- clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -193,7 +193,7 @@
 
 public:
   ASTContext *Ctx;
-  const Preprocessor &PP;
+  Preprocessor &PP;
   const std::string OutDir;
   AnalyzerOptionsRef Opts;
   ArrayRef Plugins;
@@ -336,8 +336,8 @@
 checkerMgr = createCheckerManager(
 *Ctx, *Opts, Plugins, CheckerRegistrationFns, PP.getDiagnostics());
 
-Mgr = std::make_unique(*Ctx, PathConsumers, CreateStoreMgr,
-CreateConstraintMgr,
+Mgr = std::make_unique(*Ctx, PP, PathConsumers,
+CreateStoreMgr, CreateConstraintMgr,
 checkerMgr.get(), *Opts, Injector);
   }
 
Index: clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp
+++ clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp
@@ -13,7 +13,7 @@
 
 void AnalysisManager::anchor() { }
 
-AnalysisManager::AnalysisManager(ASTContext &ASTCtx,
+AnalysisManager::AnalysisManager(ASTContext &ASTCtx, Preprocessor &PP,
  const PathDiagnosticConsumers &PDC,
  StoreManagerCreator storemgr,
  ConstraintManagerCreator constraintmgr,
@@ -38,7 +38,7 @@
   Options.ShouldElideConstructors,
   /*addVirtualBaseBranches=*/true,
   injector),
-  Ctx(ASTCtx), LangOpts(ASTCtx.getLangOpts()),
+  Ctx(ASTCtx), PP(PP), LangOpts(ASTCtx.getLangOpts()),
   PathConsumers(PDC), CreateStoreMgr(storemgr),
   CreateConstraintMgr(constraintmgr), CheckerMgr(checkerMgr),
   options(Options) {
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
@@ -107,6 +107,8 @@
 return getBugReporter().getSourceManager();
   }
 
+  Preprocessor &getPreprocessor() { return getBugReporter().getPreprocessor(); }
+
   SValBuilder &getSValBuilder() {
 return Eng.getSValBuilder();
   }
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
@@ -16,6 +16,7 @@
 
 #include "clang/Analysis/AnalysisDeclContext.h"
 #include "clang/Analysis/PathDiagnostic.h"
+#include "clang/Lex/Preprocessor.h"
 #include "clang/StaticAnalyzer/Core/AnalyzerOptions.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
 #include "clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h"
@@ -32,6 +33,7 @@
   AnalysisDeclContextManager AnaCtxMgr;
 
   ASTContext &Ctx;
+  Preprocessor &PP;
   const LangOptions &LangOpts;
   PathDiagnosticConsumers PathConsumers;
 
@@ -44,7 +46,7 @@
 public:
   AnalyzerOptions &options;
 
-  AnalysisManager(ASTContext &ctx,
+  AnalysisManager(ASTContext &ctx, Preprocessor &PP,
   const PathDiagnosticConsumers &Consumers,
   StoreManagerCreator storemgr,
   ConstraintManagerCreator constraintmgr,
@@ -61,6 +63,8 @@
 return AnaCtxMgr;
   }
 
+  Preprocessor &getPreprocessor

[clang] c53cb2b - [Clang][Bundler] Reduce fat object size

2020-01-30 Thread Sergey Dmitriev via cfe-commits

Author: Sergey Dmitriev
Date: 2020-01-30T08:21:39-08:00
New Revision: c53cb2bdc78ee3d3eec8c30821480b390b0eb145

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

LOG: [Clang][Bundler] Reduce fat object size

Summary:
Fat object size has significantly increased after D65819 which changed bundler 
tool to add host object as a normal bundle to the fat output which almost 
doubled its size. That patch was fixing the following issues

1. Problems associated with the partial linking - global constructors were not 
called for partially linking objects which clearly resulted in incorrect 
behavior.
2. Eliminating "junk" target object sections from the linked binary on the host 
side.

The first problem is no longer relevant because we do not use partial linking 
for creating fat objects anymore. Target objects sections are now inserted into 
the resulting fat object with a help of llvm-objcopy tool.

The second issue, "junk" sections in the linked host binary, has been fixed in 
D73408 by adding "exclude" flag to the fat object's sections which contain 
target objects. This flag tells linker to drop section from the inputs when 
linking executable or shared library, therefore these sections will not be 
propagated in the linked binary.

Since both problems have been solved, we can revert D65819 changes to reduce 
fat object size and this patch essentially is doing that.

Reviewers: ABataev, alexshap, jdoerfert

Reviewed By: ABataev

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/test/Driver/clang-offload-bundler.c
clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Removed: 




diff  --git a/clang/test/Driver/clang-offload-bundler.c 
b/clang/test/Driver/clang-offload-bundler.c
index 99d638cb889b..a0724b3c60e8 100644
--- a/clang/test/Driver/clang-offload-bundler.c
+++ b/clang/test/Driver/clang-offload-bundler.c
@@ -253,16 +253,16 @@
 
 // RUN: clang-offload-bundler -type=o 
-targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu
 -inputs=%t.o,%t.tgt1,%t.tgt2 -outputs=%t.bundle3.o -### 2>&1 \
 // RUN: | FileCheck %s -DHOST=%itanium_abi_triple -DINOBJ1=%t.o 
-DINOBJ2=%t.tgt1 -DINOBJ3=%t.tgt2 -DOUTOBJ=%t.bundle3.o --check-prefix 
CK-OBJ-CMD
-// CK-OBJ-CMD: llvm-objcopy{{(.exe)?}}" 
"--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]=[[INOBJ1]]" 
"--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=[[INOBJ2]]"
 "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=[[INOBJ3]]" 
"[[INOBJ1]]" "[[TEMPOBJ:.*]]"
+// CK-OBJ-CMD: llvm-objcopy{{(.exe)?}}" 
"--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]={{.*}}" 
"--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=[[INOBJ2]]"
 "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=[[INOBJ3]]" 
"[[INOBJ1]]" "[[TEMPOBJ:.*]]"
 // CK-OBJ-CMD: llvm-objcopy{{(.exe)?}}" 
"--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]=readonly,exclude" 
"--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=readonly,exclude"
 
"--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=readonly,exclude"
 "[[TEMPOBJ]]" "[[OUTOBJ]]"
 
 // RUN: clang-offload-bundler -type=o 
-targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu
 -inputs=%t.o,%t.tgt1,%t.tgt2 -outputs=%t.bundle3.o
 // RUN: clang-offload-bundler -type=o 
-targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu
 -outputs=%t.res.o,%t.res.tgt1,%t.res.tgt2 -inputs=%t.bundle3.o -unbundle
-// RUN: 
diff  %t.o %t.res.o
+// RUN: 
diff  %t.bundle3.o %t.res.o
 // RUN: 
diff  %t.tgt1 %t.res.tgt1
 // RUN: 
diff  %t.tgt2 %t.res.tgt2
 // RUN: clang-offload-bundler -type=o 
-targets=openmp-powerpc64le-ibm-linux-gnu,host-%itanium_abi_triple,openmp-x86_64-pc-linux-gnu
 -outputs=%t.res.tgt1,%t.res.o,%t.res.tgt2 -inputs=%t.bundle3.o -unbundle
-// RUN: 
diff  %t.o %t.res.o
+// RUN: 
diff  %t.bundle3.o %t.res.o
 // RUN: 
diff  %t.tgt1 %t.res.tgt1
 // RUN: 
diff  %t.tgt2 %t.res.tgt2
 // RUN: clang-offload-bundler -type=o 
-targets=openmp-powerpc64le-ibm-linux-gnu -outputs=%t.res.tgt1 
-inputs=%t.bundle3.o -unbundle

diff  --git a/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp 
b/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
index c215cff303e7..2a99a71501ab 100644
--- a/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ b/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -30,7 +30,6 @@
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ErrorOr.h"
 #include "llvm/Support/FileSystem.h"
-#include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "l

[PATCH] D73715: - Update .clang-tidy to ignore parameters of main like functions for naming violations in clang and llvm directory

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

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

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

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

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


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73715



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


[PATCH] D73642: [Clang][Bundler] Reduce fat object size

2020-01-30 Thread Sergey Dmitriev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc53cb2bdc78e: [Clang][Bundler] Reduce fat object size 
(authored by sdmitriev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73642

Files:
  clang/test/Driver/clang-offload-bundler.c
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -30,7 +30,6 @@
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ErrorOr.h"
 #include "llvm/Support/FileSystem.h"
-#include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Program.h"
@@ -365,6 +364,41 @@
   }
 };
 
+namespace {
+
+// This class implements a list of temporary files that are removed upon
+// object destruction.
+class TempFileHandlerRAII {
+public:
+  ~TempFileHandlerRAII() {
+for (const auto &File : Files)
+  sys::fs::remove(File);
+  }
+
+  // Creates temporary file with given contents.
+  Expected Create(Optional> Contents) {
+SmallString<128u> File;
+if (std::error_code EC =
+sys::fs::createTemporaryFile("clang-offload-bundler", "tmp", File))
+  return createFileError(File, EC);
+Files.push_back(File);
+
+if (Contents) {
+  std::error_code EC;
+  raw_fd_ostream OS(File, EC);
+  if (EC)
+return createFileError(File, EC);
+  OS.write(Contents->data(), Contents->size());
+}
+return Files.back();
+  }
+
+private:
+  SmallVector, 4u> Files;
+};
+
+} // end anonymous namespace
+
 /// Handler for object files. The bundles are organized by sections with a
 /// designated name.
 ///
@@ -433,11 +467,16 @@
   Error ReadBundleEnd(MemoryBuffer &Input) final { return Error::success(); }
 
   Error ReadBundle(raw_fd_ostream &OS, MemoryBuffer &Input) final {
-Expected Content = CurrentSection->getContents();
-if (!Content)
-  return Content.takeError();
+Expected ContentOrErr = CurrentSection->getContents();
+if (!ContentOrErr)
+  return ContentOrErr.takeError();
+StringRef Content = *ContentOrErr;
+
+// Copy fat object contents to the output when extracting host bundle.
+if (Content.size() == 1u && Content.front() == 0)
+  Content = StringRef(Input.getBufferStart(), Input.getBufferSize());
 
-OS.write(Content->data(), Content->size());
+OS.write(Content.data(), Content.size());
 return Error::success();
   }
 
@@ -486,22 +525,37 @@
 // to pass down to llvm-objcopy.
 OS.close();
 
+// Temporary files that need to be removed.
+TempFileHandlerRAII TempFiles;
+
 // Create an intermediate temporary file to save object after the first
 // llvm-objcopy run.
-SmallString<128u> IntermediateObj;
-if (std::error_code EC = sys::fs::createTemporaryFile(
-"clang-offload-bundler", "tmp", IntermediateObj))
-  return createFileError(IntermediateObj, EC);
-FileRemover IntermediateObjRemover(IntermediateObj);
+Expected> IntermediateObjOrErr = TempFiles.Create(None);
+if (!IntermediateObjOrErr)
+  return IntermediateObjOrErr.takeError();
+const SmallString<128u> &IntermediateObj = *IntermediateObjOrErr;
 
 // Compose llvm-objcopy command line for add target objects' sections.
 BumpPtrAllocator Alloc;
 StringSaver SS{Alloc};
 SmallVector ObjcopyArgs{"llvm-objcopy"};
-for (unsigned I = 0; I < NumberOfInputs; ++I)
+for (unsigned I = 0; I < NumberOfInputs; ++I) {
+  StringRef InputFile = InputFileNames[I];
+  if (I == HostInputIndex) {
+// Special handling for the host bundle. We do not need to add a
+// standard bundle for the host object since we are going to use fat
+// object as a host object. Therefore use dummy contents (one zero byte)
+// when creating section for the host bundle.
+Expected TempFileOrErr = TempFiles.Create(ArrayRef(0));
+if (!TempFileOrErr)
+  return TempFileOrErr.takeError();
+InputFile = *TempFileOrErr;
+  }
+
   ObjcopyArgs.push_back(SS.save(Twine("--add-section=") +
 OFFLOAD_BUNDLER_MAGIC_STR + TargetNames[I] +
-"=" + InputFileNames[I]));
+"=" + InputFile));
+}
 ObjcopyArgs.push_back(InputFileNames[HostInputIndex]);
 ObjcopyArgs.push_back(IntermediateObj);
 
Index: clang/test/Driver/clang-offload-bundler.c
===
--- clang/test/Driver/clang-offload-bundler.c
+++ clang/test/Driver/clang-offload-bundler.c
@@ -253,16 +253,16 @@
 
 // RUN: clang-offload-bundler -type=o -targets=h

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

2020-01-30 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 241478.
balazske added a comment.

Adding a new implementation.
Now the conditions itself are checked, not the constraints.
The appearance of the value to check is detected and tested if 
it is inside an error check-looking construct.
The location of the error check is available and use before check is
detected too.
More tricky cases of error check code are not found but
these should be rare or "questionable" cases.

Probably some possibilities are missed from this code.
There is still some debug code left.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72705

Files:
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  clang/lib/StaticAnalyzer/Checkers/ErrorReturnChecker.cpp
  clang/test/Analysis/Inputs/system-header-simulator.h
  clang/test/Analysis/error-return.c

Index: clang/test/Analysis/error-return.c
===
--- /dev/null
+++ clang/test/Analysis/error-return.c
@@ -0,0 +1,437 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.unix.ErrorReturn -verify %s
+
+#include "Inputs/system-header-simulator.h"
+
+/*
+Functions from CERT ERR33-C that should be checked for error:
+https://wiki.sei.cmu.edu/confluence/display/c/ERR33-C.+Detect+and+handle+standard+library+errors
+
+void *aligned_alloc( size_t alignment, size_t size );
+errno_t asctime_s(char *buf, rsize_t bufsz, const struct tm *time_ptr);
+int at_quick_exit( void (*func)(void) );
+int atexit( void (*func)(void) );
+void* bsearch( const void *key, const void *ptr, size_t count, size_t size,
+   int (*comp)(const void*, const void*) );
+void* bsearch_s( const void *key, const void *ptr, rsize_t count, rsize_t size,
+ int (*comp)(const void *, const void *, void *),
+ void *context );
+wint_t btowc( int c );
+size_t c16rtomb( char * restrict s, char16_t c16, mbstate_t * restrict ps );
+size_t c32rtomb( char * restrict s, char32_t c32, mbstate_t * restrict ps );
+void* calloc( size_t num, size_t size );
+clock_t clock(void);
+int cnd_broadcast( cnd_t *cond );
+int cnd_init( cnd_t* cond );
+int cnd_signal( cnd_t *cond );
+int cnd_timedwait( cnd_t* restrict cond, mtx_t* restrict mutex,
+   const struct timespec* restrict time_point );
+int cnd_wait( cnd_t* cond, mtx_t* mutex );
+errno_t ctime_s(char *buffer, rsize_t bufsz, const time_t *time);
+int fclose( FILE *stream );
+int fflush( FILE *stream );
+int fgetc( FILE *stream );
+int fgetpos( FILE *restrict stream, fpos_t *restrict pos );
+char *fgets( char *restrict str, int count, FILE *restrict stream );
+wint_t fgetwc( FILE *stream );
+FILE *fopen( const char *restrict filename, const char *restrict mode );
+errno_t fopen_s(FILE *restrict *restrict streamptr,
+const char *restrict filename,
+const char *restrict mode);
+int fprintf( FILE *restrict stream, const char *restrict format, ... );
+int fprintf_s(FILE *restrict stream, const char *restrict format, ...);
+int fputc( int ch, FILE *stream );
+int fputs( const char *restrict str, FILE *restrict stream );
+wint_t fputwc( wchar_t ch, FILE *stream );
+int fputws( const wchar_t * restrict str, FILE * restrict stream );
+size_t fread( void *restrict buffer, size_t size, size_t count,
+  FILE *restrict stream );
+FILE *freopen( const char *restrict filename, const char *restrict mode,
+   FILE *restrict stream );
+errno_t freopen_s(FILE *restrict *restrict newstreamptr,
+  const char *restrict filename, const char *restrict mode,
+  FILE *restrict stream);
+int fscanf( FILE *restrict stream, const char *restrict format, ... );
+int fscanf_s(FILE *restrict stream, const char *restrict format, ...);
+int fseek( FILE *stream, long offset, int origin );
+int fsetpos( FILE *stream, const fpos_t *pos );
+long ftell( FILE *stream );
+int fwprintf( FILE *restrict stream,
+  const wchar_t *restrict format, ... );
+int fwprintf_s( FILE *restrict stream,
+const wchar_t *restrict format, ...);
+size_t fwrite( const void *restrict buffer, size_t size, size_t count,
+   FILE *restrict stream ); // more exact error return: < count
+int fwscanf( FILE *restrict stream,
+ const wchar_t *restrict format, ... );
+int fwscanf_s( FILE *restrict stream,
+   const wchar_t *restrict format, ...);
+int getc( FILE *stream );
+int getchar(void);
+char *getenv( const char *name );
+errno_t getenv_s( size_t *restrict len, char *restrict value,
+  rsize_t valuesz, const char *restrict name );
+char *gets_s( char *str, rsize_t n );
+wint_t getwc( FILE *stream );
+wint_t getwchar(void);
+struct tm *gmtime( const time_t *time );
+struct tm *gmtime_s(const time_t *restrict time, struct tm *restrict result);
+struct tm *

[PATCH] D70172: [CUDA][HIP][OpenMP] Emit deferred diagnostics by a post-parsing AST travese

2020-01-30 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D70172#1812749 , @rjmccall wrote:

> In D70172#1812664 , @yaxunl wrote:
>
> > In D70172#1812631 , @rjmccall 
> > wrote:
> >
> > > Most uses of the destructor do not use the delete operator, though, and 
> > > therefore should not trigger the diagnostics in `f` to be emitted.  And 
> > > this really doesn't require a fully-realized use graph; you could very 
> > > easily track the current use stack when making a later pass over the 
> > > entities used.
> >
> >
> > The call graph is not for this specific situation. A call graph is needed 
> > because of the transitive nature of the deferred diagnostic message. That 
> > is, if any direct or indirect caller is emitted, the diagnostic msg needs 
> > to be emitted.
>
>
> One of the points that Richard and I have been trying to make is that this 
> really isn't specifically about *calls*, it's about *uses*.  You only want to 
> emit diagnostics associated with an entity if you actually have to emit that 
> entity, and whether you emit an entity has nothing to do with what places 
> might *call* it, but rather what places *use* it and therefore force it to be 
> emitted.  This is fortunate because call graphs are inherently imperfect 
> because of indirect calls, but use graphs are totally reliable.  It's also 
> fortunate because it means you can piggy-back on all of the existing logic 
> that Sema has for tracking ODR uses.
>
> Richard and I are also pointing out that Sema has to treat the v-table as its 
> own separate thing when tracking ODR uses, and so you need to as well.  You 
> want to emit diagnostics associated with a virtual function if you're 
> emitting code that either (1) directly uses the function (e.g. by calling 
> `x->A::foo()`) or (2) directly uses a v-table containing the function.  You 
> can't rely on Sema's normal ODR-use tracking for *either* of these, because 
> Sema might have observed a use in code that you don't actually have to emit, 
> e.g. host code if you're compiling for the device.  That is, a v-table is 
> only a "root" for virtual functions if you actually have to emit that 
> v-table, and you can't know that without tracking v-tables in your use graph.
>
> > The deferred diagnostic msg is recorded when parsing a function body. At 
> > that time we do not know which function will directly or indirectly call 
> > it. How do we keep a use stack?
>
> The "use stack" idea would apply if you switched from eagerly creating the 
> entire use graph to instead just making a late pass that walked function 
> bodies.  If you walk function bodies depth-first, starting from a true root 
> and gathering all the ODR-used entities to be  recursively walked, then you 
> can maintain a stack of what entities you're currently walking, and that 
> stack is a use-path that explains why you need to emit the current function.
>
> It should be straightforward to build a function that walks over the entities 
> used by a function body and calls a callback by just extracting it out of the 
> code in `MarkDeclarationsUsedInExpr`.


I updated the patch to remove the explicit call graph and use an AST traverse 
instead. Since this patch is big, is it OK to leave the tracking of vtable to 
some future patch? This patch is sufficient to fix the assertion seen on 
Windows. Thanks.


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

https://reviews.llvm.org/D70172



___
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-30 Thread Diogo N. Sampaio via Phabricator via cfe-commits
dnsampaio updated this revision to Diff 241477.
dnsampaio added a comment.

- Do not generate special volatile access if the record alignment is smaller 
than the bit-field declared type


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/CGRecordLayout.h
  clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
  clang/test/CodeGen/aapcs-bitfield.c
  clang/test/CodeGen/bitfield-2.c

Index: clang/test/CodeGen/bitfield-2.c
===
--- clang/test/CodeGen/bitfield-2.c
+++ clang/test/CodeGen/bitfield-2.c
@@ -1,3 +1,4 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
 // RUN: %clang_cc1 -emit-llvm -triple x86_64 -O3 -o %t.opt.ll %s \
 // RUN:   -fdump-record-layouts > %t.dump.txt
 // RUN: FileCheck -check-prefix=CHECK-RECORD < %t.dump.txt %s
@@ -14,7 +15,7 @@
 // CHECK-RECORD:   LLVMType:%struct.s0 = type { [3 x i8] }
 // CHECK-RECORD:   IsZeroInitializable:1
 // CHECK-RECORD:   BitFields:[
-// CHECK-RECORD: 
+// CHECK-RECORD: 
-// CHECK-RECORD: 
+// CHECK-RECORD: 
+// CHECK-RECORD: 
-// CHECK-RECORD: 
+// CHECK-RECORD: 
 
 struct __attribute__((packed)) s9 {
Index: clang/test/CodeGen/aapcs-bitfield.c
===
--- clang/test/CodeGen/aapcs-bitfield.c
+++ clang/test/CodeGen/aapcs-bitfield.c
@@ -144,26 +144,26 @@
 void st2_check_store(struct st2 *m) {
   m->c = 1;
 }
-
+// Volatile access is allowed to use 16 bits
 struct st3 {
   volatile short c : 7;
 };
 
 // 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,26 +172,26 @@
 
 // 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) {
   m->c = 1;
 }
-
+// Volatile access to st4.c should use a char ld/st
 struct st4 {
   int b : 9;
   volatile char c : 5;
@@ -199,24 +199,22 @@
 
 // LE-LABEL: @st4_check_load(
 // LE-NEXT:  entry:
-// LE-NEXT:[[TMP0:%.*]] = getelementptr [[STRUCT_ST4:%.*

[PATCH] D73719: [AArch64][SVE] Add SVE2 intrinsics for widening DSP operations

2020-01-30 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin created this revision.
kmclaughlin added reviewers: sdesmalen, dancgr, efriedma, cameron.mcinally.
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.[s|u]abalb
- @llvm.aarch64.sve.[s|u]abalt
- @llvm.aarch64.sve.[s|u]addlb
- @llvm.aarch64.sve.[s|u]addlt
- @llvm.aarch64.sve.[s|u]sublb
- @llvm.aarch64.sve.[s|u]sublt
- @llvm.aarch64.sve.[s|u]abdlb
- @llvm.aarch64.sve.[s|u]abdlt
- @llvm.aarch64.sve.sqdmullb
- @llvm.aarch64.sve.sqdmullt
- @llvm.aarch64.sve.[s|u]mullb
- @llvm.aarch64.sve.[s|u]mullt


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73719

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve2-intrinsics-widening-dsp.ll

Index: llvm/test/CodeGen/AArch64/sve2-intrinsics-widening-dsp.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve2-intrinsics-widening-dsp.ll
@@ -0,0 +1,783 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve2 < %s | FileCheck %s
+
+;
+; SABALB
+;
+
+define  @sabalb_b( %a,  %b,  %c) {
+; CHECK-LABEL: sabalb_b:
+; CHECK: sabalb z0.h, z1.b, z2.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sabalb.nxv8i16( %a,
+   %b,
+   %c)
+  ret  %out
+}
+
+define  @sabalb_h( %a,  %b,  %c) {
+; CHECK-LABEL: sabalb_h:
+; CHECK: sabalb z0.s, z1.h, z2.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sabalb.nxv4i32( %a,
+   %b,
+   %c)
+  ret  %out
+}
+
+define  @sabalb_s( %a,  %b,  %c) {
+; CHECK-LABEL: sabalb_s:
+; CHECK: sabalb z0.d, z1.s, z2.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sabalb.nxv2i64( %a,
+   %b,
+   %c)
+  ret  %out
+}
+
+;
+; SABALT
+;
+
+define  @sabalt_b( %a,  %b,  %c) {
+; CHECK-LABEL: sabalt_b:
+; CHECK: sabalt z0.h, z1.b, z2.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sabalt.nxv8i16( %a,
+   %b,
+   %c)
+  ret  %out
+}
+
+define  @sabalt_h( %a,  %b,  %c) {
+; CHECK-LABEL: sabalt_h:
+; CHECK: sabalt z0.s, z1.h, z2.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sabalt.nxv4i32( %a,
+   %b,
+   %c)
+  ret  %out
+}
+
+define  @sabalt_s( %a,  %b,  %c) {
+; CHECK-LABEL: sabalt_s:
+; CHECK: sabalt z0.d, z1.s, z2.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sabalt.nxv2i64( %a,
+   %b,
+   %c)
+  ret  %out
+}
+
+;
+; SABDLB
+;
+
+define  @sabdlb_b( %a,  %b) {
+; CHECK-LABEL: sabdlb_b:
+; CHECK: sabdlb z0.h, z0.b, z1.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sabdlb.nxv8i16( %a,
+   %b)
+  ret  %out
+}
+
+define  @sabdlb_h( %a,  %b) {
+; CHECK-LABEL: sabdlb_h:
+; CHECK: sabdlb z0.s, z0.h, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sabdlb.nxv4i32( %a,
+   %b)
+  ret  %out
+}
+
+define  @sabdlb_s( %a,  %b) {
+; CHECK-LABEL: sabdlb_s:
+; CHECK: sabdlb z0.d, z0.s, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sabdlb.nxv2i64( %a,
+   %b)
+  ret  %out
+}
+
+;
+; SABDLT
+;
+
+define  @sabdlt_b( %a,  %b) {
+; CHECK-LABEL: sabdlt_b:
+; CHECK: sabdlt z0.h, z0.b, z1.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sabdlt.nxv8i16( %a,
+   %b)
+  ret  %out
+}
+
+define  @sabdlt_h( %a,  %b) {
+; CHECK-LABEL: sabdlt_h:
+; CHECK: sabdlt z0.s, z0.h, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sabdlt.nxv4i32( %a,
+   %b)
+  ret  %out
+}
+
+define  @sabdlt_s( %a,  %b) {
+; CHECK-LABEL: sabdlt_s:
+; CHECK: sabdlt z0.d, z0.s, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sabdlt.nxv2i64( %a,
+   %b)
+  ret  %out
+}
+
+;
+; SADDLB
+;
+
+define  @saddlb_b( %a,  %b) {
+; CHECK-LABEL: saddlb_b:
+; CHECK: saddlb z0.h, z0.b, z1.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.saddlb.nxv8i

[PATCH] D73462: [dwarf-5] Support DebugInfo for Defaulted parameters for C++ templates

2020-01-30 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

In addition to the roundtrip test, can you please also add a .bc file test 
containing a DITemplateTypeParameter / DITemplateValueParameter produced by 
today's llvm to test the bitcode upgrade code added to MetadataLoader? You'll 
find examples if you search for .bc files in the existing tests.


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

https://reviews.llvm.org/D73462



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


[clang] 4697874 - [OPENMP50]Handle lastprivate conditionals passed as shared in inner

2020-01-30 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-01-30T11:35:23-05:00
New Revision: 4697874c28eda11ce29266f3c6188280809b6b36

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

LOG: [OPENMP50]Handle lastprivate conditionals passed as shared in inner
regions.

If the lastprivate conditional is passed as shared in inner region, we
shall check if it was ever changed and use this updated value after exit
from the inner region as an update value.

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGOpenMPRuntime.h
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/test/OpenMP/parallel_for_lastprivate_conditional.cpp
clang/test/OpenMP/sections_lastprivate_codegen.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 9150d3bd25cf..cbe1bfc01a59 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -1801,16 +1801,17 @@ void CGOpenMPRuntime::functionFinished(CodeGenFunction 
&CGF) {
 OpenMPLocThreadIDMap.erase(CGF.CurFn);
   }
   if (FunctionUDRMap.count(CGF.CurFn) > 0) {
-for(auto *D : FunctionUDRMap[CGF.CurFn])
+for(const auto *D : FunctionUDRMap[CGF.CurFn])
   UDRMap.erase(D);
 FunctionUDRMap.erase(CGF.CurFn);
   }
   auto I = FunctionUDMMap.find(CGF.CurFn);
   if (I != FunctionUDMMap.end()) {
-for(auto *D : I->second)
+for(const auto *D : I->second)
   UDMMap.erase(D);
 FunctionUDMMap.erase(I);
   }
+  LastprivateConditionalToTypes.erase(CGF.CurFn);
 }
 
 llvm::Type *CGOpenMPRuntime::getIdentTyPointerTy() {
@@ -11333,17 +11334,101 @@ bool CGOpenMPRuntime::isNontemporalDecl(const 
ValueDecl *VD) const {
   [VD](const NontemporalDeclsSet &Set) { return Set.count(VD) > 0; });
 }
 
+void CGOpenMPRuntime::LastprivateConditionalRAII::tryToDisableInnerAnalysis(
+const OMPExecutableDirective &S,
+llvm::DenseSet> &NeedToAddForLPCsAsDisabled)
+const {
+  llvm::DenseSet> NeedToCheckForLPCs;
+  // Vars in target/task regions must be excluded completely.
+  if (isOpenMPTargetExecutionDirective(S.getDirectiveKind()) ||
+  isOpenMPTaskingDirective(S.getDirectiveKind())) {
+SmallVector CaptureRegions;
+getOpenMPCaptureRegions(CaptureRegions, S.getDirectiveKind());
+const CapturedStmt *CS = S.getCapturedStmt(CaptureRegions.front());
+for (const CapturedStmt::Capture &Cap : CS->captures()) {
+  if (Cap.capturesVariable() || Cap.capturesVariableByCopy())
+NeedToCheckForLPCs.insert(Cap.getCapturedVar());
+}
+  }
+  // Exclude vars in private clauses.
+  for (const auto *C : S.getClausesOfKind()) {
+for (const Expr *Ref : C->varlists()) {
+  if (!Ref->getType()->isScalarType())
+continue;
+  const auto *DRE = dyn_cast(Ref->IgnoreParenImpCasts());
+  if (!DRE)
+continue;
+  NeedToCheckForLPCs.insert(DRE->getDecl());
+}
+  }
+  for (const auto *C : S.getClausesOfKind()) {
+for (const Expr *Ref : C->varlists()) {
+  if (!Ref->getType()->isScalarType())
+continue;
+  const auto *DRE = dyn_cast(Ref->IgnoreParenImpCasts());
+  if (!DRE)
+continue;
+  NeedToCheckForLPCs.insert(DRE->getDecl());
+}
+  }
+  for (const auto *C : S.getClausesOfKind()) {
+for (const Expr *Ref : C->varlists()) {
+  if (!Ref->getType()->isScalarType())
+continue;
+  const auto *DRE = dyn_cast(Ref->IgnoreParenImpCasts());
+  if (!DRE)
+continue;
+  NeedToCheckForLPCs.insert(DRE->getDecl());
+}
+  }
+  for (const auto *C : S.getClausesOfKind()) {
+for (const Expr *Ref : C->varlists()) {
+  if (!Ref->getType()->isScalarType())
+continue;
+  const auto *DRE = dyn_cast(Ref->IgnoreParenImpCasts());
+  if (!DRE)
+continue;
+  NeedToCheckForLPCs.insert(DRE->getDecl());
+}
+  }
+  for (const auto *C : S.getClausesOfKind()) {
+for (const Expr *Ref : C->varlists()) {
+  if (!Ref->getType()->isScalarType())
+continue;
+  const auto *DRE = dyn_cast(Ref->IgnoreParenImpCasts());
+  if (!DRE)
+continue;
+  NeedToCheckForLPCs.insert(DRE->getDecl());
+}
+  }
+  for (const Decl *VD : NeedToCheckForLPCs) {
+for (const LastprivateConditionalData &Data :
+ llvm::reverse(CGM.getOpenMPRuntime().LastprivateConditionalStack)) {
+  if (Data.DeclToUniqueName.count(VD) > 0) {
+if (!Data.Disabled)
+  NeedToAddForLPCsAsDisabled.insert(VD);
+break;
+  }
+}
+  }
+}
+
 CGOpenMPRuntime::LastprivateConditionalRAII::LastprivateConditionalRAII(
 CodeGenFunction &CGF, const OMPExecutableDirective &S, LValue IVLVal)
 : CGM(CGF.CGM),
-  NeedToPush(llvm::any_of(S.getClausesOfKind(),
-  [

[PATCH] D67399: [ARM] Follow AACPS for preserving number of loads/stores of volatile bit-fields

2020-01-30 Thread Diogo N. Sampaio via Phabricator via cfe-commits
dnsampaio updated this revision to Diff 241486.
dnsampaio added a comment.

- Added flag to allow user to opt-in


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67399

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  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
@@ -1,6 +1,8 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
 // RUN: %clang_cc1 -triple armv8-none-linux-eabi %s -emit-llvm -o - -O3 | FileCheck %s -check-prefix=LE
 // RUN: %clang_cc1 -triple armebv8-none-linux-eabi %s -emit-llvm -o - -O3 | FileCheck %s -check-prefix=BE
+// RUN: %clang_cc1 -triple armv8-none-linux-eabi %s -emit-llvm -o - -O3 -fAAPCSBitfieldLoad | FileCheck %s -check-prefixes=LE,LENUMLOADS
+// RUN: %clang_cc1 -triple armebv8-none-linux-eabi %s -emit-llvm -o - -O3 -fAAPCSBitfieldLoad | FileCheck %s -check-prefixes=BE,BENUMLOADS
 
 struct st0 {
   short c : 7;
@@ -680,12 +682,14 @@
 // LE-LABEL: @store_st11(
 // LE-NEXT:  entry:
 // LE-NEXT:[[F:%.*]] = getelementptr inbounds [[STRUCT_ST11:%.*]], %struct.st11* [[M:%.*]], i32 0, i32 1
+// LENUMLOADS-NEXT:[[BF_LOAD:%.*]] = load volatile i16, i16* [[F]], align 1
 // LE-NEXT:store volatile i16 1, i16* [[F]], align 1
 // LE-NEXT:ret void
 //
 // BE-LABEL: @store_st11(
 // BE-NEXT:  entry:
 // BE-NEXT:[[F:%.*]] = getelementptr inbounds [[STRUCT_ST11:%.*]], %struct.st11* [[M:%.*]], i32 0, i32 1
+// BENUMLOADS-NEXT:[[BF_LOAD:%.*]] = load volatile i16, i16* [[F]], align 1
 // BE-NEXT:store volatile i16 1, i16* [[F]], align 1
 // BE-NEXT:ret void
 //
@@ -698,6 +702,7 @@
 // LE-NEXT:[[F:%.*]] = getelementptr inbounds [[STRUCT_ST11:%.*]], %struct.st11* [[M:%.*]], i32 0, i32 1
 // LE-NEXT:[[BF_LOAD:%.*]] = load volatile i16, i16* [[F]], align 1
 // LE-NEXT:[[INC:%.*]] = add i16 [[BF_LOAD]], 1
+// LENUMLOADS-NEXT:[[BF_LOAD1:%.*]] = load volatile i16, i16* [[F]], align 1
 // LE-NEXT:store volatile i16 [[INC]], i16* [[F]], align 1
 // LE-NEXT:ret void
 //
@@ -706,6 +711,7 @@
 // BE-NEXT:[[F:%.*]] = getelementptr inbounds [[STRUCT_ST11:%.*]], %struct.st11* [[M:%.*]], i32 0, i32 1
 // BE-NEXT:[[BF_LOAD:%.*]] = load volatile i16, i16* [[F]], align 1
 // BE-NEXT:[[INC:%.*]] = add i16 [[BF_LOAD]], 1
+// BENUMLOADS-NEXT:[[BF_LOAD1:%.*]] = load volatile i16, i16* [[F]], align 1
 // BE-NEXT:store volatile i16 [[INC]], i16* [[F]], align 1
 // BE-NEXT:ret void
 //
@@ -882,6 +888,7 @@
 // LE-NEXT:[[TMP0:%.*]] = getelementptr [[STRUCT_ST14:%.*]], %struct.st14* [[S:%.*]], i32 0, i32 0
 // LE-NEXT:[[BF_LOAD:%.*]] = load volatile i8, i8* [[TMP0]], align 1
 // LE-NEXT:[[INC:%.*]] = add i8 [[BF_LOAD]], 1
+// LENUMLOADS-NEXT:[[BF_LOAD1:%.*]] = load volatile i8, i8* [[TMP0]], align 1
 // LE-NEXT:store volatile i8 [[INC]], i8* [[TMP0]], align 1
 // LE-NEXT:ret void
 //
@@ -890,6 +897,7 @@
 // BE-NEXT:[[TMP0:%.*]] = getelementptr [[STRUCT_ST14:%.*]], %struct.st14* [[S:%.*]], i32 0, i32 0
 // BE-NEXT:[[BF_LOAD:%.*]] = load volatile i8, i8* [[TMP0]], align 1
 // BE-NEXT:[[INC:%.*]] = add i8 [[BF_LOAD]], 1
+// BENUMLOADS-NEXT:[[BF_LOAD1:%.*]] = load volatile i8, i8* [[TMP0]], align 1
 // BE-NEXT:store volatile i8 [[INC]], i8* [[TMP0]], align 1
 // BE-NEXT:ret void
 //
@@ -906,6 +914,7 @@
 // LE-NEXT:[[TMP0:%.*]] = getelementptr [[STRUCT_ST15:%.*]], %struct.st15* [[S:%.*]], i32 0, i32 0
 // LE-NEXT:[[BF_LOAD:%.*]] = load volatile i8, i8* [[TMP0]], align 1
 // LE-NEXT:[[INC:%.*]] = add i8 [[BF_LOAD]], 1
+// LENUMLOADS-NEXT:[[BF_LOAD1:%.*]] = load volatile i8, i8* [[TMP0]], align 1
 // LE-NEXT:store volatile i8 [[INC]], i8* [[TMP0]], align 1
 // LE-NEXT:ret void
 //
@@ -914,6 +923,7 @@
 // BE-NEXT:[[TMP0:%.*]] = getelementptr [[STRUCT_ST15:%.*]], %struct.st15* [[S:%.*]], i32 0, i32 0
 // BE-NEXT:[[BF_LOAD:%.*]] = load volatile i8, i8* [[TMP0]], align 1
 // BE-NEXT:[[INC:%.*]] = add i8 [[BF_LOAD]], 1
+// BENUMLOADS-NEXT:[[BF_LOAD1:%.*]] = load volatile i8, i8* [[TMP0]], align 1
 // BE-NEXT:store volatile i8 [[INC]], i8* [[TMP0]], align 1
 // BE-NEXT:ret void
 //
@@ -1061,6 +1071,7 @@
 // LE-NEXT:[[TMP0:%.*]] = bitcast %struct.st16* [[S:%.*]] to i32*
 // LE-NEXT:[[BF_LOAD:%.*]] = load volatile i32, i32* [[TMP0]], align 4
 // LE-NEXT:[[INC:%.*]] = add nsw i32 [[BF_LOAD]], 1
+// LENUMLOADS-NEXT:[[BF_LOAD1:%.*]] = load volatile i32, i32* [[TMP0]], align 4
 // LE-NEXT:store volatile i32 [[INC]], i32* [[TMP0]], align 4
 // LE-NEXT:ret void
 //
@@ -1069,6 +1080,7 @@
 // BE-NEXT:[[TMP0:%.*]] = bitcast %struct.st16* [[S:

[PATCH] D73637: Fix handling of OO_Spaceship in DecodeOperatorCall

2020-01-30 Thread Stephan Bergmann via Phabricator via cfe-commits
sberg updated this revision to Diff 241485.
sberg added a comment.

Minimal reproducer is

  template struct S;
  template void operator <=>(S, S);
  template void f(T x) { decltype(x <=> x) v; }

Added a corresponding test to clang/test/SemaCXX/cxx2a-three-way-comparison.cpp.


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

https://reviews.llvm.org/D73637

Files:
  clang/lib/AST/StmtProfile.cpp
  clang/test/SemaCXX/cxx2a-three-way-comparison.cpp


Index: clang/test/SemaCXX/cxx2a-three-way-comparison.cpp
===
--- clang/test/SemaCXX/cxx2a-three-way-comparison.cpp
+++ clang/test/SemaCXX/cxx2a-three-way-comparison.cpp
@@ -22,3 +22,5 @@
 };
 
 int &r = B().operator<=>(0);
+
+template void f(T x) { decltype(x <=> x) v; }
Index: clang/lib/AST/StmtProfile.cpp
===
--- clang/lib/AST/StmtProfile.cpp
+++ clang/lib/AST/StmtProfile.cpp
@@ -1535,8 +1535,8 @@
 return Stmt::BinaryOperatorClass;
 
   case OO_Spaceship:
-// FIXME: Update this once we support <=> expressions.
-llvm_unreachable("<=> expressions not supported yet");
+BinaryOp = BO_Cmp;
+return Stmt::BinaryOperatorClass;
 
   case OO_AmpAmp:
 BinaryOp = BO_LAnd;


Index: clang/test/SemaCXX/cxx2a-three-way-comparison.cpp
===
--- clang/test/SemaCXX/cxx2a-three-way-comparison.cpp
+++ clang/test/SemaCXX/cxx2a-three-way-comparison.cpp
@@ -22,3 +22,5 @@
 };
 
 int &r = B().operator<=>(0);
+
+template void f(T x) { decltype(x <=> x) v; }
Index: clang/lib/AST/StmtProfile.cpp
===
--- clang/lib/AST/StmtProfile.cpp
+++ clang/lib/AST/StmtProfile.cpp
@@ -1535,8 +1535,8 @@
 return Stmt::BinaryOperatorClass;
 
   case OO_Spaceship:
-// FIXME: Update this once we support <=> expressions.
-llvm_unreachable("<=> expressions not supported yet");
+BinaryOp = BO_Cmp;
+return Stmt::BinaryOperatorClass;
 
   case OO_AmpAmp:
 BinaryOp = BO_LAnd;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72811: [WIP][OPENMP5.0] allow lvalue for motion clause

2020-01-30 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15201
+namespace {
+class LocatorChecker final : public StmtVisitor {
+  OMPClauseMappableExprCommon::MappableExprComponentList Components;

Seems to me, you're skipping many expressions, which could be supported. Did 
you try to test it with casting expressions and others?



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15203-15205
+  DeclRefExpr *DRE;
+  CXXThisExpr *CTE;
+  size_t DerefCnt;

Use default initializers for fields.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15213
+  bool VisitDeclRefExpr(DeclRefExpr *E) {
+if (const auto *VD = dyn_cast(E->getDecl())) {
+  const clang::Type *PT = E->getType().getTypePtr();

Better to use early exit where possible to reduce structural complexity of the 
functions.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15215-15216
+  const clang::Type *PT = E->getType().getTypePtr();
+  const std::string TypeStr = PT->getCanonicalTypeInternal().getAsString();
+  size_t PtrCnt = std::count(TypeStr.begin(), TypeStr.end(), '*');
+  // Normally we want to add Components if DerefCnt == PtrCnt, for example:

This really looks ugly. Need to find a better solution.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15233
+  //  PtrCnt for B: 0
+  if (DerefCnt <= PtrCnt) {
+pushComponentIfNoBaseDecl(E, E->getDecl());

Why do you need to count the number of dereferences? And have this comparison 
here?



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15368
 
 if (auto *CurE = dyn_cast(E)) {
+  if (!(isa(CurE->getDecl(

If you have the visitor class, you can replace all this code with an analysis 
in the visitor.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15369
 if (auto *CurE = dyn_cast(E)) {
-  if (!isa(CurE->getDecl()))
+  if (!(isa(CurE->getDecl(
 return nullptr;

Restore original code



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15554
+LocatorChecker Checker;
+if (Checker.Visit(OrigExpr)) {
+  llvm::copy(Checker.getComponents(),

General question about several cases. How we're going to support them?
1. (a ? b : c). 
2. __builtin_choose_expr(a, b, c).
3. a = b.
4. a?:b
5. __builtin_convertvector(x, ty)
6. (int&)a
7. v.xy, where v is an extended vector
8. a.b, where b is a bitfield
9. __builtin_bit_cast(v, ty)
10. const_cast(a)
11. dynamic_cast(a)
12. reinterpret_cast
13. static_cast
14. typeid() (also is an lvalue).
15. __uuidof(*comPtr)
16. lambda calls
17. User defined literals




Comment at: clang/lib/Sema/SemaOpenMP.cpp:1
+if (Checker.Visit(OrigExpr)) {
+  llvm::copy(Checker.getComponents(),
+ std::back_inserter(CurComponents));

Better to pass `CurComponents` as an argument at the construction of the 
checker to avoid extra filling/copying.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72811



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


[PATCH] D73720: [Analyzer] Use note tags to track container begin and and changes

2020-01-30 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware created this revision.
baloghadamsoftware added reviewers: NoQ, Szelethus.
baloghadamsoftware added a project: clang.
Herald added subscribers: Charusso, dkrupp, donat.nagy, mikhail.ramalho, 
a.sidorin, rnkovacs, szepet, xazax.hun.

Container operations such as `push_back()`, `pop_front()` etc. increment and 
decrement the abstract begin and end symbols of containers. This patch 
introduces note tags to `ContainerModeling` to track these changes. This helps 
the user to better identify the source of errors related to containers and 
iterators.


Repository:
  rC Clang

https://reviews.llvm.org/D73720

Files:
  clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
  clang/test/Analysis/container-modeling.cpp

Index: clang/test/Analysis/container-modeling.cpp
===
--- clang/test/Analysis/container-modeling.cpp
+++ clang/test/Analysis/container-modeling.cpp
@@ -1,6 +1,6 @@
-// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=false %s -verify
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=false %s -analyzer-output=text -verify
 
-// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=true -DINLINE=1 %s -verify
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=true -DINLINE=1 %s -analyzer-output=text -verify
 
 // RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorModeling,debug.ExprInspection -analyzer-config aggressive-binary-operation-simplification=true %s 2>&1 | FileCheck %s
 
@@ -20,14 +20,16 @@
   V.begin();
 
   clang_analyzer_denote(clang_analyzer_container_begin(V), "$V.begin()");
-  clang_analyzer_express(clang_analyzer_container_begin(V)); //expected-warning{{$V.begin()}}
+  clang_analyzer_express(clang_analyzer_container_begin(V)); // expected-warning{{$V.begin()}}
+ // expected-note@-1{{$V.begin()}}
 }
 
 void end(const std::vector &V) {
   V.end();
 
   clang_analyzer_denote(clang_analyzer_container_end(V), "$V.end()");
-  clang_analyzer_express(clang_analyzer_container_end(V)); //expected-warning{{$V.end()}}
+  clang_analyzer_express(clang_analyzer_container_end(V)); // expected-warning{{$V.end()}}
+   // expected-note@-1{{$V.end()}}
 }
 
 
@@ -48,8 +50,10 @@
   long B2 = clang_analyzer_container_begin(V2);
   long E2 = clang_analyzer_container_end(V2);
   V1 = std::move(V2);
-  clang_analyzer_eval(clang_analyzer_container_begin(V1) == B2); //expected-warning{{TRUE}}
-  clang_analyzer_eval(clang_analyzer_container_end(V2) == E2); //expected-warning{{TRUE}}
+  clang_analyzer_eval(clang_analyzer_container_begin(V1) == B2); // expected-warning{{TRUE}}
+ // expected-note@-1{{TRUE}}
+  clang_analyzer_eval(clang_analyzer_container_end(V2) == E2); // expected-warning{{TRUE}}
+   // expected-note@-1{{TRUE}}
 }
 
 
@@ -70,10 +74,13 @@
   clang_analyzer_denote(clang_analyzer_container_begin(V), "$V.begin()");
   clang_analyzer_denote(clang_analyzer_container_end(V), "$V.end()");
 
-  V.push_back(n);
+  V.push_back(n); // expected-note{{Container 'V' extended to the right by 1 position}}
+  // expected-note@-1{{Container 'V' extended to the right by 1 position}}
 
   clang_analyzer_express(clang_analyzer_container_begin(V)); // expected-warning{{$V.begin()}}
+ // expected-note@-1{{$V.begin()}}
   clang_analyzer_express(clang_analyzer_container_end(V)); // expected-warning{{$V.end() + 1}}
+   // expected-note@-1{{$V.end() + 1}}
 }
 
 /// emplace_back()
@@ -88,10 +95,14 @@
   clang_analyzer_denote(clang_analyzer_container_begin(V), "$V.begin()");
   clang_analyzer_denote(clang_analyzer_container_end(V), "$V.end()");
 
-  V.emplace_back(n);
+  V.emplace_back(n); // expected-note{{Container 'V' extended to the right by 1 position}}
+ // expected-note@-1{{Contain

[PATCH] D73701: [clang] fix linkage of nested lambda

2020-01-30 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment.

+ rsmith




Comment at: clang/lib/AST/Decl.cpp:1416-1417
 return getLVForClosure(
-  OuterMostLambda->getDeclContext()->getRedeclContext(),
-  OuterMostLambda->getLambdaContextDecl(), computation);
+  Record->getDeclContext()->getRedeclContext(),
+  Record->getLambdaContextDecl(), computation);
   }

The code is still inconsistent with the comment. `Record` is the lambda itself 
instead of the parent of the lambda.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73701



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


[PATCH] D73721: [Clang][Driver] Disable llvm passes for the first host OpenMP offload compilation

2020-01-30 Thread Sergey Dmitriev via Phabricator via cfe-commits
sdmitriev created this revision.
sdmitriev added reviewers: ABataev, jdoerfert, hfinkel.
Herald added subscribers: cfe-commits, guansong.
Herald added a project: clang.

With OpenMP offloading host compilation is done in two phases to capture host 
IR that is passed to all device compilations as input. But it turns out that we 
currently run entire LLVM optimization pipeline on host IR on both compilations 
which may have unpredictable effects on the resulting code. This patch fixes 
this problem by disabling LLVM passes on the first compilation, so the host IR 
that is passed to device compilations will be captured right after front end.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73721

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/openmp-offload.c


Index: clang/test/Driver/openmp-offload.c
===
--- clang/test/Driver/openmp-offload.c
+++ clang/test/Driver/openmp-offload.c
@@ -259,7 +259,7 @@
 //
 // Generate host BC file and host object.
 //
-// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux" 
{{.*}}"-emit-llvm-bc"
+// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux" 
{{.*}}"-emit-llvm-bc" {{.*}}"-disable-llvm-passes"
 // CHK-COMMANDS-SAME: 
"-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu"
 // CHK-COMMANDS-SAME: "-o" "
 // CHK-COMMANDS-SAME: [[HOSTBC:[^\\/]+\.bc]]" "-x" "c" "
@@ -269,7 +269,7 @@
 // CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux" 
{{.*}}"-E" {{.*}}"-fopenmp" {{.*}}"-o" "
 // CHK-COMMANDS-ST-SAME: [[HOSTPP:[^\\/]+\.i]]" "-x" "c" "
 // CHK-COMMANDS-ST-SAME: [[INPUT:[^\\/]+\.c]]"
-// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux" 
{{.*}}"-emit-llvm-bc" {{.*}}"-fopenmp" 
{{.*}}"-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu" 
{{.*}}"-o" "
+// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux" 
{{.*}}"-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-disable-llvm-passes" 
{{.*}}"-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu" 
{{.*}}"-o" "
 // CHK-COMMANDS-ST-SAME: [[HOSTBC:[^\\/]+\.bc]]" "-x" "cpp-output" 
"{{.*}}[[HOSTPP]]"
 // CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux" 
{{.*}}"-S" {{.*}}"-fopenmp" {{.*}}"-o" "
 // CHK-COMMANDS-ST-SAME: [[HOSTASM:[^\\/]+\.s]]" "-x" "ir" "{{.*}}[[HOSTBC]]"
@@ -427,14 +427,14 @@
 // RUN:   | FileCheck -check-prefix=CHK-BUJOBS-ST %s
 
 // Create host BC.
-// CHK-BUJOBS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux" 
{{.*}}"-emit-llvm-bc"  {{.*}}"-fopenmp" 
{{.*}}"-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu" 
{{.*}}"-o" "
+// CHK-BUJOBS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux" 
{{.*}}"-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-disable-llvm-passes" 
{{.*}}"-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu" 
{{.*}}"-o" "
 // CHK-BUJOBS-SAME: [[HOSTBC:[^\\/]+\.bc]]" "-x" "c" "
 // CHK-BUJOBS-SAME: [[INPUT:[^\\/]+\.c]]"
 
 // CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux" 
{{.*}}"-E"  {{.*}}"-fopenmp" {{.*}}"-o" "
 // CHK-BUJOBS-ST-SAME: [[HOSTPP:[^\\/]+\.i]]" "-x" "c" "
 // CHK-BUJOBS-ST-SAME: [[INPUT:[^\\/]+\.c]]"
-// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux" 
{{.*}}"-emit-llvm-bc"  {{.*}}"-fopenmp" 
{{.*}}"-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu" 
{{.*}}"-o" "
+// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux" 
{{.*}}"-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-disable-llvm-passes" 
{{.*}}"-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu" 
{{.*}}"-o" "
 // CHK-BUJOBS-ST-SAME: [[HOSTBC:[^\\/]+\.bc]]" "-x" "cpp-output" 
"{{.*}}[[HOSTPP]]"
 
 // Create target 1 object.
@@ -493,7 +493,7 @@
 // CHK-UBJOBS-SAME: [[HOSTPP:[^\\/]+\.i]],
 // CHK-UBJOBS-SAME: [[T1PP:[^\\/]+\.i]],
 // CHK-UBJOBS-SAME: [[T2PP:[^\\/]+\.i]]" "-unbundle"
-// CHK-UBJOBS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux" 
{{.*}}"-emit-llvm-bc"  {{.*}}"-fopenmp" 
{{.*}}"-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu" 
{{.*}}"-o" "
+// CHK-UBJOBS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux" 
{{.*}}"-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-disable-llvm-passes" 
{{.*}}"-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu" 
{{.*}}"-o" "
 // CHK-UBJOBS-SAME: [[HOSTBC:[^\\/]+\.bc]]" "-x" "cpp-output" 
"{{.*}}[[HOSTPP]]"
 // CHK-UBJOBS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux" 
{{.*}}"-emit-obj" {{.*}}"-fopenmp" {{.*}}"-o" "
 // CHK-UBJOBS-SAME: [[HOSTOBJ:[^\\/]+\.o]]" "-x" "ir" "{{.*}}[[HOSTBC]]"
@@ -502,7 +502,7 @@
 // CHK-UBJOBS-ST-SAME: [[HOSTPP:[^\\/,]+\.i]],
 // CHK-UBJOBS-ST-SAME: [[T1PP:[^\\/,]+\.i]],
 // CHK-UBJOBS-ST-SAME: [[T2PP:[^\\/,]+\.i]]" "-unbundle"
-// CHK-UBJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux" 
{{.*}}"-emit-llvm-bc"  {{.*}

[clang-tools-extra] 3ae11b4 - [NFC] small refactor on RenamerClangTidyCheck.cpp

2020-01-30 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-01-30T17:32:06Z
New Revision: 3ae11b42818363f70b3c6b0246bb617e35709c58

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

LOG: [NFC] small refactor on RenamerClangTidyCheck.cpp

Added: 


Modified: 
clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp 
b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
index b2c7797bf647..c1145802aaa4 100644
--- a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
@@ -133,7 +133,7 @@ static void 
addUsage(RenamerClangTidyCheck::NamingCheckFailureMap &Failures,
  const RenamerClangTidyCheck::NamingCheckId &Decl,
  SourceRange Range, SourceManager *SourceMgr = nullptr) {
   // Do nothing if the provided range is invalid.
-  if (Range.getBegin().isInvalid() || Range.getEnd().isInvalid())
+  if (Range.isInvalid())
 return;
 
   // If we have a source manager, use it to convert to the spelling location 
for
@@ -290,11 +290,9 @@ void RenamerClangTidyCheck::check(const 
MatchFinder::MatchResult &Result) {
   Value->getReturnType().getTypePtr()->getAs())
 addUsage(NamingCheckFailures, Typedef->getDecl(),
  Value->getSourceRange());
-  for (unsigned i = 0; i < Value->getNumParams(); ++i) {
-if (const TypedefType *Typedef = Value->parameters()[i]
- ->getType()
- .getTypePtr()
- ->getAs())
+  for (const ParmVarDecl *Param : Value->parameters()) {
+if (const TypedefType *Typedef =
+Param->getType().getTypePtr()->getAs())
   addUsage(NamingCheckFailures, Typedef->getDecl(),
Value->getSourceRange());
   }



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


[PATCH] D69746: [analyzer] FixItHint: Apply and test hints with the Clang Tidy's script

2020-01-30 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 241492.
Charusso marked 8 inline comments as done.
Charusso added a comment.

- Change to 4-column space standard.
- Simplify obtaining the Clang include directory.


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

https://reviews.llvm.org/D69746

Files:
  clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
  clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  clang/lib/StaticAnalyzer/Frontend/CMakeLists.txt
  clang/test/Analysis/analyzer-config.c
  clang/test/Analysis/check_analyzer_fixit.py
  clang/test/Analysis/virtualcall-fixit.cpp
  clang/test/lit.cfg.py

Index: clang/test/lit.cfg.py
===
--- clang/test/lit.cfg.py
+++ clang/test/lit.cfg.py
@@ -77,6 +77,11 @@
 if config.clang_staticanalyzer_z3 == '1':
 config.available_features.add('z3')
 
+check_analyzer_fixit_path = os.path.join(
+config.test_source_root, "Analysis", "check_analyzer_fixit.py")
+config.substitutions.append(
+('%check_analyzer_fixit',
+ '%s %s' % (config.python_executable, check_analyzer_fixit_path)))
 
 llvm_config.add_tool_substitutions(tools, tool_dirs)
 
Index: clang/test/Analysis/virtualcall-fixit.cpp
===
--- /dev/null
+++ clang/test/Analysis/virtualcall-fixit.cpp
@@ -0,0 +1,13 @@
+// RUN: %check_analyzer_fixit %s %t \
+// RUN:   -analyzer-checker=core,optin.cplusplus.VirtualCall \
+// RUN:   -analyzer-config optin.cplusplus.VirtualCall:ShowFixIts=true
+
+struct S {
+  virtual void foo();
+  S() {
+foo();
+// expected-warning@-1 {{Call to virtual method 'S::foo' during construction bypasses virtual dispatch}}
+// CHECK-FIXES: S::foo();
+  }
+  ~S();
+};
Index: clang/test/Analysis/check_analyzer_fixit.py
===
--- /dev/null
+++ clang/test/Analysis/check_analyzer_fixit.py
@@ -0,0 +1,121 @@
+#!/usr/bin/env python
+#
+#===- check_analyzer_fixit.py - Static Analyzer test helper ---*- python -*-===#
+#
+# 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
+#
+#======#
+#
+# This file copy-pasted mostly from the Clang Tidy's 'check_clang_tidy.py'.
+#
+#======#
+
+r"""
+Clang Static Analyzer test helper
+=
+
+This script runs the Analyzer in fix-it mode and verify fixes, warnings, notes.
+
+Usage:
+  check_analyzer_fixit.py   [analyzer arguments]
+
+Example:
+  // RUN: %check_analyzer_fixit %s %t -analyzer-checker=core
+"""
+
+import argparse
+import os
+import re
+import subprocess
+import sys
+
+
+def write_file(file_name, text):
+with open(file_name, 'w') as f:
+f.write(text)
+
+
+def run_test_once(args, extra_args):
+input_file_name = args.input_file_name
+temp_file_name = args.temp_file_name
+clang_analyzer_extra_args = extra_args
+
+file_name_with_extension = input_file_name
+_, extension = os.path.splitext(file_name_with_extension)
+if extension not in ['.c', '.hpp', '.m', '.mm']:
+extension = '.cpp'
+temp_file_name = temp_file_name + extension
+
+with open(input_file_name, 'r') as input_file:
+input_text = input_file.read()
+
+# Remove the contents of the CHECK lines to avoid CHECKs matching on
+# themselves.  We need to keep the comments to preserve line numbers while
+# avoiding empty lines which could potentially trigger formatting-related
+# checks.
+cleaned_test = re.sub('// *CHECK-[A-Z0-9\-]*:[^\r\n]*', '//', input_text)
+write_file(temp_file_name, cleaned_test)
+
+original_file_name = temp_file_name + ".orig"
+write_file(original_file_name, cleaned_test)
+
+try:
+builtin_include_dir = subprocess.check_output(
+['clang', '-print-file-name=include'], stderr=subprocess.STDOUT)
+except subprocess.CalledProcessError as e:
+print('Cannot print Clang include directory: ' + e.output.decode())
+
+builtin_include_dir = os.path.normpath(builtin_include_dir)
+
+args = (['clang', '-cc1', '-internal-isystem', builtin_include_dir,
+ '-nostdsysteminc', '-analyze', '-analyzer-constraints=range',
+ '-analyzer-config', 'apply-fixits=true']
++ clang_analyzer_extra_args + ['-verify', temp_file_name])
+
+print('Running ' + str(args) + '...')
+
+try:
+clang_analyzer_output = \
+subprocess.check_output(args, stderr=subprocess.STDOUT).decode()
+except subprocess.CalledProcessError as e:
+print('Clang Static Analyzer test failed:\n' + e.output.decode())
+raise
+
+print('- Clang Static Ana

[PATCH] D67399: [ARM] Follow AACPS for preserving number of loads/stores of volatile bit-fields

2020-01-30 Thread JF Bastien via Phabricator via cfe-commits
jfb accepted this revision.
jfb added a comment.
This revision is now accepted and ready to land.

I'm happy with this change since it's opt-in. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67399



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


[PATCH] D69746: [analyzer] FixItHint: Apply and test hints with the Clang Tidy's script

2020-01-30 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment.

Thanks for the reviews! Sorry for the delay.


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

https://reviews.llvm.org/D69746



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


[PATCH] D69746: [analyzer] FixItHint: Apply and test hints with the Clang Tidy's script

2020-01-30 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added inline comments.



Comment at: clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:92
+
+  bool IncludePath = false, ShouldEmitAsError = false, FixitsAsRemarks = false,
+   ApplyFixIts = false;

NoQ wrote:
> I'll be perfectly happy with removing `FixitsAsRemarks` entirely. Your new 
> mechanism is superior.
Okai, challenge accepted. Thanks!



Comment at: clang/test/Analysis/check_analyzer_fixit.py:1
+#!/usr/bin/env python
+#

lebedev.ri wrote:
> This does work with python3?
I think it should. It is only made for running by the `lit` which is left in 
Python 2.



Comment at: clang/test/Analysis/check_analyzer_fixit.py:50-51
+  clang_dir = clang_dir.strip()
+  if sys.platform in ['win32']:
+clang_dir = clang_dir.replace('\\', '/')
+

NoQ wrote:
> I think there must be an `os.path` function for this.
I hope it is `os.path.normpath()`.



Comment at: clang/test/Analysis/check_analyzer_fixit.py:59
+f.write(text)
+f.truncate()
+

NoQ wrote:
> Mmm, what does this do?
I think an empty `truncate()` does not do anything, so removed.


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

https://reviews.llvm.org/D69746



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


[PATCH] D69746: [analyzer] FixItHint: Apply and test hints with the Clang Tidy's script

2020-01-30 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 241493.
Charusso edited the summary of this revision.
Charusso added a comment.

- Rename the script from `check_analyzer_fixit.py` to `check-analyzer-fixit.py`


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

https://reviews.llvm.org/D69746

Files:
  clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
  clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  clang/lib/StaticAnalyzer/Frontend/CMakeLists.txt
  clang/test/Analysis/analyzer-config.c
  clang/test/Analysis/check-analyzer-fixit.py
  clang/test/Analysis/virtualcall-fixit.cpp
  clang/test/lit.cfg.py

Index: clang/test/lit.cfg.py
===
--- clang/test/lit.cfg.py
+++ clang/test/lit.cfg.py
@@ -77,6 +77,11 @@
 if config.clang_staticanalyzer_z3 == '1':
 config.available_features.add('z3')
 
+check_analyzer_fixit_path = os.path.join(
+config.test_source_root, "Analysis", "check-analyzer-fixit.py")
+config.substitutions.append(
+('%check_analyzer_fixit',
+ '%s %s' % (config.python_executable, check_analyzer_fixit_path)))
 
 llvm_config.add_tool_substitutions(tools, tool_dirs)
 
Index: clang/test/Analysis/virtualcall-fixit.cpp
===
--- /dev/null
+++ clang/test/Analysis/virtualcall-fixit.cpp
@@ -0,0 +1,13 @@
+// RUN: %check_analyzer_fixit %s %t \
+// RUN:   -analyzer-checker=core,optin.cplusplus.VirtualCall \
+// RUN:   -analyzer-config optin.cplusplus.VirtualCall:ShowFixIts=true
+
+struct S {
+  virtual void foo();
+  S() {
+foo();
+// expected-warning@-1 {{Call to virtual method 'S::foo' during construction bypasses virtual dispatch}}
+// CHECK-FIXES: S::foo();
+  }
+  ~S();
+};
Index: clang/test/Analysis/check-analyzer-fixit.py
===
--- /dev/null
+++ clang/test/Analysis/check-analyzer-fixit.py
@@ -0,0 +1,121 @@
+#!/usr/bin/env python
+#
+#===- check-analyzer-fixit.py - Static Analyzer test helper ---*- python -*-===#
+#
+# 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
+#
+#======#
+#
+# This file copy-pasted mostly from the Clang Tidy's 'check_clang_tidy.py'.
+#
+#======#
+
+r"""
+Clang Static Analyzer test helper
+=
+
+This script runs the Analyzer in fix-it mode and verify fixes, warnings, notes.
+
+Usage:
+  check-analyzer-fixit.py   [analyzer arguments]
+
+Example:
+  // RUN: %check-analyzer-fixit %s %t -analyzer-checker=core
+"""
+
+import argparse
+import os
+import re
+import subprocess
+import sys
+
+
+def write_file(file_name, text):
+with open(file_name, 'w') as f:
+f.write(text)
+
+
+def run_test_once(args, extra_args):
+input_file_name = args.input_file_name
+temp_file_name = args.temp_file_name
+clang_analyzer_extra_args = extra_args
+
+file_name_with_extension = input_file_name
+_, extension = os.path.splitext(file_name_with_extension)
+if extension not in ['.c', '.hpp', '.m', '.mm']:
+extension = '.cpp'
+temp_file_name = temp_file_name + extension
+
+with open(input_file_name, 'r') as input_file:
+input_text = input_file.read()
+
+# Remove the contents of the CHECK lines to avoid CHECKs matching on
+# themselves.  We need to keep the comments to preserve line numbers while
+# avoiding empty lines which could potentially trigger formatting-related
+# checks.
+cleaned_test = re.sub('// *CHECK-[A-Z0-9\-]*:[^\r\n]*', '//', input_text)
+write_file(temp_file_name, cleaned_test)
+
+original_file_name = temp_file_name + ".orig"
+write_file(original_file_name, cleaned_test)
+
+try:
+builtin_include_dir = subprocess.check_output(
+['clang', '-print-file-name=include'], stderr=subprocess.STDOUT)
+except subprocess.CalledProcessError as e:
+print('Cannot print Clang include directory: ' + e.output.decode())
+
+builtin_include_dir = os.path.normpath(builtin_include_dir)
+
+args = (['clang', '-cc1', '-internal-isystem', builtin_include_dir,
+ '-nostdsysteminc', '-analyze', '-analyzer-constraints=range',
+ '-analyzer-config', 'apply-fixits=true']
++ clang_analyzer_extra_args + ['-verify', temp_file_name])
+
+print('Running ' + str(args) + '...')
+
+try:
+clang_analyzer_output = \
+subprocess.check_output(args, stderr=subprocess.STDOUT).decode()
+except subprocess.CalledProcessError as e:
+print('Clang Static Analyzer test failed:\n' + e.output.decode())
+raise
+
+print('- Clang Static Analyze

[PATCH] D73723: [clangd][Hover] Handle uninstantiated default args

2020-01-30 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.

Default args might exist but be unparsed or uninstantiated.
getDefaultArg asserts on those. This patch makes sure we don't crash in such
scenarios.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73723

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
@@ -1609,6 +1609,22 @@
 HI.Type = "unsigned long";
 HI.Value = "1";
   }},
+  {
+  R"cpp(
+  template 
+  void foo(const T& = T()) {
+[[f^oo]]<>(3);
+  })cpp",
+  [](HoverInfo &HI) {
+HI.Name = "foo";
+HI.Kind = index::SymbolKind::Function;
+HI.Type = "void (const int &)";
+HI.ReturnType = "void";
+HI.Parameters = {
+{std::string("const int &"), llvm::None, std::string("T()")}};
+HI.Definition = "template <> void foo(const int &)";
+HI.NamespaceScope = "";
+  }},
   };
 
   // Create a tiny index, so tests above can verify documentation is fetched.
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -269,10 +269,17 @@
 }
 if (!PVD->getName().empty())
   P.Name = PVD->getNameAsString();
-if (PVD->hasDefaultArg()) {
+// Default argument can be unparsed or uninstatiated. For the former we
+// can't do much as token information is only stored in Sema and not
+// attached to the AST node. For the latter though, it is safe to proceed 
as
+// we only print the expression.
+if (PVD->hasDefaultArg() && !PVD->hasUnparsedDefaultArg()) {
   P.Default.emplace();
   llvm::raw_string_ostream Out(*P.Default);
-  PVD->getDefaultArg()->printPretty(Out, nullptr, Policy);
+  const Expr *Init = PVD->hasUninstantiatedDefaultArg()
+ ? PVD->getUninstantiatedDefaultArg()
+ : PVD->getDefaultArg();
+  Init->printPretty(Out, nullptr, Policy);
 }
   }
 


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -1609,6 +1609,22 @@
 HI.Type = "unsigned long";
 HI.Value = "1";
   }},
+  {
+  R"cpp(
+  template 
+  void foo(const T& = T()) {
+[[f^oo]]<>(3);
+  })cpp",
+  [](HoverInfo &HI) {
+HI.Name = "foo";
+HI.Kind = index::SymbolKind::Function;
+HI.Type = "void (const int &)";
+HI.ReturnType = "void";
+HI.Parameters = {
+{std::string("const int &"), llvm::None, std::string("T()")}};
+HI.Definition = "template <> void foo(const int &)";
+HI.NamespaceScope = "";
+  }},
   };
 
   // Create a tiny index, so tests above can verify documentation is fetched.
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -269,10 +269,17 @@
 }
 if (!PVD->getName().empty())
   P.Name = PVD->getNameAsString();
-if (PVD->hasDefaultArg()) {
+// Default argument can be unparsed or uninstatiated. For the former we
+// can't do much as token information is only stored in Sema and not
+// attached to the AST node. For the latter though, it is safe to proceed as
+// we only print the expression.
+if (PVD->hasDefaultArg() && !PVD->hasUnparsedDefaultArg()) {
   P.Default.emplace();
   llvm::raw_string_ostream Out(*P.Default);
-  PVD->getDefaultArg()->printPretty(Out, nullptr, Policy);
+  const Expr *Init = PVD->hasUninstantiatedDefaultArg()
+ ? PVD->getUninstantiatedDefaultArg()
+ : PVD->getDefaultArg();
+  Init->printPretty(Out, nullptr, Policy);
 }
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73360: [OpenCL] Restrict address space conversions in nested pointers

2020-01-30 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Is there no follow-up code when actually emitting the failure diagnostic which 
tries to figure out a more specific cause of failure?


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

https://reviews.llvm.org/D73360



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


[PATCH] D73721: [Clang][Driver] Disable llvm passes for the first host OpenMP offload compilation

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

LG


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73721



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


[PATCH] D73723: [clangd][Hover] Handle uninstantiated default args

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

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

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

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

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


//Pre-merge checks is in beta. Report issue 
.
 Please join beta  or enable 
it for your project 
.//


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73723



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


[PATCH] D70172: [CUDA][HIP][OpenMP] Emit deferred diagnostics by a post-parsing AST travese

2020-01-30 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:17183
+  class DeferredDiagnosticsEmitter
+  : public EvaluatedExprVisitor {
+Sema &S;

Is there any way to share most of the visitation logic here with the visitor we 
use in `MarkDeclarationsUsedInExpr`?  Maybe make a `UsedDeclVisitor` CRTP class 
that calls a "asImpl().visitUsedDecl(SourceLocation Loc, Decl *D)" in the right 
places?


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

https://reviews.llvm.org/D70172



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


[clang] 36bfdb7 - [Clang][Driver] Disable llvm passes for the first host OpenMP offload compilation

2020-01-30 Thread Sergey Dmitriev via cfe-commits

Author: Sergey Dmitriev
Date: 2020-01-30T10:16:41-08:00
New Revision: 36bfdb7096cfe1925448e408ec72f1a6bdc4cd2c

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

LOG: [Clang][Driver] Disable llvm passes for the first host OpenMP offload 
compilation

Summary: With OpenMP offloading host compilation is done in two phases to 
capture host IR that is passed to all device compilations as input. But it 
turns out that we currently run entire LLVM optimization pipeline on host IR on 
both compilations which may have unpredictable effects on the resulting code. 
This patch fixes this problem by disabling LLVM passes on the first 
compilation, so the host IR that is passed to device compilations will be 
captured right after front end.

Reviewers: ABataev, jdoerfert, hfinkel

Reviewed By: ABataev

Subscribers: guansong, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/openmp-offload.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 44f8f2676cbb..fdd0610f464c 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5788,7 +5788,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   // FIXME: -fembed-bitcode -save-temps will save optimized bitcode instead of
   // pristine IR generated by the frontend. Ideally, a new compile action 
should
   // be added so both IR can be captured.
-  if (C.getDriver().isSaveTempsEnabled() &&
+  if ((C.getDriver().isSaveTempsEnabled() ||
+   JA.isHostOffloading(Action::OFK_OpenMP)) &&
   !(C.getDriver().embedBitcodeInObject() && !C.getDriver().isUsingLTO()) &&
   isa(JA))
 CmdArgs.push_back("-disable-llvm-passes");

diff  --git a/clang/test/Driver/openmp-offload.c 
b/clang/test/Driver/openmp-offload.c
index 30669bb86ed1..a93ef24d7e0a 100644
--- a/clang/test/Driver/openmp-offload.c
+++ b/clang/test/Driver/openmp-offload.c
@@ -259,7 +259,7 @@
 //
 // Generate host BC file and host object.
 //
-// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux" 
{{.*}}"-emit-llvm-bc"
+// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux" 
{{.*}}"-emit-llvm-bc" {{.*}}"-disable-llvm-passes"
 // CHK-COMMANDS-SAME: 
"-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu"
 // CHK-COMMANDS-SAME: "-o" "
 // CHK-COMMANDS-SAME: [[HOSTBC:[^\\/]+\.bc]]" "-x" "c" "
@@ -269,7 +269,7 @@
 // CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux" 
{{.*}}"-E" {{.*}}"-fopenmp" {{.*}}"-o" "
 // CHK-COMMANDS-ST-SAME: [[HOSTPP:[^\\/]+\.i]]" "-x" "c" "
 // CHK-COMMANDS-ST-SAME: [[INPUT:[^\\/]+\.c]]"
-// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux" 
{{.*}}"-emit-llvm-bc" {{.*}}"-fopenmp" 
{{.*}}"-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu" 
{{.*}}"-o" "
+// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux" 
{{.*}}"-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-disable-llvm-passes" 
{{.*}}"-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu" 
{{.*}}"-o" "
 // CHK-COMMANDS-ST-SAME: [[HOSTBC:[^\\/]+\.bc]]" "-x" "cpp-output" 
"{{.*}}[[HOSTPP]]"
 // CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux" 
{{.*}}"-S" {{.*}}"-fopenmp" {{.*}}"-o" "
 // CHK-COMMANDS-ST-SAME: [[HOSTASM:[^\\/]+\.s]]" "-x" "ir" "{{.*}}[[HOSTBC]]"
@@ -427,14 +427,14 @@
 // RUN:   | FileCheck -check-prefix=CHK-BUJOBS-ST %s
 
 // Create host BC.
-// CHK-BUJOBS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux" 
{{.*}}"-emit-llvm-bc"  {{.*}}"-fopenmp" 
{{.*}}"-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu" 
{{.*}}"-o" "
+// CHK-BUJOBS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux" 
{{.*}}"-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-disable-llvm-passes" 
{{.*}}"-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu" 
{{.*}}"-o" "
 // CHK-BUJOBS-SAME: [[HOSTBC:[^\\/]+\.bc]]" "-x" "c" "
 // CHK-BUJOBS-SAME: [[INPUT:[^\\/]+\.c]]"
 
 // CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux" 
{{.*}}"-E"  {{.*}}"-fopenmp" {{.*}}"-o" "
 // CHK-BUJOBS-ST-SAME: [[HOSTPP:[^\\/]+\.i]]" "-x" "c" "
 // CHK-BUJOBS-ST-SAME: [[INPUT:[^\\/]+\.c]]"
-// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux" 
{{.*}}"-emit-llvm-bc"  {{.*}}"-fopenmp" 
{{.*}}"-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu" 
{{.*}}"-o" "
+// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux" 
{{.*}}"-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-disable-llvm-passes" 
{{.*}}"-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu" 
{{.*}}"-o"

[PATCH] D73721: [Clang][Driver] Disable llvm passes for the first host OpenMP offload compilation

2020-01-30 Thread Sergey Dmitriev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG36bfdb7096cf: [Clang][Driver] Disable llvm passes for the 
first host OpenMP offload… (authored by sdmitriev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73721

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/openmp-offload.c


Index: clang/test/Driver/openmp-offload.c
===
--- clang/test/Driver/openmp-offload.c
+++ clang/test/Driver/openmp-offload.c
@@ -259,7 +259,7 @@
 //
 // Generate host BC file and host object.
 //
-// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux" 
{{.*}}"-emit-llvm-bc"
+// CHK-COMMANDS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux" 
{{.*}}"-emit-llvm-bc" {{.*}}"-disable-llvm-passes"
 // CHK-COMMANDS-SAME: 
"-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu"
 // CHK-COMMANDS-SAME: "-o" "
 // CHK-COMMANDS-SAME: [[HOSTBC:[^\\/]+\.bc]]" "-x" "c" "
@@ -269,7 +269,7 @@
 // CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux" 
{{.*}}"-E" {{.*}}"-fopenmp" {{.*}}"-o" "
 // CHK-COMMANDS-ST-SAME: [[HOSTPP:[^\\/]+\.i]]" "-x" "c" "
 // CHK-COMMANDS-ST-SAME: [[INPUT:[^\\/]+\.c]]"
-// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux" 
{{.*}}"-emit-llvm-bc" {{.*}}"-fopenmp" 
{{.*}}"-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu" 
{{.*}}"-o" "
+// CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux" 
{{.*}}"-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-disable-llvm-passes" 
{{.*}}"-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu" 
{{.*}}"-o" "
 // CHK-COMMANDS-ST-SAME: [[HOSTBC:[^\\/]+\.bc]]" "-x" "cpp-output" 
"{{.*}}[[HOSTPP]]"
 // CHK-COMMANDS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux" 
{{.*}}"-S" {{.*}}"-fopenmp" {{.*}}"-o" "
 // CHK-COMMANDS-ST-SAME: [[HOSTASM:[^\\/]+\.s]]" "-x" "ir" "{{.*}}[[HOSTBC]]"
@@ -427,14 +427,14 @@
 // RUN:   | FileCheck -check-prefix=CHK-BUJOBS-ST %s
 
 // Create host BC.
-// CHK-BUJOBS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux" 
{{.*}}"-emit-llvm-bc"  {{.*}}"-fopenmp" 
{{.*}}"-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu" 
{{.*}}"-o" "
+// CHK-BUJOBS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux" 
{{.*}}"-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-disable-llvm-passes" 
{{.*}}"-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu" 
{{.*}}"-o" "
 // CHK-BUJOBS-SAME: [[HOSTBC:[^\\/]+\.bc]]" "-x" "c" "
 // CHK-BUJOBS-SAME: [[INPUT:[^\\/]+\.c]]"
 
 // CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux" 
{{.*}}"-E"  {{.*}}"-fopenmp" {{.*}}"-o" "
 // CHK-BUJOBS-ST-SAME: [[HOSTPP:[^\\/]+\.i]]" "-x" "c" "
 // CHK-BUJOBS-ST-SAME: [[INPUT:[^\\/]+\.c]]"
-// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux" 
{{.*}}"-emit-llvm-bc"  {{.*}}"-fopenmp" 
{{.*}}"-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu" 
{{.*}}"-o" "
+// CHK-BUJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux" 
{{.*}}"-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-disable-llvm-passes" 
{{.*}}"-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu" 
{{.*}}"-o" "
 // CHK-BUJOBS-ST-SAME: [[HOSTBC:[^\\/]+\.bc]]" "-x" "cpp-output" 
"{{.*}}[[HOSTPP]]"
 
 // Create target 1 object.
@@ -493,7 +493,7 @@
 // CHK-UBJOBS-SAME: [[HOSTPP:[^\\/]+\.i]],
 // CHK-UBJOBS-SAME: [[T1PP:[^\\/]+\.i]],
 // CHK-UBJOBS-SAME: [[T2PP:[^\\/]+\.i]]" "-unbundle"
-// CHK-UBJOBS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux" 
{{.*}}"-emit-llvm-bc"  {{.*}}"-fopenmp" 
{{.*}}"-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu" 
{{.*}}"-o" "
+// CHK-UBJOBS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux" 
{{.*}}"-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-disable-llvm-passes" 
{{.*}}"-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu" 
{{.*}}"-o" "
 // CHK-UBJOBS-SAME: [[HOSTBC:[^\\/]+\.bc]]" "-x" "cpp-output" 
"{{.*}}[[HOSTPP]]"
 // CHK-UBJOBS: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux" 
{{.*}}"-emit-obj" {{.*}}"-fopenmp" {{.*}}"-o" "
 // CHK-UBJOBS-SAME: [[HOSTOBJ:[^\\/]+\.o]]" "-x" "ir" "{{.*}}[[HOSTBC]]"
@@ -502,7 +502,7 @@
 // CHK-UBJOBS-ST-SAME: [[HOSTPP:[^\\/,]+\.i]],
 // CHK-UBJOBS-ST-SAME: [[T1PP:[^\\/,]+\.i]],
 // CHK-UBJOBS-ST-SAME: [[T2PP:[^\\/,]+\.i]]" "-unbundle"
-// CHK-UBJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux" 
{{.*}}"-emit-llvm-bc"  {{.*}}"-fopenmp" 
{{.*}}"-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu" 
{{.*}}"-o" "
+// CHK-UBJOBS-ST: clang{{.*}}" "-cc1" "-triple" "powerpc64le-unknown-linux" 
{{.*}}"-emit-llvm-bc" {{.*}}"-fopenmp" {{.*}}"-disable-llvm-passes" 
{{.*}}"-fopenmp-targets=powerpc64le-ibm-linux-gnu,x86_64-pc-linux-gnu" 
{{.*}}"-o" "
 // CHK-UBJOBS-ST-SAME: [[HOSTBC:[^\\/]+\.bc]]" 

[PATCH] D73282: Fix debug-info generation for block invocations so that we set the LinkageName instead of the Name

2020-01-30 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik updated this revision to Diff 241508.
shafik marked 4 inline comments as done.
shafik added a comment.

Address comments by not special casing the `___Z` case, this requires setting 
both the Name and Linkage name because DWARF requires subroutines to have a 
`DW_AT_name`. We discovered this when altering the code to just set the 
`LinkageName` and it broke several LLDB tests.


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

https://reviews.llvm.org/D73282

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-block-invocation-linkage-name.cpp
  clang/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
  clang/test/OpenMP/target_parallel_debug_codegen.cpp
  clang/test/OpenMP/target_parallel_for_debug_codegen.cpp


Index: clang/test/OpenMP/target_parallel_for_debug_codegen.cpp
===
--- clang/test/OpenMP/target_parallel_for_debug_codegen.cpp
+++ clang/test/OpenMP/target_parallel_for_debug_codegen.cpp
@@ -111,5 +111,5 @@
 // CHECK: addrspacecast [10 x [10 x i32]]* %{{.+}} to [10 x [10 x i32]] 
addrspace(1)*
 // CHECK: call void @__omp_offloading_{{[^(]+}}([10 x [10 x [10 x i32]]] 
addrspace(1)* {{[^,]+}}, i32 addrspace(1)* {{[^,]+}}, [10 x [10 x i32]] 
addrspace(1)* {{[^,]+}}, i8 addrspace(1)* {{[^)]+}})
 
-// CHECK-DAG: distinct !DISubprogram(name: "[[NONDEBUG_WRAPPER]]",
-// CHECK-DAG: distinct !DISubprogram(name: "[[DEBUG_PARALLEL]]",
+// CHECK-DAG: distinct !DISubprogram(name: "[[NONDEBUG_WRAPPER]]", 
linkageName: "[[NONDEBUG_WRAPPER]]",
+// CHECK-DAG: distinct !DISubprogram(name: "[[DEBUG_PARALLEL]]", linkageName: 
"[[DEBUG_PARALLEL]]",
Index: clang/test/OpenMP/target_parallel_debug_codegen.cpp
===
--- clang/test/OpenMP/target_parallel_debug_codegen.cpp
+++ clang/test/OpenMP/target_parallel_debug_codegen.cpp
@@ -133,5 +133,5 @@
 // CHECK: !DILocalVariable(name: "b",
 // CHECK-SAME: line: 21
 
-// CHECK-DAG: distinct !DISubprogram(name: "[[NONDEBUG_WRAPPER]]",
-// CHECK-DAG: distinct !DISubprogram(name: "[[DEBUG_PARALLEL]]",
+// CHECK-DAG: distinct !DISubprogram(name: "[[NONDEBUG_WRAPPER]]", 
linkageName: "[[NONDEBUG_WRAPPER]]",
+// CHECK-DAG: distinct !DISubprogram(name: "[[DEBUG_PARALLEL]]", linkageName: 
"[[DEBUG_PARALLEL]]",
Index: clang/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
===
--- clang/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
+++ clang/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
@@ -32,7 +32,7 @@
 // CHECK-NOKEXT: !DISubprogram(name: "__cxx_global_var_init",{{.*}} line: 
15,{{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
 // CHECK-NOKEXT: !DISubprogram(name: "__dtor_glob",{{.*}} line: 15,{{.*}} 
DISPFlagLocalToUnit | DISPFlagDefinition
 // CHECK-NOKEXT: !DISubprogram(name: "__cxx_global_var_init.1",{{.*}} line: 
16,{{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-NOKEXT: !DISubprogram(name: "__cxx_global_array_dtor",{{.*}} line: 
16,{{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-NOKEXT: !DISubprogram(name: "__cxx_global_array_dtor", linkageName: 
"__cxx_global_array_dtor",{{.*}} line: 16,{{.*}} DISPFlagLocalToUnit | 
DISPFlagDefinition
 // CHECK-NOKEXT: !DISubprogram(name: "__dtor_array",{{.*}} line: 16,{{.*}} 
DISPFlagLocalToUnit | DISPFlagDefinition
 // CHECK-NOKEXT: !DISubprogram(name: "__dtor__ZZ3foovE4stat",{{.*}} line: 
19,{{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
 // CHECK-NOKEXT: !DISubprogram({{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
@@ -42,7 +42,7 @@
 // CHECK-MSVC: !DISubprogram(name: "`dynamic initializer for 'glob'",{{.*}} 
line: 15,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
 // CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 
'glob'",{{.*}} line: 15,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
 // CHECK-MSVC: !DISubprogram(name: "`dynamic initializer for 'array'",{{.*}} 
line: 16,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-MSVC: !DISubprogram(name: "__cxx_global_array_dtor",{{.*}} line: 
16,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-MSVC: !DISubprogram(name: "__cxx_global_array_dtor", linkageName: 
"__cxx_global_array_dtor",{{.*}} line: 16,{{.*}}: DISPFlagLocalToUnit | 
DISPFlagDefinition
 // CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 
'array'",{{.*}} line: 16,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
 // CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 
'stat'",{{.*}} line: 19,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
 
Index: clang/test/CodeGenCXX/debug-info-block-invocation-linkage-name.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/debug-info-block-invocation-linkage-name.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=standalone -fblocks -triple 
%itanium_abi_triple %s -o - | FileCheck %s
+
+// CHECK: !DIS

[PATCH] D73282: Fix debug-info generation for block invocations so that we set the LinkageName instead of the Name

2020-01-30 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik marked an inline comment as done.
shafik added inline comments.



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:3659
 // Use llvm function name.
-Name = Fn->getName();
+if (Fn->getName().startswith("___Z"))
+  LinkageName = Fn->getName();

dblaikie wrote:
> shafik wrote:
> > dblaikie wrote:
> > > aprantl wrote:
> > > > aprantl wrote:
> > > > > Could you please add a comment that Clang Blocks are generated as raw 
> > > > > llvm::Functions but do have a mangled name and that is handling this 
> > > > > case? Otherwise this would look suspicious.
> > > > Should *all* raw LLVM functions have their name as the linkage name? 
> > > > Perhaps a raw LLVM function should only have a linkage name and no 
> > > > human-readable name?
> > > Seems plausible to me - do we have any data on other types of functions 
> > > that hit this codepath? 
> > So it was not obvious to me what other cases would this branch so I added 
> > an assert and ran `check-clang` and from that I saw four cases that ended 
> > up here:
> > 
> > `GenerateCapturedStmtFunction`
> > `GenerateOpenMPCapturedStmtFunction`
> > `GenerateBlockFunction`
> > `generateDestroyHelper`
> > 
> > It is not obvious to me we want to alter the behavior of any of the other 
> > cases.
> Could you show any small source examples & their corresponding DWARF & how 
> that DWARF would change? (what names are we using, what names would we end up 
> using/what sort of things are they naming)
Ok, I understand the objections to special casing like this. We ended up 
setting both the `Name` and `LinkageName` unconditionally in this branch 
because not setting the name for subroutines end up with us generating 
`DW_TAG_subprogram` without a `DW_AT_name` which is not valid. We discovered 
this when running the LLDB test suite.


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

https://reviews.llvm.org/D73282



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


[PATCH] D73729: [analyzer] AnalyzerOptions: Remove 'fixits-as-remarks'

2020-01-30 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso created this revision.
Charusso added a reviewer: NoQ.
Charusso added a project: clang.
Herald added subscribers: cfe-commits, dkrupp, donat.nagy, Szelethus, 
mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
Charusso added a parent revision: D69746: [analyzer] FixItHint: Apply and test 
hints with the Clang Tidy's script.

The new way of checking fix-its is `%check_analyzer_fixit`.


Repository:
  rC Clang

https://reviews.llvm.org/D73729

Files:
  clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
  clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  clang/test/Analysis/analyzer-config.c
  clang/test/Analysis/dead-stores.c
  clang/test/Analysis/virtualcall-fixit.cpp
  clang/test/Analysis/virtualcall-fixits.cpp

Index: clang/test/Analysis/virtualcall-fixits.cpp
===
--- clang/test/Analysis/virtualcall-fixits.cpp
+++ clang/test/Analysis/virtualcall-fixits.cpp
@@ -1,10 +1,11 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=core,optin.cplusplus.VirtualCall \
 // RUN: -analyzer-config optin.cplusplus.VirtualCall:ShowFixIts=true \
 // RUN: %s 2>&1 | FileCheck -check-prefix=TEXT %s
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,optin.cplusplus.VirtualCall \
+
+// RUN: %check_analyzer_fixit %s %t \
+// RUN: -analyzer-checker=core,optin.cplusplus.VirtualCall \
 // RUN: -analyzer-config optin.cplusplus.VirtualCall:ShowFixIts=true \
-// RUN: -analyzer-config fixits-as-remarks=true \
-// RUN: -analyzer-output=plist -o %t.plist -verify %s
+// RUN: -analyzer-output=plist -o %t.plist
 // RUN: cat %t.plist | FileCheck -check-prefix=PLIST %s
 
 struct S {
@@ -12,7 +13,9 @@
   S() {
 foo();
 // expected-warning@-1{{Call to virtual method 'S::foo' during construction bypasses virtual dispatch}}
-// expected-remark@-2{{5-5: 'S::'}}
+// CHECK-FIXES:  S() {
+// CHECK-FIXES-NEXT:   S::foo();
+// CHECK-FIXES-NEXT: }
   }
   ~S();
 };
@@ -30,12 +33,12 @@
 // PLIST-NEXT:remove_range
 // PLIST-NEXT:
 // PLIST-NEXT: 
-// PLIST-NEXT:  line13
+// PLIST-NEXT:  line14
 // PLIST-NEXT:  col5
 // PLIST-NEXT:  file0
 // PLIST-NEXT: 
 // PLIST-NEXT: 
-// PLIST-NEXT:  line13
+// PLIST-NEXT:  line14
 // PLIST-NEXT:  col4
 // PLIST-NEXT:  file0
 // PLIST-NEXT: 
Index: clang/test/Analysis/virtualcall-fixit.cpp
===
--- clang/test/Analysis/virtualcall-fixit.cpp
+++ /dev/null
@@ -1,13 +0,0 @@
-// RUN: %check_analyzer_fixit %s %t \
-// RUN:   -analyzer-checker=core,optin.cplusplus.VirtualCall \
-// RUN:   -analyzer-config optin.cplusplus.VirtualCall:ShowFixIts=true
-
-struct S {
-  virtual void foo();
-  S() {
-foo();
-// expected-warning@-1 {{Call to virtual method 'S::foo' during construction bypasses virtual dispatch}}
-// CHECK-FIXES: S::foo();
-  }
-  ~S();
-};
Index: clang/test/Analysis/dead-stores.c
===
--- clang/test/Analysis/dead-stores.c
+++ clang/test/Analysis/dead-stores.c
@@ -1,16 +1,16 @@
-// RUN: %clang_analyze_cc1 -Wunused-variable -fblocks -Wno-unreachable-code \
+// RUN: %check_analyzer_fixit %s %t \
+// RUN:   -Wunused-variable -fblocks -Wno-unreachable-code \
 // RUN:   -analyzer-checker=core,deadcode.DeadStores \
 // RUN:   -analyzer-config deadcode.DeadStores:ShowFixIts=true \
-// RUN:   -analyzer-config fixits-as-remarks=true \
 // RUN:   -analyzer-config \
 // RUN:   deadcode.DeadStores:WarnForDeadNestedAssignments=false \
-// RUN:   -verify=non-nested %s
+// RUN:   -verify=non-nested
 
-// RUN: %clang_analyze_cc1 -Wunused-variable -fblocks -Wno-unreachable-code \
+// RUN: %check_analyzer_fixit %s %t \
+// RUN:   -Wunused-variable -fblocks -Wno-unreachable-code \
 // RUN:   -analyzer-checker=core,deadcode.DeadStores \
 // RUN:   -analyzer-config deadcode.DeadStores:ShowFixIts=true \
-// RUN:   -analyzer-config fixits-as-remarks=true \
-// RUN:   -verify=non-nested,nested %s
+// RUN:   -verify=non-nested,nested
 
 void f1() {
   int k, y; // non-nested-warning {{unused variable 'k'}}
@@ -18,14 +18,17 @@
   int abc = 1;
   long idx = abc + 3 * 5; // non-nested-warning {{never read}}
   // non-nested-warning@-1 {{unused variable 'idx'}}
-  // non-nested-remark@-2 {{11-24: ''}}
+  // CHECK-FIXES:  int abc = 1;
+  // CHECK-FIXES-NEXT: long idx;
 }
 
 void f2(void *b) {
   char *c = (char *)b; // no-warning
   char *d = b + 1; // non-nested-warning {{never read}}
// non-nested-warning@-1 {{unused variable 'd'}}
-   // non-nested-remark@-2 {{10-17: ''}}
+  // CHECK-FIXES:  char *c = (char *)b;
+  // CHECK-FIXES-NEXT: char *d;
+
   printf("%s", c);
   // non-nested-warning@-1 {{implicitly declaring library function 'printf' with type 'int (const char *, ...)'}}
   // non-nes

[clang] c83d9be - [Concept] Fix incorrect check for containsUnexpandedParameterPack in CSE

2020-01-30 Thread Saar Raz via cfe-commits

Author: Saar Raz
Date: 2020-01-30T20:45:44+02:00
New Revision: c83d9bedc0cc430dc620e7a807daeb985d390325

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

LOG: [Concept] Fix incorrect check for containsUnexpandedParameterPack in CSE

We previously checked for containsUnexpandedParameterPack in CSEs by observing 
the property
in the converted arguments of the CSE. This may not work if the argument is an 
expanded
type-alias that contains a pack-expansion (see added test).

Check the as-written arguments when determining containsUnexpandedParameterPack 
and isInstantiationDependent.

Added: 


Modified: 
clang/include/clang/AST/ExprConcepts.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/ExprConcepts.cpp
clang/test/CXX/expr/expr.prim/expr.prim.id/p3.cpp

Removed: 




diff  --git a/clang/include/clang/AST/ExprConcepts.h 
b/clang/include/clang/AST/ExprConcepts.h
index 2a64326e8604..271d487e2fc9 100644
--- a/clang/include/clang/AST/ExprConcepts.h
+++ b/clang/include/clang/AST/ExprConcepts.h
@@ -63,6 +63,12 @@ class ConceptSpecializationExpr final : public Expr, public 
ConceptReference,
 ArrayRef ConvertedArgs,
 const ConstraintSatisfaction *Satisfaction);
 
+  ConceptSpecializationExpr(const ASTContext &C, ConceptDecl *NamedConcept,
+ArrayRef ConvertedArgs,
+const ConstraintSatisfaction *Satisfaction,
+bool Dependent,
+bool ContainsUnexpandedParameterPack);
+
   ConceptSpecializationExpr(EmptyShell Empty, unsigned NumTemplateArgs);
 
 public:
@@ -75,6 +81,13 @@ class ConceptSpecializationExpr final : public Expr, public 
ConceptReference,
  ArrayRef ConvertedArgs,
  const ConstraintSatisfaction *Satisfaction);
 
+  static ConceptSpecializationExpr *
+  Create(const ASTContext &C, ConceptDecl *NamedConcept,
+ ArrayRef ConvertedArgs,
+ const ConstraintSatisfaction *Satisfaction,
+ bool Dependent,
+ bool ContainsUnexpandedParameterPack);
+
   static ConceptSpecializationExpr *
   Create(ASTContext &C, EmptyShell Empty, unsigned NumTemplateArgs);
 

diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 72969490e32d..c80d3948d003 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -731,12 +731,8 @@ canonicalizeImmediatelyDeclaredConstraint(const ASTContext 
&C, Expr *IDC,
   NewConverted.push_back(Arg);
   }
   Expr *NewIDC = ConceptSpecializationExpr::Create(
-  C, NestedNameSpecifierLoc(), /*TemplateKWLoc=*/SourceLocation(),
-  CSE->getConceptNameInfo(), /*FoundDecl=*/CSE->getNamedConcept(),
-  CSE->getNamedConcept(),
-  // Actually canonicalizing a TemplateArgumentLoc is 
diff icult so we
-  // simply omit the ArgsAsWritten
-  /*ArgsAsWritten=*/nullptr, NewConverted, nullptr);
+  C, CSE->getNamedConcept(), NewConverted, nullptr,
+  CSE->isInstantiationDependent(), CSE->containsUnexpandedParameterPack());
 
   if (auto *OrigFold = dyn_cast(IDC))
 NewIDC = new (C) CXXFoldExpr(OrigFold->getType(), SourceLocation(), NewIDC,

diff  --git a/clang/lib/AST/ExprConcepts.cpp b/clang/lib/AST/ExprConcepts.cpp
index 76d57ed5d5b1..b5a3686dc99a 100644
--- a/clang/lib/AST/ExprConcepts.cpp
+++ b/clang/lib/AST/ExprConcepts.cpp
@@ -46,24 +46,12 @@ ConceptSpecializationExpr::ConceptSpecializationExpr(const 
ASTContext &C,
ASTConstraintSatisfaction::Create(C, *Satisfaction) :
nullptr) {
   setTemplateArguments(ConvertedArgs);
-}
-
-ConceptSpecializationExpr::ConceptSpecializationExpr(EmptyShell Empty,
-unsigned NumTemplateArgs)
-: Expr(ConceptSpecializationExprClass, Empty), ConceptReference(),
-  NumTemplateArgs(NumTemplateArgs) { }
-
-void ConceptSpecializationExpr::setTemplateArguments(
-ArrayRef Converted) {
-  assert(Converted.size() == NumTemplateArgs);
-  std::uninitialized_copy(Converted.begin(), Converted.end(),
-  getTrailingObjects());
   bool IsInstantiationDependent = false;
   bool ContainsUnexpandedParameterPack = false;
-  for (const TemplateArgument& Arg : Converted) {
-if (Arg.isInstantiationDependent())
+  for (const TemplateArgumentLoc& ArgLoc : ArgsAsWritten->arguments()) {
+if (ArgLoc.getArgument().isInstantiationDependent())
   IsInstantiationDependent = true;
-if (Arg.containsUnexpandedParameterPack())
+if (ArgLoc.getArgument().containsUnexpandedParameterPack())
   ContainsUnexpandedParameterPack = true;
 if (ContainsUnexpandedParameterPack && IsInstantiationDependent)
   break;
@@ -80,6 +68,18 @@ void ConceptSpecializationExpr::setTemplateArguments(
   

[clang] a424ef9 - [Concepts] Add check for dependent RC when checking function constraints

2020-01-30 Thread Saar Raz via cfe-commits

Author: Saar Raz
Date: 2020-01-30T20:46:32+02:00
New Revision: a424ef99e7b9821ec80564af3d3a8f091323a38c

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

LOG: [Concepts] Add check for dependent RC when checking function constraints

Do not attempt to check a dependent requires clause in a function constraint
(may be triggered by, for example, DiagnoseUseOfDecl).

Added: 


Modified: 
clang/lib/Sema/SemaConcept.cpp
clang/lib/Sema/SemaExpr.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index e5c0fa28c11f..8fdc6023040f 100755
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -325,9 +325,10 @@ bool Sema::CheckFunctionConstraints(const FunctionDecl *FD,
 ConstraintSatisfaction &Satisfaction,
 SourceLocation UsageLoc) {
   const Expr *RC = FD->getTrailingRequiresClause();
-  assert(!RC->isInstantiationDependent() &&
- "CheckFunctionConstraints can only be used with functions with "
- "non-dependent constraints");
+  if (RC->isInstantiationDependent()) {
+Satisfaction.IsSatisfied = true;
+return false;
+  }
   // We substitute with empty arguments in order to rebuild the atomic
   // constraint in a constant-evaluated context.
   // FIXME: Should this be a dedicated TreeTransform?

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index b063247bf1df..81eee22af4ee 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -333,11 +333,9 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, 
ArrayRef Locs,
   //
   // See if this is a function with constraints that need to be satisfied.
   if (FunctionDecl *FD = dyn_cast(D)) {
-if (Expr *RC = FD->getTrailingRequiresClause()) {
+if (FD->getTrailingRequiresClause()) {
   ConstraintSatisfaction Satisfaction;
-  bool Failed = CheckConstraintSatisfaction(FD, {RC}, /*TemplateArgs=*/{},
-SourceRange(Loc), 
Satisfaction);
-  if (Failed)
+  if (CheckFunctionConstraints(FD, Satisfaction, Loc))
 // A diagnostic will have already been generated (non-constant
 // constraint expression, for example)
 return true;



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


[clang] 60f5da7 - [Concepts] Add 'this' context to instantiation of member requires clause

2020-01-30 Thread Saar Raz via cfe-commits

Author: Saar Raz
Date: 2020-01-30T20:47:59+02:00
New Revision: 60f5da79e3de49b2074446e656a72970499a8d78

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

LOG: [Concepts] Add 'this' context to instantiation of member requires clause

'this' context was missing in instantiation of member requires clause.

Added: 


Modified: 
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 2e437cbe44d3..2637b4cb6dca 100755
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -2190,6 +2190,9 @@ Decl *TemplateDeclInstantiator::VisitCXXMethodDecl(
   if (TrailingRequiresClause) {
 EnterExpressionEvaluationContext ConstantEvaluated(
 SemaRef, Sema::ExpressionEvaluationContext::Unevaluated);
+auto *ThisContext = dyn_cast_or_null(Owner);
+Sema::CXXThisScopeRAII ThisScope(SemaRef, ThisContext,
+ D->getMethodQualifiers(), ThisContext);
 ExprResult SubstRC = SemaRef.SubstExpr(TrailingRequiresClause,
TemplateArgs);
 if (SubstRC.isInvalid())



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


  1   2   >