[clang] 9faedb2 - [Driver] Quote executable in reports generated by -fproc-stat-report

2020-11-17 Thread Serge Pavlov via cfe-commits

Author: Serge Pavlov
Date: 2020-11-17T15:16:09+07:00
New Revision: 9faedb2d7146d29bfd0f601e2a4a90b546cdaf04

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

LOG: [Driver] Quote executable in reports generated by -fproc-stat-report

The option -fproc-stat-report= makes driver to generate child
process resource comsumption report. In the report executable name was
not quoted and it made parsing the report more difficult. With this
change the executable name is surrounded by quotation marks.

Added: 


Modified: 
clang/lib/Driver/Driver.cpp

Removed: 




diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 5f4e7f271764..fb258197cfdd 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -3964,7 +3964,9 @@ void Driver::BuildJobs(Compilation &C) const {
 // CSV format.
 std::string Buffer;
 llvm::raw_string_ostream Out(Buffer);
-Out << llvm::sys::path::filename(Cmd.getExecutable()) << ',';
+llvm::sys::printArg(Out, 
llvm::sys::path::filename(Cmd.getExecutable()),
+/*Quote*/ true);
+Out << ',';
 if (Cmd.getOutputFilenames().empty())
   Out << "\"\"";
 else



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


[PATCH] D85474: Add -fbinutils-version= to gate ELF features on the specified binutils version

2020-11-17 Thread James Henderson via Phabricator via cfe-commits
jhenderson added a comment.

In D85474#2398858 , @MaskRay wrote:

> Sent https://lists.llvm.org/pipermail/llvm-dev/2020-November/146676.html "Add 
> -fbinutils-version=" (cross posted to cfe-dev) so that more folks can notice 
> it.
>
> About "generate code that doesn't care about GNU as/ld 
> compatibility/limitation", I am open for suggestions. Currently I like 
> `-fbinutils-version=none` the most (after considering `future` and `latest` 
> and `99` (assuming GNU binutils 99 implements everything we need...))

I like `none`. `latest` has some connotations that we attempt compatibility 
with some specific bleeding edge set of tools, which might not be true, 
especially if they've released at a different time point to us. `none` implies 
there is no specific guarantee for compatibility to me. `99` (or other number) 
seems risky/short-sighted given the way versioning sometimes shoots up versus 
the longetivity of some of these code bases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85474

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


[PATCH] D91592: [ASTMatchers] Fix typo for hasAnyOverloadedOperatorName

2020-11-17 Thread Keishi Hattori via Phabricator via cfe-commits
keishi created this revision.
keishi added a reviewer: aaron.ballman.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
keishi requested review of this revision.

Fix typo for hasAnyOverloadedOperatorName in doc and code comment.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91592

Files:
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h


Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -2825,7 +2825,7 @@
 /// Matches overloaded operator names specified in strings without the
 /// "operator" prefix: e.g. "<<".
 ///
-///   hasAnyOverloadesOperatorName("+", "-")
+///   hasAnyOverloadedOperatorName("+", "-")
 /// Is equivalent to
 ///   anyOf(hasOverloadedOperatorName("+"), hasOverloadedOperatorName("-"))
 extern const internal::VariadicFunction<
Index: clang/docs/LibASTMatchersReference.html
===
--- clang/docs/LibASTMatchersReference.html
+++ clang/docs/LibASTMatchersReference.html
@@ -2779,7 +2779,7 @@
 Matches overloaded operator names specified in strings without the
 "operator" prefix: e.g. "<<".
 
-  hasAnyOverloadesOperatorName("+", "-")
+  hasAnyOverloadedOperatorName("+", "-")
 Is equivalent to
   anyOf(hasOverloadedOperatorName("+"), hasOverloadedOperatorName("-"))
 
@@ -3400,7 +3400,7 @@
 Matches overloaded operator names specified in strings without the
 "operator" prefix: e.g. "<<".
 
-  hasAnyOverloadesOperatorName("+", "-")
+  hasAnyOverloadedOperatorName("+", "-")
 Is equivalent to
   anyOf(hasOverloadedOperatorName("+"), hasOverloadedOperatorName("-"))
 


Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -2825,7 +2825,7 @@
 /// Matches overloaded operator names specified in strings without the
 /// "operator" prefix: e.g. "<<".
 ///
-///   hasAnyOverloadesOperatorName("+", "-")
+///   hasAnyOverloadedOperatorName("+", "-")
 /// Is equivalent to
 ///   anyOf(hasOverloadedOperatorName("+"), hasOverloadedOperatorName("-"))
 extern const internal::VariadicFunction<
Index: clang/docs/LibASTMatchersReference.html
===
--- clang/docs/LibASTMatchersReference.html
+++ clang/docs/LibASTMatchersReference.html
@@ -2779,7 +2779,7 @@
 Matches overloaded operator names specified in strings without the
 "operator" prefix: e.g. "<<".
 
-  hasAnyOverloadesOperatorName("+", "-")
+  hasAnyOverloadedOperatorName("+", "-")
 Is equivalent to
   anyOf(hasOverloadedOperatorName("+"), hasOverloadedOperatorName("-"))
 
@@ -3400,7 +3400,7 @@
 Matches overloaded operator names specified in strings without the
 "operator" prefix: e.g. "<<".
 
-  hasAnyOverloadesOperatorName("+", "-")
+  hasAnyOverloadedOperatorName("+", "-")
 Is equivalent to
   anyOf(hasOverloadedOperatorName("+"), hasOverloadedOperatorName("-"))
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D90441: [X86] Add support for vex, vex2, vex3, and evex for MASM

2020-11-17 Thread LiuChen via Phabricator via cfe-commits
LiuChen3 added a comment.

Ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90441

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


[PATCH] D91596: [PowerPC] [Clang] Fix alignment of 128-bit floating types

2020-11-17 Thread Qiu Chaofan via Phabricator via cfe-commits
qiucf created this revision.
qiucf added reviewers: jsji, nemanjai, uweigand, PowerPC, steven.zhang, 
rjmccall.
Herald added subscribers: cfe-commits, shchenz, kbarton.
Herald added a project: clang.
qiucf requested review of this revision.

According to ELF v2 ABI, both IEEE 128-bit and IBM extended floating point 
variables should be quad-word (16 bytes) aligned. Previously, only vector types 
are considered aligned as quad-word on Power.

Without this fix, IEEE 128-bit fp will be passed incorrectly in va_arg cases.

(the patch is not patchable since I generated it for easier review, the case is 
a new file)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91596

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/ppc64le-varargs-f128.c


Index: clang/test/CodeGen/ppc64le-varargs-f128.c
===
--- clang/test/CodeGen/ppc64le-varargs-f128.c
+++ clang/test/CodeGen/ppc64le-varargs-f128.c
@@ -9,8 +9,11 @@
 
 // IEEE-LABEL: define fp128 @f128(i32 signext %n, ...)
 // IEEE: call void @llvm.va_start(i8* %{{[0-9a-zA-Z_.]+}})
-// IEEE: %[[P4:[0-9a-zA-Z_.]+]] = bitcast i8* %{{[0-9a-zA-Z_.]+}} to fp128*
-// IEEE: %{{[0-9a-zA-Z_.]+}} = load fp128, fp128* %[[P4]], align 8
+// IEEE: %[[P1:[0-9a-zA-Z_.]+]] = add i64 %{{[0-9a-zA-Z_.]+}}, 15
+// IEEE: %[[P2:[0-9a-zA-Z_.]+]] = and i64 %[[P1]], -16
+// IEEE: %[[P3:[0-9a-zA-Z_.]+]] = inttoptr i64 %[[P2]] to i8*
+// IEEE: %[[P4:[0-9a-zA-Z_.]+]] = bitcast i8* %[[P3]] to fp128*
+// IEEE: %{{[0-9a-zA-Z_.]+}} = load fp128, fp128* %[[P4]], align 16
 // IEEE: call void @llvm.va_end(i8* %{{[0-9a-zA-Z_.]+}})
 __float128 f128(int n, ...) {
   va_list ap;
@@ -22,14 +25,20 @@
 
 // IEEE-LABEL: define fp128 @long_double(i32 signext %n, ...)
 // IEEE: call void @llvm.va_start(i8* %{{[0-9a-zA-Z_.]+}})
-// IEEE: %[[P4:[0-9a-zA-Z_.]+]] = bitcast i8* %{{[0-9a-zA-Z_.]+}} to fp128*
-// IEEE: %{{[0-9a-zA-Z_.]+}} = load fp128, fp128* %[[P4]], align 8
+// IEEE: %[[P1:[0-9a-zA-Z_.]+]] = add i64 %{{[0-9a-zA-Z_.]+}}, 15
+// IEEE: %[[P2:[0-9a-zA-Z_.]+]] = and i64 %[[P1]], -16
+// IEEE: %[[P3:[0-9a-zA-Z_.]+]] = inttoptr i64 %[[P2]] to i8*
+// IEEE: %[[P4:[0-9a-zA-Z_.]+]] = bitcast i8* %[[P3]] to fp128*
+// IEEE: %{{[0-9a-zA-Z_.]+}} = load fp128, fp128* %[[P4]], align 16
 // IEEE: call void @llvm.va_end(i8* %{{[0-9a-zA-Z_.]+}})
 
 // IBM-LABEL: define ppc_fp128 @long_double(i32 signext %n, ...)
 // IBM: call void @llvm.va_start(i8* %{{[0-9a-zA-Z_.]+}})
-// IBM: %[[P4:[0-9a-zA-Z_.]+]] = bitcast i8* %{{[0-9a-zA-Z_.]+}} to ppc_fp128*
-// IBM: %{{[0-9a-zA-Z_.]+}} = load ppc_fp128, ppc_fp128* %[[P4]], align 8
+// IBM: %[[P1:[0-9a-zA-Z_.]+]] = add i64 %{{[0-9a-zA-Z_.]+}}, 15
+// IBM: %[[P2:[0-9a-zA-Z_.]+]] = and i64 %[[P1]], -16
+// IBM: %[[P3:[0-9a-zA-Z_.]+]] = inttoptr i64 %[[P2]] to i8*
+// IBM: %[[P4:[0-9a-zA-Z_.]+]] = bitcast i8* %[[P3]] to ppc_fp128*
+// IBM: %{{[0-9a-zA-Z_.]+}} = load ppc_fp128, ppc_fp128* %[[P4]], align 16
 // IBM: call void @llvm.va_end(i8* %{{[0-9a-zA-Z_.]+}})
 long double long_double(int n, ...) {
   va_list ap;
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -5049,7 +5049,10 @@
   return CharUnits::fromQuantity(32);
 
 return CharUnits::fromQuantity(16);
-  } else if (Ty->isVectorType()) {
+  } else if (Ty->isVectorType() || Ty->isRealFloatingType()) {
+// IEEE 128-bit floating numbers are also stored in vector registers.
+// And both IEEE quad-precision and IBM extended double (ppc_fp128) should
+// be quad-word aligned.
 return CharUnits::fromQuantity(getContext().getTypeSize(Ty) == 128 ? 16 : 
8);
   }
 


Index: clang/test/CodeGen/ppc64le-varargs-f128.c
===
--- clang/test/CodeGen/ppc64le-varargs-f128.c
+++ clang/test/CodeGen/ppc64le-varargs-f128.c
@@ -9,8 +9,11 @@
 
 // IEEE-LABEL: define fp128 @f128(i32 signext %n, ...)
 // IEEE: call void @llvm.va_start(i8* %{{[0-9a-zA-Z_.]+}})
-// IEEE: %[[P4:[0-9a-zA-Z_.]+]] = bitcast i8* %{{[0-9a-zA-Z_.]+}} to fp128*
-// IEEE: %{{[0-9a-zA-Z_.]+}} = load fp128, fp128* %[[P4]], align 8
+// IEEE: %[[P1:[0-9a-zA-Z_.]+]] = add i64 %{{[0-9a-zA-Z_.]+}}, 15
+// IEEE: %[[P2:[0-9a-zA-Z_.]+]] = and i64 %[[P1]], -16
+// IEEE: %[[P3:[0-9a-zA-Z_.]+]] = inttoptr i64 %[[P2]] to i8*
+// IEEE: %[[P4:[0-9a-zA-Z_.]+]] = bitcast i8* %[[P3]] to fp128*
+// IEEE: %{{[0-9a-zA-Z_.]+}} = load fp128, fp128* %[[P4]], align 16
 // IEEE: call void @llvm.va_end(i8* %{{[0-9a-zA-Z_.]+}})
 __float128 f128(int n, ...) {
   va_list ap;
@@ -22,14 +25,20 @@
 
 // IEEE-LABEL: define fp128 @long_double(i32 signext %n, ...)
 // IEEE: call void @llvm.va_start(i8* %{{[0-9a-zA-Z_.]+}})
-// IEEE: %[[P4:[0-9a-zA-Z_.]+]] = bitcast i8* %{{[0-9a-zA-Z_.]+}} to fp128*
-// IEEE: %{{[0-9a-zA-Z_.]+}} = load fp128, fp128* %[[P4]], align 8
+// IEEE: %[[P1:[0-9a-zA-Z_.]+]] = add i64 %{{

[clang-tools-extra] 218500d - [clang-tidy] Verify the fixes in abseil-redundant-strcat-calls test, NFC

2020-11-17 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-11-17T10:15:29+01:00
New Revision: 218500d823c8f0f43fb9c0d8e2ed5d4dd197785b

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

LOG: [clang-tidy] Verify the fixes in abseil-redundant-strcat-calls test, NFC

Added: 


Modified: 
clang-tools-extra/test/clang-tidy/checkers/abseil-redundant-strcat-calls.cpp

Removed: 




diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/abseil-redundant-strcat-calls.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/abseil-redundant-strcat-calls.cpp
index 2d7237971439..3afbac505cf1 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/abseil-redundant-strcat-calls.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/abseil-redundant-strcat-calls.cpp
@@ -154,9 +154,11 @@ using absl::StrCat;
 void Positives() {
   string S = StrCat(1, StrCat("A", StrCat(1.1)));
   // CHECK-MESSAGES: [[@LINE-1]]:14: warning: multiple calls to 'absl::StrCat' 
can be flattened into a single call
+  // CHECK-FIXES: string S = StrCat(1, "A", 1.1);
 
   S = StrCat(StrCat(StrCat(StrCat(StrCat(1);
   // CHECK-MESSAGES: [[@LINE-1]]:7: warning: multiple calls to 'absl::StrCat' 
can be flattened into a single call
+  // CHECK-FIXES: S = StrCat(1);
 
   // TODO: should trigger. The issue here is that in the current
   // implementation we ignore any StrCat with StrCat ancestors. Therefore
@@ -166,9 +168,11 @@ void Positives() {
 
   StrAppend(&S, 001, StrCat(1, 2, "3"), StrCat("FOO"));
   // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple calls to 'absl::StrCat' 
can be flattened into a single call
+  // CHECK-FIXES: StrAppend(&S, 001, 1, 2, "3", "FOO");
 
   StrAppend(&S, 001, StrCat(StrCat(1, 2), "3"), StrCat("FOO"));
   // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple calls to 'absl::StrCat' 
can be flattened into a single call
+  // CHECK-FIXES: StrAppend(&S, 001, 1, 2, "3", "FOO");
 
   // Too many args. Ignore for now.
   S = StrCat(1, 2, StrCat(3, 4, 5, 6, 7), 8, 9, 10,
@@ -177,6 +181,7 @@ void Positives() {
   // CHECK-MESSAGES: :[[@LINE-3]]:7: warning: multiple calls to 'absl::StrCat' 
can be flattened into a single call
   StrAppend(&S, StrCat(1, 2, 3, 4, 5), StrCat(6, 7, 8, 9, 10));
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: multiple calls to 'absl::StrCat' 
can be flattened into a single call
+  // CHECK-FIXES: StrAppend(&S, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
 }
 
 void Negatives() {



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


[PATCH] D91596: [PowerPC] [Clang] Fix alignment of 128-bit floating types

2020-11-17 Thread Qiu Chaofan via Phabricator via cfe-commits
qiucf updated this revision to Diff 305692.
qiucf added a comment.

Use another branch


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

https://reviews.llvm.org/D91596

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/ppc64le-varargs-f128.c


Index: clang/test/CodeGen/ppc64le-varargs-f128.c
===
--- clang/test/CodeGen/ppc64le-varargs-f128.c
+++ clang/test/CodeGen/ppc64le-varargs-f128.c
@@ -9,8 +9,11 @@
 
 // IEEE-LABEL: define fp128 @f128(i32 signext %n, ...)
 // IEEE: call void @llvm.va_start(i8* %{{[0-9a-zA-Z_.]+}})
-// IEEE: %[[P4:[0-9a-zA-Z_.]+]] = bitcast i8* %{{[0-9a-zA-Z_.]+}} to fp128*
-// IEEE: %{{[0-9a-zA-Z_.]+}} = load fp128, fp128* %[[P4]], align 8
+// IEEE: %[[P1:[0-9a-zA-Z_.]+]] = add i64 %{{[0-9a-zA-Z_.]+}}, 15
+// IEEE: %[[P2:[0-9a-zA-Z_.]+]] = and i64 %[[P1]], -16
+// IEEE: %[[P3:[0-9a-zA-Z_.]+]] = inttoptr i64 %[[P2]] to i8*
+// IEEE: %[[P4:[0-9a-zA-Z_.]+]] = bitcast i8* %[[P3]] to fp128*
+// IEEE: %{{[0-9a-zA-Z_.]+}} = load fp128, fp128* %[[P4]], align 16
 // IEEE: call void @llvm.va_end(i8* %{{[0-9a-zA-Z_.]+}})
 __float128 f128(int n, ...) {
   va_list ap;
@@ -22,14 +25,20 @@
 
 // IEEE-LABEL: define fp128 @long_double(i32 signext %n, ...)
 // IEEE: call void @llvm.va_start(i8* %{{[0-9a-zA-Z_.]+}})
-// IEEE: %[[P4:[0-9a-zA-Z_.]+]] = bitcast i8* %{{[0-9a-zA-Z_.]+}} to fp128*
-// IEEE: %{{[0-9a-zA-Z_.]+}} = load fp128, fp128* %[[P4]], align 8
+// IEEE: %[[P1:[0-9a-zA-Z_.]+]] = add i64 %{{[0-9a-zA-Z_.]+}}, 15
+// IEEE: %[[P2:[0-9a-zA-Z_.]+]] = and i64 %[[P1]], -16
+// IEEE: %[[P3:[0-9a-zA-Z_.]+]] = inttoptr i64 %[[P2]] to i8*
+// IEEE: %[[P4:[0-9a-zA-Z_.]+]] = bitcast i8* %[[P3]] to fp128*
+// IEEE: %{{[0-9a-zA-Z_.]+}} = load fp128, fp128* %[[P4]], align 16
 // IEEE: call void @llvm.va_end(i8* %{{[0-9a-zA-Z_.]+}})
 
 // IBM-LABEL: define ppc_fp128 @long_double(i32 signext %n, ...)
 // IBM: call void @llvm.va_start(i8* %{{[0-9a-zA-Z_.]+}})
-// IBM: %[[P4:[0-9a-zA-Z_.]+]] = bitcast i8* %{{[0-9a-zA-Z_.]+}} to ppc_fp128*
-// IBM: %{{[0-9a-zA-Z_.]+}} = load ppc_fp128, ppc_fp128* %[[P4]], align 8
+// IBM: %[[P1:[0-9a-zA-Z_.]+]] = add i64 %{{[0-9a-zA-Z_.]+}}, 15
+// IBM: %[[P2:[0-9a-zA-Z_.]+]] = and i64 %[[P1]], -16
+// IBM: %[[P3:[0-9a-zA-Z_.]+]] = inttoptr i64 %[[P2]] to i8*
+// IBM: %[[P4:[0-9a-zA-Z_.]+]] = bitcast i8* %[[P3]] to ppc_fp128*
+// IBM: %{{[0-9a-zA-Z_.]+}} = load ppc_fp128, ppc_fp128* %[[P4]], align 16
 // IBM: call void @llvm.va_end(i8* %{{[0-9a-zA-Z_.]+}})
 long double long_double(int n, ...) {
   va_list ap;
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -5051,6 +5051,11 @@
 return CharUnits::fromQuantity(16);
   } else if (Ty->isVectorType()) {
 return CharUnits::fromQuantity(getContext().getTypeSize(Ty) == 128 ? 16 : 
8);
+  } else if (Ty->isRealFloatingType() && getContext().getTypeSize(Ty) == 128) {
+// IEEE 128-bit floating numbers are also stored in vector registers.
+// And both IEEE quad-precision and IBM extended double (ppc_fp128) should
+// be quad-word aligned.
+return CharUnits::fromQuantity(16);
   }
 
   // For single-element float/vector structs, we consider the whole type


Index: clang/test/CodeGen/ppc64le-varargs-f128.c
===
--- clang/test/CodeGen/ppc64le-varargs-f128.c
+++ clang/test/CodeGen/ppc64le-varargs-f128.c
@@ -9,8 +9,11 @@
 
 // IEEE-LABEL: define fp128 @f128(i32 signext %n, ...)
 // IEEE: call void @llvm.va_start(i8* %{{[0-9a-zA-Z_.]+}})
-// IEEE: %[[P4:[0-9a-zA-Z_.]+]] = bitcast i8* %{{[0-9a-zA-Z_.]+}} to fp128*
-// IEEE: %{{[0-9a-zA-Z_.]+}} = load fp128, fp128* %[[P4]], align 8
+// IEEE: %[[P1:[0-9a-zA-Z_.]+]] = add i64 %{{[0-9a-zA-Z_.]+}}, 15
+// IEEE: %[[P2:[0-9a-zA-Z_.]+]] = and i64 %[[P1]], -16
+// IEEE: %[[P3:[0-9a-zA-Z_.]+]] = inttoptr i64 %[[P2]] to i8*
+// IEEE: %[[P4:[0-9a-zA-Z_.]+]] = bitcast i8* %[[P3]] to fp128*
+// IEEE: %{{[0-9a-zA-Z_.]+}} = load fp128, fp128* %[[P4]], align 16
 // IEEE: call void @llvm.va_end(i8* %{{[0-9a-zA-Z_.]+}})
 __float128 f128(int n, ...) {
   va_list ap;
@@ -22,14 +25,20 @@
 
 // IEEE-LABEL: define fp128 @long_double(i32 signext %n, ...)
 // IEEE: call void @llvm.va_start(i8* %{{[0-9a-zA-Z_.]+}})
-// IEEE: %[[P4:[0-9a-zA-Z_.]+]] = bitcast i8* %{{[0-9a-zA-Z_.]+}} to fp128*
-// IEEE: %{{[0-9a-zA-Z_.]+}} = load fp128, fp128* %[[P4]], align 8
+// IEEE: %[[P1:[0-9a-zA-Z_.]+]] = add i64 %{{[0-9a-zA-Z_.]+}}, 15
+// IEEE: %[[P2:[0-9a-zA-Z_.]+]] = and i64 %[[P1]], -16
+// IEEE: %[[P3:[0-9a-zA-Z_.]+]] = inttoptr i64 %[[P2]] to i8*
+// IEEE: %[[P4:[0-9a-zA-Z_.]+]] = bitcast i8* %[[P3]] to fp128*
+// IEEE: %{{[0-9a-zA-Z_.]+}} = load fp128, fp128* %[[P4]], align 16
 // IEEE: call void @llvm.va_end(i8* %{{[0-9a-zA-Z_.]+}})
 
 // IBM-LABEL: define ppc_fp128 @long_double(i32 signext %n, ...)
 // IBM: call voi

[PATCH] D90750: [clangd] Introduce ProjectAwareIndex

2020-11-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 305695.
kadircet marked 5 inline comments as done.
kadircet added a comment.

- Address comments
- Only query the associated index
- Use ExternalIndexSpec as the cache key


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90750

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/Config.h
  clang-tools-extra/clangd/index/ProjectAware.cpp
  clang-tools-extra/clangd/index/ProjectAware.h
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/ProjectAwareIndexTests.cpp

Index: clang-tools-extra/clangd/unittests/ProjectAwareIndexTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/ProjectAwareIndexTests.cpp
@@ -0,0 +1,84 @@
+//===-- ProjectAwareIndexTests.cpp  ---*- C++ -*---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Config.h"
+#include "TestIndex.h"
+#include "index/Index.h"
+#include "index/MemIndex.h"
+#include "index/ProjectAware.h"
+#include "index/Ref.h"
+#include "index/Relation.h"
+#include "support/Context.h"
+#include "support/Threading.h"
+#include "llvm/ADT/StringRef.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+using testing::ElementsAre;
+using testing::IsEmpty;
+
+std::unique_ptr createIndex() {
+  std::vector Symbols = {symbol("1")};
+  return std::make_unique(std::move(Symbols), RefSlab(),
+RelationSlab());
+}
+
+TEST(ProjectAware, Test) {
+  IndexGenerator Gen = [](const Config::ExternalIndexSpec &,
+  AsyncTaskRunner &) { return createIndex(); };
+
+  auto Idx = createProjectAwareIndex(std::move(Gen));
+  FuzzyFindRequest Req;
+  Req.Query = "1";
+  Req.AnyScope = true;
+
+  EXPECT_THAT(match(*Idx, Req), IsEmpty());
+
+  Config C;
+  C.Index.External.emplace();
+  WithContextValue With(Config::Key, std::move(C));
+  EXPECT_THAT(match(*Idx, Req), ElementsAre("1"));
+  return;
+}
+
+TEST(ProjectAware, CreatedOnce) {
+  unsigned InvocationCount = 0;
+  IndexGenerator Gen = [&InvocationCount](const Config::ExternalIndexSpec &,
+  AsyncTaskRunner &) {
+++InvocationCount;
+return createIndex();
+  };
+
+  auto Idx = createProjectAwareIndex(std::move(Gen));
+  // No invocation at start.
+  EXPECT_EQ(InvocationCount, 0U);
+  FuzzyFindRequest Req;
+  Req.Query = "1";
+  Req.AnyScope = true;
+
+  // Cannot invoke without proper config.
+  match(*Idx, Req);
+  EXPECT_EQ(InvocationCount, 0U);
+
+  Config C;
+  C.Index.External.emplace();
+  WithContextValue With(Config::Key, std::move(C));
+  match(*Idx, Req);
+  // Now it should be created.
+  EXPECT_EQ(InvocationCount, 1U);
+  match(*Idx, Req);
+  // It is cached afterwards.
+  EXPECT_EQ(InvocationCount, 1U);
+  return;
+}
+} // namespace clangd
+} // namespace clang
Index: clang-tools-extra/clangd/unittests/CMakeLists.txt
===
--- clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -73,6 +73,7 @@
   PathMappingTests.cpp
   PreambleTests.cpp
   PrintASTTests.cpp
+  ProjectAwareIndexTests.cpp
   QualityTests.cpp
   RenameTests.cpp
   RIFFTests.cpp
Index: clang-tools-extra/clangd/index/ProjectAware.h
===
--- /dev/null
+++ clang-tools-extra/clangd/index/ProjectAware.h
@@ -0,0 +1,30 @@
+//===--- ProjectAware.h --*- 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
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_PROJECT_AWARE_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_PROJECT_AWARE_H
+
+#include "Config.h"
+#include "index/Index.h"
+#include "support/Threading.h"
+#include 
+#include 
+namespace clang {
+namespace clangd {
+
+/// A functor to create an index for an external index specification.
+using IndexGenerator = std::function(
+const Config::ExternalIndexSpec &, AsyncTaskRunner &)>;
+
+/// Returns an index that answers queries using external indices. IndexGenerator
+/// can be used to customize how to generate an index from an external source.
+std::unique_ptr createProjectAwareIndex(IndexGenerator = nullptr);
+} // namespace clangd
+} // namespace clang
+

[PATCH] D90750: [clangd] Introduce ProjectAwareIndex

2020-11-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/index/ProjectAware.cpp:100
+  });
+  addIndex(std::move(NewIndex));
+  return PlaceHolder;

sammccall wrote:
> from memoize:
> 
> > Concurrent calls for the same key may run the
> > computation multiple times, but each call will return the same result.
> 
> so this side-effect may run multiple times too, resulting in multiple index 
> copies getting leaked. This seems like it may be bad in the case of file 
> indexes.
> 
> Why can't the memoize map own the indexes?
> This would still result in loading the index multiple times and throwing 
> things away, hmm. Not sure how best to resolve this.
> so this side-effect may run multiple times too, resulting in multiple index 
> copies getting leaked. This seems like it may be bad in the case of file 
> indexes.

The only way i can see this happening is by synchronizing calls to `getIndex`.

> Why can't the memoize map own the indexes?

Main problem is, it returns a copy to the stored elements, rather than a 
reference to them. Which might be necessary in general to guarantee 
thread-safety. Since we can't copy unique_ptrs, I had to store them elsewhere 
and only keep pointers to it within the memoize map.


So both things considered, maybe we should just give up on memoize and have our 
own thread-safe cache here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90750

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


[PATCH] D91601: [clang-tidy] Fix an abseil-redundant-strcat-calls crash on 0-parameter StrCat().

2020-11-17 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: gribozavr2.
Herald added a subscriber: xazax.hun.
Herald added a project: clang.
hokein requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91601

Files:
  clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/abseil-redundant-strcat-calls.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/abseil-redundant-strcat-calls.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/abseil-redundant-strcat-calls.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/abseil-redundant-strcat-calls.cpp
@@ -121,6 +121,7 @@
   AlphaNum &operator=(const AlphaNum &);
 };
 
+string StrCat();
 string StrCat(const AlphaNum &A);
 string StrCat(const AlphaNum &A, const AlphaNum &B);
 string StrCat(const AlphaNum &A, const AlphaNum &B, const AlphaNum &C);
@@ -182,6 +183,9 @@
   StrAppend(&S, StrCat(1, 2, 3, 4, 5), StrCat(6, 7, 8, 9, 10));
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: multiple calls to 'absl::StrCat' 
can be flattened into a single call
   // CHECK-FIXES: StrAppend(&S, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
+
+  StrCat(1, StrCat());
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: multiple calls to 'absl::StrCat' 
can be flattened into a single call
 }
 
 void Negatives() {
Index: clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp
===
--- clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp
+++ clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp
@@ -47,6 +47,8 @@
 };
 
 void RemoveCallLeaveArgs(const CallExpr* Call, StrCatCheckResult* CheckResult) 
{
+  if (Call->getNumArgs() == 0)
+return;
   // Remove 'Foo('
   CheckResult->Hints.push_back(
   FixItHint::CreateRemoval(CharSourceRange::getCharRange(


Index: clang-tools-extra/test/clang-tidy/checkers/abseil-redundant-strcat-calls.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/abseil-redundant-strcat-calls.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/abseil-redundant-strcat-calls.cpp
@@ -121,6 +121,7 @@
   AlphaNum &operator=(const AlphaNum &);
 };
 
+string StrCat();
 string StrCat(const AlphaNum &A);
 string StrCat(const AlphaNum &A, const AlphaNum &B);
 string StrCat(const AlphaNum &A, const AlphaNum &B, const AlphaNum &C);
@@ -182,6 +183,9 @@
   StrAppend(&S, StrCat(1, 2, 3, 4, 5), StrCat(6, 7, 8, 9, 10));
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: multiple calls to 'absl::StrCat' can be flattened into a single call
   // CHECK-FIXES: StrAppend(&S, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
+
+  StrCat(1, StrCat());
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: multiple calls to 'absl::StrCat' can be flattened into a single call
 }
 
 void Negatives() {
Index: clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp
===
--- clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp
+++ clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp
@@ -47,6 +47,8 @@
 };
 
 void RemoveCallLeaveArgs(const CallExpr* Call, StrCatCheckResult* CheckResult) {
+  if (Call->getNumArgs() == 0)
+return;
   // Remove 'Foo('
   CheckResult->Hints.push_back(
   FixItHint::CreateRemoval(CharSourceRange::getCharRange(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91602: [clang-tidy] Make clang-format and include-order-check coherent

2020-11-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: hokein.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.
kadircet requested review of this revision.

LLVM style puts both gtest and gmock to the end of the include list.
But llvm-include-order-check was only moving gtest headers to the end, resulting
in a false tidy-warning.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91602

Files:
  clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp
@@ -3,6 +3,7 @@
 // CHECK-MESSAGES: [[@LINE+2]]:1: warning: #includes are not sorted properly
 #include "j.h"
 #include "gtest/foo.h"
+#include "gmock/foo.h"
 #include "i.h"
 #include 
 #include "llvm/a.h"
@@ -16,6 +17,7 @@
 // CHECK-FIXES-NEXT: #include "clang/b.h"
 // CHECK-FIXES-NEXT: #include "llvm-c/d.h" // -c
 // CHECK-FIXES-NEXT: #include "llvm/a.h"
+// CHECK-FIXES-NEXT: #include "gmock/foo.h"
 // CHECK-FIXES-NEXT: #include "gtest/foo.h"
 // CHECK-FIXES-NEXT: #include 
 
Index: clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
===
--- clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
+++ clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
@@ -67,7 +67,8 @@
 return 2;
 
   // System headers are sorted to the end.
-  if (IsAngled || Filename.startswith("gtest/"))
+  if (IsAngled || Filename.startswith("gtest/") ||
+  Filename.startswith("gmock/"))
 return 3;
 
   // Other headers are inserted between the main module header and LLVM 
headers.


Index: clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp
@@ -3,6 +3,7 @@
 // CHECK-MESSAGES: [[@LINE+2]]:1: warning: #includes are not sorted properly
 #include "j.h"
 #include "gtest/foo.h"
+#include "gmock/foo.h"
 #include "i.h"
 #include 
 #include "llvm/a.h"
@@ -16,6 +17,7 @@
 // CHECK-FIXES-NEXT: #include "clang/b.h"
 // CHECK-FIXES-NEXT: #include "llvm-c/d.h" // -c
 // CHECK-FIXES-NEXT: #include "llvm/a.h"
+// CHECK-FIXES-NEXT: #include "gmock/foo.h"
 // CHECK-FIXES-NEXT: #include "gtest/foo.h"
 // CHECK-FIXES-NEXT: #include 
 
Index: clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
===
--- clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
+++ clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
@@ -67,7 +67,8 @@
 return 2;
 
   // System headers are sorted to the end.
-  if (IsAngled || Filename.startswith("gtest/"))
+  if (IsAngled || Filename.startswith("gtest/") ||
+  Filename.startswith("gmock/"))
 return 3;
 
   // Other headers are inserted between the main module header and LLVM headers.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D89296: [clangd] Call hierarchy (Protocol layer)

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

thanks, LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89296

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


[PATCH] D91601: [clang-tidy] Fix an abseil-redundant-strcat-calls crash on 0-parameter StrCat().

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



Comment at: clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp:51
+  if (Call->getNumArgs() == 0)
+return;
   // Remove 'Foo('

Remove the whole call instead of returning?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91601

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


[PATCH] D91602: [clang-tidy] Make clang-format and include-order-check coherent

2020-11-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 305707.
kadircet added a comment.

- Add gmock header


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91602

Files:
  clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/gmock/foo.h
  clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp
@@ -3,6 +3,7 @@
 // CHECK-MESSAGES: [[@LINE+2]]:1: warning: #includes are not sorted properly
 #include "j.h"
 #include "gtest/foo.h"
+#include "gmock/foo.h"
 #include "i.h"
 #include 
 #include "llvm/a.h"
@@ -16,6 +17,7 @@
 // CHECK-FIXES-NEXT: #include "clang/b.h"
 // CHECK-FIXES-NEXT: #include "llvm-c/d.h" // -c
 // CHECK-FIXES-NEXT: #include "llvm/a.h"
+// CHECK-FIXES-NEXT: #include "gmock/foo.h"
 // CHECK-FIXES-NEXT: #include "gtest/foo.h"
 // CHECK-FIXES-NEXT: #include 
 
Index: clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
===
--- clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
+++ clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
@@ -67,7 +67,8 @@
 return 2;
 
   // System headers are sorted to the end.
-  if (IsAngled || Filename.startswith("gtest/"))
+  if (IsAngled || Filename.startswith("gtest/") ||
+  Filename.startswith("gmock/"))
 return 3;
 
   // Other headers are inserted between the main module header and LLVM 
headers.


Index: clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp
@@ -3,6 +3,7 @@
 // CHECK-MESSAGES: [[@LINE+2]]:1: warning: #includes are not sorted properly
 #include "j.h"
 #include "gtest/foo.h"
+#include "gmock/foo.h"
 #include "i.h"
 #include 
 #include "llvm/a.h"
@@ -16,6 +17,7 @@
 // CHECK-FIXES-NEXT: #include "clang/b.h"
 // CHECK-FIXES-NEXT: #include "llvm-c/d.h" // -c
 // CHECK-FIXES-NEXT: #include "llvm/a.h"
+// CHECK-FIXES-NEXT: #include "gmock/foo.h"
 // CHECK-FIXES-NEXT: #include "gtest/foo.h"
 // CHECK-FIXES-NEXT: #include 
 
Index: clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
===
--- clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
+++ clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
@@ -67,7 +67,8 @@
 return 2;
 
   // System headers are sorted to the end.
-  if (IsAngled || Filename.startswith("gtest/"))
+  if (IsAngled || Filename.startswith("gtest/") ||
+  Filename.startswith("gmock/"))
 return 3;
 
   // Other headers are inserted between the main module header and LLVM headers.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D90851: [clang-tidy] Extending bugprone-signal-handler with POSIX functions.

2020-11-17 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/system-header-posix-api.h:1
-//===--- signal.h - Stub header for tests ---*- C++ 
-*-===//
+//===--- system-header-posix-api.h - Stub header for tests --*- C++ 
-*-===//
 //

aaron.ballman wrote:
> balazske wrote:
> > aaron.ballman wrote:
> > > I think we should strive to replicate the system headers rather than fake 
> > > up a system header (these headers can be used by more than one check). So 
> > > I think we want to keep signal.h and stdlib.h, and should include the 
> > > POSIX-specific functionality with a macro. This also helps us test the 
> > > behavior on systems like Windows which are not POSIX systems.
> > My concern was to add these many small header files with just some 
> > functions in them. For `accept` more than one header is needed if we want 
> > to exactly replicate the system files. And data types like `size_t` should 
> > have a common header too. So I decided to have one header that contains all 
> > system functions and data types. This can be used by multiple tests and 
> > extended as needed.
> I don't think we're too worried about having a bunch of small test headers 
> around -- I think it's more important the headers used to check system header 
> behavior be understandable as to what you're getting from them. For instance, 
> there are clang-tidy checks for llvm-libc that may have very different needs 
> from what you're doing here.
> 
> What's more, these changes break existing tests -- I don't see any companion 
> changes to fix those up.
On my system (Ubuntu) I do not see failing tests, and these changes do not 
touch files that were created before D87449, no new problems should happen. I 
am not against "mirroring" the POSIX API header structure into the test stub 
header structure, only do not like the overhead of adding these many files with 
just 1-2 lines (that is needed for this test) in them. It is not done this way 
in the clang tests either (there are multiple "system-header-simulator" files 
that contain every declaration usable for specific purposes at one or more 
tests). Also I want to have the opinion of another reviewer for this question.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90851

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


[PATCH] D91601: [clang-tidy] Fix an abseil-redundant-strcat-calls crash on 0-parameter StrCat().

2020-11-17 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaf0d607e7275: [clang-tidy] Fix an 
abseil-redundant-strcat-calls crash on 0-parameter StrCat(). (authored by 
hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91601

Files:
  clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/abseil-redundant-strcat-calls.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/abseil-redundant-strcat-calls.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/abseil-redundant-strcat-calls.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/abseil-redundant-strcat-calls.cpp
@@ -121,6 +121,7 @@
   AlphaNum &operator=(const AlphaNum &);
 };
 
+string StrCat();
 string StrCat(const AlphaNum &A);
 string StrCat(const AlphaNum &A, const AlphaNum &B);
 string StrCat(const AlphaNum &A, const AlphaNum &B, const AlphaNum &C);
@@ -182,6 +183,9 @@
   StrAppend(&S, StrCat(1, 2, 3, 4, 5), StrCat(6, 7, 8, 9, 10));
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: multiple calls to 'absl::StrCat' 
can be flattened into a single call
   // CHECK-FIXES: StrAppend(&S, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
+
+  StrCat(1, StrCat());
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: multiple calls to 'absl::StrCat' 
can be flattened into a single call
 }
 
 void Negatives() {
Index: clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp
===
--- clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp
+++ clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp
@@ -47,6 +47,8 @@
 };
 
 void RemoveCallLeaveArgs(const CallExpr* Call, StrCatCheckResult* CheckResult) 
{
+  if (Call->getNumArgs() == 0)
+return;
   // Remove 'Foo('
   CheckResult->Hints.push_back(
   FixItHint::CreateRemoval(CharSourceRange::getCharRange(


Index: clang-tools-extra/test/clang-tidy/checkers/abseil-redundant-strcat-calls.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/abseil-redundant-strcat-calls.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/abseil-redundant-strcat-calls.cpp
@@ -121,6 +121,7 @@
   AlphaNum &operator=(const AlphaNum &);
 };
 
+string StrCat();
 string StrCat(const AlphaNum &A);
 string StrCat(const AlphaNum &A, const AlphaNum &B);
 string StrCat(const AlphaNum &A, const AlphaNum &B, const AlphaNum &C);
@@ -182,6 +183,9 @@
   StrAppend(&S, StrCat(1, 2, 3, 4, 5), StrCat(6, 7, 8, 9, 10));
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: multiple calls to 'absl::StrCat' can be flattened into a single call
   // CHECK-FIXES: StrAppend(&S, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
+
+  StrCat(1, StrCat());
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: multiple calls to 'absl::StrCat' can be flattened into a single call
 }
 
 void Negatives() {
Index: clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp
===
--- clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp
+++ clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp
@@ -47,6 +47,8 @@
 };
 
 void RemoveCallLeaveArgs(const CallExpr* Call, StrCatCheckResult* CheckResult) {
+  if (Call->getNumArgs() == 0)
+return;
   // Remove 'Foo('
   CheckResult->Hints.push_back(
   FixItHint::CreateRemoval(CharSourceRange::getCharRange(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] af0d607 - [clang-tidy] Fix an abseil-redundant-strcat-calls crash on 0-parameter StrCat().

2020-11-17 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-11-17T11:05:24+01:00
New Revision: af0d607e727512775e8dbec1baf7bfa15c7ecb48

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

LOG: [clang-tidy] Fix an abseil-redundant-strcat-calls crash on 0-parameter 
StrCat().

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp
clang-tools-extra/test/clang-tidy/checkers/abseil-redundant-strcat-calls.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp 
b/clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp
index e7d037743f678..be3fa9a5628b4 100644
--- a/clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp
@@ -47,6 +47,8 @@ struct StrCatCheckResult {
 };
 
 void RemoveCallLeaveArgs(const CallExpr* Call, StrCatCheckResult* CheckResult) 
{
+  if (Call->getNumArgs() == 0)
+return;
   // Remove 'Foo('
   CheckResult->Hints.push_back(
   FixItHint::CreateRemoval(CharSourceRange::getCharRange(

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/abseil-redundant-strcat-calls.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/abseil-redundant-strcat-calls.cpp
index 3afbac505cf19..dad8ef857e2a1 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/abseil-redundant-strcat-calls.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/abseil-redundant-strcat-calls.cpp
@@ -121,6 +121,7 @@ struct AlphaNum {
   AlphaNum &operator=(const AlphaNum &);
 };
 
+string StrCat();
 string StrCat(const AlphaNum &A);
 string StrCat(const AlphaNum &A, const AlphaNum &B);
 string StrCat(const AlphaNum &A, const AlphaNum &B, const AlphaNum &C);
@@ -182,6 +183,9 @@ void Positives() {
   StrAppend(&S, StrCat(1, 2, 3, 4, 5), StrCat(6, 7, 8, 9, 10));
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: multiple calls to 'absl::StrCat' 
can be flattened into a single call
   // CHECK-FIXES: StrAppend(&S, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
+
+  StrCat(1, StrCat());
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: multiple calls to 'absl::StrCat' 
can be flattened into a single call
 }
 
 void Negatives() {



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


[PATCH] D91605: [sanitizers] Implement GetTls on Solaris

2020-11-17 Thread Rainer Orth via Phabricator via cfe-commits
ro created this revision.
ro added reviewers: vitalybuka, MaskRay.
ro added a project: Sanitizers.
Herald added subscribers: Sanitizers, pengfei, fedor.sergeev, mgorny, jyknight.
Herald added a project: clang.
ro requested review of this revision.

In the initial Solaris ASan port, `GetTls` was left unimplemented.  This patch 
corrects that.  There are a couple of caveats, unfortunately:

While current Solaris 11.4 supports the `dlpi_tls_modid` field of `struct 
dl_phdr_info`, this was only added in SRU 10 and isn't present in either 
Solaris 11.3 or Illumos.  Instead, this uses a method used in GCC's D runtime 
library libphobos dlpi_tls_modid workaround 
 which works 
even on Solaris 10.

However, the direct call to `__tls_get_address` triggers a Solaris `ld` bug on 
amd64, which needs to be worked around the same way as in `libphobos`: ld 
workaround .

Together, they allow the `sanitizer_common` TLS tests to `PASS` on both sparc 
and x86.
I've also verified that the patch doesn't break the Illumos build; however 
`compiler-rt` test results continue to be horrible there.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91605

Files:
  clang/include/clang/Config/config.h.cmake
  clang/lib/Driver/ToolChains/Solaris.cpp
  clang/tools/driver/CMakeLists.txt
  compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp

Index: compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
===
--- compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
+++ compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
@@ -57,6 +57,7 @@
 #endif
 
 #if SANITIZER_SOLARIS
+#include 
 #include 
 #include 
 #endif
@@ -451,6 +452,73 @@
   void **);
 #endif
 
+#if SANITIZER_SOLARIS
+// dlpi_tls_modid is only available since Solaris 11.4 SRU 10.  Use
+// dlinfo(RTLD_DI_LINKMAP) instead which works on both Solaris 11.3 and Illumos.
+
+// Beginning of declaration from OpenSolaris/Illumos
+// $SRC/cmd/sgs/include/rtld.h.
+typedef struct {
+  Link_map rt_public;
+  const char *rt_pathname;
+  ulong_t rt_padstart;
+  ulong_t rt_padimlen;
+  ulong_t rt_msize;
+  uint_t rt_flags;
+  uint_t rt_flags1;
+  ulong_t rt_tlsmodid;
+} Rt_map;
+
+// Structure matching the Solaris 11.4 struct dl_phdr_info used to determine
+// presence of dlpi_tls_modid field at runtime.  Cf. Solaris 11.4
+// dl_iterate_phdr(3C), Example 2.
+typedef struct dl_phdr_info_test {
+  ElfW(Addr) dlpi_addr;
+  const char *dlpi_name;
+  const ElfW(Phdr) * dlpi_phdr;
+  ElfW(Half) dlpi_phnum;
+  u_longlong_t dlpi_adds;
+  u_longlong_t dlpi_subs;
+  size_t dlpi_tls_modid;
+  void *dlpi_tls_data;
+} dl_phdr_info_test;
+
+typedef struct {
+  unsigned long ti_moduleid;
+  unsigned long ti_tlsoffset;
+} TLS_index;
+
+extern "C" void *__tls_get_addr(TLS_index *);
+
+static size_t main_tls_modid;
+
+int GetSizeFromHdr(struct dl_phdr_info *info, size_t size, void *data) {
+  const ElfW(Phdr) *hdr = info->dlpi_phdr;
+  const ElfW(Phdr) *last_hdr = hdr + info->dlpi_phnum;
+
+  // With the introduction of dlpi_tls_modid, the tlsmodid of the executable
+  // was changed to 1 to match other implementations.
+  if (size >= offsetof(dl_phdr_info_test, dlpi_tls_modid))
+main_tls_modid = 1;
+  else
+main_tls_modid = 0;
+
+  for (; hdr != last_hdr; ++hdr) {
+if (hdr->p_type == PT_TLS) {
+  Rt_map *map;
+
+  dlinfo(RTLD_SELF, RTLD_DI_LINKMAP, &map);
+
+  if (map->rt_tlsmodid == main_tls_modid) {
+*(uptr *)data = hdr->p_memsz;
+return -1;
+  }
+}
+  }
+  return 0;
+}
+#endif  // SANITIZER_SOLARIS
+
 #if !SANITIZER_GO
 static void GetTls(uptr *addr, uptr *size) {
 #if SANITIZER_ANDROID
@@ -507,9 +575,15 @@
 }
   }
 #elif SANITIZER_SOLARIS
-  // FIXME
   *addr = 0;
   *size = 0;
+  // Find size (p_memsz) of TLS block of the main program.
+  dl_iterate_phdr(GetSizeFromHdr, size);
+
+  if (*size != 0) {
+TLS_index ti = {(unsigned long)main_tls_modid, 0};
+*addr = (uptr)__tls_get_addr(&ti);
+  }
 #else
 #error "Unknown OS"
 #endif
Index: clang/tools/driver/CMakeLists.txt
===
--- clang/tools/driver/CMakeLists.txt
+++ clang/tools/driver/CMakeLists.txt
@@ -91,9 +91,10 @@
   set(TOOL_INFO_BUILD_VERSION)
 endif()
 
+include(CheckLinkerFlag)
+
 if(CLANG_ORDER_FILE AND
-(LLVM_LINKER_IS_LD64 OR LLVM_LINKER_IS_GOLD OR LLVM_LINKER_IS_LLD))
-  include(CheckLinkerFlag)
+   (LLVM_LINKER_IS_LD64 OR LLVM_LINKER_IS_GOLD OR LLVM_LINKER_IS_LLD))
 
   if (LLVM_LINKER_IS_LD64)
 set(LINKER_ORDER_FILE_OPTION "-Wl,-order_file,${CLANG_ORDER_FILE}")
@@ -118,3 +119,5 @@
 set_target_properties(clang PROPERTIES LINK_DEPENDS ${CLANG_ORDER_FILE})
   endif()
 endif()
+
+check_linker_flag("-Wl,-z,relax=tran

[PATCH] D89869: [OpenCL] Define OpenCL feature macros for all versions

2020-11-17 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov added inline comments.



Comment at: clang/include/clang/Basic/OpenCLExtensions.def:100
+// OpenCL features
+OPENCLFEAT_INTERNAL(__opencl_c_pipes, 200, ~0U)
+OPENCLFEAT_INTERNAL(__opencl_c_generic_address_space, 200, ~0U)

Anastasia wrote:
> Btw I guess we don't need the last parameter for the features since it's 
> always 0?
This need to be restructured at all, now I just wanted to be consistent. I 
think there was wrong interpretation of "core extension" concept. //Core 
//means nothing more than it was just promoted to core specification, not 
supported by default starting from specific OpenCL version. Am I missing 
something in the spec? However, I'm not sure if we need to reimplement this to 
maintain backward compatibility... Anyway, I'll try to remove it from features.



Comment at: clang/include/clang/Basic/OpenCLExtensions.def:109
+OPENCLFEAT_INTERNAL(__opencl_c_program_scope_global_variables, 200, ~0U)
+OPENCLFEAT_INTERNAL(__opencl_c_fp64, 120, ~0U)
+OPENCLFEAT_INTERNAL(__opencl_c_images, 100, ~0U)

Anastasia wrote:
> I am thinking maybe we could add an extra parameter where we can specify the 
> extension it is aliased to:
> 
> ```
> OPENCLFEAT_INTERNAL(__opencl_c_fp64, 120, ~0U, cl_khr_fp64)
> ```
> 
> Then it makes clearer which features correspond to which extensions and you 
> can populate `EquivalentFeaturesExtensions` from this field? Moreover, you 
> can then even make a map of references to `OpenCLOptions::Info` so you don't 
> need to look them up from the name every time.
> 
> 
> The drawback is that we need an extra parameter that is mainly empty... 
> however we could recycle the last parameter that is always 0 right now.
> 
> OPENCLFEAT_INTERNAL(__opencl_c_fp64, 120, ~0U, cl_khr_fp64)
Yes, that's sound reasonable to me

> The drawback is that we need an extra parameter that is mainly empty
I don't think we need to keep it `OpenCLOptions::Info`, we can always this from 
`OpenCLOptions`. 



Comment at: clang/include/clang/Basic/OpenCLOptions.h:37
+  // OpenCL Version
+  unsigned CLVer = 120;
+  bool IsOpenCLCPlusPlus = false;

Anastasia wrote:
> Ok, I see why you are adding this field but I am not very happy with it. 
> However, if you prefer to keep it I suggest to add a comment otherwise it is 
> mislediang because ideally in Clang we should be using versions from the 
> LangOpts everywhere. Alternatively we could consider a helper function to 
> calculate the version although it doesn't eliminate the need to the comment.
> However, if you prefer to keep it I suggest to add a comment otherwise it is 
> mislediang because ideally in Clang we should be using versions from the 
> LangOpts everywhere

The reason for this is that `LangOptions` is not always available for proper 
settings. So this just needed internally. Also, we could add 
`TargetInfo::setOpenCLOptions(const LangOptions &Opts)` where we can set all 
extensions/features in one step (invoke `::setSupportedOpenCLOpts` and 
`::setOpenCLExtensionOpts`) to make sure `OpenCLOptions` will get proper OpenCL 
version. What do you think of that?



Comment at: clang/include/clang/Basic/OpenCLOptions.h:42
+
+  // Note that __opencl_c_subgroups and cl_khr_subgroups are not equivalent
+  // because extension requires sub-group independent forward progress

Anastasia wrote:
> I feel I missed that. Can you explain why it is not the same. Any spec 
> reference would be help.
Ah, yeah. This one is confusing.

You can check [[ 
https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_API.html#platform-querying-devices|
 4.2. Querying Devices ]], the CL_DEVICE_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS 
entry:

//This query must return CL_TRUE for devices that support the cl_khr_subgroups 
extension, and must return CL_FALSE for devices that do not support subgroup//.

It was missing before OpenCL C 2.1 and subgroup independent forward progress is 
optional in 2.1 and 3.0. Agree that spec is not clear here though. This is just 
the case when feature describes more functionality than the extension.



Comment at: clang/include/clang/Basic/OpenCLOptions.h:51
+  // check specific version of feature)
+  void supportFeatureForPreOCL30(StringRef Feat, bool On = true) {
+assert(CLVer < 300 && "Can'be called for OpenCL C higher 3.0");

Anastasia wrote:
> I find the name of this function very confusing but I can't think of any 
> better one. Also the flow is becoming harder to understand to be honest. This 
> function is not as straight forward as `support` because it might not 
> actually do what is expected from it. I wonder if the name with something 
> like `adjust` would be more appropriate. At the same time `adjustFeatures` is 
> the only place where we need to check for the version. Perhaps you can just 
> do the language version check straight in `adjustFeatu

[PATCH] D91122: [clangd] Call hierarchy (XRefs layer, incoming calls)

2020-11-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

mostly LG, i haven't looked at the tests yet though.




Comment at: clang-tools-extra/clangd/XRefs.cpp:1344
+  auto Result = declToHierarchyItem(ND);
+  if (Result) {
+Result->deprecated = ND.isDeprecated();

nit: redundant braces



Comment at: clang-tools-extra/clangd/XRefs.cpp:1353
+  auto Result = declToHierarchyItem(ND);
+  if (Result) {
+if (ND.isDeprecated())

nit: merge the two conditions and drop the braces.



Comment at: clang-tools-extra/clangd/XRefs.cpp:1361
+template 
+static Optional symbolToHierarchyItem(const Symbol &S,
+ PathRef TUPath) {

can you qualify `Optional` here and elsewhere?



Comment at: clang-tools-extra/clangd/XRefs.cpp:1381
 
-  return std::move(THI);
+  return std::move(HI);
+}

nit: drop `std::move`



Comment at: clang-tools-extra/clangd/XRefs.cpp:1387
+  auto Result = symbolToHierarchyItem(S, TUPath);
+  if (Result) {
+Result->deprecated = (S.Flags & Symbol::Deprecated);

nit: redundant braces



Comment at: clang-tools-extra/clangd/XRefs.cpp:1396
+  auto Result = symbolToHierarchyItem(S, TUPath);
+  if (Result) {
+if (S.Flags & Symbol::Deprecated) {

nit: again merge conditions and drop braces



Comment at: clang-tools-extra/clangd/XRefs.cpp:1620
+if (auto CHI = declToCallHierarchyItem(*Decl))
+  Result.push_back(*std::move(CHI));
+  }

`Results.emplace_back(std::move(*CHI))` ?



Comment at: clang-tools-extra/clangd/XRefs.cpp:1629
+return llvm::None;
+  Expected ID = SymbolID::fromStr(Item.data);
+  if (!ID) {

nit: `auto ID`



Comment at: clang-tools-extra/clangd/XRefs.cpp:1646
+  Request.Filter = RefKind::Reference;
+  // Initially store the results in a map keyed by SymbolID.
+  // This allows us to group different calls with the same caller

... by SymbolID of the caller.



Comment at: clang-tools-extra/clangd/XRefs.cpp:1649
+  // into the same CallHierarchyIncomingCall.
+  llvm::DenseMap ResultMap;
+  // We can populate the keys of ResultMap, and the FromRanges fields of

nit: `s/ResultMap/CallsIn` ?

I would also suggest changing value type to `SmallVector` that way 
rather than having a "partially filled" IncomingCall objects in the middle, you 
can create valid ones directly within the lookup.



Comment at: clang-tools-extra/clangd/XRefs.cpp:1660
+}
+auto It = ResultMap.find(R.Container);
+if (It == ResultMap.end())

nit: `auto It = ResultMap.try_emplace(R.Container, 
CallHierarchyIncomingCall{}).first`



Comment at: clang-tools-extra/clangd/XRefs.cpp:1671
+auto It = ResultMap.find(Caller.ID);
+if (It != ResultMap.end()) {
+  if (auto CHI = symbolToCallHierarchyItem(Caller, Item.uri.file()))

why don't we assert this instead?



Comment at: clang-tools-extra/clangd/XRefs.h:109
+/// Get call hierarchy information at \p Pos.
+llvm::Optional>
+prepareCallHierarchy(ParsedAST &AST, Position Pos, const SymbolIndex *Index,

nridge wrote:
> kadircet wrote:
> > what's the distinction between empty and none return values ? (same for 
> > others)
> Generally speaking, a `None` result means "the input was not recognized in 
> some way", while an empty vector result means "there are no results for this 
> input".
> 
> For `prepareCallHierarchy`, the inputs encode a source location, and the 
> operation asks "give me `CallHierarchyItem`s for suitable declarations (i.e. 
> functions) at this location. So, `None` means "the source location could not 
> be recognized" (`sourceLocationInMainFile` failed), while an empty result 
> means "there are no declarations of functions at this location".
> 
> For `incomingCalls` and `outgoingCalls`, the inputs encode a declaration of a 
> function, and the operation asks "give me its callers / callees". So, a 
> `None` means "could not locate the function (i.e. symbol)", while an empty 
> result means "this function has no callers / callees".
> Generally speaking, a None result means "the input was not recognized in some 
> way", while an empty vector result means "there are no results for this 
> input".

Makes sense, but that sounds like an implementation detail. I don't see any 
difference between the two from caller's point of view. Even the logging 
happens inside the implementation. As for interpreting llvm::None by the 
caller, i believe it is subject to change, so unless we return an Expected, 
there's not much value in returning an Optional, and even in such a case, 
caller probably can't do much but propagate the error (maybe also try with 
Pos+/-1, but usually that's handled within th

[PATCH] D91442: [clang][Driver] Handle risvc in Baremetal.cpp.

2020-11-17 Thread Sam Elliott via Phabricator via cfe-commits
lenary added a comment.

I'm worried about this change - I *think* it doesn't cover the existing 
behaviour of a baremetal GCC toolchain being installed into the same prefix as 
clang, and clang automatically picking up that baremetal gcc toolchain. What 
should we expect to do here? This is especially an issue if you're trying to 
make a relocatable toolchain tarball, where specifying `--gcc-toolchain` 
automatically is difficult.


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

https://reviews.llvm.org/D91442

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


[PATCH] D91607: [clang][Sparc] Fix __builtin_extract_return_addr etc.

2020-11-17 Thread Rainer Orth via Phabricator via cfe-commits
ro created this revision.
ro added reviewers: efriedma, brad.
Herald added subscribers: atanasyan, fedor.sergeev, kristof.beyls, arichardson, 
sdardis, jyknight.
Herald added a project: clang.
ro requested review of this revision.

While investigating the failures of `symbolize_pc.cpp` and 
`symbolize_pc_inline.cpp` on SPARC (both Solaris and Linux), I noticed that 
`__builtin_extract_return_addr` is a no-op in `clang` on all targets, while 
`gcc` has non-default implementations for arm, mips, s390, and sparc.

This patch provides the SPARC implementation.  For background see 
`SparcISelLowering.cpp` (`SparcTargetLowering::LowerReturn_32`) , the SPARC 
psABI p.3-12, `%i7` and p.3-16/17, and SCD 2.4.1, p.3P-10, `%i7` and p.3P-15.

Tested (after enabling the `sanitizer_common` tests on SPARC) on 
`sparcv9-sun-solaris2.11`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91607

Files:
  clang/lib/CodeGen/TargetInfo.cpp


Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -9221,6 +9221,32 @@
 public:
   SparcV8TargetCodeGenInfo(CodeGenTypes &CGT)
   : TargetCodeGenInfo(std::make_unique(CGT)) {}
+
+  llvm::Value *decodeReturnAddress(CodeGen::CodeGenFunction &CGF,
+   llvm::Value *Address) const override {
+llvm::Value *AddrAsInt = Address;
+AddrAsInt = CGF.Builder.CreatePtrToInt(AddrAsInt, CGF.IntPtrTy);
+AddrAsInt = CGF.Builder.CreateAdd(AddrAsInt,
+  llvm::ConstantInt::get(CGF.IntPtrTy, 8));
+if (isAggregateTypeForABI(CGF.CurFnInfo->getReturnType()))
+  AddrAsInt = CGF.Builder.CreateAdd(
+  AddrAsInt, llvm::ConstantInt::get(CGF.IntPtrTy, 4));
+AddrAsInt = CGF.Builder.CreateIntToPtr(AddrAsInt, Address->getType());
+return AddrAsInt;
+  }
+
+  llvm::Value *encodeReturnAddress(CodeGen::CodeGenFunction &CGF,
+   llvm::Value *Address) const override {
+llvm::Value *AddrAsInt = Address;
+AddrAsInt = CGF.Builder.CreatePtrToInt(AddrAsInt, CGF.IntPtrTy);
+AddrAsInt = CGF.Builder.CreateAdd(AddrAsInt,
+  llvm::ConstantInt::get(CGF.IntPtrTy, 
-8));
+if (isAggregateTypeForABI(CGF.CurFnInfo->getReturnType()))
+  AddrAsInt = CGF.Builder.CreateAdd(
+  AddrAsInt, llvm::ConstantInt::get(CGF.IntPtrTy, -4));
+AddrAsInt = CGF.Builder.CreateIntToPtr(AddrAsInt, Address->getType());
+return AddrAsInt;
+  }
 };
 } // end anonymous namespace
 
@@ -9495,6 +9521,26 @@
 
   bool initDwarfEHRegSizeTable(CodeGen::CodeGenFunction &CGF,
llvm::Value *Address) const override;
+
+  llvm::Value *decodeReturnAddress(CodeGen::CodeGenFunction &CGF,
+   llvm::Value *Address) const override {
+llvm::Value *AddrAsInt = Address;
+AddrAsInt = CGF.Builder.CreatePtrToInt(AddrAsInt, CGF.IntPtrTy);
+AddrAsInt = CGF.Builder.CreateAdd(AddrAsInt,
+  llvm::ConstantInt::get(CGF.IntPtrTy, 8));
+AddrAsInt = CGF.Builder.CreateIntToPtr(AddrAsInt, Address->getType());
+return AddrAsInt;
+  }
+
+  llvm::Value *encodeReturnAddress(CodeGen::CodeGenFunction &CGF,
+   llvm::Value *Address) const override {
+llvm::Value *AddrAsInt = Address;
+AddrAsInt = CGF.Builder.CreatePtrToInt(AddrAsInt, CGF.IntPtrTy);
+AddrAsInt = CGF.Builder.CreateAdd(AddrAsInt,
+  llvm::ConstantInt::get(CGF.IntPtrTy, 
-8));
+AddrAsInt = CGF.Builder.CreateIntToPtr(AddrAsInt, Address->getType());
+return AddrAsInt;
+  }
 };
 } // end anonymous namespace
 


Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -9221,6 +9221,32 @@
 public:
   SparcV8TargetCodeGenInfo(CodeGenTypes &CGT)
   : TargetCodeGenInfo(std::make_unique(CGT)) {}
+
+  llvm::Value *decodeReturnAddress(CodeGen::CodeGenFunction &CGF,
+   llvm::Value *Address) const override {
+llvm::Value *AddrAsInt = Address;
+AddrAsInt = CGF.Builder.CreatePtrToInt(AddrAsInt, CGF.IntPtrTy);
+AddrAsInt = CGF.Builder.CreateAdd(AddrAsInt,
+  llvm::ConstantInt::get(CGF.IntPtrTy, 8));
+if (isAggregateTypeForABI(CGF.CurFnInfo->getReturnType()))
+  AddrAsInt = CGF.Builder.CreateAdd(
+  AddrAsInt, llvm::ConstantInt::get(CGF.IntPtrTy, 4));
+AddrAsInt = CGF.Builder.CreateIntToPtr(AddrAsInt, Address->getType());
+return AddrAsInt;
+  }
+
+  llvm::Value *encodeReturnAddress(CodeGen::CodeGenFunction &CGF,
+   llvm::Value *Address) const override {
+llvm::Value *AddrAsInt = Address;
+AddrAsInt = CGF.Builder.CreatePtrToInt(AddrAs

[PATCH] D72184: [BPF] support atomic instructions

2020-11-17 Thread Brendan Jackman via Phabricator via cfe-commits
jackmanb added inline comments.



Comment at: llvm/lib/Target/BPF/BPFInstrInfo.td:684
+  let Inst{47-32} = addr{15-0}; // offset
+  let Inst{11-8} = val;
+  let Inst{7-4} = Opc.Value;

yonghong-song wrote:
> jackmanb wrote:
> > jackmanb wrote:
> > > jackmanb wrote:
> > > > Sorry I'm a beginner with the LLVM code, could you explain what `val` 
> > > > does? I didn't notice this when I looked through here before.
> > > > 
> > > > To try and get a clue I tried just removing this line and then 
> > > > compiling the following code:
> > > > 
> > > > ```C
> > > > // SPDX-License-Identifier: GPL-2.0
> > > > #include 
> > > > 
> > > > #include 
> > > > #include 
> > > > #include 
> > > > 
> > > > __u64 test_data_64 = 0;
> > > > __u64 test1_result = 0;
> > > > 
> > > > SEC("fentry/bpf_fentry_test1")
> > > > int BPF_PROG(test1, int a)
> > > > {
> > > > /* atomic_fetch_add(&test_data_64, 1); */
> > > > test1_result = __sync_fetch_and_add(&test_data_64, 1);
> > > > return 0;
> > > > }
> > > > ```
> > > > 
> > > > And I was able to load and run the program, with the kernel on my WIP 
> > > > branch: https://github.com/bjackman/linux-bpf/tree/wips/bpf-atomics-v0
> > > > 
> > > > The result looks like this:
> > > > 
> > > > ```shell
> > > > $ llvm-objdump -d atomics_test.o
> > > > 
> > > > atomics_test.o: file format elf64-bpf
> > > > 
> > > > 
> > > > Disassembly of section fentry/bpf_fentry_test1:
> > > > 
> > > >  :
> > > >0:   b7 01 00 00 01 00 00 00 r1 = 1
> > > >1:   18 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 r2 = 0 
> > > > ll
> > > >3:   db 12 00 00 01 00 00 00 r1 = atomic_fetch_add((u64 
> > > > *)(r2 + 0), PLEASE submit a bug report to https://bugs.llvm.org/ and 
> > > > include the crash backtrace.
> > > > Stack dump:
> > > > 0.  Program arguments: llvm-objdump -d atomics_test.o 
> > > > Segmentation fault
> > > > ```
> > > > 
> > > > Aside from the fact that llvm-objdump crashed, the encoding `db 12 00 
> > > > 00 01 00 00 00` seems correct to me. If I add the `let Inst{11-8} = 
> > > > val` back in I get `db 12 00 00 01 01 00 00` which I don't understand.
> > > Ah wait, I guess this is adding a 3rd operand register? In my example 
> > > it's unclear because it is R1 which is also the dst operand. I was 
> > > envisaging we just have semantics like `src = atomic_fetch_add(dst+off, 
> > > src)` but you are instead proposing `dst = atomic_fetch_add(dst+off, 
> > > val)`?
> > Sorry I mean `dst = atomic_fetch_add(src+off, val)`
> > Sorry I'm a beginner with the LLVM code, could you explain what `val` does? 
> > I didn't notice this when I looked through here before.
> 
> For the below statement:
>   test1_result = __sync_fetch_and_add(&test_data_64, 1);
> 
> 'val' represents the register which holds the value '1'.
> 
> bit 4-7 is also used in compare-and-exchange insn as you need a memory 
> location, in-register old/new values.
> 
> > 
> > To try and get a clue I tried just removing this line and then compiling 
> > the following code:
> > 
> > ```C
> > // SPDX-License-Identifier: GPL-2.0
> > #include 
> > 
> > #include 
> > #include 
> > #include 
> > 
> > __u64 test_data_64 = 0;
> > __u64 test1_result = 0;
> > 
> > SEC("fentry/bpf_fentry_test1")
> > int BPF_PROG(test1, int a)
> > {
> > /* atomic_fetch_add(&test_data_64, 1); */
> > test1_result = __sync_fetch_and_add(&test_data_64, 1);
> > return 0;
> > }
> > ```
> > 
> > And I was able to load and run the program, with the kernel on my WIP 
> > branch: https://github.com/bjackman/linux-bpf/tree/wips/bpf-atomics-v0
> > 
> > The result looks like this:
> > 
> > ```shell
> > $ llvm-objdump -d atomics_test.o
> > 
> > atomics_test.o: file format elf64-bpf
> > 
> > 
> > Disassembly of section fentry/bpf_fentry_test1:
> > 
> >  :
> >0:   b7 01 00 00 01 00 00 00 r1 = 1
> >1:   18 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 r2 = 0 ll
> >3:   db 12 00 00 01 00 00 00 r1 = atomic_fetch_add((u64 *)(r2 + 
> > 0), PLEASE submit a bug report to https://bugs.llvm.org/ and include the 
> > crash backtrace.
> > Stack dump:
> > 0.  Program arguments: llvm-objdump -d atomics_test.o 
> > Segmentation fault
> > ```
> > 
> 
> the crash may come from that the 'val' is not encoded properly. I will double 
> check.
> 
> > Aside from the fact that llvm-objdump crashed, the encoding `db 12 00 00 01 
> > 00 00 00` seems correct to me. If I add the `let Inst{11-8} = val` back in 
> > I get `db 12 00 00 01 01 00 00` which I don't understand.
> 
> in this particular case, yes, as final asm code looks like
>r1 = atomic_fetch_add((u64 *)(r2 + 0), r1)
> where the value "r1" and the result "r1" shared the same register. A little 
> bit compiler work is need to enforce "val" register and result register 
> always the same.
> 
> My current design allows:
>   r3 = atomic_fetch_add((u64 *)(r2 + 0), r1

[PATCH] D88393: [cfe][M68k] (Patch 7/8) Basic Clang support

2020-11-17 Thread Renato Golin via Phabricator via cfe-commits
rengolin added inline comments.



Comment at: clang/lib/Basic/Targets.cpp:314
+default:
+  return new M68kTargetInfo(Triple, Opts);
+}

No support for bare-metal?



Comment at: clang/lib/Basic/Targets/M68k.cpp:123
+"d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7",
+"a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7"};
+

no "sp", "pc", etc? Or are all of them aliased to those?



Comment at: clang/lib/CodeGen/TargetInfo.cpp:8083
+
+// TODO Does not actually work right now
+void M68kTargetCodeGenInfo::setTargetAttributes(

That's an odd comment... :)

What doesn't work right now? Something or everything?


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

https://reviews.llvm.org/D88393

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


[PATCH] D91610: [clangd] Add OverridenBy Relation to index.

2020-11-17 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 created this revision.
Herald added subscribers: cfe-commits, kadircet, arphaman.
Herald added a project: clang.
usaxena95 requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

This was previously explored in reviews.llvm.org/D69094 
.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91610

Files:
  clang-tools-extra/clangd/index/Relation.cpp
  clang-tools-extra/clangd/index/Relation.h
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp

Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -97,6 +97,9 @@
   const Range &Range = ::testing::get<1>(arg);
   return rangesMatch(Pos.Location, Range);
 }
+MATCHER_P2(OverridenBy, Subject, Object, "") {
+  return arg == Relation{Subject.ID, RelationKind::OverridenBy, Object.ID};
+}
 ::testing::Matcher &>
 HaveRanges(const std::vector Ranges) {
   return ::testing::UnorderedPointwise(RefRange(), Ranges);
@@ -873,12 +876,12 @@
 llvm::StringRef Main;
 llvm::StringRef TargetSymbolName;
   } TestCases[] = {
-{
-  R"cpp(
+  {
+  R"cpp(
 struct Foo;
 #define MACRO Foo
   )cpp",
-  R"cpp(
+  R"cpp(
 struct $spelled[[Foo]] {
   $spelled[[Foo]]();
   ~$spelled[[Foo]]();
@@ -886,24 +889,24 @@
 $spelled[[Foo]] Variable1;
 $implicit[[MACRO]] Variable2;
   )cpp",
-  "Foo",
-},
-{
-  R"cpp(
+  "Foo",
+  },
+  {
+  R"cpp(
 class Foo {
 public:
   Foo() = default;
 };
   )cpp",
-  R"cpp(
+  R"cpp(
 void f() { Foo $implicit[[f]]; f = $spelled[[Foo]]();}
   )cpp",
-  "Foo::Foo" /// constructor.
-},
+  "Foo::Foo" /// constructor.
+  },
   };
   CollectorOpts.RefFilter = RefKind::All;
   CollectorOpts.RefsInHeaders = false;
-  for (const auto& T : TestCases) {
+  for (const auto &T : TestCases) {
 Annotations Header(T.Header);
 Annotations Main(T.Main);
 // Reset the file system.
@@ -1031,7 +1034,7 @@
   HaveRanges(Header.ranges("macro");
 }
 
-TEST_F(SymbolCollectorTest, Relations) {
+TEST_F(SymbolCollectorTest, BaseOfRelations) {
   std::string Header = R"(
   class Base {};
   class Derived : public Base {};
@@ -1043,6 +1046,41 @@
   Contains(Relation{Base.ID, RelationKind::BaseOf, Derived.ID}));
 }
 
+TEST_F(SymbolCollectorTest, OverrideRelations) {
+  std::string Header = R"cpp(
+class A {
+  virtual void foo();
+};
+class B : public A {
+  void foo() override;
+  virtual void bar();
+};
+class C : public B {
+  void bar() override;
+};
+class D: public C {
+  void foo() override;
+  void bar() override;
+};
+  )cpp";
+  runSymbolCollector(Header, /*Main=*/"");
+  const Symbol &AFoo = findSymbol(Symbols, "A::foo");
+  const Symbol &BFoo = findSymbol(Symbols, "B::foo");
+  const Symbol &DFoo = findSymbol(Symbols, "D::foo");
+
+  const Symbol &BBar = findSymbol(Symbols, "B::bar");
+  const Symbol &CBar = findSymbol(Symbols, "C::bar");
+  const Symbol &DBar = findSymbol(Symbols, "D::bar");
+
+  std::vector Result;
+  for (const Relation &R : Relations)
+if (R.Predicate == RelationKind::OverridenBy)
+  Result.push_back(R);
+  EXPECT_THAT(Result, UnorderedElementsAre(
+  OverridenBy(AFoo, BFoo), OverridenBy(BBar, CBar),
+  OverridenBy(BFoo, DFoo), OverridenBy(CBar, DBar)));
+}
+
 TEST_F(SymbolCollectorTest, CountReferences) {
   const std::string Header = R"(
 class W;
Index: clang-tools-extra/clangd/index/SymbolCollector.cpp
===
--- clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -15,6 +15,7 @@
 #include "SourceCode.h"
 #include "SymbolLocation.h"
 #include "URI.h"
+#include "index/Relation.h"
 #include "index/SymbolID.h"
 #include "support/Logger.h"
 #include "clang/AST/Decl.h"
@@ -187,9 +188,12 @@
   return Result;
 }
 
-bool shouldIndexRelation(const index::SymbolRelation &R) {
-  // We currently only index BaseOf relations, for type hierarchy subtypes.
-  return R.Roles & static_cast(index::SymbolRole::RelationBaseOf);
+llvm::Optional indexableRelation(const index::SymbolRelation &R) {
+  if (R.Roles & static_cast(index::SymbolRole::RelationBaseOf))
+return RelationKind::BaseOf;
+  if (R.Roles & static_cast(index::SymbolRole::RelationOverrideOf))
+return RelationKind::OverridenBy;
+  return None;
 }
 
 } // namespace
@@ -486,14 +490,10 @@
 void SymbolCollector::processRelations(
 const NamedD

[PATCH] D91531: [RFC][OpenCL] Provide mechanisms for defining extension macros

2020-11-17 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 305721.
Anastasia added a comment.

- Added full diffs.


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

https://reviews.llvm.org/D91531

Files:
  clang/include/clang/Basic/OpenCLExtensions.def
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/Targets.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Headers/opencl-c.h
  clang/test/Headers/opencl-c-header.cl
  clang/test/SemaOpenCL/extension-version.cl

Index: clang/test/SemaOpenCL/extension-version.cl
===
--- clang/test/SemaOpenCL/extension-version.cl
+++ clang/test/SemaOpenCL/extension-version.cl
@@ -9,11 +9,11 @@
 // RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
 // RUN: %clang_cc1 -x cl -cl-std=clc++ %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
 
-#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) && !defined(TEST_CORE_FEATURES)
-// expected-no-diagnostics
+// Extensions in all versions
+#ifndef __opencl_c_int64
+#error "Missing __opencl_c_int64 predefined macro"
 #endif
 
-// Extensions in all versions
 #ifndef cl_clang_storage_class_specifiers
 #error "Missing cl_clang_storage_class_specifiers define"
 #endif
@@ -167,17 +167,14 @@
 #endif
 #pragma OPENCL EXTENSION cl_amd_media_ops2 : enable
 
-#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 120)
-#ifndef cl_khr_depth_images
-#error "Missing cl_khr_depth_images define"
-#endif
-#else
-#ifdef cl_khr_depth_images
-#error "Incorrect cl_khr_depth_images define"
-#endif
-// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_depth_images' - ignoring}}
-#endif
+// FIXME: This pragma is meaningless and it doesn't add any functionality.
+// However we will probably need to keep it for backward compatibility.
+// In which case there is no need to guard its use by any version or a target
+// setting as it does absolutely nothing anyway.
+// The warning diagnostic should change however to something like -
+// - pragma has no effect.
 #pragma OPENCL EXTENSION cl_khr_depth_images : enable
+// expected-warning@-1{{unknown OpenCL extension 'cl_khr_depth_images' - ignoring}}
 
 #if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 120)
 #ifndef cl_intel_subgroups
Index: clang/test/Headers/opencl-c-header.cl
===
--- clang/test/Headers/opencl-c-header.cl
+++ clang/test/Headers/opencl-c-header.cl
@@ -95,3 +95,16 @@
 #pragma OPENCL EXTENSION cl_intel_planar_yuv : enable
 
 // CHECK-MOD: Reading modules
+
+// Check predefined extension macros
+
+#if defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ == 200 || \
+ (__OPENCL_C_VERSION__ >= 120 && defined(__SPIR__) && !defined(__undef_cl_khr_depth_images)) 
+#ifndef cl_khr_depth_images
+#error "Missing cl_khr_depth_images define"
+#endif
+#else
+#ifdef cl_khr_depth_images
+#error "Incorrect cl_khr_depth_images define"
+#endif
+#endif
Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -11,7 +11,8 @@
 
 #include "opencl-c-base.h"
 
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ == CL_VERSION_2_0) || \
+(__OPENCL_C_VERSION__ >= CL_VERSION_1_2 && defined(__SPIR__) && !defined(__undef_cl_khr_depth_images))
 #ifndef cl_khr_depth_images
 #define cl_khr_depth_images
 #endif //cl_khr_depth_images
Index: clang/lib/Frontend/InitPreprocessor.cpp
===
--- clang/lib/Frontend/InitPreprocessor.cpp
+++ clang/lib/Frontend/InitPreprocessor.cpp
@@ -,10 +,8 @@
 
   // OpenCL definitions.
   if (LangOpts.OpenCL) {
-#define OPENCLEXT(Ext) \
-  if (TI.getSupportedOpenCLOpts().isSupported(#Ext, LangOpts)) \
-Builder.defineMacro(#Ext);
-#include "clang/Basic/OpenCLExtensions.def"
+// Add OpenCL #defines for supported extensions. 
+TI.getOpenCLExtensionDefines(LangOpts, Builder);
 
 if (TI.getTriple().isSPIR())
   Builder.defineMacro("__IMAGE_SUPPORT__");
Index: clang/lib/Basic/Targets.cpp
===
--- clang/lib/Basic/Targets.cpp
+++ clang/lib/Basic/Targets.cpp
@@ -705,3 +705,21 @@
 
   return Target.release();
 }
+
+void TargetInfo::getOpenCLExtensionDefines(const LangOptions &Opts,
+   MacroBuilder &Builder) const {
+  // Add macros for extension that this target supports.
+  auto defineExtMacro = [&](llvm::StringRef Ext) {
+if (getSupportedOpenCLOpts().isSupported(Ext, Opts))
+  Builder.defineMacro(Ext);
+  };
+
+#define OPENCLEXT(Ext) defineE

[PATCH] D88394: [Driver][M68k] (Patch 8/8) Add driver support for M68k

2020-11-17 Thread Renato Golin via Phabricator via cfe-commits
rengolin added inline comments.



Comment at: clang/include/clang/Driver/Options.td:3125
+foreach i = {0-4} in
+  def m680#i#0 : Flag<["-"], "m680"#i#"0">, Group;
 

Same question as @RKSimon had below: Shouldn't this cover all models the 
back-end recognises?



Comment at: clang/lib/Driver/ToolChains/Gnu.cpp:2089
+  static const char *const M68kTriples[] = {
+  "m68k-linux-gnu", "m68k-unknown-linux-gnu", "m68k-suse-linux"};
+

The front-end supports FreeBSD, too.


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

https://reviews.llvm.org/D88394

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


[PATCH] D91602: [clang-tidy] Make clang-format and include-order-check coherent

2020-11-17 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

Thanks for fixing this, been bugging me for a while.




Comment at: clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp:1
 // RUN: %check_clang_tidy %s llvm-include-order %t -- -- -isystem 
%S/Inputs/Headers
 

Would it be wise to specify a format style here to ensure they align. Better 
yet 2 run lines, one that runs clang-tidy with no format, the other specifies a 
format.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91602

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


[PATCH] D91534: [RFC][OpenCL] Add new diagnostic for extension pragma with no effect

2020-11-17 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 305723.
Anastasia added a comment.

Added full diff.


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

https://reviews.llvm.org/D91534

Files:
  clang/docs/DiagnosticsReference.rst
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/Parse/ParsePragma.cpp
  clang/test/Headers/opencl-c-header.cl
  clang/test/Parser/opencl-pragma.cl
  clang/test/SemaOpenCL/extension-begin.cl
  clang/test/SemaOpenCL/extension-version.cl

Index: clang/test/SemaOpenCL/extension-version.cl
===
--- clang/test/SemaOpenCL/extension-version.cl
+++ clang/test/SemaOpenCL/extension-version.cl
@@ -7,7 +7,11 @@
 // RUN: %clang_cc1 -x cl -cl-std=CL1.1 %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
 // RUN: %clang_cc1 -x cl -cl-std=CL1.2 %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
 // RUN: %clang_cc1 -x cl -cl-std=CL2.0 %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
-// RUN: %clang_cc1 -x cl -cl-std=clc++ %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -DTEST_CORE_FEATURES
+// RUN: %clang_cc1 -x cl -cl-std=clc++ %s -verify -triple spir-unknown-unknown -Wpedantic-core-features -Wpedantic-redundant-pragma -DTEST_CORE_FEATURES -DTEST_REDUNDANT_PRAGMA
+
+#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ == 200) && !(defined(TEST_CORE_FEATURES) || defined(TEST_REDUNDANT_PRAGMA))
+// expected-no-diagnostics
+#endif
 
 // Extensions in all versions
 #ifndef __opencl_c_int64
@@ -167,14 +171,14 @@
 #endif
 #pragma OPENCL EXTENSION cl_amd_media_ops2 : enable
 
-// FIXME: This pragma is meaningless and it doesn't add any functionality.
+// This pragma is meaningless and it doesn't add any functionality.
 // However we will probably need to keep it for backward compatibility.
 // In which case there is no need to guard its use by any version or a target
 // setting as it does absolutely nothing anyway.
-// The warning diagnostic should change however to something like -
-// - pragma has no effect.
 #pragma OPENCL EXTENSION cl_khr_depth_images : enable
-// expected-warning@-1{{unknown OpenCL extension 'cl_khr_depth_images' - ignoring}}
+#if defined(TEST_REDUNDANT_PRAGMA)
+// expected-warning@-2{{OpenCL extension pragma 'cl_khr_depth_images' has no effect - ignoring}}
+#endif
 
 #if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 120)
 #ifndef cl_intel_subgroups
Index: clang/test/SemaOpenCL/extension-begin.cl
===
--- clang/test/SemaOpenCL/extension-begin.cl
+++ clang/test/SemaOpenCL/extension-begin.cl
@@ -18,8 +18,8 @@
 
 #pragma OPENCL EXTENSION my_ext : enable
 #ifndef IMPLICIT_INCLUDE
-// expected-warning@-2 {{unknown OpenCL extension 'my_ext' - ignoring}}
-// expected-warning@+2 {{unknown OpenCL extension 'my_ext' - ignoring}}
+// expected-warning@-2 {{unknown OpenCL extension pragma 'my_ext' - ignoring}}
+// expected-warning@+2 {{unknown OpenCL extension pragma 'my_ext' - ignoring}}
 #endif // IMPLICIT_INCLUDE
 #pragma OPENCL EXTENSION my_ext : disable
 
Index: clang/test/Parser/opencl-pragma.cl
===
--- clang/test/Parser/opencl-pragma.cl
+++ clang/test/Parser/opencl-pragma.cl
@@ -2,7 +2,7 @@
 
 #pragma OPENCL EXTENSION cl_khr_fp16 : enable
 
-#pragma OPENCL EXTENSION cl_no_such_extension : disable /* expected-warning {{unknown OpenCL extension 'cl_no_such_extension' - ignoring}} */
+#pragma OPENCL EXTENSION cl_no_such_extension : disable /* expected-warning {{unknown OpenCL extension pragma 'cl_no_such_extension' - ignoring}} */
 
 #pragma OPENCL EXTENSION all : disable
 #pragma OPENCL EXTENSION all : enable /* expected-warning {{expected 'disable' - ignoring}} */
Index: clang/test/Headers/opencl-c-header.cl
===
--- clang/test/Headers/opencl-c-header.cl
+++ clang/test/Headers/opencl-c-header.cl
@@ -90,7 +90,7 @@
 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2)
 // expected-no-diagnostics
 #else //__OPENCL_C_VERSION__
-// expected-warning@+2{{unknown OpenCL extension 'cl_intel_planar_yuv' - ignoring}}
+// expected-warning@+2{{unknown OpenCL extension pragma 'cl_intel_planar_yuv' - ignoring}}
 #endif //__OPENCL_C_VERSION__
 #pragma OPENCL EXTENSION cl_intel_planar_yuv : enable
 
Index: clang/lib/Parse/ParsePragma.cpp
===
--- clang/lib/Parse/ParsePragma.cpp
+++ clang/lib/Parse/ParsePragma.cpp
@@ -786,9 +786,17 @@
 if (Name != Actions.getCurrentOpenCLExtension())
   PP.Diag(NameLoc, diag::warn_pragma_begin_end_mismatch);
 Actions.setCurrentOpenCLExtension("");
-  } else if (!Opt.isKnown(Name))
-PP.Diag(NameLoc, diag::warn_pragma_unknown_extension) << Ident;
-  else i

[PATCH] D91442: [clang][Driver] Handle risvc in Baremetal.cpp.

2020-11-17 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
abidh added a comment.

In D91442#2399200 , @lenary wrote:

> I'm worried about this change - I *think* it doesn't cover the existing 
> behaviour of a baremetal GCC toolchain being installed into the same prefix 
> as clang, and clang automatically picking up that baremetal gcc toolchain. 
> What should we expect to do here? This is especially an issue if you're 
> trying to make a relocatable toolchain tarball, where specifying 
> `--gcc-toolchain` automatically is difficult.

Would it be possible to use a relative path with --gcc-toolchain then this can 
be checked in either RISCVToolChain.cpp or GNU.cpp and adjusted accordingly?


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

https://reviews.llvm.org/D91442

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


[PATCH] D91538: [RFC][OpenCL] Make Tablegen header work with extensions that are not added in clang

2020-11-17 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 305724.
Anastasia added a comment.

Added full diffs.


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

https://reviews.llvm.org/D91538

Files:
  clang/include/clang/Basic/OpenCLExtensions.def
  clang/lib/Basic/Targets/AMDGPU.h
  clang/lib/Headers/opencl-c-base.h
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/test/Headers/opencl-c-header.cl
  clang/test/SemaOpenCL/extension-version.cl
  clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl

Index: clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
===
--- clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
+++ clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
@@ -30,8 +30,8 @@
 typedef int int4 __attribute__((ext_vector_type(4)));
 typedef uint uint4 __attribute__((ext_vector_type(4)));
 typedef long long2 __attribute__((ext_vector_type(2)));
+typedef float float2 __attribute__((ext_vector_type(2)));
 #endif
-
 kernel void test_pointers(volatile global void *global_p, global const int4 *a) {
   int i;
   unsigned int ui;
@@ -143,8 +143,11 @@
 #if defined(__OPENCL_CPP_VERSION__)
   // expected-error@-2{{no matching function for call to 'get_sub_group_size'}}
   // expected-note@-3{{candidate unavailable as it requires OpenCL extension 'cl_khr_subgroups' to be enabled}}
-#else
+#elif __OPENCL_C_VERSION__ == CL_VERSION_2_0 
   // expected-error@-5{{use of declaration 'get_sub_group_size' requires cl_khr_subgroups extension to be enabled}}
+#else
+  // expected-error@-7{{implicit declaration of function 'get_sub_group_size' is invalid in OpenCL}}
+  // expected-error@-8{{implicit conversion changes signedness: 'int' to 'uint' (aka 'unsigned int')}}
 #endif
 }
 
@@ -179,3 +182,50 @@
 // expected-error@-2{{implicit declaration of function 'get_enqueued_local_size' is invalid in OpenCL}}
 #endif
 }
+
+float4 basic_mipmap_image(read_only image2d_t image, sampler_t sampler, float2 coord, float lod) {
+  return read_imagef(image, sampler, coord, lod);
+#if (!defined(__OPENCL_CPP_VERSION__) && __OPENCL_C_VERSION__ < CL_VERSION_2_0) || defined(NO_HEADER)
+// expected-error@-2{{no matching function for call to 'read_imagef'}}
+// expected-note@-3{{candidate function not viable:}}
+// expected-note@-4{{candidate function not viable:}}
+// expected-note@-5{{candidate function not viable:}}
+// expected-note@-6{{candidate function not viable:}}
+// expected-note@-7{{candidate function not viable:}}
+// expected-note@-8{{candidate function not viable:}}
+// expected-note@-9{{candidate function not viable:}}
+// expected-note@-10{{candidate function not viable:}}
+// expected-note@-11{{candidate function not viable:}}
+// expected-note@-12{{candidate function not viable:}}
+// expected-note@-13{{candidate function not viable:}}
+// expected-note@-14{{candidate function not viable:}}
+// expected-note@-15{{candidate function not viable:}}
+// expected-note@-16{{candidate function not viable:}}
+// expected-note@-17{{candidate function not viable:}}
+// expected-note@-18{{candidate function not viable:}}
+// expected-note@-19{{candidate function not viable:}}
+// expected-note@-20{{candidate function not viable:}}
+// expected-note@-21{{candidate function not viable:}}
+// expected-note@-22{{candidate function not viable:}}
+// expected-note@-23{{candidate function not viable:}}
+// expected-note@-24{{candidate function not viable:}}
+// expected-note@-25{{candidate function not viable:}}
+// expected-note@-26{{candidate function not viable:}}
+// expected-note@-27{{candidate function not viable:}}
+// expected-note@-28{{candidate function not viable:}}
+// expected-note@-29{{candidate function not viable:}}
+// expected-note@-30{{candidate function not viable:}}
+// expected-note@-31{{candidate function not viable:}}
+// expected-note@-32{{candidate function not viable:}}
+#if defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= CL_VERSION_1_2
+// expected-note@-34{{candidate function not viable:}}
+// expected-note@-35{{candidate function not viable:}}
+// expected-note@-36{{candidate function not viable:}}
+// expected-note@-37{{candidate function not viable:}}
+// expected-note@-38{{candidate function not viable:}}
+// expected-note@-39{{candidate function not viable:}}
+// expected-note@-40{{candidate function not viable:}}
+// expected-note@-41{{candidate function not viable:}}
+#endif
+#endif
+}
Index: clang/test/SemaOpenCL/extension-version.cl
===
--- clang/test/SemaOpenCL/extension-version.cl
+++ clang/test/SemaOpenCL/extension-version.cl
@@ -116,17 +116,10 @@
 #endif
 #pragma OPENCL EXTENSION cl_khr_gl_msaa_sharing : enable
 
-#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
-#ifndef cl_khr_mipmap_image
-#error "Missing cl_khr_mipmap_image define"
-#endif
-#else
-#ifdef cl_khr_mipmap_image
-#error "Incorrect cl_khr_mipmap_image define"
-#

[PATCH] D91047: Add a call super attribute plugin example

2020-11-17 Thread Yafei Liu via Phabricator via cfe-commits
psionic12 updated this revision to Diff 305725.
psionic12 added a comment.

use `VerifyDiagnosticConsumer` (-verify) instead of `FileCheck` for syntax only 
feature test.
remove illustration in ClangPlugins.rst (which is not very appropriate)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91047

Files:
  clang/examples/CMakeLists.txt
  clang/examples/CallSuperAttribute/CMakeLists.txt
  clang/examples/CallSuperAttribute/CallSuperAttrInfo.cpp
  clang/test/CMakeLists.txt
  clang/test/Frontend/plugin-call-super.cpp

Index: clang/test/Frontend/plugin-call-super.cpp
===
--- /dev/null
+++ clang/test/Frontend/plugin-call-super.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang -fplugin=%llvmshlibdir/CallSuperAttr%pluginext -fsyntax-only -Xclang -verify %s
+// RUN: %clang -fplugin=%llvmshlibdir/CallSuperAttr%pluginext -DBAD_CALLSUPER -fsyntax-only -Xclang -verify %s
+// REQUIRES: plugins, examples
+
+#ifndef BAD_CALLSUPER
+// expected-no-diagnostics
+struct Base1 { [[clang::call_super]] virtual void Test() {} };
+struct Base2 { [[clang::call_super]] virtual void Test() {} };
+struct Derive : public Base1, public Base2 { void Test() override; };
+void Derive::Test() { Base1::Test(); Base2::Test(); }
+struct Derive2 : public Base1, public Base2 { void Test() override {  Base1::Test();  Base2::Test();}};
+#else
+struct Base1 { [[clang::call_super]] virtual void Test() {} };
+struct Base2 { [[clang::call_super]] virtual void Test() {} };
+struct Derive : public Base1, public Base2 { [[clang::call_super]] virtual void Test() override final; };
+// expected-warning@15 {{'call_super' attribute marked on a final method}}
+void Derive::Test() { Base1::Test(); /*Base2::Test();*/ }
+// expected-warning@17 {{virtual function 'Base2::Test' is marked as 'call_super' but this overriding method does not call the base version}}
+// expected-note@14 {{function marked 'call_super' here}}
+struct Derive2 : public Base1, public Base2 { void Test() override {  Base1::Test();  Base2::Test();}};
+#endif
Index: clang/test/CMakeLists.txt
===
--- clang/test/CMakeLists.txt
+++ clang/test/CMakeLists.txt
@@ -91,6 +91,7 @@
   list(APPEND CLANG_TEST_DEPS
 Attribute
 AnnotateFunctions
+CallSuperAttr
 clang-interpreter
 PrintFunctionNames
 )
Index: clang/examples/CallSuperAttribute/CallSuperAttrInfo.cpp
===
--- /dev/null
+++ clang/examples/CallSuperAttribute/CallSuperAttrInfo.cpp
@@ -0,0 +1,190 @@
+//===- AnnotateFunctions.cpp --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// Attribute plugin to mark a virtual method as ``call_super``, subclasses must
+// call it in the overridden method.
+//
+// This example shows that attribute plugins combined with ``PluginASTAction``
+// in Clang can do some of the same things which Java Annotations do.
+//
+// Unlike the other attribute plugin examples, this one does not attach an
+// attribute AST node to the declaration AST node. Instead, it keeps a separate
+// list of attributed declarations, which may be faster than using
+// ``Decl::getAttr()`` in some cases. The disadvantage of this approach is
+// that the attribute is not part of the AST, which means that dumping the AST
+// will lose the attribute information, pretty printing the AST won't write the
+// attribute back out to source, and AST matchers will not be able to match
+// against the attribute on the declaration.
+//
+//===--===//
+
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Attr.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/Frontend/FrontendPluginRegistry.h"
+#include "clang/Sema/ParsedAttr.h"
+#include "clang/Sema/Sema.h"
+#include "clang/Sema/SemaDiagnostic.h"
+#include "llvm/ADT/SmallPtrSet.h"
+using namespace clang;
+
+namespace {
+// Cached methods which are marked as 'call_super'.
+llvm::SmallPtrSet MarkedMethods;
+bool isMarkedAsCallSuper(const CXXMethodDecl *D) {
+  // Uses this way to avoid add an annotation attr to the AST.
+  return MarkedMethods.contains(D);
+}
+
+class MethodUsageVisitor : public RecursiveASTVisitor {
+public:
+  bool IsOverriddenUsed = false;
+  explicit MethodUsageVisitor(
+  llvm::SmallPtrSet &MustCalledMethods)
+  : MustCalledMethods(MustCalledMethods) {}
+  bool VisitCallExpr(CallExpr *CallExpr) {
+const CXXMethodDecl *Callee = nullptr;
+for (const auto &MustCalled : MustCalledMethods) {
+  if (CallExpr

[PATCH] D91047: Add a call super attribute plugin example

2020-11-17 Thread Yafei Liu via Phabricator via cfe-commits
psionic12 added inline comments.



Comment at: clang/docs/ClangPlugins.rst:116
 
+Defining CallSuperAttr
+==

After a whole day's research of `Sphinx`, I figured out that  
`ClangPlugins.rst` is the "proto-type" of 
https://clang.llvm.org/docs/ClangPlugins.html, which is the document on how to 
use Clang plugin features.

This leads that my change in `ClangPlugins.rst` are not very appropriate, sort 
of off-topic.

Sorry I don't notice the rest of the file, and misunderstood it as a documents 
for examples.

I decide to move the illustration to the source code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91047

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


[PATCH] D88393: [cfe][M68k] (Patch 7/8) Basic Clang support

2020-11-17 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added inline comments.



Comment at: clang/lib/Basic/CMakeLists.txt:78
   Targets/Mips.cpp
+  Targets/M68k.cpp
   Targets/NVPTX.cpp

(sorting) - move after Le64.cpp



Comment at: clang/lib/CodeGen/TargetInfo.cpp:8087
+  if (const FunctionDecl *FD = dyn_cast_or_null(D)) {
+if (const M68kInterruptAttr *attr = FD->getAttr()) {
+  // Handle 'interrupt' attribute:

(style) Use const auto * for cast results


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

https://reviews.llvm.org/D88393

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


[PATCH] D91047: Add a call super attribute plugin example

2020-11-17 Thread Yafei Liu via Phabricator via cfe-commits
psionic12 marked an inline comment as done.
psionic12 added inline comments.



Comment at: clang/test/Frontend/plugin-call-super.cpp:18-19
+struct Derive2 : public Base1, public Base2 { void Test() override {  
Base1::Test();  Base2::Test();}};
+// BADCALLSUPER: warning: virtual function 'Base2::Test' is marked as 
'call_super' but this overriding method does not call the base version
+// BADCALLSUPER: note: function marked 'call_super' here
+#endif

aaron.ballman wrote:
> These warnings and notes (and the warning a few lines up) are ones I would 
> have expected to catch using `// expected-warning {{virtual function 
> 'Base2::Test' is marked as 'call_super' but this overriding method does not 
> call the base version}}` style checks instead of needing to use FileCheck.
> 
> Do plugin-based diagnostics not get caught by `-verify`? I expect this test 
> file to fail as currently written because of the `expected-no-diagnostics`, 
> but I've not done a whole lot of testing of plugins before.
`-verify` works well with plugins, I just tested, thanks for pointing out this 
elegant test way for syntax only features.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91047

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


[PATCH] D91610: [clangd] Add OverridenBy Relation to index.

2020-11-17 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 updated this revision to Diff 305727.
usaxena95 added a comment.

added more tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91610

Files:
  clang-tools-extra/clangd/index/Relation.cpp
  clang-tools-extra/clangd/index/Relation.h
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp

Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -97,6 +97,9 @@
   const Range &Range = ::testing::get<1>(arg);
   return rangesMatch(Pos.Location, Range);
 }
+MATCHER_P2(OverridenBy, Subject, Object, "") {
+  return arg == Relation{Subject.ID, RelationKind::OverridenBy, Object.ID};
+}
 ::testing::Matcher &>
 HaveRanges(const std::vector Ranges) {
   return ::testing::UnorderedPointwise(RefRange(), Ranges);
@@ -873,12 +876,12 @@
 llvm::StringRef Main;
 llvm::StringRef TargetSymbolName;
   } TestCases[] = {
-{
-  R"cpp(
+  {
+  R"cpp(
 struct Foo;
 #define MACRO Foo
   )cpp",
-  R"cpp(
+  R"cpp(
 struct $spelled[[Foo]] {
   $spelled[[Foo]]();
   ~$spelled[[Foo]]();
@@ -886,24 +889,24 @@
 $spelled[[Foo]] Variable1;
 $implicit[[MACRO]] Variable2;
   )cpp",
-  "Foo",
-},
-{
-  R"cpp(
+  "Foo",
+  },
+  {
+  R"cpp(
 class Foo {
 public:
   Foo() = default;
 };
   )cpp",
-  R"cpp(
+  R"cpp(
 void f() { Foo $implicit[[f]]; f = $spelled[[Foo]]();}
   )cpp",
-  "Foo::Foo" /// constructor.
-},
+  "Foo::Foo" /// constructor.
+  },
   };
   CollectorOpts.RefFilter = RefKind::All;
   CollectorOpts.RefsInHeaders = false;
-  for (const auto& T : TestCases) {
+  for (const auto &T : TestCases) {
 Annotations Header(T.Header);
 Annotations Main(T.Main);
 // Reset the file system.
@@ -1031,7 +1034,7 @@
   HaveRanges(Header.ranges("macro");
 }
 
-TEST_F(SymbolCollectorTest, Relations) {
+TEST_F(SymbolCollectorTest, BaseOfRelations) {
   std::string Header = R"(
   class Base {};
   class Derived : public Base {};
@@ -1043,6 +1046,77 @@
   Contains(Relation{Base.ID, RelationKind::BaseOf, Derived.ID}));
 }
 
+TEST_F(SymbolCollectorTest, OverrideRelationsSimpleInheritance) {
+  std::string Header = R"cpp(
+class A {
+  virtual void foo();
+};
+class B : public A {
+  void foo() override;  // A::foo
+  virtual void bar();
+};
+class C : public B {
+  void bar() override;  // B::bar
+};
+class D: public C {
+  void foo() override;  // B::foo
+  void bar() override;  // C::bar
+};
+  )cpp";
+  runSymbolCollector(Header, /*Main=*/"");
+  const Symbol &AFoo = findSymbol(Symbols, "A::foo");
+  const Symbol &BFoo = findSymbol(Symbols, "B::foo");
+  const Symbol &DFoo = findSymbol(Symbols, "D::foo");
+
+  const Symbol &BBar = findSymbol(Symbols, "B::bar");
+  const Symbol &CBar = findSymbol(Symbols, "C::bar");
+  const Symbol &DBar = findSymbol(Symbols, "D::bar");
+
+  std::vector Result;
+  for (const Relation &R : Relations)
+if (R.Predicate == RelationKind::OverridenBy)
+  Result.push_back(R);
+  EXPECT_THAT(Result, UnorderedElementsAre(
+  OverridenBy(AFoo, BFoo), OverridenBy(BBar, CBar),
+  OverridenBy(BFoo, DFoo), OverridenBy(CBar, DBar)));
+}
+
+TEST_F(SymbolCollectorTest, OverrideRelationsMultipleInheritance) {
+  std::string Header = R"cpp(
+class A {
+  virtual void foo();
+};
+class B {
+  virtual void bar();
+};
+class C : public B {
+  void bar() override;  // B::bar
+  virtual void baz();
+}
+class D : public A, C {
+  void foo() override;  // A::foo
+  void bar() override;  // C::bar
+  void baz() override;  // C::baz
+};
+  )cpp";
+  runSymbolCollector(Header, /*Main=*/"");
+  const Symbol &AFoo = findSymbol(Symbols, "A::foo");
+  const Symbol &BBar = findSymbol(Symbols, "B::bar");
+  const Symbol &CBar = findSymbol(Symbols, "C::bar");
+  const Symbol &CBaz = findSymbol(Symbols, "C::baz");
+  const Symbol &DFoo = findSymbol(Symbols, "D::foo");
+  const Symbol &DBar = findSymbol(Symbols, "D::bar");
+  const Symbol &DBaz = findSymbol(Symbols, "D::baz");
+
+  std::vector Result;
+  for (const Relation &R : Relations)
+if (R.Predicate == RelationKind::OverridenBy)
+  Result.push_back(R);
+  EXPECT_THAT(Result, UnorderedElementsAre(
+  OverridenBy(BBar, CBar), OverridenBy(AFoo, DFoo),
+  OverridenBy(CBar, DBar), OverridenBy(CBaz, DBaz)));
+}
+
 TEST_F(SymbolCollectorTest,

[PATCH] D91442: [clang][Driver] Handle risvc in Baremetal.cpp.

2020-11-17 Thread Sam Elliott via Phabricator via cfe-commits
lenary added a comment.

In D91442#2399341 , @abidh wrote:

> In D91442#2399200 , @lenary wrote:
>
>> I'm worried about this change - I *think* it doesn't cover the existing 
>> behaviour of a baremetal GCC toolchain being installed into the same prefix 
>> as clang, and clang automatically picking up that baremetal gcc toolchain. 
>> What should we expect to do here? This is especially an issue if you're 
>> trying to make a relocatable toolchain tarball, where specifying 
>> `--gcc-toolchain` automatically is difficult.
>
> Would it be possible to use a relative path with --gcc-toolchain then this 
> can be checked in either RISCVToolChain.cpp or GNU.cpp and adjusted 
> accordingly?

The GCC toolchain, when given a relative path, already interprets it relative 
to the working directory the compiler was invoked from, not the directory the 
compiler is located in, iirc.


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

https://reviews.llvm.org/D91442

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


[PATCH] D91429: [OpenCL] Stop opencl-c-base.h leaking extension enabling

2020-11-17 Thread Sven van Haastregt via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf0c690018ad1: [OpenCL] Stop opencl-c-base.h leaking 
extension enabling (authored by svenvh).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91429

Files:
  clang/lib/Headers/opencl-c-base.h
  clang/lib/Headers/opencl-c.h
  clang/test/SemaOpenCL/half.cl


Index: clang/test/SemaOpenCL/half.cl
===
--- clang/test/SemaOpenCL/half.cl
+++ clang/test/SemaOpenCL/half.cl
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -Wno-unused-value 
-triple spir-unknown-unknown
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -Wno-unused-value 
-triple spir-unknown-unknown -fdeclare-opencl-builtins -finclude-default-header
 
-#pragma OPENCL EXTENSION cl_khr_fp16 : disable
 constant float f = 1.0h; // expected-error{{half precision constant requires 
cl_khr_fp16}}
 
 half half_disabled(half *p, // expected-error{{declaring function return value 
of type 'half' is not allowed}}
Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -4633,6 +4633,7 @@
 // Conversions with double data type parameters or return value.
 
 #ifdef cl_khr_fp64
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
 char __ovld __cnfn convert_char(double);
 char __ovld __cnfn convert_char_rte(double);
 char __ovld __cnfn convert_char_rtn(double);
@@ -5455,6 +5456,7 @@
 #endif //cl_khr_fp64
 
 #ifdef cl_khr_fp16
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
 // Convert half types to non-double types.
 uchar __ovld __cnfn convert_uchar(half);
 uchar __ovld __cnfn convert_uchar_rte(half);
Index: clang/lib/Headers/opencl-c-base.h
===
--- clang/lib/Headers/opencl-c-base.h
+++ clang/lib/Headers/opencl-c-base.h
@@ -568,4 +568,7 @@
 #pragma OPENCL EXTENSION cl_intel_device_side_avc_motion_estimation : end
 #endif // cl_intel_device_side_avc_motion_estimation
 
+// Disable any extensions we may have enabled previously.
+#pragma OPENCL EXTENSION all : disable
+
 #endif //_OPENCL_BASE_H_


Index: clang/test/SemaOpenCL/half.cl
===
--- clang/test/SemaOpenCL/half.cl
+++ clang/test/SemaOpenCL/half.cl
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -Wno-unused-value -triple spir-unknown-unknown
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -Wno-unused-value -triple spir-unknown-unknown -fdeclare-opencl-builtins -finclude-default-header
 
-#pragma OPENCL EXTENSION cl_khr_fp16 : disable
 constant float f = 1.0h; // expected-error{{half precision constant requires cl_khr_fp16}}
 
 half half_disabled(half *p, // expected-error{{declaring function return value of type 'half' is not allowed}}
Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -4633,6 +4633,7 @@
 // Conversions with double data type parameters or return value.
 
 #ifdef cl_khr_fp64
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
 char __ovld __cnfn convert_char(double);
 char __ovld __cnfn convert_char_rte(double);
 char __ovld __cnfn convert_char_rtn(double);
@@ -5455,6 +5456,7 @@
 #endif //cl_khr_fp64
 
 #ifdef cl_khr_fp16
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
 // Convert half types to non-double types.
 uchar __ovld __cnfn convert_uchar(half);
 uchar __ovld __cnfn convert_uchar_rte(half);
Index: clang/lib/Headers/opencl-c-base.h
===
--- clang/lib/Headers/opencl-c-base.h
+++ clang/lib/Headers/opencl-c-base.h
@@ -568,4 +568,7 @@
 #pragma OPENCL EXTENSION cl_intel_device_side_avc_motion_estimation : end
 #endif // cl_intel_device_side_avc_motion_estimation
 
+// Disable any extensions we may have enabled previously.
+#pragma OPENCL EXTENSION all : disable
+
 #endif //_OPENCL_BASE_H_
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] f0c6900 - [OpenCL] Stop opencl-c-base.h leaking extension enabling

2020-11-17 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2020-11-17T12:07:40Z
New Revision: f0c690018ad1fb4746da3aca26a443c0f96530fa

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

LOG: [OpenCL] Stop opencl-c-base.h leaking extension enabling

opencl-c.h disables all extensions at its end, but opencl-c-base.h
does not, and that causes any inclusion of only opencl-c-base.h to
leave some extensions (such as cl_khr_fp16) enabled.  This affects the
-fdeclare-opencl-builtins option for example.

This violates the OpenCL Extension Specification which specifies that
"The initial state of the compiler is as if the directive #pragma
OPENCL EXTENSION all : disable was issued".

Fix by disabling all extensions at the end of opencl-c-base.h and
enable extensions inside opencl.h which relied on opencl-c-base.h
enabling the cl_khr_fp16/64 extensions.

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

Added: 


Modified: 
clang/lib/Headers/opencl-c-base.h
clang/lib/Headers/opencl-c.h
clang/test/SemaOpenCL/half.cl

Removed: 




diff  --git a/clang/lib/Headers/opencl-c-base.h 
b/clang/lib/Headers/opencl-c-base.h
index 430e07d36f62..4c52ebed1709 100644
--- a/clang/lib/Headers/opencl-c-base.h
+++ b/clang/lib/Headers/opencl-c-base.h
@@ -568,4 +568,7 @@ typedef struct {
 #pragma OPENCL EXTENSION cl_intel_device_side_avc_motion_estimation : end
 #endif // cl_intel_device_side_avc_motion_estimation
 
+// Disable any extensions we may have enabled previously.
+#pragma OPENCL EXTENSION all : disable
+
 #endif //_OPENCL_BASE_H_

diff  --git a/clang/lib/Headers/opencl-c.h b/clang/lib/Headers/opencl-c.h
index 66e18bdd47bb..ab665628c8e1 100644
--- a/clang/lib/Headers/opencl-c.h
+++ b/clang/lib/Headers/opencl-c.h
@@ -4633,6 +4633,7 @@ float16 __ovld __cnfn convert_float16(float16);
 // Conversions with double data type parameters or return value.
 
 #ifdef cl_khr_fp64
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
 char __ovld __cnfn convert_char(double);
 char __ovld __cnfn convert_char_rte(double);
 char __ovld __cnfn convert_char_rtn(double);
@@ -5455,6 +5456,7 @@ double16 __ovld __cnfn convert_double16_rtz(ushort16);
 #endif //cl_khr_fp64
 
 #ifdef cl_khr_fp16
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
 // Convert half types to non-double types.
 uchar __ovld __cnfn convert_uchar(half);
 uchar __ovld __cnfn convert_uchar_rte(half);

diff  --git a/clang/test/SemaOpenCL/half.cl b/clang/test/SemaOpenCL/half.cl
index 2ea971c08510..50bbd745d2af 100644
--- a/clang/test/SemaOpenCL/half.cl
+++ b/clang/test/SemaOpenCL/half.cl
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -Wno-unused-value 
-triple spir-unknown-unknown
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -Wno-unused-value 
-triple spir-unknown-unknown -fdeclare-opencl-builtins -finclude-default-header
 
-#pragma OPENCL EXTENSION cl_khr_fp16 : disable
 constant float f = 1.0h; // expected-error{{half precision constant requires 
cl_khr_fp16}}
 
 half half_disabled(half *p, // expected-error{{declaring function return value 
of type 'half' is not allowed}}



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


[PATCH] D78903: [Driver] Add option -fproc-stat-report

2020-11-17 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

In D78903#2397845 , @tschuett wrote:

> Could you add quotation marks around the executable name to make the CSV file 
> easier to parse?

Implemented: rG9faedb2d7146 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78903

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


[PATCH] D91614: [clang-tidy] Fix a nullptr-access crash in unused-raii-check.

2020-11-17 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: gribozavr2.
Herald added a subscriber: xazax.hun.
Herald added a project: clang.
hokein requested review of this revision.

I saw this crash in our internal production, but unfortunately didn't get
reproduced testcase, we likely hit this crash when the AST is ill-formed
(e.g. broken code).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91614

Files:
  clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp


Index: clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp
@@ -79,12 +79,11 @@
   // written type.
   auto Matches =
   match(expr(hasDescendant(typeLoc().bind("t"))), *E, *Result.Context);
-  const auto *TL = selectFirst("t", Matches);
-  assert(TL);
-  D << FixItHint::CreateInsertion(
-  Lexer::getLocForEndOfToken(TL->getEndLoc(), 0, *Result.SourceManager,
- getLangOpts()),
-  Replacement);
+  if (const auto *TL = selectFirst("t", Matches))
+D << FixItHint::CreateInsertion(
+Lexer::getLocForEndOfToken(TL->getEndLoc(), 0, *Result.SourceManager,
+   getLangOpts()),
+Replacement);
 }
 
 } // namespace bugprone


Index: clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp
@@ -79,12 +79,11 @@
   // written type.
   auto Matches =
   match(expr(hasDescendant(typeLoc().bind("t"))), *E, *Result.Context);
-  const auto *TL = selectFirst("t", Matches);
-  assert(TL);
-  D << FixItHint::CreateInsertion(
-  Lexer::getLocForEndOfToken(TL->getEndLoc(), 0, *Result.SourceManager,
- getLangOpts()),
-  Replacement);
+  if (const auto *TL = selectFirst("t", Matches))
+D << FixItHint::CreateInsertion(
+Lexer::getLocForEndOfToken(TL->getEndLoc(), 0, *Result.SourceManager,
+   getLangOpts()),
+Replacement);
 }
 
 } // namespace bugprone
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D90441: [X86] Add support for vex, vex2, vex3, and evex for MASM

2020-11-17 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei added inline comments.



Comment at: clang/lib/AST/Stmt.cpp:795
+  SmallVector Pieces;
+  AsmStr.split(Pieces, "\n\t");
+  std::string MSAsmString;

Can we always assume the separator is `\n\t`?



Comment at: llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:3083
+  }
+  if (IsPrefix) {
+NameLoc = Parser.getTok().getLoc();

You just need to check `ForcedVEXEncoding != VEXEncoding_Default`.



Comment at: llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp:3084
+  if (IsPrefix) {
+NameLoc = Parser.getTok().getLoc();
+if (getLexer().isNot(AsmToken::Identifier))

Unused assignment. It may suppose to be used on line 3086.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90441

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


[clang] 0627140 - [clang][driver] Fix definition/declaration argument name mismatches. NFCI.

2020-11-17 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-11-17T12:39:45Z
New Revision: 0627140cd593e20b89b55e309c35c82ef618190e

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

LOG: [clang][driver] Fix definition/declaration argument name mismatches. NFCI.

AddCXXStdlibLibArgs args were using the names for the clang equivalent methods.

Silences cppcheck warnings.

Added: 


Modified: 
clang/lib/Driver/ToolChains/AIX.cpp
clang/lib/Driver/ToolChains/CrossWindows.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AIX.cpp 
b/clang/lib/Driver/ToolChains/AIX.cpp
index 7b5d7da8c873..36fe578fcb3d 100644
--- a/clang/lib/Driver/ToolChains/AIX.cpp
+++ b/clang/lib/Driver/ToolChains/AIX.cpp
@@ -216,11 +216,11 @@ void AIX::AddClangSystemIncludeArgs(const ArgList 
&DriverArgs,
   addSystemInclude(DriverArgs, CC1Args, UP.str());
 }
 
-void AIX::AddCXXStdlibLibArgs(const llvm::opt::ArgList &DriverArgs,
-  llvm::opt::ArgStringList &CC1Args) const {
-  switch (GetCXXStdlibType(DriverArgs)) {
+void AIX::AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
+  llvm::opt::ArgStringList &CmdArgs) const {
+  switch (GetCXXStdlibType(Args)) {
   case ToolChain::CST_Libcxx:
-CC1Args.push_back("-lc++");
+CmdArgs.push_back("-lc++");
 return;
   case ToolChain::CST_Libstdcxx:
 llvm::report_fatal_error("linking libstdc++ unimplemented on AIX");

diff  --git a/clang/lib/Driver/ToolChains/CrossWindows.cpp 
b/clang/lib/Driver/ToolChains/CrossWindows.cpp
index 28ad6c59c655..07abf4f83f7d 100644
--- a/clang/lib/Driver/ToolChains/CrossWindows.cpp
+++ b/clang/lib/Driver/ToolChains/CrossWindows.cpp
@@ -271,10 +271,10 @@ AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList 
&DriverArgs,
 }
 
 void CrossWindowsToolChain::
-AddCXXStdlibLibArgs(const llvm::opt::ArgList &DriverArgs,
-llvm::opt::ArgStringList &CC1Args) const {
-  if (GetCXXStdlibType(DriverArgs) == ToolChain::CST_Libcxx)
-CC1Args.push_back("-lc++");
+AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
+llvm::opt::ArgStringList &CmdArgs) const {
+  if (GetCXXStdlibType(Args) == ToolChain::CST_Libcxx)
+CmdArgs.push_back("-lc++");
 }
 
 clang::SanitizerMask CrossWindowsToolChain::getSupportedSanitizers() const {



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


[PATCH] D91592: [ASTMatchers] Fix typo for hasAnyOverloadedOperatorName

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

LGTM! Do you need me to commit on your behalf? If so, is `Keishi Hattori 
` the correct attribution you'd like me to use?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91592

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


[PATCH] D90944: [clang-tidy] implement misc-mt-unsafe

2020-11-17 Thread Vasily Kulikov via Phabricator via cfe-commits
segoon added inline comments.



Comment at: clang-tools-extra/clang-tidy/misc/MtUnsafeCheck.cpp:295
+  case MtUnsafeCheck::LibcType::Any:
+return hasAnyName(anyFunctions);
+  }

lebedev.ri wrote:
> return anyOf(hasAnyName(posixFunctions), hasAnyName(glibcFunctions));
It would be a bit slower than now - the current code removes duplicates. 
If/when other FunctionSets are added, duplicate list will be much bigger.



Comment at: clang-tools-extra/clang-tidy/misc/MtUnsafeCheck.cpp:309-310
+void MtUnsafeCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(callExpr(callee(functionDecl(hasAnyMtUnsafeNames(Libc
+ .bind("mt-unsafe"),
+ this);

lebedev.ri wrote:
> Is there any way to invert the direction of this matcher,
> instead of checking each call that it's callee isn't one of the bad ones,
> look through all function decls, and for all the bad ones, diagnose all calls 
> to them?
I'm not sure it is possible without additional costs - it would require somehow 
marking bad FunctionDecl, it requires an addition of state.

I'm not an expert in LLVM AST, maybe it is very cheap and easy to do, but I 
don't see how, do you?


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

https://reviews.llvm.org/D90944

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


[clang] d44edfc - [clang][NFC] Use SmallString instead of SmallVector

2020-11-17 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-11-17T13:02:58Z
New Revision: d44edfc1094ceece13e30e36dcc4a51b6eeebdaa

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

LOG: [clang][NFC] Use SmallString instead of SmallVector Buffer;
+SmallString<128> Buffer;
 llvm::raw_svector_ostream Out(Buffer);
 F->describe(Out);
 addDiag(CallLocation, diag::note_constexpr_call_here) << Out.str();

diff  --git a/clang/lib/AST/JSONNodeDumper.cpp 
b/clang/lib/AST/JSONNodeDumper.cpp
index a9136a903b98..7b99546bbe2d 100644
--- a/clang/lib/AST/JSONNodeDumper.cpp
+++ b/clang/lib/AST/JSONNodeDumper.cpp
@@ -1418,7 +1418,7 @@ void JSONNodeDumper::VisitFixedPointLiteral(const 
FixedPointLiteral *FPL) {
   JOS.attribute("value", FPL->getValueAsString(/*Radix=*/10));
 }
 void JSONNodeDumper::VisitFloatingLiteral(const FloatingLiteral *FL) {
-  llvm::SmallVector Buffer;
+  llvm::SmallString<16> Buffer;
   FL->getValue().toString(Buffer);
   JOS.attribute("value", Buffer);
 }

diff  --git a/clang/lib/Basic/Diagnostic.cpp b/clang/lib/Basic/Diagnostic.cpp
index 03ceca1262af..30a4c51b134b 100644
--- a/clang/lib/Basic/Diagnostic.cpp
+++ b/clang/lib/Basic/Diagnostic.cpp
@@ -808,7 +808,7 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd,
   /// QualTypeVals - Pass a vector of arrays so that QualType names can be
   /// compared to see if more information is needed to be printed.
   SmallVector QualTypeVals;
-  SmallVector Tree;
+  SmallString<64> Tree;
 
   for (unsigned i = 0, e = getNumArgs(); i < e; ++i)
 if (getArgKind(i) == DiagnosticsEngine::ak_qualtype)

diff  --git a/clang/lib/CrossTU/CrossTranslationUnit.cpp 
b/clang/lib/CrossTU/CrossTranslationUnit.cpp
index 80465c41d151..45a2a91616b8 100644
--- a/clang/lib/CrossTU/CrossTranslationUnit.cpp
+++ b/clang/lib/CrossTU/CrossTranslationUnit.cpp
@@ -162,8 +162,7 @@ parseCrossTUIndex(StringRef IndexPath) {
   StringRef LookupName = LineRef.substr(0, Delimiter);
 
   // Store paths with posix-style directory separator.
-  SmallVector FilePath;
-  llvm::Twine{LineRef.substr(Delimiter + 1)}.toVector(FilePath);
+  SmallString<32> FilePath(LineRef.substr(Delimiter + 1));
   llvm::sys::path::native(FilePath, llvm::sys::path::Style::posix);
 
   bool InsertionOccured;
@@ -624,15 +623,14 @@ parseInvocationList(StringRef FileContent, 
llvm::sys::path::Style PathStyle) {
   return llvm::make_error(
   index_error_code::invocation_list_wrong_format);
 
-SmallVector ValueStorage;
+SmallString<32> ValueStorage;
 StringRef SourcePath = Key->getValue(ValueStorage);
 
 // Store paths with PathStyle directory separator.
-SmallVector NativeSourcePath;
-llvm::Twine{SourcePath}.toVector(NativeSourcePath);
+SmallString<32> NativeSourcePath(SourcePath);
 llvm::sys::path::native(NativeSourcePath, PathStyle);
 
-StringRef InvocationKey{NativeSourcePath.begin(), NativeSourcePath.size()};
+StringRef InvocationKey(NativeSourcePath);
 
 if (InvocationList.find(InvocationKey) != InvocationList.end())
   return llvm::make_error(

diff  --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index 7effb152773c..3901c5e1fec8 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -1818,7 +1818,7 @@ bool Sema::findMacroSpelling(SourceLocation &locref, 
StringRef name) {
   loc = getSourceManager().getExpansionLoc(loc);
 
   // If that's written with the name, stop here.
-  SmallVector buffer;
+  SmallString<16> buffer;
   if (getPreprocessor().getSpelling(loc, buffer) == name) {
 locref = loc;
 return true;

diff  --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index 0b7fe0ca0672..e8e34c33e37b 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -584,7 +584,7 @@ void Sema::PrintInstantiationStack() {
 
 case CodeSynthesisContext::DefaultTemplateArgumentInstantiation: {
   TemplateDecl *Template = cast(Active->Template);
-  SmallVector TemplateArgsStr;
+  SmallString<128> TemplateArgsStr;
   llvm::raw_svector_ostream OS(TemplateArgsStr);
   Template->printName(OS);
   printTemplateArgumentList(OS, Active->template_arguments(),
@@ -650,7 +650,7 @@ void Sema::PrintInstantiationStack() {
   ParmVarDecl *Param = cast(Active->Entity);
   FunctionDecl *FD = cast(Param->getDeclContext());
 
-  SmallVector TemplateArgsStr;
+  SmallString<128> TemplateArgsStr;
   llvm::raw_svector_ostream OS(TemplateArgsStr);
   FD->printName(OS);
   printTemplateArgumentList(OS, Active->template_arguments(),
@@ -802,7 +802,7 @@ void Sema::PrintInstantiationStack() {
 assert(isa(Active->Entity));
 DiagID = diag::note_checking_constraints_for_function_here;
   }
-  SmallVector TemplateArgsStr;
+  Sma

[PATCH] D90944: [clang-tidy] implement misc-mt-unsafe

2020-11-17 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

Also can this be ran through clang-tidy, feeling a few naming violations are in 
here. If you use arc to upload your patches you'll get lint warnings about 
clang-tidy and clang-format.




Comment at: clang-tools-extra/clang-tidy/misc/MtUnsafeCheck.cpp:279-282
+  llvm::DenseSet result;
+  result.insert(std::begin(posixFunctions), std::end(posixFunctions));
+  result.insert(std::begin(glibcFunctions), std::end(glibcFunctions));
+  return {result.begin(), result.end()};

Would it not be faster to get rid of the set. Instead insert all the items in 
to a vector, then sort and unique it


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

https://reviews.llvm.org/D90944

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


[PATCH] D91543: [clang-tidy] Improving bugprone-sizeof-expr check.

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

LGTM aside from a testing request.




Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp:301
+  sum += sizeof(PtrArray) / sizeof(PtrArray[0]);
+  sum += sizeof(PtrArray) / sizeof(PtrArray1[0]);
   return sum;

I think this is missing some test coverage for cases like:
```
sum += sizeof(PtrArray) / sizeof(PtrArray[1]); // Bad array index
sum += sizeof(PtrArray) / sizeof(A[0]); // Different array types
```
Also, if you can add a comment to the `sum += sizeof(PtrArray) / 
sizeof(PtrArray1[0]);` test case about why this passes (same canonical types), 
that'd be appreciated since the test case is a bit subtle.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91543

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


[PATCH] D91625: [clang] Do not crash on pointer wchar_t pointer assignment.

2020-11-17 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
adamcz requested review of this revision.

wchar_t can be signed (thus hasSignedIntegerRepresentation() returns
true), but it doesn't have an unsigned type, which would lead to a crash
when trying to get it.

With this fix, we special-case WideChar types in the pointer assignment
code.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91625

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/wchar_t.cpp


Index: clang/test/SemaCXX/wchar_t.cpp
===
--- clang/test/SemaCXX/wchar_t.cpp
+++ clang/test/SemaCXX/wchar_t.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
-// RUN: %clang_cc1 -fsyntax-only -Wno-signed-unsigned-wchar 
-verify=allow-signed %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-signed-unsigned-wchar 
-verify=allow-signed -DSKIP_ERROR_TESTS %s
 // allow-signed-no-diagnostics
 wchar_t x;
 
@@ -32,3 +32,10 @@
 // rdar://8040728
 wchar_t in[] = L"\x434" "\x434";  // No warning
 
+#ifndef SKIP_ERROR_TESTS
+// Verify that we do not crash when assigning wchar_t* to another pointer type.
+void assignment(wchar_t *x) {
+  char *y;
+  y = x; // expected-error {{incompatible pointer types assigning to 'char *' 
from 'wchar_t *'}}
+}
+#endif
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -8722,12 +8722,14 @@
 // "unsigned char" on systems where "char" is unsigned.
 if (lhptee->isCharType())
   ltrans = S.Context.UnsignedCharTy;
-else if (lhptee->hasSignedIntegerRepresentation())
+else if (!lhptee->isWideCharType() &&
+ lhptee->hasSignedIntegerRepresentation())
   ltrans = S.Context.getCorrespondingUnsignedType(ltrans);
 
 if (rhptee->isCharType())
   rtrans = S.Context.UnsignedCharTy;
-else if (rhptee->hasSignedIntegerRepresentation())
+else if (!rhptee->isWideCharType() &&
+ rhptee->hasSignedIntegerRepresentation())
   rtrans = S.Context.getCorrespondingUnsignedType(rtrans);
 
 if (ltrans == rtrans) {


Index: clang/test/SemaCXX/wchar_t.cpp
===
--- clang/test/SemaCXX/wchar_t.cpp
+++ clang/test/SemaCXX/wchar_t.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
-// RUN: %clang_cc1 -fsyntax-only -Wno-signed-unsigned-wchar -verify=allow-signed %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-signed-unsigned-wchar -verify=allow-signed -DSKIP_ERROR_TESTS %s
 // allow-signed-no-diagnostics
 wchar_t x;
 
@@ -32,3 +32,10 @@
 // rdar://8040728
 wchar_t in[] = L"\x434" "\x434";  // No warning
 
+#ifndef SKIP_ERROR_TESTS
+// Verify that we do not crash when assigning wchar_t* to another pointer type.
+void assignment(wchar_t *x) {
+  char *y;
+  y = x; // expected-error {{incompatible pointer types assigning to 'char *' from 'wchar_t *'}}
+}
+#endif
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -8722,12 +8722,14 @@
 // "unsigned char" on systems where "char" is unsigned.
 if (lhptee->isCharType())
   ltrans = S.Context.UnsignedCharTy;
-else if (lhptee->hasSignedIntegerRepresentation())
+else if (!lhptee->isWideCharType() &&
+ lhptee->hasSignedIntegerRepresentation())
   ltrans = S.Context.getCorrespondingUnsignedType(ltrans);
 
 if (rhptee->isCharType())
   rtrans = S.Context.UnsignedCharTy;
-else if (rhptee->hasSignedIntegerRepresentation())
+else if (!rhptee->isWideCharType() &&
+ rhptee->hasSignedIntegerRepresentation())
   rtrans = S.Context.getCorrespondingUnsignedType(rtrans);
 
 if (ltrans == rtrans) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91625: [clang] Do not crash on pointer wchar_t pointer assignment.

2020-11-17 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz updated this revision to Diff 305752.
adamcz added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91625

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/wchar_t.cpp


Index: clang/test/SemaCXX/wchar_t.cpp
===
--- clang/test/SemaCXX/wchar_t.cpp
+++ clang/test/SemaCXX/wchar_t.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
-// RUN: %clang_cc1 -fsyntax-only -Wno-signed-unsigned-wchar 
-verify=allow-signed %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-signed-unsigned-wchar 
-verify=allow-signed -DSKIP_ERROR_TESTS %s
 // allow-signed-no-diagnostics
 wchar_t x;
 
@@ -32,3 +32,10 @@
 // rdar://8040728
 wchar_t in[] = L"\x434" "\x434";  // No warning
 
+#ifndef SKIP_ERROR_TESTS
+// Verify that we do not crash when assigning wchar_t* to another pointer type.
+void assignment(wchar_t *x) {
+  char *y;
+  y = x; // expected-error {{incompatible pointer types assigning to 'char *' 
from 'wchar_t *'}}
+}
+#endif
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -8722,12 +8722,14 @@
 // "unsigned char" on systems where "char" is unsigned.
 if (lhptee->isCharType())
   ltrans = S.Context.UnsignedCharTy;
-else if (lhptee->hasSignedIntegerRepresentation())
+else if (!lhptee->isWideCharType() &&
+ lhptee->hasSignedIntegerRepresentation())
   ltrans = S.Context.getCorrespondingUnsignedType(ltrans);
 
 if (rhptee->isCharType())
   rtrans = S.Context.UnsignedCharTy;
-else if (rhptee->hasSignedIntegerRepresentation())
+else if (!rhptee->isWideCharType() &&
+ rhptee->hasSignedIntegerRepresentation())
   rtrans = S.Context.getCorrespondingUnsignedType(rtrans);
 
 if (ltrans == rtrans) {


Index: clang/test/SemaCXX/wchar_t.cpp
===
--- clang/test/SemaCXX/wchar_t.cpp
+++ clang/test/SemaCXX/wchar_t.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
-// RUN: %clang_cc1 -fsyntax-only -Wno-signed-unsigned-wchar -verify=allow-signed %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-signed-unsigned-wchar -verify=allow-signed -DSKIP_ERROR_TESTS %s
 // allow-signed-no-diagnostics
 wchar_t x;
 
@@ -32,3 +32,10 @@
 // rdar://8040728
 wchar_t in[] = L"\x434" "\x434";  // No warning
 
+#ifndef SKIP_ERROR_TESTS
+// Verify that we do not crash when assigning wchar_t* to another pointer type.
+void assignment(wchar_t *x) {
+  char *y;
+  y = x; // expected-error {{incompatible pointer types assigning to 'char *' from 'wchar_t *'}}
+}
+#endif
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -8722,12 +8722,14 @@
 // "unsigned char" on systems where "char" is unsigned.
 if (lhptee->isCharType())
   ltrans = S.Context.UnsignedCharTy;
-else if (lhptee->hasSignedIntegerRepresentation())
+else if (!lhptee->isWideCharType() &&
+ lhptee->hasSignedIntegerRepresentation())
   ltrans = S.Context.getCorrespondingUnsignedType(ltrans);
 
 if (rhptee->isCharType())
   rtrans = S.Context.UnsignedCharTy;
-else if (rhptee->hasSignedIntegerRepresentation())
+else if (!rhptee->isWideCharType() &&
+ rhptee->hasSignedIntegerRepresentation())
   rtrans = S.Context.getCorrespondingUnsignedType(rtrans);
 
 if (ltrans == rtrans) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D90944: [clang-tidy] implement misc-mt-unsafe

2020-11-17 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: clang-tools-extra/clang-tidy/misc/MtUnsafeCheck.cpp:279-282
+  llvm::DenseSet result;
+  result.insert(std::begin(posixFunctions), std::end(posixFunctions));
+  result.insert(std::begin(glibcFunctions), std::end(glibcFunctions));
+  return {result.begin(), result.end()};

njames93 wrote:
> Would it not be faster to get rid of the set. Instead insert all the items in 
> to a vector, then sort and unique it
I can't imagine this will have measurable performance difference.
The main problem is algorithmic, https://reviews.llvm.org/D90944#inline-853246

But my main point is 
https://llvm.org/docs/CodingStandards.html#do-not-use-static-constructors


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

https://reviews.llvm.org/D90944

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


[PATCH] D90851: [clang-tidy] Extending bugprone-signal-handler with POSIX functions.

2020-11-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/system-header-posix-api.h:1
-//===--- signal.h - Stub header for tests ---*- C++ 
-*-===//
+//===--- system-header-posix-api.h - Stub header for tests --*- C++ 
-*-===//
 //

balazske wrote:
> aaron.ballman wrote:
> > balazske wrote:
> > > aaron.ballman wrote:
> > > > I think we should strive to replicate the system headers rather than 
> > > > fake up a system header (these headers can be used by more than one 
> > > > check). So I think we want to keep signal.h and stdlib.h, and should 
> > > > include the POSIX-specific functionality with a macro. This also helps 
> > > > us test the behavior on systems like Windows which are not POSIX 
> > > > systems.
> > > My concern was to add these many small header files with just some 
> > > functions in them. For `accept` more than one header is needed if we want 
> > > to exactly replicate the system files. And data types like `size_t` 
> > > should have a common header too. So I decided to have one header that 
> > > contains all system functions and data types. This can be used by 
> > > multiple tests and extended as needed.
> > I don't think we're too worried about having a bunch of small test headers 
> > around -- I think it's more important the headers used to check system 
> > header behavior be understandable as to what you're getting from them. For 
> > instance, there are clang-tidy checks for llvm-libc that may have very 
> > different needs from what you're doing here.
> > 
> > What's more, these changes break existing tests -- I don't see any 
> > companion changes to fix those up.
> On my system (Ubuntu) I do not see failing tests, and these changes do not 
> touch files that were created before D87449, no new problems should happen. I 
> am not against "mirroring" the POSIX API header structure into the test stub 
> header structure, only do not like the overhead of adding these many files 
> with just 1-2 lines (that is needed for this test) in them. It is not done 
> this way in the clang tests either (there are multiple 
> "system-header-simulator" files that contain every declaration usable for 
> specific purposes at one or more tests). Also I want to have the opinion of 
> another reviewer for this question.
> On my system (Ubuntu) I do not see failing tests, and these changes do not 
> touch files that were created before D87449, no new problems should happen.

You renamed stdlib.h and `lllvmlibc-restrict-system-libc-headers.cpp` includes 
`stdlib.h`, but after closer inspection, I see now that it's including one from 
a different directory. So this doesn't break the things I thought it was 
breaking, good!

> Also I want to have the opinion of another reviewer for this question.

I'm happy to go with whatever @alexfh thinks.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90851

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


[PATCH] D89869: [OpenCL] Define OpenCL feature macros for all versions

2020-11-17 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/include/clang/Basic/OpenCLExtensions.def:100
+// OpenCL features
+OPENCLFEAT_INTERNAL(__opencl_c_pipes, 200, ~0U)
+OPENCLFEAT_INTERNAL(__opencl_c_generic_address_space, 200, ~0U)

azabaznov wrote:
> Anastasia wrote:
> > Btw I guess we don't need the last parameter for the features since it's 
> > always 0?
> This need to be restructured at all, now I just wanted to be consistent. I 
> think there was wrong interpretation of "core extension" concept. //Core 
> //means nothing more than it was just promoted to core specification, not 
> supported by default starting from specific OpenCL version. Am I missing 
> something in the spec? However, I'm not sure if we need to reimplement this 
> to maintain backward compatibility... Anyway, I'll try to remove it from 
> features.
> This need to be restructured at all, now I just wanted to be consistent. I 
> think there was wrong interpretation of "core extension" concept. Core means 
> nothing more than it was just promoted to core specification, not supported 
> by default starting from specific OpenCL version. 

Good question! I don't think spec ever explained what it means. This is 
possibly one of multiple interpretations and it won't be easy to change but it 
would help if spec clarifies it. Potentially we can point out the 
interpretation from clang implementation. Perhaps it will be taken into 
account. 



Comment at: clang/include/clang/Basic/OpenCLOptions.h:37
+  // OpenCL Version
+  unsigned CLVer = 120;
+  bool IsOpenCLCPlusPlus = false;

azabaznov wrote:
> Anastasia wrote:
> > Ok, I see why you are adding this field but I am not very happy with it. 
> > However, if you prefer to keep it I suggest to add a comment otherwise it 
> > is mislediang because ideally in Clang we should be using versions from the 
> > LangOpts everywhere. Alternatively we could consider a helper function to 
> > calculate the version although it doesn't eliminate the need to the comment.
> > However, if you prefer to keep it I suggest to add a comment otherwise it 
> > is mislediang because ideally in Clang we should be using versions from the 
> > LangOpts everywhere
> 
> The reason for this is that `LangOptions` is not always available for proper 
> settings. So this just needed internally. Also, we could add 
> `TargetInfo::setOpenCLOptions(const LangOptions &Opts)` where we can set all 
> extensions/features in one step (invoke `::setSupportedOpenCLOpts` and 
> `::setOpenCLExtensionOpts`) to make sure `OpenCLOptions` will get proper 
> OpenCL version. What do you think of that?
Yes this feels neater!



Comment at: clang/include/clang/Basic/OpenCLOptions.h:51
+  // check specific version of feature)
+  void supportFeatureForPreOCL30(StringRef Feat, bool On = true) {
+assert(CLVer < 300 && "Can'be called for OpenCL C higher 3.0");

azabaznov wrote:
> Anastasia wrote:
> > I find the name of this function very confusing but I can't think of any 
> > better one. Also the flow is becoming harder to understand to be honest. 
> > This function is not as straight forward as `support` because it might not 
> > actually do what is expected from it. I wonder if the name with something 
> > like `adjust` would be more appropriate. At the same time `adjustFeatures` 
> > is the only place where we need to check for the version. Perhaps you can 
> > just do the language version check straight in `adjustFeatures`?
> > 
> > Overall, let's just get clear about the flow of setting the features and 
> > extensions. If in `adjustFeatures` we set default features supported in a 
> > certain language version then targets can set the other features. Now let's 
> > examine what should happen with the features and extensions on the 
> > following use cases:
> > - Do we always set the equivalent extension when the feature is being set 
> > by the target?
> > - Do we always set the equivalent feature when the extension is being set 
> > by the target?
> > - What happens when equivalent features and extensions are set but to 
> > different values?
> > - What if targets set core feature/extension to unsupported?
> > - How does `-cl-ext` modify core features/extensions and equivalent 
> > features+extensions?
> > 
> > I am a bit worried about the fact that we have different items for the same 
> > optional functionality in `OpenCLOptions` as it might be a nightmare to 
> > keep them consistent. We can however also choose a path of not keeping them 
> > consistent in the common code and rely on targets to set them up correctly.
> > 
> > Initially, when we discussed adding feature macros to earlier standards I 
> > was thinking of simplifying the design. For example instead of checking for 
> > extension macros and feature macros in the header when declaring certain 
> > functions we could only check for one of those. The question whether we can 
> > re

[PATCH] D18914: [clang-tidy] new readability-redundant-inline

2020-11-17 Thread Paweł Bylica via Phabricator via cfe-commits
chfast added a comment.

This check can be useful in other case like this:

  inline constexpr const int x = 1;

where `inline` and `const` are redundant.


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

https://reviews.llvm.org/D18914

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


[clang] 6976fef - Update 'note-candiate' functions to skip lambda-conversion-op-overloads

2020-11-17 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2020-11-17T05:49:31-08:00
New Revision: 6976fef05b7e5301815baa6cc4af27284e8aceb4

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

LOG: Update 'note-candiate' functions to skip lambda-conversion-op-overloads

In the wake of https://reviews.llvm.org/D89559, we discovered that a
couple of tests (the ones modified below to have additional triple
versions) would fail on Win32, for 1 of two reasons.  We seem to not
have a win32 buildbot anymore, so the triple is to make sure this
doesn't get broken in the future.

First, two of the three 'note-candidate' functions weren't appropriately
skipping the remaining conversion functions.

Second, in 1 situation (note surrogate candidates) we actually print the
type of the conversion operator.  The two tests that ran into that
needed updating to make sure it printed the proper one in the win32
case.

Added: 


Modified: 
clang/lib/Sema/SemaOverload.cpp
clang/test/CXX/expr/expr.prim/expr.prim.lambda/default-arguments.cpp
clang/test/CXX/expr/expr.prim/expr.prim.lambda/p6.cpp
clang/test/SemaCXX/cxx1y-generic-lambdas-capturing.cpp
clang/test/SemaCXX/cxx1y-generic-lambdas-variadics.cpp
clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
clang/test/SemaOpenCLCXX/address-space-lambda.cl

Removed: 




diff  --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 847f0dd977b73..11fa0a634492a 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -10217,6 +10217,27 @@ bool Sema::checkAddressOfFunctionIsAvailable(const 
FunctionDecl *Function,
  Loc);
 }
 
+// Don't print candidates other than the one that matches the calling
+// convention of the call operator, since that is guaranteed to exist.
+static bool shouldSkipNotingLambdaConversionDecl(FunctionDecl *Fn) {
+  const auto *ConvD = dyn_cast(Fn);
+
+  if (!ConvD)
+return false;
+  const auto *RD = cast(Fn->getParent());
+  if (!RD->isLambda())
+return false;
+
+  CXXMethodDecl *CallOp = RD->getLambdaCallOperator();
+  CallingConv CallOpCC =
+  CallOp->getType()->getAs()->getCallConv();
+  QualType ConvRTy = ConvD->getType()->getAs()->getReturnType();
+  CallingConv ConvToCC =
+  ConvRTy->getPointeeType()->getAs()->getCallConv();
+
+  return ConvToCC != CallOpCC;
+}
+
 // Notes the location of an overload candidate.
 void Sema::NoteOverloadCandidate(NamedDecl *Found, FunctionDecl *Fn,
  OverloadCandidateRewriteKind RewriteKind,
@@ -10226,22 +10247,8 @@ void Sema::NoteOverloadCandidate(NamedDecl *Found, 
FunctionDecl *Fn,
   if (Fn->isMultiVersion() && Fn->hasAttr() &&
   !Fn->getAttr()->isDefaultVersion())
 return;
-  if (isa(Fn) &&
-  cast(Fn->getParent())->isLambda()) {
-// Don't print candidates other than the one that matches the calling
-// convention of the call operator, since that is guaranteed to exist.
-const auto *RD = cast(Fn->getParent());
-CXXMethodDecl *CallOp = RD->getLambdaCallOperator();
-CallingConv CallOpCC =
-CallOp->getType()->getAs()->getCallConv();
-CXXConversionDecl *ConvD = cast(Fn);
-QualType ConvRTy = 
ConvD->getType()->getAs()->getReturnType();
-CallingConv ConvToCC =
-ConvRTy->getPointeeType()->getAs()->getCallConv();
-
-if (ConvToCC != CallOpCC)
-  return;
-  }
+  if (shouldSkipNotingLambdaConversionDecl(Fn))
+return;
 
   std::string FnDesc;
   std::pair KSPair =
@@ -11101,6 +11108,8 @@ static void NoteFunctionCandidate(Sema &S, 
OverloadCandidate *Cand,
   bool TakingCandidateAddress,
   LangAS CtorDestAS = LangAS::Default) {
   FunctionDecl *Fn = Cand->Function;
+  if (shouldSkipNotingLambdaConversionDecl(Fn))
+return;
 
   // Note deleted candidates, but only if they're viable.
   if (Cand->Viable) {
@@ -11217,6 +11226,9 @@ static void NoteFunctionCandidate(Sema &S, 
OverloadCandidate *Cand,
 }
 
 static void NoteSurrogateCandidate(Sema &S, OverloadCandidate *Cand) {
+  if (shouldSkipNotingLambdaConversionDecl(Cand->Surrogate))
+return;
+
   // Desugar the type of the surrogate down to a function type,
   // retaining as many typedefs as possible while still showing
   // the function type (and, therefore, its parameter types).

diff  --git 
a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/default-arguments.cpp 
b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/default-arguments.cpp
index 9b0a9ad8c2573..5d3c63f92c287 100644
--- a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/default-arguments.cpp
+++ b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/default-arguments.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -v

[PATCH] D91602: [clang-tidy] Make clang-format and include-order-check coherent

2020-11-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5a9f3867046c: [clang-tidy] Make clang-format and 
include-order-check coherent (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91602

Files:
  clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/gmock/foo.h
  clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp
@@ -3,6 +3,7 @@
 // CHECK-MESSAGES: [[@LINE+2]]:1: warning: #includes are not sorted properly
 #include "j.h"
 #include "gtest/foo.h"
+#include "gmock/foo.h"
 #include "i.h"
 #include 
 #include "llvm/a.h"
@@ -16,6 +17,7 @@
 // CHECK-FIXES-NEXT: #include "clang/b.h"
 // CHECK-FIXES-NEXT: #include "llvm-c/d.h" // -c
 // CHECK-FIXES-NEXT: #include "llvm/a.h"
+// CHECK-FIXES-NEXT: #include "gmock/foo.h"
 // CHECK-FIXES-NEXT: #include "gtest/foo.h"
 // CHECK-FIXES-NEXT: #include 
 
Index: clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
===
--- clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
+++ clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
@@ -67,7 +67,8 @@
 return 2;
 
   // System headers are sorted to the end.
-  if (IsAngled || Filename.startswith("gtest/"))
+  if (IsAngled || Filename.startswith("gtest/") ||
+  Filename.startswith("gmock/"))
 return 3;
 
   // Other headers are inserted between the main module header and LLVM 
headers.


Index: clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp
@@ -3,6 +3,7 @@
 // CHECK-MESSAGES: [[@LINE+2]]:1: warning: #includes are not sorted properly
 #include "j.h"
 #include "gtest/foo.h"
+#include "gmock/foo.h"
 #include "i.h"
 #include 
 #include "llvm/a.h"
@@ -16,6 +17,7 @@
 // CHECK-FIXES-NEXT: #include "clang/b.h"
 // CHECK-FIXES-NEXT: #include "llvm-c/d.h" // -c
 // CHECK-FIXES-NEXT: #include "llvm/a.h"
+// CHECK-FIXES-NEXT: #include "gmock/foo.h"
 // CHECK-FIXES-NEXT: #include "gtest/foo.h"
 // CHECK-FIXES-NEXT: #include 
 
Index: clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
===
--- clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
+++ clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
@@ -67,7 +67,8 @@
 return 2;
 
   // System headers are sorted to the end.
-  if (IsAngled || Filename.startswith("gtest/"))
+  if (IsAngled || Filename.startswith("gtest/") ||
+  Filename.startswith("gmock/"))
 return 3;
 
   // Other headers are inserted between the main module header and LLVM headers.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 5a9f386 - [clang-tidy] Make clang-format and include-order-check coherent

2020-11-17 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-11-17T14:54:10+01:00
New Revision: 5a9f3867046c4e1c97760e22a505f4d1d788417e

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

LOG: [clang-tidy] Make clang-format and include-order-check coherent

LLVM style puts both gtest and gmock to the end of the include list.
But llvm-include-order-check was only moving gtest headers to the end, resulting
in a false tidy-warning.

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

Added: 
clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/gmock/foo.h

Modified: 
clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp 
b/clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
index 834a49a51d60..c962fb3bc25b 100644
--- a/clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
+++ b/clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
@@ -67,7 +67,8 @@ static int getPriority(StringRef Filename, bool IsAngled, 
bool IsMainModule) {
 return 2;
 
   // System headers are sorted to the end.
-  if (IsAngled || Filename.startswith("gtest/"))
+  if (IsAngled || Filename.startswith("gtest/") ||
+  Filename.startswith("gmock/"))
 return 3;
 
   // Other headers are inserted between the main module header and LLVM 
headers.

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/gmock/foo.h 
b/clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/gmock/foo.h
new file mode 100644
index ..e69de29bb2d1

diff  --git a/clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp
index 7272353bedcb..6dd3d6ace458 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp
@@ -3,6 +3,7 @@
 // CHECK-MESSAGES: [[@LINE+2]]:1: warning: #includes are not sorted properly
 #include "j.h"
 #include "gtest/foo.h"
+#include "gmock/foo.h"
 #include "i.h"
 #include 
 #include "llvm/a.h"
@@ -16,6 +17,7 @@
 // CHECK-FIXES-NEXT: #include "clang/b.h"
 // CHECK-FIXES-NEXT: #include "llvm-c/d.h" // -c
 // CHECK-FIXES-NEXT: #include "llvm/a.h"
+// CHECK-FIXES-NEXT: #include "gmock/foo.h"
 // CHECK-FIXES-NEXT: #include "gtest/foo.h"
 // CHECK-FIXES-NEXT: #include 
 



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


[PATCH] D91311: Add new 'preferred_name' attribute.

2020-11-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D91311#2398526 , @rsmith wrote:

> In D91311#2398144 , @ldionne wrote:
>
>> I think that the fact we need to re declare everything shows how the 
>> ergonomics would be better if we could just add the attribute to the 
>> typedef. See for example how we're re-declaring a bunch of stuff in 
>> ``. How bad of an idea is it to try putting the attribute on 
>> typedefs instead, and how strongly are you opposed to it? Because from a 
>> naive user perspective, having to redeclare the class with a closed set of 
>> preferred names feels awkward (IMO, of course).

FWIW, I'd be pretty strongly opposed to putting the attribute on the typedef 
instead, for all the reasons Richard points out. It's the wrong subject for the 
attribute given the semantics of how the attribute behaves and I'd liken it 
somewhat to writing an attribute on a function declaration when the semantics 
of the attribute impact a parameter of the function instead. While the function 
and its parameter are certainly related (more strongly than the template and 
the typedef in this case), it's just the wrong place to write the attribute.

> How much should we concern ourselves with ergonomics in this instance? Most 
> of the intended uses of this attribute (at least by how often they'll affect 
> diagnostics) are included in this patch, and are in code that we don't expect 
> many people to look at most of the time, that is maintained by domain 
> experts, and that is generally optimized for other properties than 
> readability. However, this is certainly intended to be used by third-party 
> library authors; otherwise we could just add a hard-coded table to Clang 
> itself. So I think ergonomics do matter a little, but that other factors are 
> probably more important.

I think the ergonomics matter because it's a documented attribute that people 
will use outside of the STL, but I don't imagine this being an attribute that 
gets written frequently. I'm fine if the usage is a bit verbose in this case.

> We could allow the attribute on typedefs, and internally reverse the sense of 
> it and attach it to the template specialization instead, but that would be 
> incredibly messy -- in order to maintain AST invariants and source fidelity, 
> we'd need to synthesize a new declaration of the template specialization to 
> attach the attribute to, or something similar. We'd still need the attribute 
> to appear before the template definition, though -- unless we rework how 
> attribute instantiation is done -- so that's not really a general solution to 
> the ergonomics issue. Or we could store a side-table, which would also bring 
> with it a lot of complexity, particularly when we come to lazily load such 
> information from module files. In my view, the added implementation 
> complexity from attaching the attribute to a typedef outweighs the ergonomic 
> benefit.
>
> There's another design approach we could follow, that would keep the 
> attribute on the template but avoid the awkwardness of requiring the typedef 
> to appear first: we could completely divorce this feature from typedefs. 
> Instead, we could say the attribute is of the form `preferred_name(type, 
> "name")`, where `type` is a specialization of the type to which the attribute 
> is attached, and `"name"` is a name used in diagnostics when referring to 
> that type, which is printed as if it's a member of the enclosing namespace 
> (but there'd be no enforcement that such a member actually exists and 
> declares the corresponding type). What do you think?

I'm not opposed to that approach, but I don't think the design is as nice as 
what's originally proposed in terms of behavior. With the current approach, the 
name that gets used in diagnostics is one that shows up in the code as an 
actual declaration of something and I think that's a useful property to 
enforce. I don't like a design where the user can write an arbitrary string 
literal that has no enforcement that it actually names a type in the user's 
program. While doing such a thing is up to the author of the attribute and so 
it's sort of a "well then don't do that if it's nonsense" situation, it's also 
not hard to get accidental typos that slip through code reviews but would be 
caught by using the actual type system itself (which provides extra value like 
diagnostics about the mistake or possible typo correction).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91311

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


[PATCH] D91410: [llvm][clang][mlir] Add checks for the return values from Target::createXXX to prevent protential null deref

2020-11-17 Thread Alex Zinenko via Phabricator via cfe-commits
ftynse added a comment.
Herald added a subscriber: teijeong.

LGTM for the MLIR part


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91410

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


[PATCH] D91262: [AArch64][SVE] Allow C-style casts between fixed-size and scalable vectors

2020-11-17 Thread Joe Ellis via Phabricator via cfe-commits
joechrisellis updated this revision to Diff 305763.
joechrisellis marked 7 inline comments as done.
joechrisellis added a comment.

Address @c-rhodes's and @peterwaller-arm's comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91262

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/aarch64-sve-explicit-casts-fixed-size.c
  clang/test/SemaCXX/aarch64-sve-explicit-casts-fixed-size.cpp

Index: clang/test/SemaCXX/aarch64-sve-explicit-casts-fixed-size.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/aarch64-sve-explicit-casts-fixed-size.cpp
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=128 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=256 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=512 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=1024 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=2048 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+
+#include 
+
+#define N __ARM_FEATURE_SVE_BITS
+#define FIXED_ATTR __attribute__((arm_sve_vector_bits(N)))
+
+typedef svfloat32_t fixed_float32_t FIXED_ATTR;
+typedef svfloat64_t fixed_float64_t FIXED_ATTR;
+typedef svint32_t fixed_int32_t FIXED_ATTR;
+typedef svint64_t fixed_int64_t FIXED_ATTR;
+
+// SVE VLSTs can be cast to SVE VLATs, regardless of lane size.
+// NOTE: the list below is NOT exhaustive for all SVE types.
+
+#define CAST(from, to) \
+void from##_to_##to(from a, to b) { \
+b = (to) a; \
+}
+
+#define TESTCASE(ty1, ty2) \
+CAST(ty1, ty2) \
+CAST(ty2, ty1)
+
+TESTCASE(fixed_float32_t, svfloat32_t)
+TESTCASE(fixed_float32_t, svfloat64_t)
+TESTCASE(fixed_float32_t, svint32_t)
+TESTCASE(fixed_float32_t, svint64_t)
+
+TESTCASE(fixed_float64_t, svfloat32_t)
+TESTCASE(fixed_float64_t, svfloat64_t)
+TESTCASE(fixed_float64_t, svint32_t)
+TESTCASE(fixed_float64_t, svint64_t)
+
+TESTCASE(fixed_int32_t, svfloat32_t)
+TESTCASE(fixed_int32_t, svfloat64_t)
+TESTCASE(fixed_int32_t, svint32_t)
+TESTCASE(fixed_int32_t, svint64_t)
+
+TESTCASE(fixed_int64_t, svfloat32_t)
+TESTCASE(fixed_int64_t, svfloat64_t)
+TESTCASE(fixed_int64_t, svint32_t)
+TESTCASE(fixed_int64_t, svint64_t)
Index: clang/test/Sema/aarch64-sve-explicit-casts-fixed-size.c
===
--- /dev/null
+++ clang/test/Sema/aarch64-sve-explicit-casts-fixed-size.c
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=128 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=256 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=512 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=1024 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=2048 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+
+#include 
+
+#define N __ARM_FEATURE_SVE_BITS
+#define FIXED_ATTR __attribute__((arm_sve_vector_bits(N)))
+
+typedef svfloat32_t fixed_float32_t FIXED_ATTR;
+typedef svfloat64_t fixed_float64_t FIXED_ATTR;
+typedef svint32_t fixed_int32_t FIXED_ATTR;
+typedef svint64_t fixed_int64_t FIXED_ATTR;
+
+// SVE VLSTs can be cast to SVE VLATs, regardless of lane size.
+// NOTE: the list below is NOT exhaustive for all SVE types.
+
+#define CAST(from, to) \
+void from##_to_##to(from a, to b) { \
+b = (to) a; \
+}
+
+#define TESTCASE(ty1, ty2) \
+CAST(ty1, ty2) \
+CAST(ty2, ty1)
+
+TESTCASE(fixed_float32_t, svfloat32_t)
+TESTCASE(fixed_float32_t, svfloat64_t)
+TESTCASE(fixed_float32_t, svint32_t)
+

[PATCH] D91262: [AArch64][SVE] Allow C-style casts between fixed-size and scalable vectors

2020-11-17 Thread Joe Ellis via Phabricator via cfe-commits
joechrisellis added inline comments.



Comment at: clang/lib/Sema/SemaCast.cpp:2217-2218
 
-  // Allow reinterpret_casts between vectors of the same size and
-  // between vectors and integers of the same size.
   bool destIsVector = DestType->isVectorType();

c-rhodes wrote:
> nit: not sure we need to change this
I changed this because the code changes mean that the original comment is 
incomplete. I.e., we now allow for reinterpret casts VLAT <-> VLST, which is 
not captured by the comment above.



Comment at: clang/lib/Sema/SemaCast.cpp:2763
+  // SVE bitcast. We can bitcast between SVE VLATs and VLSTs, and vice-versa.
+  if (SrcType->isVectorType() || DestType->isVectorType())
+if (Self.isValidSveBitcast(SrcType, DestType)) {

peterwaller-arm wrote:
> c-rhodes wrote:
> > I think braces are recommended on the outer if as well, see: 
> > https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements
> > 
> > Although I suppose it could also be written as:
> > 
> > ```
> > if ((SrcType->isVectorType() || DestType->isVectorType()) &&
> > Self.isValidSveBitcast(SrcType, DestType)) {
> >   Kind = CK_BitCast;
> >   return;
> > }```
> I don't understand why this is an || rather than an &&, please can you 
> clarify? I would have expected they must both be vectors.
The sizeless types defined by the ACLE are represented in Clang as 
`BuiltinType`s rather than `VectorType`s. The sized types are represented as 
`VectorTypes`. The only possibility for a valid C-style cast is when we're 
casting VLAT <-> VLST, which is if one of the two is a `VectorType`. :) 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91262

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


[PATCH] D91610: [clangd] Add OverridenBy Relation to index.

2020-11-17 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

Thanks! I think we need to bump the index version number (in 
`index/Serialization.cpp`) in order to let the index pick up this change.




Comment at: clang-tools-extra/clangd/index/Relation.h:29
 /// For an example "A is a base class of B" may be represented
 /// as { Subject = A, Predicate = BaseOf, Object = B }.
 struct Relation {

nit: can you add an override example here?



Comment at: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp:879
   } TestCases[] = {
-{
-  R"cpp(
+  {
+  R"cpp(

looks like these changes are unexpected?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91610

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


[PATCH] D91410: [llvm][clang][mlir] Add checks for the return values from Target::createXXX to prevent protential null deref

2020-11-17 Thread Clement Courbet via Phabricator via cfe-commits
courbet added a comment.

LGTM for llvm-exegesis


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91410

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


[PATCH] D91626: [clangd] Implement textDocument/implementation.

2020-11-17 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 created this revision.
Herald added subscribers: cfe-commits, kadircet, arphaman.
Herald added a project: clang.
usaxena95 requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91626

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/XRefs.h
  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
@@ -41,6 +41,7 @@
 using ::testing::Eq;
 using ::testing::IsEmpty;
 using ::testing::Matcher;
+using ::testing::Not;
 using ::testing::UnorderedElementsAre;
 using ::testing::UnorderedElementsAreArray;
 
@@ -1161,7 +1162,7 @@
 )cpp",
   };
 
-  for (const auto* Case : Tests) {
+  for (const auto *Case : Tests) {
 SCOPED_TRACE(Case);
 auto T = Annotations(Case);
 auto AST = TestTU::withCode(T.code()).build();
@@ -1464,6 +1465,69 @@
   }
 }
 
+// TEST(FindImplementations, Inheritance) {
+//   llvm::StringRef Test = R"cpp(
+// struct Base {
+//   virtual void F$1^oo();
+// };
+// struct Sub1 : Base {
+//   void $1[[Foo]]() override;
+//   virtual void Bar();
+// };
+// struct Sub2 : Base {
+//   void $1[[Foo]]() override;
+//   virtual void Baz();
+// };
+// struct Sub12: Sub1, Sub2 {
+//   void $1[[Foo]]() override;
+//   void Bar() override;
+//   void Baz() override;
+// };
+
+// void FromReference() {
+//   Base* B;
+//   B->Fo$1^o();
+// }
+//   )cpp";
+
+//   Annotations Code(Test);
+//   auto TU = TestTU::withCode(Code.code());
+//   auto AST = TU.build();
+
+//   std::vector> ExpectedLocations;
+//   for (const auto &R : Code.ranges("1"))
+// ExpectedLocations.push_back(RangeIs(R));
+//   for (const auto &Point : Code.points("1")) {
+// EXPECT_THAT(findImplementations(AST, Point, TU.index().get()).References,
+// UnorderedElementsAreArray(ExpectedLocations))
+// << Test << " at" << Point;
+//   }
+// }
+
+// TEST(FindImplementations, BaseTemplateDoesNotWork) {
+//   std::string Test = R"cpp(
+// template 
+// class Base {
+//   virtual void f^oo();
+// };
+// class Sub : public Base {
+//   void [[foo]]() override;
+// };
+//   )cpp";
+//   Annotations Code(Test);
+//   auto TU = TestTU::withCode(Code.code());
+//   auto AST = TU.build();
+
+//   std::vector> ExpectedLocations;
+//   for (const auto &R : Code.ranges())
+// ExpectedLocations.push_back(RangeIs(R));
+//   // FIXME: No implementations for templated virtual functions.
+//   EXPECT_THAT(
+//   findImplementations(AST, Code.point(), TU.index().get()).References,
+//   Not(UnorderedElementsAreArray(ExpectedLocations)))
+//   << Test;
+// }
+
 TEST(FindReferences, WithinAST) {
   const char *Tests[] = {
   R"cpp(// Local variable
Index: clang-tools-extra/clangd/XRefs.h
===
--- clang-tools-extra/clangd/XRefs.h
+++ clang-tools-extra/clangd/XRefs.h
@@ -82,6 +82,11 @@
   std::vector References;
   bool HasMore = false;
 };
+
+/// Returns implementations of the virtual function at a specified \p Pos.
+ReferencesResult findImplementations(ParsedAST &AST, Position Pos,
+ const SymbolIndex *Index = nullptr);
+
 /// Returns references of the symbol at a specified \p Pos.
 /// \p Limit limits the number of results returned (0 means no limit).
 ReferencesResult findReferences(ParsedAST &AST, Position Pos, uint32_t Limit,
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -1124,6 +1124,40 @@
   return Result;
 }
 
+ReferencesResult findImplementations(ParsedAST &AST, Position Pos,
+ const SymbolIndex *Index) {
+  ReferencesResult Results;
+  // We rely on index to find the implementations in subclasses.
+  if (!Index)
+return Results;
+  const SourceManager &SM = AST.getSourceManager();
+  auto MainFilePath =
+  getCanonicalPath(SM.getFileEntryForID(SM.getMainFileID()), SM);
+  if (!MainFilePath) {
+elog("Failed to get a path for the main file, so no implementations.");
+return Results;
+  }
+  auto CurLoc = sourceLocationInMainFile(SM, Pos);
+  DeclRelationSet Relations =
+  DeclRelation::TemplatePattern | DeclRelation::Alias;
+  std::vector Decls =
+  getDeclAtPosition(AST, *CurLoc, Relations

[PATCH] D91627: [OPENMP] Fix PR47999: correctly map implicit firstprivates in outer tasks.

2020-11-17 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added a reviewer: jdoerfert.
Herald added subscribers: guansong, yaxunl.
Herald added a project: clang.
ABataev requested review of this revision.
Herald added a subscriber: sstefan1.

If the variable is implicitly firstprivatized in the inner task-based
region, it also must be firstprivatized in outer task-based regions.
Previously firstprivates were captured in tasks but later it was
optimized to reduce the memory usage. But still need to mark such
variables as implicit firstprivate in outer tasks.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91627

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/task_in_task_firstprivate_codegen.cpp


Index: clang/test/OpenMP/task_in_task_firstprivate_codegen.cpp
===
--- /dev/null
+++ clang/test/OpenMP/task_in_task_firstprivate_codegen.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -x c++ 
-emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -emit-pch -o 
%t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -include-pch 
%t -verify %s -emit-llvm -o - | FileCheck %s
+
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp-simd -x c++ 
-emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple x86_64-apple-darwin10 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple x86_64-apple-darwin10 
-include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix 
SIMD-ONLY0 %s
+// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+// CHECK: @main
+int main() {
+  double var = 0;
+  // Check that var is firstprivatized in the outermost task.
+  // CHECK: [[BASE:%.+]] = call i8* @__kmpc_omp_task_alloc(%struct.ident_t* 
@{{.+}}, i32 {{.+}}, i32 1, i64 48, i64 1, i32 (i32, i8*)* bitcast (i32 (i32, 
[[TASK_TY:%.+]]*)* @{{.+}} to i32 (i32, i8*)*))
+  // CHECK: [[TD:%.+]] = bitcast i8* [[BASE]] to [[TASK_TY]]*
+  // CHECK: [[PRIVS:%.+]] = getelementptr inbounds [[TASK_TY]], [[TASK_TY]]* 
[[TD]], i32 0, i32 1
+  // CHECK: [[VAR_FP:%.+]] = getelementptr inbounds %{{.+}}, %{{.+}}* 
[[PRIVS]], i32 0, i32 0
+  // CHECK: [[VAR_VAL:%.+]] = load double, double* %{{.+}},
+  // CHECK: store double [[VAR_VAL]], double* [[VAR_FP]],
+  // CHECK: call i32 @__kmpc_omp_task(%struct.ident_t* @{{.+}}, i32 %{{.+}}, 
i8* [[BASE]])
+#pragma omp task
+#pragma omp task
+  var += 1;
+  return 0;
+}
+
+#endif
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -3687,7 +3687,8 @@
   // Skip analysis of arguments of implicitly defined map clause for target
   // directives.
   if (C && !((isa(C) || isa(C)) &&
- C->isImplicit())) {
+ C->isImplicit() &&
+ !isOpenMPTaskingDirective(Stack->getCurrentDirective( {
 for (Stmt *CC : C->children()) {
   if (CC)
 Visit(CC);


Index: clang/test/OpenMP/task_in_task_firstprivate_codegen.cpp
===
--- /dev/null
+++ clang/test/OpenMP/task_in_task_firstprivate_codegen.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -x c++ -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp-simd -x c++ -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple x86_64-apple-darwin10 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+// CHECK: @main
+int main() {
+  double var = 0;
+  // Check that var is firstprivatized in the outermost task.
+  // CHECK: [[BASE:%.+]] = call i8* @__kmpc_omp_task_alloc(%struct.ident_t* @{{.+}}, i32 {{.+}}, i32 1, i64 48, i64 1, i32 (i32, i8*)* bitcast (i32 (i32, [[TASK_TY:%.+]]*)* @{{.+}} to i32 (i32, i8*)*))
+  // CHECK: [[TD:%.+]] = bitcast i8* [[BASE]] to [[TASK_TY]]*
+  // CHECK: [[PRIVS:%.+]] = getelementptr inbounds [[TASK_TY]], [[TASK_TY]]* [[TD]], i32 0, i32 1
+  // CHECK: [[VAR_FP:%.+]] = getelementptr inbounds %{{.+}}, %{{.+}}* [[PRIVS]], i32 0, i32 0
+  // CHECK: [[VAR_VAL:%.+]] = load double, double* %{{.+}},
+  // CHECK: store double [[VAR_VAL]], double* [[VAR_FP]],
+  // CHECK: call i32 @__kmpc_omp_task(%struct.ident_t* @{{.+}}, i32 %{{.+}}, i8* [[BASE]]

[PATCH] D91442: [clang][Driver] Handle risvc in Baremetal.cpp.

2020-11-17 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
abidh added a comment.

In D91442#2399402 , @lenary wrote:

> In D91442#2399341 , @abidh wrote:
>
>> In D91442#2399200 , @lenary wrote:
>>
>>> I'm worried about this change - I *think* it doesn't cover the existing 
>>> behaviour of a baremetal GCC toolchain being installed into the same prefix 
>>> as clang, and clang automatically picking up that baremetal gcc toolchain. 
>>> What should we expect to do here? This is especially an issue if you're 
>>> trying to make a relocatable toolchain tarball, where specifying 
>>> `--gcc-toolchain` automatically is difficult.
>>
>> Would it be possible to use a relative path with --gcc-toolchain then this 
>> can be checked in either RISCVToolChain.cpp or GNU.cpp and adjusted 
>> accordingly?
>
> The GCC toolchain, when given a relative path, already interprets it relative 
> to the working directory the compiler was invoked from, not the directory the 
> compiler is located in, iirc.

I dont think path is made absolute relative using working directory. What is 
happening is that if (!VFS.exists(Prefix)) call in the following line will 
succeed if the path existed relative to working directory. This seems 
accidental to me.

https://github.com/llvm/llvm-project/blob/5a9f3867046c4e1c97760e22a505f4d1d788417e/clang/lib/Driver/ToolChains/Gnu.cpp#L1947

I tried a small change to turn a relative --gcc-toolchain into absolute using 
the compiler installed path and it works ok.  If this is something that works 
for you then I can post a patch.


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

https://reviews.llvm.org/D91442

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


[PATCH] D90982: Ignore implicit nodes in IgnoreUnlessSpelledInSource mode

2020-11-17 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 305767.
steveire added a comment.

Update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90982

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ASTNodeTraverser.h
  clang/include/clang/ASTMatchers/ASTMatchersInternal.h
  clang/lib/ASTMatchers/ASTMatchFinder.cpp
  clang/lib/ASTMatchers/ASTMatchersInternal.cpp
  clang/unittests/AST/ASTTraverserTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
  clang/unittests/Tooling/TransformerTest.cpp

Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- clang/unittests/Tooling/TransformerTest.cpp
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -132,6 +132,13 @@
 compareSnippets(Expected, rewrite(Input));
   }
 
+  template  void testRuleFailure(R Rule, StringRef Input) {
+Transformers.push_back(
+std::make_unique(std::move(Rule), consumer()));
+Transformers.back()->registerMatchers(&MatchFinder);
+ASSERT_FALSE(rewrite(Input)) << "Expected failure to rewrite code";
+  }
+
   // Transformers are referenced by MatchFinder.
   std::vector> Transformers;
   clang::ast_matchers::MatchFinder MatchFinder;
@@ -1067,6 +1074,179 @@
   EXPECT_EQ(ErrorCount, 0);
 }
 
+TEST_F(TransformerTest, ImplicitNodes_ConstructorDecl) {
+
+  std::string OtherStructPrefix = R"cpp(
+struct Other {
+)cpp";
+  std::string OtherStructSuffix = "};";
+
+  std::string CopyableStructName = "struct Copyable";
+  std::string BrokenStructName = "struct explicit Copyable";
+
+  std::string CodeSuffix = R"cpp(
+{
+Other m_i;
+Copyable();
+};
+)cpp";
+
+  std::string CopyCtor = "Other(const Other&) = default;";
+  std::string ExplicitCopyCtor = "explicit Other(const Other&) = default;";
+  std::string BrokenExplicitCopyCtor =
+  "explicit explicit explicit Other(const Other&) = default;";
+
+  std::string RewriteInput = OtherStructPrefix + CopyCtor + OtherStructSuffix +
+ CopyableStructName + CodeSuffix;
+  std::string ExpectedRewriteOutput = OtherStructPrefix + ExplicitCopyCtor +
+  OtherStructSuffix + CopyableStructName +
+  CodeSuffix;
+  std::string BrokenRewriteOutput = OtherStructPrefix + BrokenExplicitCopyCtor +
+OtherStructSuffix + BrokenStructName +
+CodeSuffix;
+
+  auto MatchedRecord =
+  cxxConstructorDecl(isCopyConstructor()).bind("copyConstructor");
+
+  auto RewriteRule =
+  changeTo(before(node("copyConstructor")), cat("explicit "));
+
+  testRule(makeRule(traverse(TK_IgnoreUnlessSpelledInSource, MatchedRecord),
+RewriteRule),
+   RewriteInput, ExpectedRewriteOutput);
+
+  testRule(makeRule(traverse(TK_AsIs, MatchedRecord), RewriteRule),
+   RewriteInput, BrokenRewriteOutput);
+}
+
+TEST_F(TransformerTest, ImplicitNodes_RangeFor) {
+
+  std::string CodePrefix = R"cpp(
+struct Container
+{
+int* begin() const;
+int* end() const;
+int* cbegin() const;
+int* cend() const;
+};
+
+void foo()
+{
+  const Container c;
+)cpp";
+
+  std::string BeginCallBefore = "  c.begin();";
+  std::string BeginCallAfter = "  c.cbegin();";
+
+  std::string ForLoop = "for (auto i : c)";
+  std::string BrokenForLoop = "for (auto i :.cbegin() c)";
+
+  std::string CodeSuffix = R"cpp(
+  {
+  }
+}
+)cpp";
+
+  std::string RewriteInput =
+  CodePrefix + BeginCallBefore + ForLoop + CodeSuffix;
+  std::string ExpectedRewriteOutput =
+  CodePrefix + BeginCallAfter + ForLoop + CodeSuffix;
+  std::string BrokenRewriteOutput =
+  CodePrefix + BeginCallAfter + BrokenForLoop + CodeSuffix;
+
+  auto MatchedRecord =
+  cxxMemberCallExpr(on(expr(hasType(qualType(isConstQualified(),
+ hasDeclaration(cxxRecordDecl(
+ hasName("Container"))
+   .bind("callTarget")),
+callee(cxxMethodDecl(hasName("begin"
+  .bind("constBeginCall");
+
+  auto RewriteRule =
+  changeTo(node("constBeginCall"), cat(name("callTarget"), ".cbegin()"));
+
+  testRule(makeRule(traverse(TK_IgnoreUnlessSpelledInSource, MatchedRecord),
+RewriteRule),
+   RewriteInput, ExpectedRewriteOutput);
+
+  testRule(makeRule(traverse(TK_AsIs, MatchedRecord), RewriteRule),
+   RewriteInput, BrokenRewriteOutput);
+}
+
+TEST_F(TransformerTest, ImplicitNodes_ForStmt) {
+
+  std::string CodePrefix = R"cpp(
+struct NonTrivial {
+NonTrivial() {}
+NonTrivial(NonTrivial&) {}
+NonTrivial& operator=(NonTrivial const&) { return *this; }
+
+~NonTrivial() {}
+};
+
+struct ContainsArray {
+NonTrivial arr[2];
+ContainsArray& operator=(ContainsArray const&) = de

[PATCH] D91442: [clang][Driver] Handle risvc in Baremetal.cpp.

2020-11-17 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

In D91442#2399750 , @abidh wrote:

> In D91442#2399402 , @lenary wrote:
>
>> In D91442#2399341 , @abidh wrote:
>>
>>> In D91442#2399200 , @lenary wrote:
>>>
 I'm worried about this change - I *think* it doesn't cover the existing 
 behaviour of a baremetal GCC toolchain being installed into the same 
 prefix as clang, and clang automatically picking up that baremetal gcc 
 toolchain. What should we expect to do here? This is especially an issue 
 if you're trying to make a relocatable toolchain tarball, where specifying 
 `--gcc-toolchain` automatically is difficult.
>>>
>>> Would it be possible to use a relative path with --gcc-toolchain then this 
>>> can be checked in either RISCVToolChain.cpp or GNU.cpp and adjusted 
>>> accordingly?
>>
>> The GCC toolchain, when given a relative path, already interprets it 
>> relative to the working directory the compiler was invoked from, not the 
>> directory the compiler is located in, iirc.
>
> I dont think path is made absolute relative using working directory. What is 
> happening is that if (!VFS.exists(Prefix)) call in the following line will 
> succeed if the path existed relative to working directory. This seems 
> accidental to me.
>
> https://github.com/llvm/llvm-project/blob/5a9f3867046c4e1c97760e22a505f4d1d788417e/clang/lib/Driver/ToolChains/Gnu.cpp#L1947
>
> I tried a small change to turn a relative --gcc-toolchain into absolute using 
> the compiler installed path and it works ok.  If this is something that works 
> for you then I can post a patch.

Relative paths should be relative to the current working directory. That is 
what everyone expects and is what every other argument does (and see `=` and 
`$SYSROOT` for how GCC and compatible drivers get around that in cases like -I).


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

https://reviews.llvm.org/D91442

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


[PATCH] D91442: [clang][Driver] Handle risvc in Baremetal.cpp.

2020-11-17 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

In D91442#2399753 , @jrtc27 wrote:

> In D91442#2399750 , @abidh wrote:
>
>> In D91442#2399402 , @lenary wrote:
>>
>>> In D91442#2399341 , @abidh wrote:
>>>
 In D91442#2399200 , @lenary wrote:

> I'm worried about this change - I *think* it doesn't cover the existing 
> behaviour of a baremetal GCC toolchain being installed into the same 
> prefix as clang, and clang automatically picking up that baremetal gcc 
> toolchain. What should we expect to do here? This is especially an issue 
> if you're trying to make a relocatable toolchain tarball, where 
> specifying `--gcc-toolchain` automatically is difficult.

 Would it be possible to use a relative path with --gcc-toolchain then this 
 can be checked in either RISCVToolChain.cpp or GNU.cpp and adjusted 
 accordingly?
>>>
>>> The GCC toolchain, when given a relative path, already interprets it 
>>> relative to the working directory the compiler was invoked from, not the 
>>> directory the compiler is located in, iirc.
>>
>> I dont think path is made absolute relative using working directory. What is 
>> happening is that if (!VFS.exists(Prefix)) call in the following line will 
>> succeed if the path existed relative to working directory. This seems 
>> accidental to me.
>>
>> https://github.com/llvm/llvm-project/blob/5a9f3867046c4e1c97760e22a505f4d1d788417e/clang/lib/Driver/ToolChains/Gnu.cpp#L1947
>>
>> I tried a small change to turn a relative --gcc-toolchain into absolute 
>> using the compiler installed path and it works ok.  If this is something 
>> that works for you then I can post a patch.
>
> Relative paths should be relative to the current working directory. That is 
> what everyone expects and is what every other argument does (and see `=` and 
> `$SYSROOT` for how GCC and compatible drivers get around that in cases like 
> -I).

And how is that accidental? It looks to me like the correct behaviour naturally 
falls out just as it normally does in that by default anything involving a 
relative path automatically interprets it relative to the current working 
directory.


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

https://reviews.llvm.org/D91442

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


[PATCH] D91262: [AArch64][SVE] Allow C-style casts between fixed-size and scalable vectors

2020-11-17 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes added inline comments.



Comment at: clang/lib/Sema/SemaCast.cpp:2217-2218
 
-  // Allow reinterpret_casts between vectors of the same size and
-  // between vectors and integers of the same size.
   bool destIsVector = DestType->isVectorType();

joechrisellis wrote:
> c-rhodes wrote:
> > nit: not sure we need to change this
> I changed this because the code changes mean that the original comment is 
> incomplete. I.e., we now allow for reinterpret casts VLAT <-> VLST, which is 
> not captured by the comment above.
> I changed this because the code changes mean that the original comment is 
> incomplete. I.e., we now allow for reinterpret casts VLAT <-> VLST, which is 
> not captured by the comment above.

It's a minor point but the reason I raised it is we have to be conscious of the 
fact most people probably don't care about SVE and this is changing an existing 
comment to put it first and foremost.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91262

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


[PATCH] D91602: [clang-tidy] Make clang-format and include-order-check coherent

2020-11-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp:1
 // RUN: %check_clang_tidy %s llvm-include-order %t -- -- -isystem 
%S/Inputs/Headers
 

njames93 wrote:
> Would it be wise to specify a format style here to ensure they align. Better 
> yet 2 run lines, one that runs clang-tidy with no format, the other specifies 
> a format.
ah sorry, i missed this comment :/ i am not sure how the formatting vs. 
generated edits interact. is it enough to have `--format-style=LLVM` and ensure 
the run lines produce the same ordering?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91602

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


[PATCH] D90944: [clang-tidy] implement concurrent-mt-unsafe

2020-11-17 Thread Vasily Kulikov via Phabricator via cfe-commits
segoon updated this revision to Diff 305764.
segoon retitled this revision from "[clang-tidy] implement misc-mt-unsafe" to 
"[clang-tidy] implement concurrent-mt-unsafe".
segoon added a comment.
Herald added subscribers: sstefan1, arphaman.
Herald added a reviewer: jdoerfert.

- move plugin to `concurrent` group
- naming fixes
- use anyOf
- Libc -> FunctionSet


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

https://reviews.llvm.org/D90944

Files:
  clang-tools-extra/clang-tidy/CMakeLists.txt
  clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
  clang-tools-extra/clang-tidy/concurrent/CMakeLists.txt
  clang-tools-extra/clang-tidy/concurrent/ConcurrentTidyModule.cpp
  clang-tools-extra/clang-tidy/concurrent/MtUnsafeCheck.cpp
  clang-tools-extra/clang-tidy/concurrent/MtUnsafeCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/concurrent-mt-unsafe.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  clang-tools-extra/test/clang-tidy/checkers/concurrent-mt-unsafe-any.cpp
  clang-tools-extra/test/clang-tidy/checkers/concurrent-mt-unsafe-glibc.cpp
  clang-tools-extra/test/clang-tidy/checkers/concurrent-mt-unsafe-posix.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/concurrent-mt-unsafe-posix.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/concurrent-mt-unsafe-posix.cpp
@@ -0,0 +1,22 @@
+// RUN: %check_clang_tidy %s concurrent-mt-unsafe %t -- -config='{CheckOptions: [{key: "concurrent-mt-unsafe.FunctionSet", value: "posix"}]}'
+
+extern unsigned int sleep (unsigned int __seconds);
+extern int *gmtime (const int *__timer);
+extern int *gmtime_r (const int *__timer, char*);
+extern char *dirname (char *__path);
+
+void foo() {
+  sleep(2);
+  ::sleep(2);
+
+  auto tm = gmtime(nullptr);
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: function is not thread safe [concurrent-mt-unsafe]
+  tm = ::gmtime(nullptr);
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: function is not thread safe [concurrent-mt-unsafe]
+
+  tm = gmtime_r(nullptr, nullptr);
+  tm = ::gmtime_r(nullptr, nullptr);
+
+  dirname(nullptr);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: function is not thread safe [concurrent-mt-unsafe]
+}
Index: clang-tools-extra/test/clang-tidy/checkers/concurrent-mt-unsafe-glibc.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/concurrent-mt-unsafe-glibc.cpp
@@ -0,0 +1,15 @@
+// RUN: %check_clang_tidy %s concurrent-mt-unsafe %t -- -config='{CheckOptions: [{key: "concurrent-mt-unsafe.FunctionSet", value: "glibc"}]}'
+
+extern unsigned int sleep (unsigned int __seconds);
+extern int *gmtime (const int *__timer);
+extern char *dirname (char *__path);
+
+void foo() {
+  sleep(2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: function is not thread safe [concurrent-mt-unsafe]
+
+  ::sleep(2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: function is not thread safe [concurrent-mt-unsafe]
+
+  dirname(nullptr);
+}
Index: clang-tools-extra/test/clang-tidy/checkers/concurrent-mt-unsafe-any.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/concurrent-mt-unsafe-any.cpp
@@ -0,0 +1,24 @@
+// RUN: %check_clang_tidy %s concurrent-mt-unsafe %t
+
+extern unsigned int sleep (unsigned int __seconds);
+extern int *gmtime (const int *__timer);
+extern int *gmtime_r (const int *__timer, char*);
+extern char *dirname (char *__path);
+
+void foo() {
+  sleep(2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: function is not thread safe [concurrent-mt-unsafe]
+  ::sleep(2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: function is not thread safe [concurrent-mt-unsafe]
+
+  auto tm = gmtime(nullptr);
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: function is not thread safe [concurrent-mt-unsafe]
+  tm = ::gmtime(nullptr);
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: function is not thread safe [concurrent-mt-unsafe]
+
+  tm = gmtime_r(nullptr, nullptr);
+  tm = ::gmtime_r(nullptr, nullptr);
+
+  dirname(nullptr);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: function is not thread safe [concurrent-mt-unsafe]
+}
Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -64,6 +64,8 @@
 ``bugprone-``  Checks that target bugprone code constructs.
 ``cert-``  Checks related to CERT Secure Coding Guidelines.
 ``clang-analyzer-``Clang Static Analyzer checks.
+``concurrent-``Checks related to concurrent programming (including
+   threads, fibers, coroutines, etc.).
 ``cppcoreguidelines-`` Checks related to C++ Core Guidelines.
 ``darwin-``Checks related to 

[PATCH] D90984: Update matchers to be traverse-aware

2020-11-17 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 305768.
steveire added a comment.

Update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90984

Files:
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/ASTMatchers/ASTMatchersInternal.h
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
  clang/unittests/Tooling/TransformerTest.cpp

Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- clang/unittests/Tooling/TransformerTest.cpp
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -1245,6 +1245,32 @@
 testRuleFailure(makeRule(traverse(TK_AsIs, MatchedLoop), RewriteRule),
 RewriteInput);
   }
+  {
+auto MatchedLoop = forStmt(
+hasLoopInit(declStmt(
+hasSingleDecl(varDecl(hasInitializer(integerLiteral(equals(0
+  .bind("loopVar",
+hasCondition(binaryOperator(hasOperatorName("!="),
+hasLHS(ignoringImplicit(declRefExpr(to(
+varDecl(equalsBoundNode("loopVar")),
+hasRHS(expr().bind("upperBoundExpr",
+hasIncrement(unaryOperator(hasOperatorName("++"),
+   hasUnaryOperand(declRefExpr(to(
+   varDecl(equalsBoundNode("loopVar"))
+ .bind("incrementOp")));
+
+auto RewriteRule =
+changeTo(transformer::enclose(node("loopVar"), node("incrementOp")),
+ cat("auto ", name("loopVar"), " : boost::irange(",
+ node("upperBoundExpr"), ")"));
+
+testRule(makeRule(traverse(TK_IgnoreUnlessSpelledInSource, MatchedLoop),
+  RewriteRule),
+ RewriteInput, RewriteOutput);
+
+testRuleFailure(makeRule(traverse(TK_AsIs, MatchedLoop), RewriteRule),
+RewriteInput);
+  }
 }
 
 TEST_F(TransformerTest, TemplateInstantiation) {
Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -2335,8 +2335,8 @@
   StringRef Code = R"cpp(
 struct NonTrivial {
 NonTrivial() {}
-NonTrivial(NonTrivial&) {}
-NonTrivial& operator=(NonTrivial&) { return *this; }
+NonTrivial(const NonTrivial &) {}
+NonTrivial& operator=(const NonTrivial &) { return *this; }
 
 ~NonTrivial() {}
 };
@@ -2347,7 +2347,7 @@
 
 struct ContainsArray {
 NonTrivial arr[2];
-ContainsArray& operator=(ContainsArray &other) = default;
+ContainsArray& operator=(const ContainsArray &other) = default;
 };
 
 void copyIt()
@@ -2368,6 +2368,13 @@
   HasCtorInits() : NoSpecialMethods(), m_i(42) {}
 };
 
+struct CtorInitsNonTrivial : NonTrivial
+{
+  int m_i;
+  NonTrivial m_nt;
+  CtorInitsNonTrivial() : NonTrivial(), m_i(42) {}
+};
+
 )cpp";
   {
 auto M = cxxRecordDecl(hasName("NoSpecialMethods"),
@@ -2393,6 +2400,35 @@
 M = cxxRecordDecl(hasName("NoSpecialMethods"), has(cxxDestructorDecl()));
 EXPECT_TRUE(matches(Code, traverse(TK_AsIs, M)));
 EXPECT_FALSE(matches(Code, traverse(TK_IgnoreUnlessSpelledInSource, M)));
+
+M = cxxRecordDecl(hasName("NoSpecialMethods"),
+  hasMethod(cxxConstructorDecl(isCopyConstructor(;
+EXPECT_TRUE(matches(Code, traverse(TK_AsIs, M)));
+EXPECT_FALSE(matches(Code, traverse(TK_IgnoreUnlessSpelledInSource, M)));
+
+M = cxxRecordDecl(hasName("NoSpecialMethods"),
+  hasMethod(cxxMethodDecl(isCopyAssignmentOperator(;
+EXPECT_TRUE(matches(Code, traverse(TK_AsIs, M)));
+EXPECT_FALSE(matches(Code, traverse(TK_IgnoreUnlessSpelledInSource, M)));
+
+M = cxxRecordDecl(hasName("NoSpecialMethods"),
+  hasMethod(cxxConstructorDecl(isDefaultConstructor(;
+EXPECT_TRUE(matches(Code, traverse(TK_AsIs, M)));
+EXPECT_FALSE(matches(Code, traverse(TK_IgnoreUnlessSpelledInSource, M)));
+
+M = cxxRecordDecl(hasName("NoSpecialMethods"),
+  hasMethod(cxxDestructorDecl()));
+EXPECT_TRUE(matches(Code, traverse(TK_AsIs, M)));
+EXPECT_FALSE(matches(Code, traverse(TK_IgnoreUnlessSpelledInSource, M)));
+  }
+  {
+// Because the copy-assignment operator is not spelled in the
+// source (ie, isImplicit()), we don't match it
+auto M =
+cxxOperatorCallExpr(hasType(cxxRecordDecl(hasName("NoSpecialMethods"))),
+callee(cxxMethodDecl(isCopyAssignmentOperator(;
+EXPECT_TRUE(matches(Code, traverse(TK_AsIs, M)));
+EXPECT_FALSE(matches(Code, traverse(TK_IgnoreUnlessSpelledInSource, M)));
   }
   {
 // Compiler generates a forStmt to copy the array
@@ -2414,6 +2450,24 @@
 EXPEC

[PATCH] D91262: [AArch64][SVE] Allow C-style casts between fixed-size and scalable vectors

2020-11-17 Thread Joe Ellis via Phabricator via cfe-commits
joechrisellis added inline comments.



Comment at: clang/lib/Sema/SemaCast.cpp:2217-2218
 
-  // Allow reinterpret_casts between vectors of the same size and
-  // between vectors and integers of the same size.
   bool destIsVector = DestType->isVectorType();

c-rhodes wrote:
> joechrisellis wrote:
> > c-rhodes wrote:
> > > nit: not sure we need to change this
> > I changed this because the code changes mean that the original comment is 
> > incomplete. I.e., we now allow for reinterpret casts VLAT <-> VLST, which 
> > is not captured by the comment above.
> > I changed this because the code changes mean that the original comment is 
> > incomplete. I.e., we now allow for reinterpret casts VLAT <-> VLST, which 
> > is not captured by the comment above.
> 
> It's a minor point but the reason I raised it is we have to be conscious of 
> the fact most people probably don't care about SVE and this is changing an 
> existing comment to put it first and foremost.
Ok, I see what you mean. Will revert this part.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91262

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


[PATCH] D91442: [clang][Driver] Handle risvc in Baremetal.cpp.

2020-11-17 Thread Sam Elliott via Phabricator via cfe-commits
lenary added a comment.

I recall that there is also https://reviews.llvm.org/D68407 which iirc hoped to 
address using `RISCVToolchain` with Compiler-rt and libunwind - presumably it 
is not a complete solution, but it might be we want to use some checking of the 
GCCInstallation (like `RISCVToolChain::GetDefaultRuntimeLibType` does) to 
choose which toolchain to instantiate? I'm not sure if we can satisfy that 
ordering though.


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

https://reviews.llvm.org/D91442

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


[PATCH] D91262: [AArch64][SVE] Allow C-style casts between fixed-size and scalable vectors

2020-11-17 Thread Joe Ellis via Phabricator via cfe-commits
joechrisellis updated this revision to Diff 305769.
joechrisellis added a comment.

Address @c-rhodes's comment regarding comment change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91262

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/aarch64-sve-explicit-casts-fixed-size.c
  clang/test/SemaCXX/aarch64-sve-explicit-casts-fixed-size.cpp

Index: clang/test/SemaCXX/aarch64-sve-explicit-casts-fixed-size.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/aarch64-sve-explicit-casts-fixed-size.cpp
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=128 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=256 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=512 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=1024 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=2048 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+
+#include 
+
+#define N __ARM_FEATURE_SVE_BITS
+#define FIXED_ATTR __attribute__((arm_sve_vector_bits(N)))
+
+typedef svfloat32_t fixed_float32_t FIXED_ATTR;
+typedef svfloat64_t fixed_float64_t FIXED_ATTR;
+typedef svint32_t fixed_int32_t FIXED_ATTR;
+typedef svint64_t fixed_int64_t FIXED_ATTR;
+
+// SVE VLSTs can be cast to SVE VLATs, regardless of lane size.
+// NOTE: the list below is NOT exhaustive for all SVE types.
+
+#define CAST(from, to) \
+void from##_to_##to(from a, to b) { \
+b = (to) a; \
+}
+
+#define TESTCASE(ty1, ty2) \
+CAST(ty1, ty2) \
+CAST(ty2, ty1)
+
+TESTCASE(fixed_float32_t, svfloat32_t)
+TESTCASE(fixed_float32_t, svfloat64_t)
+TESTCASE(fixed_float32_t, svint32_t)
+TESTCASE(fixed_float32_t, svint64_t)
+
+TESTCASE(fixed_float64_t, svfloat32_t)
+TESTCASE(fixed_float64_t, svfloat64_t)
+TESTCASE(fixed_float64_t, svint32_t)
+TESTCASE(fixed_float64_t, svint64_t)
+
+TESTCASE(fixed_int32_t, svfloat32_t)
+TESTCASE(fixed_int32_t, svfloat64_t)
+TESTCASE(fixed_int32_t, svint32_t)
+TESTCASE(fixed_int32_t, svint64_t)
+
+TESTCASE(fixed_int64_t, svfloat32_t)
+TESTCASE(fixed_int64_t, svfloat64_t)
+TESTCASE(fixed_int64_t, svint32_t)
+TESTCASE(fixed_int64_t, svint64_t)
Index: clang/test/Sema/aarch64-sve-explicit-casts-fixed-size.c
===
--- /dev/null
+++ clang/test/Sema/aarch64-sve-explicit-casts-fixed-size.c
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=128 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=256 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=512 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=1024 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=2048 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+
+#include 
+
+#define N __ARM_FEATURE_SVE_BITS
+#define FIXED_ATTR __attribute__((arm_sve_vector_bits(N)))
+
+typedef svfloat32_t fixed_float32_t FIXED_ATTR;
+typedef svfloat64_t fixed_float64_t FIXED_ATTR;
+typedef svint32_t fixed_int32_t FIXED_ATTR;
+typedef svint64_t fixed_int64_t FIXED_ATTR;
+
+// SVE VLSTs can be cast to SVE VLATs, regardless of lane size.
+// NOTE: the list below is NOT exhaustive for all SVE types.
+
+#define CAST(from, to) \
+void from##_to_##to(from a, to b) { \
+b = (to) a; \
+}
+
+#define TESTCASE(ty1, ty2) \
+CAST(ty1, ty2) \
+CAST(ty2, ty1)
+
+TESTCASE(fixed_float32_t, svfloat32_t)
+TESTCASE(fixed_float32_t, svfloat64_t)
+TESTCASE(fixed_float32_t, svint32_t)
+TESTCASE(fixed_float32_t, svint64_t)
+
+TESTCAS

[PATCH] D90944: [clang-tidy] implement concurrent-mt-unsafe

2020-11-17 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

In D90944#2399759 , @segoon wrote:

> - move plugin to `concurrent` group

While this is definitely a step in the right direction, it should be a separate 
patch to introduce the new module. After making that, set this to be a child of 
it.


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

https://reviews.llvm.org/D90944

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


[PATCH] D80499: Remove obsolete ignore*() matcher uses

2020-11-17 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

In D80499#2362028 , @steveire wrote:

>> ! In D80499#2353187 , @alexfh wrote:
>>  You should be ready for back and forth with this change, if users hit 
>> widespread issues not caught by tests. Maybe splitting it into separate 
>> pieces and involving check authors where practical may be reasonable.
>
> Ok, I'll do that when https://reviews.llvm.org/D80961 and 
> https://reviews.llvm.org/D82278 are merged.

@alexfh This is done in D91302  and D91303 
. Could you review?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80499

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


[PATCH] D90984: Update matchers to be traverse-aware

2020-11-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:4083
+return false;
+  return InnerMatcher.matches(*Arg->IgnoreParenImpCasts(), Finder, Builder);
 }

This probably shouldn't compile given that there's no declaration of `Arg`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90984

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


[PATCH] D91067: [AArch64][SVE] Support implicit lax vector conversions for SVE types

2020-11-17 Thread Joe Ellis via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG23a96b84a8d9: [AArch64][SVE] Support implicit lax vector 
conversions for SVE types (authored by joechrisellis).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91067

Files:
  clang/include/clang/AST/ASTContext.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/Sema/aarch64-sve-lax-vector-conversions.c
  clang/test/Sema/attr-arm-sve-vector-bits.c
  clang/test/SemaCXX/aarch64-sve-lax-vector-conversions.cpp

Index: clang/test/SemaCXX/aarch64-sve-lax-vector-conversions.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/aarch64-sve-lax-vector-conversions.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=512 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify=lax-vector-none %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=512 -flax-vector-conversions=integer -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify=lax-vector-integer %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=512 -flax-vector-conversions=all -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify=lax-vector-all %s
+
+// lax-vector-all-no-diagnostics
+
+#include 
+
+#define N __ARM_FEATURE_SVE_BITS
+#define FIXED_ATTR __attribute__((arm_sve_vector_bits(N)))
+
+typedef svfloat32_t fixed_float32_t FIXED_ATTR;
+typedef svint32_t fixed_int32_t FIXED_ATTR;
+
+void allowed_with_integer_lax_conversions() {
+  fixed_int32_t fi32;
+  svint64_t si64;
+
+  // The implicit cast here should fail if -flax-vector-conversions=none, but pass if
+  // -flax-vector-conversions={integer,all}.
+  fi32 = si64;
+  // lax-vector-none-error@-1 {{assigning to 'fixed_int32_t' (vector of 16 'int' values) from incompatible type}}
+}
+
+void allowed_with_all_lax_conversions() {
+  fixed_float32_t ff32;
+  svfloat64_t sf64;
+
+  // The implicit cast here should fail if -flax-vector-conversions={none,integer}, but pass if
+  // -flax-vector-conversions=all.
+  ff32 = sf64;
+  // lax-vector-none-error@-1 {{assigning to 'fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
+  // lax-vector-integer-error@-2 {{assigning to 'fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
+}
Index: clang/test/Sema/attr-arm-sve-vector-bits.c
===
--- clang/test/Sema/attr-arm-sve-vector-bits.c
+++ clang/test/Sema/attr-arm-sve-vector-bits.c
@@ -270,7 +270,6 @@
 TEST_CAST_COMMON(bool)
 
 // Test the implicit conversion only applies to valid types
-fixed_int8_t to_fixed_int8_t__from_svuint8_t(svuint8_t x) { return x; } // expected-error-re {{returning 'svuint8_t' (aka '__SVUint8_t') from a function with incompatible result type 'fixed_int8_t' (vector of {{[0-9]+}} 'signed char' values)}}
 fixed_bool_t to_fixed_bool_t__from_svint32_t(svint32_t x) { return x; } // expected-error-re {{returning 'svint32_t' (aka '__SVInt32_t') from a function with incompatible result type 'fixed_bool_t' (vector of {{[0-9]+}} 'unsigned char' values)}}
 
 svint64_t to_svint64_t__from_gnu_int32_t(gnu_int32_t x) { return x; } // expected-error-re {{returning 'gnu_int32_t' (vector of {{[0-9]+}} 'int32_t' values) from a function with incompatible result type 'svint64_t' (aka '__SVInt64_t')}}
Index: clang/test/Sema/aarch64-sve-lax-vector-conversions.c
===
--- /dev/null
+++ clang/test/Sema/aarch64-sve-lax-vector-conversions.c
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=512 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify=lax-vector-none %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=512 -flax-vector-conversions=integer -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify=lax-vector-integer %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=512 -flax-vector-conversions=all -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify=lax-vector-all %s
+
+// lax-vector-all-no-diagnostics
+
+#include 
+
+#define N __ARM_FEATURE_SVE_BITS
+#define FIXED_ATTR __attribute__((arm_sve_vector_bits(N)))
+
+typedef svfloat32_t fixed_float32_t FIXED_ATTR;
+typedef svint32_t fixed_int32_t FIXED_ATTR;
+
+void allowed_with_integer_lax_conversions() {
+  fixed_int32_t fi32;
+  svint64_t si64;
+
+  // The implicit cast here should fail if -flax-vector-conversions=none, but pass 

[clang] 23a96b8 - [AArch64][SVE] Support implicit lax vector conversions for SVE types

2020-11-17 Thread Joe Ellis via cfe-commits

Author: Joe Ellis
Date: 2020-11-17T14:50:17Z
New Revision: 23a96b84a8d985b686a4e06dec1f7aebc0cca6c6

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

LOG: [AArch64][SVE] Support implicit lax vector conversions for SVE types

Lax vector conversions was behaving incorrectly for implicit casts
between scalable and fixed-length vector types. For example, this:

#include 

#define N __ARM_FEATURE_SVE_BITS
#define FIXED_ATTR __attribute__((arm_sve_vector_bits(N)))

typedef svfloat32_t fixed_float32_t FIXED_ATTR;

void allowed_depending() {
  fixed_float32_t fs32;
  svfloat64_t s64;

  fs32 = s64;
}

... would fail because the vectors have differing lane sizes. This patch
implements the correct behaviour for
-flax-vector-conversions={none,all,integer}. Specifically:

- -flax-vector-conversions=none prevents all lax vector conversions
  between scalable and fixed-sized vectors.
- -flax-vector-conversions=integer allows lax vector conversions between
  scalable and fixed-size vectors whose element types are integers.
- -flax-vector-conversions=all allows all lax vector conversions between
  scalable and fixed-size vectors (including those with floating point
  element types).

The implicit conversions are implemented as bitcasts.

Reviewed By: fpetrogalli

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

Added: 
clang/test/Sema/aarch64-sve-lax-vector-conversions.c
clang/test/SemaCXX/aarch64-sve-lax-vector-conversions.cpp

Modified: 
clang/include/clang/AST/ASTContext.h
clang/lib/AST/ASTContext.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaOverload.cpp
clang/test/Sema/attr-arm-sve-vector-bits.c

Removed: 




diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 9fc9c924b51c..8c0930237583 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -2088,6 +2088,10 @@ class ASTContext : public RefCountedBase {
   /// vector-length.
   bool areCompatibleSveTypes(QualType FirstType, QualType SecondType);
 
+  /// Return true if the given vector types are lax-compatible SVE vector 
types,
+  /// false otherwise.
+  bool areLaxCompatibleSveTypes(QualType FirstType, QualType SecondType);
+
   /// Return true if the type has been explicitly qualified with ObjC 
ownership.
   /// A type may be implicitly qualified with ownership under ObjC ARC, and in
   /// some cases the compiler treats these 
diff erently.

diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index d63f299f021f..836065291fea 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -8574,6 +8574,41 @@ bool ASTContext::areCompatibleSveTypes(QualType 
FirstType,
  IsValidCast(SecondType, FirstType);
 }
 
+bool ASTContext::areLaxCompatibleSveTypes(QualType FirstType,
+  QualType SecondType) {
+  assert(((FirstType->isSizelessBuiltinType() && SecondType->isVectorType()) ||
+  (FirstType->isVectorType() && SecondType->isSizelessBuiltinType())) 
&&
+ "Expected SVE builtin type and vector type!");
+
+  auto IsLaxCompatible = [this](QualType FirstType, QualType SecondType) {
+if (!FirstType->getAs())
+  return false;
+
+const auto *VecTy = SecondType->getAs();
+if (VecTy &&
+VecTy->getVectorKind() == VectorType::SveFixedLengthDataVector) {
+  const LangOptions::LaxVectorConversionKind LVCKind =
+  getLangOpts().getLaxVectorConversions();
+
+  // If -flax-vector-conversions=all is specified, the types are
+  // certainly compatible.
+  if (LVCKind == LangOptions::LaxVectorConversionKind::All)
+return true;
+
+  // If -flax-vector-conversions=integer is specified, the types are
+  // compatible if the elements are integer types.
+  if (LVCKind == LangOptions::LaxVectorConversionKind::Integer)
+return VecTy->getElementType().getCanonicalType()->isIntegerType() &&
+   FirstType->getSveEltType(*this)->isIntegerType();
+}
+
+return false;
+  };
+
+  return IsLaxCompatible(FirstType, SecondType) ||
+ IsLaxCompatible(SecondType, FirstType);
+}
+
 bool ASTContext::hasDirectOwnershipQualifier(QualType Ty) const {
   while (true) {
 // __strong id

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 0a25720c0f7b..e1a87ede3bdd 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -9003,12 +9003,13 @@ Sema::CheckAssignmentConstraints(QualType LHSType, 
ExprResult &RHS,
 }
 
 // Allow assignments between fixed-length and sizeless SVE vectors.
-if (((LHSType->isSizelessBuiltinType() && RHSType->isVectorType()) ||
- (LHSType-

[PATCH] D91610: [clangd] Add OverridenBy Relation to index.

2020-11-17 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 updated this revision to Diff 305776.
usaxena95 marked an inline comment as done.
usaxena95 added a comment.

Addressed comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91610

Files:
  clang-tools-extra/clangd/index/Relation.cpp
  clang-tools-extra/clangd/index/Relation.h
  clang-tools-extra/clangd/index/Serialization.cpp
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp

Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -97,6 +97,9 @@
   const Range &Range = ::testing::get<1>(arg);
   return rangesMatch(Pos.Location, Range);
 }
+MATCHER_P2(OverridenBy, Subject, Object, "") {
+  return arg == Relation{Subject.ID, RelationKind::OverridenBy, Object.ID};
+}
 ::testing::Matcher &>
 HaveRanges(const std::vector Ranges) {
   return ::testing::UnorderedPointwise(RefRange(), Ranges);
@@ -1031,7 +1034,7 @@
   HaveRanges(Header.ranges("macro");
 }
 
-TEST_F(SymbolCollectorTest, Relations) {
+TEST_F(SymbolCollectorTest, BaseOfRelations) {
   std::string Header = R"(
   class Base {};
   class Derived : public Base {};
@@ -1043,6 +1046,77 @@
   Contains(Relation{Base.ID, RelationKind::BaseOf, Derived.ID}));
 }
 
+TEST_F(SymbolCollectorTest, OverrideRelationsSimpleInheritance) {
+  std::string Header = R"cpp(
+class A {
+  virtual void foo();
+};
+class B : public A {
+  void foo() override;  // A::foo
+  virtual void bar();
+};
+class C : public B {
+  void bar() override;  // B::bar
+};
+class D: public C {
+  void foo() override;  // B::foo
+  void bar() override;  // C::bar
+};
+  )cpp";
+  runSymbolCollector(Header, /*Main=*/"");
+  const Symbol &AFoo = findSymbol(Symbols, "A::foo");
+  const Symbol &BFoo = findSymbol(Symbols, "B::foo");
+  const Symbol &DFoo = findSymbol(Symbols, "D::foo");
+
+  const Symbol &BBar = findSymbol(Symbols, "B::bar");
+  const Symbol &CBar = findSymbol(Symbols, "C::bar");
+  const Symbol &DBar = findSymbol(Symbols, "D::bar");
+
+  std::vector Result;
+  for (const Relation &R : Relations)
+if (R.Predicate == RelationKind::OverridenBy)
+  Result.push_back(R);
+  EXPECT_THAT(Result, UnorderedElementsAre(
+  OverridenBy(AFoo, BFoo), OverridenBy(BBar, CBar),
+  OverridenBy(BFoo, DFoo), OverridenBy(CBar, DBar)));
+}
+
+TEST_F(SymbolCollectorTest, OverrideRelationsMultipleInheritance) {
+  std::string Header = R"cpp(
+class A {
+  virtual void foo();
+};
+class B {
+  virtual void bar();
+};
+class C : public B {
+  void bar() override;  // B::bar
+  virtual void baz();
+}
+class D : public A, C {
+  void foo() override;  // A::foo
+  void bar() override;  // C::bar
+  void baz() override;  // C::baz
+};
+  )cpp";
+  runSymbolCollector(Header, /*Main=*/"");
+  const Symbol &AFoo = findSymbol(Symbols, "A::foo");
+  const Symbol &BBar = findSymbol(Symbols, "B::bar");
+  const Symbol &CBar = findSymbol(Symbols, "C::bar");
+  const Symbol &CBaz = findSymbol(Symbols, "C::baz");
+  const Symbol &DFoo = findSymbol(Symbols, "D::foo");
+  const Symbol &DBar = findSymbol(Symbols, "D::bar");
+  const Symbol &DBaz = findSymbol(Symbols, "D::baz");
+
+  std::vector Result;
+  for (const Relation &R : Relations)
+if (R.Predicate == RelationKind::OverridenBy)
+  Result.push_back(R);
+  EXPECT_THAT(Result, UnorderedElementsAre(
+  OverridenBy(BBar, CBar), OverridenBy(AFoo, DFoo),
+  OverridenBy(CBar, DBar), OverridenBy(CBaz, DBaz)));
+}
+
 TEST_F(SymbolCollectorTest, CountReferences) {
   const std::string Header = R"(
 class W;
Index: clang-tools-extra/clangd/index/SymbolCollector.cpp
===
--- clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -15,6 +15,7 @@
 #include "SourceCode.h"
 #include "SymbolLocation.h"
 #include "URI.h"
+#include "index/Relation.h"
 #include "index/SymbolID.h"
 #include "support/Logger.h"
 #include "clang/AST/Decl.h"
@@ -187,9 +188,12 @@
   return Result;
 }
 
-bool shouldIndexRelation(const index::SymbolRelation &R) {
-  // We currently only index BaseOf relations, for type hierarchy subtypes.
-  return R.Roles & static_cast(index::SymbolRole::RelationBaseOf);
+llvm::Optional indexableRelation(const index::SymbolRelation &R) {
+  if (R.Roles & static_cast(index::SymbolRole::RelationBaseOf))
+return RelationKind::BaseOf;
+  if (R.Roles & static_cast(index::SymbolRole::RelationOverrideOf))
+return Relat

[PATCH] D91610: [clangd] Add OverridenBy Relation to index.

2020-11-17 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 marked an inline comment as done.
usaxena95 added a comment.

Bumped the index version. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91610

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


[PATCH] D90984: Update matchers to be traverse-aware

2020-11-17 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 305777.
steveire added a comment.

Update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90984

Files:
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/ASTMatchers/ASTMatchersInternal.h
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
  clang/unittests/Tooling/TransformerTest.cpp

Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- clang/unittests/Tooling/TransformerTest.cpp
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -1245,6 +1245,32 @@
 testRuleFailure(makeRule(traverse(TK_AsIs, MatchedLoop), RewriteRule),
 RewriteInput);
   }
+  {
+auto MatchedLoop = forStmt(
+hasLoopInit(declStmt(
+hasSingleDecl(varDecl(hasInitializer(integerLiteral(equals(0
+  .bind("loopVar",
+hasCondition(binaryOperator(hasOperatorName("!="),
+hasLHS(ignoringImplicit(declRefExpr(to(
+varDecl(equalsBoundNode("loopVar")),
+hasRHS(expr().bind("upperBoundExpr",
+hasIncrement(unaryOperator(hasOperatorName("++"),
+   hasUnaryOperand(declRefExpr(to(
+   varDecl(equalsBoundNode("loopVar"))
+ .bind("incrementOp")));
+
+auto RewriteRule =
+changeTo(transformer::enclose(node("loopVar"), node("incrementOp")),
+ cat("auto ", name("loopVar"), " : boost::irange(",
+ node("upperBoundExpr"), ")"));
+
+testRule(makeRule(traverse(TK_IgnoreUnlessSpelledInSource, MatchedLoop),
+  RewriteRule),
+ RewriteInput, RewriteOutput);
+
+testRuleFailure(makeRule(traverse(TK_AsIs, MatchedLoop), RewriteRule),
+RewriteInput);
+  }
 }
 
 TEST_F(TransformerTest, TemplateInstantiation) {
Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -2335,8 +2335,8 @@
   StringRef Code = R"cpp(
 struct NonTrivial {
 NonTrivial() {}
-NonTrivial(NonTrivial&) {}
-NonTrivial& operator=(NonTrivial&) { return *this; }
+NonTrivial(const NonTrivial &) {}
+NonTrivial& operator=(const NonTrivial &) { return *this; }
 
 ~NonTrivial() {}
 };
@@ -2347,7 +2347,7 @@
 
 struct ContainsArray {
 NonTrivial arr[2];
-ContainsArray& operator=(ContainsArray &other) = default;
+ContainsArray& operator=(const ContainsArray &other) = default;
 };
 
 void copyIt()
@@ -2368,6 +2368,13 @@
   HasCtorInits() : NoSpecialMethods(), m_i(42) {}
 };
 
+struct CtorInitsNonTrivial : NonTrivial
+{
+  int m_i;
+  NonTrivial m_nt;
+  CtorInitsNonTrivial() : NonTrivial(), m_i(42) {}
+};
+
 )cpp";
   {
 auto M = cxxRecordDecl(hasName("NoSpecialMethods"),
@@ -2393,6 +2400,35 @@
 M = cxxRecordDecl(hasName("NoSpecialMethods"), has(cxxDestructorDecl()));
 EXPECT_TRUE(matches(Code, traverse(TK_AsIs, M)));
 EXPECT_FALSE(matches(Code, traverse(TK_IgnoreUnlessSpelledInSource, M)));
+
+M = cxxRecordDecl(hasName("NoSpecialMethods"),
+  hasMethod(cxxConstructorDecl(isCopyConstructor(;
+EXPECT_TRUE(matches(Code, traverse(TK_AsIs, M)));
+EXPECT_FALSE(matches(Code, traverse(TK_IgnoreUnlessSpelledInSource, M)));
+
+M = cxxRecordDecl(hasName("NoSpecialMethods"),
+  hasMethod(cxxMethodDecl(isCopyAssignmentOperator(;
+EXPECT_TRUE(matches(Code, traverse(TK_AsIs, M)));
+EXPECT_FALSE(matches(Code, traverse(TK_IgnoreUnlessSpelledInSource, M)));
+
+M = cxxRecordDecl(hasName("NoSpecialMethods"),
+  hasMethod(cxxConstructorDecl(isDefaultConstructor(;
+EXPECT_TRUE(matches(Code, traverse(TK_AsIs, M)));
+EXPECT_FALSE(matches(Code, traverse(TK_IgnoreUnlessSpelledInSource, M)));
+
+M = cxxRecordDecl(hasName("NoSpecialMethods"),
+  hasMethod(cxxDestructorDecl()));
+EXPECT_TRUE(matches(Code, traverse(TK_AsIs, M)));
+EXPECT_FALSE(matches(Code, traverse(TK_IgnoreUnlessSpelledInSource, M)));
+  }
+  {
+// Because the copy-assignment operator is not spelled in the
+// source (ie, isImplicit()), we don't match it
+auto M =
+cxxOperatorCallExpr(hasType(cxxRecordDecl(hasName("NoSpecialMethods"))),
+callee(cxxMethodDecl(isCopyAssignmentOperator(;
+EXPECT_TRUE(matches(Code, traverse(TK_AsIs, M)));
+EXPECT_FALSE(matches(Code, traverse(TK_IgnoreUnlessSpelledInSource, M)));
   }
   {
 // Compiler generates a forStmt to copy the array
@@ -2414,6 +2450,24 @@
 EXPEC

[PATCH] D90984: Update matchers to be traverse-aware

2020-11-17 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added inline comments.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:4083
+return false;
+  return InnerMatcher.matches(*Arg->IgnoreParenImpCasts(), Finder, Builder);
 }

aaron.ballman wrote:
> This probably shouldn't compile given that there's no declaration of `Arg`?
Correct. Fixed now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90984

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


[PATCH] D91610: [clangd] Add OverridenBy Relation to index.

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



Comment at: clang-tools-extra/clangd/index/Relation.cpp:21
+  case RelationKind ::OverridenBy:
+return OS << "OverridenBy";
+  }

Also here.
And there's a bogus extra space in `RelationKind ::BaseOf`.



Comment at: clang-tools-extra/clangd/index/Relation.h:24
   BaseOf,
+  OverridenBy,
 };

s/Overriden/Overridden/g


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91610

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


[PATCH] D90984: Update matchers to be traverse-aware

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

LGTM, thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90984

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


[PATCH] D91628: [SystemZ][NFC] Group SystemZ tests in SystemZ folder

2020-11-17 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
abhina.sreeskantharajan requested review of this revision.

This patch creates a SystemZ folder in clang/test/CodeGen to contain 
systemz-related lit tests.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91628

Files:
  clang/test/CodeGen/SystemZ/align-systemz.c
  clang/test/CodeGen/SystemZ/builtins-systemz-error.c
  clang/test/CodeGen/SystemZ/builtins-systemz-error2.c
  clang/test/CodeGen/SystemZ/builtins-systemz-vector-constrained.c
  clang/test/CodeGen/SystemZ/builtins-systemz-vector-error.c
  clang/test/CodeGen/SystemZ/builtins-systemz-vector.c
  clang/test/CodeGen/SystemZ/builtins-systemz-vector2-constrained.c
  clang/test/CodeGen/SystemZ/builtins-systemz-vector2-error.c
  clang/test/CodeGen/SystemZ/builtins-systemz-vector2.c
  clang/test/CodeGen/SystemZ/builtins-systemz-vector3-error.c
  clang/test/CodeGen/SystemZ/builtins-systemz-vector3.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector-constrained.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector-error.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector2-constrained.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector2-error.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector2.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector3-constrained.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector3-error.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector3.c
  clang/test/CodeGen/SystemZ/builtins-systemz.c
  clang/test/CodeGen/SystemZ/mbackchain-2.c
  clang/test/CodeGen/SystemZ/mbackchain-3.c
  clang/test/CodeGen/SystemZ/mbackchain.c
  clang/test/CodeGen/SystemZ/s390x-packed-struct-func-arg.c
  clang/test/CodeGen/SystemZ/systemz-abi-vector.c
  clang/test/CodeGen/SystemZ/systemz-abi.c
  clang/test/CodeGen/SystemZ/systemz-inline-asm-02.c
  clang/test/CodeGen/SystemZ/systemz-inline-asm.c
  clang/test/CodeGen/SystemZ/zos-alignment.c
  clang/test/CodeGen/SystemZ/zvector.c
  clang/test/CodeGen/SystemZ/zvector2.c
  clang/test/CodeGen/align-systemz.c
  clang/test/CodeGen/builtins-systemz-error.c
  clang/test/CodeGen/builtins-systemz-error2.c
  clang/test/CodeGen/builtins-systemz-vector-constrained.c
  clang/test/CodeGen/builtins-systemz-vector-error.c
  clang/test/CodeGen/builtins-systemz-vector.c
  clang/test/CodeGen/builtins-systemz-vector2-constrained.c
  clang/test/CodeGen/builtins-systemz-vector2-error.c
  clang/test/CodeGen/builtins-systemz-vector2.c
  clang/test/CodeGen/builtins-systemz-vector3-error.c
  clang/test/CodeGen/builtins-systemz-vector3.c
  clang/test/CodeGen/builtins-systemz-zvector-constrained.c
  clang/test/CodeGen/builtins-systemz-zvector-error.c
  clang/test/CodeGen/builtins-systemz-zvector.c
  clang/test/CodeGen/builtins-systemz-zvector2-constrained.c
  clang/test/CodeGen/builtins-systemz-zvector2-error.c
  clang/test/CodeGen/builtins-systemz-zvector2.c
  clang/test/CodeGen/builtins-systemz-zvector3-constrained.c
  clang/test/CodeGen/builtins-systemz-zvector3-error.c
  clang/test/CodeGen/builtins-systemz-zvector3.c
  clang/test/CodeGen/builtins-systemz.c
  clang/test/CodeGen/mbackchain-2.c
  clang/test/CodeGen/mbackchain-3.c
  clang/test/CodeGen/mbackchain.c
  clang/test/CodeGen/s390x-packed-struct-func-arg.c
  clang/test/CodeGen/systemz-abi-vector.c
  clang/test/CodeGen/systemz-abi.c
  clang/test/CodeGen/systemz-inline-asm-02.c
  clang/test/CodeGen/systemz-inline-asm.c
  clang/test/CodeGen/zos-alignment.c
  clang/test/CodeGen/zvector.c
  clang/test/CodeGen/zvector2.c




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


[PATCH] D91628: [SystemZ][NFC] Group SystemZ tests in SystemZ folder

2020-11-17 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 305781.
abhina.sreeskantharajan added a comment.

Add one more testcase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91628

Files:
  clang/test/CodeGen/SystemZ/align-systemz.c
  clang/test/CodeGen/SystemZ/builtins-systemz-error.c
  clang/test/CodeGen/SystemZ/builtins-systemz-error2.c
  clang/test/CodeGen/SystemZ/builtins-systemz-vector-constrained.c
  clang/test/CodeGen/SystemZ/builtins-systemz-vector-error.c
  clang/test/CodeGen/SystemZ/builtins-systemz-vector.c
  clang/test/CodeGen/SystemZ/builtins-systemz-vector2-constrained.c
  clang/test/CodeGen/SystemZ/builtins-systemz-vector2-error.c
  clang/test/CodeGen/SystemZ/builtins-systemz-vector2.c
  clang/test/CodeGen/SystemZ/builtins-systemz-vector3-error.c
  clang/test/CodeGen/SystemZ/builtins-systemz-vector3.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector-constrained.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector-error.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector2-constrained.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector2-error.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector2.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector3-constrained.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector3-error.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector3.c
  clang/test/CodeGen/SystemZ/builtins-systemz.c
  clang/test/CodeGen/SystemZ/mbackchain-2.c
  clang/test/CodeGen/SystemZ/mbackchain-3.c
  clang/test/CodeGen/SystemZ/mbackchain.c
  clang/test/CodeGen/SystemZ/s390x-packed-struct-func-arg.c
  clang/test/CodeGen/SystemZ/systemz-abi-vector.c
  clang/test/CodeGen/SystemZ/systemz-abi.c
  clang/test/CodeGen/SystemZ/systemz-abi.cpp
  clang/test/CodeGen/SystemZ/systemz-inline-asm-02.c
  clang/test/CodeGen/SystemZ/systemz-inline-asm.c
  clang/test/CodeGen/SystemZ/zos-alignment.c
  clang/test/CodeGen/SystemZ/zvector.c
  clang/test/CodeGen/SystemZ/zvector2.c
  clang/test/CodeGen/align-systemz.c
  clang/test/CodeGen/builtins-systemz-error.c
  clang/test/CodeGen/builtins-systemz-error2.c
  clang/test/CodeGen/builtins-systemz-vector-constrained.c
  clang/test/CodeGen/builtins-systemz-vector-error.c
  clang/test/CodeGen/builtins-systemz-vector.c
  clang/test/CodeGen/builtins-systemz-vector2-constrained.c
  clang/test/CodeGen/builtins-systemz-vector2-error.c
  clang/test/CodeGen/builtins-systemz-vector2.c
  clang/test/CodeGen/builtins-systemz-vector3-error.c
  clang/test/CodeGen/builtins-systemz-vector3.c
  clang/test/CodeGen/builtins-systemz-zvector-constrained.c
  clang/test/CodeGen/builtins-systemz-zvector-error.c
  clang/test/CodeGen/builtins-systemz-zvector.c
  clang/test/CodeGen/builtins-systemz-zvector2-constrained.c
  clang/test/CodeGen/builtins-systemz-zvector2-error.c
  clang/test/CodeGen/builtins-systemz-zvector2.c
  clang/test/CodeGen/builtins-systemz-zvector3-constrained.c
  clang/test/CodeGen/builtins-systemz-zvector3-error.c
  clang/test/CodeGen/builtins-systemz-zvector3.c
  clang/test/CodeGen/builtins-systemz.c
  clang/test/CodeGen/mbackchain-2.c
  clang/test/CodeGen/mbackchain-3.c
  clang/test/CodeGen/mbackchain.c
  clang/test/CodeGen/s390x-packed-struct-func-arg.c
  clang/test/CodeGen/systemz-abi-vector.c
  clang/test/CodeGen/systemz-abi.c
  clang/test/CodeGen/systemz-abi.cpp
  clang/test/CodeGen/systemz-inline-asm-02.c
  clang/test/CodeGen/systemz-inline-asm.c
  clang/test/CodeGen/zos-alignment.c
  clang/test/CodeGen/zvector.c
  clang/test/CodeGen/zvector2.c




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


[PATCH] D91610: [clangd] Add OverridenBy Relation to index.

2020-11-17 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 updated this revision to Diff 305780.
usaxena95 added a comment.
Herald added a subscriber: wenlei.

Updated sample input for index-serialization test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91610

Files:
  clang-tools-extra/clangd/index/Relation.cpp
  clang-tools-extra/clangd/index/Relation.h
  clang-tools-extra/clangd/index/Serialization.cpp
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp
  clang-tools-extra/clangd/test/index-serialization/Inputs/sample.h
  clang-tools-extra/clangd/test/index-serialization/Inputs/sample.idx
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp

Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -97,6 +97,9 @@
   const Range &Range = ::testing::get<1>(arg);
   return rangesMatch(Pos.Location, Range);
 }
+MATCHER_P2(OverridenBy, Subject, Object, "") {
+  return arg == Relation{Subject.ID, RelationKind::OverridenBy, Object.ID};
+}
 ::testing::Matcher &>
 HaveRanges(const std::vector Ranges) {
   return ::testing::UnorderedPointwise(RefRange(), Ranges);
@@ -1031,7 +1034,7 @@
   HaveRanges(Header.ranges("macro");
 }
 
-TEST_F(SymbolCollectorTest, Relations) {
+TEST_F(SymbolCollectorTest, BaseOfRelations) {
   std::string Header = R"(
   class Base {};
   class Derived : public Base {};
@@ -1043,6 +1046,77 @@
   Contains(Relation{Base.ID, RelationKind::BaseOf, Derived.ID}));
 }
 
+TEST_F(SymbolCollectorTest, OverrideRelationsSimpleInheritance) {
+  std::string Header = R"cpp(
+class A {
+  virtual void foo();
+};
+class B : public A {
+  void foo() override;  // A::foo
+  virtual void bar();
+};
+class C : public B {
+  void bar() override;  // B::bar
+};
+class D: public C {
+  void foo() override;  // B::foo
+  void bar() override;  // C::bar
+};
+  )cpp";
+  runSymbolCollector(Header, /*Main=*/"");
+  const Symbol &AFoo = findSymbol(Symbols, "A::foo");
+  const Symbol &BFoo = findSymbol(Symbols, "B::foo");
+  const Symbol &DFoo = findSymbol(Symbols, "D::foo");
+
+  const Symbol &BBar = findSymbol(Symbols, "B::bar");
+  const Symbol &CBar = findSymbol(Symbols, "C::bar");
+  const Symbol &DBar = findSymbol(Symbols, "D::bar");
+
+  std::vector Result;
+  for (const Relation &R : Relations)
+if (R.Predicate == RelationKind::OverridenBy)
+  Result.push_back(R);
+  EXPECT_THAT(Result, UnorderedElementsAre(
+  OverridenBy(AFoo, BFoo), OverridenBy(BBar, CBar),
+  OverridenBy(BFoo, DFoo), OverridenBy(CBar, DBar)));
+}
+
+TEST_F(SymbolCollectorTest, OverrideRelationsMultipleInheritance) {
+  std::string Header = R"cpp(
+class A {
+  virtual void foo();
+};
+class B {
+  virtual void bar();
+};
+class C : public B {
+  void bar() override;  // B::bar
+  virtual void baz();
+}
+class D : public A, C {
+  void foo() override;  // A::foo
+  void bar() override;  // C::bar
+  void baz() override;  // C::baz
+};
+  )cpp";
+  runSymbolCollector(Header, /*Main=*/"");
+  const Symbol &AFoo = findSymbol(Symbols, "A::foo");
+  const Symbol &BBar = findSymbol(Symbols, "B::bar");
+  const Symbol &CBar = findSymbol(Symbols, "C::bar");
+  const Symbol &CBaz = findSymbol(Symbols, "C::baz");
+  const Symbol &DFoo = findSymbol(Symbols, "D::foo");
+  const Symbol &DBar = findSymbol(Symbols, "D::bar");
+  const Symbol &DBaz = findSymbol(Symbols, "D::baz");
+
+  std::vector Result;
+  for (const Relation &R : Relations)
+if (R.Predicate == RelationKind::OverridenBy)
+  Result.push_back(R);
+  EXPECT_THAT(Result, UnorderedElementsAre(
+  OverridenBy(BBar, CBar), OverridenBy(AFoo, DFoo),
+  OverridenBy(CBar, DBar), OverridenBy(CBaz, DBaz)));
+}
+
 TEST_F(SymbolCollectorTest, CountReferences) {
   const std::string Header = R"(
 class W;
Index: clang-tools-extra/clangd/test/index-serialization/Inputs/sample.h
===
--- clang-tools-extra/clangd/test/index-serialization/Inputs/sample.h
+++ clang-tools-extra/clangd/test/index-serialization/Inputs/sample.h
@@ -1,4 +1,6 @@
 #pragma once
 
 // Introduce a symbol.
-struct Foo {};
+struct Foo {
+  virtual void Func() {}
+};
Index: clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp
===
--- clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp
+++ clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp
@@ -2,4 +2,6 @@
 #include "sam

[PATCH] D91610: [clangd] Add OverriddenBy Relation to index.

2020-11-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: 
clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp:6
+struct Bar : public Foo {
+  void Func() override {}
+};

could you also add a comment for the reason we have this in the test (i.e. 
Introduces an `OverridenBy` relation)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91610

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


[PATCH] D91610: [clangd] Add OverriddenBy Relation to index.

2020-11-17 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 added inline comments.



Comment at: clang-tools-extra/clangd/index/Relation.h:24
   BaseOf,
+  OverridenBy,
 };

Quuxplusone wrote:
> s/Overriden/Overridden/g
Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91610

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


[PATCH] D91610: [clangd] Add OverriddenBy Relation to index.

2020-11-17 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 updated this revision to Diff 305783.
usaxena95 marked 2 inline comments as done.
usaxena95 added a comment.

s/OverridenBy/OverriddenBy


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91610

Files:
  clang-tools-extra/clangd/index/Relation.cpp
  clang-tools-extra/clangd/index/Relation.h
  clang-tools-extra/clangd/index/Serialization.cpp
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp
  clang-tools-extra/clangd/test/index-serialization/Inputs/sample.h
  clang-tools-extra/clangd/test/index-serialization/Inputs/sample.idx
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp

Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -97,6 +97,9 @@
   const Range &Range = ::testing::get<1>(arg);
   return rangesMatch(Pos.Location, Range);
 }
+MATCHER_P2(OverriddenBy, Subject, Object, "") {
+  return arg == Relation{Subject.ID, RelationKind::OverriddenBy, Object.ID};
+}
 ::testing::Matcher &>
 HaveRanges(const std::vector Ranges) {
   return ::testing::UnorderedPointwise(RefRange(), Ranges);
@@ -1031,7 +1034,7 @@
   HaveRanges(Header.ranges("macro");
 }
 
-TEST_F(SymbolCollectorTest, Relations) {
+TEST_F(SymbolCollectorTest, BaseOfRelations) {
   std::string Header = R"(
   class Base {};
   class Derived : public Base {};
@@ -1043,6 +1046,77 @@
   Contains(Relation{Base.ID, RelationKind::BaseOf, Derived.ID}));
 }
 
+TEST_F(SymbolCollectorTest, OverrideRelationsSimpleInheritance) {
+  std::string Header = R"cpp(
+class A {
+  virtual void foo();
+};
+class B : public A {
+  void foo() override;  // A::foo
+  virtual void bar();
+};
+class C : public B {
+  void bar() override;  // B::bar
+};
+class D: public C {
+  void foo() override;  // B::foo
+  void bar() override;  // C::bar
+};
+  )cpp";
+  runSymbolCollector(Header, /*Main=*/"");
+  const Symbol &AFoo = findSymbol(Symbols, "A::foo");
+  const Symbol &BFoo = findSymbol(Symbols, "B::foo");
+  const Symbol &DFoo = findSymbol(Symbols, "D::foo");
+
+  const Symbol &BBar = findSymbol(Symbols, "B::bar");
+  const Symbol &CBar = findSymbol(Symbols, "C::bar");
+  const Symbol &DBar = findSymbol(Symbols, "D::bar");
+
+  std::vector Result;
+  for (const Relation &R : Relations)
+if (R.Predicate == RelationKind::OverriddenBy)
+  Result.push_back(R);
+  EXPECT_THAT(Result, UnorderedElementsAre(
+  OverriddenBy(AFoo, BFoo), OverriddenBy(BBar, CBar),
+  OverriddenBy(BFoo, DFoo), OverriddenBy(CBar, DBar)));
+}
+
+TEST_F(SymbolCollectorTest, OverrideRelationsMultipleInheritance) {
+  std::string Header = R"cpp(
+class A {
+  virtual void foo();
+};
+class B {
+  virtual void bar();
+};
+class C : public B {
+  void bar() override;  // B::bar
+  virtual void baz();
+}
+class D : public A, C {
+  void foo() override;  // A::foo
+  void bar() override;  // C::bar
+  void baz() override;  // C::baz
+};
+  )cpp";
+  runSymbolCollector(Header, /*Main=*/"");
+  const Symbol &AFoo = findSymbol(Symbols, "A::foo");
+  const Symbol &BBar = findSymbol(Symbols, "B::bar");
+  const Symbol &CBar = findSymbol(Symbols, "C::bar");
+  const Symbol &CBaz = findSymbol(Symbols, "C::baz");
+  const Symbol &DFoo = findSymbol(Symbols, "D::foo");
+  const Symbol &DBar = findSymbol(Symbols, "D::bar");
+  const Symbol &DBaz = findSymbol(Symbols, "D::baz");
+
+  std::vector Result;
+  for (const Relation &R : Relations)
+if (R.Predicate == RelationKind::OverriddenBy)
+  Result.push_back(R);
+  EXPECT_THAT(Result, UnorderedElementsAre(
+  OverriddenBy(BBar, CBar), OverriddenBy(AFoo, DFoo),
+  OverriddenBy(CBar, DBar), OverriddenBy(CBaz, DBaz)));
+}
+
 TEST_F(SymbolCollectorTest, CountReferences) {
   const std::string Header = R"(
 class W;
Index: clang-tools-extra/clangd/test/index-serialization/Inputs/sample.h
===
--- clang-tools-extra/clangd/test/index-serialization/Inputs/sample.h
+++ clang-tools-extra/clangd/test/index-serialization/Inputs/sample.h
@@ -1,4 +1,6 @@
 #pragma once
 
 // Introduce a symbol.
-struct Foo {};
+struct Foo {
+  virtual void Func() {}
+};
Index: clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp
===
--- clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp
+++ clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp
@@ -2,4 +2,6 @@
 #include "sample

[clang] 46846ac - [Matrix] Add inline assembly test case.

2020-11-17 Thread Florian Hahn via cfe-commits

Author: Florian Hahn
Date: 2020-11-17T15:13:16Z
New Revision: 46846ac45b2c44aa6e33be5ac498309f465ba7eb

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

LOG: [Matrix] Add inline assembly test case.

This patch adds a new test cases which uses a matrix value as memory
inline assembly argument. Currently the pointer element type does not
match the vector type.

Added: 


Modified: 
clang/test/CodeGen/matrix-type.c

Removed: 




diff  --git a/clang/test/CodeGen/matrix-type.c 
b/clang/test/CodeGen/matrix-type.c
index 31d2497b7986..399984b50c69 100644
--- a/clang/test/CodeGen/matrix-type.c
+++ b/clang/test/CodeGen/matrix-type.c
@@ -156,3 +156,21 @@ void matrix_struct(Matrix *a, Matrix *b) {
   // CHECK-NEXT:ret void
   b->Data = a->Data;
 }
+
+typedef double dx4x4_t __attribute__((matrix_type(4, 4)));
+void matrix_inline_asm_memory_readwrite() {
+  // CHECK-LABEL: define void @matrix_inline_asm_memory_readwrite()
+  // CHECK-NEXT:  entry:
+  // CHECK-NEXT:[[ALLOCA:%.+]] = alloca [16 x double], align 8
+  // CHECK-NEXT:[[PTR:%.+]] = bitcast [16 x double]* [[ALLOCA]] to <16 x 
double>*
+  // CHECK-NEXT:[[VAL:%.+]] = load <16 x double>, <16 x double>* [[PTR]], 
align 8
+  // FIXME: Pointer element type does not match the vector type.
+  // CHECK-NEXT:call void asm sideeffect "", 
"=*r|m,0,~{memory},~{dirflag},~{fpsr},~{flags}"([16 x double]* [[ALLOCA]], <16 
x double> [[VAL]])
+  // CHECK-NEXT:ret void
+
+  dx4x4_t m;
+  asm volatile(""
+   : "+r,m"(m)
+   :
+   : "memory");
+}



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


[PATCH] D91610: [clangd] Add OverriddenBy Relation to index.

2020-11-17 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 updated this revision to Diff 305787.
usaxena95 marked an inline comment as done.
usaxena95 added a comment.

Add documentation for change in index test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91610

Files:
  clang-tools-extra/clangd/index/Relation.cpp
  clang-tools-extra/clangd/index/Relation.h
  clang-tools-extra/clangd/index/Serialization.cpp
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp
  clang-tools-extra/clangd/test/index-serialization/Inputs/sample.h
  clang-tools-extra/clangd/test/index-serialization/Inputs/sample.idx
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp

Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -97,6 +97,9 @@
   const Range &Range = ::testing::get<1>(arg);
   return rangesMatch(Pos.Location, Range);
 }
+MATCHER_P2(OverriddenBy, Subject, Object, "") {
+  return arg == Relation{Subject.ID, RelationKind::OverriddenBy, Object.ID};
+}
 ::testing::Matcher &>
 HaveRanges(const std::vector Ranges) {
   return ::testing::UnorderedPointwise(RefRange(), Ranges);
@@ -1031,7 +1034,7 @@
   HaveRanges(Header.ranges("macro");
 }
 
-TEST_F(SymbolCollectorTest, Relations) {
+TEST_F(SymbolCollectorTest, BaseOfRelations) {
   std::string Header = R"(
   class Base {};
   class Derived : public Base {};
@@ -1043,6 +1046,77 @@
   Contains(Relation{Base.ID, RelationKind::BaseOf, Derived.ID}));
 }
 
+TEST_F(SymbolCollectorTest, OverrideRelationsSimpleInheritance) {
+  std::string Header = R"cpp(
+class A {
+  virtual void foo();
+};
+class B : public A {
+  void foo() override;  // A::foo
+  virtual void bar();
+};
+class C : public B {
+  void bar() override;  // B::bar
+};
+class D: public C {
+  void foo() override;  // B::foo
+  void bar() override;  // C::bar
+};
+  )cpp";
+  runSymbolCollector(Header, /*Main=*/"");
+  const Symbol &AFoo = findSymbol(Symbols, "A::foo");
+  const Symbol &BFoo = findSymbol(Symbols, "B::foo");
+  const Symbol &DFoo = findSymbol(Symbols, "D::foo");
+
+  const Symbol &BBar = findSymbol(Symbols, "B::bar");
+  const Symbol &CBar = findSymbol(Symbols, "C::bar");
+  const Symbol &DBar = findSymbol(Symbols, "D::bar");
+
+  std::vector Result;
+  for (const Relation &R : Relations)
+if (R.Predicate == RelationKind::OverriddenBy)
+  Result.push_back(R);
+  EXPECT_THAT(Result, UnorderedElementsAre(
+  OverriddenBy(AFoo, BFoo), OverriddenBy(BBar, CBar),
+  OverriddenBy(BFoo, DFoo), OverriddenBy(CBar, DBar)));
+}
+
+TEST_F(SymbolCollectorTest, OverrideRelationsMultipleInheritance) {
+  std::string Header = R"cpp(
+class A {
+  virtual void foo();
+};
+class B {
+  virtual void bar();
+};
+class C : public B {
+  void bar() override;  // B::bar
+  virtual void baz();
+}
+class D : public A, C {
+  void foo() override;  // A::foo
+  void bar() override;  // C::bar
+  void baz() override;  // C::baz
+};
+  )cpp";
+  runSymbolCollector(Header, /*Main=*/"");
+  const Symbol &AFoo = findSymbol(Symbols, "A::foo");
+  const Symbol &BBar = findSymbol(Symbols, "B::bar");
+  const Symbol &CBar = findSymbol(Symbols, "C::bar");
+  const Symbol &CBaz = findSymbol(Symbols, "C::baz");
+  const Symbol &DFoo = findSymbol(Symbols, "D::foo");
+  const Symbol &DBar = findSymbol(Symbols, "D::bar");
+  const Symbol &DBaz = findSymbol(Symbols, "D::baz");
+
+  std::vector Result;
+  for (const Relation &R : Relations)
+if (R.Predicate == RelationKind::OverriddenBy)
+  Result.push_back(R);
+  EXPECT_THAT(Result, UnorderedElementsAre(
+  OverriddenBy(BBar, CBar), OverriddenBy(AFoo, DFoo),
+  OverriddenBy(CBar, DBar), OverriddenBy(CBaz, DBaz)));
+}
+
 TEST_F(SymbolCollectorTest, CountReferences) {
   const std::string Header = R"(
 class W;
Index: clang-tools-extra/clangd/test/index-serialization/Inputs/sample.h
===
--- clang-tools-extra/clangd/test/index-serialization/Inputs/sample.h
+++ clang-tools-extra/clangd/test/index-serialization/Inputs/sample.h
@@ -1,4 +1,6 @@
 #pragma once
 
 // Introduce a symbol.
-struct Foo {};
+struct Foo {
+  virtual void Func() {}
+};
Index: clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp
===
--- clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp
+++ clang-tools-extra/clangd/test/index-serialization/Inputs/sample.cpp
@@ -2,4 +2,7 @@

[PATCH] D90188: Add support for attribute 'using_if_exists'

2020-11-17 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington updated this revision to Diff 305788.
erik.pilkington marked 6 inline comments as done.
erik.pilkington added a comment.

Split off parsing support for C++ attributes.


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

https://reviews.llvm.org/D90188

Files:
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DeclNodes.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/DeclBase.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTCommon.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/Parser/using-if-exists-attr.cpp
  clang/test/SemaCXX/attr-deprecated.cpp
  clang/test/SemaCXX/using-if-exists.cpp
  clang/tools/libclang/CIndex.cpp

Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -6414,6 +6414,7 @@
   case Decl::Concept:
   case Decl::LifetimeExtendedTemporary:
   case Decl::RequiresExprBody:
+  case Decl::UnresolvedUsingIfExists:
 return C;
 
   // Declaration kinds that don't make any sense here, but are
Index: clang/test/SemaCXX/using-if-exists.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/using-if-exists.cpp
@@ -0,0 +1,207 @@
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only %s -verify
+
+#define UIE __attribute__((using_if_exists))
+
+namespace test_basic {
+namespace NS {}
+
+using NS::x UIE; // expected-note{{using declaration annotated with 'using_if_exists' here}}
+x usex(); // expected-error{{reference to unresolved using declaration}}
+
+using NotNS::x UIE; // expected-error{{use of undeclared identifier 'NotNS'}}
+} // test_basic
+
+namespace test_redecl {
+namespace NS {}
+
+using NS::x UIE;
+using NS::x UIE;
+
+namespace NS1 {}
+namespace NS2 {}
+namespace NS3 {
+int A(); // expected-note{{target of using declaration}}
+struct B {}; // expected-note{{target of using declaration}}
+int C(); // expected-note{{conflicting declaration}}
+struct D {}; // expected-note{{conflicting declaration}}
+}
+
+using NS1::A UIE;
+using NS2::A UIE; // expected-note{{using declaration annotated with 'using_if_exists' here}} expected-note{{conflicting declaration}}
+using NS3::A UIE; // expected-error{{target of using declaration conflicts with declaration already in scope}}
+int i = A(); // expected-error{{reference to unresolved using declaration}}
+
+using NS1::B UIE;
+using NS2::B UIE; // expected-note{{conflicting declaration}} expected-note{{using declaration annotated with 'using_if_exists' here}}
+using NS3::B UIE; // expected-error{{target of using declaration conflicts with declaration already in scope}}
+B myB; // expected-error{{reference to unresolved using declaration}}
+
+using NS3::C UIE;
+using NS2::C UIE; // expected-error{{target of using declaration conflicts with declaration already in scope}} expected-note{{target of using declaration}}
+int j = C();
+
+using NS3::D UIE;
+using NS2::D UIE; // expected-error{{target of using declaration conflicts with declaration already in scope}} expected-note{{target of using declaration}}
+D myD;
+} // test_redecl
+
+namespace test_dependent {
+template 
+struct S : B {
+  using B::mf UIE; // expected-note 3 {{using declaration annotated with 'using_if_exists' here}}
+  using typename B::mt UIE; // expected-note{{using declaration annotated with 'using_if_exists' here}}
+};
+
+struct BaseEmpty {
+};
+struct BaseNonEmpty {
+  void mf();
+  typedef int mt;
+};
+
+void f() {
+  S empty;
+  S nonempty;
+  empty.mf(); // expected-error {{reference to unresolved using declaration}}
+  nonempty.mf();
+  (&empty)->mf(); // expected-error {{reference to unresolved using declaration}}
+  (&nonempty)->mf();
+
+  S::mt y; // expected-error {{reference to unresolved using declaration}}
+  S::mt z;
+
+  S::mf(); // expected-error {{reference to unresolved using declaration}}
+}
+
+template 
+struct Implicit : B {
+  using B::mf UIE; // expected-note {{using declaration annotated with 'using_if_exists' here}}
+  using typename B::mt UIE; // expected-note 2 {{using declaration annotated with 'using_if_exists' here}}
+
+  void use() {
+mf(); // expected-error {{reference to unresolved using declaration}}
+mt x; // expected-error {{reference to unresolved using declaration}}
+  }
+
+  mt alsoUse(); // expected-error {{reference to unresolved using declaration}}
+};
+
+void testImplicit() {
+  Implicit nonemp

[PATCH] D91630: [Parse] Add parsing support for C++ attributes on using-declarations

2020-11-17 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington created this revision.
erik.pilkington added reviewers: aaron.ballman, rsmith, ldionne, Mordante.
Herald added subscribers: jdoerfert, ributzka, jkorous.
erik.pilkington requested review of this revision.

This is split off from D90188 .


https://reviews.llvm.org/D91630

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Parse/Parser.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/test/Parser/cxx0x-attributes.cpp

Index: clang/test/Parser/cxx0x-attributes.cpp
===
--- clang/test/Parser/cxx0x-attributes.cpp
+++ clang/test/Parser/cxx0x-attributes.cpp
@@ -131,7 +131,7 @@
 [[]] static_assert(true, ""); //expected-error {{an attribute list cannot appear here}}
 [[]] asm(""); // expected-error {{an attribute list cannot appear here}}
 
-[[]] using ns::i; // expected-error {{an attribute list cannot appear here}}
+[[]] using ns::i;
 [[unknown]] using namespace ns; // expected-warning {{unknown attribute 'unknown' ignored}}
 [[noreturn]] using namespace ns; // expected-error {{'noreturn' attribute only applies to functions}}
 namespace [[]] ns2 {} // expected-warning {{attributes on a namespace declaration are a C++17 extension}}
@@ -157,7 +157,16 @@
 [[]] using T = int; // expected-error {{an attribute list cannot appear here}}
 using T [[]] = int; // ok
 template using U [[]] = T;
-using ns::i [[]]; // expected-error {{an attribute list cannot appear here}}
+using ns::i [[]];
+using ns::i [[]], ns::i [[]]; // expected-warning {{use of multiple declarators in a single using declaration is a C++17 extension}}
+struct using_in_struct_base {
+  typedef int i, j, k, l;
+};
+struct using_in_struct : using_in_struct_base {
+  [[]] using using_in_struct_base::i;
+  using using_in_struct_base::j [[]];
+  [[]] using using_in_struct_base::k [[]], using_in_struct_base::l [[]]; // expected-warning {{use of multiple declarators in a single using declaration is a C++17 extension}}
+};
 using [[]] ns::i; // expected-error {{an attribute list cannot appear here}}
 using T [[unknown]] = int; // expected-warning {{unknown attribute 'unknown' ignored}}
 using T [[noreturn]] = int; // expected-error {{'noreturn' attribute only applies to functions}}
Index: clang/lib/Parse/ParseDeclCXX.cpp
===
--- clang/lib/Parse/ParseDeclCXX.cpp
+++ clang/lib/Parse/ParseDeclCXX.cpp
@@ -497,12 +497,8 @@
   }
 
   // Otherwise, it must be a using-declaration or an alias-declaration.
-
-  // Using declarations can't have attributes.
-  ProhibitAttributes(attrs);
-
   return ParseUsingDeclaration(Context, TemplateInfo, UsingLoc, DeclEnd,
-   AS_none);
+   attrs, AS_none);
 }
 
 /// ParseUsingDirective - Parse C++ using-directive, assumes
@@ -675,6 +671,7 @@
 Parser::ParseUsingDeclaration(DeclaratorContext Context,
   const ParsedTemplateInfo &TemplateInfo,
   SourceLocation UsingLoc, SourceLocation &DeclEnd,
+  ParsedAttributesWithRange &PrefixAttrs,
   AccessSpecifier AS) {
   // Check for misplaced attributes before the identifier in an
   // alias-declaration.
@@ -695,6 +692,8 @@
   return nullptr;
 }
 
+ProhibitAttributes(PrefixAttrs);
+
 // If we had any misplaced attributes from earlier, this is where they
 // should have been written.
 if (MisplacedAttrs.Range.isValid()) {
@@ -712,10 +711,8 @@
 return Actions.ConvertDeclToDeclGroup(AD, DeclFromDeclSpec);
   }
 
-  // C++11 attributes are not allowed on a using-declaration, but GNU ones
-  // are.
   ProhibitAttributes(MisplacedAttrs);
-  ProhibitAttributes(Attrs);
+  DiagnoseCXX11AttributeExtension(PrefixAttrs);
 
   // Diagnose an attempt to declare a templated using-declaration.
   // In C++11, alias-declarations can be templates:
@@ -733,8 +730,11 @@
 
   SmallVector DeclsInGroup;
   while (true) {
-// Parse (optional) attributes (most likely GNU strong-using extension).
+// Parse (optional) attributes.
 MaybeParseGNUAttributes(Attrs);
+MaybeParseCXX11Attributes(Attrs);
+DiagnoseCXX11AttributeExtension(Attrs);
+Attrs.addAll(PrefixAttrs.begin(), PrefixAttrs.end());
 
 if (InvalidDeclarator)
   SkipUntil(tok::comma, tok::semi, StopBeforeMatch);
@@ -2590,8 +2590,6 @@
   MaybeParseMicrosoftAttributes(attrs);
 
   if (Tok.is(tok::kw_using)) {
-ProhibitAttributes(attrs);
-
 // Eat 'using'.
 SourceLocation UsingLoc = ConsumeToken();
 
@@ -2610,7 +2608,7 @@
 SourceLocation DeclEnd;
 // Otherwise, it must be a using-declaration or an alias-declaration.
 return ParseUsingDeclaration(DeclaratorContext::MemberContext, TemplateInfo,
- UsingLoc, DeclEnd, AS);
+ Usin

[PATCH] D90188: Add support for attribute 'using_if_exists'

2020-11-17 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a comment.

In D90188#2397441 , @aaron.ballman 
wrote:

> FWIW, it'd be a bit easier if those changes were split off into their own 
> patch, as they're orthogonal to `using_if_exists`.

Ok, I moved this part to: https://reviews.llvm.org/D91630




Comment at: clang/include/clang/Basic/AttrDocs.td:5351
+the availability of those declarations is difficult or impossible to detect at
+compile time with the preprocessor.
+  }];

aaron.ballman wrote:
> Do you think the docs should call out that using the C++ spelling on a 
> `using` declaration is currently a Clang extension? It's a bit of an odd 
> place to put that information, but I don't know of where else to mention that 
> this attribute is nonportable in a few different ways.
Sure, I'll mention it. I'm also switching back to the GCC spelling here since 
we're warning on the C++ spelling by default.



Comment at: clang/include/clang/Basic/DiagnosticParseKinds.td:689
 def err_attributes_not_allowed : Error<"an attribute list cannot appear here">;
+def ext_cxx11_attr_placement : Extension<
+  "C++ does not allow an attribute list to appear here">,

aaron.ballman wrote:
> I'm not certain what @rsmith thinks, but I think this should be `ExtWarn` and 
> have the `DefaultIgnore` removed -- this is a conforming extension of 
> something that's nonportable even in the absence of any attributes in the 
> attribute list. e.g., `[[]] using foo::bar;``` is not portable to parse.
Sure, I'll update the docs to prefer using the GNU spelling if we're going to 
warn by default on this spelling.



Comment at: clang/include/clang/Serialization/ASTBitCodes.h:1364
+  /// An UnresolvedUsingIfExistsDecl record.
+  DECL_UNRESOLVED_USING_IF_EXISTS,
+

aaron.ballman wrote:
> Does this mean you need to bump `VERSION_MAJOR` as well?
Hmm, I don't think so, it looks like the git hash is taken into account based 
on the comment in ASTBitCodes.h:

```
/// Version 4 of AST files also requires that the version control branch and
/// revision match exactly, since there is no backward compatibility of
/// AST files at this time.
const unsigned VERSION_MAJOR = 11;
```

FWIW it seems like nobody else who adds new AST nodes is bumping this version.



Comment at: clang/test/Parser/cxx0x-attributes.cpp:160
 template using U [[]] = T;
-using ns::i [[]]; // expected-error {{an attribute list cannot appear here}}
+using ns::i [[]];
 using [[]] ns::i; // expected-error {{an attribute list cannot appear here}}

aaron.ballman wrote:
> Can you also add a test for `using foo [[]], bar []]];` syntax?
Sure, I did this in the parser patch.



Comment at: clang/test/SemaCXX/using-if-exists-attr.cpp:9-17
+using NS::x [[clang::using_if_exists]]; // expected-warning{{C++ does not 
allow an attribute list to appear here}}
+
+[[clang::using_if_exists]] // expected-warning{{C++ does not allow an 
attribute list to appear here}}
+using NS::not_there, NS::not_there2;
+
+using NS::not_there3, // expected-error {{no member named 'not_there3' in 
namespace 'NS'}}
+  NS::not_there4 [[clang::using_if_exists]]; // expected-warning{{C++ does 
not allow an attribute list to appear here}}

aaron.ballman wrote:
> These test cases look like they belong in a `Parser` test not a `SemaCXX` 
> test.
Sure, I moved this file over to Parser.


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

https://reviews.llvm.org/D90188

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


[PATCH] D90982: Ignore implicit nodes in IgnoreUnlessSpelledInSource mode

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

LGTM, thank you!




Comment at: clang/lib/ASTMatchers/ASTMatchFinder.cpp:164
   auto *LambdaNode = dyn_cast_or_null(StmtNode);
-  if (LambdaNode && !Finder->isTraversalAsIs())
+  if (LambdaNode && Finder->isTraversalIgnoringImplicitNodes())
 StmtToTraverse = LambdaNode;

Good catch!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90982

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


[PATCH] D91631: [Matrix] Adjust matrix pointer type for inline asm arguments.

2020-11-17 Thread Florian Hahn via Phabricator via cfe-commits
fhahn created this revision.
Herald added subscribers: cfe-commits, tschuett.
Herald added a project: clang.
fhahn requested review of this revision.

Matrix types in memory are represented as arrays, but accessed through
vector pointers, with the alignment specified on the access operation.

For inline assembly, update pointer arguments to use vector pointers.
Otherwise there will be a mis-match if the matrix is also an
input-argument which is represented as vector.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91631

Files:
  clang/lib/CodeGen/CGStmt.cpp
  clang/test/CodeGen/matrix-type.c


Index: clang/test/CodeGen/matrix-type.c
===
--- clang/test/CodeGen/matrix-type.c
+++ clang/test/CodeGen/matrix-type.c
@@ -162,10 +162,10 @@
   // CHECK-LABEL: define void @matrix_inline_asm_memory_readwrite()
   // CHECK-NEXT:  entry:
   // CHECK-NEXT:[[ALLOCA:%.+]] = alloca [16 x double], align 8
-  // CHECK-NEXT:[[PTR:%.+]] = bitcast [16 x double]* [[ALLOCA]] to <16 x 
double>*
-  // CHECK-NEXT:[[VAL:%.+]] = load <16 x double>, <16 x double>* [[PTR]], 
align 8
-  // FIXME: Pointer element type does not match the vector type.
-  // CHECK-NEXT:call void asm sideeffect "", 
"=*r|m,0,~{memory},~{dirflag},~{fpsr},~{flags}"([16 x double]* [[ALLOCA]], <16 
x double> [[VAL]])
+  // CHECK-NEXT:[[PTR1:%.+]] = bitcast [16 x double]* [[ALLOCA]] to <16 x 
double>*
+  // CHECK-NEXT:[[PTR2:%.+]] = bitcast [16 x double]* [[ALLOCA]] to <16 x 
double>*
+  // CHECK-NEXT:[[VAL:%.+]] = load <16 x double>, <16 x double>* [[PTR2]], 
align 8
+  // CHECK-NEXT:call void asm sideeffect "", 
"=*r|m,0,~{memory},~{dirflag},~{fpsr},~{flags}"(<16 x double>* [[PTR1]], <16 x 
double> [[VAL]])
   // CHECK-NEXT:ret void
 
   dx4x4_t m;
Index: clang/lib/CodeGen/CGStmt.cpp
===
--- clang/lib/CodeGen/CGStmt.cpp
+++ clang/lib/CodeGen/CGStmt.cpp
@@ -2306,8 +2306,21 @@
 std::max((uint64_t)LargestVectorWidth,
  VT->getPrimitiveSizeInBits().getKnownMinSize());
 } else {
-  ArgTypes.push_back(Dest.getAddress(*this).getType());
-  Args.push_back(Dest.getPointer(*this));
+  llvm::Type *DestAddrTy = Dest.getAddress(*this).getType();
+  llvm::Value *DestPtr = Dest.getPointer(*this);
+  // Matrix types in memory are represented by arrays, but accessed through
+  // vector pointers, with the alignment specified on the access operation.
+  // For inline assembly, update pointer arguments to use vector pointers.
+  // Otherwise there will be a mis-match if the matrix is also an
+  // input-argument which is represented as vector.
+  if (isa(OutExpr->getType().getCanonicalType())) {
+DestAddrTy = llvm::PointerType::get(
+ConvertType(OutExpr->getType()),
+cast(DestAddrTy)->getAddressSpace());
+DestPtr = Builder.CreateBitCast(DestPtr, DestAddrTy);
+  }
+  ArgTypes.push_back(DestAddrTy);
+  Args.push_back(DestPtr);
   Constraints += "=*";
   Constraints += OutputConstraint;
   ReadOnly = ReadNone = false;


Index: clang/test/CodeGen/matrix-type.c
===
--- clang/test/CodeGen/matrix-type.c
+++ clang/test/CodeGen/matrix-type.c
@@ -162,10 +162,10 @@
   // CHECK-LABEL: define void @matrix_inline_asm_memory_readwrite()
   // CHECK-NEXT:  entry:
   // CHECK-NEXT:[[ALLOCA:%.+]] = alloca [16 x double], align 8
-  // CHECK-NEXT:[[PTR:%.+]] = bitcast [16 x double]* [[ALLOCA]] to <16 x double>*
-  // CHECK-NEXT:[[VAL:%.+]] = load <16 x double>, <16 x double>* [[PTR]], align 8
-  // FIXME: Pointer element type does not match the vector type.
-  // CHECK-NEXT:call void asm sideeffect "", "=*r|m,0,~{memory},~{dirflag},~{fpsr},~{flags}"([16 x double]* [[ALLOCA]], <16 x double> [[VAL]])
+  // CHECK-NEXT:[[PTR1:%.+]] = bitcast [16 x double]* [[ALLOCA]] to <16 x double>*
+  // CHECK-NEXT:[[PTR2:%.+]] = bitcast [16 x double]* [[ALLOCA]] to <16 x double>*
+  // CHECK-NEXT:[[VAL:%.+]] = load <16 x double>, <16 x double>* [[PTR2]], align 8
+  // CHECK-NEXT:call void asm sideeffect "", "=*r|m,0,~{memory},~{dirflag},~{fpsr},~{flags}"(<16 x double>* [[PTR1]], <16 x double> [[VAL]])
   // CHECK-NEXT:ret void
 
   dx4x4_t m;
Index: clang/lib/CodeGen/CGStmt.cpp
===
--- clang/lib/CodeGen/CGStmt.cpp
+++ clang/lib/CodeGen/CGStmt.cpp
@@ -2306,8 +2306,21 @@
 std::max((uint64_t)LargestVectorWidth,
  VT->getPrimitiveSizeInBits().getKnownMinSize());
 } else {
-  ArgTypes.push_back(Dest.getAddress(*this).getType());
-  Args.push_back(Dest.getPointer(*this));
+  llvm::Type *DestAddrTy = Dest.getAddress(*this).getType();
+  llvm::Value *DestPtr = Dest.getPointer(*this);
+  // Ma

  1   2   3   >