[PATCH] D112024: [clang] diagnose_as attribute for Fortify diagnosing like builtins.

2021-10-28 Thread serge via Phabricator via cfe-commits
serge-sans-paille added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:3822
+def DiagnoseAs : InheritableAttr {
+  let Spellings = [Clang<"diagnose_as">];
+  let Args = [ExprArgument<"Function">,

aaron.ballman wrote:
> george.burgess.iv wrote:
> > purely subjective nit: `diagnose_as` feels a bit too generic. if you agree, 
> > does `diagnose_as_builtin` sound potentially better?
> Agreed on it being a bit generic -- it sounds like this is only useful for 
> Fortify, so I wonder if I'm wrong about that or whether we should name it 
> `fortify_diagnose_as_builtin` or `fortify_diagnostic`, etc.
(Jumping in a  bit late) I second the `diagnose_as_builtin` name. But then we 
should check that the attribute is only set on inline builtin declaration (as 
in `Decl::isInlineBuiltinDeclaration`) and state so in the documentation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112024

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


[PATCH] D112158: mips: fix search path for multilib o32

2021-10-28 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan accepted this revision.
atanasyan added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D112158

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


[PATCH] D112459: [AArch64] Enablement of Cortex-X2

2021-10-28 Thread Dave Green via Phabricator via cfe-commits
dmgreen accepted this revision.
dmgreen added a comment.
This revision is now accepted and ready to land.

Thanks. LGTM


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

https://reviews.llvm.org/D112459

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


[PATCH] D107339: [analyzer] Retrieve a character from StringLiteral as an initializer for constant arrays.

2021-10-28 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

I'm still worried about regressions.
Please split the patch into two by separating the tests into an NFC patch, on 
which you would apply the behavioral change.
That way it would be clear what and why changed. It would also help us to see 
what previously had defects you plan to preserve and annotate with FIXMEs.




Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1757-1760
+  // FIXME: Nevertheless, we can't do the same for cases, like:
+  //   const char *str = "123"; // literal length is 4
+  //   char c = str[41];// offset is 41
+  // It should be properly handled before reaching this point.

ASDenysPetrov wrote:
> ASDenysPetrov wrote:
> > steakhal wrote:
> > > martong wrote:
> > > > ASDenysPetrov wrote:
> > > > > ASDenysPetrov wrote:
> > > > > > martong wrote:
> > > > > > > Thanks for updating the patch! However, this `FIXME` makes me 
> > > > > > > worried. Do you think you could pass the `Decl` itself to 
> > > > > > > `getSValFromInitListExpr` in order to be able to check whether 
> > > > > > > the type is a pointer or an array? 
> > > > > > This worried me as well. Currently I can't find a way to get the 
> > > > > > `Decl` for `SL`.
> > > > > > 
> > > > > We can load this as is for now with mentioning the known issue.
> > > > This might cause some itchy false positives. Perhaps, we could address 
> > > > this in a follow-up patch and then commit them together?
> > > > Currently I can't find a way to get the Decl for SL.
> > > Why do you need a Decl? The SVal's gotta be an `Element{"123",41 
> > > S64b,char}` for the example in the comment (*).
> > > 
> > > (*) With a minor modification: https://godbolt.org/z/7zhGMnf7P
> > > ```lang=C++
> > > template  void clang_analyzer_dump(T);
> > > const char * const str = "123";
> > > const char * str2 = "123";
> > > void top() {
> > >   clang_analyzer_dump(&str[41]);  // &Element{"123",41 S64b,char}
> > >   clang_analyzer_dump(&str2[41]); // &Element{SymRegion{reg_$0 > > * str2>},41 S64b,char}
> > > }
> > > ```
> > Because only `Decl` can tell us whether it is a `const char str[42]` or 
> > `const char * const str`. We can't say anything just looking at `SVal`.
> > This might cause some itchy false positives. Perhaps, we could address this 
> > in a follow-up patch and then commit them together?
> This will produce not more FP as before, even less. I didn't change the 
> behavior specifically here. I just found the issue point to it.
I probably still miss the point. https://godbolt.org/z/EMhbq3745
Since the case you mention is actually represented by a `NonParamVarRegion` 
which holds a pointer to its decl.
```lang=C++
const char str3[43] = "123";
void top() {
  clang_analyzer_dump(&str3[41]); // &Element{str3,41 S64b,char}
  //NonParamVarRegion  --- (it can print the name of 
the *decl*)
}
```

---

What I wanted to highlight is, that it's a non-issue. In your example you had a 
**non-const** global variable, thus we could not infer any meaningful initial 
value for it, and that is actually the expected behavior. As soon as I marked 
the `str` pointer //const// (along with its //pointee//), suddenly the analyzer 
can infer its initial value.


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

https://reviews.llvm.org/D107339

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


[clang] 284c2eb - [clang][MIPS] Fix search path for Debian multilib O32

2021-10-28 Thread Simon Atanasyan via cfe-commits

Author: YunQiang Su
Date: 2021-10-28T10:23:06+03:00
New Revision: 284c2ebc5e057a0fda23257b899260d274e69a27

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

LOG: [clang][MIPS] Fix search path for Debian multilib O32

In the situation of multilib, the gcc objects are in a /32 directory. On
Debian, the libraries is under /libo32 to avoid confliction. This patch
enables clang find gcc in /32, and C lib in /libo32.

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

Added: 
clang/test/Driver/Inputs/debian_6_mips64_tree/libo32/.keep

clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64-linux-gnuabi64/4.9/32/crtbegin.o

clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64-linux-gnuabi64/4.9/32/crtend.o

clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64-linux-gnuabi64/4.9/n32/crtbegin.o

clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64-linux-gnuabi64/4.9/n32/crtend.o

clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/32/crtbegin.o

clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/32/crtend.o

clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/n32/crtbegin.o

clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/n32/crtend.o
clang/test/Driver/Inputs/debian_6_mips64_tree/usr/libo32/crt1.o
clang/test/Driver/Inputs/debian_6_mips64_tree/usr/libo32/crti.o
clang/test/Driver/Inputs/debian_6_mips64_tree/usr/libo32/crtn.o

Modified: 
clang/lib/Driver/ToolChains/Gnu.cpp
clang/lib/Driver/ToolChains/Linux.cpp
clang/test/Driver/linux-ld.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index e599f5d2a53eb..5436f008ed4d2 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -1081,7 +1081,8 @@ static bool findMipsCsMultilibs(const 
Multilib::flags_list &Flags,
.flag("-m32")
.flag("-mabi=n32");
 
-Multilib M32 = Multilib().flag("-m64").flag("+m32").flag("-mabi=n32");
+Multilib M32 =
+
Multilib().gccSuffix("/32").flag("-m64").flag("+m32").flag("-mabi=n32");
 
 DebianMipsMultilibs =
 MultilibSet().Either(M32, M64, MAbiN32).FilterOut(NonExistent);
@@ -2120,11 +2121,11 @@ void 
Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
   static const char *const M68kTriples[] = {
   "m68k-linux-gnu", "m68k-unknown-linux-gnu", "m68k-suse-linux"};
 
-  static const char *const MIPSLibDirs[] = {"/lib"};
+  static const char *const MIPSLibDirs[] = {"/libo32", "/lib"};
   static const char *const MIPSTriples[] = {
   "mips-linux-gnu", "mips-mti-linux", "mips-mti-linux-gnu",
   "mips-img-linux-gnu", "mipsisa32r6-linux-gnu"};
-  static const char *const MIPSELLibDirs[] = {"/lib"};
+  static const char *const MIPSELLibDirs[] = {"/libo32", "/lib"};
   static const char *const MIPSELTriples[] = {
   "mipsel-linux-gnu", "mips-img-linux-gnu", "mipsisa32r6el-linux-gnu"};
 

diff  --git a/clang/lib/Driver/ToolChains/Linux.cpp 
b/clang/lib/Driver/ToolChains/Linux.cpp
index 20ed697fecbca..d02c3af28257b 100644
--- a/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
@@ -261,6 +261,13 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, 
const ArgList &Args)
   const std::string OSLibDir = std::string(getOSLibDir(Triple, Args));
   const std::string MultiarchTriple = getMultiarchTriple(D, Triple, SysRoot);
 
+  // mips32: Debian multilib, we use /libo32, while in other case, /lib is
+  // used. We need add both libo32 and /lib.
+  if (Arch == llvm::Triple::mips || Arch == llvm::Triple::mipsel) {
+Generic_GCC::AddMultilibPaths(D, SysRoot, "libo32", MultiarchTriple, 
Paths);
+addPathIfExists(D, SysRoot + "/libo32", Paths);
+addPathIfExists(D, SysRoot + "/usr/libo32", Paths);
+  }
   Generic_GCC::AddMultilibPaths(D, SysRoot, OSLibDir, MultiarchTriple, Paths);
 
   addPathIfExists(D, SysRoot + "/lib/" + MultiarchTriple, Paths);

diff  --git a/clang/test/Driver/Inputs/debian_6_mips64_tree/libo32/.keep 
b/clang/test/Driver/Inputs/debian_6_mips64_tree/libo32/.keep
new file mode 100644
index 0..e69de29bb2d1d

diff  --git 
a/clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64-linux-gnuabi64/4.9/32/crtbegin.o
 
b/clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64-linux-gnuabi64/4.9/32/crtbegin.o
new file mode 100644
index 0..e69de29bb2d1d

diff  --git 
a/clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64-linux-gnuabi64/4.9/32/crtend.o
 
b/clang/test/Driver/Inputs/debian_6_mips64_tree

[PATCH] D112158: mips: fix search path for multilib o32

2021-10-28 Thread Simon Atanasyan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG284c2ebc5e05: [clang][MIPS] Fix search path for Debian 
multilib O32 (authored by wzssyqa, committed by atanasyan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112158

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/test/Driver/Inputs/debian_6_mips64_tree/libo32/.keep
  
clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64-linux-gnuabi64/4.9/32/crtbegin.o
  
clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64-linux-gnuabi64/4.9/32/crtend.o
  
clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64-linux-gnuabi64/4.9/n32/crtbegin.o
  
clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64-linux-gnuabi64/4.9/n32/crtend.o
  
clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/32/crtbegin.o
  
clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/32/crtend.o
  
clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/n32/crtbegin.o
  
clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/n32/crtend.o
  clang/test/Driver/Inputs/debian_6_mips64_tree/usr/libo32/crt1.o
  clang/test/Driver/Inputs/debian_6_mips64_tree/usr/libo32/crti.o
  clang/test/Driver/Inputs/debian_6_mips64_tree/usr/libo32/crtn.o
  clang/test/Driver/linux-ld.c


Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -1039,7 +1039,6 @@
 // CHECK-SPARCV9: "-m" "elf64_sparc"
 // CHECK-SPARCV9: "-dynamic-linker" 
"{{(/usr/sparcv9-unknown-linux-gnu)?}}/lib{{(64)?}}/ld-linux.so.2"
 
-
 // Test linker invocation on Android.
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: --target=arm-linux-androideabi -rtlib=platform 
--unwindlib=platform \
@@ -1455,6 +1454,22 @@
 // CHECK-DEBIAN-ML-MIPS64EL-N32: "-L[[SYSROOT]]/usr/lib"
 //
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=mips64el-linux-gnuabi64 -rtlib=platform -mabi=32 \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/debian_6_mips64_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-DEBIAN-ML-MIPS64EL-O32 %s
+// CHECK-DEBIAN-ML-MIPS64EL-O32: "{{.*}}ld{{(.exe)?}}" 
"--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-DEBIAN-ML-MIPS64EL-O32: 
"{{.*}}/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/../../../../libo32{{/|}}crt1.o"
+// CHECK-DEBIAN-ML-MIPS64EL-O32: 
"{{.*}}/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/../../../../libo32{{/|}}crti.o"
+// CHECK-DEBIAN-ML-MIPS64EL-O32: 
"{{.*}}/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/32{{/|}}crtbegin.o"
+// CHECK-DEBIAN-ML-MIPS64EL-O32: 
"-L[[SYSROOT]]/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/32"
+// CHECK-DEBIAN-ML-MIPS64EL-O32: 
"-L[[SYSROOT]]/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/../../../../libo32"
+// CHECK-DEBIAN-ML-MIPS64EL-O32: "-L[[SYSROOT]]/libo32"
+// CHECK-DEBIAN-ML-MIPS64EL-O32: "-L[[SYSROOT]]/usr/libo32"
+// CHECK-DEBIAN-ML-MIPS64EL-O32: "-L[[SYSROOT]]/lib"
+// CHECK-DEBIAN-ML-MIPS64EL-O32: "-L[[SYSROOT]]/usr/lib"
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: --target=mips64-unknown-linux-gnu --rtlib=platform \
 // RUN: --gcc-toolchain="" \
 // RUN: --sysroot=%S/Inputs/debian_6_mips64_tree \
Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -261,6 +261,13 @@
   const std::string OSLibDir = std::string(getOSLibDir(Triple, Args));
   const std::string MultiarchTriple = getMultiarchTriple(D, Triple, SysRoot);
 
+  // mips32: Debian multilib, we use /libo32, while in other case, /lib is
+  // used. We need add both libo32 and /lib.
+  if (Arch == llvm::Triple::mips || Arch == llvm::Triple::mipsel) {
+Generic_GCC::AddMultilibPaths(D, SysRoot, "libo32", MultiarchTriple, 
Paths);
+addPathIfExists(D, SysRoot + "/libo32", Paths);
+addPathIfExists(D, SysRoot + "/usr/libo32", Paths);
+  }
   Generic_GCC::AddMultilibPaths(D, SysRoot, OSLibDir, MultiarchTriple, Paths);
 
   addPathIfExists(D, SysRoot + "/lib/" + MultiarchTriple, Paths);
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -1081,7 +1081,8 @@
.flag("-m32")
.flag("-mabi=n32");
 
-Multilib M32 = Multilib().flag("-m64").flag("+m32").flag("-mabi=n32");
+Multilib M32 =
+
Multilib().gccSuffix("/32").flag("-m64").flag("+m32").flag("-mabi=n32");
 
 DebianMipsMultilibs =
 MultilibSet().Either(M32, M64, MAbiN32).Filte

[PATCH] D112646: [clang-tidy] Add `readability-container-contains` check

2021-10-28 Thread Whisperity via Phabricator via cfe-commits
whisperity added reviewers: aaron.ballman, xazax.hun.
whisperity added a comment.
Herald added a subscriber: rnkovacs.

Why `readability-`, if the intent is to make users move to a newer API?

@xazax.hun I think you did something similar wrt. `empty()`, right? Could you 
take a look at this?




Comment at: clang-tools-extra/docs/clang-tidy/checks/list.rst:341-343
+   `cert-exp42-c `_, `bugprone-suspicious-memory-comparison 
`_,
`cert-fio38-c `_, `misc-non-copyable-objects 
`_,
+   `cert-flp37-c `_, `bugprone-suspicious-memory-comparison 
`_,

These are unrelated changes coming from a lack of rebase or a too eager diff.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/readability-container-contains.rst:15
+---  --
+``x.begin() == x.end()``   ``!myMap.contains(x)``
+``x.begin() != x.end()``   ``myMap.contains(x)``

The indentation looks offset for the 2nd column here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112646

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


[clang] 897c86d - [clang] [MinGW] Rename the 'Arch' member to 'SubdirName'. NFC.

2021-10-28 Thread Martin Storsjö via cfe-commits

Author: Martin Storsjö
Date: 2021-10-28T10:26:54+03:00
New Revision: 897c86dec5af2780d443edd852aa5911e2650ec6

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

LOG: [clang] [MinGW] Rename the 'Arch' member to 'SubdirName'. NFC.

This string isn't a plain architecture name, but contains the whole
subdir name used for the sysroot, which often is equal to the target
triple.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/MinGW.cpp
clang/lib/Driver/ToolChains/MinGW.h

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/MinGW.cpp 
b/clang/lib/Driver/ToolChains/MinGW.cpp
index 6f1b7dd330fd..0bdeff38f52e 100644
--- a/clang/lib/Driver/ToolChains/MinGW.cpp
+++ b/clang/lib/Driver/ToolChains/MinGW.cpp
@@ -349,20 +349,20 @@ static bool findGccVersion(StringRef LibDir, std::string 
&GccLibDir,
 }
 
 void toolchains::MinGW::findGccLibDir() {
-  llvm::SmallVector, 2> Archs;
-  Archs.emplace_back(getTriple().getArchName());
-  Archs[0] += "-w64-mingw32";
-  Archs.emplace_back("mingw32");
-  if (Arch.empty())
-Arch = std::string(Archs[0].str());
+  llvm::SmallVector, 2> SubdirNames;
+  SubdirNames.emplace_back(getTriple().getArchName());
+  SubdirNames[0] += "-w64-mingw32";
+  SubdirNames.emplace_back("mingw32");
+  if (SubdirName.empty())
+SubdirName = std::string(SubdirNames[0].str());
   // lib: Arch Linux, Ubuntu, Windows
   // lib64: openSUSE Linux
   for (StringRef CandidateLib : {"lib", "lib64"}) {
-for (StringRef CandidateArch : Archs) {
+for (StringRef CandidateSysroot : SubdirNames) {
   llvm::SmallString<1024> LibDir(Base);
-  llvm::sys::path::append(LibDir, CandidateLib, "gcc", CandidateArch);
+  llvm::sys::path::append(LibDir, CandidateLib, "gcc", CandidateSysroot);
   if (findGccVersion(LibDir, GccLibDir, Ver)) {
-Arch = std::string(CandidateArch);
+SubdirName = std::string(CandidateSysroot);
 return;
   }
 }
@@ -391,7 +391,7 @@ llvm::ErrorOr 
toolchains::MinGW::findClangRelativeSysroot() {
   StringRef Sep = llvm::sys::path::get_separator();
   for (StringRef CandidateSubdir : Subdirs) {
 if (llvm::sys::fs::is_directory(ClangRoot + Sep + CandidateSubdir)) {
-  Arch = std::string(CandidateSubdir);
+  SubdirName = std::string(CandidateSubdir);
   return (ClangRoot + Sep + CandidateSubdir).str();
 }
   }
@@ -423,10 +423,10 @@ toolchains::MinGW::MinGW(const Driver &D, const 
llvm::Triple &Triple,
   // correct crtbegin.o ,cetend.o would be found.
   getFilePaths().push_back(GccLibDir);
   getFilePaths().push_back(
-  (Base + Arch + llvm::sys::path::get_separator() + "lib").str());
+  (Base + SubdirName + llvm::sys::path::get_separator() + "lib").str());
   getFilePaths().push_back(Base + "lib");
   // openSUSE
-  getFilePaths().push_back(Base + Arch + "/sys-root/mingw/lib");
+  getFilePaths().push_back(Base + SubdirName + "/sys-root/mingw/lib");
 
   NativeLLVMSupport =
   Args.getLastArgValue(options::OPT_fuse_ld_EQ, CLANG_DEFAULT_LINKER)
@@ -573,11 +573,12 @@ void toolchains::MinGW::AddClangSystemIncludeArgs(const 
ArgList &DriverArgs,
   if (GetRuntimeLibType(DriverArgs) == ToolChain::RLT_Libgcc) {
 // openSUSE
 addSystemInclude(DriverArgs, CC1Args,
- Base + Arch + "/sys-root/mingw/include");
+ Base + SubdirName + "/sys-root/mingw/include");
   }
 
   addSystemInclude(DriverArgs, CC1Args,
-   Base + Arch + llvm::sys::path::get_separator() + "include");
+   Base + SubdirName + llvm::sys::path::get_separator() +
+   "include");
   addSystemInclude(DriverArgs, CC1Args, Base + "include");
 }
 
@@ -596,8 +597,9 @@ void toolchains::MinGW::AddClangCXXStdlibIncludeArgs(
 .str();
 if (getDriver().getVFS().exists(TargetDir))
   addSystemInclude(DriverArgs, CC1Args, TargetDir);
-addSystemInclude(DriverArgs, CC1Args, Base + Arch + Slash + "include" +
-  Slash + "c++" + Slash + "v1");
+addSystemInclude(DriverArgs, CC1Args,
+ Base + SubdirName + Slash + "include" + Slash + "c++" +
+ Slash + "v1");
 addSystemInclude(DriverArgs, CC1Args,
  Base + "include" + Slash + "c++" + Slash + "v1");
 break;
@@ -606,9 +608,10 @@ void toolchains::MinGW::AddClangCXXStdlibIncludeArgs(
   case ToolChain::CST_Libstdcxx:
 llvm::SmallVector, 4> CppIncludeBases;
 CppIncludeBases.emplace_back(Base);
-llvm::sys::path::append(CppIncludeBases[0], Arch, "include", "c++");
+llvm::sys::path::append(CppIncludeBases[0], SubdirName, "include", "c++");
 CppIncludeBases.emplace_back(Base);

[PATCH] D112387: [clang] [MinGW] Rename the 'Arch' member to 'SysrootName'. NFC.

2021-10-28 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG897c86dec5af: [clang] [MinGW] Rename the 'Arch' 
member to 'SubdirName'. NFC. (authored by mstorsjo).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112387

Files:
  clang/lib/Driver/ToolChains/MinGW.cpp
  clang/lib/Driver/ToolChains/MinGW.h

Index: clang/lib/Driver/ToolChains/MinGW.h
===
--- clang/lib/Driver/ToolChains/MinGW.h
+++ clang/lib/Driver/ToolChains/MinGW.h
@@ -99,7 +99,7 @@
   std::string Base;
   std::string GccLibDir;
   std::string Ver;
-  std::string Arch;
+  std::string SubdirName;
   mutable std::unique_ptr Preprocessor;
   mutable std::unique_ptr Compiler;
   void findGccLibDir();
Index: clang/lib/Driver/ToolChains/MinGW.cpp
===
--- clang/lib/Driver/ToolChains/MinGW.cpp
+++ clang/lib/Driver/ToolChains/MinGW.cpp
@@ -349,20 +349,20 @@
 }
 
 void toolchains::MinGW::findGccLibDir() {
-  llvm::SmallVector, 2> Archs;
-  Archs.emplace_back(getTriple().getArchName());
-  Archs[0] += "-w64-mingw32";
-  Archs.emplace_back("mingw32");
-  if (Arch.empty())
-Arch = std::string(Archs[0].str());
+  llvm::SmallVector, 2> SubdirNames;
+  SubdirNames.emplace_back(getTriple().getArchName());
+  SubdirNames[0] += "-w64-mingw32";
+  SubdirNames.emplace_back("mingw32");
+  if (SubdirName.empty())
+SubdirName = std::string(SubdirNames[0].str());
   // lib: Arch Linux, Ubuntu, Windows
   // lib64: openSUSE Linux
   for (StringRef CandidateLib : {"lib", "lib64"}) {
-for (StringRef CandidateArch : Archs) {
+for (StringRef CandidateSysroot : SubdirNames) {
   llvm::SmallString<1024> LibDir(Base);
-  llvm::sys::path::append(LibDir, CandidateLib, "gcc", CandidateArch);
+  llvm::sys::path::append(LibDir, CandidateLib, "gcc", CandidateSysroot);
   if (findGccVersion(LibDir, GccLibDir, Ver)) {
-Arch = std::string(CandidateArch);
+SubdirName = std::string(CandidateSysroot);
 return;
   }
 }
@@ -391,7 +391,7 @@
   StringRef Sep = llvm::sys::path::get_separator();
   for (StringRef CandidateSubdir : Subdirs) {
 if (llvm::sys::fs::is_directory(ClangRoot + Sep + CandidateSubdir)) {
-  Arch = std::string(CandidateSubdir);
+  SubdirName = std::string(CandidateSubdir);
   return (ClangRoot + Sep + CandidateSubdir).str();
 }
   }
@@ -423,10 +423,10 @@
   // correct crtbegin.o ,cetend.o would be found.
   getFilePaths().push_back(GccLibDir);
   getFilePaths().push_back(
-  (Base + Arch + llvm::sys::path::get_separator() + "lib").str());
+  (Base + SubdirName + llvm::sys::path::get_separator() + "lib").str());
   getFilePaths().push_back(Base + "lib");
   // openSUSE
-  getFilePaths().push_back(Base + Arch + "/sys-root/mingw/lib");
+  getFilePaths().push_back(Base + SubdirName + "/sys-root/mingw/lib");
 
   NativeLLVMSupport =
   Args.getLastArgValue(options::OPT_fuse_ld_EQ, CLANG_DEFAULT_LINKER)
@@ -573,11 +573,12 @@
   if (GetRuntimeLibType(DriverArgs) == ToolChain::RLT_Libgcc) {
 // openSUSE
 addSystemInclude(DriverArgs, CC1Args,
- Base + Arch + "/sys-root/mingw/include");
+ Base + SubdirName + "/sys-root/mingw/include");
   }
 
   addSystemInclude(DriverArgs, CC1Args,
-   Base + Arch + llvm::sys::path::get_separator() + "include");
+   Base + SubdirName + llvm::sys::path::get_separator() +
+   "include");
   addSystemInclude(DriverArgs, CC1Args, Base + "include");
 }
 
@@ -596,8 +597,9 @@
 .str();
 if (getDriver().getVFS().exists(TargetDir))
   addSystemInclude(DriverArgs, CC1Args, TargetDir);
-addSystemInclude(DriverArgs, CC1Args, Base + Arch + Slash + "include" +
-  Slash + "c++" + Slash + "v1");
+addSystemInclude(DriverArgs, CC1Args,
+ Base + SubdirName + Slash + "include" + Slash + "c++" +
+ Slash + "v1");
 addSystemInclude(DriverArgs, CC1Args,
  Base + "include" + Slash + "c++" + Slash + "v1");
 break;
@@ -606,9 +608,10 @@
   case ToolChain::CST_Libstdcxx:
 llvm::SmallVector, 4> CppIncludeBases;
 CppIncludeBases.emplace_back(Base);
-llvm::sys::path::append(CppIncludeBases[0], Arch, "include", "c++");
+llvm::sys::path::append(CppIncludeBases[0], SubdirName, "include", "c++");
 CppIncludeBases.emplace_back(Base);
-llvm::sys::path::append(CppIncludeBases[1], Arch, "include", "c++", Ver);
+llvm::sys::path::append(CppIncludeBases[1], SubdirName, "include", "c++",
+Ver);
 CppIncludeBases.emplace_back(Base);
 llvm::sys::path::append(CppIncludeBases[2], "include", "c++", Ver);
 CppIncludeBases.emplace_back(Gc

[PATCH] D112663: [clang-repl] Allow Interpreter::getSymbolAddress to take a mangled name.

2021-10-28 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev updated this revision to Diff 382939.
v.g.vassilev marked 2 inline comments as done.
v.g.vassilev added a comment.

Address comments


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

https://reviews.llvm.org/D112663

Files:
  clang/include/clang/CodeGen/ModuleBuilder.h
  clang/include/clang/Interpreter/Interpreter.h
  clang/lib/CodeGen/ModuleBuilder.cpp
  clang/lib/Interpreter/IncrementalExecutor.cpp
  clang/lib/Interpreter/IncrementalExecutor.h
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/lib/Interpreter/IncrementalParser.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/unittests/Interpreter/CMakeLists.txt
  clang/unittests/Interpreter/IncrementalProcessingTest.cpp
  clang/unittests/Interpreter/InterpreterTest.cpp

Index: clang/unittests/Interpreter/InterpreterTest.cpp
===
--- clang/unittests/Interpreter/InterpreterTest.cpp
+++ clang/unittests/Interpreter/InterpreterTest.cpp
@@ -14,8 +14,13 @@
 
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclGroup.h"
+#include "clang/AST/Mangle.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
+#include "clang/Sema/Lookup.h"
+#include "clang/Sema/Sema.h"
+
+#include "llvm/Support/TargetSelect.h"
 
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
@@ -123,4 +128,110 @@
   EXPECT_EQ("Parsing failed.", llvm::toString(std::move(Err)));
 }
 
+static std::string MangleName(NamedDecl *ND) {
+  ASTContext &C = ND->getASTContext();
+  std::unique_ptr MangleC(C.createMangleContext());
+  std::string mangledName;
+  llvm::raw_string_ostream RawStr(mangledName);
+  MangleC->mangleName(ND, RawStr);
+  return RawStr.str();
+}
+
+struct LLVMInitRAII {
+  LLVMInitRAII() {
+llvm::InitializeNativeTarget();
+llvm::InitializeNativeTargetAsmPrinter();
+  }
+  ~LLVMInitRAII() { llvm::llvm_shutdown(); }
+} LLVMInit;
+
+TEST(IncrementalProcessing, FindMangledNameSymbol) {
+
+  std::unique_ptr Interp = createInterpreter();
+
+  auto &PTU(cantFail(Interp->Parse("int f(const char*) {return 0;}")));
+  EXPECT_EQ(1U, DeclsSize(PTU.TUPart));
+  auto R1DeclRange = PTU.TUPart->decls();
+
+  NamedDecl *FD = cast(*R1DeclRange.begin());
+  // Lower the PTU
+  if (llvm::Error Err = Interp->Execute(PTU)) {
+// We cannot execute on the platform.
+consumeError(std::move(Err));
+return;
+  }
+
+  std::string MangledName = MangleName(FD);
+  auto Addr = cantFail(Interp->getSymbolAddress(MangledName));
+  EXPECT_TRUE(Addr != 0);
+  GlobalDecl GD(FD);
+  EXPECT_TRUE(Addr == cantFail(Interp->getSymbolAddress(GD)));
+}
+
+static void *AllocateObject(TypeDecl *TD, Interpreter &Interp) {
+  std::string Name = TD->getQualifiedNameAsString();
+  const clang::Type *RDTy = TD->getTypeForDecl();
+  clang::ASTContext &C = Interp.getCompilerInstance()->getASTContext();
+  size_t Size = C.getTypeSize(RDTy);
+  void *Addr = malloc(Size);
+
+  // Tell the interpreter to call the default ctor with this memory. Synthesize:
+  // new (loc) ClassName;
+  static unsigned Counter = 0;
+  std::stringstream SS;
+  SS << "auto _v" << Counter++ << " = "
+ << "new ((void*)" << Addr << ")" << Name << "();";
+
+  auto R = Interp.ParseAndExecute(SS.str());
+  if (!R)
+return nullptr;
+
+  return Addr;
+}
+
+static NamedDecl *LookupSingleName(Interpreter &Interp, const char *Name) {
+  Sema &SemaRef = Interp.getCompilerInstance()->getSema();
+  ASTContext &C = SemaRef.getASTContext();
+  DeclarationName DeclName = &C.Idents.get(Name);
+  LookupResult R(SemaRef, DeclName, SourceLocation(), Sema::LookupOrdinaryName);
+  SemaRef.LookupName(R, SemaRef.TUScope);
+  assert(!R.empty());
+  return R.getFoundDecl();
+}
+
+TEST(IncrementalProcessing, InstantiateTemplate) {
+  std::unique_ptr Interp = createInterpreter();
+
+  llvm::cantFail(Interp->Parse("void* operator new(__SIZE_TYPE__, void* __p);"
+   "extern \"C\" int printf(const char*,...);"
+   "class A {};"
+   "struct B {"
+   "  template"
+   "  int callme(T) { return 42; }"
+   "};"));
+  auto &PTU = llvm::cantFail(Interp->Parse("auto _t = &B::callme;"));
+  auto PTUDeclRange = PTU.TUPart->decls();
+  EXPECT_TRUE(std::distance(PTUDeclRange.begin(), PTUDeclRange.end()));
+
+  // Lower the PTU
+  if (llvm::Error Err = Interp->Execute(PTU)) {
+// We cannot execute on the platform.
+consumeError(std::move(Err));
+return;
+  }
+
+  TypeDecl *TD = cast(LookupSingleName(*Interp, "A"));
+  void *NewA = AllocateObject(TD, *Interp);
+
+  // Find back the template specialization
+  VarDecl *VD = static_cast(*PTUDeclRange.begin());
+  UnaryOperator *UO = llvm::cast(VD->getInit());
+  NamedDecl *TmpltSpec = llvm::cast(UO->getSubExpr())->getDecl();
+
+  std::string MangledName = MangleName(TmpltSpec);
+  typedef int (*TemplateSpecFn)(void

[PATCH] D112406: [Driver][AArch64]Add driver support for neoverse-512tvb target

2021-10-28 Thread Dave Green via Phabricator via cfe-commits
dmgreen added a comment.

> The total vector bandwidth includes unrolling so currently having 
> `VScaleForTuning=1` and `MaxInterleaveFactor=4` implies 512 tvb.  If the 
> target has >128bit vectors then vector loops will likely have more work than 
> they can handle in parallel but as long as that does not negatively affect 
> register pressure it shouldn't be a problem.

That doesn't fit with my understanding of how VScaleForTuning is currently 
used, and vectorizing/unrolling too far can easily cause the vector part to be 
skipped for many loop counts, falling back to the scalar part. But that all 
sounds fine to me for what this is. Cheers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112406

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


[clang] 2186b01 - [Driver][AArch64]Add driver support for neoverse-512tvb target

2021-10-28 Thread Caroline Concatto via cfe-commits

Author: Caroline Concatto
Date: 2021-10-28T09:08:40+01:00
New Revision: 2186b011e96669b447896c103c10a07dd3aa6203

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

LOG: [Driver][AArch64]Add driver support for neoverse-512tvb target

The support for  neoverse-512tvb mirrors the same option available in GCC[1].
There is no functional effect for this option yet.
This patch ensures the driver accepts "-mcpu=neoverse-512tvb", and enough
plumbing is in place to allow the new option to be used in the future.

[1]https://gcc.gnu.org/onlinedocs/gcc/AArch64-Options.html

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

Added: 


Modified: 
clang/test/Driver/aarch64-cpus.c
clang/test/Misc/target-invalid-cpu-note.c
llvm/include/llvm/Support/AArch64TargetParser.def
llvm/lib/Target/AArch64/AArch64.td
llvm/lib/Target/AArch64/AArch64Subtarget.cpp
llvm/lib/Target/AArch64/AArch64Subtarget.h
llvm/test/CodeGen/AArch64/cpus.ll
llvm/test/CodeGen/AArch64/misched-fusion-aes.ll
llvm/unittests/Support/TargetParserTest.cpp

Removed: 




diff  --git a/clang/test/Driver/aarch64-cpus.c 
b/clang/test/Driver/aarch64-cpus.c
index 55cef730ebe52..4f049c79dac1b 100644
--- a/clang/test/Driver/aarch64-cpus.c
+++ b/clang/test/Driver/aarch64-cpus.c
@@ -192,6 +192,9 @@
 // RUN: %clang -target aarch64 -mcpu=neoverse-n2 -### -c %s 2>&1 | FileCheck 
-check-prefix=NEOVERSE-N2 %s
 // NEOVERSE-N2: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-n2"
 
+// RUN: %clang -target aarch64 -mcpu=neoverse-512tvb -### -c %s 2>&1 | 
FileCheck -check-prefix=NEOVERSE-512TVB %s
+// NEOVERSE-512TVB: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-512tvb"
+
 // RUN: %clang -target aarch64 -mcpu=cortex-r82  -### -c %s 2>&1 | FileCheck 
-check-prefix=CORTEXR82 %s
 // CORTEXR82: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-r82"
 

diff  --git a/clang/test/Misc/target-invalid-cpu-note.c 
b/clang/test/Misc/target-invalid-cpu-note.c
index 800910b749838..efdc92263e7e9 100644
--- a/clang/test/Misc/target-invalid-cpu-note.c
+++ b/clang/test/Misc/target-invalid-cpu-note.c
@@ -5,11 +5,11 @@
 
 // RUN: not %clang_cc1 -triple arm64--- -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix AARCH64
 // AARCH64: error: unknown target CPU 'not-a-cpu'
-// AARCH64-NEXT: note: valid target CPU values are: cortex-a34, cortex-a35, 
cortex-a53, cortex-a55, cortex-a510, cortex-a57, cortex-a65, cortex-a65ae, 
cortex-a72, cortex-a73, cortex-a75, cortex-a76, cortex-a76ae, cortex-a77, 
cortex-a78, cortex-a78c, cortex-r82, cortex-x1, neoverse-e1, neoverse-n1, 
neoverse-n2, neoverse-v1, cyclone, apple-a7, apple-a8, apple-a9, apple-a10, 
apple-a11, apple-a12, apple-a13, apple-a14, apple-m1, apple-s4, apple-s5, 
exynos-m3, exynos-m4, exynos-m5, falkor, saphira, kryo, thunderx2t99, 
thunderx3t110, thunderx, thunderxt88, thunderxt81, thunderxt83, tsv110, a64fx, 
carmel{{$}}
+// AARCH64-NEXT: note: valid target CPU values are: cortex-a34, cortex-a35, 
cortex-a53, cortex-a55, cortex-a510, cortex-a57, cortex-a65, cortex-a65ae, 
cortex-a72, cortex-a73, cortex-a75, cortex-a76, cortex-a76ae, cortex-a77, 
cortex-a78, cortex-a78c, cortex-r82, cortex-x1, neoverse-e1, neoverse-n1, 
neoverse-n2, neoverse-512tvb, neoverse-v1, cyclone, apple-a7, apple-a8, 
apple-a9, apple-a10, apple-a11, apple-a12, apple-a13, apple-a14, apple-m1, 
apple-s4, apple-s5, exynos-m3, exynos-m4, exynos-m5, falkor, saphira, kryo, 
thunderx2t99, thunderx3t110, thunderx, thunderxt88, thunderxt81, thunderxt83, 
tsv110, a64fx, carmel{{$}}
 
 // RUN: not %clang_cc1 -triple arm64--- -tune-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix TUNE_AARCH64
 // TUNE_AARCH64: error: unknown target CPU 'not-a-cpu'
-// TUNE_AARCH64-NEXT: note: valid target CPU values are: cortex-a34, 
cortex-a35, cortex-a53, cortex-a55, cortex-a510, cortex-a57, cortex-a65, 
cortex-a65ae, cortex-a72, cortex-a73, cortex-a75, cortex-a76, cortex-a76ae, 
cortex-a77, cortex-a78, cortex-a78c, cortex-r82, cortex-x1, neoverse-e1, 
neoverse-n1, neoverse-n2, neoverse-v1, cyclone, apple-a7, apple-a8, apple-a9, 
apple-a10, apple-a11, apple-a12, apple-a13, apple-a14, apple-m1, apple-s4, 
apple-s5, exynos-m3, exynos-m4, exynos-m5, falkor, saphira, kryo, thunderx2t99, 
thunderx3t110, thunderx, thunderxt88, thunderxt81, thunderxt83, tsv110, a64fx, 
carmel{{$}}
+// TUNE_AARCH64-NEXT: note: valid target CPU values are: cortex-a34, 
cortex-a35, cortex-a53, cortex-a55, cortex-a510, cortex-a57, cortex-a65, 
cortex-a65ae, cortex-a72, cortex-a73, cortex-a75, cortex-a76, cortex-a76ae, 
cortex-a77, cortex-a78, cortex-a78c, cortex-r82, cortex-x1, neoverse-e1, 
neoverse-n1, neoverse-n2, neoverse-512tvb, neoverse-v1, cyclone, apple-a7, 
apple-a8, a

[PATCH] D112406: [Driver][AArch64]Add driver support for neoverse-512tvb target

2021-10-28 Thread Caroline 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 rG2186b011e966: [Driver][AArch64]Add driver support for 
neoverse-512tvb target (authored by CarolineConcatto).

Changed prior to commit:
  https://reviews.llvm.org/D112406?vs=382273&id=382945#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112406

Files:
  clang/test/Driver/aarch64-cpus.c
  clang/test/Misc/target-invalid-cpu-note.c
  llvm/include/llvm/Support/AArch64TargetParser.def
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64Subtarget.cpp
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/test/CodeGen/AArch64/cpus.ll
  llvm/test/CodeGen/AArch64/misched-fusion-aes.ll
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -1134,6 +1134,14 @@
  AArch64::AEK_SVE2 | AArch64::AEK_SVE2BITPERM |
  AArch64::AEK_BF16 | AArch64::AEK_I8MM,
  "8.5-A"),
+ARMCPUTestParams(
+"neoverse-512tvb", "armv8.4-a", "crypto-neon-fp-armv8",
+AArch64::AEK_RAS | AArch64::AEK_SVE | AArch64::AEK_SSBS |
+AArch64::AEK_RCPC | AArch64::AEK_CRC | AArch64::AEK_FP |
+AArch64::AEK_SIMD | AArch64::AEK_RAS | AArch64::AEK_LSE |
+AArch64::AEK_RDM | AArch64::AEK_RCPC | AArch64::AEK_DOTPROD |
+AArch64::AEK_CRYPTO | AArch64::AEK_FP16 | AArch64::AEK_BF16,
+"8.4-A"),
 ARMCPUTestParams("thunderx2t99", "armv8.1-a", "crypto-neon-fp-armv8",
  AArch64::AEK_NONE | AArch64::AEK_CRC |
  AArch64::AEK_CRYPTO | AArch64::AEK_LSE |
@@ -1189,7 +1197,7 @@
  AArch64::AEK_LSE | AArch64::AEK_RDM,
  "8.2-A")));
 
-static constexpr unsigned NumAArch64CPUArchs = 49;
+static constexpr unsigned NumAArch64CPUArchs = 50;
 
 TEST(TargetParserTest, testAArch64CPUArchList) {
   SmallVector List;
Index: llvm/test/CodeGen/AArch64/misched-fusion-aes.ll
===
--- llvm/test/CodeGen/AArch64/misched-fusion-aes.ll
+++ llvm/test/CodeGen/AArch64/misched-fusion-aes.ll
@@ -14,6 +14,7 @@
 ; RUN: llc %s -o - -mtriple=aarch64-unknown -mcpu=neoverse-n1 | FileCheck %s
 ; RUN: llc %s -o - -mtriple=aarch64-unknown -mcpu=neoverse-n2 | FileCheck %s
 ; RUN: llc %s -o - -mtriple=aarch64-unknown -mcpu=neoverse-v1 | FileCheck %s
+; RUN: llc %s -o - -mtriple=aarch64-unknown -mcpu=neoverse-512tvb | FileCheck %s
 ; RUN: llc %s -o - -mtriple=aarch64-unknown -mcpu=exynos-m3  | FileCheck %s
 ; RUN: llc %s -o - -mtriple=aarch64-unknown -mcpu=exynos-m4  | FileCheck %s
 ; RUN: llc %s -o - -mtriple=aarch64-unknown -mcpu=exynos-m5  | FileCheck %s
Index: llvm/test/CodeGen/AArch64/cpus.ll
===
--- llvm/test/CodeGen/AArch64/cpus.ll
+++ llvm/test/CodeGen/AArch64/cpus.ll
@@ -21,6 +21,7 @@
 ; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=neoverse-e1 2>&1 | FileCheck %s
 ; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=neoverse-n1 2>&1 | FileCheck %s
 ; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=neoverse-n2 2>&1 | FileCheck %s
+; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=neoverse-512tvb 2>&1 | FileCheck %s
 ; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=neoverse-v1 2>&1 | FileCheck %s
 ; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=exynos-m3 2>&1 | FileCheck %s
 ; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=exynos-m4 2>&1 | FileCheck %s
Index: llvm/lib/Target/AArch64/AArch64Subtarget.h
===
--- llvm/lib/Target/AArch64/AArch64Subtarget.h
+++ llvm/lib/Target/AArch64/AArch64Subtarget.h
@@ -68,6 +68,7 @@
 NeoverseE1,
 NeoverseN1,
 NeoverseN2,
+Neoverse512TVB,
 NeoverseV1,
 Saphira,
 ThunderX2T99,
Index: llvm/lib/Target/AArch64/AArch64Subtarget.cpp
===
--- llvm/lib/Target/AArch64/AArch64Subtarget.cpp
+++ llvm/lib/Target/AArch64/AArch64Subtarget.cpp
@@ -164,6 +164,11 @@
 PrefFunctionLogAlignment = 4;
 VScaleForTuning = 2;
 break;
+  case Neoverse512TVB:
+PrefFunctionLogAlignment = 4;
+VScaleForTuning = 1;
+MaxInterleaveFactor = 4;
+break;
   case Saphira:
 MaxInterleaveFactor = 4;
 // FIXME: remove this to enable 64-bit SLP if performance looks good.
Index: llvm/lib/Target/AArch64/AArch64.td
===
--- llvm/lib/Target/AArch64/AArch64.td
+++ llvm/lib/Targe

[PATCH] D111952: [clang] [MinGW] Guess the right ix86 arch name spelling as sysroot

2021-10-28 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo updated this revision to Diff 382946.
mstorsjo marked an inline comment as done.
mstorsjo added a comment.

Fixed the naming of the new function, using `--target=` in the newly added test 
lines, fixed a case of missed clang-format.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111952

Files:
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/MinGW.cpp
  clang/lib/Driver/ToolChains/MinGW.h
  clang/test/Driver/mingw-sysroot.cpp

Index: clang/test/Driver/mingw-sysroot.cpp
===
--- clang/test/Driver/mingw-sysroot.cpp
+++ clang/test/Driver/mingw-sysroot.cpp
@@ -12,6 +12,7 @@
 // RUN: mkdir -p %T/testroot-clang/bin
 // RUN: ln -s %clang %T/testroot-clang/bin/x86_64-w64-mingw32-clang
 // RUN: ln -s %S/Inputs/mingw_ubuntu_posix_tree/usr/x86_64-w64-mingw32 %T/testroot-clang/x86_64-w64-mingw32
+// RUN: ln -s %S/Inputs/mingw_arch_tree/usr/i686-w64-mingw32 %T/testroot-clang/i686-w64-mingw32
 
 
 // If we find a gcc in the path with the right triplet prefix, pick that as
@@ -36,3 +37,14 @@
 // the libgcc directory:
 
 // RUN: env "PATH=%T/testroot-gcc/bin:%PATH%" %T/testroot-gcc/bin/x86_64-w64-mingw32-clang -target x86_64-w64-mingw32 -rtlib=platform -stdlib=libstdc++ --sysroot="" -c -### %s 2>&1 | FileCheck -check-prefix=CHECK_TESTROOT_GCC %s
+
+
+// If the user requests a different arch via the -m32 option, which changes
+// x86_64 into i386, check that the driver notices that it can't find a
+// sysroot for i386 but there is one for i686, and uses that one.
+// (In practice, the real usecase is when using an unprefixed native clang
+// that defaults to x86_64 mingw, but it's easier to test this in cross setups
+// with symlinks, like the other tests here.)
+
+// RUN: env "PATH=%T/testroot-gcc/bin:%PATH%" %T/testroot-clang/bin/x86_64-w64-mingw32-clang --target=x86_64-w64-mingw32 -m32 -rtlib=compiler-rt -stdlib=libstdc++ --sysroot="" -c -### %s 2>&1 | FileCheck -check-prefix=CHECK_TESTROOT_CLANG_I686 %s
+// CHECK_TESTROOT_CLANG_I686: "{{[^"]+}}/testroot-clang{{/|}}i686-w64-mingw32{{/|}}include"
Index: clang/lib/Driver/ToolChains/MinGW.h
===
--- clang/lib/Driver/ToolChains/MinGW.h
+++ clang/lib/Driver/ToolChains/MinGW.h
@@ -60,6 +60,9 @@
   MinGW(const Driver &D, const llvm::Triple &Triple,
 const llvm::opt::ArgList &Args);
 
+  static void fixTripleArch(const Driver &D, llvm::Triple &Triple,
+const llvm::opt::ArgList &Args);
+
   bool HasNativeLLVMSupport() const override;
 
   bool IsIntegratedAssemblerDefault() const override;
@@ -103,8 +106,6 @@
   mutable std::unique_ptr Preprocessor;
   mutable std::unique_ptr Compiler;
   void findGccLibDir();
-  llvm::ErrorOr findGcc();
-  llvm::ErrorOr findClangRelativeSysroot();
 
   bool NativeLLVMSupport;
 };
Index: clang/lib/Driver/ToolChains/MinGW.cpp
===
--- clang/lib/Driver/ToolChains/MinGW.cpp
+++ clang/lib/Driver/ToolChains/MinGW.cpp
@@ -369,9 +369,9 @@
   }
 }
 
-llvm::ErrorOr toolchains::MinGW::findGcc() {
+static llvm::ErrorOr findGcc(const llvm::Triple &T) {
   llvm::SmallVector, 2> Gccs;
-  Gccs.emplace_back(getTriple().getArchName());
+  Gccs.emplace_back(T.getArchName());
   Gccs[0] += "-w64-mingw32-gcc";
   Gccs.emplace_back("mingw32-gcc");
   // Please do not add "gcc" here
@@ -381,13 +381,14 @@
   return make_error_code(std::errc::no_such_file_or_directory);
 }
 
-llvm::ErrorOr toolchains::MinGW::findClangRelativeSysroot() {
+static llvm::ErrorOr
+findClangRelativeSysroot(const Driver &D, const llvm::Triple &T,
+ std::string &SubdirName) {
   llvm::SmallVector, 2> Subdirs;
-  Subdirs.emplace_back(getTriple().str());
-  Subdirs.emplace_back(getTriple().getArchName());
+  Subdirs.emplace_back(T.str());
+  Subdirs.emplace_back(T.getArchName());
   Subdirs[1] += "-w64-mingw32";
-  StringRef ClangRoot =
-  llvm::sys::path::parent_path(getDriver().getInstalledDir());
+  StringRef ClangRoot = llvm::sys::path::parent_path(D.getInstalledDir());
   StringRef Sep = llvm::sys::path::get_separator();
   for (StringRef CandidateSubdir : Subdirs) {
 if (llvm::sys::fs::is_directory(ClangRoot + Sep + CandidateSubdir)) {
@@ -404,13 +405,16 @@
   RocmInstallation(D, Triple, Args) {
   getProgramPaths().push_back(getDriver().getInstalledDir());
 
+  // The sequence for detecting a sysroot here should be kept in sync with
+  // the testTriple function below.
   if (getDriver().SysRoot.size())
 Base = getDriver().SysRoot;
   // Look for /../; if found, use /.. as the
   // base as it could still be a base for a gcc setup with libgcc.
-  else if (llvm::ErrorOr TargetSubdir = findClangRelativeSysroot())
+  else if (llvm::ErrorOr TargetSubdir =
+   findClangRelativeSysroot(getDriver(), getTriple()

[PATCH] D112409: [clang-tidy] Add check 'cert-err33-c'.

2021-10-28 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

It looks good to me. But I'm leaving the approval up to the //tidy// folks.
BTW shouldn't we use //backticks// in the giant list?




Comment at: clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp:45-50
+// The following functions are
+// deliberately excluded because they can
+// be called with NULL argument and in
+// this case the check is not applicable:
+// mblen, mbrlen, mbrtowc, mbtowc, wctomb,
+// wctomb_s

whisperity wrote:
> aaron.ballman wrote:
> > Pretty sure this comment can be re-flowed to 80 columns. Also needs 
> > trailing punctuation.
> Shouldn't we reuse `utils::options::serializeStringList` here instead of 
> hardcoding the separator character into a giant literal? I know executing 
> that operation has an associated run-time cost, and as it is not `constexpr` 
> it needs to be done somewhere else, and `std::string` could throw so we can't 
> do it at "static initialisation" time... But having those extra chars there 
> just seems way too fragile at a later modification. We've had cases where 
> people missed separating `,`s even -- and those are syntactically highlighted 
> differently due to being outside the string literal.
> 
> Suggestion:
> 
>  * An array of `StringRef`s or even `llvm::StringLiteral`s containing the 
> individual function names. Array separated with `,`, the separator outside 
> the literal. Aligned to column and probably one per line.
>  * When using this variable later (🌟), instead of passing the stringref, pass 
> the result of `serializeStringList`.
I think it looks good enough. We will certainly recognize if we change this 
behavior and it would be easy to port these anyway. So I'm not too concerned 
about this.



Comment at: clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp:328
 Opts["cert-str34-c.DiagnoseSignedUnsignedCharComparisons"] = "false";
+Opts["cert-err33-c.CheckedFunctions"] = CertErr33CCheckedFunctions;
 return Options;

carlosgalvezp wrote:
> balazske wrote:
> > carlosgalvezp wrote:
> > > Same here
> > This is correct: 'str34' before 'err33'.
> No, `e` goes before `s`.  The existing checks are ordered: `dcl`, `oop`, 
> `str`. So this check should go after `dcl16`.
+1 for fixing the order


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112409

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


[PATCH] D107339: [analyzer] Retrieve a character from StringLiteral as an initializer for constant arrays.

2021-10-28 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1757-1760
+  // FIXME: Nevertheless, we can't do the same for cases, like:
+  //   const char *str = "123"; // literal length is 4
+  //   char c = str[41];// offset is 41
+  // It should be properly handled before reaching this point.

steakhal wrote:
> ASDenysPetrov wrote:
> > ASDenysPetrov wrote:
> > > steakhal wrote:
> > > > martong wrote:
> > > > > ASDenysPetrov wrote:
> > > > > > ASDenysPetrov wrote:
> > > > > > > martong wrote:
> > > > > > > > Thanks for updating the patch! However, this `FIXME` makes me 
> > > > > > > > worried. Do you think you could pass the `Decl` itself to 
> > > > > > > > `getSValFromInitListExpr` in order to be able to check whether 
> > > > > > > > the type is a pointer or an array? 
> > > > > > > This worried me as well. Currently I can't find a way to get the 
> > > > > > > `Decl` for `SL`.
> > > > > > > 
> > > > > > We can load this as is for now with mentioning the known issue.
> > > > > This might cause some itchy false positives. Perhaps, we could 
> > > > > address this in a follow-up patch and then commit them together?
> > > > > Currently I can't find a way to get the Decl for SL.
> > > > Why do you need a Decl? The SVal's gotta be an `Element{"123",41 
> > > > S64b,char}` for the example in the comment (*).
> > > > 
> > > > (*) With a minor modification: https://godbolt.org/z/7zhGMnf7P
> > > > ```lang=C++
> > > > template  void clang_analyzer_dump(T);
> > > > const char * const str = "123";
> > > > const char * str2 = "123";
> > > > void top() {
> > > >   clang_analyzer_dump(&str[41]);  // &Element{"123",41 S64b,char}
> > > >   clang_analyzer_dump(&str2[41]); // &Element{SymRegion{reg_$0 > > > char * str2>},41 S64b,char}
> > > > }
> > > > ```
> > > Because only `Decl` can tell us whether it is a `const char str[42]` or 
> > > `const char * const str`. We can't say anything just looking at `SVal`.
> > > This might cause some itchy false positives. Perhaps, we could address 
> > > this in a follow-up patch and then commit them together?
> > This will produce not more FP as before, even less. I didn't change the 
> > behavior specifically here. I just found the issue point to it.
> I probably still miss the point. https://godbolt.org/z/EMhbq3745
> Since the case you mention is actually represented by a `NonParamVarRegion` 
> which holds a pointer to its decl.
> ```lang=C++
> const char str3[43] = "123";
> void top() {
>   clang_analyzer_dump(&str3[41]); // &Element{str3,41 S64b,char}
>   //NonParamVarRegion  --- (it can print the name of 
> the *decl*)
> }
> ```
> 
> ---
> 
> What I wanted to highlight is, that it's a non-issue. In your example you had 
> a **non-const** global variable, thus we could not infer any meaningful 
> initial value for it, and that is actually the expected behavior. As soon as 
> I marked the `str` pointer //const// (along with its //pointee//), suddenly 
> the analyzer can infer its initial value.
But @steakhal, we have this case in the test file with a `FIXME` that is not 
aligned with your observation.
```
char const *const glob_ptr8 = "123";
void glob_ptr_index4() {
  clang_analyzer_eval(glob_ptr8[0] == '1');  // expected-warning{{TRUE}}
  clang_analyzer_eval(glob_ptr8[1] == '2');  // expected-warning{{TRUE}}
  clang_analyzer_eval(glob_ptr8[2] == '3');  // expected-warning{{TRUE}}
  clang_analyzer_eval(glob_ptr8[3] == '\0'); // expected-warning{{TRUE}}
  // FIXME: Should be UNDEFINED.
  // We should take into account a declaration in which the literal is used.
  clang_analyzer_eval(glob_ptr8[4] == '\0'); // expected-warning{{TRUE}}
}
```



Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1757-1760
+  // FIXME: Nevertheless, we can't do the same for cases, like:
+  //   const char *str = "123"; // literal length is 4
+  //   char c = str[41];// offset is 41
+  // It should be properly handled before reaching this point.

martong wrote:
> steakhal wrote:
> > ASDenysPetrov wrote:
> > > ASDenysPetrov wrote:
> > > > steakhal wrote:
> > > > > martong wrote:
> > > > > > ASDenysPetrov wrote:
> > > > > > > ASDenysPetrov wrote:
> > > > > > > > martong wrote:
> > > > > > > > > Thanks for updating the patch! However, this `FIXME` makes me 
> > > > > > > > > worried. Do you think you could pass the `Decl` itself to 
> > > > > > > > > `getSValFromInitListExpr` in order to be able to check 
> > > > > > > > > whether the type is a pointer or an array? 
> > > > > > > > This worried me as well. Currently I can't find a way to get 
> > > > > > > > the `Decl` for `SL`.
> > > > > > > > 
> > > > > > > We can load this as is for now with mentioning the known issue.
> > > > > > This might cause some itchy false positives. Perhaps, we could 
> > > > > > address this in a follow-up patch and then commit them together?
> > > > > > Currently I can't find a way t

[PATCH] D107339: [analyzer] Retrieve a character from StringLiteral as an initializer for constant arrays.

2021-10-28 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1757-1760
+  // FIXME: Nevertheless, we can't do the same for cases, like:
+  //   const char *str = "123"; // literal length is 4
+  //   char c = str[41];// offset is 41
+  // It should be properly handled before reaching this point.

martong wrote:
> martong wrote:
> > steakhal wrote:
> > > ASDenysPetrov wrote:
> > > > ASDenysPetrov wrote:
> > > > > steakhal wrote:
> > > > > > martong wrote:
> > > > > > > ASDenysPetrov wrote:
> > > > > > > > ASDenysPetrov wrote:
> > > > > > > > > martong wrote:
> > > > > > > > > > Thanks for updating the patch! However, this `FIXME` makes 
> > > > > > > > > > me worried. Do you think you could pass the `Decl` itself 
> > > > > > > > > > to `getSValFromInitListExpr` in order to be able to check 
> > > > > > > > > > whether the type is a pointer or an array? 
> > > > > > > > > This worried me as well. Currently I can't find a way to get 
> > > > > > > > > the `Decl` for `SL`.
> > > > > > > > > 
> > > > > > > > We can load this as is for now with mentioning the known issue.
> > > > > > > This might cause some itchy false positives. Perhaps, we could 
> > > > > > > address this in a follow-up patch and then commit them together?
> > > > > > > Currently I can't find a way to get the Decl for SL.
> > > > > > Why do you need a Decl? The SVal's gotta be an `Element{"123",41 
> > > > > > S64b,char}` for the example in the comment (*).
> > > > > > 
> > > > > > (*) With a minor modification: https://godbolt.org/z/7zhGMnf7P
> > > > > > ```lang=C++
> > > > > > template  void clang_analyzer_dump(T);
> > > > > > const char * const str = "123";
> > > > > > const char * str2 = "123";
> > > > > > void top() {
> > > > > >   clang_analyzer_dump(&str[41]);  // &Element{"123",41 S64b,char}
> > > > > >   clang_analyzer_dump(&str2[41]); // 
> > > > > > &Element{SymRegion{reg_$0},41 S64b,char}
> > > > > > }
> > > > > > ```
> > > > > Because only `Decl` can tell us whether it is a `const char str[42]` 
> > > > > or `const char * const str`. We can't say anything just looking at 
> > > > > `SVal`.
> > > > > This might cause some itchy false positives. Perhaps, we could 
> > > > > address this in a follow-up patch and then commit them together?
> > > > This will produce not more FP as before, even less. I didn't change the 
> > > > behavior specifically here. I just found the issue point to it.
> > > I probably still miss the point. https://godbolt.org/z/EMhbq3745
> > > Since the case you mention is actually represented by a 
> > > `NonParamVarRegion` which holds a pointer to its decl.
> > > ```lang=C++
> > > const char str3[43] = "123";
> > > void top() {
> > >   clang_analyzer_dump(&str3[41]); // &Element{str3,41 S64b,char}
> > >   //NonParamVarRegion  --- (it can print the name 
> > > of the *decl*)
> > > }
> > > ```
> > > 
> > > ---
> > > 
> > > What I wanted to highlight is, that it's a non-issue. In your example you 
> > > had a **non-const** global variable, thus we could not infer any 
> > > meaningful initial value for it, and that is actually the expected 
> > > behavior. As soon as I marked the `str` pointer //const// (along with its 
> > > //pointee//), suddenly the analyzer can infer its initial value.
> > But @steakhal, we have this case in the test file with a `FIXME` that is 
> > not aligned with your observation.
> > ```
> > char const *const glob_ptr8 = "123";
> > void glob_ptr_index4() {
> >   clang_analyzer_eval(glob_ptr8[0] == '1');  // expected-warning{{TRUE}}
> >   clang_analyzer_eval(glob_ptr8[1] == '2');  // expected-warning{{TRUE}}
> >   clang_analyzer_eval(glob_ptr8[2] == '3');  // expected-warning{{TRUE}}
> >   clang_analyzer_eval(glob_ptr8[3] == '\0'); // expected-warning{{TRUE}}
> >   // FIXME: Should be UNDEFINED.
> >   // We should take into account a declaration in which the literal is used.
> >   clang_analyzer_eval(glob_ptr8[4] == '\0'); // expected-warning{{TRUE}}
> > }
> > ```
> > > This might cause some itchy false positives. Perhaps, we could address 
> > > this in a follow-up patch and then commit them together?
> > This will produce not more FP as before, even less. I didn't change the 
> > behavior specifically here. I just found the issue point to it.
> 
> Would it be a FP introduced by this patch? Or we would report the "bug" in 
> the baseline too?
> ```
> char const *const glob_ptr8 = "123";
> int glob_ptr_index4(int x) {
>   return x/glob_ptr8[4]; // Div by zero 
> }
> ```
> Actually, we should report "accessing garbage or undefined" instead of div 
> zero.
Actually, separating the tests into a parent patch would highlight these 
differences.


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

https://reviews.llvm.org/D107339

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

[PATCH] D107450: [clang-tidy] Fix wrong FixIt in performance-move-const-arg

2021-10-28 Thread Whisperity via Phabricator via cfe-commits
whisperity added a comment.

Okay. I think I am convinced. And removing a bogus automated fix is always a 
positive change!




Comment at: clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp:144
+  << (InvocationParm->getFunctionScopeIndex() + 1)
+  << ReceivingCallExpr->getDirectCallee()->getName()
+  << InvocationParm->getOriginalType() << ExpectParmTypeName;

I am not sure if this will always return something reasonable as a printed name.

Could you please add a test case where the receiving function is a 
//constructor//? E.g. a `testStringView` that takes, let's say, `const char*&&`?



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:116-119
+- Improved :doc:`performance-move-const-arg` check.
+
+  Removed fixes for that a trivially-copyable object wrapped by std::move is 
passed to the function with rvalue reference parameters because the code was 
broken by removing std::move.
+

I tried to make the release note entry a bit easier to understand. Of course, 
please reflow!


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

https://reviews.llvm.org/D107450

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


[clang] 49285f4 - [analyzer] sprintf is a taint propagator not a source

2021-10-28 Thread Balazs Benics via cfe-commits

Author: Balazs Benics
Date: 2021-10-28T11:03:02+02:00
New Revision: 49285f43e5ed17206235e43c9cd17762d77ed275

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

LOG: [analyzer] sprintf is a taint propagator not a source

Due to a typo, `sprintf()` was recognized as a taint source instead of a
taint propagator. It was because an empty taint source list - which is
the first parameter of the `TaintPropagationRule` - encoded the
unconditional taint sources.
This typo effectively turned the `sprintf()` into an unconditional taint
source.

This patch fixes that typo and demonstrated the correct behavior with
tests.

Reviewed By: martong

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
clang/test/Analysis/taint-generic.c

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
index 69e9cbd51c357..66ef781871ec9 100644
--- a/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
@@ -514,7 +514,7 @@ 
GenericTaintChecker::TaintPropagationRule::getTaintPropagationRule(
 if (OneOf("snprintf"))
   return {{1}, {0, ReturnValueIndex}, VariadicType::Src, 3};
 if (OneOf("sprintf"))
-  return {{}, {0, ReturnValueIndex}, VariadicType::Src, 2};
+  return {{1}, {0, ReturnValueIndex}, VariadicType::Src, 2};
 if (OneOf("strcpy", "stpcpy", "strcat"))
   return {{1}, {0, ReturnValueIndex}};
 if (OneOf("bcopy"))

diff  --git a/clang/test/Analysis/taint-generic.c 
b/clang/test/Analysis/taint-generic.c
index 2cbd580168ba9..90ab454ff7e8f 100644
--- a/clang/test/Analysis/taint-generic.c
+++ b/clang/test/Analysis/taint-generic.c
@@ -341,6 +341,16 @@ void constraintManagerShouldTreatAsOpaque(int rhs) {
 *(volatile int *) 0; // no-warning
 }
 
+int sprintf_is_not_a_source(char *buf, char *msg) {
+  int x = sprintf(buf, "%s", msg); // no-warning
+  return 1 / x; // no-warning: 'sprintf' is not a taint source
+}
+
+int sprintf_propagates_taint(char *buf, char *msg) {
+  scanf("%s", msg);
+  int x = sprintf(buf, "%s", msg); // propagate taint!
+  return 1 / x; // expected-warning {{Division by a tainted value, possibly 
zero}}
+}
 
 // Test configuration
 int mySource1();



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


[PATCH] D112558: [analyzer] sprintf is a taint propagator not a source

2021-10-28 Thread Balázs Benics via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG49285f43e5ed: [analyzer] sprintf is a taint propagator not a 
source (authored by steakhal).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D112558?vs=382600&id=382953#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112558

Files:
  clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
  clang/test/Analysis/taint-generic.c


Index: clang/test/Analysis/taint-generic.c
===
--- clang/test/Analysis/taint-generic.c
+++ clang/test/Analysis/taint-generic.c
@@ -341,6 +341,16 @@
 *(volatile int *) 0; // no-warning
 }
 
+int sprintf_is_not_a_source(char *buf, char *msg) {
+  int x = sprintf(buf, "%s", msg); // no-warning
+  return 1 / x; // no-warning: 'sprintf' is not a taint source
+}
+
+int sprintf_propagates_taint(char *buf, char *msg) {
+  scanf("%s", msg);
+  int x = sprintf(buf, "%s", msg); // propagate taint!
+  return 1 / x; // expected-warning {{Division by a tainted value, possibly 
zero}}
+}
 
 // Test configuration
 int mySource1();
Index: clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
@@ -514,7 +514,7 @@
 if (OneOf("snprintf"))
   return {{1}, {0, ReturnValueIndex}, VariadicType::Src, 3};
 if (OneOf("sprintf"))
-  return {{}, {0, ReturnValueIndex}, VariadicType::Src, 2};
+  return {{1}, {0, ReturnValueIndex}, VariadicType::Src, 2};
 if (OneOf("strcpy", "stpcpy", "strcat"))
   return {{1}, {0, ReturnValueIndex}};
 if (OneOf("bcopy"))


Index: clang/test/Analysis/taint-generic.c
===
--- clang/test/Analysis/taint-generic.c
+++ clang/test/Analysis/taint-generic.c
@@ -341,6 +341,16 @@
 *(volatile int *) 0; // no-warning
 }
 
+int sprintf_is_not_a_source(char *buf, char *msg) {
+  int x = sprintf(buf, "%s", msg); // no-warning
+  return 1 / x; // no-warning: 'sprintf' is not a taint source
+}
+
+int sprintf_propagates_taint(char *buf, char *msg) {
+  scanf("%s", msg);
+  int x = sprintf(buf, "%s", msg); // propagate taint!
+  return 1 / x; // expected-warning {{Division by a tainted value, possibly zero}}
+}
 
 // Test configuration
 int mySource1();
Index: clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
@@ -514,7 +514,7 @@
 if (OneOf("snprintf"))
   return {{1}, {0, ReturnValueIndex}, VariadicType::Src, 3};
 if (OneOf("sprintf"))
-  return {{}, {0, ReturnValueIndex}, VariadicType::Src, 2};
+  return {{1}, {0, ReturnValueIndex}, VariadicType::Src, 2};
 if (OneOf("strcpy", "stpcpy", "strcat"))
   return {{1}, {0, ReturnValueIndex}};
 if (OneOf("bcopy"))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112420: [clang][ARM] PACBTI-M assembly support

2021-10-28 Thread Oliver Stannard (Linaro) via Phabricator via cfe-commits
ostannard added inline comments.



Comment at: llvm/lib/Target/ARM/ARMInstrThumb2.td:4083
 def : t2InstAlias<"csdb$p",   (t2HINT 20, pred:$p), 1>;
+def : t2InstAlias<"pacbti$p r12,lr,sp", (t2HINT 13, pred:$p), 1>;
+def : t2InstAlias<"bti$p", (t2HINT 15, pred:$p), 1>;

Why are these needed in addition to the PACBTIHintSpaceInst instructions below?



Comment at: llvm/lib/Target/ARM/ARMInstrThumb2.td:5674
+
+def t2AUTG  : PACBTIAut<"autg", 0>;
+def t2BXAUT : PACBTIAut<"bxaut", 1>;

I think all of the `AUT` instructions need `hasSideEffects` set, since they can 
raise exceptions.



Comment at: llvm/lib/Target/ARM/ARMInstrThumb2.td:5675
+def t2AUTG  : PACBTIAut<"autg", 0>;
+def t2BXAUT : PACBTIAut<"bxaut", 1>;
+}

This needs `isBranch` set, and a test added to 
test/MC/ARM/implicit-it-generation.s.



Comment at: llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp:6441
+  Mnemonic == "csetm" ||
+  Mnemonic == "autg"  || Mnemonic == "aut"   ||
+  Mnemonic == "bxaut" || Mnemonic == "pacg"  || Mnemonic == "pac" ||

PACG, AUTG and BXAUT can be conditional, so shouldn't be in this list.



Comment at: llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp:6590
+  Mnemonic.startswith("vpt") || Mnemonic.startswith("vpst") ||
+  Mnemonic == "pacg" || Mnemonic == "pac" || Mnemonic == "pacbti" ||
+  Mnemonic == "autg" || Mnemonic == "aut" || Mnemonic == "bxaut" ||

Again, some of these are predicable.



Comment at: llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp:12283
   // FIXME: Unsupported extensions.
-  {ARM::AEK_OS, {}, {}},
+{ARM::AEK_OS, {}, {}},
   {ARM::AEK_IWMMXT, {}, {}},

Unintentional formatting change.



Comment at: llvm/test/MC/ARM/armv8.1m-pacbti-error.s:3
+
+// CHECK: error: invalid instruction
+pac r0, r1, r2

We should also test the cases where PACG/AUTG/BXAUT cannot use PC/SP.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112420

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


[PATCH] D112695: [clangd] IncludeCleaner: Skip non self-contained headers

2021-10-28 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev created this revision.
kbobyrev added a reviewer: sammccall.
Herald added subscribers: usaxena95, arphaman.
kbobyrev requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Headers without include guards might have side effects or can be the files we
don't want to consider (e.g. tablegen ".inc" files). Skip them when translating
headers to the HeaderIDs that we will consider as unused.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112695

Files:
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/IncludeCleaner.h
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
  clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp

Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -9,6 +9,7 @@
 #include "Annotations.h"
 #include "IncludeCleaner.h"
 #include "TestTU.h"
+#include "llvm/ADT/StringRef.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
@@ -16,6 +17,10 @@
 namespace clangd {
 namespace {
 
+std::string guard(llvm::StringRef Code) {
+  return "#pragma once\n" + Code.str();
+}
+
 using ::testing::ElementsAre;
 using ::testing::UnorderedElementsAre;
 
@@ -216,13 +221,13 @@
   // Build expected ast with symbols coming from headers.
   TestTU TU;
   TU.Filename = "foo.cpp";
-  TU.AdditionalFiles["foo.h"] = "void foo();";
-  TU.AdditionalFiles["a.h"] = "void a();";
-  TU.AdditionalFiles["b.h"] = "void b();";
-  TU.AdditionalFiles["dir/c.h"] = "void c();";
-  TU.AdditionalFiles["unused.h"] = "void unused();";
-  TU.AdditionalFiles["dir/unused.h"] = "void dirUnused();";
-  TU.AdditionalFiles["system/system_header.h"] = "";
+  TU.AdditionalFiles["foo.h"] = guard("void foo();");
+  TU.AdditionalFiles["a.h"] = guard("void a();");
+  TU.AdditionalFiles["b.h"] = guard("void b();");
+  TU.AdditionalFiles["dir/c.h"] = guard("void c();");
+  TU.AdditionalFiles["unused.h"] = guard("void unused();");
+  TU.AdditionalFiles["dir/unused.h"] = guard("void dirUnused();");
+  TU.AdditionalFiles["system/system_header.h"] = guard("");
   TU.ExtraArgs.push_back("-I" + testPath("dir"));
   TU.ExtraArgs.push_back("-isystem" + testPath("system"));
   TU.Code = MainFile.str();
@@ -252,6 +257,9 @@
   // ScratchBuffer with `flags::FLAGS_FOO` that will have FileID but not
   // FileEntry.
   TU.AdditionalFiles["macros.h"] = R"cpp(
+#ifndef MACROS_H
+#define MACROS_H
+
 #define DEFINE_FLAG(X) \
 namespace flags { \
 int FLAGS_##X; \
@@ -261,6 +269,8 @@
 
 #define ab x
 #define concat(x, y) x##y
+
+#endif // MACROS_H
 )cpp";
   TU.ExtraArgs = {"-DCLI=42"};
   ParsedAST AST = TU.build();
@@ -278,7 +288,9 @@
testPath("macros.h")));
 
   // Should not crash due to FileIDs that are not headers.
-  auto ReferencedHeaders = translateToHeaderIDs(ReferencedFiles, Includes, SM);
+  auto ReferencedHeaders =
+  translateToHeaderIDs(ReferencedFiles, Includes, SM,
+   AST.getPreprocessor().getHeaderSearchInfo());
   std::vector ReferencedHeaderNames;
   for (IncludeStructure::HeaderID HID : ReferencedHeaders)
 ReferencedHeaderNames.push_back(Includes.getRealPath(HID));
Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -1494,9 +1494,11 @@
   TestTU TU;
   TU.Code = Test.code().str();
   TU.AdditionalFiles["unused.h"] = R"cpp(
+#pragma once
 void unused() {}
   )cpp";
   TU.AdditionalFiles["used.h"] = R"cpp(
+#pragma once
 void used() {}
   )cpp";
   TU.AdditionalFiles["system/system_header.h"] = "";
Index: clang-tools-extra/clangd/IncludeCleaner.h
===
--- clang-tools-extra/clangd/IncludeCleaner.h
+++ clang-tools-extra/clangd/IncludeCleaner.h
@@ -24,6 +24,7 @@
 #include "Headers.h"
 #include "ParsedAST.h"
 #include "clang/Basic/SourceLocation.h"
+#include "clang/Lex/HeaderSearch.h"
 #include "llvm/ADT/DenseSet.h"
 #include 
 
@@ -58,7 +59,8 @@
 /// FileIDs that are not true files ( etc) are dropped.
 llvm::DenseSet
 translateToHeaderIDs(const llvm::DenseSet &Files,
- const IncludeStructure &Includes, const SourceManager &SM);
+ const IncludeStructure &Includes, const SourceManager &SM,
+ HeaderSearch &HeaderSearch);
 
 /// Retrieves headers that are referenced from the main file but not used.
 std::vector
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/Include

[PATCH] D112695: [clangd] IncludeCleaner: Skip non self-contained headers

2021-10-28 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 382955.
kbobyrev added a comment.

Update the docs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112695

Files:
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/IncludeCleaner.h
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
  clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp

Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -9,6 +9,7 @@
 #include "Annotations.h"
 #include "IncludeCleaner.h"
 #include "TestTU.h"
+#include "llvm/ADT/StringRef.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
@@ -16,6 +17,10 @@
 namespace clangd {
 namespace {
 
+std::string guard(llvm::StringRef Code) {
+  return "#pragma once\n" + Code.str();
+}
+
 using ::testing::ElementsAre;
 using ::testing::UnorderedElementsAre;
 
@@ -216,13 +221,13 @@
   // Build expected ast with symbols coming from headers.
   TestTU TU;
   TU.Filename = "foo.cpp";
-  TU.AdditionalFiles["foo.h"] = "void foo();";
-  TU.AdditionalFiles["a.h"] = "void a();";
-  TU.AdditionalFiles["b.h"] = "void b();";
-  TU.AdditionalFiles["dir/c.h"] = "void c();";
-  TU.AdditionalFiles["unused.h"] = "void unused();";
-  TU.AdditionalFiles["dir/unused.h"] = "void dirUnused();";
-  TU.AdditionalFiles["system/system_header.h"] = "";
+  TU.AdditionalFiles["foo.h"] = guard("void foo();");
+  TU.AdditionalFiles["a.h"] = guard("void a();");
+  TU.AdditionalFiles["b.h"] = guard("void b();");
+  TU.AdditionalFiles["dir/c.h"] = guard("void c();");
+  TU.AdditionalFiles["unused.h"] = guard("void unused();");
+  TU.AdditionalFiles["dir/unused.h"] = guard("void dirUnused();");
+  TU.AdditionalFiles["system/system_header.h"] = guard("");
   TU.ExtraArgs.push_back("-I" + testPath("dir"));
   TU.ExtraArgs.push_back("-isystem" + testPath("system"));
   TU.Code = MainFile.str();
@@ -252,6 +257,9 @@
   // ScratchBuffer with `flags::FLAGS_FOO` that will have FileID but not
   // FileEntry.
   TU.AdditionalFiles["macros.h"] = R"cpp(
+#ifndef MACROS_H
+#define MACROS_H
+
 #define DEFINE_FLAG(X) \
 namespace flags { \
 int FLAGS_##X; \
@@ -261,6 +269,8 @@
 
 #define ab x
 #define concat(x, y) x##y
+
+#endif // MACROS_H
 )cpp";
   TU.ExtraArgs = {"-DCLI=42"};
   ParsedAST AST = TU.build();
@@ -278,7 +288,9 @@
testPath("macros.h")));
 
   // Should not crash due to FileIDs that are not headers.
-  auto ReferencedHeaders = translateToHeaderIDs(ReferencedFiles, Includes, SM);
+  auto ReferencedHeaders =
+  translateToHeaderIDs(ReferencedFiles, Includes, SM,
+   AST.getPreprocessor().getHeaderSearchInfo());
   std::vector ReferencedHeaderNames;
   for (IncludeStructure::HeaderID HID : ReferencedHeaders)
 ReferencedHeaderNames.push_back(Includes.getRealPath(HID));
Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -1494,9 +1494,11 @@
   TestTU TU;
   TU.Code = Test.code().str();
   TU.AdditionalFiles["unused.h"] = R"cpp(
+#pragma once
 void unused() {}
   )cpp";
   TU.AdditionalFiles["used.h"] = R"cpp(
+#pragma once
 void used() {}
   )cpp";
   TU.AdditionalFiles["system/system_header.h"] = "";
Index: clang-tools-extra/clangd/IncludeCleaner.h
===
--- clang-tools-extra/clangd/IncludeCleaner.h
+++ clang-tools-extra/clangd/IncludeCleaner.h
@@ -24,6 +24,7 @@
 #include "Headers.h"
 #include "ParsedAST.h"
 #include "clang/Basic/SourceLocation.h"
+#include "clang/Lex/HeaderSearch.h"
 #include "llvm/ADT/DenseSet.h"
 #include 
 
@@ -55,10 +56,12 @@
const SourceManager &SM);
 
 /// Maps FileIDs to the internal IncludeStructure representation (HeaderIDs).
-/// FileIDs that are not true files ( etc) are dropped.
+/// FileIDs that are not true files ( etc) and headers without
+/// include guards are dropped.
 llvm::DenseSet
 translateToHeaderIDs(const llvm::DenseSet &Files,
- const IncludeStructure &Includes, const SourceManager &SM);
+ const IncludeStructure &Includes, const SourceManager &SM,
+ HeaderSearch &HeaderSearch);
 
 /// Retrieves headers that are referenced from the main file but not used.
 std::vector
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -14,6 +14,8 @

[PATCH] D112695: [clangd] IncludeCleaner: Skip non self-contained headers

2021-10-28 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev planned changes to this revision.
kbobyrev added a comment.

Aww, I think this is the wrong place to do that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112695

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


[PATCH] D110257: [CFE][Codegen] Make sure to maintain the contiguity of all the static allocas

2021-10-28 Thread Mahesha S via Phabricator via cfe-commits
hsmhsm added a comment.

@rjmccall I assume, I have fixed all your review comments. In case, if I have 
missed something OR if you think, few more changes are required for the patch, 
please do let me know so that I will proceed as per the comments/suggestions. I 
would like to bring this patch to the closure.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110257

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


[PATCH] D112421: [clang][ARM] PACBTI-M frontend support

2021-10-28 Thread Oliver Stannard (Linaro) via Phabricator via cfe-commits
ostannard added a comment.

In the commit message: s/armclang/clang/




Comment at: clang/lib/Driver/ToolChains/Clang.cpp:1832
   // Enable/disable return address signing and indirect branch targets.
   if (Arg *A = Args.getLastArg(options::OPT_msign_return_address_EQ,
options::OPT_mbranch_protection_EQ)) {

This block is duplicating the behaviour of the `CollectARMPACBTIOptions` call 
below.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112421

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


[PATCH] D112422: [clang][ARM] emit PACBTI-M feature defines

2021-10-28 Thread Oliver Stannard (Linaro) via Phabricator via cfe-commits
ostannard accepted this revision.
ostannard added a comment.
This revision is now accepted and ready to land.

LGTM, I assume that the pre-commit test failure is because the bot hasn't 
applied the parent patches.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112422

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


[PATCH] D112695: [clangd] IncludeCleaner: Skip non self-contained headers

2021-10-28 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 382968.
kbobyrev added a comment.

Put the check into the right place.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112695

Files:
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/IncludeCleaner.h
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
  clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp

Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -9,6 +9,7 @@
 #include "Annotations.h"
 #include "IncludeCleaner.h"
 #include "TestTU.h"
+#include "llvm/ADT/StringRef.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
@@ -252,6 +253,9 @@
   // ScratchBuffer with `flags::FLAGS_FOO` that will have FileID but not
   // FileEntry.
   TU.AdditionalFiles["macros.h"] = R"cpp(
+#ifndef MACROS_H
+#define MACROS_H
+
 #define DEFINE_FLAG(X) \
 namespace flags { \
 int FLAGS_##X; \
@@ -261,6 +265,8 @@
 
 #define ab x
 #define concat(x, y) x##y
+
+#endif // MACROS_H
 )cpp";
   TU.ExtraArgs = {"-DCLI=42"};
   ParsedAST AST = TU.build();
Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -1483,7 +1483,9 @@
 TEST(DiagnosticsTest, IncludeCleaner) {
   Annotations Test(R"cpp(
 $fix[[  $diag[[#include "unused.h"]]
-]]#include "used.h"
+]]
+  #include "no_guard.h"
+  #include "used.h"
 
   #include 
 
@@ -1494,9 +1496,16 @@
   TestTU TU;
   TU.Code = Test.code().str();
   TU.AdditionalFiles["unused.h"] = R"cpp(
+#pragma once
 void unused() {}
   )cpp";
+  // This header is unused but doesn't have a header guard meaning it is not
+  // self-contained and can have side effects. There will be no warning for it.
+  TU.AdditionalFiles["no_guard.h"] = R"cpp(
+int side_effects = 42;
+  )cpp";
   TU.AdditionalFiles["used.h"] = R"cpp(
+#pragma once
 void used() {}
   )cpp";
   TU.AdditionalFiles["system/system_header.h"] = "";
Index: clang-tools-extra/clangd/IncludeCleaner.h
===
--- clang-tools-extra/clangd/IncludeCleaner.h
+++ clang-tools-extra/clangd/IncludeCleaner.h
@@ -55,7 +55,8 @@
const SourceManager &SM);
 
 /// Maps FileIDs to the internal IncludeStructure representation (HeaderIDs).
-/// FileIDs that are not true files ( etc) are dropped.
+/// FileIDs that are not true files ( etc) and headers without
+/// include guards are dropped.
 llvm::DenseSet
 translateToHeaderIDs(const llvm::DenseSet &Files,
  const IncludeStructure &Includes, const SourceManager &SM);
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -14,6 +14,8 @@
 #include "support/Trace.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/Basic/SourceLocation.h"
+#include "clang/Lex/HeaderSearch.h"
+#include "clang/Lex/Preprocessor.h"
 #include "clang/Tooling/Syntax/Tokens.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Path.h"
@@ -186,12 +188,27 @@
   }
 }
 
-// FIXME(kirillbobyrev): We currently do not support the umbrella headers.
-// Standard Library headers are typically umbrella headers, and system headers
-// are likely to be the Standard Library headers. Until we have a good support
-// for umbrella headers and Standard Library headers, don't warn about them.
-bool mayConsiderUnused(const Inclusion *Inc) {
-  return Inc->Written.front() != '<';
+bool mayConsiderUnused(const Inclusion *Inc, const IncludeStructure &Includes,
+   FileManager &FM, HeaderSearch &HeaderInfo) {
+  // FIXME(kirillbobyrev): We currently do not support the umbrella headers.
+  // Standard Library headers are typically umbrella headers, and system
+  // headers are likely to be the Standard Library headers. Until we have a
+  // good support for umbrella headers and Standard Library headers, don't warn
+  // about them.
+  if (Inc->Written.front() == '<')
+return false;
+  // Headers without include guards have side effects and are not
+  // self-contained, skip them.
+  assert(Inc->HeaderID);
+  auto FE = FM.getFile(Includes.getRealPath(
+  static_cast(*Inc->HeaderID)));
+  assert(FE);
+  if (!HeaderInfo.isFileMultipleIncludeGuarded(*FE)) {
+dlog("{0} doesn't have header guard and will not be considered unused",
+ (*FE)->getName());
+return false;
+  }
+  return true;
 }
 
 } // namespac

[PATCH] D112695: [clangd] IncludeCleaner: Skip non self-contained headers

2021-10-28 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 382969.
kbobyrev added a comment.

Remove redundant changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112695

Files:
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/IncludeCleaner.h
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp

Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -1483,7 +1483,9 @@
 TEST(DiagnosticsTest, IncludeCleaner) {
   Annotations Test(R"cpp(
 $fix[[  $diag[[#include "unused.h"]]
-]]#include "used.h"
+]]
+  #include "no_guard.h"
+  #include "used.h"
 
   #include 
 
@@ -1494,9 +1496,16 @@
   TestTU TU;
   TU.Code = Test.code().str();
   TU.AdditionalFiles["unused.h"] = R"cpp(
+#pragma once
 void unused() {}
   )cpp";
+  // This header is unused but doesn't have a header guard meaning it is not
+  // self-contained and can have side effects. There will be no warning for it.
+  TU.AdditionalFiles["no_guard.h"] = R"cpp(
+int side_effects = 42;
+  )cpp";
   TU.AdditionalFiles["used.h"] = R"cpp(
+#pragma once
 void used() {}
   )cpp";
   TU.AdditionalFiles["system/system_header.h"] = "";
Index: clang-tools-extra/clangd/IncludeCleaner.h
===
--- clang-tools-extra/clangd/IncludeCleaner.h
+++ clang-tools-extra/clangd/IncludeCleaner.h
@@ -55,7 +55,8 @@
const SourceManager &SM);
 
 /// Maps FileIDs to the internal IncludeStructure representation (HeaderIDs).
-/// FileIDs that are not true files ( etc) are dropped.
+/// FileIDs that are not true files ( etc) and headers without
+/// include guards are dropped.
 llvm::DenseSet
 translateToHeaderIDs(const llvm::DenseSet &Files,
  const IncludeStructure &Includes, const SourceManager &SM);
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -14,6 +14,8 @@
 #include "support/Trace.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/Basic/SourceLocation.h"
+#include "clang/Lex/HeaderSearch.h"
+#include "clang/Lex/Preprocessor.h"
 #include "clang/Tooling/Syntax/Tokens.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Path.h"
@@ -186,12 +188,27 @@
   }
 }
 
-// FIXME(kirillbobyrev): We currently do not support the umbrella headers.
-// Standard Library headers are typically umbrella headers, and system headers
-// are likely to be the Standard Library headers. Until we have a good support
-// for umbrella headers and Standard Library headers, don't warn about them.
-bool mayConsiderUnused(const Inclusion *Inc) {
-  return Inc->Written.front() != '<';
+bool mayConsiderUnused(const Inclusion *Inc, const IncludeStructure &Includes,
+   FileManager &FM, HeaderSearch &HeaderInfo) {
+  // FIXME(kirillbobyrev): We currently do not support the umbrella headers.
+  // Standard Library headers are typically umbrella headers, and system
+  // headers are likely to be the Standard Library headers. Until we have a
+  // good support for umbrella headers and Standard Library headers, don't warn
+  // about them.
+  if (Inc->Written.front() == '<')
+return false;
+  // Headers without include guards have side effects and are not
+  // self-contained, skip them.
+  assert(Inc->HeaderID);
+  auto FE = FM.getFile(Includes.getRealPath(
+  static_cast(*Inc->HeaderID)));
+  assert(FE);
+  if (!HeaderInfo.isFileMultipleIncludeGuarded(*FE)) {
+dlog("{0} doesn't have header guard and will not be considered unused",
+ (*FE)->getName());
+return false;
+  }
+  return true;
 }
 
 } // namespace
@@ -291,7 +308,9 @@
   ->getName()
   .str();
   for (const auto *Inc : computeUnusedIncludes(AST)) {
-if (!mayConsiderUnused(Inc))
+if (!mayConsiderUnused(Inc, AST.getIncludeStructure(),
+   AST.getSourceManager().getFileManager(),
+   AST.getPreprocessor().getHeaderSearchInfo()))
   continue;
 Diag D;
 D.Message =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112695: [clangd] IncludeCleaner: Skip non self-contained headers

2021-10-28 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 382970.
kbobyrev added a comment.

Revert docs change that is no longer true.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112695

Files:
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp


Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -1483,7 +1483,9 @@
 TEST(DiagnosticsTest, IncludeCleaner) {
   Annotations Test(R"cpp(
 $fix[[  $diag[[#include "unused.h"]]
-]]#include "used.h"
+]]
+  #include "no_guard.h"
+  #include "used.h"
 
   #include 
 
@@ -1494,9 +1496,16 @@
   TestTU TU;
   TU.Code = Test.code().str();
   TU.AdditionalFiles["unused.h"] = R"cpp(
+#pragma once
 void unused() {}
   )cpp";
+  // This header is unused but doesn't have a header guard meaning it is not
+  // self-contained and can have side effects. There will be no warning for it.
+  TU.AdditionalFiles["no_guard.h"] = R"cpp(
+int side_effects = 42;
+  )cpp";
   TU.AdditionalFiles["used.h"] = R"cpp(
+#pragma once
 void used() {}
   )cpp";
   TU.AdditionalFiles["system/system_header.h"] = "";
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -14,6 +14,8 @@
 #include "support/Trace.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/Basic/SourceLocation.h"
+#include "clang/Lex/HeaderSearch.h"
+#include "clang/Lex/Preprocessor.h"
 #include "clang/Tooling/Syntax/Tokens.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Path.h"
@@ -186,12 +188,27 @@
   }
 }
 
-// FIXME(kirillbobyrev): We currently do not support the umbrella headers.
-// Standard Library headers are typically umbrella headers, and system headers
-// are likely to be the Standard Library headers. Until we have a good support
-// for umbrella headers and Standard Library headers, don't warn about them.
-bool mayConsiderUnused(const Inclusion *Inc) {
-  return Inc->Written.front() != '<';
+bool mayConsiderUnused(const Inclusion *Inc, const IncludeStructure &Includes,
+   FileManager &FM, HeaderSearch &HeaderInfo) {
+  // FIXME(kirillbobyrev): We currently do not support the umbrella headers.
+  // Standard Library headers are typically umbrella headers, and system
+  // headers are likely to be the Standard Library headers. Until we have a
+  // good support for umbrella headers and Standard Library headers, don't warn
+  // about them.
+  if (Inc->Written.front() == '<')
+return false;
+  // Headers without include guards have side effects and are not
+  // self-contained, skip them.
+  assert(Inc->HeaderID);
+  auto FE = FM.getFile(Includes.getRealPath(
+  static_cast(*Inc->HeaderID)));
+  assert(FE);
+  if (!HeaderInfo.isFileMultipleIncludeGuarded(*FE)) {
+dlog("{0} doesn't have header guard and will not be considered unused",
+ (*FE)->getName());
+return false;
+  }
+  return true;
 }
 
 } // namespace
@@ -291,7 +308,9 @@
   ->getName()
   .str();
   for (const auto *Inc : computeUnusedIncludes(AST)) {
-if (!mayConsiderUnused(Inc))
+if (!mayConsiderUnused(Inc, AST.getIncludeStructure(),
+   AST.getSourceManager().getFileManager(),
+   AST.getPreprocessor().getHeaderSearchInfo()))
   continue;
 Diag D;
 D.Message =


Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -1483,7 +1483,9 @@
 TEST(DiagnosticsTest, IncludeCleaner) {
   Annotations Test(R"cpp(
 $fix[[  $diag[[#include "unused.h"]]
-]]#include "used.h"
+]]
+  #include "no_guard.h"
+  #include "used.h"
 
   #include 
 
@@ -1494,9 +1496,16 @@
   TestTU TU;
   TU.Code = Test.code().str();
   TU.AdditionalFiles["unused.h"] = R"cpp(
+#pragma once
 void unused() {}
   )cpp";
+  // This header is unused but doesn't have a header guard meaning it is not
+  // self-contained and can have side effects. There will be no warning for it.
+  TU.AdditionalFiles["no_guard.h"] = R"cpp(
+int side_effects = 42;
+  )cpp";
   TU.AdditionalFiles["used.h"] = R"cpp(
+#pragma once
 void used() {}
   )cpp";
   TU.AdditionalFiles["system/system_header.h"] = "";
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -14,6 +14,8 @@
 #include "su

[clang-tools-extra] 56a8aee - [clangd] NFC: Match function signature in the header and source file

2021-10-28 Thread Kirill Bobyrev via cfe-commits

Author: Kirill Bobyrev
Date: 2021-10-28T12:13:18+02:00
New Revision: 56a8aee1000149408facdaa1825b043c08cd35ad

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

LOG: [clangd] NFC: Match function signature in the header and source file

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/IncludeCleaner.cpp 
b/clang-tools-extra/clangd/IncludeCleaner.cpp
index b813c3f2c0417..6dfc5256feffd 100644
--- a/clang-tools-extra/clangd/IncludeCleaner.cpp
+++ b/clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -223,10 +223,10 @@ findReferencedFiles(const llvm::DenseSet 
&Locs,
 }
 
 std::vector
-getUnused(const IncludeStructure &Structure,
+getUnused(const IncludeStructure &Includes,
   const llvm::DenseSet &ReferencedFiles) {
   std::vector Unused;
-  for (const Inclusion &MFI : Structure.MainFileIncludes) {
+  for (const Inclusion &MFI : Includes.MainFileIncludes) {
 // FIXME: Skip includes that are not self-contained.
 if (!MFI.HeaderID) {
   elog("File {0} not found.", MFI.Written);



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


[clang-tools-extra] f9201c7 - [clangd] NFC: Use more idiomatic way of checking for definition

2021-10-28 Thread Kirill Bobyrev via cfe-commits

Author: Kirill Bobyrev
Date: 2021-10-28T12:25:12+02:00
New Revision: f9201c70ad082a1c1d13b24f1c9cadab8b470e38

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

LOG: [clangd] NFC: Use more idiomatic way of checking for definition

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/IncludeCleaner.cpp 
b/clang-tools-extra/clangd/IncludeCleaner.cpp
index 6dfc5256feff..26ae356e243e 100644
--- a/clang-tools-extra/clangd/IncludeCleaner.cpp
+++ b/clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -48,7 +48,7 @@ class ReferencedLocationCrawler
 
   bool VisitFunctionDecl(FunctionDecl *FD) {
 // Function definition will require redeclarations to be included.
-if (FD == FD->getDefinition())
+if (FD->isThisDeclarationADefinition())
   add(FD);
 return true;
   }



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


[PATCH] D111062: [RISCV] Rename some assembler mnemonic and intrinsic functions for RVV 1.0.

2021-10-28 Thread Alex Bradbury via Phabricator via cfe-commits
asb added a comment.

Is this blocked on anything or is it good to land?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111062

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


[PATCH] D112646: [clang-tidy] Add `readability-container-contains` check

2021-10-28 Thread Adrian Vogelsgesang via Phabricator via cfe-commits
avogelsgesang added a comment.

> Why readability-, if the intent is to make users move to a newer API?

My line of thinking was:

1. The very similar `readability-container-size-empty` pass is also a 
readability pass.
2. The main reason why I want people to use `contains` over `count` is because 
of readability. For this rule, I want to use modern C++20, not because my 
intent is to "modernize" per se, but because my intent is to make the C++ code 
more readable afterwards

That being said, I don't care strongly about `readability-` vs. `modernize-` 
and if you prefer, I can move the check to `modernize`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112646

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


[PATCH] D112646: [clang-tidy] Add `readability-container-contains` check

2021-10-28 Thread Adrian Vogelsgesang via Phabricator via cfe-commits
avogelsgesang added inline comments.



Comment at: clang-tools-extra/docs/clang-tidy/checks/list.rst:341-343
+   `cert-exp42-c `_, `bugprone-suspicious-memory-comparison 
`_,
`cert-fio38-c `_, `misc-non-copyable-objects 
`_,
+   `cert-flp37-c `_, `bugprone-suspicious-memory-comparison 
`_,

whisperity wrote:
> These are unrelated changes coming from a lack of rebase or a too eager diff.
those changes were added by `add_new_check.py`.
I guess `add_new_check.py` recreates the complete `list.rst` file, and the 
previously checked in `list.rst` was not in sync with the remaining files...

Do you want me to remove those changes from this commit?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112646

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


[PATCH] D34654: Allow passing a regex for headers to exclude from clang-tidy

2021-10-28 Thread Mateusz via Phabricator via cfe-commits
Ashimaru added a comment.

In D34654#3022728 , @alexfh wrote:

> Repeating my question from an earlier comment: would a header glob list 
> (similar to how the format of the `-checks=` flag) be enough for the use 
> cases folks have? On the one hand glob list doesn't support all the features 
> of regular expressions, but are they all useful for matching paths? Glob list 
> in clang-tidy currently supports set union (similar to regex `|`) and  subsequence> - `*` (regex `.*`). If needed, the support can be expanded with 
> `?`, character classes, character ranges and/or other features of POSIX globs 
> (https://man7.org/linux/man-pages/man7/glob.7.html). On the flipside, glob 
> list has a cleaner syntax (no need to quote characters common in paths - like 
> `.`), and allows to easily express exclusion of subsets. It should be a 
> convenient tool to represent a set of files / directories. In comparison to 
> the proposed header-filter + exclude-header-filter glob list makes it 
> possible to naturally express restrictions similar to "everything under a/ 
> (except for everything under a/b/ (except for everything under a/b/c/))" - 
> `a/,-a/b/,a/b/c/`.
>
> What do folks think?

Yes in my case this would be enough :)


Repository:
  rL LLVM

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

https://reviews.llvm.org/D34654

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


[PATCH] D107339: [analyzer] Retrieve a character from StringLiteral as an initializer for constant arrays.

2021-10-28 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:1757-1760
+  // FIXME: Nevertheless, we can't do the same for cases, like:
+  //   const char *str = "123"; // literal length is 4
+  //   char c = str[41];// offset is 41
+  // It should be properly handled before reaching this point.

steakhal wrote:
> martong wrote:
> > martong wrote:
> > > steakhal wrote:
> > > > ASDenysPetrov wrote:
> > > > > ASDenysPetrov wrote:
> > > > > > steakhal wrote:
> > > > > > > martong wrote:
> > > > > > > > ASDenysPetrov wrote:
> > > > > > > > > ASDenysPetrov wrote:
> > > > > > > > > > martong wrote:
> > > > > > > > > > > Thanks for updating the patch! However, this `FIXME` 
> > > > > > > > > > > makes me worried. Do you think you could pass the `Decl` 
> > > > > > > > > > > itself to `getSValFromInitListExpr` in order to be able 
> > > > > > > > > > > to check whether the type is a pointer or an array? 
> > > > > > > > > > This worried me as well. Currently I can't find a way to 
> > > > > > > > > > get the `Decl` for `SL`.
> > > > > > > > > > 
> > > > > > > > > We can load this as is for now with mentioning the known 
> > > > > > > > > issue.
> > > > > > > > This might cause some itchy false positives. Perhaps, we could 
> > > > > > > > address this in a follow-up patch and then commit them together?
> > > > > > > > Currently I can't find a way to get the Decl for SL.
> > > > > > > Why do you need a Decl? The SVal's gotta be an `Element{"123",41 
> > > > > > > S64b,char}` for the example in the comment (*).
> > > > > > > 
> > > > > > > (*) With a minor modification: https://godbolt.org/z/7zhGMnf7P
> > > > > > > ```lang=C++
> > > > > > > template  void clang_analyzer_dump(T);
> > > > > > > const char * const str = "123";
> > > > > > > const char * str2 = "123";
> > > > > > > void top() {
> > > > > > >   clang_analyzer_dump(&str[41]);  // &Element{"123",41 S64b,char}
> > > > > > >   clang_analyzer_dump(&str2[41]); // 
> > > > > > > &Element{SymRegion{reg_$0},41 S64b,char}
> > > > > > > }
> > > > > > > ```
> > > > > > Because only `Decl` can tell us whether it is a `const char 
> > > > > > str[42]` or `const char * const str`. We can't say anything just 
> > > > > > looking at `SVal`.
> > > > > > This might cause some itchy false positives. Perhaps, we could 
> > > > > > address this in a follow-up patch and then commit them together?
> > > > > This will produce not more FP as before, even less. I didn't change 
> > > > > the behavior specifically here. I just found the issue point to it.
> > > > I probably still miss the point. https://godbolt.org/z/EMhbq3745
> > > > Since the case you mention is actually represented by a 
> > > > `NonParamVarRegion` which holds a pointer to its decl.
> > > > ```lang=C++
> > > > const char str3[43] = "123";
> > > > void top() {
> > > >   clang_analyzer_dump(&str3[41]); // &Element{str3,41 S64b,char}
> > > >   //NonParamVarRegion  --- (it can print the 
> > > > name of the *decl*)
> > > > }
> > > > ```
> > > > 
> > > > ---
> > > > 
> > > > What I wanted to highlight is, that it's a non-issue. In your example 
> > > > you had a **non-const** global variable, thus we could not infer any 
> > > > meaningful initial value for it, and that is actually the expected 
> > > > behavior. As soon as I marked the `str` pointer //const// (along with 
> > > > its //pointee//), suddenly the analyzer can infer its initial value.
> > > But @steakhal, we have this case in the test file with a `FIXME` that is 
> > > not aligned with your observation.
> > > ```
> > > char const *const glob_ptr8 = "123";
> > > void glob_ptr_index4() {
> > >   clang_analyzer_eval(glob_ptr8[0] == '1');  // expected-warning{{TRUE}}
> > >   clang_analyzer_eval(glob_ptr8[1] == '2');  // expected-warning{{TRUE}}
> > >   clang_analyzer_eval(glob_ptr8[2] == '3');  // expected-warning{{TRUE}}
> > >   clang_analyzer_eval(glob_ptr8[3] == '\0'); // expected-warning{{TRUE}}
> > >   // FIXME: Should be UNDEFINED.
> > >   // We should take into account a declaration in which the literal is 
> > > used.
> > >   clang_analyzer_eval(glob_ptr8[4] == '\0'); // expected-warning{{TRUE}}
> > > }
> > > ```
> > > > This might cause some itchy false positives. Perhaps, we could address 
> > > > this in a follow-up patch and then commit them together?
> > > This will produce not more FP as before, even less. I didn't change the 
> > > behavior specifically here. I just found the issue point to it.
> > 
> > Would it be a FP introduced by this patch? Or we would report the "bug" in 
> > the baseline too?
> > ```
> > char const *const glob_ptr8 = "123";
> > int glob_ptr_index4(int x) {
> >   return x/glob_ptr8[4]; // Div by zero 
> > }
> > ```
> > Actually, we should report "accessing garbage or undefined" instead of div 
> > zero.
> Actually, separating the tests into a parent patch would highlight these 
> differences.
> In your example you had a 

[PATCH] D112646: [clang-tidy] Add `readability-container-contains` check

2021-10-28 Thread Adrian Vogelsgesang via Phabricator via cfe-commits
avogelsgesang updated this revision to Diff 382982.
avogelsgesang added a comment.

Fix formatting; remove unrelated changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112646

Files:
  clang-tools-extra/clang-tidy/readability/CMakeLists.txt
  clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp
  clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.h
  clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-container-contains.rst
  clang-tools-extra/test/clang-tidy/checkers/readability-container-contains.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-container-contains.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability-container-contains.cpp
@@ -0,0 +1,111 @@
+// RUN: %check_clang_tidy -std=c++20 %s readability-container-contains %t
+
+// Some *very* simplified versions of `map` etc.
+namespace std {
+
+template 
+struct map {
+  unsigned count(const Key &K) const;
+  bool contains(const Key &K) const;
+  void *find(const Key &K);
+  void *end();
+};
+
+template 
+struct set {
+  unsigned count(const Key &K) const;
+  bool contains(const Key &K) const;
+};
+
+template 
+struct unordered_set {
+  unsigned count(const Key &K) const;
+  bool contains(const Key &K) const;
+};
+
+template 
+struct multimap {
+  unsigned count(const Key &K) const;
+  bool contains(const Key &K) const;
+};
+
+} // namespace std
+
+using namespace std;
+
+// Check that we detect various common ways to check for containment
+int testDifferentCheckTypes(map &MyMap) {
+  if (MyMap.count(0))
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use `contains` instead of `count` to check for containment [readability-container-contains]
+// CHECK-FIXES: if (MyMap.contains(0))
+return 1;
+  bool C1 = MyMap.count(1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use `contains` instead of `count` to check for containment [readability-container-contains]
+  // CHECK-FIXES: bool C1 = MyMap.contains(1);
+  auto C2 = static_cast(MyMap.count(1));
+  // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: use `contains` instead of `count` to check for containment [readability-container-contains]
+  // CHECK-FIXES: auto C2 = static_cast(MyMap.contains(1));
+  auto C3 = MyMap.count(2) != 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use `contains` instead of `count` to check for containment [readability-container-contains]
+  // CHECK-FIXES: auto C3 = MyMap.contains(2);
+  auto C4 = MyMap.count(3) > 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use `contains` instead of `count` to check for containment [readability-container-contains]
+  // CHECK-FIXES: auto C4 = MyMap.contains(3);
+  auto C5 = MyMap.count(4) >= 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use `contains` instead of `count` to check for containment [readability-container-contains]
+  // CHECK-FIXES: auto C5 = MyMap.contains(4);
+  auto C6 = MyMap.find(5) != MyMap.end();
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use `contains` instead of `count` to check for containment [readability-container-contains]
+  // CHECK-FIXES: auto C6 = MyMap.contains(5);
+  return C1 + C2 + C3 + C4 + C5 + C6;
+}
+
+// Check that we detect various common ways to check for non-containment
+int testNegativeChecks(map &MyMap) {
+  bool C1 = !MyMap.count(-1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use `contains` instead of `count` to check for containment [readability-container-contains]
+  // CHECK-FIXES: bool C1 = !MyMap.contains(-1);
+  auto C2 = MyMap.count(-2) == 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use `contains` instead of `count` to check for containment [readability-container-contains]
+  // CHECK-FIXES: auto C2 = !MyMap.contains(-2);
+  auto C3 = MyMap.count(-3) <= 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use `contains` instead of `count` to check for containment [readability-container-contains]
+  // CHECK-FIXES: auto C3 = !MyMap.contains(-3);
+  auto C4 = MyMap.count(-4) < 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use `contains` instead of `count` to check for containment [readability-container-contains]
+  // CHECK-FIXES: auto C4 = !MyMap.contains(-4);
+  auto C5 = MyMap.find(-5) == MyMap.end();
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use `contains` instead of `count` to check for containment [readability-container-contains]
+  // CHECK-FIXES: auto C5 = !MyMap.contains(-5);
+  return C1 + C2 + C3 + C4 + C5;
+}
+
+// Check for various types
+int testDifferentTypes(map &M, unordered_set &US, set &S, multimap &MM) {
+  bool C1 = M.count(1001);
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: use `contains` instead of `count` to check for containment [

[PATCH] D112646: [clang-tidy] Add `readability-container-contains` check

2021-10-28 Thread Adrian Vogelsgesang via Phabricator via cfe-commits
avogelsgesang marked 2 inline comments as done.
avogelsgesang added inline comments.



Comment at: clang-tools-extra/docs/clang-tidy/checks/list.rst:341-343
+   `cert-exp42-c `_, `bugprone-suspicious-memory-comparison 
`_,
`cert-fio38-c `_, `misc-non-copyable-objects 
`_,
+   `cert-flp37-c `_, `bugprone-suspicious-memory-comparison 
`_,

avogelsgesang wrote:
> whisperity wrote:
> > These are unrelated changes coming from a lack of rebase or a too eager 
> > diff.
> those changes were added by `add_new_check.py`.
> I guess `add_new_check.py` recreates the complete `list.rst` file, and the 
> previously checked in `list.rst` was not in sync with the remaining files...
> 
> Do you want me to remove those changes from this commit?
I removed the other changes from this commit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112646

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


[PATCH] D34654: Allow passing a regex for headers to exclude from clang-tidy

2021-10-28 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added a comment.

I've recently fiddled with the `GlobList` to enable globbing in `NOLINT` 
expressions, so I have it quite fresh and I think it could easily be re-used 
here. I'd be happy to implement this feature, should I (can I?) continue on 
this patch or create a brand new one?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D34654

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


[clang] 4d50803 - [libomptarget] Build DeviceRTL for amdgpu

2021-10-28 Thread Jon Chesterfield via cfe-commits

Author: Jon Chesterfield
Date: 2021-10-28T12:34:01+01:00
New Revision: 4d50803ce49ce6b57c4865361c9ba0ad7063b7be

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

LOG: [libomptarget] Build DeviceRTL for amdgpu

Passes same tests as the current deviceRTL. Includes cmake change from D111987.
CI is showing a different set of pass/fails to local, committing this
without the tests enabled by default while debugging that difference.

Reviewed By: jdoerfert

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
openmp/libomptarget/DeviceRTL/CMakeLists.txt
openmp/libomptarget/DeviceRTL/src/Configuration.cpp
openmp/libomptarget/DeviceRTL/src/Synchronization.cpp
openmp/libomptarget/test/mapping/data_member_ref.cpp
openmp/libomptarget/test/mapping/declare_mapper_nested_default_mappers.cpp
openmp/libomptarget/test/mapping/declare_mapper_nested_mappers.cpp
openmp/libomptarget/test/mapping/delete_inf_refcount.c
openmp/libomptarget/test/mapping/lambda_by_value.cpp
openmp/libomptarget/test/mapping/ompx_hold/struct.c
openmp/libomptarget/test/mapping/ptr_and_obj_motion.c
openmp/libomptarget/test/mapping/reduction_implicit_map.cpp
openmp/libomptarget/test/offloading/bug49021.cpp
openmp/libomptarget/test/offloading/bug49334.cpp
openmp/libomptarget/test/offloading/bug50022.cpp
openmp/libomptarget/test/offloading/global_constructor.cpp
openmp/libomptarget/test/offloading/host_as_target.c
openmp/libomptarget/test/unified_shared_memory/api.c
openmp/libomptarget/test/unified_shared_memory/close_enter_exit.c
openmp/libomptarget/test/unified_shared_memory/close_modifier.c
openmp/libomptarget/test/unified_shared_memory/shared_update.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp 
b/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
index 5400e26177291..b138000f8cf29 100644
--- a/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
@@ -252,7 +252,7 @@ void AMDGPUOpenMPToolChain::addClangTargetOptions(
   std::string BitcodeSuffix;
   if (DriverArgs.hasFlag(options::OPT_fopenmp_target_new_runtime,
  options::OPT_fno_openmp_target_new_runtime, false))
-BitcodeSuffix = "new-amdgcn-" + GPUArch;
+BitcodeSuffix = "new-amdgpu-" + GPUArch;
   else
 BitcodeSuffix = "amdgcn-" + GPUArch;
 

diff  --git a/openmp/libomptarget/DeviceRTL/CMakeLists.txt 
b/openmp/libomptarget/DeviceRTL/CMakeLists.txt
index a4f9862fb09b3..419c64d381168 100644
--- a/openmp/libomptarget/DeviceRTL/CMakeLists.txt
+++ b/openmp/libomptarget/DeviceRTL/CMakeLists.txt
@@ -226,6 +226,5 @@ foreach(sm ${nvptx_sm_list})
 endforeach()
 
 foreach(mcpu ${amdgpu_mcpus})
-  # require D112227 or similar to enable the compilation for amdgpu
-  # compileDeviceRTLLibrary(${mcpu} amdgpu -target amdgcn-amd-amdhsa 
-D__AMDGCN__ -fvisibility=default -nogpulib)
+  compileDeviceRTLLibrary(${mcpu} amdgpu -target amdgcn-amd-amdhsa 
-D__AMDGCN__ -fvisibility=default -nogpulib)
 endforeach()

diff  --git a/openmp/libomptarget/DeviceRTL/src/Configuration.cpp 
b/openmp/libomptarget/DeviceRTL/src/Configuration.cpp
index 2b6f20fb1732c..f7c61dc013cf1 100644
--- a/openmp/libomptarget/DeviceRTL/src/Configuration.cpp
+++ b/openmp/libomptarget/DeviceRTL/src/Configuration.cpp
@@ -20,9 +20,9 @@ using namespace _OMP;
 
 #pragma omp declare target
 
-extern uint32_t __omp_rtl_debug_kind;
+extern uint32_t __omp_rtl_debug_kind; // defined by CGOpenMPRuntimeGPU
 
-// TOOD: We want to change the name as soon as the old runtime is gone.
+// TODO: We want to change the name as soon as the old runtime is gone.
 DeviceEnvironmentTy CONSTANT(omptarget_device_environment)
 __attribute__((used));
 

diff  --git a/openmp/libomptarget/DeviceRTL/src/Synchronization.cpp 
b/openmp/libomptarget/DeviceRTL/src/Synchronization.cpp
index d09461a016200..931dffcaa131e 100644
--- a/openmp/libomptarget/DeviceRTL/src/Synchronization.cpp
+++ b/openmp/libomptarget/DeviceRTL/src/Synchronization.cpp
@@ -68,8 +68,23 @@ uint64_t atomicAdd(uint64_t *Address, uint64_t Val, int 
Ordering) {
 ///{
 #pragma omp begin declare variant match(device = {arch(amdgcn)})
 
-uint32_t atomicInc(uint32_t *Address, uint32_t Val, int Ordering) {
-  return __builtin_amdgcn_atomic_inc32(Address, Val, Ordering, "");
+uint32_t atomicInc(uint32_t *A, uint32_t V, int Ordering) {
+  // builtin_amdgcn_atomic_inc32 should expand to this switch when
+  // passed a runtime value, but does not do so yet. Workaround here.
+  switch (Ordering) {
+  default:
+__builtin_unreachable();
+  case __ATOMIC_RELAXED:
+return __builtin_amdgcn_atomic_inc32(A, V, __ATOMIC_RELAXED, "");
+  case __ATOMI

[PATCH] D112227: [libomptarget] Build DeviceRTL for amdgpu

2021-10-28 Thread Jon Chesterfield via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4d50803ce49c: [libomptarget] Build DeviceRTL for amdgpu 
(authored by JonChesterfield).

Changed prior to commit:
  https://reviews.llvm.org/D112227?vs=382866&id=382987#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112227

Files:
  clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
  openmp/libomptarget/DeviceRTL/CMakeLists.txt
  openmp/libomptarget/DeviceRTL/src/Configuration.cpp
  openmp/libomptarget/DeviceRTL/src/Synchronization.cpp
  openmp/libomptarget/test/mapping/data_member_ref.cpp
  openmp/libomptarget/test/mapping/declare_mapper_nested_default_mappers.cpp
  openmp/libomptarget/test/mapping/declare_mapper_nested_mappers.cpp
  openmp/libomptarget/test/mapping/delete_inf_refcount.c
  openmp/libomptarget/test/mapping/lambda_by_value.cpp
  openmp/libomptarget/test/mapping/ompx_hold/struct.c
  openmp/libomptarget/test/mapping/ptr_and_obj_motion.c
  openmp/libomptarget/test/mapping/reduction_implicit_map.cpp
  openmp/libomptarget/test/offloading/bug49021.cpp
  openmp/libomptarget/test/offloading/bug49334.cpp
  openmp/libomptarget/test/offloading/bug50022.cpp
  openmp/libomptarget/test/offloading/global_constructor.cpp
  openmp/libomptarget/test/offloading/host_as_target.c
  openmp/libomptarget/test/unified_shared_memory/api.c
  openmp/libomptarget/test/unified_shared_memory/close_enter_exit.c
  openmp/libomptarget/test/unified_shared_memory/close_modifier.c
  openmp/libomptarget/test/unified_shared_memory/shared_update.c

Index: openmp/libomptarget/test/unified_shared_memory/shared_update.c
===
--- openmp/libomptarget/test/unified_shared_memory/shared_update.c
+++ openmp/libomptarget/test/unified_shared_memory/shared_update.c
@@ -4,6 +4,7 @@
 
 // amdgcn does not have printf definition
 // XFAIL: amdgcn-amd-amdhsa
+// XFAIL: amdgcn-amd-amdhsa-newRTL
 
 #include 
 #include 
Index: openmp/libomptarget/test/unified_shared_memory/close_modifier.c
===
--- openmp/libomptarget/test/unified_shared_memory/close_modifier.c
+++ openmp/libomptarget/test/unified_shared_memory/close_modifier.c
@@ -5,6 +5,7 @@
 
 // amdgcn does not have printf definition
 // XFAIL: amdgcn-amd-amdhsa
+// XFAIL: amdgcn-amd-amdhsa-newRTL
 
 #include 
 #include 
Index: openmp/libomptarget/test/unified_shared_memory/close_enter_exit.c
===
--- openmp/libomptarget/test/unified_shared_memory/close_enter_exit.c
+++ openmp/libomptarget/test/unified_shared_memory/close_enter_exit.c
@@ -5,6 +5,7 @@
 
 // Fails on amdgcn with error: GPU Memory Error
 // XFAIL: amdgcn-amd-amdhsa
+// XFAIL: amdgcn-amd-amdhsa-newRTL
 
 #include 
 #include 
Index: openmp/libomptarget/test/unified_shared_memory/api.c
===
--- openmp/libomptarget/test/unified_shared_memory/api.c
+++ openmp/libomptarget/test/unified_shared_memory/api.c
@@ -4,6 +4,7 @@
 
 // Fails on amdgcn with error: GPU Memory Error
 // XFAIL: amdgcn-amd-amdhsa
+// XFAIL: amdgcn-amd-amdhsa-newRTL
 
 #include 
 #include 
Index: openmp/libomptarget/test/offloading/host_as_target.c
===
--- openmp/libomptarget/test/offloading/host_as_target.c
+++ openmp/libomptarget/test/offloading/host_as_target.c
@@ -9,6 +9,7 @@
 
 // amdgcn does not have printf definition
 // XFAIL: amdgcn-amd-amdhsa
+// XFAIL: amdgcn-amd-amdhsa-newRTL
 
 #include 
 #include 
Index: openmp/libomptarget/test/offloading/global_constructor.cpp
===
--- openmp/libomptarget/test/offloading/global_constructor.cpp
+++ openmp/libomptarget/test/offloading/global_constructor.cpp
@@ -2,6 +2,7 @@
 
 // Fails in DAGToDAG on an address space problem
 // UNSUPPORTED: amdgcn-amd-amdhsa
+// UNSUPPORTED: amdgcn-amd-amdhsa-newRTL
 
 #include 
 #include 
Index: openmp/libomptarget/test/offloading/bug50022.cpp
===
--- openmp/libomptarget/test/offloading/bug50022.cpp
+++ openmp/libomptarget/test/offloading/bug50022.cpp
@@ -1,6 +1,7 @@
 // RUN: %libomptarget-compilexx-and-run-generic
 
 // UNSUPPORTED: amdgcn-amd-amdhsa
+// UNSUPPORTED: amdgcn-amd-amdhsa-newRTL
 
 #include 
 #include 
Index: openmp/libomptarget/test/offloading/bug49334.cpp
===
--- openmp/libomptarget/test/offloading/bug49334.cpp
+++ openmp/libomptarget/test/offloading/bug49334.cpp
@@ -2,7 +2,7 @@
 
 // Currently hangs on amdgpu
 // UNSUPPORTED: amdgcn-amd-amdhsa
-
+// UNSUPPORTED: amdgcn-amd-amdhsa-newRTL
 // UNSUPPORTED: x86_64-pc-linux-gnu
 
 #include 
Index: openmp/libomptarget/test/offloading/bug49021.cpp

[PATCH] D112704: Re-instate -Wweak-template-vtables as a no-op flag

2021-10-28 Thread Hans Wennborg via Phabricator via cfe-commits
hans created this revision.
hans added reviewers: thakis, dblaikie.
hans requested review of this revision.
Herald added a project: clang.

Follow-up to 
https://github.com/llvm/llvm-project/commit/8c136805242014b6ad9ff1afcac9d7f4a18bec3f
 to allow a less abrupt migration for users.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112704

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/test/SemaCXX/warn-weak-vtables.cpp


Index: clang/test/SemaCXX/warn-weak-vtables.cpp
===
--- clang/test/SemaCXX/warn-weak-vtables.cpp
+++ clang/test/SemaCXX/warn-weak-vtables.cpp
@@ -3,6 +3,9 @@
 // Check that this warning is disabled on MS ABI targets which don't have key
 // functions.
 // RUN: %clang_cc1 %s -fsyntax-only -triple %ms_abi_triple -Werror 
-Wweak-vtables
+//
+// -Wweak-template-vtables is deprecated but we still parse it.
+// RUN: %clang_cc1 %s -fsyntax-only -Werror -Wweak-template-vtables
 
 struct A { // expected-warning {{'A' has no out-of-line virtual method 
definitions; its vtable will be emitted in every translation unit}}
   virtual void f() { } 
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1647,6 +1647,9 @@
   "%0 has no out-of-line virtual method definitions; its vtable will be "
   "emitted in every translation unit">,
   InGroup>, DefaultIgnore;
+def warn_weak_template_vtable : Warning<
+  "this warning is no longer in use and will be removed in the next release">,
+  InGroup>, DefaultIgnore;
 
 def ext_using_undefined_std : ExtWarn<
   "using directive refers to implicitly-defined namespace 'std'">;
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -67,7 +67,8 @@
 Deprecated Compiler Flags
 -
 
-- ...
+- -Wweak-template-vtables has been deprecated and no longer has any effect. The
+  flag will be removed in the next release.
 
 Modified Compiler Flags
 ---


Index: clang/test/SemaCXX/warn-weak-vtables.cpp
===
--- clang/test/SemaCXX/warn-weak-vtables.cpp
+++ clang/test/SemaCXX/warn-weak-vtables.cpp
@@ -3,6 +3,9 @@
 // Check that this warning is disabled on MS ABI targets which don't have key
 // functions.
 // RUN: %clang_cc1 %s -fsyntax-only -triple %ms_abi_triple -Werror -Wweak-vtables
+//
+// -Wweak-template-vtables is deprecated but we still parse it.
+// RUN: %clang_cc1 %s -fsyntax-only -Werror -Wweak-template-vtables
 
 struct A { // expected-warning {{'A' has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit}}
   virtual void f() { } 
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1647,6 +1647,9 @@
   "%0 has no out-of-line virtual method definitions; its vtable will be "
   "emitted in every translation unit">,
   InGroup>, DefaultIgnore;
+def warn_weak_template_vtable : Warning<
+  "this warning is no longer in use and will be removed in the next release">,
+  InGroup>, DefaultIgnore;
 
 def ext_using_undefined_std : ExtWarn<
   "using directive refers to implicitly-defined namespace 'std'">;
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -67,7 +67,8 @@
 Deprecated Compiler Flags
 -
 
-- ...
+- -Wweak-template-vtables has been deprecated and no longer has any effect. The
+  flag will be removed in the next release.
 
 Modified Compiler Flags
 ---
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112534: [PoC][RISCV] Use an attribute to declare C intrinsics with different policy.

2021-10-28 Thread Fraser Cormack via Phabricator via cfe-commits
frasercrmck added a comment.
Herald added a reviewer: luke957.

Just nits from me at this stage.




Comment at: clang/include/clang/Basic/AttrDocs.td:2150
+  let Content = [{
+Users could use the attribute to specify the policy of destination tail and
+destination inactive masked-off elements in the vector operations. There are

Nit, but the use of `could` seems out of place in this documentation. Is `can` 
or `may` perhaps more common?



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:895
 ListSeparator LS;
 for (unsigned i = 0; i < InputTypes.size(); ++i)
   OS << LS << InputTypes[i]->getTypeStr();

This variable `i` shadowing the outer loop's induction variable is a little 
odd. Perhaps the outer loop could use a range-based for?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112534

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


[PATCH] D112227: [libomptarget] Build DeviceRTL for amdgpu

2021-10-28 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

Landed a slightly modified version of this - code and test changes are 
included, but the tests are not run by default. I'm hopeful this will help the 
process of working out why ~10 are failing on CI and passing locally.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112227

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


[PATCH] D34654: Allow passing a regex for headers to exclude from clang-tidy

2021-10-28 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added a comment.

On the other hand, switching from Regex to Glob will be quite a breaking change 
- everyone has `.*` in their config file, which will silently stop to work when 
switching to Glob and suddenly people won't get their headers linted. What do 
you think?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D34654

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


[PATCH] D112707: [clangd] IncludeCleaner: Be more conservative in marking RecordDecl usage

2021-10-28 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev created this revision.
kbobyrev added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman.
kbobyrev requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

For expression with RecordDecl type, we only need its definition in case it's
available. And when it isn't, there's a high chance the forward decl is in the
same file, so take the most recent decl.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112707

Files:
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp


Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -72,9 +72,13 @@
   },
   // Redecls
   {
-  "class ^X; class ^X{}; class ^X;",
+  "class X; class ^X{}; class X;",
   "X *y;",
   },
+  {
+  "class X;",
+  "class X; X *y;",
+  },
   // Constructor
   {
   "struct ^X { ^X(int) {} int ^foo(); };",
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -15,6 +15,7 @@
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Tooling/Syntax/Tokens.h"
+#include "llvm/Support/Casting.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Path.h"
 
@@ -42,6 +43,14 @@
   }
 
   bool VisitTagType(TagType *TT) {
+// For RecordDecls take either definition or the most recent forward
+// declaration.
+if (const auto *RD = llvm::dyn_cast(TT->getDecl())) {
+  const auto *Definition = RD->getDefinition();
+  Result.insert(Definition ? Definition->getLocation()
+   : RD->getMostRecentDecl()->getLocation());
+  return true;
+}
 add(TT->getDecl());
 return true;
   }


Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -72,9 +72,13 @@
   },
   // Redecls
   {
-  "class ^X; class ^X{}; class ^X;",
+  "class X; class ^X{}; class X;",
   "X *y;",
   },
+  {
+  "class X;",
+  "class X; X *y;",
+  },
   // Constructor
   {
   "struct ^X { ^X(int) {} int ^foo(); };",
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -15,6 +15,7 @@
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Tooling/Syntax/Tokens.h"
+#include "llvm/Support/Casting.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Path.h"
 
@@ -42,6 +43,14 @@
   }
 
   bool VisitTagType(TagType *TT) {
+// For RecordDecls take either definition or the most recent forward
+// declaration.
+if (const auto *RD = llvm::dyn_cast(TT->getDecl())) {
+  const auto *Definition = RD->getDefinition();
+  Result.insert(Definition ? Definition->getLocation()
+   : RD->getMostRecentDecl()->getLocation());
+  return true;
+}
 add(TT->getDecl());
 return true;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112404: [SPIR-V] Add translator tool

2021-10-28 Thread Alexey Bader via Phabricator via cfe-commits
bader accepted this revision.
bader added a comment.
This revision is now accepted and ready to land.

This part looks good to me. Just a couple of minor style comments.




Comment at: clang/lib/Driver/ToolChains/SPIRV.cpp:18
+
+void SPIRV::constructTranslateCommand(Compilation &C, const Tool &T,
+  const JobAction &JA,

If this function is going to be used only by `SPIRV::Translator::ConstructJob`, 
it's better to make it `static` or manually inline into 4-line 
`SPIRV::Translator::ConstructJob`.



Comment at: clang/lib/Driver/ToolChains/SPIRV.h:31
+  Translator(const ToolChain &TC)
+  : Tool("SPIRV::Translator", "translator", TC) {}
+

I think using just "translator" as a short name might be ambiguous.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112404

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


[PATCH] D107339: [analyzer] Retrieve a character from StringLiteral as an initializer for constant arrays.

2021-10-28 Thread Balázs Benics via Phabricator via cfe-commits
steakhal accepted this revision.
steakhal added a comment.
This revision is now accepted and ready to land.

There is no need to do anything with this. You can commit as-is.
I've done it myself, and it seems like your patch only turns `TRUE` for the 
cases where it was `UNKNOWN` or `FALSE` previously.
So these test cases were changed by your test, and the rest of them were 
preserved in your patch:
`glob_array_index5()`, `glob_ptr_index3()`, `glob_array_index6()`, 
`glob_ptr_index5()`, `glob_ptr_index6()`, `glob_ptr_index7()`

Next time I would rather have two patches, one of which adds tests to document 
the existing behavior and a follow-up changing the behavior.


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

https://reviews.llvm.org/D107339

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


[PATCH] D112704: Re-instate -Wweak-template-vtables as a no-op flag

2021-10-28 Thread Nico Weber via Phabricator via cfe-commits
thakis accepted this revision.
thakis added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112704

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


[PATCH] D107339: [analyzer] Retrieve a character from StringLiteral as an initializer for constant arrays.

2021-10-28 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 382999.
ASDenysPetrov edited the summary of this revision.
ASDenysPetrov added a comment.

Updated comments briefly explaining the root of the existing issue.

Thanks, @steakhal and @martong.  I appreciate your efforts!


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

https://reviews.llvm.org/D107339

Files:
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp
  clang/test/Analysis/initialization.cpp

Index: clang/test/Analysis/initialization.cpp
===
--- clang/test/Analysis/initialization.cpp
+++ clang/test/Analysis/initialization.cpp
@@ -146,3 +146,110 @@
 void struct_arr_index1() {
   clang_analyzer_eval(S2::arr_no_init[2]); // expected-warning{{UNKNOWN}}
 }
+
+char const glob_arr6[5] = "123";
+void glob_array_index5() {
+  clang_analyzer_eval(glob_arr6[0] == '1');  // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr6[1] == '2');  // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr6[2] == '3');  // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr6[3] == '\0'); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr6[4] == '\0'); // expected-warning{{TRUE}}
+}
+
+void glob_ptr_index3() {
+  char const *ptr = glob_arr6;
+  clang_analyzer_eval(ptr[-42] == '\0'); // expected-warning{{UNDEFINED}}
+  clang_analyzer_eval(ptr[0] == '1');// expected-warning{{TRUE}}
+  clang_analyzer_eval(ptr[1] == '2');// expected-warning{{TRUE}}
+  clang_analyzer_eval(ptr[2] == '3');// expected-warning{{TRUE}}
+  clang_analyzer_eval(ptr[3] == '\0');   // expected-warning{{TRUE}}
+  clang_analyzer_eval(ptr[4] == '\0');   // expected-warning{{TRUE}}
+  clang_analyzer_eval(ptr[5] == '\0');   // expected-warning{{UNDEFINED}}
+  clang_analyzer_eval(ptr[6] == '\0');   // expected-warning{{UNDEFINED}}
+}
+
+void glob_invalid_index7() {
+  int idx = -42;
+  auto x = glob_arr6[idx]; // expected-warning{{garbage or undefined}}
+}
+
+void glob_invalid_index8() {
+  const char *ptr = glob_arr6;
+  int idx = 42;
+  auto x = ptr[idx]; // expected-warning{{garbage or undefined}}
+}
+
+char const glob_arr7[5] = {"123"};
+void glob_array_index6() {
+  clang_analyzer_eval(glob_arr7[0] == '1');  // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr7[1] == '2');  // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr7[2] == '3');  // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr7[3] == '\0'); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_arr7[4] == '\0'); // expected-warning{{TRUE}}
+}
+
+void glob_invalid_index9() {
+  int idx = -42;
+  auto x = glob_arr7[idx]; // expected-warning{{garbage or undefined}}
+}
+
+void glob_invalid_index10() {
+  const char *ptr = glob_arr7;
+  int idx = 42;
+  auto x = ptr[idx]; // expected-warning{{garbage or undefined}}
+}
+
+char const *const glob_ptr8 = "123";
+void glob_ptr_index4() {
+  clang_analyzer_eval(glob_ptr8[0] == '1');  // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_ptr8[1] == '2');  // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_ptr8[2] == '3');  // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_ptr8[3] == '\0'); // expected-warning{{TRUE}}
+  // FIXME: Should be UNDEFINED.
+  // We should take into account a declaration in which the literal is used.
+  clang_analyzer_eval(glob_ptr8[4] == '\0'); // expected-warning{{TRUE}}
+}
+
+void glob_invalid_index11() {
+  int idx = -42;
+  auto x = glob_ptr8[idx]; // expected-warning{{garbage or undefined}}
+}
+
+void glob_invalid_index12() {
+  int idx = 42;
+  // FIXME: Should warn {{garbage or undefined}}
+  // We should take into account a declaration in which the literal is used.
+  auto x = glob_ptr8[idx]; // no-warning
+}
+
+const char16_t *const glob_ptr9 = u"абв";
+void glob_ptr_index5() {
+  clang_analyzer_eval(glob_ptr9[0] == u'а'); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_ptr9[1] == u'б'); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_ptr9[2] == u'в'); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_ptr9[3] == '\0'); // expected-warning{{TRUE}}
+}
+
+const char32_t *const glob_ptr10 = U"\U0001F607\U0001F608\U0001F609";
+void glob_ptr_index6() {
+  clang_analyzer_eval(glob_ptr10[0] == U'\U0001F607'); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_ptr10[1] == U'\U0001F608'); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_ptr10[2] == U'\U0001F609'); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_ptr10[3] == '\0');  // expected-warning{{TRUE}}
+}
+
+const wchar_t *const glob_ptr11 = L"\123\u0041\xFF";
+void glob_ptr_index7() {
+  clang_analyzer_eval(glob_ptr11[0] == L'\123');   // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_ptr11[1] == L'\u0041'); // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_ptr11[2] == L'\xFF');   // expected-warning{{TRUE}}
+  clang_analyzer_eval(glob_ptr11[3] == L'\0'); // expected-warning{{TRUE}}
+}
+
+const char *const gl

[PATCH] D112404: [SPIR-V] Add translator tool

2021-10-28 Thread Henry Linjamäki via Phabricator via cfe-commits
linjamaki updated this revision to Diff 383001.
linjamaki added a comment.

Rename SPIRV::Translator's tool names as suggested by bader.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112404

Files:
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/ToolChains/SPIRV.cpp
  clang/lib/Driver/ToolChains/SPIRV.h

Index: clang/lib/Driver/ToolChains/SPIRV.h
===
--- /dev/null
+++ clang/lib/Driver/ToolChains/SPIRV.h
@@ -0,0 +1,46 @@
+//===--- SPIRV.h - SPIR-V Tool Implementations --*- 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_LIB_DRIVER_TOOLCHAINS_SPIRV_H
+#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_SPIRV_H
+
+#include "clang/Driver/Tool.h"
+#include "clang/Driver/ToolChain.h"
+
+namespace clang {
+namespace driver {
+namespace tools {
+namespace SPIRV {
+
+void addTranslatorArgs(const llvm::opt::ArgList &InArgs,
+   llvm::opt::ArgStringList &OutArgs);
+
+void constructTranslateCommand(Compilation &C, const Tool &T,
+   const JobAction &JA, const InputInfo &Output,
+   const InputInfo &Input,
+   const llvm::opt::ArgStringList &Args);
+
+class LLVM_LIBRARY_VISIBILITY Translator : public Tool {
+public:
+  Translator(const ToolChain &TC)
+  : Tool("SPIR-V::Translator", "llvm-spirv", TC) {}
+
+  bool hasIntegratedCPP() const override { return false; }
+  bool hasIntegratedAssembler() const override { return true; }
+
+  void ConstructJob(Compilation &C, const JobAction &JA,
+const InputInfo &Output, const InputInfoList &Inputs,
+const llvm::opt::ArgList &TCArgs,
+const char *LinkingOutput) const override;
+};
+
+} // namespace SPIRV
+} // namespace tools
+} // namespace driver
+} // namespace clang
+#endif
Index: clang/lib/Driver/ToolChains/SPIRV.cpp
===
--- /dev/null
+++ clang/lib/Driver/ToolChains/SPIRV.cpp
@@ -0,0 +1,48 @@
+//===--- SPIRV.cpp - SPIR-V Tool Implementations *- 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 "SPIRV.h"
+#include "CommonArgs.h"
+#include "clang/Driver/Compilation.h"
+#include "clang/Driver/Driver.h"
+#include "clang/Driver/InputInfo.h"
+#include "clang/Driver/Options.h"
+
+using namespace clang::driver::tools;
+using namespace llvm::opt;
+
+void SPIRV::constructTranslateCommand(Compilation &C, const Tool &T,
+  const JobAction &JA,
+  const InputInfo &Output,
+  const InputInfo &Input,
+  const llvm::opt::ArgStringList &Args) {
+  llvm::opt::ArgStringList CmdArgs(Args);
+  CmdArgs.push_back(Input.getFilename());
+
+  if (Input.getType() == types::TY_PP_Asm)
+CmdArgs.push_back("-to-binary");
+  if (Output.getType() == types::TY_PP_Asm)
+CmdArgs.push_back("-spirv-text");
+
+  CmdArgs.append({"-o", Output.getFilename()});
+
+  const char *Exec =
+  C.getArgs().MakeArgString(T.getToolChain().GetProgramPath("llvm-spirv"));
+  C.addCommand(std::make_unique(JA, T, ResponseFileSupport::None(),
+ Exec, CmdArgs, Input, Output));
+}
+
+void SPIRV::Translator::ConstructJob(Compilation &C, const JobAction &JA,
+ const InputInfo &Output,
+ const InputInfoList &Inputs,
+ const ArgList &Args,
+ const char *LinkingOutput) const {
+  claimNoWarnArgs(Args);
+  if (Inputs.size() != 1)
+llvm_unreachable("Invalid number of input files.");
+  constructTranslateCommand(C, *this, JA, Output, Inputs[0], {});
+}
Index: clang/lib/Driver/CMakeLists.txt
===
--- clang/lib/Driver/CMakeLists.txt
+++ clang/lib/Driver/CMakeLists.txt
@@ -69,6 +69,7 @@
   ToolChains/PS4CPU.cpp
   ToolChains/RISCVToolchain.cpp
   ToolChains/Solaris.cpp
+  ToolChains/SPIRV.cpp
   ToolChains/TCE.cpp
   ToolChains/VEToolchain.cpp
   ToolChains/WebAssembly.cpp
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mai

[clang] 4d2765e - Re-instate -Wweak-template-vtables as a no-op flag

2021-10-28 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2021-10-28T14:40:59+02:00
New Revision: 4d2765e9949f3113799527db265cd2fa1994a05e

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

LOG: Re-instate -Wweak-template-vtables as a no-op flag

Follow-up to 8c136805242014b6ad9ff1afcac9d7f4a18bec3f to allow a less
abrupt migration for users.

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/test/SemaCXX/warn-weak-vtables.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 11a039204e13d..b4595b20def53 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -67,7 +67,8 @@ New Compiler Flags
 Deprecated Compiler Flags
 -
 
-- ...
+- -Wweak-template-vtables has been deprecated and no longer has any effect. The
+  flag will be removed in the next release.
 
 Modified Compiler Flags
 ---

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 920146f71bd8a..f2dd69bbdbbd3 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1647,6 +1647,9 @@ def warn_weak_vtable : Warning<
   "%0 has no out-of-line virtual method definitions; its vtable will be "
   "emitted in every translation unit">,
   InGroup>, DefaultIgnore;
+def warn_weak_template_vtable : Warning<
+  "this warning is no longer in use and will be removed in the next release">,
+  InGroup>, DefaultIgnore;
 
 def ext_using_undefined_std : ExtWarn<
   "using directive refers to implicitly-defined namespace 'std'">;

diff  --git a/clang/test/SemaCXX/warn-weak-vtables.cpp 
b/clang/test/SemaCXX/warn-weak-vtables.cpp
index 9355af50310d4..083209fa5e315 100644
--- a/clang/test/SemaCXX/warn-weak-vtables.cpp
+++ b/clang/test/SemaCXX/warn-weak-vtables.cpp
@@ -3,6 +3,9 @@
 // Check that this warning is disabled on MS ABI targets which don't have key
 // functions.
 // RUN: %clang_cc1 %s -fsyntax-only -triple %ms_abi_triple -Werror 
-Wweak-vtables
+//
+// -Wweak-template-vtables is deprecated but we still parse it.
+// RUN: %clang_cc1 %s -fsyntax-only -Werror -Wweak-template-vtables
 
 struct A { // expected-warning {{'A' has no out-of-line virtual method 
definitions; its vtable will be emitted in every translation unit}}
   virtual void f() { } 



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


[PATCH] D112704: Re-instate -Wweak-template-vtables as a no-op flag

2021-10-28 Thread Hans Wennborg via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4d2765e9949f: Re-instate -Wweak-template-vtables as a no-op 
flag (authored by hans).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112704

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/test/SemaCXX/warn-weak-vtables.cpp


Index: clang/test/SemaCXX/warn-weak-vtables.cpp
===
--- clang/test/SemaCXX/warn-weak-vtables.cpp
+++ clang/test/SemaCXX/warn-weak-vtables.cpp
@@ -3,6 +3,9 @@
 // Check that this warning is disabled on MS ABI targets which don't have key
 // functions.
 // RUN: %clang_cc1 %s -fsyntax-only -triple %ms_abi_triple -Werror 
-Wweak-vtables
+//
+// -Wweak-template-vtables is deprecated but we still parse it.
+// RUN: %clang_cc1 %s -fsyntax-only -Werror -Wweak-template-vtables
 
 struct A { // expected-warning {{'A' has no out-of-line virtual method 
definitions; its vtable will be emitted in every translation unit}}
   virtual void f() { } 
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1647,6 +1647,9 @@
   "%0 has no out-of-line virtual method definitions; its vtable will be "
   "emitted in every translation unit">,
   InGroup>, DefaultIgnore;
+def warn_weak_template_vtable : Warning<
+  "this warning is no longer in use and will be removed in the next release">,
+  InGroup>, DefaultIgnore;
 
 def ext_using_undefined_std : ExtWarn<
   "using directive refers to implicitly-defined namespace 'std'">;
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -67,7 +67,8 @@
 Deprecated Compiler Flags
 -
 
-- ...
+- -Wweak-template-vtables has been deprecated and no longer has any effect. The
+  flag will be removed in the next release.
 
 Modified Compiler Flags
 ---


Index: clang/test/SemaCXX/warn-weak-vtables.cpp
===
--- clang/test/SemaCXX/warn-weak-vtables.cpp
+++ clang/test/SemaCXX/warn-weak-vtables.cpp
@@ -3,6 +3,9 @@
 // Check that this warning is disabled on MS ABI targets which don't have key
 // functions.
 // RUN: %clang_cc1 %s -fsyntax-only -triple %ms_abi_triple -Werror -Wweak-vtables
+//
+// -Wweak-template-vtables is deprecated but we still parse it.
+// RUN: %clang_cc1 %s -fsyntax-only -Werror -Wweak-template-vtables
 
 struct A { // expected-warning {{'A' has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit}}
   virtual void f() { } 
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1647,6 +1647,9 @@
   "%0 has no out-of-line virtual method definitions; its vtable will be "
   "emitted in every translation unit">,
   InGroup>, DefaultIgnore;
+def warn_weak_template_vtable : Warning<
+  "this warning is no longer in use and will be removed in the next release">,
+  InGroup>, DefaultIgnore;
 
 def ext_using_undefined_std : ExtWarn<
   "using directive refers to implicitly-defined namespace 'std'">;
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -67,7 +67,8 @@
 Deprecated Compiler Flags
 -
 
-- ...
+- -Wweak-template-vtables has been deprecated and no longer has any effect. The
+  flag will be removed in the next release.
 
 Modified Compiler Flags
 ---
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34654: Allow passing a regex for headers to exclude from clang-tidy

2021-10-28 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added a comment.

Also, the new header filter expresion would need to be: `HeaderFilter: 
'*/mydir/*' instead of `HeaderFilter: 'mydir'`


Repository:
  rL LLVM

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

https://reviews.llvm.org/D34654

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


[PATCH] D107339: [analyzer] Retrieve a character from StringLiteral as an initializer for constant arrays.

2021-10-28 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

In D107339#3093207 , @steakhal wrote:

> Next time I would rather have two patches, one of which adds tests to 
> document the existing behavior and a follow-up changing the behavior.

It makes sense. I will take this into account with the following changes.


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

https://reviews.llvm.org/D107339

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


[PATCH] D112404: [SPIR-V] Add translator tool

2021-10-28 Thread Henry Linjamäki via Phabricator via cfe-commits
linjamaki marked an inline comment as done.
linjamaki added a comment.

Thanks for the review.




Comment at: clang/lib/Driver/ToolChains/SPIRV.cpp:18
+
+void SPIRV::constructTranslateCommand(Compilation &C, const Tool &T,
+  const JobAction &JA,

bader wrote:
> If this function is going to be used only by 
> `SPIRV::Translator::ConstructJob`, it's better to make it `static` or 
> manually inline into 4-line `SPIRV::Translator::ConstructJob`.
This function is used by HIPSPV tool chain too (D110618) by the 
HIPSPV::Linker::constructLinkAndEmitSpirvCommand() function.



Comment at: clang/lib/Driver/ToolChains/SPIRV.h:31
+  Translator(const ToolChain &TC)
+  : Tool("SPIRV::Translator", "translator", TC) {}
+

bader wrote:
> I think using just "translator" as a short name might be ambiguous.
Updated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112404

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


[clang-tools-extra] fbf1745 - [clangd] Escape error message in AddUsing

2021-10-28 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2021-10-28T14:52:12+02:00
New Revision: fbf1745722a0df95608128561d58744ae7b6f311

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

LOG: [clangd] Escape error message in AddUsing

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

Added: 


Modified: 
clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
index c1adbdde6199d..c87b8864d6e6d 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
@@ -187,7 +187,7 @@ findInsertionPoint(const Tweak::Selection &Inputs,
   return Tok.kind() == tok::l_brace;
 });
 if (Tok == Toks.end() || Tok->endLocation().isInvalid()) {
-  return error("Namespace with no {");
+  return error("Namespace with no {{");
 }
 if (!Tok->endLocation().isMacroID() && IsValidPoint(Tok->endLocation())) {
   InsertionPointData Out;



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


[PATCH] D112359: [RISCV] Unify depedency check and extension implication parsing logics

2021-10-28 Thread Alex Bradbury via Phabricator via cfe-commits
asb added a comment.
Herald added a reviewer: luke957.

This doesn't apply cleanly to current HEAD, could you please rebase?

I think the second part of this that you list, where the ISA extension version 
becomes optional is undesirable. We made the explicit choice of requiring the 
version string to be specified for experimental extensions in order to make it 
even clearer up-front that these are subject to change (and to allow people to 
catch easily when the supported ISA version has changed in a compiler update).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112359

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


[PATCH] D112712: [clangd] SelectionTree should prefer lexical declcontext

2021-10-28 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: usaxena95, arphaman.
kadircet requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

This is important especially for code that tries to traverse scopes as
written in code, which is the contract SelectionTree tries to satisfy.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112712

Files:
  clang-tools-extra/clangd/Selection.cpp
  clang-tools-extra/clangd/unittests/SelectionTests.cpp


Index: clang-tools-extra/clangd/unittests/SelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SelectionTests.cpp
@@ -739,6 +739,21 @@
   EXPECT_EQ(1u, Seen) << "one tree for nontrivial selection";
 }
 
+TEST(SelectionTest, DeclContext) {
+  llvm::Annotations Test("namespace a { void $1^foo(); } void a::$2^foo();");
+  auto AST = TestTU::withCode(Test.code()).build();
+  {
+auto ST = SelectionTree::createRight(AST.getASTContext(), AST.getTokens(),
+ Test.point("1"), Test.point("1"));
+EXPECT_FALSE(ST.commonAncestor()->getDeclContext().isTranslationUnit());
+  }
+  {
+auto ST = SelectionTree::createRight(AST.getASTContext(), AST.getTokens(),
+ Test.point("2"), Test.point("2"));
+EXPECT_TRUE(ST.commonAncestor()->getDeclContext().isTranslationUnit());
+  }
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/Selection.cpp
===
--- clang-tools-extra/clangd/Selection.cpp
+++ clang-tools-extra/clangd/Selection.cpp
@@ -897,7 +897,7 @@
   if (CurrentNode != this)
 if (auto *DC = dyn_cast(Current))
   return *DC;
-  return *Current->getDeclContext();
+  return *Current->getLexicalDeclContext();
 }
   }
   llvm_unreachable("A tree must always be rooted at TranslationUnitDecl.");


Index: clang-tools-extra/clangd/unittests/SelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SelectionTests.cpp
@@ -739,6 +739,21 @@
   EXPECT_EQ(1u, Seen) << "one tree for nontrivial selection";
 }
 
+TEST(SelectionTest, DeclContext) {
+  llvm::Annotations Test("namespace a { void $1^foo(); } void a::$2^foo();");
+  auto AST = TestTU::withCode(Test.code()).build();
+  {
+auto ST = SelectionTree::createRight(AST.getASTContext(), AST.getTokens(),
+ Test.point("1"), Test.point("1"));
+EXPECT_FALSE(ST.commonAncestor()->getDeclContext().isTranslationUnit());
+  }
+  {
+auto ST = SelectionTree::createRight(AST.getASTContext(), AST.getTokens(),
+ Test.point("2"), Test.point("2"));
+EXPECT_TRUE(ST.commonAncestor()->getDeclContext().isTranslationUnit());
+  }
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/Selection.cpp
===
--- clang-tools-extra/clangd/Selection.cpp
+++ clang-tools-extra/clangd/Selection.cpp
@@ -897,7 +897,7 @@
   if (CurrentNode != this)
 if (auto *DC = dyn_cast(Current))
   return *DC;
-  return *Current->getDeclContext();
+  return *Current->getLexicalDeclContext();
 }
   }
   llvm_unreachable("A tree must always be rooted at TranslationUnitDecl.");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112712: [clangd] SelectionTree should prefer lexical declcontext

2021-10-28 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 383008.
kadircet edited the summary of this revision.
kadircet added a comment.

- Related https://github.com/clangd/clangd/issues/900.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112712

Files:
  clang-tools-extra/clangd/Selection.cpp
  clang-tools-extra/clangd/unittests/SelectionTests.cpp


Index: clang-tools-extra/clangd/unittests/SelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SelectionTests.cpp
@@ -739,6 +739,21 @@
   EXPECT_EQ(1u, Seen) << "one tree for nontrivial selection";
 }
 
+TEST(SelectionTest, DeclContext) {
+  llvm::Annotations Test("namespace a { void $1^foo(); } void a::$2^foo();");
+  auto AST = TestTU::withCode(Test.code()).build();
+  {
+auto ST = SelectionTree::createRight(AST.getASTContext(), AST.getTokens(),
+ Test.point("1"), Test.point("1"));
+EXPECT_FALSE(ST.commonAncestor()->getDeclContext().isTranslationUnit());
+  }
+  {
+auto ST = SelectionTree::createRight(AST.getASTContext(), AST.getTokens(),
+ Test.point("2"), Test.point("2"));
+EXPECT_TRUE(ST.commonAncestor()->getDeclContext().isTranslationUnit());
+  }
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/Selection.cpp
===
--- clang-tools-extra/clangd/Selection.cpp
+++ clang-tools-extra/clangd/Selection.cpp
@@ -897,7 +897,7 @@
   if (CurrentNode != this)
 if (auto *DC = dyn_cast(Current))
   return *DC;
-  return *Current->getDeclContext();
+  return *Current->getLexicalDeclContext();
 }
   }
   llvm_unreachable("A tree must always be rooted at TranslationUnitDecl.");


Index: clang-tools-extra/clangd/unittests/SelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SelectionTests.cpp
@@ -739,6 +739,21 @@
   EXPECT_EQ(1u, Seen) << "one tree for nontrivial selection";
 }
 
+TEST(SelectionTest, DeclContext) {
+  llvm::Annotations Test("namespace a { void $1^foo(); } void a::$2^foo();");
+  auto AST = TestTU::withCode(Test.code()).build();
+  {
+auto ST = SelectionTree::createRight(AST.getASTContext(), AST.getTokens(),
+ Test.point("1"), Test.point("1"));
+EXPECT_FALSE(ST.commonAncestor()->getDeclContext().isTranslationUnit());
+  }
+  {
+auto ST = SelectionTree::createRight(AST.getASTContext(), AST.getTokens(),
+ Test.point("2"), Test.point("2"));
+EXPECT_TRUE(ST.commonAncestor()->getDeclContext().isTranslationUnit());
+  }
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/Selection.cpp
===
--- clang-tools-extra/clangd/Selection.cpp
+++ clang-tools-extra/clangd/Selection.cpp
@@ -897,7 +897,7 @@
   if (CurrentNode != this)
 if (auto *DC = dyn_cast(Current))
   return *DC;
-  return *Current->getDeclContext();
+  return *Current->getLexicalDeclContext();
 }
   }
   llvm_unreachable("A tree must always be rooted at TranslationUnitDecl.");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108643: Introduce _BitInt, deprecate _ExtInt

2021-10-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.
Herald added a subscriber: asavonic.

Ping.


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

https://reviews.llvm.org/D108643

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


[PATCH] D112059: Fix inline builtin handling in case of redefinition

2021-10-28 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

I second @aaron.ballman there. I compiled the sqlite3.c amalgamation, -O0, with 
both approach, measuring the number of instructions as gathered by `valgrind 
--tool=callgrind`

- when walking redecls:9001630039 instructions, I changed the 
implementation a bit down to 9001628850
- when storing redecl state: 9000816370 instructions


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

https://reviews.llvm.org/D112059

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


Re: [Lldb-commits] [lldb] aee4925 - Recommit: Compress formatting of array type names (int [4] -> int[4])

2021-10-28 Thread Pavel Labath via cfe-commits

On 26/10/2021 23:14, Jim Ingham via lldb-commits wrote:




On Oct 26, 2021, at 12:45 PM, David Blaikie  wrote:

On Tue, Oct 26, 2021 at 12:15 PM Raphael Isemann  wrote:
Not sure how many LLDB users would (or can) write AST matchers though. And
 (lldb) type summary add "foo[4]" ...
is arguably easier on the eyes than
 type summary add
constantArrayType(allOf(hasSize(4),hasDeclaration(namedDecl(hasName("foo")`

Though presumably (& the example I think Jim was giving) more often the desire 
would be to write a matcher for arrays of any dimension, where it's:

"foo[\d+]" or similar (maybe having to escape the "[]"
compared to
arrayType(hasElementType(hasDeclaration(cxxRecordDecl(hasName("foo")
  
Which is, admittedly, still pretty verbose. But more type checked (for better and worse - annoying to get right (took me ages to figure out I needed "hasDeclaration" in there) but more robust once it is right)


(that's my best shot at a good AST matcher, not sure if we could make
this shorter, but that's probably what a user ends up with).

In this case it seems just comparing tokens instead of direct strings
is enough to make most users happy. And it doesn't require building
clang ASTs (which is always expensive).

Yeah, as much as I like the abstract purity of structural comparison, token 
comparison is probably close enough. (guess that has to involve LLDB walking 
through typedefs incrementally, etc - if typedefs can be used in pretty printer 
matching/searching, otherwise got to go strip out all the typedefs (from the 
users regex (if they are allowed there) and from the type of the thing being 
printed) and other sugar before comparison - guess that's done today somewhere)




The formatter matching does use a type hierarchy if it has one.  We walk the 
chain of typedefs looking for a match, first one wins.  We also match down 
class hierarchies, since if you only format the base class fields, it would be 
annoying to have to write a new formatter for each derived class just to get 
the base class fields printed.

We could also invent some mini-language for the type specification, like "char 
[*]" to mean an array of any size.  But I hesitate to introduce non-language 
features in here because then some other language we need to support will use those 
characters making them ambiguous.  And it's better to rely on facts people already know 
to specify this sort of thing, if possible.  But maybe having a slightly smart tokenizer 
and a few conventions for the common cases might make specifying matches less awkward.

But it doesn't require that we know about then names being matched, and will 
fall back now on either plain string matching or regex-es.



I've recently approached this issue from a slightly different angle 
(trying to format sizeless char arrays (char[]), and I've learned a 
couple of things which might be interesting to this discussion:
- besides typedefs, we also strip cv qualifiers (so a formatter for char 
* applies to const char * as well). However, we didn't to this for array 
types (so one had to include char [.*] and const char [.*] separately. 
(D112708 extends this behavior to arrays too)
- our formatters were not handling cv arrays separately, and the reason 
this worked is because they used unachored regexes, so "char [.*]" 
matched the last part of "const volatile char [47]"
- the unachored matching meant that these formatters were getting 
applied to completely unrelated types as well (e.g. MyStruct). 
(D112709 fixes the second two issues)


While I don't think it's realistic to expect that our users will learn 
how clang ast matchers (or any similar language) work, I think all of 
these examples show that the regex approach has a lot of pitfalls as 
well. It might be good to consider switching to a full-match regexes at 
least, as I think the template trick will affect most formatters, and I 
doubt users will remember to surround their expressions with ^$.


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


[PATCH] D111866: [RISCV] Support Zfhmin extension

2021-10-28 Thread Alex Bradbury via Phabricator via cfe-commits
asb added a comment.
Herald added a reviewer: luke957.

From an initial look, I think this is almost ready to land - thank you.

One suggestion would be to review the various `Subtarget.hasStdExtZfhmin() || 
Subtarget.hasStdExtZfh()`. I'd first thought adding a new helper to 
RISCVSubtarget to be called instead, but actually it looks like a number of 
these could be replaced by just hasStdExtZfhmin due to Zfhmin implying Zfh.




Comment at: llvm/lib/Target/RISCV/RISCVInstrInfoZfh.td:187
 }
-} // Predicates = [HasStdExtZfh]
+}
 

Unintended change?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111866

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


[PATCH] D112410: [SPIR-V] Add a tool chain for SPIR-V (incomplete)

2021-10-28 Thread Henry Linjamäki via Phabricator via cfe-commits
linjamaki updated this revision to Diff 383019.
linjamaki added a comment.

Rebase on updated llvm-spirv tool (D112404 ).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112410

Files:
  clang/include/clang/Driver/Tool.h
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Clang.h
  clang/lib/Driver/ToolChains/SPIRV.cpp
  clang/lib/Driver/ToolChains/SPIRV.h
  clang/test/Driver/spirv-toolchain.c

Index: clang/test/Driver/spirv-toolchain.c
===
--- /dev/null
+++ clang/test/Driver/spirv-toolchain.c
@@ -0,0 +1,57 @@
+// Check object emission.
+// RUN: %clang -### -no-canonical-prefixes -target spirv64 -x cl -c %s 2>&1 | FileCheck --check-prefix=SPV64 %s
+// RUN: %clang -### -no-canonical-prefixes -target spirv64 -x ir -c %s 2>&1 | FileCheck --check-prefix=SPV64 %s
+// RUN: %clang -### -no-canonical-prefixes -target spirv64 -x clcpp -c %s 2>&1 | FileCheck --check-prefix=SPV64 %s
+// RUN: %clang -### -no-canonical-prefixes -target spirv64 -x c -c %s 2>&1 | FileCheck --check-prefix=SPV64 %s
+
+// SPV64: clang{{.*}} "-cc1" "-triple" "spirv64"
+// SPV64-SAME: "-o" [[BC:".*bc"]]
+// SPV64: {{".*llvm-spirv.*"}} [[BC]] "-o" {{".*o"}}
+
+// RUN: %clang -### -no-canonical-prefixes -target spirv32 -x cl -c %s 2>&1 | FileCheck --check-prefix=SPV32 %s
+// RUN: %clang -### -no-canonical-prefixes -target spirv32 -x ir -c %s 2>&1 | FileCheck --check-prefix=SPV32 %s
+// RUN: %clang -### -no-canonical-prefixes -target spirv32 -x clcpp -c %s 2>&1 | FileCheck --check-prefix=SPV32 %s
+// RUN: %clang -### -no-canonical-prefixes -target spirv32 -x c -c %s 2>&1 | FileCheck --check-prefix=SPV32 %s
+
+// SPV32: clang{{.*}} "-cc1" "-triple" "spirv32"
+// SPV32-SAME: "-o" [[BC:".*bc"]]
+// SPV32: {{".*llvm-spirv.*"}} [[BC]] "-o" {{".*o"}}
+
+//-
+// Check Assembly emission.
+// RUN: %clang -### -no-canonical-prefixes -target spirv64 -x cl -S %s 2>&1 | FileCheck --check-prefix=SPT64 %s
+// RUN: %clang -### -no-canonical-prefixes -target spirv64 -x ir -S %s 2>&1 | FileCheck --check-prefix=SPT64 %s
+// RUN: %clang -### -no-canonical-prefixes -target spirv64 -x clcpp -c %s 2>&1 | FileCheck --check-prefix=SPV64 %s
+// RUN: %clang -### -no-canonical-prefixes -target spirv64 -x c -S %s 2>&1 | FileCheck --check-prefix=SPT64 %s
+
+// SPT64: clang{{.*}} "-cc1" "-triple" "spirv64"
+// SPT64-SAME: "-o" [[BC:".*bc"]]
+// SPT64: {{".*llvm-spirv.*"}} [[BC]] "-spirv-text" "-o" {{".*s"}}
+
+// RUN: %clang -### -no-canonical-prefixes -target spirv32 -x cl -S %s 2>&1 | FileCheck --check-prefix=SPT32 %s
+// RUN: %clang -### -no-canonical-prefixes -target spirv32 -x ir -S %s 2>&1 | FileCheck --check-prefix=SPT32 %s
+// RUN: %clang -### -no-canonical-prefixes -target spirv32 -x clcpp -c %s 2>&1 | FileCheck --check-prefix=SPV32 %s
+// RUN: %clang -### -no-canonical-prefixes -target spirv32 -x c -S %s 2>&1 | FileCheck --check-prefix=SPT32 %s
+
+// SPT32: clang{{.*}} "-cc1" "-triple" "spirv32"
+// SPT32-SAME: "-o" [[BC:".*bc"]]
+// SPT32: {{".*llvm-spirv.*"}} [[BC]] "-spirv-text" "-o" {{".*s"}}
+
+//-
+// Check assembly input -> object output
+// RUN: %clang -### -no-canonical-prefixes -target spirv64 -x assembler -c %s 2>&1 | FileCheck --check-prefix=ASM %s
+// RUN: %clang -### -no-canonical-prefixes -target spirv32 -x assembler -c %s 2>&1 | FileCheck --check-prefix=ASM %s
+// ASM: {{".*llvm-spirv.*"}} {{".*"}} "-to-binary" "-o" {{".*o"}}
+
+//-
+// Check --save-temps.
+// RUN: %clang -### -no-canonical-prefixes -target spirv64 -x cl -c %s --save-temps 2>&1 | FileCheck --check-prefix=TMP %s
+
+// TMP: clang{{.*}} "-cc1" "-triple" "spirv64"
+// TMP-SAME: "-E"
+// TMP-SAME: "-o" [[I:".*i"]]
+// TMP: clang{{.*}} "-cc1" "-triple" "spirv64"
+// TMP-SAME: "-o" [[BC:".*bc"]]
+// TMP-SAME: [[I]]
+// TMP: {{".*llvm-spirv.*"}} [[BC]] "-spirv-text" "-o" [[S:".*s"]]
+// TMP: {{".*llvm-spirv.*"}} [[S]] "-to-binary" "-o" {{".*o"}}
Index: clang/lib/Driver/ToolChains/SPIRV.h
===
--- clang/lib/Driver/ToolChains/SPIRV.h
+++ clang/lib/Driver/ToolChains/SPIRV.h
@@ -41,6 +41,37 @@
 
 } // namespace SPIRV
 } // namespace tools
+
+namespace toolchains {
+
+class LLVM_LIBRARY_VISIBILITY SPIRVToolChain final : public ToolChain {
+  mutable std::unique_ptr Translator;
+
+public:
+  SPIRVToolChain(const Driver &D, const llvm::Triple &Triple,
+ const llvm::opt::ArgList &Args)
+  : ToolChain(D, Triple, Args) {}
+
+  bool useIntegratedAs() const override { return true; }
+  bool useInte

[PATCH] D111199: [Clang][LLVM][Attr] support btf_type_tag attribute

2021-10-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Attribute bits look good to me, but I'd appreciate if @dblaikie could weigh in 
on whether he thinks the CodeGen changes are fine. My concern there is around 
whether the changes to function signatures to accept a `TypeLoc` are reasonable 
or not.




Comment at: clang/include/clang/Basic/AttrDocs.td:2031
+all targets. It only has effect when ``-g`` is specified on the command line 
and
+may only be specified on a pointer type.
+

This makes it a bit more clear what the current behavior is and that we might 
change that behavior in the future,


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99

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


[PATCH] D111062: [RISCV] Rename some assembler mnemonic and intrinsic functions for RVV 1.0.

2021-10-28 Thread Fraser Cormack via Phabricator via cfe-commits
frasercrmck added inline comments.
Herald added a reviewer: luke957.



Comment at: clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmand.c:97
 
 // CHECK-RV64-LABEL: @test_vmandnot_mm_b8(
+// CHECK-RV64-LABEL: @test_vmandn_mm_b8(

Was this test manually updated? I'm not sure how we could still expect to see 
`test_vmandnot_mm_b8`. Please use `update_cc_test_checks` if you haven't 
already.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111062

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


[PATCH] D112707: [clangd] IncludeCleaner: Be more conservative in marking RecordDecl usage

2021-10-28 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:51
+  Result.insert(Definition ? Definition->getLocation()
+   : RD->getMostRecentDecl()->getLocation());
+  return true;

i think this might turn a direct dependency into a transitive one, e.g. you got 
forward declarations of `struct Foo;` in a.h and b.h, then c.h includes b.h. In 
the main file you might have includes for a.h and c.h. Now the most recent 
redecl happens through c.h hence a.h will be marked as unused, even though it's 
the one header providing the forward decl directly.

what about just rolling with the definition when it's visible and handling the 
forward-decl in main file case inside the `add` ? i suppose that's something 
we'd want for all decls and not just records? it implies passing in main file 
id and a sourcemanager into the crawler, and inside the `add` before going over 
all redecls, we just check if most recent decl falls into the main file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112707

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


[PATCH] D108301: [MSP430][Clang] Update hard-coded MCU data

2021-10-28 Thread Jozef Lawrynowicz via Phabricator via cfe-commits
jozefl added a comment.

Ping.

Thanks,
Jozef


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108301

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


[PATCH] D109174: [MSP430][Clang] Infer CPU type from -mcpu= or -mmcu=

2021-10-28 Thread Jozef Lawrynowicz via Phabricator via cfe-commits
jozefl added a comment.

Ping.

Thanks,
Jozef


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109174

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


[PATCH] D98726: [analyzer] Enabling MallocChecker to take up after SmartPtrModelling

2021-10-28 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

What's the status on this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98726

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


Re: [clang] 2edb89c - Lex arguments for __has_cpp_attribute and friends as expanded tokens

2021-10-28 Thread Nico Weber via cfe-commits
On Mon, Oct 25, 2021 at 9:06 PM Nico Weber  wrote:

> Looks like the reason for this check was that
> https://github.com/llvm/llvm-project/blob/3b42fc8a07c37e47efae80c931eff7e63103e0e9/clang/include/clang/Basic/Attr.td#L1946
> contains __unsafe_unretained despite it just being a macro here:
> http://llvm-cs.pcc.me.uk/tools/clang/lib/Frontend/InitPreprocessor.cpp#1019
>
> Is that Attr.td entry incorrect?
>

Aaron: Ping on ^ :)


>
> On Mon, Oct 25, 2021 at 8:40 PM Nico Weber  wrote:
>
>> Was this reviewed anywhere?
>>
>> I'll note that some internal project apparently used to check `#if
>> __has_attribute(__unsafe_unretained)`. That used to silently (and
>> incorrectly I think) always return 0 as far as I can tell, but now it fails
>> with:
>>
>> ```
>> $ out/gn/bin/clang -c foo.mm
>> foo.mm:1:21: error: missing ')' after '__attribute__'
>> #if __has_attribute(__unsafe_unretained)
>> ^~~
>> :350:42: note: expanded from here
>> #define __unsafe_unretained __attribute__((objc_ownership(none)))
>> ~^
>> foo.mm:1:20: note: to match this '('
>> #if __has_attribute(__unsafe_unretained)
>>^
>> 1 error generated.
>> ```
>>
>> That's arguably a progression and I'm still finding out what the intent
>> there was (maybe `#ifdef __unsafe_unretained`?).
>>
>> So nothing to do here I think, but I thought I'd mention it.
>>
>> On Sun, Oct 17, 2021 at 7:58 AM Aaron Ballman via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>>
>>> Author: Aaron Ballman
>>> Date: 2021-10-17T07:54:48-04:00
>>> New Revision: 2edb89c746848c52964537268bf03e7906bf2542
>>>
>>> URL:
>>> https://github.com/llvm/llvm-project/commit/2edb89c746848c52964537268bf03e7906bf2542
>>> DIFF:
>>> https://github.com/llvm/llvm-project/commit/2edb89c746848c52964537268bf03e7906bf2542.diff
>>>
>>> LOG: Lex arguments for __has_cpp_attribute and friends as expanded tokens
>>>
>>> The C and C++ standards require the argument to __has_cpp_attribute and
>>> __has_c_attribute to be expanded ([cpp.cond]p5). It would make little
>>> sense
>>> to expand the argument to those operators but not expand the argument to
>>> __has_attribute and __has_declspec, so those were both also changed in
>>> this
>>> patch.
>>>
>>> Note that it might make sense for the other builtins to also expand their
>>> argument, but it wasn't as clear to me whether the behavior would be
>>> correct
>>> there, and so they were left for a future revision.
>>>
>>> Added:
>>> clang/test/Preprocessor/has_attribute_errors.cpp
>>>
>>> Modified:
>>> clang/docs/ReleaseNotes.rst
>>> clang/lib/Lex/PPMacroExpansion.cpp
>>> clang/test/Preprocessor/has_attribute.c
>>> clang/test/Preprocessor/has_attribute.cpp
>>> clang/test/Preprocessor/has_c_attribute.c
>>>
>>> Removed:
>>>
>>>
>>>
>>>
>>> 
>>> diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
>>> index 6501a4870e2a6..263eae83036df 100644
>>> --- a/clang/docs/ReleaseNotes.rst
>>> +++ b/clang/docs/ReleaseNotes.rst
>>> @@ -110,6 +110,13 @@ Attribute Changes in Clang
>>>attribute is handled instead, e.g. in ``handleDeclAttribute``.
>>>(This was changed in order to better support attributes in code
>>> completion).
>>>
>>> +- __has_cpp_attribute, __has_c_attribute, __has_attribute, and
>>> __has_declspec
>>> +  will now macro expand their argument. This causes a change in
>>> behavior for
>>> +  code using ``__has_cpp_attribute(__clang__::attr)`` (and same for
>>> +  ``__has_c_attribute``) where it would previously expand to ``0`` for
>>> all
>>> +  attributes, but will now issue an error due to the expansion of the
>>> +  predefined ``__clang__`` macro.
>>> +
>>>  Windows Support
>>>  ---
>>>
>>>
>>> diff  --git a/clang/lib/Lex/PPMacroExpansion.cpp
>>> b/clang/lib/Lex/PPMacroExpansion.cpp
>>> index bf19f538647e6..5a0fa5184e38b 100644
>>> --- a/clang/lib/Lex/PPMacroExpansion.cpp
>>> +++ b/clang/lib/Lex/PPMacroExpansion.cpp
>>> @@ -1293,7 +1293,7 @@ static bool EvaluateHasIncludeNext(Token &Tok,
>>>  /// integer values.
>>>  static void EvaluateFeatureLikeBuiltinMacro(llvm::raw_svector_ostream&
>>> OS,
>>>  Token &Tok, IdentifierInfo
>>> *II,
>>> -Preprocessor &PP,
>>> +Preprocessor &PP, bool
>>> ExpandArgs,
>>>  llvm::function_ref<
>>>int(Token &Tok,
>>>bool
>>> &HasLexedNextTok)> Op) {
>>> @@ -1319,7 +1319,10 @@ static void
>>> EvaluateFeatureLikeBuiltinMacro(llvm::raw_svector_ostream& OS,
>>>bool SuppressDiagnostic = false;
>>>while (true) {
>>>  // Parse next token.
>>> -PP.LexUnexpandedToken(Tok);
>>> +if (ExpandArgs)
>>> + 

[PATCH] D112421: [clang][ARM] PACBTI-M frontend support

2021-10-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:2980
+def warn_unsupported_branch_protection_spec : Warning<
+  "unsupported branch protection specification '%0'">,  
InGroup;
+





Comment at: clang/lib/Basic/Targets/AArch64.cpp:134-135
  StringRef &Err) const {
-  llvm::AArch64::ParsedBranchProtection PBP;
-  if (!llvm::AArch64::parseBranchProtection(Spec, PBP, Err))
+  llvm::ARM::ParsedBranchProtection PBP;
+  if (!llvm::ARM::parseBranchProtection(Spec, PBP, Err))
 return false;

This change surprises me. Why should AArch64TargetInfo prefer calling into ARM 
instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112421

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


[PATCH] D112712: [clangd] SelectionTree should prefer lexical declcontext

2021-10-28 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/Selection.cpp:893
 
 const DeclContext &SelectionTree::Node::getDeclContext() const {
   for (const Node *CurrentNode = this; CurrentNode != nullptr;

Maybe insert the word "lexical" into the doc comment for this function



Comment at: clang-tools-extra/clangd/unittests/SelectionTests.cpp:742
 
+TEST(SelectionTest, DeclContext) {
+  llvm::Annotations Test("namespace a { void $1^foo(); } void a::$2^foo();");

Nit: call the case DeclContextIsLexical to make the point clearer?



Comment at: clang-tools-extra/clangd/unittests/SelectionTests.cpp:751
+  {
+auto ST = SelectionTree::createRight(AST.getASTContext(), AST.getTokens(),
+ Test.point("2"), Test.point("2"));

I'd probably use makeSelectionTree(Test.code(), AST) for brevity and only test 
the #2 case, but up to you


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112712

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


[PATCH] D112718: Add intrinsics and builtins for PTX atomics with semantic orders

2021-10-28 Thread Tadej Ciglarič via Phabricator via cfe-commits
t4c1 created this revision.
t4c1 added reviewers: jholewinski, bader.
Herald added subscribers: asavonic, hiraditya.
t4c1 requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, jdoerfert.
Herald added projects: clang, LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112718

Files:
  clang/include/clang/Basic/BuiltinsNVPTX.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-nvptx.c
  llvm/include/llvm/IR/IntrinsicsNVVM.td
  llvm/lib/Target/NVPTX/NVPTXInstrInfo.td
  llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
  llvm/lib/Target/NVPTX/NVPTXSubtarget.h
  llvm/test/CodeGen/NVPTX/atomics-with-semantics.ll

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


[PATCH] D34654: Allow passing a regex for headers to exclude from clang-tidy

2021-10-28 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added a comment.

> everyone has .* in their config file, which will silently stop to work

Nevermind this. `.*` treated as a glob will turn into the regex `..*` which is 
equivalent.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D34654

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


[PATCH] D111952: [clang] [MinGW] Guess the right ix86 arch name spelling as sysroot

2021-10-28 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added inline comments.



Comment at: clang/lib/Driver/ToolChains/MinGW.h:63
 
+  static void FixTripleArch(const Driver &D, llvm::Triple &Triple,
+const llvm::opt::ArgList &Args);

MaskRay wrote:
> Use `functionName` for newer functions. (It's unfortunate that Clang has much 
> inconsistency but we should do the right thing for new methods.)
Sure, will change it.



Comment at: clang/test/Driver/mingw-sysroot.cpp:49
+
+// RUN: env "PATH=%T/testroot-gcc/bin:%PATH%" 
%T/testroot-clang/bin/x86_64-w64-mingw32-clang -target x86_64-w64-mingw32 -m32 
-rtlib=compiler-rt -stdlib=libstdc++ --sysroot="" -c -### %s 2>&1 | FileCheck 
-check-prefix=CHECK_TESTROOT_CLANG_I686 %s
+// CHECK_TESTROOT_CLANG_I686: 
"{{[^"]+}}/testroot-clang{{/|}}i686-w64-mingw32{{/|}}include"

MaskRay wrote:
> Changing `PATH` seems unreliable for some test environments.
> 
> Any alternative way to test this?
> 
> `--target=` is preferred over `-target ` for driver options. `-target ` is 
> legacy but we probably need to keep indefinitely for its wide usage.
> 
> `linux-cross.cpp` has some nice tests which may inspire this file ? :)
Using `PATH` isn't very nice, no, but it's at least reliable enough to run on 
the current testing setups?

I don't see any good input for testing this in linux-cross.cpp - that file uses 
explicit `--sysroot=` parameters all over the place, while this test file is 
mostly about how to best implicitly deduce the sysroot when one isn't specified.

This file (both the old and the newly added tests) relies on checking what 
directories it finds in `/../`, so it requires 
fake-installing the clang binary by symlinking into a test toolchain tree.

I guess it could be possible to execute that fake-installed clang binary by 
specifying the direct path to it, instead of adding it to `PATH` - but it's an 
important usecase to make sure that it works when the literal path isn't 
spelled out in `argv[0]` too.

I can change to use `--target=` in the added lines, but the rest of the file 
uses the other spelling anyway (and I don't think it's on topic to do such 
rewrites as part of this patch).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111952

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


Re: [clang] 2edb89c - Lex arguments for __has_cpp_attribute and friends as expanded tokens

2021-10-28 Thread Aaron Ballman via cfe-commits
On Thu, Oct 28, 2021 at 9:55 AM Nico Weber  wrote:
>
> On Mon, Oct 25, 2021 at 9:06 PM Nico Weber  wrote:
>>
>> Looks like the reason for this check was that 
>> https://github.com/llvm/llvm-project/blob/3b42fc8a07c37e47efae80c931eff7e63103e0e9/clang/include/clang/Basic/Attr.td#L1946
>>  contains __unsafe_unretained despite it just being a macro here: 
>> http://llvm-cs.pcc.me.uk/tools/clang/lib/Frontend/InitPreprocessor.cpp#1019
>>
>> Is that Attr.td entry incorrect?
>
>
> Aaron: Ping on ^ :)

Oh, perhaps my original reply got dropped somewhere along the way.
Here is what I had written before:

I did some digging:

The attribute was added three years ago in
https://github.com/llvm/llvm-project/commit/e43e2b3667f9bc29c23be5235b53a7d7afcdb181
The empty macro was added six years ago in
https://github.com/llvm/llvm-project/commit/28ea04fc4caa40a04220c61bbcadd9d692aa0c7f
The nonempty macro was added eleven years ago in
https://github.com/llvm/llvm-project/commit/5d36a8cc700ef258df055baf95a248f85f36

I think the entry in Attr.td is correct-ish. It specifies there's an
attribute that's spelled with a keyword spelling, but TokenKinds.def
does not define a keyword for __unsafe_unretained (and keywords
defined in Attr.td are not automagically turned into keywords in
TokenKinds.def); this acts as a way to connect the macro to the
attribute for maintainers. So there is no __unsafe_unretained keyword,
it's actually a macro which is sometimes not defined, sometimes
defined to be empty, and sometimes defined to be another attribute.
The type attribute from Attr.td is still used by the type system and
is added automatically when the lifetime qualifier is OCL_ExplicitNone
(https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaType.cpp#L6706).
However, I say "correct-ish" because I think the keyword spelling used
in Attr.td is incorrect -- ObjCInertUnsafeUnretainedAttr is a
different attribute than the one you get from the expansion of
__unsafe_unretained, so while the attribute and the macro are related,
they're not the same thing. As best I can tell,
ObjCInertUnsafeUnretainedAttr can only ever be created implicitly, so
I think the entry in Attr.td should have its spelling removed and a
comment added that says `// This attribute has no spellings as it is
only ever created implicitly.` as with other implicit-defined
attributes. Richard, do you agree?

All that said, __has_attribute() does not tell you anything about
keyword attributes, only GNU-style attributes. __unsafe_unretained is
not a GNU spelling, so I agree that the construct never returned true
for you before.

~Aaron

>
>>
>>
>> On Mon, Oct 25, 2021 at 8:40 PM Nico Weber  wrote:
>>>
>>> Was this reviewed anywhere?
>>>
>>> I'll note that some internal project apparently used to check `#if 
>>> __has_attribute(__unsafe_unretained)`. That used to silently (and 
>>> incorrectly I think) always return 0 as far as I can tell, but now it fails 
>>> with:
>>>
>>> ```
>>> $ out/gn/bin/clang -c foo.mm
>>> foo.mm:1:21: error: missing ')' after '__attribute__'
>>> #if __has_attribute(__unsafe_unretained)
>>> ^~~
>>> :350:42: note: expanded from here
>>> #define __unsafe_unretained __attribute__((objc_ownership(none)))
>>> ~^
>>> foo.mm:1:20: note: to match this '('
>>> #if __has_attribute(__unsafe_unretained)
>>>^
>>> 1 error generated.
>>> ```
>>>
>>> That's arguably a progression and I'm still finding out what the intent 
>>> there was (maybe `#ifdef __unsafe_unretained`?).
>>>
>>> So nothing to do here I think, but I thought I'd mention it.
>>>
>>> On Sun, Oct 17, 2021 at 7:58 AM Aaron Ballman via cfe-commits 
>>>  wrote:


 Author: Aaron Ballman
 Date: 2021-10-17T07:54:48-04:00
 New Revision: 2edb89c746848c52964537268bf03e7906bf2542

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

 LOG: Lex arguments for __has_cpp_attribute and friends as expanded tokens

 The C and C++ standards require the argument to __has_cpp_attribute and
 __has_c_attribute to be expanded ([cpp.cond]p5). It would make little sense
 to expand the argument to those operators but not expand the argument to
 __has_attribute and __has_declspec, so those were both also changed in this
 patch.

 Note that it might make sense for the other builtins to also expand their
 argument, but it wasn't as clear to me whether the behavior would be 
 correct
 there, and so they were left for a future revision.

 Added:
 clang/test/Preprocessor/has_attribute_errors.cpp

 Modified:
 clang/docs/ReleaseNotes.rst
 clang/lib/Lex/PPMacroExpansion.cpp
 clang/test/Preprocessor/has_attribute.c
 clang/test/Preprocessor/has_attribut

[PATCH] D112420: [clang][ARM] PACBTI-M assembly support

2021-10-28 Thread Victor Campos via Phabricator via cfe-commits
vhscampos added inline comments.



Comment at: llvm/lib/Target/ARM/ARMInstrThumb2.td:4083
 def : t2InstAlias<"csdb$p",   (t2HINT 20, pred:$p), 1>;
+def : t2InstAlias<"pacbti$p r12,lr,sp", (t2HINT 13, pred:$p), 1>;
+def : t2InstAlias<"bti$p", (t2HINT 15, pred:$p), 1>;

ostannard wrote:
> Why are these needed in addition to the PACBTIHintSpaceInst instructions 
> below?
Since these instructions are in the HINT space, without specifying inst 
aliases, they were printed in the HINT form when using llvm-mc instead of in 
their PACBTI form. Therefore I added these t2InstAlias instances.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112420

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


[PATCH] D112534: [PoC][RISCV] Use an attribute to declare C intrinsics with different policy.

2021-10-28 Thread Luke via Phabricator via cfe-commits
luke957 resigned from this revision.
luke957 added a comment.

So sorry for my bad herald script.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112534

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


[PATCH] D111062: [RISCV] Rename some assembler mnemonic and intrinsic functions for RVV 1.0.

2021-10-28 Thread Luke via Phabricator via cfe-commits
luke957 resigned from this revision.
luke957 added a comment.

So sorry for my bad herald script.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111062

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


[PATCH] D112642: [clang][NFC] Inclusive terms: Replace uses of whitelist in clang/lib/StaticAnalyzer

2021-10-28 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.

Thank you for this! Mostly just bikeshedding on names (allowlist as a verb 
sounds weird to me), feel free to take or leave the suggestions. LG aside from 
the formatting nits.




Comment at: clang/lib/StaticAnalyzer/Checkers/EnumCastOutOfRangeChecker.cpp:97
   // all other cast kinds (where enum range checks are unnecessary or invalid),
-  // just return immediately.  TODO: The set of casts whitelisted for enum
+  // just return immediately.  TODO: The set of casts allowlisted for enum
   // range checking may be incomplete.  Better to add a missing cast kind to





Comment at: 
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp:1191-1199
+  llvm::SmallPtrSet AllowlistedSymbols;
 
   for (const MemRegion *I : ExplicitRegions)
 if (const SymbolicRegion *SR = I->StripCasts()->getAs())
-  WhitelistedSymbols.insert(SR->getSymbol());
+  AllowlistedSymbols.insert(SR->getSymbol());
 
   for (SymbolRef sym : *invalidated) {





Comment at: clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp:12
 //  range of actions is significantly limited: can't write variables,
-//  can't call functions not in whitelist, etc. For more details, see
+//  can't call functions not in allowed list, etc. For more details, see
 //  http://man7.org/linux/man-pages/man2/vfork.2.html





Comment at: clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp:53
   bool isVforkCall(const Decl *D, CheckerContext &C) const;
-  bool isCallWhitelisted(const IdentifierInfo *II, CheckerContext &C) const;
+  bool isCallAllowlisted(const IdentifierInfo *II, CheckerContext &C) const;
 





Comment at: clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp:96
 // Returns true iff ok to call function after successful vfork.
-bool VforkChecker::isCallWhitelisted(const IdentifierInfo *II,
+bool VforkChecker::isCallAllowlisted(const IdentifierInfo *II,
  CheckerContext &C) const {

Also, should fix the clang-format issue.



Comment at: clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp:182
 
-// Prohibit calls to non-whitelist functions in child process.
+// Prohibit calls to non-allowlisted functions in child process.
 void VforkChecker::checkPreCall(const CallEvent &Call,





Comment at: clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp:187
   if (isChildProcess(State)
-  && !isCallWhitelisted(Call.getCalleeIdentifier(), C))
+  && !isCallAllowlisted(Call.getCalleeIdentifier(), C))
 reportBug("This function call", C);

Might as well handle this formatting issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112642

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


[PATCH] D112359: [RISCV] Unify depedency check and extension implication parsing logics

2021-10-28 Thread Luke via Phabricator via cfe-commits
luke957 resigned from this revision.
luke957 added a comment.

So sorry for my bad herald script.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112359

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


[PATCH] D112720: [clang-tidy] Use globs in HeaderFilter

2021-10-28 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp created this revision.
carlosgalvezp added a project: clang-tools-extra.
Herald added subscribers: libc-commits, arphaman, zzheng, kbarton, xazax.hun, 
mgorny, nemanjai.
Herald added a project: libc-project.
carlosgalvezp requested review of this revision.
Herald added subscribers: cfe-commits, aheejin.

Instead of regex, to allow for negative globs.

Rename HeaderFilterRegex to HeaderFilter,
to keep it consistent.

Fix existing usage of HeaderFilter in the codebase.

Add unit test excluding one directory.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112720

Files:
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.h
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  clang-tools-extra/test/clang-tidy/checkers/abseil-no-internal-dependencies.cpp
  clang-tools-extra/test/clang-tidy/checkers/abseil-no-namespace.cpp
  
clang-tools-extra/test/clang-tidy/checkers/altera-id-dependent-backward-branch.cpp
  clang-tools-extra/test/clang-tidy/checkers/altera-single-work-item-barrier.cpp
  
clang-tools-extra/test/clang-tidy/checkers/altera-struct-pack-align-no-crash.cpp
  clang-tools-extra/test/clang-tidy/checkers/altera-struct-pack-align.cpp
  clang-tools-extra/test/clang-tidy/checkers/altera-unroll-loops.cpp
  clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-macro-usage.cpp
  clang-tools-extra/test/clang-tidy/checkers/google-namespaces.cpp
  clang-tools-extra/test/clang-tidy/checkers/google-readability-casting.c
  clang-tools-extra/test/clang-tidy/checkers/misc-unused-parameters.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-concat-nested-namespaces.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-pass-by-value-header.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-pass-by-value-multi-fixes.cpp
  
clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-transitive.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-multiple-styles.cpp
  clang-tools-extra/test/clang-tidy/checkers/zircon-temporary-objects.cpp
  
clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/.clang-tidy
  
clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/1/.clang-tidy
  
clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/3/.clang-tidy
  clang-tools-extra/test/clang-tidy/infrastructure/Inputs/overlapping/o.h
  clang-tools-extra/test/clang-tidy/infrastructure/clang-tidy-mac-libcxx.cpp
  
clang-tools-extra/test/clang-tidy/infrastructure/clang-tidy-run-with-database.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
  
clang-tools-extra/test/clang-tidy/infrastructure/expand-modular-headers-ppcallbacks.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/file-filter-symlinks.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/file-filter.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/line-filter.cpp
  
clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-error-within-include.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/overlapping.cpp
  clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
  libc/src/.clang-tidy
  libc/test/src/CMakeLists.txt

Index: libc/test/src/CMakeLists.txt
===
--- libc/test/src/CMakeLists.txt
+++ libc/test/src/CMakeLists.txt
@@ -115,7 +115,7 @@
 COMMAND $ --system-headers
   --checks=-*,llvmlibc-restrict-system-libc-headers
   "--extra-arg=-resource-dir=${COMPILER_RESOURCE_DIR}"
-  --header-filter=.*
+  --header-filter=*
   --warnings-as-errors=llvmlibc-*
   "-config={CheckOptions: [{key: llvmlibc-restrict-system-libc-headers.Includes, value: '-*, linux/*, asm/*.h, asm-generic/*.h'}]}"
   --quiet
Index: libc/src/.clang-tidy
===
--- libc/src/.clang-tidy
+++ libc/src/.clang-tidy
@@ -1,5 +1,5 @@
 Checks: '-*,llvmlibc-*'
-HeaderFilterRegex: '.*'
+HeaderFilter: '*'
 WarningsAsErrors: 'llvmlibc-*'
 CheckOptions:
   - key: llvmlibc-restrict-system-libc-headers.Includes
Index: clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
@@ -76,13 +76,13 @@
 TEST(ParseConfiguration, ValidConfiguration) {
   llvm::ErrorOr Options =
   parseConfiguration(llvm::MemoryBufferRef("Checks: \"-*,misc-*\"\n"
-   "HeaderFilterRegex: \".*\"\n"
+   "HeaderFilter: \"*\"\n"
 

[PATCH] D112720: [clang-tidy] Use globs in HeaderFilter

2021-10-28 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp updated this revision to Diff 383034.
carlosgalvezp added a comment.

Fixed typo.


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

https://reviews.llvm.org/D112720

Files:
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.h
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  clang-tools-extra/test/clang-tidy/checkers/abseil-no-internal-dependencies.cpp
  clang-tools-extra/test/clang-tidy/checkers/abseil-no-namespace.cpp
  
clang-tools-extra/test/clang-tidy/checkers/altera-id-dependent-backward-branch.cpp
  clang-tools-extra/test/clang-tidy/checkers/altera-single-work-item-barrier.cpp
  
clang-tools-extra/test/clang-tidy/checkers/altera-struct-pack-align-no-crash.cpp
  clang-tools-extra/test/clang-tidy/checkers/altera-struct-pack-align.cpp
  clang-tools-extra/test/clang-tidy/checkers/altera-unroll-loops.cpp
  clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-macro-usage.cpp
  clang-tools-extra/test/clang-tidy/checkers/google-namespaces.cpp
  clang-tools-extra/test/clang-tidy/checkers/google-readability-casting.c
  clang-tools-extra/test/clang-tidy/checkers/misc-unused-parameters.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-concat-nested-namespaces.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-pass-by-value-header.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-pass-by-value-multi-fixes.cpp
  
clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-transitive.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-multiple-styles.cpp
  clang-tools-extra/test/clang-tidy/checkers/zircon-temporary-objects.cpp
  
clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/.clang-tidy
  
clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/1/.clang-tidy
  
clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/3/.clang-tidy
  clang-tools-extra/test/clang-tidy/infrastructure/Inputs/overlapping/o.h
  clang-tools-extra/test/clang-tidy/infrastructure/clang-tidy-mac-libcxx.cpp
  
clang-tools-extra/test/clang-tidy/infrastructure/clang-tidy-run-with-database.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
  
clang-tools-extra/test/clang-tidy/infrastructure/expand-modular-headers-ppcallbacks.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/file-filter-symlinks.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/file-filter.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/line-filter.cpp
  
clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-error-within-include.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/overlapping.cpp
  clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
  libc/src/.clang-tidy
  libc/test/src/CMakeLists.txt

Index: libc/test/src/CMakeLists.txt
===
--- libc/test/src/CMakeLists.txt
+++ libc/test/src/CMakeLists.txt
@@ -115,7 +115,7 @@
 COMMAND $ --system-headers
   --checks=-*,llvmlibc-restrict-system-libc-headers
   "--extra-arg=-resource-dir=${COMPILER_RESOURCE_DIR}"
-  --header-filter=.*
+  --header-filter=*
   --warnings-as-errors=llvmlibc-*
   "-config={CheckOptions: [{key: llvmlibc-restrict-system-libc-headers.Includes, value: '-*, linux/*, asm/*.h, asm-generic/*.h'}]}"
   --quiet
Index: libc/src/.clang-tidy
===
--- libc/src/.clang-tidy
+++ libc/src/.clang-tidy
@@ -1,5 +1,5 @@
 Checks: '-*,llvmlibc-*'
-HeaderFilterRegex: '.*'
+HeaderFilter: '*'
 WarningsAsErrors: 'llvmlibc-*'
 CheckOptions:
   - key: llvmlibc-restrict-system-libc-headers.Includes
Index: clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
@@ -76,13 +76,13 @@
 TEST(ParseConfiguration, ValidConfiguration) {
   llvm::ErrorOr Options =
   parseConfiguration(llvm::MemoryBufferRef("Checks: \"-*,misc-*\"\n"
-   "HeaderFilterRegex: \".*\"\n"
+   "HeaderFilter: \"*\"\n"
"AnalyzeTemporaryDtors: true\n"
"User: some.user",
"Options"));
   EXPECT_TRUE(!!Options);
   EXPECT_EQ("-*,misc-*", *Options->Checks);
-  EXPECT_EQ(".*", *Options->HeaderFilterRegex);
+  EXPECT_EQ("*", *Options->HeaderFilter);
   EXPECT_EQ("some.user", *Options-

[PATCH] D34654: Allow passing a regex for headers to exclude from clang-tidy

2021-10-28 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added a comment.

Here's a patch that uses Globs, let me know how you like it!
https://reviews.llvm.org/D112720


Repository:
  rL LLVM

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

https://reviews.llvm.org/D34654

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


[PATCH] D111833: [clang] Fortify warning for scanf calls with field width too big.

2021-10-28 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

This doesn't seem to be working very well:

  thakis@thakis:~/src/llvm-project$ cat test.cc
  #include 
  #include 
  #include 
  
  int main() {
uint16_t hextets[8];
int chars_scanned;
char buf[] = "1234:5678:9abc:def0:1234:5678:9abc:def0";
sscanf(buf,
 "%4" SCNx16 ":%4" SCNx16 ":%4" SCNx16 ":%4" SCNx16 ":%4" SCNx16
 ":%4" SCNx16 ":%4" SCNx16 ":%4" SCNx16 "%n",
 &hextets[0], &hextets[1], &hextets[2], &hextets[3], &hextets[4],
 &hextets[5], &hextets[6], &hextets[7], &chars_scanned);
  
for (int i = 0; i < 8; ++i)
  printf("%x ", hextets[i]);
printf("%d\n", chars_scanned);
  }
  thakis@thakis:~/src/llvm-project$ out/gn/bin/clang test.cc -Wall
  test.cc:9:3: warning: 'sscanf' may overflow; destination buffer in argument 9 
has size 4, but the corresponding field width plus NUL byte is 5 
[-Wfortify-source]
sscanf(buf,
^
  test.cc:9:3: warning: 'sscanf' may overflow; destination buffer in argument 
10 has size 2, but the corresponding field width plus NUL byte is 5 
[-Wfortify-source]
  2 warnings generated.
  thakis@thakis:~/src/llvm-project$ ./a.out 
  1234 5678 9abc def0 1234 5678 9abc def0 39



1. The warning is emitted twice, but doesn't point at code the 2nd time round
2. That code looks correct to me (ie there shouldn't be any warnings), maybe 
`%n` isn't handled correctly?
3. The diag points at the start of the scanf instead of at the faulty arg.

Especially 2 is breaking builds, so I'll revert this for now. Looks like a cool 
warning though, looking forward to the relanding :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111833

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


[clang] bf87294 - Revert "[clang] Fortify warning for scanf calls with field width too big."

2021-10-28 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2021-10-28T10:41:18-04:00
New Revision: bf87294cd4fa5781aa2fc0954e117712befedf87

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

LOG: Revert "[clang] Fortify warning for scanf calls with field width too big."

This reverts commit 15e3d39110fa4449be4f56196af3bc81b623f3ab.
See https://reviews.llvm.org/D111833#3093629

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaChecking.cpp

Removed: 
clang/test/Sema/warn-fortify-scanf.c



diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index f2dd69bbdbbd..7153b9c66563 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -833,10 +833,6 @@ def warn_fortify_source_format_overflow : Warning<
   " but format string expands to at least %2">,
   InGroup;
 
-def warn_fortify_scanf_overflow : Warning<
-  "'%0' may overflow; destination buffer in argument %1 has size "
-  "%2, but the corresponding field width plus NUL byte is %3">,
-  InGroup;
 
 /// main()
 // static main() is not an error in C, just in C++.

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index e11966020ae9..147f50aeed97 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -408,50 +408,6 @@ static bool SemaBuiltinCallWithStaticChain(Sema &S, 
CallExpr *BuiltinCall) {
 
 namespace {
 
-class ScanfDiagnosticFormatHandler
-: public analyze_format_string::FormatStringHandler {
-  // Accepts the argument index (relative to the first destination index) of 
the
-  // argument whose size we want.
-  using ComputeSizeFunction =
-  llvm::function_ref(unsigned)>;
-
-  // Accepts the argument index (relative to the first destination index), the
-  // destination size, and the source size).
-  using DiagnoseFunction =
-  llvm::function_ref;
-
-  ComputeSizeFunction ComputeSizeArgument;
-  DiagnoseFunction Diagnose;
-
-public:
-  ScanfDiagnosticFormatHandler(ComputeSizeFunction ComputeSizeArgument,
-   DiagnoseFunction Diagnose)
-  : ComputeSizeArgument(ComputeSizeArgument), Diagnose(Diagnose) {}
-
-  bool HandleScanfSpecifier(const analyze_scanf::ScanfSpecifier &FS,
-const char *StartSpecifier,
-unsigned specifierLen) override {
-auto OptionalFW = FS.getFieldWidth();
-if (OptionalFW.getHowSpecified() !=
-analyze_format_string::OptionalAmount::HowSpecified::Constant)
-  return true;
-
-// We have to write the data plus a NUL byte.
-unsigned SourceSize = OptionalFW.getConstantAmount() + 1;
-
-auto DestSizeAPS = ComputeSizeArgument(FS.getArgIndex());
-if (!DestSizeAPS)
-  return true;
-
-unsigned DestSize = DestSizeAPS->getZExtValue();
-
-if (DestSize < SourceSize)
-  Diagnose(FS.getArgIndex(), DestSize, SourceSize);
-
-return true;
-  }
-};
-
 class EstimateSizeFormatHandler
 : public analyze_format_string::FormatStringHandler {
   size_t Size;
@@ -659,12 +615,9 @@ void 
Sema::checkFortifiedBuiltinMemoryFunction(FunctionDecl *FD,
 // (potentially) more strict checking mode. Otherwise, conservatively 
assume
 // type 0.
 int BOSType = 0;
-// This check can fail for variadic functions.
-if (Index < FD->getNumParams()) {
-  if (const auto *POS =
-  FD->getParamDecl(Index)->getAttr())
-BOSType = POS->getType();
-}
+if (const auto *POS =
+FD->getParamDecl(Index)->getAttr())
+  BOSType = POS->getType();
 
 const Expr *ObjArg = TheCall->getArg(Index);
 uint64_t Result;
@@ -689,20 +642,6 @@ void 
Sema::checkFortifiedBuiltinMemoryFunction(FunctionDecl *FD,
   unsigned DiagID = 0;
   bool IsChkVariant = false;
 
-  auto GetFunctionName = [&]() {
-StringRef FunctionName = getASTContext().BuiltinInfo.getName(BuiltinID);
-// Skim off the details of whichever builtin was called to produce a better
-// diagnostic, as it's unlikely that the user wrote the __builtin
-// explicitly.
-if (IsChkVariant) {
-  FunctionName = FunctionName.drop_front(std::strlen("__builtin___"));
-  FunctionName = FunctionName.drop_back(std::strlen("_chk"));
-} else if (FunctionName.startswith("__builtin_")) {
-  FunctionName = FunctionName.drop_front(std::strlen("__builtin_"));
-}
-return FunctionName;
-  };
-
   switch (BuiltinID) {
   default:
 return;
@@ -722,61 +661,6 @@ void 
Sema::checkFortifiedBuiltinMemoryFunction(FunctionDecl *FD,
 break;
   }
 
-  case Builtin::BIscanf:
-  case Builtin::BIfscanf:
-  case Builtin::BIsscanf: {
-unsigned FormatIndex = 1;
-unsigned DataInd

[PATCH] D112720: [clang-tidy] Use globs in HeaderFilter

2021-10-28 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Not in favor of general directions like this.
Does it not break the existing uses (existing `.clang-tidy`'s e.g.)


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

https://reviews.llvm.org/D112720

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


[PATCH] D111617: [RISCV] Lazily add RVV C intrinsics.

2021-10-28 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai added a comment.

In D111617#3076994 , @rogfer01 wrote:

> In D111617#3060377 , @HsiangKai 
> wrote:
>
>> Although it reduces the header size, this patch will increase the binary 
>> size of clang.
>
> Options we can consider to mitigate this:
>
> - See if we can be more economical reprenting the table itself

Yes, I agree. This primitive work has lots of space to improve. Most of the C 
intrinsics have the same argument lists. We could encode them in a table and 
reuse the same argument lists. In addition, we could use StringMatcher in the 
TableGen utilities to generate the switch cases to improve the performance. I 
am trying to implement this patch in a better way.

> - Store it in the binary in a format unsuitable for lookups (e.g. compressed) 
> and then transform it (in memory) the first time is used so queries can be 
> solved in a reasonable amount of time.
>
>> Or we should go back to think about the design of RVV intrinsics?
>
> Certainly the explosion of cases is an issue.
>
> Maybe an alternative is using overloaded builtins (similar to what atomic 
> builtins can do when the type is not specified), but I understand this means 
> implementing the typechecking itself. Which perhaps it can be generated too.
>
> This looks like it might bring a lot of reduction in cases and tables. Corner 
> cases will appear when the arguments of a call are not enough to determine 
> the precise intrinsic desired, e.g. loads as they are currently defined would 
> be ambiguous between different LMUL types (though there may be ways to 
> mitigate this, e.g. overload only within LMULs).




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111617

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


[PATCH] D112720: [clang-tidy] Use globs in HeaderFilter

2021-10-28 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp updated this revision to Diff 383036.
carlosgalvezp added a comment.

Fixed formatting of release notes


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

https://reviews.llvm.org/D112720

Files:
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.h
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  clang-tools-extra/test/clang-tidy/checkers/abseil-no-internal-dependencies.cpp
  clang-tools-extra/test/clang-tidy/checkers/abseil-no-namespace.cpp
  
clang-tools-extra/test/clang-tidy/checkers/altera-id-dependent-backward-branch.cpp
  clang-tools-extra/test/clang-tidy/checkers/altera-single-work-item-barrier.cpp
  
clang-tools-extra/test/clang-tidy/checkers/altera-struct-pack-align-no-crash.cpp
  clang-tools-extra/test/clang-tidy/checkers/altera-struct-pack-align.cpp
  clang-tools-extra/test/clang-tidy/checkers/altera-unroll-loops.cpp
  clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-macro-usage.cpp
  clang-tools-extra/test/clang-tidy/checkers/google-namespaces.cpp
  clang-tools-extra/test/clang-tidy/checkers/google-readability-casting.c
  clang-tools-extra/test/clang-tidy/checkers/misc-unused-parameters.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-concat-nested-namespaces.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-pass-by-value-header.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-pass-by-value-multi-fixes.cpp
  
clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-transitive.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-multiple-styles.cpp
  clang-tools-extra/test/clang-tidy/checkers/zircon-temporary-objects.cpp
  
clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/.clang-tidy
  
clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/1/.clang-tidy
  
clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/3/.clang-tidy
  clang-tools-extra/test/clang-tidy/infrastructure/Inputs/overlapping/o.h
  clang-tools-extra/test/clang-tidy/infrastructure/clang-tidy-mac-libcxx.cpp
  
clang-tools-extra/test/clang-tidy/infrastructure/clang-tidy-run-with-database.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
  
clang-tools-extra/test/clang-tidy/infrastructure/expand-modular-headers-ppcallbacks.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/file-filter-symlinks.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/file-filter.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/line-filter.cpp
  
clang-tools-extra/test/clang-tidy/infrastructure/nolintbeginend-error-within-include.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/overlapping.cpp
  clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
  libc/src/.clang-tidy
  libc/test/src/CMakeLists.txt

Index: libc/test/src/CMakeLists.txt
===
--- libc/test/src/CMakeLists.txt
+++ libc/test/src/CMakeLists.txt
@@ -115,7 +115,7 @@
 COMMAND $ --system-headers
   --checks=-*,llvmlibc-restrict-system-libc-headers
   "--extra-arg=-resource-dir=${COMPILER_RESOURCE_DIR}"
-  --header-filter=.*
+  --header-filter=*
   --warnings-as-errors=llvmlibc-*
   "-config={CheckOptions: [{key: llvmlibc-restrict-system-libc-headers.Includes, value: '-*, linux/*, asm/*.h, asm-generic/*.h'}]}"
   --quiet
Index: libc/src/.clang-tidy
===
--- libc/src/.clang-tidy
+++ libc/src/.clang-tidy
@@ -1,5 +1,5 @@
 Checks: '-*,llvmlibc-*'
-HeaderFilterRegex: '.*'
+HeaderFilter: '*'
 WarningsAsErrors: 'llvmlibc-*'
 CheckOptions:
   - key: llvmlibc-restrict-system-libc-headers.Includes
Index: clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
@@ -76,13 +76,13 @@
 TEST(ParseConfiguration, ValidConfiguration) {
   llvm::ErrorOr Options =
   parseConfiguration(llvm::MemoryBufferRef("Checks: \"-*,misc-*\"\n"
-   "HeaderFilterRegex: \".*\"\n"
+   "HeaderFilter: \"*\"\n"
"AnalyzeTemporaryDtors: true\n"
"User: some.user",
"Options"));
   EXPECT_TRUE(!!Options);
   EXPECT_EQ("-*,misc-*", *Options->Checks);
-  EXPECT_EQ(".*", *Options->HeaderFilterRegex);
+  EXPECT_EQ("*", *Options->HeaderFilter);
   EXPECT_EQ(

[PATCH] D112720: [clang-tidy] Use globs in HeaderFilter

2021-10-28 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added a comment.

In D112720#3093636 , @lebedev.ri 
wrote:

> Not in favor of general directions like this.
> Does it not break the existing uses (existing `.clang-tidy`'s e.g.)

Yep, it's a breaking change. The purpose of this patch is mostly to show how it 
would look like and see if that would be the desired result. There's 2 aspects 
of it:

- Rename of `HeaderFilterRegex` to `HeaderFilter`, to be consistent with 
`--header-filter`. If this is too much breakage, I'm OK with reverting.
- Replace regex with globs. Won't break the use of `.*`. It will break for the 
use case of having a parent `.clang-tidy` with `.*` and a child `.clang-tidy` 
with `my_folder/*\.h`. I personally always found the current interface 
confusing as a user. What regex should I write? Should I consider full paths, 
relative paths, does it matter?

I suppose I can keep the exact same behavior as master, but that will add 
additional tweaks and complexity to the `GlobList` class.


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

https://reviews.llvm.org/D112720

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


[PATCH] D112722: [clang-tidy]performance-unnecessary-copy-initialization: fix false negative

2021-10-28 Thread Clement Courbet via Phabricator via cfe-commits
courbet created this revision.
courbet added reviewers: flx, ymandel, aaron.ballman.
Herald added subscribers: carlosgalvezp, xazax.hun.
courbet requested review of this revision.
Herald added a project: clang-tools-extra.

We're missing all cases where the return value is a type alias.

Unfortunately, this includes things we care about, such as
`std::vector::operator[]` (return value is `const_reference`,
not `const T&`).

Match the canonical type instead.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112722

Files:
  clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
  
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
@@ -12,6 +12,8 @@
   ExpensiveToCopyType();
   virtual ~ExpensiveToCopyType();
   const ExpensiveToCopyType &reference() const;
+  using ConstRef = const ExpensiveToCopyType &;
+  ConstRef referenceWithAlias() const;
   const ExpensiveToCopyType *pointer() const;
   Iterator begin() const;
   Iterator end() const;
@@ -206,6 +208,15 @@
   }
 }
 
+void positiveNonConstVarInCodeBlockWithAlias(const ExpensiveToCopyType &Obj) {
+  {
+const ExpensiveToCopyType Assigned = Obj.referenceWithAlias();
+// CHECK-MESSAGES: [[@LINE-1]]:31: warning: the const qualified variable
+// CHECK-FIXES: const ExpensiveToCopyType& Assigned = 
Obj.referenceWithAlias();
+useAsConstReference(Assigned);
+  }
+}
+
 void negativeNonConstVarWithNonConstUse(const ExpensiveToCopyType &Obj) {
   {
 auto NonConstInvoked = Obj.reference();
Index: 
clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
===
--- clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
+++ clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
@@ -84,7 +84,8 @@
   // returned either points to a global static variable or to a member of the
   // called object.
   return cxxMemberCallExpr(
-  callee(cxxMethodDecl(returns(matchers::isReferenceToConst()))
+  callee(cxxMethodDecl(
+ returns(hasCanonicalType(matchers::isReferenceToConst(
  .bind(MethodDeclId)),
   on(declRefExpr(to(
   varDecl(
@@ -97,7 +98,8 @@
   // Only allow initialization of a const reference from a free function if it
   // has no arguments. Otherwise it could return an alias to one of its
   // arguments and the arguments need to be checked for const use as well.
-  return callExpr(callee(functionDecl(returns(matchers::isReferenceToConst()))
+  return callExpr(callee(functionDecl(returns(hasCanonicalType(
+  matchers::isReferenceToConst(
  .bind(FunctionDeclId)),
   argumentCountIs(0), unless(callee(cxxMethodDecl(
   .bind(InitFunctionCallId);


Index: clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp
@@ -12,6 +12,8 @@
   ExpensiveToCopyType();
   virtual ~ExpensiveToCopyType();
   const ExpensiveToCopyType &reference() const;
+  using ConstRef = const ExpensiveToCopyType &;
+  ConstRef referenceWithAlias() const;
   const ExpensiveToCopyType *pointer() const;
   Iterator begin() const;
   Iterator end() const;
@@ -206,6 +208,15 @@
   }
 }
 
+void positiveNonConstVarInCodeBlockWithAlias(const ExpensiveToCopyType &Obj) {
+  {
+const ExpensiveToCopyType Assigned = Obj.referenceWithAlias();
+// CHECK-MESSAGES: [[@LINE-1]]:31: warning: the const qualified variable
+// CHECK-FIXES: const ExpensiveToCopyType& Assigned = Obj.referenceWithAlias();
+useAsConstReference(Assigned);
+  }
+}
+
 void negativeNonConstVarWithNonConstUse(const ExpensiveToCopyType &Obj) {
   {
 auto NonConstInvoked = Obj.reference();
Index: clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
===
--- clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
+++ clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
@@ -84,7 +84,8 @@
   // returned either points to a global static variable or to a member of the
   // called object.
   return cxxMemberCallExpr(
-  callee(cxxMethodDecl(returns(matchers::isReferenceToConst()))
+  callee(cxxMethodDec

[PATCH] D112720: [clang-tidy] Use globs in HeaderFilter

2021-10-28 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added a comment.

Just to clarify, this patch is the solution proposed by @alexfh here: 
https://reviews.llvm.org/D34654#3022728


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

https://reviews.llvm.org/D112720

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


[PATCH] D112722: [clang-tidy]performance-unnecessary-copy-initialization: fix false negative

2021-10-28 Thread Felix Berger via Phabricator via cfe-commits
flx accepted this revision.
flx added a comment.
This revision is now accepted and ready to land.

Thanks for the fix!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112722

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


[PATCH] D111866: [RISCV] Support Zfhmin extension

2021-10-28 Thread Shao-Ce SUN via Phabricator via cfe-commits
achieveartificialintelligence updated this revision to Diff 383040.
achieveartificialintelligence added a comment.

Address @asb 's comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111866

Files:
  clang/test/Driver/riscv-arch.c
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfoZfh.td
  llvm/lib/Target/RISCV/RISCVSubtarget.h
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/rv32zfhmin-invalid.s
  llvm/test/MC/RISCV/rv32zfhmin-valid.s

Index: llvm/test/MC/RISCV/rv32zfhmin-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv32zfhmin-valid.s
@@ -0,0 +1,62 @@
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zfhmin,+d -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zfhmin,+d -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+experimental-zfhmin,+d < %s \
+# RUN: | llvm-objdump --mattr=+experimental-zfhmin,+d -M no-aliases -d -r - \
+# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+experimental-zfhmin,+d < %s \
+# RUN: | llvm-objdump --mattr=+experimental-zfhmin,+d -M no-aliases -d -r - \
+# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
+
+# CHECK-ASM-AND-OBJ: flh ft0, 12(a0)
+# CHECK-ASM: encoding: [0x07,0x10,0xc5,0x00]
+flh f0, 12(a0)
+# CHECK-ASM-AND-OBJ: flh ft1, 4(ra)
+# CHECK-ASM: encoding: [0x87,0x90,0x40,0x00]
+flh f1, +4(ra)
+# CHECK-ASM-AND-OBJ: flh ft2, -2048(a3)
+# CHECK-ASM: encoding: [0x07,0x91,0x06,0x80]
+flh f2, -2048(x13)
+# CHECK-ASM-AND-OBJ: flh ft3, -2048(s1)
+# CHECK-ASM: encoding: [0x87,0x91,0x04,0x80]
+flh f3, %lo(2048)(s1)
+# CHECK-ASM-AND-OBJ: flh ft4, 2047(s2)
+# CHECK-ASM: encoding: [0x07,0x12,0xf9,0x7f]
+flh f4, 2047(s2)
+# CHECK-ASM-AND-OBJ: flh ft5, 0(s3)
+# CHECK-ASM: encoding: [0x87,0x92,0x09,0x00]
+flh f5, 0(s3)
+
+# CHECK-ASM-AND-OBJ: fsh ft6, 2047(s4)
+# CHECK-ASM: encoding: [0xa7,0x1f,0x6a,0x7e]
+fsh f6, 2047(s4)
+# CHECK-ASM-AND-OBJ: fsh ft7, -2048(s5)
+# CHECK-ASM: encoding: [0x27,0x90,0x7a,0x80]
+fsh f7, -2048(s5)
+# CHECK-ASM-AND-OBJ: fsh fs0, -2048(s6)
+# CHECK-ASM: encoding: [0x27,0x10,0x8b,0x80]
+fsh f8, %lo(2048)(s6)
+# CHECK-ASM-AND-OBJ: fsh fs1, 999(s7)
+# CHECK-ASM: encoding: [0xa7,0x93,0x9b,0x3e]
+fsh f9, 999(s7)
+
+# CHECK-ASM-AND-OBJ: fmv.x.h a2, fs7
+# CHECK-ASM: encoding: [0x53,0x86,0x0b,0xe4]
+fmv.x.h a2, fs7
+# CHECK-ASM-AND-OBJ: fmv.h.x ft1, a6
+# CHECK-ASM: encoding: [0xd3,0x00,0x08,0xf4]
+fmv.h.x ft1, a6
+
+# CHECK-ASM-AND-OBJ: fcvt.s.h fa0, ft0
+# CHECK-ASM: encoding: [0x53,0x05,0x20,0x40]
+fcvt.s.h fa0, ft0
+# CHECK-ASM-AND-OBJ: fcvt.h.s ft2, fa2
+# CHECK-ASM: encoding: [0x53,0x71,0x06,0x44]
+fcvt.h.s ft2, fa2
+# CHECK-ASM-AND-OBJ: fcvt.d.h fa0, ft0
+# CHECK-ASM: encoding: [0x53,0x05,0x20,0x42]
+fcvt.d.h fa0, ft0
+# CHECK-ASM-AND-OBJ: fcvt.h.d ft2, fa2
+# CHECK-ASM: encoding: [0x53,0x71,0x16,0x44]
+fcvt.h.d ft2, fa2
Index: llvm/test/MC/RISCV/rv32zfhmin-invalid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv32zfhmin-invalid.s
@@ -0,0 +1,23 @@
+# RUN: not llvm-mc -triple riscv32 -mattr=+experimental-zfhmin < %s 2>&1 | \
+# RUN:   FileCheck %s
+
+# Out of range immediates
+## simm12
+flh ft1, -2049(a0) # CHECK: :[[@LINE]]:10: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047]
+fsh ft2, 2048(a1) # CHECK: :[[@LINE]]:10: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047]
+
+# Memory operand not formatted correctly
+flh ft1, a0, -200 # CHECK: :[[@LINE]]:14: error: invalid operand for instruction
+
+# Invalid register names
+flh ft15, 100(a0) # CHECK: :[[@LINE]]:5: error: invalid operand for instruction
+flh ft1, 100(a10) # CHECK: :[[@LINE]]:14: error: expected register
+
+# Integer registers where FP regs are expected
+fmv.x.h fs7, a2 # CHECK: :[[@LINE]]:9: error: invalid operand for instruction
+
+# FP registers where integer regs are expected
+fmv.h.x a8, ft2 # CHECK: :[[@LINE]]:9: error: invalid operand for instruction
+
+# Zfh instructions
+fmadd.h f10, f11, f12, f13, dyn # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'Zfh' (Half-Precision Floating-Point)
Index: llvm/test/MC/RISCV/attribute-arch.s
===
--- llvm/test/MC/RISCV/attribute-arch.s
+++ llvm/test/MC/RISCV/attribute-arch.s
@@ -66,8 +66,11 @@
 .attribute arch, "rv32izbt"
 # CHECK: attribute  5, "rv32i2p0_zbt0p93"
 
+.attribute a

[PATCH] D112421: [clang][ARM] PACBTI-M frontend support

2021-10-28 Thread Victor Campos via Phabricator via cfe-commits
vhscampos added inline comments.



Comment at: clang/lib/Basic/Targets/AArch64.cpp:134-135
  StringRef &Err) const {
-  llvm::AArch64::ParsedBranchProtection PBP;
-  if (!llvm::AArch64::parseBranchProtection(Spec, PBP, Err))
+  llvm::ARM::ParsedBranchProtection PBP;
+  if (!llvm::ARM::parseBranchProtection(Spec, PBP, Err))
 return false;

aaron.ballman wrote:
> This change surprises me. Why should AArch64TargetInfo prefer calling into 
> ARM instead?
Since that particular function ended up identical in both ARM and AArch64, we 
removed the AArch64 specific function and kept only one under ARM. You can spot 
the removal further down the patch.

The ARM namespace under ARMTargetParser.h already had code used in 
AArch64TargetParser, so we did not introduce new cross dependencies.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112421

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


[PATCH] D112091: libfuzzer: All building libfuzzer for ARM32

2021-10-28 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

@kcc do you have any concerns?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112091

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


[clang] 6f9c251 - [OpenMP] Initial parsing/sema for the 'omp loop' construct

2021-10-28 Thread Mike Rice via cfe-commits

Author: Mike Rice
Date: 2021-10-28T08:26:43-07:00
New Revision: 6f9c25167d16acff3ff8e4f54a8c14a2a175fc59

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

LOG: [OpenMP] Initial parsing/sema for the 'omp loop' construct

Adds basic parsing/sema/serialization support for the #pragma omp loop
directive.

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

Added: 
clang/test/OpenMP/generic_loop_ast_print.cpp
clang/test/OpenMP/generic_loop_messages.cpp

Modified: 
clang/include/clang-c/Index.h
clang/include/clang/AST/RecursiveASTVisitor.h
clang/include/clang/AST/StmtOpenMP.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/OpenMPKinds.h
clang/include/clang/Basic/StmtNodes.td
clang/include/clang/Sema/Sema.h
clang/include/clang/Serialization/ASTBitCodes.h
clang/lib/AST/StmtOpenMP.cpp
clang/lib/AST/StmtPrinter.cpp
clang/lib/AST/StmtProfile.cpp
clang/lib/Basic/OpenMPKinds.cpp
clang/lib/CodeGen/CGStmt.cpp
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Sema/SemaExceptionSpec.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReaderStmt.cpp
clang/lib/Serialization/ASTWriterStmt.cpp
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
clang/tools/libclang/CIndex.cpp
clang/tools/libclang/CXCursor.cpp
llvm/include/llvm/Frontend/OpenMP/OMP.td

Removed: 




diff  --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h
index b49acf6b58543..b0d7ef509c26f 100644
--- a/clang/include/clang-c/Index.h
+++ b/clang/include/clang-c/Index.h
@@ -2596,7 +2596,11 @@ enum CXCursorKind {
*/
   CXCursor_OMPMetaDirective = 294,
 
-  CXCursor_LastStmt = CXCursor_OMPMetaDirective,
+  /** OpenMP loop directive.
+   */
+  CXCursor_OMPGenericLoopDirective = 295,
+
+  CXCursor_LastStmt = CXCursor_OMPGenericLoopDirective,
 
   /**
* Cursor that represents the translation unit itself.

diff  --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index f200cd3920e67..74c49546c00bc 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -3023,6 +3023,9 @@ DEF_TRAVERSE_STMT(OMPDispatchDirective,
 DEF_TRAVERSE_STMT(OMPMaskedDirective,
   { TRY_TO(TraverseOMPExecutableDirective(S)); })
 
+DEF_TRAVERSE_STMT(OMPGenericLoopDirective,
+  { TRY_TO(TraverseOMPExecutableDirective(S)); })
+
 // OpenMP clauses.
 template 
 bool RecursiveASTVisitor::TraverseOMPClause(OMPClause *C) {

diff  --git a/clang/include/clang/AST/StmtOpenMP.h 
b/clang/include/clang/AST/StmtOpenMP.h
index 60d47b93ba79f..48b2dce152a64 100644
--- a/clang/include/clang/AST/StmtOpenMP.h
+++ b/clang/include/clang/AST/StmtOpenMP.h
@@ -1144,7 +1144,7 @@ class OMPLoopDirective : public OMPLoopBasedDirective {
 if (isOpenMPLoopBoundSharingDirective(Kind))
   return CombinedDistributeEnd;
 if (isOpenMPWorksharingDirective(Kind) || isOpenMPTaskLoopDirective(Kind) 
||
-isOpenMPDistributeDirective(Kind))
+isOpenMPGenericLoopDirective(Kind) || 
isOpenMPDistributeDirective(Kind))
   return WorksharingEnd;
 return DefaultEnd;
   }
@@ -1176,6 +1176,7 @@ class OMPLoopDirective : public OMPLoopBasedDirective {
   }
   void setIsLastIterVariable(Expr *IL) {
 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
+isOpenMPGenericLoopDirective(getDirectiveKind()) ||
 isOpenMPTaskLoopDirective(getDirectiveKind()) ||
 isOpenMPDistributeDirective(getDirectiveKind())) &&
"expected worksharing loop directive");
@@ -1183,6 +1184,7 @@ class OMPLoopDirective : public OMPLoopBasedDirective {
   }
   void setLowerBoundVariable(Expr *LB) {
 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
+isOpenMPGenericLoopDirective(getDirectiveKind()) ||
 isOpenMPTaskLoopDirective(getDirectiveKind()) ||
 isOpenMPDistributeDirective(getDirectiveKind())) &&
"expected worksharing loop directive");
@@ -1190,6 +1192,7 @@ class OMPLoopDirective : public OMPLoopBasedDirective {
   }
   void setUpperBoundVariable(Expr *UB) {
 assert((isOpenMPWorksharingDirective(getDirectiveKind()) ||
+isOpenMPGenericLoopDirective(getDirectiveKind()) ||
 isOpenMPTaskLoopDirective(getDirectiveKind()) ||
 isOpenMPDistributeDirective(getDirectiveKind())) &&
"expected worksharing loop directive");
@@ -1197,6 +1200,7 @@ class OMPLoopDirective : public OMPLoopBasedDirective {
   }
   void setStrideVariable(Expr *ST) {
 assert((isOpenMPWorksharing

  1   2   3   >