[PATCH] D120258: [clangd] Add inlay hints for auto-typed parameters with one instantiation.

2022-02-22 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

Thanks, this is a nice extension of D119537 .

I don't have a good sense for how common the "multiple instantiations, same 
type" scenario is; perhaps @Trass3r has an opinion on that.




Comment at: clang-tools-extra/clangd/AST.cpp:572
+#define TEMPLATE_TYPE(SomeTemplateDecl)
\
+  if (auto *STD = llvm::dyn_cast(TD)) {  
\
+for (auto *Spec : STD->specializations()) {
\

Is it possible to extract this into a helper function template?

I'm not a huge fan of using macros like this, as the macro definition is harder 
to read (e.g. its tokens don't get semantic highlighting) and edit (e.g. 
completion).



Comment at: clang-tools-extra/clangd/AST.h:136
+// FIXME: handle more type patterns.
+llvm::Optional getContainedAutoParamType(TypeLoc TL);
+

Why `Optional` if `TypeLoc` can represent a null type loc?



Comment at: clang-tools-extra/clangd/unittests/ASTTests.cpp:303
+auto AST = TU.build();
+AST.getASTContext().getTranslationUnitDecl()->dump();
+PrintingPolicy PP = AST.getASTContext().getPrintingPolicy();

leftover or deliberate?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120258

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


[PATCH] D120251: [clang][driver][wasm] Fix libstdc++ target-dependent include dir

2022-02-22 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

@sbc100 Do you think we should add `/backward` as well? `Gnu.cpp` does that it 
seems: 
https://github.com/llvm/llvm-project/blob/main/clang/lib/Driver/ToolChains/Gnu.cpp#L2959-L2960


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120251

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


[PATCH] D120305: [Driver] Default CLANG_DEFAULT_PIE_ON_LINUX to ON

2022-02-22 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: foutrelis, sylvestre.ledru, thesamesam, tstellar.
Herald added a subscriber: mgorny.
MaskRay requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Default the option introduced in D113372  to 
ON to match all(?) major Linux
distros. This improves behavior consistency with GCC.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120305

Files:
  clang/CMakeLists.txt
  clang/docs/ReleaseNotes.rst
  clang/test/Driver/hexagon-toolchain-elf.c
  llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn
  utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h


Index: utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h
===
--- utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h
+++ utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h
@@ -23,7 +23,7 @@
 #define BUG_REPORT_URL "https://github.com/llvm/llvm-project/issues/";
 
 /* Default to -fPIE and -pie on Linux. */
-#define CLANG_DEFAULT_PIE_ON_LINUX 0
+#define CLANG_DEFAULT_PIE_ON_LINUX 1
 
 /* Default linker to use. */
 #define CLANG_DEFAULT_LINKER ""
Index: llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn
+++ llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn
@@ -9,7 +9,7 @@
   output = "$target_gen_dir/config.h"
   values = [
 "BUG_REPORT_URL=https://github.com/llvm/llvm-project/issues/";,
-"CLANG_DEFAULT_PIE_ON_LINUX=",
+"CLANG_DEFAULT_PIE_ON_LINUX=1",
 "CLANG_DEFAULT_LINKER=",
 "CLANG_DEFAULT_STD_C=",
 "CLANG_DEFAULT_STD_CXX=",
Index: clang/test/Driver/hexagon-toolchain-elf.c
===
--- clang/test/Driver/hexagon-toolchain-elf.c
+++ clang/test/Driver/hexagon-toolchain-elf.c
@@ -1,3 +1,4 @@
+// UNSUPPORTED: default-pie-on-linux
 // 
-
 // Test standard include paths
 // 
-
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -174,6 +174,9 @@
 Build System Changes
 
 
+* CMake ``-DCLANG_DEFAULT_PIE_ON_LINUX=ON`` is now the default.
+  This matches GCC installations on many Linux distros.
+
 AST Matchers
 
 
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -245,7 +245,7 @@
 set(CLANG_SPAWN_CC1 OFF CACHE BOOL
 "Whether clang should use a new process for the CC1 invocation")
 
-option(CLANG_DEFAULT_PIE_ON_LINUX "Default to -fPIE and -pie on Linux" OFF)
+option(CLANG_DEFAULT_PIE_ON_LINUX "Default to -fPIE and -pie on Linux" ON)
 
 # TODO: verify the values against LangStandards.def?
 set(CLANG_DEFAULT_STD_C "" CACHE STRING


Index: utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h
===
--- utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h
+++ utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h
@@ -23,7 +23,7 @@
 #define BUG_REPORT_URL "https://github.com/llvm/llvm-project/issues/";
 
 /* Default to -fPIE and -pie on Linux. */
-#define CLANG_DEFAULT_PIE_ON_LINUX 0
+#define CLANG_DEFAULT_PIE_ON_LINUX 1
 
 /* Default linker to use. */
 #define CLANG_DEFAULT_LINKER ""
Index: llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn
+++ llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn
@@ -9,7 +9,7 @@
   output = "$target_gen_dir/config.h"
   values = [
 "BUG_REPORT_URL=https://github.com/llvm/llvm-project/issues/";,
-"CLANG_DEFAULT_PIE_ON_LINUX=",
+"CLANG_DEFAULT_PIE_ON_LINUX=1",
 "CLANG_DEFAULT_LINKER=",
 "CLANG_DEFAULT_STD_C=",
 "CLANG_DEFAULT_STD_CXX=",
Index: clang/test/Driver/hexagon-toolchain-elf.c
===
--- clang/test/Driver/hexagon-toolchain-elf.c
+++ clang/test/Driver/hexagon-toolchain-elf.c
@@ -1,3 +1,4 @@
+// UNSUPPORTED: default-pie-on-linux
 // -
 // Test standard include paths
 // -
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/Rel

[PATCH] D88425: Skip -fPIE for AMDGPU and HIP toolchain

2022-02-22 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

I plan to default CMake `CLANG_DEFAULT_PIE_ON_LINUX` to on in D120305 
 and hip-fpie-option.hip will fail. Do you 
mind investigating the issue?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88425

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


[PATCH] D77440: [Hexagon] Update include paths for linux/musl

2022-02-22 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

I plan to default CMake `CLANG_DEFAULT_PIE_ON_LINUX` to on in D120305 
 and `hexagon-toolchain-linux.c` will fail. 
Do you mind investigating the issue?

Also, see D119309  for tips improving driver 
tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77440

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


[PATCH] D97625: fix check-clang-tools tests that fail due to Windows CRLF line endings

2022-02-22 Thread Dave Green via Phabricator via cfe-commits
dmgreen added a comment.

Hello. I noticed this was applied to the base /test directory in the llvm repo: 
https://github.com/llvm/llvm-project/tree/main/test
Was it intended be in clang-tools-extra: 
https://github.com/llvm/llvm-project/tree/main/clang-tools-extra/test? I'm not 
sure it will do much where it is.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97625

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


[PATCH] D120305: [Driver] Default CLANG_DEFAULT_PIE_ON_LINUX to ON

2022-02-22 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a subscriber: atanasyan.
MaskRay added a comment.

@atanasyan A few mips test/Driver tests will fail. Wonder if you have time 
making them more portable... Otherwise I'll just add `UNSUPPORTED: 
default-pie-on-linux` to them.

  Failed Tests (6):
Clang :: Driver/hip-fpie-option.hip
Clang :: Driver/mips-cs.cpp
Clang :: Driver/mips-fsf.cpp
Clang :: Driver/mips-img-v2.cpp
Clang :: Driver/mips-img.cpp
Clang :: Driver/mips-mti-linux.c


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120305

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


[PATCH] D120306: [clangd] IncludeCleaner: Add support for IWYU pragma private

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

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120306

Files:
  clang-tools-extra/clangd/Headers.cpp
  clang-tools-extra/clangd/Headers.h
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/IncludeCleaner.h
  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
@@ -266,8 +266,9 @@
 
 ReferencedLocations Locs = findReferencedLocations(AST);
 EXPECT_THAT(Locs.Stdlib, ElementsAreArray(WantSyms));
-ReferencedFiles Files = findReferencedFiles(Locs, AST.getIncludeStructure(),
-AST.getSourceManager());
+ReferencedFiles Files =
+findReferencedFiles(Locs, AST.getIncludeStructure(),
+AST.getCanonicalIncludes(), AST.getSourceManager());
 EXPECT_THAT(Files.Stdlib, ElementsAreArray(WantHeaders));
   }
 }
@@ -378,8 +379,8 @@
   auto &SM = AST.getSourceManager();
   auto &Includes = AST.getIncludeStructure();
 
-  auto ReferencedFiles =
-  findReferencedFiles(findReferencedLocations(AST), Includes, SM);
+  auto ReferencedFiles = findReferencedFiles(
+  findReferencedLocations(AST), Includes, AST.getCanonicalIncludes(), SM);
   llvm::StringSet<> ReferencedFileNames;
   for (FileID FID : ReferencedFiles.User)
 ReferencedFileNames.insert(
@@ -427,9 +428,9 @@
 
   ParsedAST AST = TU.build();
 
-  auto ReferencedFiles =
-  findReferencedFiles(findReferencedLocations(AST),
-  AST.getIncludeStructure(), AST.getSourceManager());
+  auto ReferencedFiles = findReferencedFiles(
+  findReferencedLocations(AST), AST.getIncludeStructure(),
+  AST.getCanonicalIncludes(), AST.getSourceManager());
   llvm::StringSet<> ReferencedFileNames;
   auto &SM = AST.getSourceManager();
   for (FileID FID : ReferencedFiles.User)
@@ -461,9 +462,9 @@
 
   ParsedAST AST = TU.build();
 
-  auto ReferencedFiles =
-  findReferencedFiles(findReferencedLocations(AST),
-  AST.getIncludeStructure(), AST.getSourceManager());
+  auto ReferencedFiles = findReferencedFiles(
+  findReferencedLocations(AST), AST.getIncludeStructure(),
+  AST.getCanonicalIncludes(), AST.getSourceManager());
   llvm::StringSet<> ReferencedFileNames;
   auto &SM = AST.getSourceManager();
   for (FileID FID : ReferencedFiles.User)
@@ -483,9 +484,9 @@
   TU.AdditionalFiles["behind_keep.h"] = guard("");
   ParsedAST AST = TU.build();
 
-  auto ReferencedFiles =
-  findReferencedFiles(findReferencedLocations(AST),
-  AST.getIncludeStructure(), AST.getSourceManager());
+  auto ReferencedFiles = findReferencedFiles(
+  findReferencedLocations(AST), AST.getIncludeStructure(),
+  AST.getCanonicalIncludes(), AST.getSourceManager());
   EXPECT_TRUE(ReferencedFiles.User.empty());
   EXPECT_THAT(AST.getDiagnostics(), llvm::ValueIs(IsEmpty()));
 }
Index: clang-tools-extra/clangd/IncludeCleaner.h
===
--- clang-tools-extra/clangd/IncludeCleaner.h
+++ clang-tools-extra/clangd/IncludeCleaner.h
@@ -13,9 +13,6 @@
 /// to provide useful warnings in most popular scenarios but not 1:1 exact
 /// feature compatibility.
 ///
-/// FIXME(kirillbobyrev): Add support for IWYU pragmas.
-/// FIXME(kirillbobyrev): Add support for standard library headers.
-///
 //===--===//
 
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INCLUDECLEANER_H
@@ -23,6 +20,7 @@
 
 #include "Headers.h"
 #include "ParsedAST.h"
+#include "index/CanonicalIncludes.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Tooling/Inclusions/StandardLibrary.h"
 #include "llvm/ADT/DenseSet.h"
@@ -72,6 +70,7 @@
 llvm::function_ref HeaderResponsible);
 ReferencedFiles findReferencedFiles(const ReferencedLocations &Locs,
 const IncludeStructure &Includes,
+const CanonicalIncludes &CanonIncludes,
 const SourceManager &SM);
 
 /// Maps FileIDs to the internal IncludeStructure representation (HeaderIDs).
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -12,6 +12,7 @@
 #include "ParsedAST.h"
 #include "Protocol.h"
 #include "SourceCode.h"
+#i

[PATCH] D120306: [clangd] IncludeCleaner: Add support for IWYU pragma private

2022-02-22 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev planned changes to this revision.
kbobyrev added a comment.

The patch is working but I didn't add tests yet. Also, I think I should move 
the suffix mapping to `CanonicalIncludes` structure rather than `Headers`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120306

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


[PATCH] D120258: [clangd] Add inlay hints for auto-typed parameters with one instantiation.

2022-02-22 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added inline comments.



Comment at: clang-tools-extra/clangd/InlayHints.cpp:323
+   "Instantiated function has fewer (non-pack) parameters?");
+return InstantiatedFunction->getParamDecl(ParamIdx);
+  }

Here's a test case which slips past these checks:

```
int waldo(auto... args, auto last);
int x = waldo(1, 2.0, 'x');
```

`last` incorrectly gets `float` (rather than `char`) as a hint


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120258

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


[PATCH] D116153: [ARM][AArch64] Add missing v8.x checks

2022-02-22 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer accepted this revision.
SjoerdMeijer added a comment.
This revision is now accepted and ready to land.

Thanks, looks good!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116153

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


[PATCH] D120305: [Driver] Default CLANG_DEFAULT_PIE_ON_LINUX to ON

2022-02-22 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:177
 
+* CMake ``-DCLANG_DEFAULT_PIE_ON_LINUX=ON`` is now the default.
+  This matches GCC installations on many Linux distros.

it would be nice to explain what "pie" it is doing :)



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120305

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


[PATCH] D120305: [Driver] Default CLANG_DEFAULT_PIE_ON_LINUX to ON

2022-02-22 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan added a comment.

In D120305#3337019 , @MaskRay wrote:

> @atanasyan A few mips test/Driver tests will fail. Wonder if you have time 
> making them more portable... Otherwise I'll just add `UNSUPPORTED: 
> default-pie-on-linux` to them.
>
>   Failed Tests (6):
> Clang :: Driver/hip-fpie-option.hip
> Clang :: Driver/mips-cs.cpp
> Clang :: Driver/mips-fsf.cpp
> Clang :: Driver/mips-img-v2.cpp
> Clang :: Driver/mips-img.cpp
> Clang :: Driver/mips-mti-linux.c

I will take a look at the tests. Probably `hip-fpie-option.hip` is unrelated to 
MIPS?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120305

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


[PATCH] D120307: [X86] Add helper macros for ternary intrinsics

2022-02-22 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei created this revision.
pengfei added reviewers: RKSimon, craig.topper, LuoYuanke, spatel.
pengfei requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120307

Files:
  clang/lib/Headers/avx512fintrin.h
  clang/lib/Headers/avx512vlintrin.h
  clang/test/CodeGen/X86/avx512f-builtins.c

Index: clang/test/CodeGen/X86/avx512f-builtins.c
===
--- clang/test/CodeGen/X86/avx512f-builtins.c
+++ clang/test/CodeGen/X86/avx512f-builtins.c
@@ -6008,41 +6008,41 @@
 __m512i test_mm512_ternarylogic_epi32(__m512i __A, __m512i __B, __m512i __C) {
   // CHECK-LABEL: @test_mm512_ternarylogic_epi32
   // CHECK: @llvm.x86.avx512.pternlog.d.512
-  return _mm512_ternarylogic_epi32(__A, __B, __C, 4); 
+  return _mm512_ternarylogic_epi32(__A, __B, __C, _MM_TERNLOG_A);
 }
 
 __m512i test_mm512_mask_ternarylogic_epi32(__m512i __A, __mmask16 __U, __m512i __B, __m512i __C) {
   // CHECK-LABEL: @test_mm512_mask_ternarylogic_epi32
   // CHECK: @llvm.x86.avx512.pternlog.d.512
   // CHECK: select <16 x i1> %{{.*}}, <16 x i32> %{{.*}}, <16 x i32> %{{.*}}
-  return _mm512_mask_ternarylogic_epi32(__A, __U, __B, __C, 4); 
+  return _mm512_mask_ternarylogic_epi32(__A, __U, __B, __C, _MM_TERNLOG_B);
 }
 
 __m512i test_mm512_maskz_ternarylogic_epi32(__mmask16 __U, __m512i __A, __m512i __B, __m512i __C) {
   // CHECK-LABEL: @test_mm512_maskz_ternarylogic_epi32
   // CHECK: @llvm.x86.avx512.pternlog.d.512
   // CHECK: select <16 x i1> %{{.*}}, <16 x i32> %{{.*}}, <16 x i32> zeroinitializer
-  return _mm512_maskz_ternarylogic_epi32(__U, __A, __B, __C, 4); 
+  return _mm512_maskz_ternarylogic_epi32(__U, __A, __B, __C, _MM_TERNLOG_C);
 }
 
 __m512i test_mm512_ternarylogic_epi64(__m512i __A, __m512i __B, __m512i __C) {
   // CHECK-LABEL: @test_mm512_ternarylogic_epi64
   // CHECK: @llvm.x86.avx512.pternlog.q.512
-  return _mm512_ternarylogic_epi64(__A, __B, __C, 4); 
+  return _mm512_ternarylogic_epi64(__A, __B, __C, _MM_TERNLOG_A & _MM_TERNLOG_B);
 }
 
 __m512i test_mm512_mask_ternarylogic_epi64(__m512i __A, __mmask8 __U, __m512i __B, __m512i __C) {
   // CHECK-LABEL: @test_mm512_mask_ternarylogic_epi64
   // CHECK: @llvm.x86.avx512.pternlog.q.512
   // CHECK: select <8 x i1> %{{.*}}, <8 x i64> %{{.*}}, <8 x i64> %{{.*}}
-  return _mm512_mask_ternarylogic_epi64(__A, __U, __B, __C, 4); 
+  return _mm512_mask_ternarylogic_epi64(__A, __U, __B, __C, _MM_TERNLOG_B | _MM_TERNLOG_C);
 }
 
 __m512i test_mm512_maskz_ternarylogic_epi64(__mmask8 __U, __m512i __A, __m512i __B, __m512i __C) {
   // CHECK-LABEL: @test_mm512_maskz_ternarylogic_epi64
   // CHECK: @llvm.x86.avx512.pternlog.q.512
   // CHECK: select <8 x i1> %{{.*}}, <8 x i64> %{{.*}}, <8 x i64> zeroinitializer
-  return _mm512_maskz_ternarylogic_epi64(__U, __A, __B, __C, 4); 
+  return _mm512_maskz_ternarylogic_epi64(__U, __A, __B, __C, ~_MM_TERNLOG_A | (_MM_TERNLOG_B ^ _MM_TERNLOG_C));
 }
 
 __m512 test_mm512_shuffle_f32x4(__m512 __A, __m512 __B) {
Index: clang/lib/Headers/avx512vlintrin.h
===
--- clang/lib/Headers/avx512vlintrin.h
+++ clang/lib/Headers/avx512vlintrin.h
@@ -6525,79 +6525,65 @@
 (__v4di)_mm256_setzero_si256());
 }
 
-#define _mm_ternarylogic_epi32(A, B, C, imm) \
-  ((__m128i)__builtin_ia32_pternlogd128_mask((__v4si)(__m128i)(A), \
- (__v4si)(__m128i)(B), \
- (__v4si)(__m128i)(C), (int)(imm), \
- (__mmask8)-1))
-
-#define _mm_mask_ternarylogic_epi32(A, U, B, C, imm) \
-  ((__m128i)__builtin_ia32_pternlogd128_mask((__v4si)(__m128i)(A), \
- (__v4si)(__m128i)(B), \
- (__v4si)(__m128i)(C), (int)(imm), \
- (__mmask8)(U)))
-
-#define _mm_maskz_ternarylogic_epi32(U, A, B, C, imm) \
-  ((__m128i)__builtin_ia32_pternlogd128_maskz((__v4si)(__m128i)(A), \
-  (__v4si)(__m128i)(B), \
-  (__v4si)(__m128i)(C), (int)(imm), \
-  (__mmask8)(U)))
-
-#define _mm256_ternarylogic_epi32(A, B, C, imm) \
-  ((__m256i)__builtin_ia32_pternlogd256_mask((__v8si)(__m256i)(A), \
- (__v8si)(__m256i)(B), \
- (__v8si)(__m256i)(C), (int)(imm), \
- (__mmask8)-1))
-
-#define _mm256_mask_ternarylogic_epi32(A, U, B, C, imm) \
-  ((__m256i)__builtin_ia32_pternlogd256_mask((__v8si)(__m256i)(A), \
- (__v8si)(__m256i)(B), \
- (__v8si)(

[clang] 48dc980 - [Format] Remove unused LineContainsContinuedForLoopSection. NFC

2022-02-22 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2022-02-22T09:59:02+01:00
New Revision: 48dc980847b25384511276e37c02c7edcf9e3d3a

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

LOG: [Format] Remove unused LineContainsContinuedForLoopSection. NFC

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

Added: 


Modified: 
clang/lib/Format/ContinuationIndenter.cpp
clang/lib/Format/ContinuationIndenter.h

Removed: 




diff  --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index f4a755268eae8..ec268e74fd97e 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -253,7 +253,6 @@ LineState ContinuationIndenter::getInitialState(unsigned 
FirstIndent,
   State.Stack.push_back(ParenState(/*Tok=*/nullptr, FirstIndent, FirstIndent,
/*AvoidBinPacking=*/false,
/*NoLineBreak=*/false));
-  State.LineContainsContinuedForLoopSection = false;
   State.NoContinuation = false;
   State.StartOfStringLiteral = 0;
   State.StartOfLineLevel = 0;
@@ -343,8 +342,6 @@ bool ContinuationIndenter::mustBreak(const LineState 
&State) {
 return true;
   if (CurrentState.BreakBeforeClosingParen && Current.is(tok::r_paren))
 return true;
-  if (Previous.is(tok::semi) && State.LineContainsContinuedForLoopSection)
-return true;
   if (Style.Language == FormatStyle::LK_ObjC &&
   Style.ObjCBreakBeforeNestedBlockParam &&
   Current.ObjCSelectorNameParts > 1 &&

diff  --git a/clang/lib/Format/ContinuationIndenter.h 
b/clang/lib/Format/ContinuationIndenter.h
index 0eb53cbd02937..494a9727d5edc 100644
--- a/clang/lib/Format/ContinuationIndenter.h
+++ b/clang/lib/Format/ContinuationIndenter.h
@@ -419,9 +419,6 @@ struct LineState {
   /// The token that needs to be next formatted.
   FormatToken *NextToken;
 
-  /// \c true if this line contains a continued for-loop section.
-  bool LineContainsContinuedForLoopSection;
-
   /// \c true if \p NextToken should not continue this line.
   bool NoContinuation;
 
@@ -468,9 +465,6 @@ struct LineState {
   return NextToken < Other.NextToken;
 if (Column != Other.Column)
   return Column < Other.Column;
-if (LineContainsContinuedForLoopSection !=
-Other.LineContainsContinuedForLoopSection)
-  return LineContainsContinuedForLoopSection;
 if (NoContinuation != Other.NoContinuation)
   return NoContinuation;
 if (StartOfLineLevel != Other.StartOfLineLevel)



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


[PATCH] D120282: [Format] Remove unused LineContainsContinuedForLoopSection. NFC

2022-02-22 Thread Sam McCall 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 rG48dc980847b2: [Format] Remove unused 
LineContainsContinuedForLoopSection. NFC (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120282

Files:
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/ContinuationIndenter.h


Index: clang/lib/Format/ContinuationIndenter.h
===
--- clang/lib/Format/ContinuationIndenter.h
+++ clang/lib/Format/ContinuationIndenter.h
@@ -419,9 +419,6 @@
   /// The token that needs to be next formatted.
   FormatToken *NextToken;
 
-  /// \c true if this line contains a continued for-loop section.
-  bool LineContainsContinuedForLoopSection;
-
   /// \c true if \p NextToken should not continue this line.
   bool NoContinuation;
 
@@ -468,9 +465,6 @@
   return NextToken < Other.NextToken;
 if (Column != Other.Column)
   return Column < Other.Column;
-if (LineContainsContinuedForLoopSection !=
-Other.LineContainsContinuedForLoopSection)
-  return LineContainsContinuedForLoopSection;
 if (NoContinuation != Other.NoContinuation)
   return NoContinuation;
 if (StartOfLineLevel != Other.StartOfLineLevel)
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -253,7 +253,6 @@
   State.Stack.push_back(ParenState(/*Tok=*/nullptr, FirstIndent, FirstIndent,
/*AvoidBinPacking=*/false,
/*NoLineBreak=*/false));
-  State.LineContainsContinuedForLoopSection = false;
   State.NoContinuation = false;
   State.StartOfStringLiteral = 0;
   State.StartOfLineLevel = 0;
@@ -343,8 +342,6 @@
 return true;
   if (CurrentState.BreakBeforeClosingParen && Current.is(tok::r_paren))
 return true;
-  if (Previous.is(tok::semi) && State.LineContainsContinuedForLoopSection)
-return true;
   if (Style.Language == FormatStyle::LK_ObjC &&
   Style.ObjCBreakBeforeNestedBlockParam &&
   Current.ObjCSelectorNameParts > 1 &&


Index: clang/lib/Format/ContinuationIndenter.h
===
--- clang/lib/Format/ContinuationIndenter.h
+++ clang/lib/Format/ContinuationIndenter.h
@@ -419,9 +419,6 @@
   /// The token that needs to be next formatted.
   FormatToken *NextToken;
 
-  /// \c true if this line contains a continued for-loop section.
-  bool LineContainsContinuedForLoopSection;
-
   /// \c true if \p NextToken should not continue this line.
   bool NoContinuation;
 
@@ -468,9 +465,6 @@
   return NextToken < Other.NextToken;
 if (Column != Other.Column)
   return Column < Other.Column;
-if (LineContainsContinuedForLoopSection !=
-Other.LineContainsContinuedForLoopSection)
-  return LineContainsContinuedForLoopSection;
 if (NoContinuation != Other.NoContinuation)
   return NoContinuation;
 if (StartOfLineLevel != Other.StartOfLineLevel)
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -253,7 +253,6 @@
   State.Stack.push_back(ParenState(/*Tok=*/nullptr, FirstIndent, FirstIndent,
/*AvoidBinPacking=*/false,
/*NoLineBreak=*/false));
-  State.LineContainsContinuedForLoopSection = false;
   State.NoContinuation = false;
   State.StartOfStringLiteral = 0;
   State.StartOfLineLevel = 0;
@@ -343,8 +342,6 @@
 return true;
   if (CurrentState.BreakBeforeClosingParen && Current.is(tok::r_paren))
 return true;
-  if (Previous.is(tok::semi) && State.LineContainsContinuedForLoopSection)
-return true;
   if (Style.Language == FormatStyle::LK_ObjC &&
   Style.ObjCBreakBeforeNestedBlockParam &&
   Current.ObjCSelectorNameParts > 1 &&
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D120246: [flang][driver] Add support for `--target`/`--triple`

2022-02-22 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski updated this revision to Diff 410469.
awarzynski added a comment.

Add TargetOptions.h (that I forgot to add earlier)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120246

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/CompilerInvocation.h
  flang/include/flang/Frontend/TargetOptions.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  flang/test/Driver/print-target-triple.f90
  flang/test/Driver/target.f90

Index: flang/test/Driver/target.f90
===
--- /dev/null
+++ flang/test/Driver/target.f90
@@ -0,0 +1,13 @@
+!  Test that --target indeed sets the target
+
+!-
+! RUN LINES
+!-
+! RUN: %flang --target=unknown-unknown-unknown -emit-llvm -c %s \
+! RUN:   -o %t.o -### 2>&1 | FileCheck %s
+
+!-
+! EXPECTED OUTPUT
+!-
+! CHECK: Target: unknown-unknown-unknown
+! CHECK: "-triple" "unknown-unknown-unknown"
Index: flang/test/Driver/print-target-triple.f90
===
--- /dev/null
+++ flang/test/Driver/print-target-triple.f90
@@ -0,0 +1,16 @@
+! Test that -print-target-triple prints correct triple
+
+!-
+! RUN LINES
+!-
+! RUN: %flang -print-target-triple 2>&1 --target=aarch64-linux-gnu \
+! RUN:   | FileCheck --check-prefix=AARCH64 %s
+
+! RUN: %flang -print-target-triple 2>&1 --target=x86_64-linux-gnu \
+! RUN:   | FileCheck --check-prefix=X86_64 %s
+
+!-
+! EXPECTED OUTPUT
+!-
+! X86_64: x86_64-unknown-linux-gnu
+! AARCH64: aarch64-unknown-linux-gnu
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -21,6 +21,7 @@
 ! HELP-NEXT: -cpp   Enable predefined and command line preprocessor macros
 ! HELP-NEXT: -c Only run preprocess, compile, and assemble steps
 ! HELP-NEXT: -D = Define  to  (or 1 if  omitted)
+! HELP-NEXT: -emit-llvm Use the LLVM representation for assembler and object files
 ! HELP-NEXT: -E Only run the preprocessor
 ! HELP-NEXT: -falternative-parameter-statement
 ! HELP-NEXT: Enable the old style PARAMETER statement
@@ -50,8 +51,11 @@
 ! HELP-NEXT: -nocpp Disable predefined and command line preprocessor macros
 ! HELP-NEXT: -o   Write output to 
 ! HELP-NEXT: -pedantic  Warn on language extensions
+! HELP-NEXT: -print-effective-triple Print the effective target triple
+! HELP-NEXT: -print-target-triplePrint the normalized target triple
 ! HELP-NEXT: -P Disable linemarker output in -E mode
 ! HELP-NEXT: -std=   Language standard to compile for
+! HELP-NEXT: --target=   Generate code for the given target
 ! HELP-NEXT: -U  Undefine macro 
 ! HELP-NEXT: --version  Print version information
 ! HELP-NEXT: -WEnable the specified warning
@@ -124,6 +128,7 @@
 ! HELP-FC1-NEXT: -P Disable linemarker output in -E mode
 ! HELP-FC1-NEXT: -std=   Language standard to compile for
 ! HELP-FC1-NEXT: -test-io   Run the InputOuputTest action. Use for development and testing only.
+! HELP-FC1-NEXT: -triple Specify target triple (e.g. i686-apple-darwin9)
 ! HELP-FC1-NEXT: -U  Undefine macro 
 ! HELP-FC1-NEXT: --version  Print version information
 ! HELP-FC1-NEXT: -WEnable the specified warning
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -21,6 +21,7 @@
 ! CHECK-NEXT: -cpp  Enable predefined and command line preprocessor macros
 ! CHECK-NEXT: -cOnly run preprocess, compile, and assemble steps
 ! CHECK-NEXT: -D = Define  to  (or 1 if  omitted)
+! CHECK-NEXT: -emit-llvm Use the LLVM representation for assembler and object files
 ! CHECK-NEXT: -EOnly run the preprocessor
 ! CHECK-NEXT: -falternative-parameter-statement
 ! CHECK-NEXT: Enable the old style PARAMETER statement
@@ -50,8 +51,11 @@
 ! CHECK-NEXT: -nocpp Disable predefined and command line preprocessor macros
 ! CHECK-NEXT: -o  Write output to 
 ! CHECK-NEXT: -pedantic  Warn on language extensions
+! CHECK-NEXT: -print-effective-triple Print the effective target triple
+! CHECK-NEXT: -print-target-triplePrint the normalize

[PATCH] D120309: [clang-format] Fix QualifierOrder breaking the code with requires clause.

2022-02-22 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius created this revision.
curdeius added reviewers: MyDeveloperDay, HazardyKnusperkeks, owenpan.
curdeius requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fixes https://github.com/llvm/llvm-project/issues/53962.

Given the config:

  BasedOnStyle: LLVM
  QualifierAlignment: Custom
  QualifierOrder: ['constexpr', 'type']

The code:

  template 
requires std::invocable
  constexpr constructor();

was incorrectly formatted to:

  template 
requires 
  constexpr std::invocable constructor();

because we considered `std::invocable constexpr` as a type, not recognising 
the requires clause.

This patch avoids moving the qualifier across the boundary of the requires 
clause (checking `ClosesRequiresClause`).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120309

Files:
  clang/lib/Format/QualifierAlignmentFixer.cpp
  clang/unittests/Format/QualifierFixerTest.cpp


Index: clang/unittests/Format/QualifierFixerTest.cpp
===
--- clang/unittests/Format/QualifierFixerTest.cpp
+++ clang/unittests/Format/QualifierFixerTest.cpp
@@ -858,6 +858,17 @@
Style);
 }
 
+TEST_F(QualifierFixerTest, WithConstraints) {
+  FormatStyle Style = getLLVMStyle();
+  Style.QualifierAlignment = FormatStyle::QAS_Custom;
+  Style.QualifierOrder = {"constexpr", "type"};
+
+  verifyFormat("template \n"
+   "  requires Concept\n"
+   "constexpr constructor();",
+   Style);
+}
+
 TEST_F(QualifierFixerTest, DisableRegions) {
   FormatStyle Style = getLLVMStyle();
   Style.QualifierAlignment = FormatStyle::QAS_Custom;
Index: clang/lib/Format/QualifierAlignmentFixer.cpp
===
--- clang/lib/Format/QualifierAlignmentFixer.cpp
+++ clang/lib/Format/QualifierAlignmentFixer.cpp
@@ -328,14 +328,17 @@
   if (Next->is(tok::comment) && Next->getNextNonComment())
 Next = Next->getNextNonComment();
   assert(Next->MatchingParen && "Missing template closer");
-  Next = Next->MatchingParen->Next;
+  Next = Next->MatchingParen;
+  if (Next->ClosesRequiresClause)
+return Next;
+  Next = Next->Next;
 
   // Move to the end of any template class members e.g.
   // `Foo::iterator`.
   if (Next && Next->startsSequence(tok::coloncolon, tok::identifier))
 Next = Next->Next->Next;
   if (Next && Next->is(QualifierType)) {
-// Remove the const.
+// Move the qualifier.
 insertQualifierBefore(SourceMgr, Fixes, Tok, Qualifier);
 removeToken(SourceMgr, Fixes, Next);
 return Next;
@@ -344,7 +347,7 @@
 if (Next && Next->Next &&
 Next->Next->isOneOf(tok::amp, tok::ampamp, tok::star)) {
   if (Next->is(QualifierType)) {
-// Remove the qualifier.
+// Move the qualifier.
 insertQualifierBefore(SourceMgr, Fixes, Tok, Qualifier);
 removeToken(SourceMgr, Fixes, Next);
 return Next;


Index: clang/unittests/Format/QualifierFixerTest.cpp
===
--- clang/unittests/Format/QualifierFixerTest.cpp
+++ clang/unittests/Format/QualifierFixerTest.cpp
@@ -858,6 +858,17 @@
Style);
 }
 
+TEST_F(QualifierFixerTest, WithConstraints) {
+  FormatStyle Style = getLLVMStyle();
+  Style.QualifierAlignment = FormatStyle::QAS_Custom;
+  Style.QualifierOrder = {"constexpr", "type"};
+
+  verifyFormat("template \n"
+   "  requires Concept\n"
+   "constexpr constructor();",
+   Style);
+}
+
 TEST_F(QualifierFixerTest, DisableRegions) {
   FormatStyle Style = getLLVMStyle();
   Style.QualifierAlignment = FormatStyle::QAS_Custom;
Index: clang/lib/Format/QualifierAlignmentFixer.cpp
===
--- clang/lib/Format/QualifierAlignmentFixer.cpp
+++ clang/lib/Format/QualifierAlignmentFixer.cpp
@@ -328,14 +328,17 @@
   if (Next->is(tok::comment) && Next->getNextNonComment())
 Next = Next->getNextNonComment();
   assert(Next->MatchingParen && "Missing template closer");
-  Next = Next->MatchingParen->Next;
+  Next = Next->MatchingParen;
+  if (Next->ClosesRequiresClause)
+return Next;
+  Next = Next->Next;
 
   // Move to the end of any template class members e.g.
   // `Foo::iterator`.
   if (Next && Next->startsSequence(tok::coloncolon, tok::identifier))
 Next = Next->Next->Next;
   if (Next && Next->is(QualifierType)) {
-// Remove the const.
+// Move the qualifier.
 insertQualifierBefore(SourceMgr, Fixes, Tok, Qualifier);
 removeToken(SourceMgr, Fixes, Next);
 return Next;
@@ -344,7 +347,7 @@
 if (Next && Next->Next &&
 Next->Next->isOneOf(tok::amp, tok::ampamp, tok::star)) {
   if (Next->is(QualifierType)) {
-  

[PATCH] D120310: [clang][analyzer] Add modeling of 'errno' (work-in-progress).

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

Add a checker to maintain the system-defined value 'errno'.
The value is supposed to be set in the future by existing or
new checkers that evaluate errno-modifying function calls.

The patch is work-in-progress because the possible definitions
of `errno` on various implementations should be collected.
Some tests (dependent on these) are missing yet.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120310

Files:
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
  clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  clang/lib/StaticAnalyzer/Checkers/Errno.h
  clang/lib/StaticAnalyzer/Checkers/ErrnoChecker.cpp
  clang/lib/StaticAnalyzer/Core/MemRegion.cpp
  clang/test/Analysis/Inputs/errno_func.h
  clang/test/Analysis/Inputs/errno_var.h
  clang/test/Analysis/Inputs/system-header-simulator.h
  clang/test/Analysis/analyzer-enabled-checkers.c
  clang/test/Analysis/errno.c
  clang/test/Analysis/global-region-invalidation.c
  clang/test/Analysis/std-c-library-functions-arg-enabled-checkers.c

Index: clang/test/Analysis/std-c-library-functions-arg-enabled-checkers.c
===
--- clang/test/Analysis/std-c-library-functions-arg-enabled-checkers.c
+++ clang/test/Analysis/std-c-library-functions-arg-enabled-checkers.c
@@ -21,6 +21,7 @@
 // CHECK-NEXT: alpha.unix.Stream
 // CHECK-NEXT: apiModeling.StdCLibraryFunctions
 // CHECK-NEXT: alpha.unix.StdCLibraryFunctionArgs
+// CHECK-NEXT: apiModeling.Errno
 // CHECK-NEXT: apiModeling.TrustNonnull
 // CHECK-NEXT: apiModeling.TrustReturnsNonnull
 // CHECK-NEXT: apiModeling.llvm.CastValue
Index: clang/test/Analysis/global-region-invalidation.c
===
--- clang/test/Analysis/global-region-invalidation.c
+++ clang/test/Analysis/global-region-invalidation.c
@@ -3,6 +3,7 @@
 void clang_analyzer_eval(int);
 
 // Note, we do need to include headers here, since the analyzer checks if the function declaration is located in a system header.
+#include "Inputs/errno_var.h"
 #include "Inputs/system-header-simulator.h"
 
 // Test that system header does not invalidate the internal global.
Index: clang/test/Analysis/errno.c
===
--- /dev/null
+++ clang/test/Analysis/errno.c
@@ -0,0 +1,26 @@
+// RUN: %clang_analyze_cc1 -verify %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=apiModeling.Errno \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-checker=debug.ErrnoTest
+
+#include "Inputs/errno_var.h"
+#include "Inputs/system-header-simulator.h"
+
+void clang_analyzer_eval(int);
+void ErrnoTesterChecker_set_errno(int);
+
+void test() {
+  // Test if errno is initialized.
+  clang_analyzer_eval(errno == 0); // expected-warning{{TRUE}}
+
+  ErrnoTesterChecker_set_errno(1);
+
+  // Test if errno was recognized and changed.
+  clang_analyzer_eval(errno == 1); // expected-warning{{TRUE}}
+
+  FILE *F = fopen("/a/b", "r");
+
+  // Test if errno was invalidated.
+  clang_analyzer_eval(errno); // expected-warning{{UNKNOWN}}
+}
Index: clang/test/Analysis/analyzer-enabled-checkers.c
===
--- clang/test/Analysis/analyzer-enabled-checkers.c
+++ clang/test/Analysis/analyzer-enabled-checkers.c
@@ -7,6 +7,7 @@
 // CHECK:  OVERVIEW: Clang Static Analyzer Enabled Checkers List
 // CHECK-EMPTY:
 // CHECK-NEXT: core.CallAndMessageModeling
+// CHECK-NEXT: apiModeling.Errno
 // CHECK-NEXT: apiModeling.StdCLibraryFunctions
 // CHECK-NEXT: apiModeling.TrustNonnull
 // CHECK-NEXT: apiModeling.TrustReturnsNonnull
Index: clang/test/Analysis/Inputs/system-header-simulator.h
===
--- clang/test/Analysis/Inputs/system-header-simulator.h
+++ clang/test/Analysis/Inputs/system-header-simulator.h
@@ -59,9 +59,6 @@
 int ferror(FILE *stream);
 int fileno(FILE *stream);
 
-// Note, on some platforms errno macro gets replaced with a function call.
-extern int errno;
-
 size_t strlen(const char *);
 
 char *strcpy(char *restrict, const char *restrict);
Index: clang/test/Analysis/Inputs/errno_var.h
===
--- /dev/null
+++ clang/test/Analysis/Inputs/errno_var.h
@@ -0,0 +1,5 @@
+#pragma clang system_header
+
+// Define 'errno' as an extern variable in a system header.
+// This may be not allowed in C99.
+extern int errno;
Index: clang/test/Analysis/Inputs/errno_func.h

[clang] 650aec6 - [ARM][AArch64] Add missing v8.x checks

2022-02-22 Thread via cfe-commits

Author: tyb0807
Date: 2022-02-22T09:07:59Z
New Revision: 650aec687eb54aeeb3cef4a41f2dbaa49ef3e358

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

LOG: [ARM][AArch64] Add missing v8.x checks

Summary:
This patch adds checks that were missing in clang for Armv8.5/6/7-A. These 
include:
* ACLE macro defines for AArch32.
* Handling of crypto and SM4, SHA and AES feature flags on clang's driver.

Reviewers: dmgreen, SjoerdMeijer, tmatheson

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

Added: 


Modified: 
clang/lib/Basic/Targets/ARM.cpp
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
clang/test/Preprocessor/aarch64-target-features.c
clang/test/Preprocessor/arm-target-features.c

Removed: 




diff  --git a/clang/lib/Basic/Targets/ARM.cpp b/clang/lib/Basic/Targets/ARM.cpp
index 9c9d198e8f324..b2f61cff81c95 100644
--- a/clang/lib/Basic/Targets/ARM.cpp
+++ b/clang/lib/Basic/Targets/ARM.cpp
@@ -955,6 +955,7 @@ void ARMTargetInfo::getTargetDefines(const LangOptions 
&Opts,
   case llvm::ARM::ArchKind::ARMV8_4A:
   case llvm::ARM::ArchKind::ARMV8_5A:
   case llvm::ARM::ArchKind::ARMV8_6A:
+  case llvm::ARM::ArchKind::ARMV8_7A:
   case llvm::ARM::ArchKind::ARMV8_8A:
   case llvm::ARM::ArchKind::ARMV9A:
   case llvm::ARM::ArchKind::ARMV9_1A:

diff  --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp 
b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index 6e3e3d04bbe3a..f9557bac5fcdc 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -393,6 +393,9 @@ void aarch64::getAArch64TargetFeatures(const Driver &D,
   }
 
   if (std::find(ItBegin, ItEnd, "+v8.4a") != ItEnd ||
+  std::find(ItBegin, ItEnd, "+v8.5a") != ItEnd ||
+  std::find(ItBegin, ItEnd, "+v8.6a") != ItEnd ||
+  std::find(ItBegin, ItEnd, "+v8.7a") != ItEnd ||
   std::find(ItBegin, ItEnd, "+v8.8a") != ItEnd ||
   std::find(ItBegin, ItEnd, "+v9a") != ItEnd ||
   std::find(ItBegin, ItEnd, "+v9.1a") != ItEnd ||

diff  --git a/clang/test/Preprocessor/aarch64-target-features.c 
b/clang/test/Preprocessor/aarch64-target-features.c
index 6de0657d09bc4..833d75b7e5b9e 100644
--- a/clang/test/Preprocessor/aarch64-target-features.c
+++ b/clang/test/Preprocessor/aarch64-target-features.c
@@ -294,7 +294,7 @@
 // CHECK-MCPU-CARMEL: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+v8.2a" "-target-feature" "+fp-armv8" "-target-feature" "+neon" 
"-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" 
"+fullfp16" "-target-feature" "+ras" "-target-feature" "+lse" "-target-feature" 
"+rdm" "-target-feature" "+sha2" "-target-feature" "+aes"
 
 // RUN: %clang -target x86_64-apple-macosx -arch arm64 -### -c %s 2>&1 | 
FileCheck --check-prefix=CHECK-ARCH-ARM64 %s
-// CHECK-ARCH-ARM64: "-target-cpu" "apple-m1" "-target-feature" "+v8.5a" 
"-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" 
"+crc" "-target-feature" "+crypto" "-target-feature" "+dotprod" 
"-target-feature" "+fp16fml" "-target-feature" "+ras" "-target-feature" "+lse" 
"-target-feature" "+rdm" "-target-feature" "+rcpc" "-target-feature" "+zcm" 
"-target-feature" "+zcz" "-target-feature" "+fullfp16" "-target-feature" 
"+sha2" "-target-feature" "+aes"
+// CHECK-ARCH-ARM64: "-target-cpu" "apple-m1" "-target-feature" "+v8.5a" 
"-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" 
"+crc" "-target-feature" "+crypto" "-target-feature" "+dotprod" 
"-target-feature" "+fp16fml" "-target-feature" "+ras" "-target-feature" "+lse" 
"-target-feature" "+rdm" "-target-feature" "+rcpc" "-target-feature" "+zcm" 
"-target-feature" "+zcz" "-target-feature" "+fullfp16" "-target-feature" "+sm4" 
"-target-feature" "+sha3" "-target-feature" "+sha2" "-target-feature" "+aes"
 
 // RUN: %clang -target x86_64-apple-macosx -arch arm64_32 -### -c %s 2>&1 | 
FileCheck --check-prefix=CHECK-ARCH-ARM64_32 %s
 // CHECK-ARCH-ARM64_32: "-target-cpu" "apple-s4" "-target-feature" "+v8.3a" 
"-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" 
"+crc" "-target-feature" "+crypto" "-target-feature" "+fullfp16" 
"-target-feature" "+ras" "-target-feature" "+lse" "-target-feature" "+rdm" 
"-target-feature" "+rcpc" "-target-feature" "+zcm" "-target-feature" "+zcz" 
"-target-feature" "+sha2" "-target-feature" "+aes"
@@ -390,7 +390,13 @@
 // Check +crypto:
 //
 // RUN: %clang -target aarch64 -march=armv8.4a+crypto -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CRYPTO84 %s
-// CHECK-CRYPTO84: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+v8.4a" "-target-feature" "+crypto" "-target-feature" "+sm4" "-target-feature" 
"+sha3" "-target-feature" "+sha2" "-target-feature" "+aes"
+// RUN: %clang -target aarch64 -march=armv8.5a+crypto -### -c %s 

[PATCH] D116153: [ARM][AArch64] Add missing v8.x checks

2022-02-22 Thread Son Tuan Vu 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 rG650aec687eb5: [ARM][AArch64] Add missing v8.x checks 
(authored by tyb0807).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116153

Files:
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  clang/test/Preprocessor/aarch64-target-features.c
  clang/test/Preprocessor/arm-target-features.c

Index: clang/test/Preprocessor/arm-target-features.c
===
--- clang/test/Preprocessor/arm-target-features.c
+++ clang/test/Preprocessor/arm-target-features.c
@@ -938,3 +938,20 @@
 // CHECK-SHA2-NOT: #define __ARM_FEATURE_AES 1
 // CHECK-SHA2-NOT: #define __ARM_FEATURE_CRYPTO 1
 // CHECK-SHA2: #define __ARM_FEATURE_SHA2 1
+
+// == Check default macros for Armv8.1-A and later
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-a -x c -E -dM %s -o - | FileCheck --check-prefixes=CHECK-V81-OR-LATER,CHECK-BEFORE-V83   %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.2-a -x c -E -dM %s -o - | FileCheck --check-prefixes=CHECK-V81-OR-LATER,CHECK-BEFORE-V83   %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.3-a -x c -E -dM %s -o - | FileCheck --check-prefixes=CHECK-V81-OR-LATER,CHECK-V83-OR-LATER %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.4-a -x c -E -dM %s -o - | FileCheck --check-prefixes=CHECK-V81-OR-LATER,CHECK-V83-OR-LATER %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.5-a -x c -E -dM %s -o - | FileCheck --check-prefixes=CHECK-V81-OR-LATER,CHECK-V83-OR-LATER %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.6-a -x c -E -dM %s -o - | FileCheck --check-prefixes=CHECK-V81-OR-LATER,CHECK-V83-OR-LATER %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.7-a -x c -E -dM %s -o - | FileCheck --check-prefixes=CHECK-V81-OR-LATER,CHECK-V83-OR-LATER %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.8-a -x c -E -dM %s -o - | FileCheck --check-prefixes=CHECK-V81-OR-LATER,CHECK-V83-OR-LATER %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv9-a   -x c -E -dM %s -o - | FileCheck --check-prefixes=CHECK-V81-OR-LATER,CHECK-V83-OR-LATER %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv9.1-a -x c -E -dM %s -o - | FileCheck --check-prefixes=CHECK-V81-OR-LATER,CHECK-V83-OR-LATER %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv9.2-a -x c -E -dM %s -o - | FileCheck --check-prefixes=CHECK-V81-OR-LATER,CHECK-V83-OR-LATER %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv9.3-a -x c -E -dM %s -o - | FileCheck --check-prefixes=CHECK-V81-OR-LATER,CHECK-V83-OR-LATER %s
+// CHECK-V83-OR-LATER: __ARM_FEATURE_COMPLEX 1
+// CHECK-V81-OR-LATER: __ARM_FEATURE_QRDMX 1
+// CHECK-BEFORE-V83-NOT: __ARM_FEATURE_COMPLEX 1
Index: clang/test/Preprocessor/aarch64-target-features.c
===
--- clang/test/Preprocessor/aarch64-target-features.c
+++ clang/test/Preprocessor/aarch64-target-features.c
@@ -294,7 +294,7 @@
 // CHECK-MCPU-CARMEL: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8.2a" "-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" "+fullfp16" "-target-feature" "+ras" "-target-feature" "+lse" "-target-feature" "+rdm" "-target-feature" "+sha2" "-target-feature" "+aes"
 
 // RUN: %clang -target x86_64-apple-macosx -arch arm64 -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-ARCH-ARM64 %s
-// CHECK-ARCH-ARM64: "-target-cpu" "apple-m1" "-target-feature" "+v8.5a" "-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" "+dotprod" "-target-feature" "+fp16fml" "-target-feature" "+ras" "-target-feature" "+lse" "-target-feature" "+rdm" "-target-feature" "+rcpc" "-target-feature" "+zcm" "-target-feature" "+zcz" "-target-feature" "+fullfp16" "-target-feature" "+sha2" "-target-feature" "+aes"
+// CHECK-ARCH-ARM64: "-target-cpu" "apple-m1" "-target-feature" "+v8.5a" "-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" "+dotprod" "-target-feature" "+fp16fml" "-target-feature" "+ras" "-target-feature" "+lse" "-target-feature" "+rdm" "-target-feature" "+rcpc" "-target-feature" "+zcm" "-target-feature" "+zcz" "-target-feature" "+fullfp16" "-target-feature" "+sm4" "-target-feature" "+sha3" "-target-feature" "+sha2" "-target-feature" "+aes"
 
 // RUN: %clang -target x86_64-apple-macosx -arch arm64_32 -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-ARCH-ARM64_32 %s
 // CHECK-ARCH-ARM64_32: "-target-cpu" "apple-s4" "-target-feature" "+v8.3a" "-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature"

[PATCH] D119077: clangd SemanticHighlighting: added support for highlighting overloaded operators

2022-02-22 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

Still haven't had a chance to take a super detailed look, but a few high-level 
thoughts:

1. The AST nodes that reference operator names should store source ranges 
associated with the operator names, such that we shouldn't need to do 
token-by-token manipulation. For example, 
`functionDecl->getNameInfo().getCXXOperatorNameRange()`.
2. I think I appreciate now the issue with `findExplicitReferences()`: it gives 
us `ReferenceLoc` objects, which store a single `SourceLocation` but do **not** 
retain the AST node containing the reference (thereby not allowing us to access 
the source range of the reference easily). We've run into this before (here 
), and 
contemplated modifying `ReferenceLoc` to retain the AST node containing the 
reference, but decided against it, so I guess we should stick to that. That 
said... would it make sense to handle the **single-token** cases with 
`findExplicitReferences()`? Or would that just end up splitting the logic / 
duplicating code more?


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

https://reviews.llvm.org/D119077

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


[PATCH] D120310: [clang][analyzer] Add modeling of 'errno' (work-in-progress).

2022-02-22 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added reviewers: NoQ, steakhal, martong.
balazske added a comment.
Herald added subscribers: ormris, rnkovacs.

Documentation not added yet.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120310

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


[PATCH] D116015: [PowerPC] Add generic fnmsub intrinsic

2022-02-22 Thread Qiu Chaofan via Phabricator via cfe-commits
qiucf added a comment.

In D116015#3326148 , @shchenz wrote:

>> hiding the semantics from the optimizer is sometimes a good thing and 
>> sometimes a bad thing).
>
> Agree. Imagining a case when the neg and fma (from fnmsub) can both be CSE-ed 
> with another neg and fma, so we can totally eliminate the fnmsub. But after 
> we convert it to an intrinsic, we may lose the opportunity to CSE the fnmsub.
>
>> Here's a pretty simple case: vector float foo(vector float a, vector float 
>> b, vector float c, vector float d) { return __builtin_vsx_xvnmsubasp(c, d, 
>> a*b); }
>> It current produces xvnegsp+xvmulsp+xvnmaddasp, after this patch it produces 
>> xvmulsp+xvnmsubasp. In some complicated cases, we can see much more 
>> unexpected instructions generated.
>
> This is narrowed down from a real-world case. After CSE some part of the 
> fnmsub, it is hard to optimize it back to a single hardware fnmsub 
> instruction as normally we check the use number of a register and if the user 
> number is not 1, we may exit the combine.
>
> Is it possible to get some perf data for some float workloads with this 
> patch? @qiucf

Thanks. I did not see performance change in some common benchmarks.




Comment at: llvm/include/llvm/IR/IntrinsicsPowerPC.td:1737
+  [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>],
+  [IntrNoMem]>;
   def int_ppc_fre

shchenz wrote:
> When `llvm_anyfloat_ty` is `f32` or `f64`, we will generate two intrinsics 
> with same semantic. `llvm.ppc.nmsub.f32` + `llvm.ppc.fnmsubs` and 
> `llvm.ppc.nmsub.f64` + `llvm.ppc.fnmsub`. At first glance, we seems can not 
> delete the `int_ppc_fnmsub` and `int_ppc_fnmsubs`, because they are for XL 
> compatibility and XL has seperated fnmsub for float and double and we need to 
> map them 1 by 1. Better to check if it is possible to replace 
> `int_ppc_fnmsub` and `int_ppc_fnmsubs` with `int_ppc_nmsub`. And if it can be 
> replaced, we can use a meaningful name like `int_ppc_fnmsub` for the new 
> intrinsic.
We can do that, but that requires more work and seems beyond this patch's 
scope. See D105930, we'll need to handle the builtin in Clang. And the builtin 
explicitly generates type-M VSX instructions (I guess to reduce copy in simple 
cases).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116015

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


[PATCH] D120258: [clangd] Add inlay hints for auto-typed parameters with one instantiation.

2022-02-22 Thread Sam McCall via Phabricator via cfe-commits
sammccall marked 4 inline comments as done.
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/AST.cpp:572
+#define TEMPLATE_TYPE(SomeTemplateDecl)
\
+  if (auto *STD = llvm::dyn_cast(TD)) {  
\
+for (auto *Spec : STD->specializations()) {
\

nridge wrote:
> Is it possible to extract this into a helper function template?
> 
> I'm not a huge fan of using macros like this, as the macro definition is 
> harder to read (e.g. its tokens don't get semantic highlighting) and edit 
> (e.g. completion).
Oops, of course.



Comment at: clang-tools-extra/clangd/AST.h:136
+// FIXME: handle more type patterns.
+llvm::Optional getContainedAutoParamType(TypeLoc TL);
+

nridge wrote:
> Why `Optional` if `TypeLoc` can represent a null type loc?
It was to match getContainedAutoParamType, which I guess wanted to be explicit 
about the fact that we may not find one. But this isn't common, so I've dropped 
it.



Comment at: clang-tools-extra/clangd/InlayHints.cpp:323
+   "Instantiated function has fewer (non-pack) parameters?");
+return InstantiatedFunction->getParamDecl(ParamIdx);
+  }

nridge wrote:
> Here's a test case which slips past these checks:
> 
> ```
> int waldo(auto... args, auto last);
> int x = waldo(1, 2.0, 'x');
> ```
> 
> `last` incorrectly gets `float` (rather than `char`) as a hint
Ah, good catch! For some reason I had it in my head that a pack had to be at 
the end. (It can't be deduced though? Weird...)

I made this give up hinting once we see a pack.

Added that test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120258

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


[PATCH] D120258: [clangd] Add inlay hints for auto-typed parameters with one instantiation.

2022-02-22 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 410482.
sammccall marked 3 inline comments as done.
sammccall added a comment.

address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120258

Files:
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/AST.h
  clang-tools-extra/clangd/InlayHints.cpp
  clang-tools-extra/clangd/unittests/ASTTests.cpp
  clang-tools-extra/clangd/unittests/InlayHintTests.cpp
  clang-tools-extra/clangd/unittests/TestTU.cpp

Index: clang-tools-extra/clangd/unittests/TestTU.cpp
===
--- clang-tools-extra/clangd/unittests/TestTU.cpp
+++ clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -247,7 +247,7 @@
   Visitor.F = Filter;
   Visitor.TraverseDecl(AST.getASTContext().getTranslationUnitDecl());
   if (Visitor.Decls.size() != 1) {
-llvm::errs() << Visitor.Decls.size() << " symbols matched.";
+llvm::errs() << Visitor.Decls.size() << " symbols matched.\n";
 assert(Visitor.Decls.size() == 1);
   }
   return *Visitor.Decls.front();
Index: clang-tools-extra/clangd/unittests/InlayHintTests.cpp
===
--- clang-tools-extra/clangd/unittests/InlayHintTests.cpp
+++ clang-tools-extra/clangd/unittests/InlayHintTests.cpp
@@ -58,7 +58,7 @@
 return false;
   }
   if (arg.range != Code.range(Expected.RangeName)) {
-*result_listener << "range is " << arg.label << " but $"
+*result_listener << "range is " << llvm::to_string(arg.range) << " but $"
  << Expected.RangeName << " is "
  << llvm::to_string(Code.range(Expected.RangeName));
 return false;
@@ -81,7 +81,7 @@
  ExpectedHints... Expected) {
   Annotations Source(AnnotatedSource);
   TestTU TU = TestTU::withCode(Source.code());
-  TU.ExtraArgs.push_back("-std=c++14");
+  TU.ExtraArgs.push_back("-std=c++20");
   auto AST = TU.build();
 
   EXPECT_THAT(hintsOfKind(AST, Kind),
@@ -676,6 +676,22 @@
   ExpectedHint{": int", "var"});
 }
 
+TEST(TypeHints, SinglyInstantiatedTemplate) {
+  assertTypeHints(R"cpp(
+auto $lambda[[x]] = [](auto *$param[[y]]) { return 42; };
+int m = x("foo");
+  )cpp",
+  ExpectedHint{": (lambda)", "lambda"},
+  ExpectedHint{": const char *", "param"});
+
+  // No hint for packs, or auto params following packs
+  assertTypeHints(R"cpp(
+int x(auto $a[[a]], auto... b, auto c) { return 42; }
+int m = x(nullptr, 'c', 2.0, 2);
+  )cpp",
+  ExpectedHint{": void *", "a"});
+}
+
 TEST(DesignatorHints, Basic) {
   assertDesignatorHints(R"cpp(
 struct S { int x, y, z; };
Index: clang-tools-extra/clangd/unittests/ASTTests.cpp
===
--- clang-tools-extra/clangd/unittests/ASTTests.cpp
+++ clang-tools-extra/clangd/unittests/ASTTests.cpp
@@ -30,6 +30,7 @@
 namespace {
 using testing::Contains;
 using testing::Each;
+using testing::IsEmpty;
 
 TEST(GetDeducedType, KwAutoKwDecltypeExpansion) {
   struct Test {
@@ -192,12 +193,12 @@
   R"cpp(
 // Generic lambda instantiated twice, matching deduction.
 struct Foo{};
-using Bar = Foo;
 auto Generic = [](^auto x, auto y) { return 0; };
-int m = Generic(Bar{}, "one");
+int m = Generic(Foo{}, "one");
 int n = Generic(Foo{}, 2);
   )cpp",
-  "struct Foo",
+  // No deduction although both instantiations yield the same result :-(
+  nullptr,
   },
   {
   R"cpp(
@@ -253,6 +254,117 @@
   }
 }
 
+TEST(ClangdAST, GetOnlyInstantiation) {
+  struct {
+const char *Code;
+llvm::StringLiteral NodeType;
+const char *Name;
+  } Cases[] = {
+  {
+  R"cpp(
+template  class X {};
+X x;
+  )cpp",
+  "CXXRecord",
+  "template<> class X {}",
+  },
+  {
+  R"cpp(
+template  T X = T{};
+int y = X;
+  )cpp",
+  "Var",
+  // VarTemplateSpecializationDecl doesn't print as template<>...
+  "char X = char{}",
+  },
+  {
+  R"cpp(
+template  int X(T) { return 42; }
+int y = X("text");
+  )cpp",
+  "Function",
+  "template<> int X(const char *)",
+  },
+  {
+  R"cpp(
+int X(auto *x) { return 42; }
+int y = X("text");
+  )cpp",
+  "Function",
+  "template<> int X(const char *x)",
+  },
+  };
+
+  for (const auto &Case : Cases) {
+SCOPED_TRACE(Case.Code);
+auto TU = TestTU::withCode(Case.Code);
+TU.ExtraArgs.push_back("-std=c++20");
+auto AST = TU.build();
+PrintingPolicy PP = AST.getASTContext().getPrintingPolicy();
+PP.TerseOutput = true;
+std::stri

[PATCH] D120306: [clangd] IncludeCleaner: Add support for IWYU pragma private

2022-02-22 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

What's the policy this patch intends to implement?

I'm a little concerned by building up maps of filenames with segment limits - 
it looks like some kind of heuristic/partial matching.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120306

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


[PATCH] D91164: [clang-tidy] Improve C++ support in bugprone-signal-handler.

2022-02-22 Thread Balázs Kéri via Phabricator via cfe-commits
balazske abandoned this revision.
balazske added a comment.
Herald added subscribers: carlosgalvezp, steakhal.

Newer revision: D118996 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91164

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


[PATCH] D120254: [OpenCL] Align subgroup builtin guards

2022-02-22 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov accepted this revision.
azabaznov added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks!




Comment at: clang/lib/Headers/opencl-c-base.h:85
+// Internal feature macro to provide subgroup builtins.
+#define __opencl_subgroup_builtins 1
+#endif

svenvh wrote:
> I'm in doubt whether we could just reuse `__opencl_c_subgroups` for this?
I think we couldn't. Those subgroup features/extensions are different, as 
implementation may support the extension but not the feature. The difference is 
in subgroup independent forward progress: for example, it's required by the 
extension, but optional in OpenCL C 3.0 feature.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120254

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


[clang] c9cc803 - [C++20][Modules][2/8] Add enumerations for partition modules and stream them.

2022-02-22 Thread Iain Sandoe via cfe-commits

Author: Iain Sandoe
Date: 2022-02-22T10:08:15Z
New Revision: c9cc8035eb4fbf5d20a73ec7e0870e6195012a71

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

LOG: [C++20][Modules][2/8] Add enumerations for partition modules and stream 
them.

This is an initial enabling patch for module partition support.
We add enumerations for partition interfaces/implementations.

This means that the module kind enumeration now occupies three
bits, so the AST streamer is adjusted for this.  Adding one bit there
seems preferable to trying to overload the meanings of existing
kinds (and we will also want to add a C++20 header unit case later).

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

Added: 


Modified: 
clang/include/clang/Basic/Module.h
clang/lib/AST/Decl.cpp
clang/lib/Sema/SemaModule.cpp
clang/lib/Serialization/ASTWriter.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/Module.h 
b/clang/include/clang/Basic/Module.h
index de7857347bc2..b05d3c654e72 100644
--- a/clang/include/clang/Basic/Module.h
+++ b/clang/include/clang/Basic/Module.h
@@ -106,9 +106,15 @@ class Module {
 /// of header files.
 ModuleMapModule,
 
-/// This is a C++ Modules TS module interface unit.
+/// This is a C++20 module interface unit.
 ModuleInterfaceUnit,
 
+/// This is a C++ 20 module partition interface.
+ModulePartitionInterface,
+
+/// This is a C++ 20 module partition implementation.
+ModulePartitionImplementation,
+
 /// This is a fragment of the global module within some C++ module.
 GlobalModuleFragment,
 
@@ -150,7 +156,9 @@ class Module {
 
   /// Does this Module scope describe part of the purview of a named C++ 
module?
   bool isModulePurview() const {
-return Kind == ModuleInterfaceUnit || Kind == PrivateModuleFragment;
+return Kind == ModuleInterfaceUnit || Kind == ModulePartitionInterface ||
+   Kind == ModulePartitionImplementation ||
+   Kind == PrivateModuleFragment;
   }
 
   /// Does this Module scope describe a fragment of the global module within
@@ -506,6 +514,9 @@ class Module {
 Parent->SubModules.push_back(this);
   }
 
+  /// Is this a module partition.
+  bool isModulePartition() const { return Name.find(':') != std::string::npos; 
}
+
   /// Retrieve the full name of this module, including the path from
   /// its top-level module.
   /// \param AllowStringLiterals If \c true, components that might not be

diff  --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 030da7f55fac..82c4412296db 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -1550,6 +1550,8 @@ Module *Decl::getOwningModuleForLinkage(bool 
IgnoreLinkage) const {
 return nullptr;
 
   case Module::ModuleInterfaceUnit:
+  case Module::ModulePartitionInterface:
+  case Module::ModulePartitionImplementation:
 return M;
 
   case Module::GlobalModuleFragment: {

diff  --git a/clang/lib/Sema/SemaModule.cpp b/clang/lib/Sema/SemaModule.cpp
index 9bed3cb769f7..bd5b900e5d38 100644
--- a/clang/lib/Sema/SemaModule.cpp
+++ b/clang/lib/Sema/SemaModule.cpp
@@ -261,6 +261,8 @@ Sema::ActOnPrivateModuleFragmentDecl(SourceLocation 
ModuleLoc,
: ModuleScopes.back().Module->Kind) {
   case Module::ModuleMapModule:
   case Module::GlobalModuleFragment:
+  case Module::ModulePartitionImplementation:
+  case Module::ModulePartitionInterface:
 Diag(PrivateLoc, diag::err_private_module_fragment_not_module);
 return nullptr;
 

diff  --git a/clang/lib/Serialization/ASTWriter.cpp 
b/clang/lib/Serialization/ASTWriter.cpp
index a126e12bcbd9..cf42e529a8d6 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -2674,7 +2674,7 @@ void ASTWriter::WriteSubmodules(Module *WritingModule) {
   Abbrev->Add(BitCodeAbbrevOp(SUBMODULE_DEFINITION));
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ID
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Parent
-  Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // Kind
+  Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // Kind
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsFramework
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsExplicit
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsSystem



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


[PATCH] D114714: [C++20][Modules][2/8] Add enumerations for partition modules and stream them.

2022-02-22 Thread Iain Sandoe 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 rGc9cc8035eb4f: [C++20][Modules][2/8] Add enumerations for 
partition modules and stream them. (authored by iains).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114714

Files:
  clang/include/clang/Basic/Module.h
  clang/lib/AST/Decl.cpp
  clang/lib/Sema/SemaModule.cpp
  clang/lib/Serialization/ASTWriter.cpp


Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -2674,7 +2674,7 @@
   Abbrev->Add(BitCodeAbbrevOp(SUBMODULE_DEFINITION));
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ID
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Parent
-  Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // Kind
+  Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // Kind
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsFramework
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsExplicit
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsSystem
Index: clang/lib/Sema/SemaModule.cpp
===
--- clang/lib/Sema/SemaModule.cpp
+++ clang/lib/Sema/SemaModule.cpp
@@ -261,6 +261,8 @@
: ModuleScopes.back().Module->Kind) {
   case Module::ModuleMapModule:
   case Module::GlobalModuleFragment:
+  case Module::ModulePartitionImplementation:
+  case Module::ModulePartitionInterface:
 Diag(PrivateLoc, diag::err_private_module_fragment_not_module);
 return nullptr;
 
Index: clang/lib/AST/Decl.cpp
===
--- clang/lib/AST/Decl.cpp
+++ clang/lib/AST/Decl.cpp
@@ -1550,6 +1550,8 @@
 return nullptr;
 
   case Module::ModuleInterfaceUnit:
+  case Module::ModulePartitionInterface:
+  case Module::ModulePartitionImplementation:
 return M;
 
   case Module::GlobalModuleFragment: {
Index: clang/include/clang/Basic/Module.h
===
--- clang/include/clang/Basic/Module.h
+++ clang/include/clang/Basic/Module.h
@@ -106,9 +106,15 @@
 /// of header files.
 ModuleMapModule,
 
-/// This is a C++ Modules TS module interface unit.
+/// This is a C++20 module interface unit.
 ModuleInterfaceUnit,
 
+/// This is a C++ 20 module partition interface.
+ModulePartitionInterface,
+
+/// This is a C++ 20 module partition implementation.
+ModulePartitionImplementation,
+
 /// This is a fragment of the global module within some C++ module.
 GlobalModuleFragment,
 
@@ -150,7 +156,9 @@
 
   /// Does this Module scope describe part of the purview of a named C++ 
module?
   bool isModulePurview() const {
-return Kind == ModuleInterfaceUnit || Kind == PrivateModuleFragment;
+return Kind == ModuleInterfaceUnit || Kind == ModulePartitionInterface ||
+   Kind == ModulePartitionImplementation ||
+   Kind == PrivateModuleFragment;
   }
 
   /// Does this Module scope describe a fragment of the global module within
@@ -506,6 +514,9 @@
 Parent->SubModules.push_back(this);
   }
 
+  /// Is this a module partition.
+  bool isModulePartition() const { return Name.find(':') != std::string::npos; 
}
+
   /// Retrieve the full name of this module, including the path from
   /// its top-level module.
   /// \param AllowStringLiterals If \c true, components that might not be


Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -2674,7 +2674,7 @@
   Abbrev->Add(BitCodeAbbrevOp(SUBMODULE_DEFINITION));
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ID
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Parent
-  Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // Kind
+  Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // Kind
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsFramework
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsExplicit
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsSystem
Index: clang/lib/Sema/SemaModule.cpp
===
--- clang/lib/Sema/SemaModule.cpp
+++ clang/lib/Sema/SemaModule.cpp
@@ -261,6 +261,8 @@
: ModuleScopes.back().Module->Kind) {
   case Module::ModuleMapModule:
   case Module::GlobalModuleFragment:
+  case Module::ModulePartitionImplementation:
+  case Module::ModulePartitionInterface:
 Diag(PrivateLoc, diag::err_private_module_fragment_not_module);
 return nullptr;
 
I

[PATCH] D120313: [clang][www] Port make_cxx_dr_status script to Python3

2022-02-22 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: rsmith, aaron.ballman.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

And run it to re-generate the cxx_dr_status.html


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120313

Files:
  clang/www/cxx_dr_status.html
  clang/www/make_cxx_dr_status

Index: clang/www/make_cxx_dr_status
===
--- clang/www/make_cxx_dr_status
+++ clang/www/make_cxx_dr_status
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
 import sys, os, re
 
 index = 'cwg_index.html'
@@ -10,7 +10,7 @@
 elif len(sys.argv) == 2:
   index = sys.argv[1]
 else:
-  print >>sys.stderr, 'Usage: make_drs []'
+  print('Usage: make_drs []', file=sys.stderr)
   sys.exit(1)
 
 class DR:
@@ -38,17 +38,16 @@
 continue
   test_cpp = os.path.join(dr_test_dir, test_cpp)
   found_any = False;
-  for match in re.finditer(status_re, file(test_cpp, 'r').read()):
+  for match in re.finditer(status_re, open(test_cpp, 'r').read()):
 status_map[int(match.group(1))] = match.group(2)
 found_any = True
   if not found_any:
-print >> sys.stderr, "warning:%s: no '// dr123: foo' comments in this file" % test_cpp
+print("warning:%s: no '// dr123: foo' comments in this file" % test_cpp, file=sys.stderr)
 
-drs = sorted((parse(dr) for dr in file(index, 'r').read().split('')[2:]),
+drs = sorted((parse(dr) for dr in open(index, 'r').read().split('')[2:]),
  key = lambda dr: dr.issue)
-out_file = file(output, 'w')
-
-print >> out_file, '''\
+out_file = open(output, 'w')
+out_file.write('''\
 http://www.w3.org/TR/html4/strict.dtd";>
 
@@ -90,7 +89,7 @@
 Status
 Issue title
 Available in Clang?
-  '''
+  ''')
 
 latest_release = 13
 
@@ -143,7 +142,7 @@
   try:
 _, avail_style = availability(int(dup))
   except:
-print >>sys.stderr, "issue %s marked as sup %s" % (issue, dup)
+print("issue %s marked as sup %s" % (issue, dup), file=sys.stderr)
 avail_style = ' class="none"'
   elif status.startswith('dup '):
 dup = int(status.split(' ', 1)[1])
@@ -174,20 +173,21 @@
 if not avail.startswith('Sup') and not avail.startswith('Dup'):
   count[avail] = count.get(avail, 0) + 1
 
-  print >> out_file, '''\
+  out_file.write('''
   
 https://wg21.link/cwg%s";>%s
 %s
 %s
 %s
-  ''' % (row_style, dr.issue, dr.issue, dr.issue, dr.status, dr.title, avail_style, avail)
+  ''' % (row_style, dr.issue, dr.issue, dr.issue, dr.status, dr.title, avail_style, avail))
 
 for status, num in sorted(count.items()):
-  print "%s: %s" % (status, num)
+  print("%s: %s" % (status, num))
 
-print >> out_file, '''\
+out_file.write('''\
 
 
 
 
-'''
+''')
+out_file.close()
Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -7304,11 +7304,11 @@
 Updating Annex C to C99
 Not resolved
   
-  
+  
 https://wg21.link/cwg1249";>1249
-drafting
+DRWP
 Cv-qualification of nested lambda capture
-Not resolved
+Unknown
   
   
 https://wg21.link/cwg1250";>1250
@@ -10006,9 +10006,9 @@
   
   
 https://wg21.link/cwg1699";>1699
-open
+extension
 Does befriending a class befriend its friends?
-Not resolved
+Extension
   
   
 https://wg21.link/cwg1700";>1700
@@ -10154,11 +10154,11 @@
 Multicharacter user-defined character literals
 Not resolved
   
-  
+  
 https://wg21.link/cwg1724";>1724
-drafting
+DRWP
 Unclear rules for deduction failure
-Not resolved
+Unknown
   
   
 https://wg21.link/cwg1725";>1725
@@ -10166,11 +10166,11 @@
 Trailing return type with nested function declarator
 Unknown
   
-  
+  
 https://wg21.link/cwg1726";>1726
-drafting
+DR
 Declarator operators and conversion function
-Not resolved
+Unknown
   
   
 https://wg21.link/cwg1727";>1727
@@ -10208,11 +10208,11 @@
 Defining types in conditions and range-based for statements
 Unknown
   
-  
+  
 https://wg21.link/cwg1733";>1733
-drafting
+DRWP
 Return type and value for operator= with ref-qualifier
-Not resolved
+Unknown
   
   
 https://wg21.link/cwg1734";>1734
@@ -14154,7 +14154,7 @@
 https://wg21.link/cwg2390";>2390
 CD5
 Is the argument of __has_cpp_attribute macro-expanded?
-Unknown
+Yes
   
   
 https://wg21.link/cwg2391";>2391
@@ -14194,7 +14194,7 @@
   
   
 https://wg21.link/cwg2397";>2397
-DR
+DRWP
 auto specifier for pointers and references to arrays
 Unknown
   
@@ -14250,7 +14250,7 @@
 https://wg21.link/cwg2406";>2406
 CD5
 [[fallthrough]] attribute and iteration statements
-Unknown
+Yes
   
   
 https://wg21.link/cwg2407";>2407
@@ -14500,7 +14500,7 @@
   
   
 h

[clang] e7e17b3 - [OpenCL] opencl-c.h: use uint/ulong consistently

2022-02-22 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2022-02-22T10:15:40Z
New Revision: e7e17b30d02d4f0035fef92850d529f16849c6f0

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

LOG: [OpenCL] opencl-c.h: use uint/ulong consistently

Most places already seem to use the short spelling instead of
'unsigned int/long', so perform the following substitutions:

  s/unsigned int /uint /g
  s/unsigned long /ulong /g

This simplifies completeness comparisons against OpenCLBuiltins.td.

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

Added: 


Modified: 
clang/lib/Headers/opencl-c.h

Removed: 




diff  --git a/clang/lib/Headers/opencl-c.h b/clang/lib/Headers/opencl-c.h
index 6c9c3cacf3ec..18c1c317e100 100644
--- a/clang/lib/Headers/opencl-c.h
+++ b/clang/lib/Headers/opencl-c.h
@@ -12919,28 +12919,28 @@ void __ovld prefetch(const __global half16 *p, size_t 
num_elements);
  * pointed by p. The function returns old.
  */
 int __ovld atomic_add(volatile __global int *p, int val);
-unsigned int __ovld atomic_add(volatile __global unsigned int *p, unsigned int 
val);
+uint __ovld atomic_add(volatile __global uint *p, uint val);
 int __ovld atomic_add(volatile __local int *p, int val);
-unsigned int __ovld atomic_add(volatile __local unsigned int *p, unsigned int 
val);
+uint __ovld atomic_add(volatile __local uint *p, uint val);
 #ifdef __OPENCL_CPP_VERSION__
 int __ovld atomic_add(volatile int *p, int val);
-unsigned int __ovld atomic_add(volatile unsigned int *p, unsigned int val);
+uint __ovld atomic_add(volatile uint *p, uint val);
 #endif
 
 #if defined(cl_khr_global_int32_base_atomics)
 int __ovld atom_add(volatile __global int *p, int val);
-unsigned int __ovld atom_add(volatile __global unsigned int *p, unsigned int 
val);
+uint __ovld atom_add(volatile __global uint *p, uint val);
 #endif
 #if defined(cl_khr_local_int32_base_atomics)
 int __ovld atom_add(volatile __local int *p, int val);
-unsigned int __ovld atom_add(volatile __local unsigned int *p, unsigned int 
val);
+uint __ovld atom_add(volatile __local uint *p, uint val);
 #endif
 
 #if defined(cl_khr_int64_base_atomics)
 long __ovld atom_add(volatile __global long *p, long val);
-unsigned long __ovld atom_add(volatile __global unsigned long *p, unsigned 
long val);
+ulong __ovld atom_add(volatile __global ulong *p, ulong val);
 long __ovld atom_add(volatile __local long *p, long val);
-unsigned long __ovld atom_add(volatile __local unsigned long *p, unsigned long 
val);
+ulong __ovld atom_add(volatile __local ulong *p, ulong val);
 #endif
 
 /**
@@ -12949,28 +12949,28 @@ unsigned long __ovld atom_add(volatile __local 
unsigned long *p, unsigned long v
  * returns old.
  */
 int __ovld atomic_sub(volatile __global int *p, int val);
-unsigned int __ovld atomic_sub(volatile __global unsigned int *p, unsigned int 
val);
+uint __ovld atomic_sub(volatile __global uint *p, uint val);
 int __ovld atomic_sub(volatile __local int *p, int val);
-unsigned int __ovld atomic_sub(volatile __local unsigned int *p, unsigned int 
val);
+uint __ovld atomic_sub(volatile __local uint *p, uint val);
 #ifdef __OPENCL_CPP_VERSION__
 int __ovld atomic_sub(volatile int *p, int val);
-unsigned int __ovld atomic_sub(volatile unsigned int *p, unsigned int val);
+uint __ovld atomic_sub(volatile uint *p, uint val);
 #endif
 
 #if defined(cl_khr_global_int32_base_atomics)
 int __ovld atom_sub(volatile __global int *p, int val);
-unsigned int __ovld atom_sub(volatile __global unsigned int *p, unsigned int 
val);
+uint __ovld atom_sub(volatile __global uint *p, uint val);
 #endif
 #if defined(cl_khr_local_int32_base_atomics)
 int __ovld atom_sub(volatile __local int *p, int val);
-unsigned int __ovld atom_sub(volatile __local unsigned int *p, unsigned int 
val);
+uint __ovld atom_sub(volatile __local uint *p, uint val);
 #endif
 
 #if defined(cl_khr_int64_base_atomics)
 long __ovld atom_sub(volatile __global long *p, long val);
-unsigned long __ovld atom_sub(volatile __global unsigned long *p, unsigned 
long val);
+ulong __ovld atom_sub(volatile __global ulong *p, ulong val);
 long __ovld atom_sub(volatile __local long *p, long val);
-unsigned long __ovld atom_sub(volatile __local unsigned long *p, unsigned long 
val);
+ulong __ovld atom_sub(volatile __local ulong *p, ulong val);
 #endif
 
 /**
@@ -12979,31 +12979,31 @@ unsigned long __ovld atom_sub(volatile __local 
unsigned long *p, unsigned long v
  * value.
  */
 int __ovld atomic_xchg(volatile __global int *p, int val);
-unsigned int __ovld atomic_xchg(volatile __global unsigned int *p, unsigned 
int val);
+uint __ovld atomic_xchg(volatile __global uint *p, uint val);
 int __ovld atomic_xchg(volatile __local int *p, int val);
-unsigned int __ovld atomic_xchg(volatile __local unsigned int *p, unsigned int 
val);
+u

[PATCH] D120032: [OpenCL] opencl-c.h: use uint/ulong consistently

2022-02-22 Thread Sven van Haastregt via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe7e17b30d02d: [OpenCL] opencl-c.h: use uint/ulong 
consistently (authored by svenvh).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120032

Files:
  clang/lib/Headers/opencl-c.h

Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -12919,28 +12919,28 @@
  * pointed by p. The function returns old.
  */
 int __ovld atomic_add(volatile __global int *p, int val);
-unsigned int __ovld atomic_add(volatile __global unsigned int *p, unsigned int val);
+uint __ovld atomic_add(volatile __global uint *p, uint val);
 int __ovld atomic_add(volatile __local int *p, int val);
-unsigned int __ovld atomic_add(volatile __local unsigned int *p, unsigned int val);
+uint __ovld atomic_add(volatile __local uint *p, uint val);
 #ifdef __OPENCL_CPP_VERSION__
 int __ovld atomic_add(volatile int *p, int val);
-unsigned int __ovld atomic_add(volatile unsigned int *p, unsigned int val);
+uint __ovld atomic_add(volatile uint *p, uint val);
 #endif
 
 #if defined(cl_khr_global_int32_base_atomics)
 int __ovld atom_add(volatile __global int *p, int val);
-unsigned int __ovld atom_add(volatile __global unsigned int *p, unsigned int val);
+uint __ovld atom_add(volatile __global uint *p, uint val);
 #endif
 #if defined(cl_khr_local_int32_base_atomics)
 int __ovld atom_add(volatile __local int *p, int val);
-unsigned int __ovld atom_add(volatile __local unsigned int *p, unsigned int val);
+uint __ovld atom_add(volatile __local uint *p, uint val);
 #endif
 
 #if defined(cl_khr_int64_base_atomics)
 long __ovld atom_add(volatile __global long *p, long val);
-unsigned long __ovld atom_add(volatile __global unsigned long *p, unsigned long val);
+ulong __ovld atom_add(volatile __global ulong *p, ulong val);
 long __ovld atom_add(volatile __local long *p, long val);
-unsigned long __ovld atom_add(volatile __local unsigned long *p, unsigned long val);
+ulong __ovld atom_add(volatile __local ulong *p, ulong val);
 #endif
 
 /**
@@ -12949,28 +12949,28 @@
  * returns old.
  */
 int __ovld atomic_sub(volatile __global int *p, int val);
-unsigned int __ovld atomic_sub(volatile __global unsigned int *p, unsigned int val);
+uint __ovld atomic_sub(volatile __global uint *p, uint val);
 int __ovld atomic_sub(volatile __local int *p, int val);
-unsigned int __ovld atomic_sub(volatile __local unsigned int *p, unsigned int val);
+uint __ovld atomic_sub(volatile __local uint *p, uint val);
 #ifdef __OPENCL_CPP_VERSION__
 int __ovld atomic_sub(volatile int *p, int val);
-unsigned int __ovld atomic_sub(volatile unsigned int *p, unsigned int val);
+uint __ovld atomic_sub(volatile uint *p, uint val);
 #endif
 
 #if defined(cl_khr_global_int32_base_atomics)
 int __ovld atom_sub(volatile __global int *p, int val);
-unsigned int __ovld atom_sub(volatile __global unsigned int *p, unsigned int val);
+uint __ovld atom_sub(volatile __global uint *p, uint val);
 #endif
 #if defined(cl_khr_local_int32_base_atomics)
 int __ovld atom_sub(volatile __local int *p, int val);
-unsigned int __ovld atom_sub(volatile __local unsigned int *p, unsigned int val);
+uint __ovld atom_sub(volatile __local uint *p, uint val);
 #endif
 
 #if defined(cl_khr_int64_base_atomics)
 long __ovld atom_sub(volatile __global long *p, long val);
-unsigned long __ovld atom_sub(volatile __global unsigned long *p, unsigned long val);
+ulong __ovld atom_sub(volatile __global ulong *p, ulong val);
 long __ovld atom_sub(volatile __local long *p, long val);
-unsigned long __ovld atom_sub(volatile __local unsigned long *p, unsigned long val);
+ulong __ovld atom_sub(volatile __local ulong *p, ulong val);
 #endif
 
 /**
@@ -12979,31 +12979,31 @@
  * value.
  */
 int __ovld atomic_xchg(volatile __global int *p, int val);
-unsigned int __ovld atomic_xchg(volatile __global unsigned int *p, unsigned int val);
+uint __ovld atomic_xchg(volatile __global uint *p, uint val);
 int __ovld atomic_xchg(volatile __local int *p, int val);
-unsigned int __ovld atomic_xchg(volatile __local unsigned int *p, unsigned int val);
+uint __ovld atomic_xchg(volatile __local uint *p, uint val);
 float __ovld atomic_xchg(volatile __global float *p, float val);
 float __ovld atomic_xchg(volatile __local float *p, float val);
 #ifdef __OPENCL_CPP_VERSION__
 int __ovld atomic_xchg(volatile int *p, int val);
-unsigned int __ovld atomic_xchg(volatile unsigned int *p, unsigned int val);
+uint __ovld atomic_xchg(volatile uint *p, uint val);
 float __ovld atomic_xchg(volatile float *p, float val);
 #endif
 
 #if defined(cl_khr_global_int32_base_atomics)
 int __ovld atom_xchg(volatile __global int *p, int val);
-unsigned int __ovld atom_xchg(volatile __global unsigned int *p, unsigned int val);
+u

[PATCH] D120258: [clangd] Add inlay hints for auto-typed parameters with one instantiation.

2022-02-22 Thread Trass3r via Phabricator via cfe-commits
Trass3r added a comment.

> I don't have a good sense for how common the "multiple instantiations, same 
> type" scenario is; perhaps @Trass3r has an opinion on that.

Hmm you said the function needs to be defined in the cpp file, right? Then I 
guess lambdas are indeed the main use-case. I've seen them getting reused 
sometimes, though just for generic error callbacks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120258

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


[PATCH] D118757: [AArch64] Remove unused feature flags from AArch64TargetInfo

2022-02-22 Thread Victor Campos via Phabricator via cfe-commits
vhscampos accepted this revision.
vhscampos added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118757

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


[PATCH] D120306: [clangd] IncludeCleaner: Add support for IWYU pragma private

2022-02-22 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added a comment.

In D120306#3337212 , @sammccall wrote:

> What's the policy this patch intends to implement?
>
> I'm a little concerned by building up maps of filenames with segment limits - 
> it looks like some kind of heuristic/partial matching.

Basically, handling the mappings that. IWYU pragmas provide.

Are you concerned about the limit itself or the way I'm trying to find these 
headers in general? I was afraid of consuming too much memory, hence the limit; 
it's not crucial to the implementation, though, I can remove it if your concern 
is the limit rather than the approach.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120306

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


[PATCH] D120306: [clangd] IncludeCleaner: Add support for IWYU pragma private

2022-02-22 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 410490.
kbobyrev added a comment.

Move suffix map to CanonicalIncludes (where it logically belongs), remove
component limit there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120306

Files:
  clang-tools-extra/clangd/Headers.cpp
  clang-tools-extra/clangd/Headers.h
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/IncludeCleaner.h
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/index/CanonicalIncludes.cpp
  clang-tools-extra/clangd/index/CanonicalIncludes.h
  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
@@ -266,8 +266,9 @@
 
 ReferencedLocations Locs = findReferencedLocations(AST);
 EXPECT_THAT(Locs.Stdlib, ElementsAreArray(WantSyms));
-ReferencedFiles Files = findReferencedFiles(Locs, AST.getIncludeStructure(),
-AST.getSourceManager());
+ReferencedFiles Files =
+findReferencedFiles(Locs, AST.getIncludeStructure(),
+AST.getCanonicalIncludes(), AST.getSourceManager());
 EXPECT_THAT(Files.Stdlib, ElementsAreArray(WantHeaders));
   }
 }
@@ -378,8 +379,8 @@
   auto &SM = AST.getSourceManager();
   auto &Includes = AST.getIncludeStructure();
 
-  auto ReferencedFiles =
-  findReferencedFiles(findReferencedLocations(AST), Includes, SM);
+  auto ReferencedFiles = findReferencedFiles(
+  findReferencedLocations(AST), Includes, AST.getCanonicalIncludes(), SM);
   llvm::StringSet<> ReferencedFileNames;
   for (FileID FID : ReferencedFiles.User)
 ReferencedFileNames.insert(
@@ -427,9 +428,9 @@
 
   ParsedAST AST = TU.build();
 
-  auto ReferencedFiles =
-  findReferencedFiles(findReferencedLocations(AST),
-  AST.getIncludeStructure(), AST.getSourceManager());
+  auto ReferencedFiles = findReferencedFiles(
+  findReferencedLocations(AST), AST.getIncludeStructure(),
+  AST.getCanonicalIncludes(), AST.getSourceManager());
   llvm::StringSet<> ReferencedFileNames;
   auto &SM = AST.getSourceManager();
   for (FileID FID : ReferencedFiles.User)
@@ -461,9 +462,9 @@
 
   ParsedAST AST = TU.build();
 
-  auto ReferencedFiles =
-  findReferencedFiles(findReferencedLocations(AST),
-  AST.getIncludeStructure(), AST.getSourceManager());
+  auto ReferencedFiles = findReferencedFiles(
+  findReferencedLocations(AST), AST.getIncludeStructure(),
+  AST.getCanonicalIncludes(), AST.getSourceManager());
   llvm::StringSet<> ReferencedFileNames;
   auto &SM = AST.getSourceManager();
   for (FileID FID : ReferencedFiles.User)
@@ -483,9 +484,9 @@
   TU.AdditionalFiles["behind_keep.h"] = guard("");
   ParsedAST AST = TU.build();
 
-  auto ReferencedFiles =
-  findReferencedFiles(findReferencedLocations(AST),
-  AST.getIncludeStructure(), AST.getSourceManager());
+  auto ReferencedFiles = findReferencedFiles(
+  findReferencedLocations(AST), AST.getIncludeStructure(),
+  AST.getCanonicalIncludes(), AST.getSourceManager());
   EXPECT_TRUE(ReferencedFiles.User.empty());
   EXPECT_THAT(AST.getDiagnostics(), llvm::ValueIs(IsEmpty()));
 }
Index: clang-tools-extra/clangd/index/CanonicalIncludes.h
===
--- clang-tools-extra/clangd/index/CanonicalIncludes.h
+++ clang-tools-extra/clangd/index/CanonicalIncludes.h
@@ -19,6 +19,7 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_CANONICALINCLUDES_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_CANONICALINCLUDES_H
 
+#include "clang/Lex/PPCallbacks.h"
 #include "clang/Lex/Preprocessor.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
@@ -54,9 +55,14 @@
   /// headers.
   void addSystemHeadersMapping(const LangOptions &Language);
 
+  void addHeader(llvm::StringRef Header);
+
+  llvm::StringRef suffixToHeader(llvm::StringRef Suffix) const;
+
 private:
   /// A map from full include path to a canonical path.
   llvm::StringMap FullPathMapping;
+  llvm::StringMap SuffixToFullPathMapping;
   /// A map from a suffix (one or components of a path) to a canonical path.
   /// Used only for mapping standard headers.
   const llvm::StringMap *StdSuffixHeaderMapping = nullptr;
@@ -89,6 +95,8 @@
 std::unique_ptr
 collectIWYUHeaderMaps(CanonicalIncludes *Includes);
 
+std::unique_ptr collectSuffixMappings(CanonicalIncludes *Includes);
+
 } // namespace clangd
 } // namespace clang
 
Index: clang-tools-extra/clangd/index/CanonicalIncludes.cpp
===
--- clang-tools-extra/clangd/ind

[PATCH] D120134: [analyzer] refactor makeIntValWithPtrWidth, remove getZeroWithPtrWidth (NFC)

2022-02-22 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers updated this revision to Diff 410493.
vabridgers added a comment.

Update per @steakhal comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120134

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
  clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/lib/StaticAnalyzer/Core/SValBuilder.cpp


Index: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -742,9 +742,6 @@
   // This change is needed for architectures with varying
   // pointer widths. See the amdgcn opencl reproducer with
   // this change as an example: solver-sym-simplification-ptr-bool.cl
-  // FIXME: Cleanup remainder of `getZeroWithPtrWidth ()`
-  //and `getIntWithPtrWidth()` functions to prevent future
-  //confusion
   if (!Ty->isReferenceType())
 return makeNonLoc(Sym, BO_NE, BasicVals.getZeroWithTypeSize(Ty),
   CastTy);
Index: clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -1342,8 +1342,9 @@
 case Stmt::GNUNullExprClass: {
   // GNU __null is a pointer-width integer, not an actual pointer.
   ProgramStateRef state = Pred->getState();
-  state = state->BindExpr(S, Pred->getLocationContext(),
-  svalBuilder.makeIntValWithPtrWidth(0, false));
+  state = state->BindExpr(
+  S, Pred->getLocationContext(),
+  svalBuilder.makeIntValWithWidth(getContext().VoidPtrTy, 0));
   Bldr.generateNode(S, Pred, state);
   break;
 }
Index: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -2565,9 +2565,9 @@
 return nullptr;
 
   // Compare the size argument to 0.
-  DefinedOrUnknownSVal SizeZero =
-svalBuilder.evalEQ(State, TotalSize.castAs(),
-   svalBuilder.makeIntValWithPtrWidth(0, false));
+  DefinedOrUnknownSVal SizeZero = svalBuilder.evalEQ(
+  State, TotalSize.castAs(),
+  svalBuilder.makeIntValWithWidth(svalBuilder.getArrayIndexType(), 0));
 
   ProgramStateRef StatePtrIsNull, StatePtrNotNull;
   std::tie(StatePtrIsNull, StatePtrNotNull) = State->assume(PtrEQ);
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
@@ -332,9 +332,8 @@
 return nonloc::ConcreteInt(BasicVals.getIntValue(integer, isUnsigned));
   }
 
-  NonLoc makeIntValWithPtrWidth(uint64_t integer, bool isUnsigned) {
-return nonloc::ConcreteInt(
-BasicVals.getIntWithPtrWidth(integer, isUnsigned));
+  NonLoc makeIntValWithWidth(QualType ptrType, uint64_t integer) {
+return nonloc::ConcreteInt(BasicVals.getValue(integer, ptrType));
   }
 
   NonLoc makeLocAsInteger(Loc loc, unsigned bits) {
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
@@ -220,14 +220,6 @@
 return getValue(0, Ctx.getTypeSize(T), true);
   }
 
-  const llvm::APSInt &getZeroWithPtrWidth(bool isUnsigned = true) {
-return getValue(0, Ctx.getTypeSize(Ctx.VoidPtrTy), isUnsigned);
-  }
-
-  const llvm::APSInt &getIntWithPtrWidth(uint64_t X, bool isUnsigned) {
-return getValue(X, Ctx.getTypeSize(Ctx.VoidPtrTy), isUnsigned);
-  }
-
   const llvm::APSInt &getTruthValue(bool b, QualType T) {
 return getValue(b ? 1 : 0, Ctx.getIntWidth(T),
 T->isUnsignedIntegerOrEnumerationType());


Index: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -742,9 +742,6 @@
   // This change is needed for architectures with varying
   // pointer widths. See the amdgcn opencl reproducer with
   // this change as an example: solver-sym-simplification-ptr-bool.cl
-  // FIXME: Cleanup remainder of `getZeroWithPtrWidth ()`
-  //and `getIntWithPtrWidth()` functions to prevent fu

[PATCH] D120134: [analyzer] refactor makeIntValWithPtrWidth, remove getZeroWithPtrWidth (NFC)

2022-02-22 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers marked 2 inline comments as done.
vabridgers added a comment.

I believe the comments have been addressed. Thank you - Vince


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120134

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


[PATCH] D120315: [clang-format] fix preprocessor nesting after https://github.com/llvm/llvm-project/commit/529aa4b011c4ae808d658022ef643c44dd9b2c9c

2022-02-22 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir created this revision.
krasimir requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

In 
https://github.com/llvm/llvm-project/commit/529aa4b011c4ae808d658022ef643c44dd9b2c9c
by setting the identifier info to nullptr, we started to subtly
interfere with the parts in the beginning of the function,
https://github.com/llvm/llvm-project/blob/529aa4b011c4ae808d658022ef643c44dd9b2c9c/clang/lib/Format/UnwrappedLineParser.cpp#L991
causing the preprocessor nesting to change in some cases. E.g., for the
added regression test, clang-format started incorrectly guessing the
language as C++.

This tries to address this by introducing an internal identifier info
element to use instead.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120315

Files:
  clang/lib/Format/FormatToken.h
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -22724,6 +22724,13 @@
   EXPECT_EQ(
   FormatStyle::LK_Cpp,
   guessLanguage("foo.h", "#define FOO(...) auto bar = [] __VA_ARGS__;"));
+  // Only only one of the two preprocessor regions has ObjC-like code.
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "#if A\n"
+   "#define B() C\n"
+   "#else\n"
+   "#define B() [NSString a:@\"\"]\n"
+   "#endif\n"));
 }
 
 TEST_F(FormatTest, GuessLanguageWithCpp11AttributeSpecifiers) {
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1089,9 +1089,11 @@
   // In the context of a define, even keywords should be treated as normal
   // identifiers. Setting the kind to identifier is not enough, because we need
   // to treat additional keywords like __except as well, which are already
-  // identifiers.
+  // identifiers. Setting the identifier info to null interferes with include
+  // guard processing above, and changes preprocessing nesting.
   FormatTok->Tok.setKind(tok::identifier);
-  FormatTok->Tok.setIdentifierInfo(nullptr);
+  FormatTok->Tok.setIdentifierInfo(
+  Keywords.kw_clang_format_internal_ident_after_define);
   nextToken();
   if (FormatTok->Tok.getKind() == tok::l_paren &&
   !FormatTok->hasWhitespaceBefore())
Index: clang/lib/Format/FormatToken.h
===
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -949,6 +949,10 @@
 kw_slots = &IdentTable.get("slots");
 kw_qslots = &IdentTable.get("Q_SLOTS");
 
+// For internal clang-format use.
+kw_clang_format_internal_ident_after_define =
+&IdentTable.get("__CLANG_FORMAT_INTERNAL_IDENT_AFTER_DEFINE__");
+
 // C# keywords
 kw_dollar = &IdentTable.get("dollar");
 kw_base = &IdentTable.get("base");
@@ -1069,6 +1073,9 @@
   IdentifierInfo *kw_slots;
   IdentifierInfo *kw_qslots;
 
+  // For internal use by clang-format.
+  IdentifierInfo *kw_clang_format_internal_ident_after_define;
+
   // C# keywords
   IdentifierInfo *kw_dollar;
   IdentifierInfo *kw_base;


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -22724,6 +22724,13 @@
   EXPECT_EQ(
   FormatStyle::LK_Cpp,
   guessLanguage("foo.h", "#define FOO(...) auto bar = [] __VA_ARGS__;"));
+  // Only only one of the two preprocessor regions has ObjC-like code.
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "#if A\n"
+   "#define B() C\n"
+   "#else\n"
+   "#define B() [NSString a:@\"\"]\n"
+   "#endif\n"));
 }
 
 TEST_F(FormatTest, GuessLanguageWithCpp11AttributeSpecifiers) {
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1089,9 +1089,11 @@
   // In the context of a define, even keywords should be treated as normal
   // identifiers. Setting the kind to identifier is not enough, because we need
   // to treat additional keywords like __except as well, which are already
-  // identifiers.
+  // identifiers. Setting the identifier info to null interferes with include
+  // guard processing above, and changes preprocessing nesting.
   FormatTok->Tok.setKind(tok::identifier);
-  FormatTok->Tok.setIdentifierInfo(nullptr);
+  FormatTok->Tok.setI

[PATCH] D120307: [X86] Add helper macros for ternary intrinsics

2022-02-22 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

Are similar macros used by any other compilers at all?




Comment at: clang/lib/Headers/avx512fintrin.h:5932
 
-#define _mm512_ternarylogic_epi32(A, B, C, imm) \
-  ((__m512i)__builtin_ia32_pternlogd512_mask((__v16si)(__m512i)(A), \
- (__v16si)(__m512i)(B), \
- (__v16si)(__m512i)(C), 
(int)(imm), \
- (__mmask16)-1))
-
-#define _mm512_mask_ternarylogic_epi32(A, U, B, C, imm) \
-  ((__m512i)__builtin_ia32_pternlogd512_mask((__v16si)(__m512i)(A), \
- (__v16si)(__m512i)(B), \
- (__v16si)(__m512i)(C), 
(int)(imm), \
- (__mmask16)(U)))
-
-#define _mm512_maskz_ternarylogic_epi32(U, A, B, C, imm) \
-  ((__m512i)__builtin_ia32_pternlogd512_maskz((__v16si)(__m512i)(A), \
-  (__v16si)(__m512i)(B), \
-  (__v16si)(__m512i)(C), \
-  (int)(imm), (__mmask16)(U)))
-
-#define _mm512_ternarylogic_epi64(A, B, C, imm) \
-  ((__m512i)__builtin_ia32_pternlogq512_mask((__v8di)(__m512i)(A), \
- (__v8di)(__m512i)(B), \
- (__v8di)(__m512i)(C), (int)(imm), 
\
- (__mmask8)-1))
-
-#define _mm512_mask_ternarylogic_epi64(A, U, B, C, imm) \
-  ((__m512i)__builtin_ia32_pternlogq512_mask((__v8di)(__m512i)(A), \
- (__v8di)(__m512i)(B), \
- (__v8di)(__m512i)(C), (int)(imm), 
\
- (__mmask8)(U)))
-
-#define _mm512_maskz_ternarylogic_epi64(U, A, B, C, imm) \
-  ((__m512i)__builtin_ia32_pternlogq512_maskz((__v8di)(__m512i)(A), \
-  (__v8di)(__m512i)(B), \
-  (__v8di)(__m512i)(C), 
(int)(imm), \
-  (__mmask8)(U)))
+#define _MM_TERNLOG_A 0xF0
+#define _MM_TERNLOG_B 0xCC

Add a doxygen comment for these?



Comment at: clang/test/CodeGen/X86/avx512f-builtins.c:6010
   // CHECK-LABEL: @test_mm512_ternarylogic_epi32
   // CHECK: @llvm.x86.avx512.pternlog.d.512
+  return _mm512_ternarylogic_epi32(__A, __B, __C, _MM_TERNLOG_A);

check the immediate value?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120307

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


[PATCH] D118586: [C++20][Modules][3/8] Initial handling for module partitions.

2022-02-22 Thread Iain Sandoe via Phabricator via cfe-commits
iains updated this revision to Diff 410498.
iains added a comment.

rebased, update testcases to use split-file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118586

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaModule.cpp
  clang/test/CXX/module/module.unit/p3.cpp
  clang/test/CXX/module/module.unit/p8.cpp
  clang/test/Modules/cxx20-multiple-partitions.cpp
  clang/test/Modules/cxx20-partition-diagnostics-a.cpp

Index: clang/test/Modules/cxx20-partition-diagnostics-a.cpp
===
--- /dev/null
+++ clang/test/Modules/cxx20-partition-diagnostics-a.cpp
@@ -0,0 +1,19 @@
+// Module Partition diagnostics
+
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only %t/bad-import.cpp -verify
+
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only %t/bad-partition.cpp -verify
+
+//--- bad-import.cpp
+
+import :B; // expected-error {{module partition imports must be within a module purview}}
+
+//--- bad-partition.cpp
+
+module; // expected-error {{missing 'module' declaration at end of global module fragment introduced here}}
+
+import :Part; // expected-error {{module partition imports cannot be in the global module fragment}}
Index: clang/test/Modules/cxx20-multiple-partitions.cpp
===
--- /dev/null
+++ clang/test/Modules/cxx20-multiple-partitions.cpp
@@ -0,0 +1,46 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/partition1.cpp \
+// RUN:  -o %t/A_part1.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/partition2.cpp \
+// RUN:  -o %t/A_part2.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/partition3.cpp \
+// RUN:  -o %t/A_part3.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/moduleA.cpp \
+// RUN:  -fmodule-file=%t/A_part1.pcm -fmodule-file=%t/A_part2.pcm \
+// RUN:  -fmodule-file=%t/A_part3.pcm -o %t/A.pcm
+
+// expected-no-diagnostics
+
+//--- partition1.cpp
+
+export module A:Part1;
+
+int part1();
+
+//--- partition2.cpp
+
+export module A:Part2;
+
+int part2();
+
+//--- partition3.cpp
+
+export module A:Part3;
+
+int part3();
+
+//--- moduleA.cpp
+
+export module A;
+
+import :Part1;
+export import :Part2;
+import :Part3;
+
+int foo();
Index: clang/test/CXX/module/module.unit/p8.cpp
===
--- clang/test/CXX/module/module.unit/p8.cpp
+++ clang/test/CXX/module/module.unit/p8.cpp
@@ -12,7 +12,7 @@
 
 #elif MODE == 1
 // expected-no-diagnostics
-module foo;
+module foo; // Implementation, implicitly imports foo.
 #define IMPORTED
 
 #elif MODE == 2
@@ -21,15 +21,15 @@
 #define IMPORTED
 
 #elif MODE == 3
-export module bar;
+export module bar; // A different module
 
 #elif MODE == 4
-module foo:bar; // expected-error {{not yet supported}}
-#define IMPORTED // FIXME
+module foo:bar; // Partition implementation
+//#define IMPORTED (we don't import foo here)
 
 #elif MODE == 5
-export module foo:bar; // expected-error {{not yet supported}} expected-error {{redefinition}} expected-note@* {{loaded from}}
-#define IMPORTED // FIXME
+export module foo:bar; // Partition interface
+//#define IMPORTED  (we don't import foo here)
 
 #endif
 
Index: clang/test/CXX/module/module.unit/p3.cpp
===
--- clang/test/CXX/module/module.unit/p3.cpp
+++ clang/test/CXX/module/module.unit/p3.cpp
@@ -1,4 +1,4 @@
 // RUN: %clang_cc1 -std=c++2a -verify %s
 
-export module foo:bar; // expected-error {{sorry, module partitions are not yet supported}}
-import :baz; // expected-error {{sorry, module partitions are not yet supported}}
+export module foo:bar;
+import :baz; // expected-error {{module 'foo:baz' not found}}
Index: clang/lib/Sema/SemaModule.cpp
===
--- clang/lib/Sema/SemaModule.cpp
+++ clang/lib/Sema/SemaModule.cpp
@@ -54,6 +54,23 @@
   }
 }
 
+// We represent the primary and partition names as 'Paths' which are sections
+// of the hierarchical access path for a clang module.  However for C++20
+// the periods in a name are just another character, and we will need to
+// flatten them into a string.
+static std::string stringFromPath(ModuleIdPath Path) {
+  std::string Name;
+  if (Path.empty())
+return Name;
+
+  for (auto &Piece : Path) {
+if (!Name.empty())
+  Name += ".";
+Name += Piece.first->getName();
+  }
+  return Name;
+}
+
 Sema::DeclGroupPtrTy
 Sema::ActOnGlobalModuleFragmentDecl(SourceLocation ModuleLoc) {
   if (!ModuleScopes.empty() &&
@@ -80,11 +97,10 @@

[PATCH] D118586: [C++20][Modules][3/8] Initial handling for module partitions.

2022-02-22 Thread Iain Sandoe via Phabricator via cfe-commits
iains marked an inline comment as done.
iains added inline comments.



Comment at: clang/test/Modules/cxx20-multiple-partitions.cpp:48
+#else
+#error "no TU set"
+#endif

jansvoboda11 wrote:
> Instead of splitting the file with preprocessor, you could use the 
> `split-file` utility (introduced in D83834).
thanks!
this is exactly what is needed here.
I've converted the added cases here (and will do for the follow-on patches).



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118586

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


[PATCH] D120306: [clangd] IncludeCleaner: Add support for IWYU pragma private

2022-02-22 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D120306#3337288 , @kbobyrev wrote:

> In D120306#3337212 , @sammccall 
> wrote:
>
>> What's the policy this patch intends to implement?
>>
>> I'm a little concerned by building up maps of filenames with segment limits 
>> - it looks like some kind of heuristic/partial matching.
>
> Basically, handling the mappings that. IWYU pragmas provide.

Yes, I'm asking you to describe that handling in a couple of sentences so I can 
understand what you intend it to be.

e.g. for includecleaner in general, the approach is: walk the AST, map each 
node to decls it uses, map decls to locations, map locations to files, then 
check which includes point to files that were not identified.

> Are you concerned about the limit itself or the way I'm trying to find these 
> headers in general? I was afraid of consuming too much memory, hence the 
> limit; it's not crucial to the implementation, though, I can remove it if 
> your concern is the limit rather than the approach.

Mostly I'm unclear on:

- whether we're comparing filenames among a small (e.g. the include stack - 
heuristics OK) or a large set (need to be very precise)
- whether the partial matching is semantically important or a performance 
optimitzation
- whether the concept of "real name" is significant or likely to cause problems
- whether storing another copy of the names of all the transitive headers is 
actually necessary for what you're trying to do


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120306

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


[PATCH] D119816: Fix not working attribute no_sanitize bounds that affects linux kernel

2022-02-22 Thread Marco Elver via Phabricator via cfe-commits
melver added a comment.

Adding a new IR attribute comes with a whole slew of other required changes. 
Please see https://reviews.llvm.org/D102772 for an example.

In addition, please update the patch description to explain what the problem is 
exactly (remove the old kernel-specific problem, because it's only a 
distraction). In particular, what current no_sanitize does (because it does 
something for "bounds checking), and what is missing. Introducing a new IR 
attribute needs to be properly justified, so if you can explain why this can't 
be solved another way would also be useful (something like .. the local-bounds 
code generation happens in the middleend and not frontend unlike some other 
UBSAN checks).

Also, you need to add some IR tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119816

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


[PATCH] D112916: Confusable identifiers detection

2022-02-22 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/misc/ConfusableTable/build_confusable_table.cpp:22
+  SmallVector Lines;
+  Content.split(Lines, '\n', -1, false);
+

We're testing this functionality in our downstream and noticed that this causes 
an issue when the repo is cloned with CRLF  line endings. Can you make this a 
bit more resilient to the platform line endings?


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

https://reviews.llvm.org/D112916

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


[PATCH] D113319: [clang-format] Improve require and concept handling

2022-02-22 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

It appears that after this patch clang-format started breaking up `requires` in 
javascript, e.g.:

  // before
  function f() {
var requires = {};
  }
  // after
  function f() {
var
  requires
= {};
  }

Could we restrict the requires logic only to (obj)C++? (normally I'd go and 
come up with a patch for cases like this, but this patch is quite large and 
it's not immediately clear where's the best place for this restriction).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113319

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


[PATCH] D120205: Restore documentation for __builtin_assume

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

LGTM, thanks for catching this!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120205

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


[PATCH] D120306: [clangd] IncludeCleaner: Add support for IWYU pragma private

2022-02-22 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added a comment.

In D120306#3337374 , @sammccall wrote:

> In D120306#3337288 , @kbobyrev 
> wrote:
>
>> In D120306#3337212 , @sammccall 
>> wrote:
>>
>>> What's the policy this patch intends to implement?
>>>
>>> I'm a little concerned by building up maps of filenames with segment limits 
>>> - it looks like some kind of heuristic/partial matching.
>>
>> Basically, handling the mappings that. IWYU pragmas provide.
>
> Yes, I'm asking you to describe that handling in a couple of sentences so I 
> can understand what you intend it to be.
>
> e.g. for includecleaner in general, the approach is: walk the AST, map each 
> node to decls it uses, map decls to locations, map locations to files, then 
> check which includes point to files that were not identified.

I'm trying to reuse the information about `IWYU pragma private` that is 
collected in `Canoncalncludes` to find the header responsible for including the 
private ones. Canonicalncludes stores information about the headers with `IWYU 
pragma: prviate, include `. When we're figuring out the responsible header 
in IncludeCleaner, I'm checking if the header has this pragma and then I'm 
trying to find the `` header that is mentioned in the pragma comment. For 
that I'm using a heuristic that the include stack of the main file should have 
a header whose suffix is . This because we never really have the full 
header name in the pragma comment and it might not be visible from the private 
header (and hence can not be resolved from there). I'm not sure if this 
heuristic will work well in practice, but I couldn't figure out a better one.

An alternative would probably be:

- Walk #include directives and try to find the "umbrella headers"
- For each include directive, query the included file and figure out if it has 
"IWYU pragma: private, include " through `CanonicalIncludes`
- If it does, figure out if the supposed umbrella header name has the `` 
suffix, in that case attribute the private header to this public one

This all would need to be done after `Canonicalncludes` are complete, meaning 
this would probably belong to `IncludeStructure` instead. Maybe this is more 
precise, WDYT?

>> Are you concerned about the limit itself or the way I'm trying to find these 
>> headers in general? I was afraid of consuming too much memory, hence the 
>> limit; it's not crucial to the implementation, though, I can remove it if 
>> your concern is the limit rather than the approach.
>
> Mostly I'm unclear on:
>
> - whether we're comparing filenames among a small (e.g. the include stack - 
> heuristics OK) or a large set (need to be very precise)

Yes, I'm using just the include stack of the main file and the preamble. When 
you say "large set", do you mean the whole set of project headers?

The problem here is that for the include stack we would miss the right 
diagnostic if the public header responsible for the private one is not 
accessible. Maybe we should throw an "unused" warning either way here, I don't 
know what would be right.

> - whether the partial matching is semantically important or a performance 
> optimitzation

The matching itself is an optimisation, right: what I'm dealing with is that 
`gtest.h` header is called 
`/home/user/llvm-project/llvm/util/googletest/.../gtest/gtest.h` but the 
private headers will only say `include "gtest/gtest.h"`. What I'm trying to do 
is find the header whose real path name ends with `gtest/gtest.h`.

> - whether the concept of "real name" is significant or likely to cause 
> problems

Hm, I don't know; what kind of problems do you think might appear?

> - whether storing another copy of the names of all the transitive headers is 
> actually necessary for what you're trying to do

The problem here is that I'll need `FileID` in `headerResponsbile` but I can't 
reuse `FileID`s between preamble and main file, right? Logically, I'm afraid I 
don't have an option to store anything other than the name (or an index to it); 
I could uplift this logic to the `IncludeStructure` and loop over all visible 
headers in there, I wouldn't need another copy since I'm already storing it 
there. But that might be quite slow.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120306

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


[PATCH] D120134: [analyzer] refactor makeIntValWithPtrWidth, remove getZeroWithPtrWidth (NFC)

2022-02-22 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.

Thanks for the patch. LGTM on my part.
@NoQ WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120134

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


[PATCH] D118587: [C++20][Modules][4/8] Handle generation of partition implementation CMIs.

2022-02-22 Thread Iain Sandoe via Phabricator via cfe-commits
iains updated this revision to Diff 410514.
iains added a comment.

rebased, revised testcases to use split-file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118587

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaModule.cpp
  clang/test/Modules/cxx20-10-1-ex1.cpp
  clang/test/Modules/cxx20-10-1-ex2.cpp
  clang/test/Modules/cxx20-import-diagnostics-a.cpp

Index: clang/test/Modules/cxx20-import-diagnostics-a.cpp
===
--- clang/test/Modules/cxx20-import-diagnostics-a.cpp
+++ clang/test/Modules/cxx20-import-diagnostics-a.cpp
@@ -94,9 +94,9 @@
 #elif TU == 6
 
 module;
-// We can only have preprocessor commands here, which could include an include
+// We can only have preprocessor directives here, which permits an include-
 // translated header unit.  However those are identified specifically by the
-// preprocessor; non-preprocessed user code should not contain an import here.
+// preprocessor; non-preprocessed user code should not contain an 'import' here.
 import B; // expected-error {{module imports cannot be in the global module fragment}}
 
 export module D;
Index: clang/test/Modules/cxx20-10-1-ex2.cpp
===
--- /dev/null
+++ clang/test/Modules/cxx20-10-1-ex2.cpp
@@ -0,0 +1,64 @@
+
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/std10-1-ex2-tu1.cpp \
+// RUN:  -o %t/B_Y.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/std10-1-ex2-tu2.cpp \
+// RUN:  -fmodule-file=%t/B_Y.pcm -o %t/B.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/std10-1-ex2-tu3.cpp \
+// RUN:   -o %t/B_X1.pcm -verify
+
+// Not expected to work yet.
+//  %clang_cc1 -std=c++20 -emit-module-interface %t/std10-1-ex2-tu4.cpp \
+//   -fmodule-file=%t/B.pcm  -o %t/B_X2.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-obj %t/std10-1-ex2-tu5.cpp \
+// RUN:  -fmodule-file=%t/B.pcm  -o %t/b_tu5.o
+
+// RUN: %clang_cc1 -std=c++20 -S %t/std10-1-ex2-tu6.cpp \
+// RUN:  -fmodule-file=%t/B.pcm  -o %t/b_tu6.s -verify
+
+// Not expected to work yet.
+//  %clang_cc1 -std=c++20 -emit-module-interface %t/std10-1-ex2-tu7.cpp \
+//   -fmodule-file=%t/B_X2.pcm  -o %t/B_X3.pcm -verify
+
+//--- std10-1-ex2-tu1.cpp
+module B:Y;
+int y();
+// expected-no-diagnostics
+
+//--- std10-1-ex2-tu2.cpp
+export module B;
+import :Y;
+int n = y();
+// expected-no-diagnostics
+
+//--- std10-1-ex2-tu3.cpp
+module B:X1; // does not implicitly import B
+int &a = n;  // expected-error {{use of undeclared identifier }}
+
+//--- std10-1-ex2-tu4.cpp
+module B:X2; // does not implicitly import B
+import B;
+int &b = n; // OK
+// expected-no-diagnostics
+
+//--- std10-1-ex2-tu5.cpp
+module B;   // implicitly imports B
+int &c = n; // OK
+// expected-no-diagnostics
+
+//--- std10-1-ex2-tu6.cpp
+import B;
+// error, n is module-local and this is not a module.
+int &c = n; // expected-error {{use of undeclared identifier}}
+
+//--- std10-1-ex2-tu7.cpp
+module B:X3; // does not implicitly import B
+import :X2;  // X2 is an implementation so exports nothing.
+ // error: n not visible here.
+int &c = n;  // expected-error {{use of undeclared identifier }}
Index: clang/test/Modules/cxx20-10-1-ex1.cpp
===
--- /dev/null
+++ clang/test/Modules/cxx20-10-1-ex1.cpp
@@ -0,0 +1,48 @@
+// The example in the standard is not in required build order.
+// revised here
+
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/std10-1-ex1-tu1.cpp \
+// RUN:  -o %t/A_Internals.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/std10-1-ex1-tu2.cpp \
+// RUN:  -fmodule-file=%t/A_Internals.pcm -o %t/A_Foo.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/std10-1-ex1-tu3.cpp \
+// RUN:  -fmodule-file=%t/A_Foo.pcm -o %t/A.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-obj %t/std10-1-ex1-tu4.cpp \
+// RUN:  -fmodule-file=%t/A.pcm -o %t/ex1.o
+
+// expected-no-diagnostics
+
+//--- std10-1-ex1-tu1.cpp
+
+module A:Internals;
+int bar();
+
+//--- std10-1-ex1-tu2.cpp
+
+export module A:Foo;
+
+import :Internals;
+
+export int foo() { return 2 * (bar() + 1); }
+
+//--- std10-1-ex1-tu3.cpp
+
+export module A;
+export import :Foo;
+export int baz();
+
+//--- std10-1-ex1-tu4.cpp
+
+module A;
+
+import :Internals;
+
+int bar() { return baz() - 10; }
+int baz() { return 30; }
Index: clang/lib/Sema/SemaModule.cpp
===
--- clang/lib/Sema/SemaModule.cpp
+++ clang/lib/Sema/SemaModule.cpp
@@ -110,9 +110,24 @@
   // module state;
   ImportState = ModuleImportState::NotACXX20Module;
 
-  // A module implementation unit requires that we are not compiling a module
-  // of any kind. A 

[PATCH] D120315: [clang-format] fix preprocessor nesting after https://github.com/llvm/llvm-project/commit/529aa4b011c4ae808d658022ef643c44dd9b2c9c

2022-02-22 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:22727
   guessLanguage("foo.h", "#define FOO(...) auto bar = [] __VA_ARGS__;"));
+  // Only only one of the two preprocessor regions has ObjC-like code.
+  EXPECT_EQ(FormatStyle::LK_ObjC,

Only only


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120315

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


[PATCH] D120315: [clang-format] fix preprocessor nesting after https://github.com/llvm/llvm-project/commit/529aa4b011c4ae808d658022ef643c44dd9b2c9c

2022-02-22 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/lib/Format/FormatToken.h:1077
+  // For internal use by clang-format.
+  IdentifierInfo *kw_clang_format_internal_ident_after_define;
+

I'd be ok with just

`kw_internal_ident_after_define`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120315

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


[PATCH] D120290: [Clang][OpenMP] Add the codegen support for `atomic compare capture`

2022-02-22 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/include/clang/AST/StmtOpenMP.h:2835-2847
   bool IsXLHSInRHSPart = false;
   /// Used for 'atomic update' or 'atomic capture' constructs. They may
   /// have atomic expressions of forms
   /// \code
   /// v = x; ;
   /// ; v = x;
   /// \endcode

Transform these booleans to bitfields?



Comment at: clang/lib/Sema/SemaOpenMP.cpp:11556
   X = ThenBO->getLHS();
-  D = ThenBO->getRHS();
+  D = ThenBO->getRHS()->IgnoreImpCasts();
 

Need to be careful here, probably may need to cast to resulting type explicitly 
to avoid problems between int/float/etc. conversions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120290

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


[PATCH] D120315: [clang-format] fix preprocessor nesting after https://github.com/llvm/llvm-project/commit/529aa4b011c4ae808d658022ef643c44dd9b2c9c

2022-02-22 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.
This revision is now accepted and ready to land.

Just a few nits, but LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120315

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


[PATCH] D119599: [clang-format] Add option to align compound assignments like `+=`

2022-02-22 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

Could you mark the comments as done (if they are done)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119599

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


[PATCH] D118050: [analyzer] Different address spaces cannot overlap

2022-02-22 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.

Besides a couple of nits, it's ready for landing.
Thanks for the hard work @vabridgers!




Comment at: clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:726-727
+  LhsLoc.getType(Ctx).isNull() ? 0 : Ctx.getTypeSize(LhsLoc.getType(Ctx));
+  if (RhsBitwidth && LhsBitwidth &&
+  (LhsLoc.getSubKind() == RhsLoc.getSubKind())) {
+assert(RhsBitwidth == LhsBitwidth &&

You should probably ignore references.
Ah, but we already lost that information. Well, that's bad.
Anyway. You probably don't need to check the subkinds. Do you?



Comment at: clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:745
+  // See LIT case clang/test/Analysis/cstring-checker-addressspace.c
+  assertEqualBitWidths(state, rhs, lhs);
+

You don't use the return value of this call.
Can we have a `void` return type instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118050

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


[PATCH] D119599: [clang-format] Add option to align compound assignments like `+=`

2022-02-22 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added subscribers: njames93, grimar.
MyDeveloperDay added a comment.

Does the YAML changes need unit tests in (llvm/unittests/Support) ? also we 
should pull in a reviewer from llvm/Support  (maybe @njames93, @grimar ) who 
have made YAML specific changes in this header.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119599

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


[PATCH] D119599: [clang-format] Add option to align compound assignments like `+=`

2022-02-22 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/docs/tools/dump_format_style.py:121
   def __str__(self):
-return '\n'.join(map(str, self.values))
+return self.comment + '\n' + '\n'.join(map(str, self.values))
 

Can this change be separate? why is this needed? Could you add a screengrab of 
the html that it generates?



Comment at: clang/lib/Format/WhitespaceManager.cpp:273
+// RightJustify - Whether it is the token's right end or left end that
+// gets moved to that column.
 template 

something odd here why not, the following its fits 80 columns

```
// Column - The token for which Matches returns true is moved to this column.
// RightJustify - Whether it is the token's right end or left end that gets
// moved to that column.
```



Comment at: clang/lib/Format/WhitespaceManager.cpp:337
+  Shift = Column - RightJustify * Changes[i].TokenLength -
+  Changes[i].StartOfTokenColumn;
   Changes[i].Spaces += Shift;

RightJustify is a bool? so I'm sure this is a good way of doing a conditional 
but surely there is a compiler out there that is going to complain


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119599

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


[PATCH] D120306: [clangd] IncludeCleaner: Add support for IWYU pragma private

2022-02-22 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D120306#3337490 , @kbobyrev wrote:

> In D120306#3337374 , @sammccall 
> wrote:
>
>> In D120306#3337288 , @kbobyrev 
>> wrote:
>>
>>> In D120306#3337212 , @sammccall 
>>> wrote:
>>>
 What's the policy this patch intends to implement?

 I'm a little concerned by building up maps of filenames with segment 
 limits - it looks like some kind of heuristic/partial matching.
>>>
>>> Basically, handling the mappings that. IWYU pragmas provide.
>>
>> Yes, I'm asking you to describe that handling in a couple of sentences so I 
>> can understand what you intend it to be.
>>
>> e.g. for includecleaner in general, the approach is: walk the AST, map each 
>> node to decls it uses, map decls to locations, map locations to files, then 
>> check which includes point to files that were not identified.
>
> I'm trying to reuse the information about `IWYU pragma private` that is 
> collected in `Canoncalncludes` to find the header responsible for including 
> the private ones. Canonicalncludes stores information about the headers with 
> `IWYU pragma: prviate, include `.

This makes sense, though note that CanonicalIncludes predates IncludeStructure 
and had a pretty narrow purpose, it _might_ make more sense to record/store the 
data elsewhere, we should consider all options.

> When we're figuring out the responsible header in IncludeCleaner, I'm 
> checking if the header has this pragma and then I'm trying to find the 
> `` header that is mentioned in the pragma comment.
> For that I'm using a heuristic that the include stack of the main file should 
> have a header whose suffix is .

So all we *know* is that the header that should be included can be spelled 
``.
We don't know that it's on the include stack for the header defining the 
symbol, but we also don't know that it's included at all! (This is similar to 
the stdlib case).

It's true that for "unused include" warning we can ignore it if not included.
Still, it seems like a bad sign that we're trying to model headers referenced 
in this was as FileIDs rather than e.g. strings.
(And it will be harder to reuse for "missing include" warnings).

> This because we never really have the full header name in the pragma comment 
> an?d
> it might not be visible from the private header (and hence can not be 
> resolved from there)

Do you have an example? For include insertion purposes, we assume the header 
name can be included verbatim.
That implies it should be resolvable against the include path of any TU that 
sees the private header. (That said, performing IO might have its own problems)

> An alternative would probably be:
>
> - Walk #include directives and try to find the "umbrella headers"
> - For each include directive, query the included file and figure out if it 
> has "IWYU pragma: private, include " through `CanonicalIncludes`
> - If it does, figure out if the supposed umbrella header name has the `` 
> suffix, in that case attribute the private header to this public one
>
> This all would need to be done after `Canonicalncludes` are complete, meaning 
> this would probably belong to `IncludeStructure` instead. Maybe this is more 
> precise, WDYT?

I don't really understand this alternative, because "try to find the umbrella 
headers" seems to be begging the question.
What is an umbrella header apart from one referenced by an IWYU private pragma, 
and how would we identify them?

>> - whether we're comparing filenames among a small (e.g. the include stack - 
>> heuristics OK) or a large set (need to be very precise)
>
> Yes, I'm using just the include stack of the main file and the preamble. When 
> you say "large set", do you mean the whole set of project headers?

Small set = include stack = chain of includes from main file -> private header. 
(But public header may not be on that stack).
Large set = include graph = all preamble headers.

> The problem here is that for the include stack we would miss the right 
> diagnostic if the public header responsible for the private one is not 
> accessible. Maybe we should throw an "unused" warning either way here, I 
> don't know what would be right.
>
>> - whether the partial matching is semantically important or a performance 
>> optimitzation
>
> The matching itself is an optimisation, right: what I'm dealing with is that 
> `gtest.h` header is called 
> `/home/user/llvm-project/llvm/util/googletest/.../gtest/gtest.h` but the 
> private headers will only say `include "gtest/gtest.h"`. What I'm trying to 
> do is find the header whose real path name ends with `gtest/gtest.h`.

There's a few issues here:

- there might be multiple `"gtest/gtest.h"` (`#include_next`) though typically 
only in the stdlib
- ignoring the include path might lead to an incorrect match (`private; include 
"config.h"` should not mat

[PATCH] D120315: [clang-format] Fix preprocessor nesting after commit 529aa4b011c4ae808d658022ef643c44dd9b2c9c

2022-02-22 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius accepted this revision.
curdeius added a comment.

LGTM with other comments addressed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120315

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


[PATCH] D118900: [ASTMatchers] Expand isInline matcher to VarDecl

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

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118900

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


[PATCH] D119599: [clang-format] Add option to align compound assignments like `+=`

2022-02-22 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added inline comments.



Comment at: clang/docs/ClangFormatStyleOptions.rst:406
+
+  Options for aligning stuff.
 

Stuff?



Comment at: clang/docs/ClangFormatStyleOptions.rst:482-483
+
+  * ``bool AlignCompound`` Only for ``AlignConsecutiveAssignments``.  Whether 
compound
+assignments like ``+=``'s are aligned along with ``=``'s.
+





Comment at: clang/docs/ClangFormatStyleOptions.rst:510-512
+  regardless of this option:
+  a = 2;
+  bbb >>= 2;

IMO, it would be easier to understand if you appended (after a blank line) the 
"regardless" example into both true and false part.



Comment at: clang/docs/ClangFormatStyleOptions.rst:529
+
+  Options for aligning stuff.
+

Ditto.



Comment at: clang/docs/ClangFormatStyleOptions.rst:1408-1415
+  Precise control over the wrapping of braces.
+
+  .. code-block:: c++
+
+# Should be declared this way:
+BreakBeforeBraces: Custom
+BraceWrapping:

That's an unrelated change. Could you please do it in another (NFC) revision?



Comment at: clang/docs/ClangFormatStyleOptions.rst:4163-4171
+  Precise control over the spacing before parentheses.
+
+  .. code-block:: c++
+
+# Should be declared this way:
+SpaceBeforeParens: Custom
+SpaceBeforeParensOptions:

Ditto.



Comment at: llvm/docs/YamlIO.rst:561-590
+.. code-block:: c++
+
+template <> struct MappingTraits {
+  static void enumInput(IO &IO, FormatStyle::AlignConsecutiveStyle &Value) 
{
+IO.enumCase(Value, "None", FormatStyle::AlignConsecutiveStyle({}));
+IO.enumCase(Value, "Consecutive",
+FormatStyle::AlignConsecutiveStyle({/*.Enabled=*/true}));

A simpler example (not clang-format specific) would be better.



Comment at: llvm/include/llvm/Support/YAMLTraits.h:66
   // static std::string validate(IO &io, T &fields);
+  // static void enumInput(IO &io, T &value);
   //

Can't it be `enumeration` to match `ScalarEnumerationTraits`? Or would it clash?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119599

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


[PATCH] D120313: [clang][www] Port make_cxx_dr_status script to Python3

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

LGTM!




Comment at: clang/www/cxx_dr_status.html:15003
+
\ No newline at end of file


It doesn't matter overly much, but it might be reasonable to end this file with 
a newline still.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120313

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


[PATCH] D113319: [clang-format] Improve require and concept handling

2022-02-22 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

It appears that this causes a regression by adding a space in-between pointer 
dereferences `*p` -> `* p` in some cases, e.g. formatting this with llvm style:

  // before
  void f() {
while (p < a && *p == 'a')
  p++;
  }
  // after
  void f() {
while (p < a && * p == 'a')
  p++;
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113319

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


[PATCH] D120307: [X86] Add helper macros for ternary intrinsics

2022-02-22 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei updated this revision to Diff 410520.
pengfei marked 2 inline comments as done.
pengfei added a comment.

In D120307#3337352 , @RKSimon wrote:

> Are similar macros used by any other compilers at all?

Not so far. GCC folks agreed to add them. I'll add them to intrinsic guide as 
well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120307

Files:
  clang/lib/Headers/avx512fintrin.h
  clang/lib/Headers/avx512vlintrin.h
  clang/test/CodeGen/X86/avx512f-builtins.c

Index: clang/test/CodeGen/X86/avx512f-builtins.c
===
--- clang/test/CodeGen/X86/avx512f-builtins.c
+++ clang/test/CodeGen/X86/avx512f-builtins.c
@@ -6007,42 +6007,42 @@
 
 __m512i test_mm512_ternarylogic_epi32(__m512i __A, __m512i __B, __m512i __C) {
   // CHECK-LABEL: @test_mm512_ternarylogic_epi32
-  // CHECK: @llvm.x86.avx512.pternlog.d.512
-  return _mm512_ternarylogic_epi32(__A, __B, __C, 4); 
+  // CHECK: @llvm.x86.avx512.pternlog.d.512({{.*}}, i32 240)
+  return _mm512_ternarylogic_epi32(__A, __B, __C, _MM_TERNLOG_A);
 }
 
 __m512i test_mm512_mask_ternarylogic_epi32(__m512i __A, __mmask16 __U, __m512i __B, __m512i __C) {
   // CHECK-LABEL: @test_mm512_mask_ternarylogic_epi32
-  // CHECK: @llvm.x86.avx512.pternlog.d.512
+  // CHECK: @llvm.x86.avx512.pternlog.d.512({{.*}}, i32 204)
   // CHECK: select <16 x i1> %{{.*}}, <16 x i32> %{{.*}}, <16 x i32> %{{.*}}
-  return _mm512_mask_ternarylogic_epi32(__A, __U, __B, __C, 4); 
+  return _mm512_mask_ternarylogic_epi32(__A, __U, __B, __C, _MM_TERNLOG_B);
 }
 
 __m512i test_mm512_maskz_ternarylogic_epi32(__mmask16 __U, __m512i __A, __m512i __B, __m512i __C) {
   // CHECK-LABEL: @test_mm512_maskz_ternarylogic_epi32
-  // CHECK: @llvm.x86.avx512.pternlog.d.512
+  // CHECK: @llvm.x86.avx512.pternlog.d.512({{.*}}, i32 170)
   // CHECK: select <16 x i1> %{{.*}}, <16 x i32> %{{.*}}, <16 x i32> zeroinitializer
-  return _mm512_maskz_ternarylogic_epi32(__U, __A, __B, __C, 4); 
+  return _mm512_maskz_ternarylogic_epi32(__U, __A, __B, __C, _MM_TERNLOG_C);
 }
 
 __m512i test_mm512_ternarylogic_epi64(__m512i __A, __m512i __B, __m512i __C) {
   // CHECK-LABEL: @test_mm512_ternarylogic_epi64
-  // CHECK: @llvm.x86.avx512.pternlog.q.512
-  return _mm512_ternarylogic_epi64(__A, __B, __C, 4); 
+  // CHECK: @llvm.x86.avx512.pternlog.q.512({{.*}}, i32 192)
+  return _mm512_ternarylogic_epi64(__A, __B, __C, _MM_TERNLOG_A & _MM_TERNLOG_B);
 }
 
 __m512i test_mm512_mask_ternarylogic_epi64(__m512i __A, __mmask8 __U, __m512i __B, __m512i __C) {
   // CHECK-LABEL: @test_mm512_mask_ternarylogic_epi64
-  // CHECK: @llvm.x86.avx512.pternlog.q.512
+  // CHECK: @llvm.x86.avx512.pternlog.q.512({{.*}}, i32 238)
   // CHECK: select <8 x i1> %{{.*}}, <8 x i64> %{{.*}}, <8 x i64> %{{.*}}
-  return _mm512_mask_ternarylogic_epi64(__A, __U, __B, __C, 4); 
+  return _mm512_mask_ternarylogic_epi64(__A, __U, __B, __C, _MM_TERNLOG_B | _MM_TERNLOG_C);
 }
 
 __m512i test_mm512_maskz_ternarylogic_epi64(__mmask8 __U, __m512i __A, __m512i __B, __m512i __C) {
   // CHECK-LABEL: @test_mm512_maskz_ternarylogic_epi64
-  // CHECK: @llvm.x86.avx512.pternlog.q.512
+  // CHECK: @llvm.x86.avx512.pternlog.q.512({{.*}}, i32 111)
   // CHECK: select <8 x i1> %{{.*}}, <8 x i64> %{{.*}}, <8 x i64> zeroinitializer
-  return _mm512_maskz_ternarylogic_epi64(__U, __A, __B, __C, 4); 
+  return _mm512_maskz_ternarylogic_epi64(__U, __A, __B, __C, ~_MM_TERNLOG_A | (_MM_TERNLOG_B ^ _MM_TERNLOG_C));
 }
 
 __m512 test_mm512_shuffle_f32x4(__m512 __A, __m512 __B) {
Index: clang/lib/Headers/avx512vlintrin.h
===
--- clang/lib/Headers/avx512vlintrin.h
+++ clang/lib/Headers/avx512vlintrin.h
@@ -6525,79 +6525,65 @@
 (__v4di)_mm256_setzero_si256());
 }
 
-#define _mm_ternarylogic_epi32(A, B, C, imm) \
-  ((__m128i)__builtin_ia32_pternlogd128_mask((__v4si)(__m128i)(A), \
- (__v4si)(__m128i)(B), \
- (__v4si)(__m128i)(C), (int)(imm), \
- (__mmask8)-1))
-
-#define _mm_mask_ternarylogic_epi32(A, U, B, C, imm) \
-  ((__m128i)__builtin_ia32_pternlogd128_mask((__v4si)(__m128i)(A), \
- (__v4si)(__m128i)(B), \
- (__v4si)(__m128i)(C), (int)(imm), \
- (__mmask8)(U)))
-
-#define _mm_maskz_ternarylogic_epi32(U, A, B, C, imm) \
-  ((__m128i)__builtin_ia32_pternlogd128_maskz((__v4si)(__m128i)(A), \
-  (__v4si)(__m128i)(B), \
-  (__v4si)(__m128i)(C), (int)(imm), \
-  (__mmask8)(U)))
-
-#define _mm256_ternary

[PATCH] D120315: [clang-format] Fix preprocessor nesting after commit 529aa4b011c4ae808d658022ef643c44dd9b2c9c

2022-02-22 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 410521.
krasimir marked an inline comment as done.
krasimir added a comment.

- address review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120315

Files:
  clang/lib/Format/FormatToken.h
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -22724,6 +22724,13 @@
   EXPECT_EQ(
   FormatStyle::LK_Cpp,
   guessLanguage("foo.h", "#define FOO(...) auto bar = [] __VA_ARGS__;"));
+  // Only one of the two preprocessor regions has ObjC-like code.
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "#if A\n"
+   "#define B() C\n"
+   "#else\n"
+   "#define B() [NSString a:@\"\"]\n"
+   "#endif\n"));
 }
 
 TEST_F(FormatTest, GuessLanguageWithCpp11AttributeSpecifiers) {
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1089,9 +1089,10 @@
   // In the context of a define, even keywords should be treated as normal
   // identifiers. Setting the kind to identifier is not enough, because we need
   // to treat additional keywords like __except as well, which are already
-  // identifiers.
+  // identifiers. Setting the identifier info to null interferes with include
+  // guard processing above, and changes preprocessing nesting.
   FormatTok->Tok.setKind(tok::identifier);
-  FormatTok->Tok.setIdentifierInfo(nullptr);
+  FormatTok->Tok.setIdentifierInfo(Keywords.kw_internal_ident_after_define);
   nextToken();
   if (FormatTok->Tok.getKind() == tok::l_paren &&
   !FormatTok->hasWhitespaceBefore())
Index: clang/lib/Format/FormatToken.h
===
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -949,6 +949,10 @@
 kw_slots = &IdentTable.get("slots");
 kw_qslots = &IdentTable.get("Q_SLOTS");
 
+// For internal clang-format use.
+kw_internal_ident_after_define =
+&IdentTable.get("__CLANG_FORMAT_INTERNAL_IDENT_AFTER_DEFINE__");
+
 // C# keywords
 kw_dollar = &IdentTable.get("dollar");
 kw_base = &IdentTable.get("base");
@@ -1069,6 +1073,9 @@
   IdentifierInfo *kw_slots;
   IdentifierInfo *kw_qslots;
 
+  // For internal use by clang-format.
+  IdentifierInfo *kw_internal_ident_after_define;
+
   // C# keywords
   IdentifierInfo *kw_dollar;
   IdentifierInfo *kw_base;


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -22724,6 +22724,13 @@
   EXPECT_EQ(
   FormatStyle::LK_Cpp,
   guessLanguage("foo.h", "#define FOO(...) auto bar = [] __VA_ARGS__;"));
+  // Only one of the two preprocessor regions has ObjC-like code.
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "#if A\n"
+   "#define B() C\n"
+   "#else\n"
+   "#define B() [NSString a:@\"\"]\n"
+   "#endif\n"));
 }
 
 TEST_F(FormatTest, GuessLanguageWithCpp11AttributeSpecifiers) {
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1089,9 +1089,10 @@
   // In the context of a define, even keywords should be treated as normal
   // identifiers. Setting the kind to identifier is not enough, because we need
   // to treat additional keywords like __except as well, which are already
-  // identifiers.
+  // identifiers. Setting the identifier info to null interferes with include
+  // guard processing above, and changes preprocessing nesting.
   FormatTok->Tok.setKind(tok::identifier);
-  FormatTok->Tok.setIdentifierInfo(nullptr);
+  FormatTok->Tok.setIdentifierInfo(Keywords.kw_internal_ident_after_define);
   nextToken();
   if (FormatTok->Tok.getKind() == tok::l_paren &&
   !FormatTok->hasWhitespaceBefore())
Index: clang/lib/Format/FormatToken.h
===
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -949,6 +949,10 @@
 kw_slots = &IdentTable.get("slots");
 kw_qslots = &IdentTable.get("Q_SLOTS");
 
+// For internal clang-format use.
+kw_internal_ident_after_define =
+&IdentTable.get("__CLANG_FORMAT_INTERNAL_IDENT_AFTER

[clang] c9592ae - [clang-format] Fix preprocessor nesting after commit 529aa4b011c4ae808d658022ef643c44dd9b2c9c

2022-02-22 Thread Krasimir Georgiev via cfe-commits

Author: Krasimir Georgiev
Date: 2022-02-22T15:43:18+01:00
New Revision: c9592ae49b8c486754a745e0c7b1a30b92a12e8b

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

LOG: [clang-format] Fix preprocessor nesting after commit 
529aa4b011c4ae808d658022ef643c44dd9b2c9c

In 
https://github.com/llvm/llvm-project/commit/529aa4b011c4ae808d658022ef643c44dd9b2c9c
by setting the identifier info to nullptr, we started to subtly
interfere with the parts in the beginning of the function,
https://github.com/llvm/llvm-project/blob/529aa4b011c4ae808d658022ef643c44dd9b2c9c/clang/lib/Format/UnwrappedLineParser.cpp#L991
causing the preprocessor nesting to change in some cases. E.g., for the
added regression test, clang-format started incorrectly guessing the
language as C++.

This tries to address this by introducing an internal identifier info
element to use instead.

Reviewed By: curdeius, MyDeveloperDay

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

Added: 


Modified: 
clang/lib/Format/FormatToken.h
clang/lib/Format/UnwrappedLineParser.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h
index 5f05986addf6a..bd1d447328a0a 100644
--- a/clang/lib/Format/FormatToken.h
+++ b/clang/lib/Format/FormatToken.h
@@ -949,6 +949,10 @@ struct AdditionalKeywords {
 kw_slots = &IdentTable.get("slots");
 kw_qslots = &IdentTable.get("Q_SLOTS");
 
+// For internal clang-format use.
+kw_internal_ident_after_define =
+&IdentTable.get("__CLANG_FORMAT_INTERNAL_IDENT_AFTER_DEFINE__");
+
 // C# keywords
 kw_dollar = &IdentTable.get("dollar");
 kw_base = &IdentTable.get("base");
@@ -1069,6 +1073,9 @@ struct AdditionalKeywords {
   IdentifierInfo *kw_slots;
   IdentifierInfo *kw_qslots;
 
+  // For internal use by clang-format.
+  IdentifierInfo *kw_internal_ident_after_define;
+
   // C# keywords
   IdentifierInfo *kw_dollar;
   IdentifierInfo *kw_base;

diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index 7d29afb0c042c..09e209e856541 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -1089,9 +1089,10 @@ void UnwrappedLineParser::parsePPDefine() {
   // In the context of a define, even keywords should be treated as normal
   // identifiers. Setting the kind to identifier is not enough, because we need
   // to treat additional keywords like __except as well, which are already
-  // identifiers.
+  // identifiers. Setting the identifier info to null interferes with include
+  // guard processing above, and changes preprocessing nesting.
   FormatTok->Tok.setKind(tok::identifier);
-  FormatTok->Tok.setIdentifierInfo(nullptr);
+  FormatTok->Tok.setIdentifierInfo(Keywords.kw_internal_ident_after_define);
   nextToken();
   if (FormatTok->Tok.getKind() == tok::l_paren &&
   !FormatTok->hasWhitespaceBefore())

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 51f6239bf2100..7d8b74c9c455f 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -22724,6 +22724,13 @@ TEST_F(FormatTest, FileAndCode) {
   EXPECT_EQ(
   FormatStyle::LK_Cpp,
   guessLanguage("foo.h", "#define FOO(...) auto bar = [] __VA_ARGS__;"));
+  // Only one of the two preprocessor regions has ObjC-like code.
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "#if A\n"
+   "#define B() C\n"
+   "#else\n"
+   "#define B() [NSString a:@\"\"]\n"
+   "#endif\n"));
 }
 
 TEST_F(FormatTest, GuessLanguageWithCpp11AttributeSpecifiers) {



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


[PATCH] D120315: [clang-format] Fix preprocessor nesting after commit 529aa4b011c4ae808d658022ef643c44dd9b2c9c

2022-02-22 Thread Krasimir Georgiev 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 rGc9592ae49b8c: [clang-format] Fix preprocessor nesting after 
commit… (authored by krasimir).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120315

Files:
  clang/lib/Format/FormatToken.h
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -22724,6 +22724,13 @@
   EXPECT_EQ(
   FormatStyle::LK_Cpp,
   guessLanguage("foo.h", "#define FOO(...) auto bar = [] __VA_ARGS__;"));
+  // Only one of the two preprocessor regions has ObjC-like code.
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "#if A\n"
+   "#define B() C\n"
+   "#else\n"
+   "#define B() [NSString a:@\"\"]\n"
+   "#endif\n"));
 }
 
 TEST_F(FormatTest, GuessLanguageWithCpp11AttributeSpecifiers) {
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1089,9 +1089,10 @@
   // In the context of a define, even keywords should be treated as normal
   // identifiers. Setting the kind to identifier is not enough, because we need
   // to treat additional keywords like __except as well, which are already
-  // identifiers.
+  // identifiers. Setting the identifier info to null interferes with include
+  // guard processing above, and changes preprocessing nesting.
   FormatTok->Tok.setKind(tok::identifier);
-  FormatTok->Tok.setIdentifierInfo(nullptr);
+  FormatTok->Tok.setIdentifierInfo(Keywords.kw_internal_ident_after_define);
   nextToken();
   if (FormatTok->Tok.getKind() == tok::l_paren &&
   !FormatTok->hasWhitespaceBefore())
Index: clang/lib/Format/FormatToken.h
===
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -949,6 +949,10 @@
 kw_slots = &IdentTable.get("slots");
 kw_qslots = &IdentTable.get("Q_SLOTS");
 
+// For internal clang-format use.
+kw_internal_ident_after_define =
+&IdentTable.get("__CLANG_FORMAT_INTERNAL_IDENT_AFTER_DEFINE__");
+
 // C# keywords
 kw_dollar = &IdentTable.get("dollar");
 kw_base = &IdentTable.get("base");
@@ -1069,6 +1073,9 @@
   IdentifierInfo *kw_slots;
   IdentifierInfo *kw_qslots;
 
+  // For internal use by clang-format.
+  IdentifierInfo *kw_internal_ident_after_define;
+
   // C# keywords
   IdentifierInfo *kw_dollar;
   IdentifierInfo *kw_base;


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -22724,6 +22724,13 @@
   EXPECT_EQ(
   FormatStyle::LK_Cpp,
   guessLanguage("foo.h", "#define FOO(...) auto bar = [] __VA_ARGS__;"));
+  // Only one of the two preprocessor regions has ObjC-like code.
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "#if A\n"
+   "#define B() C\n"
+   "#else\n"
+   "#define B() [NSString a:@\"\"]\n"
+   "#endif\n"));
 }
 
 TEST_F(FormatTest, GuessLanguageWithCpp11AttributeSpecifiers) {
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1089,9 +1089,10 @@
   // In the context of a define, even keywords should be treated as normal
   // identifiers. Setting the kind to identifier is not enough, because we need
   // to treat additional keywords like __except as well, which are already
-  // identifiers.
+  // identifiers. Setting the identifier info to null interferes with include
+  // guard processing above, and changes preprocessing nesting.
   FormatTok->Tok.setKind(tok::identifier);
-  FormatTok->Tok.setIdentifierInfo(nullptr);
+  FormatTok->Tok.setIdentifierInfo(Keywords.kw_internal_ident_after_define);
   nextToken();
   if (FormatTok->Tok.getKind() == tok::l_paren &&
   !FormatTok->hasWhitespaceBefore())
Index: clang/lib/Format/FormatToken.h
===
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -949,6 +949,10 @@
 kw_slots = &IdentTable.get("slots");
 kw_qslots = &IdentTable.get("Q_SLOTS");
 
+// For internal clang-format use.
+

[PATCH] D120323: [clang][SVE] Add support for arithmetic operators on SVE types

2022-02-22 Thread David Truby via Phabricator via cfe-commits
DavidTruby created this revision.
Herald added subscribers: ctetreau, psnobl, tschuett.
Herald added a reviewer: efriedma.
DavidTruby requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch implements support for the +, -, *, / and % operators on sizeless SVE
types. Support for these operators on svbool_t is excluded.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120323

Files:
  clang/include/clang/AST/Type.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Type.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGen/aarch64-sve-vector-ops.c
  clang/test/Sema/aarch64-sve-vector-ops.c
  clang/test/Sema/sizeless-1.c
  clang/test/SemaCXX/sizeless-1.cpp

Index: clang/test/SemaCXX/sizeless-1.cpp
===
--- clang/test/SemaCXX/sizeless-1.cpp
+++ clang/test/SemaCXX/sizeless-1.cpp
@@ -211,11 +211,6 @@
   __real init_int8; // expected-error {{invalid type 'svint8_t'}}
   __imag init_int8; // expected-error {{invalid type 'svint8_t'}}
 
-  local_int8 + init_int8;  // expected-error {{invalid operands to binary expression}}
-  local_int8 - init_int8;  // expected-error {{invalid operands to binary expression}}
-  local_int8 *init_int8;   // expected-error {{invalid operands to binary expression}}
-  local_int8 / init_int8;  // expected-error {{invalid operands to binary expression}}
-  local_int8 % init_int8;  // expected-error {{invalid operands to binary expression}}
   local_int8 &init_int8;   // expected-error {{invalid operands to binary expression}}
   local_int8 | init_int8;  // expected-error {{invalid operands to binary expression}}
   local_int8 ^ init_int8;  // expected-error {{invalid operands to binary expression}}
@@ -230,11 +225,6 @@
   local_int8 &&init_int8;  // expected-error {{invalid operands to binary expression}} expected-error {{not contextually convertible}}
   local_int8 || init_int8; // expected-error {{invalid operands to binary expression}} expected-error {{not contextually convertible}}
 
-  local_int8 += init_int8;  // expected-error {{invalid operands to binary expression}}
-  local_int8 -= init_int8;  // expected-error {{invalid operands to binary expression}}
-  local_int8 *= init_int8;  // expected-error {{invalid operands to binary expression}}
-  local_int8 /= init_int8;  // expected-error {{invalid operands to binary expression}}
-  local_int8 %= init_int8;  // expected-error {{invalid operands to binary expression}}
   local_int8 &= init_int8;  // expected-error {{invalid operands to binary expression}}
   local_int8 |= init_int8;  // expected-error {{invalid operands to binary expression}}
   local_int8 ^= init_int8;  // expected-error {{invalid operands to binary expression}}
Index: clang/test/Sema/sizeless-1.c
===
--- clang/test/Sema/sizeless-1.c
+++ clang/test/Sema/sizeless-1.c
@@ -199,11 +199,6 @@
   __real init_int8; // expected-error {{invalid type 'svint8_t'}}
   __imag init_int8; // expected-error {{invalid type 'svint8_t'}}
 
-  local_int8 + init_int8;  // expected-error {{invalid operands to binary expression}}
-  local_int8 - init_int8;  // expected-error {{invalid operands to binary expression}}
-  local_int8 *init_int8;   // expected-error {{invalid operands to binary expression}}
-  local_int8 / init_int8;  // expected-error {{invalid operands to binary expression}}
-  local_int8 % init_int8;  // expected-error {{invalid operands to binary expression}}
   local_int8 &init_int8;   // expected-error {{invalid operands to binary expression}}
   local_int8 | init_int8;  // expected-error {{invalid operands to binary expression}}
   local_int8 ^ init_int8;  // expected-error {{invalid operands to binary expression}}
@@ -218,11 +213,6 @@
   local_int8 &&init_int8;  // expected-error {{invalid operands to binary expression}}
   local_int8 || init_int8; // expected-error {{invalid operands to binary expression}}
 
-  local_int8 += init_int8;  // expected-error {{invalid operands to binary expression}}
-  local_int8 -= init_int8;  // expected-error {{invalid operands to binary expression}}
-  local_int8 *= init_int8;  // expected-error {{invalid operands to binary expression}}
-  local_int8 /= init_int8;  // expected-error {{invalid operands to binary expression}}
-  local_int8 %= init_int8;  // expected-error {{invalid operands to binary expression}}
   local_int8 &= init_int8;  // expected-error {{invalid operands to binary expression}}
   local_int8 |= init_int8;  // expected-error {{invalid operands to binary expression}}
   local_int8 ^= init_int8;  // expected-error {{invalid operands to binary expression}}
Index: clang/test/Sema/aarch64-sve-vector-ops.c
===
--- /dev/null
+++ clang/test/Sema/aarch64-sve-vector-ops.c
@@ -0,0 +1,645 @@
+// RUN: %clang_cc1 -verify -triple aarch64-none-linux-gnu -target-f

[clang] 02571f8 - [clang][www] Port make_cxx_dr_status script to Python3

2022-02-22 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2022-02-22T15:47:43+01:00
New Revision: 02571f86bb01bbea171072996533d7a6e63bba54

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

LOG: [clang][www] Port make_cxx_dr_status script to Python3

And run it to re-generate the cxx_dr_status.html

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

Added: 


Modified: 
clang/www/cxx_dr_status.html
clang/www/make_cxx_dr_status

Removed: 




diff  --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index 462b335f7801c..62ccfc518d456 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -7304,11 +7304,11 @@ C++ defect report implementation 
status
 Updating Annex C to C99
 Not resolved
   
-  
+  
 https://wg21.link/cwg1249";>1249
-drafting
+DRWP
 Cv-qualification of nested lambda capture
-Not resolved
+Unknown
   
   
 https://wg21.link/cwg1250";>1250
@@ -10006,9 +10006,9 @@ C++ defect report implementation 
status
   
   
 https://wg21.link/cwg1699";>1699
-open
+extension
 Does befriending a class befriend its friends?
-Not resolved
+Extension
   
   
 https://wg21.link/cwg1700";>1700
@@ -10154,11 +10154,11 @@ C++ defect report implementation 
status
 Multicharacter user-defined character literals
 Not resolved
   
-  
+  
 https://wg21.link/cwg1724";>1724
-drafting
+DRWP
 Unclear rules for deduction failure
-Not resolved
+Unknown
   
   
 https://wg21.link/cwg1725";>1725
@@ -10166,11 +10166,11 @@ C++ defect report implementation 
status
 Trailing return type with nested function declarator
 Unknown
   
-  
+  
 https://wg21.link/cwg1726";>1726
-drafting
+DR
 Declarator operators and conversion function
-Not resolved
+Unknown
   
   
 https://wg21.link/cwg1727";>1727
@@ -10208,11 +10208,11 @@ C++ defect report implementation 
status
 Defining types in conditions and range-based for 
statements
 Unknown
   
-  
+  
 https://wg21.link/cwg1733";>1733
-drafting
+DRWP
 Return type and value for operator= with 
ref-qualifier
-Not resolved
+Unknown
   
   
 https://wg21.link/cwg1734";>1734
@@ -14154,7 +14154,7 @@ C++ defect report implementation 
status
 https://wg21.link/cwg2390";>2390
 CD5
 Is the argument of __has_cpp_attribute macro-expanded?
-Unknown
+Yes
   
   
 https://wg21.link/cwg2391";>2391
@@ -14194,7 +14194,7 @@ C++ defect report implementation 
status
   
   
 https://wg21.link/cwg2397";>2397
-DR
+DRWP
 auto specifier for pointers and references to arrays
 Unknown
   
@@ -14250,7 +14250,7 @@ C++ defect report implementation 
status
 https://wg21.link/cwg2406";>2406
 CD5
 [[fallthrough]] attribute and iteration statements
-Unknown
+Yes
   
   
 https://wg21.link/cwg2407";>2407
@@ -14500,7 +14500,7 @@ C++ defect report implementation 
status
   
   
 https://wg21.link/cwg2448";>2448
-DR
+DRWP
 Cv-qualification of arithmetic types and deprecation of volatile
 Unknown
   
@@ -14540,11 +14540,11 @@ C++ defect report implementation 
status
 Tail recursion and coroutine symmetric transfer
 Unknown
   
-  
+  
 https://wg21.link/cwg2455";>2455
-drafting
+WP
 Concatenation of string literals vs translation phases 5 and 6
-Not resolved
+Unknown
   
   
 https://wg21.link/cwg2456";>2456
@@ -14560,7 +14560,7 @@ C++ defect report implementation 
status
   
   
 https://wg21.link/cwg2458";>2458
-DR
+DRWP
 Value category of expressions denoting non-static member functions
 Unknown
   
@@ -14602,13 +14602,13 @@ C++ defect report implementation 
status
   
   
 https://wg21.link/cwg2465";>2465
-DR
+DRWP
 Coroutine parameters passed to a promise constructor
 Unknown
   
   
 https://wg21.link/cwg2466";>2466
-DR
+DRWP
 co_await should be a single evaluation
 Unknown
   
@@ -14656,7 +14656,7 @@ C++ defect report implementation 
status
   
   
 https://wg21.link/cwg2474";>2474
-DR
+DRWP
 Cv-qualification and deletion
 Unknown
   
@@ -14674,7 +14674,7 @@ C++ defect report implementation 
status
   
   
 https://wg21.link/cwg2477";>2477
-DR
+DRWP
 Defaulted vs deleted copy constructors/assignment operators
 Unknown
   
@@ -14686,7 +14686,7 @@ C++ defect report implementation 
status
   
   
 https://wg21.link/cwg2479";>2479
-DR
+DRWP
 Missing specifications for consteval and 
constinit
 Unknown
   
@@ -14698,15 +14698,15 @@ C++ defect report implementation 
status
   
   
 https://wg21.link/cwg2481";>2481
-DR
+DRWP
 Cv-qualification of temporary to wh

[PATCH] D120324: [clang-format] Avoid parsing "requires" as a keyword in non-C++-like languages.

2022-02-22 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius created this revision.
curdeius added reviewers: MyDeveloperDay, HazardyKnusperkeks, owenpan, krasimir.
curdeius requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fixes the issue raised post-review in D113319 
 (cf. 
https://reviews.llvm.org/D113319#3337485).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120324

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTestJS.cpp


Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -323,6 +323,7 @@
   verifyFormat("var struct = 2;");
   verifyFormat("var union = 2;");
   verifyFormat("var interface = 2;");
+  verifyFormat("var requires = {};");
   verifyFormat("interface = 2;");
   verifyFormat("x = interface instanceof y;");
   verifyFormat("interface Test {\n"
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1562,9 +1562,13 @@
   parseConcept();
   return;
 case tok::kw_requires: {
-  bool ParsedClause = parseRequires();
-  if (ParsedClause)
-return;
+  if (Style.isCpp()) {
+bool ParsedClause = parseRequires();
+if (ParsedClause)
+  return;
+  } else {
+nextToken();
+  }
   break;
 }
 case tok::kw_enum:


Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -323,6 +323,7 @@
   verifyFormat("var struct = 2;");
   verifyFormat("var union = 2;");
   verifyFormat("var interface = 2;");
+  verifyFormat("var requires = {};");
   verifyFormat("interface = 2;");
   verifyFormat("x = interface instanceof y;");
   verifyFormat("interface Test {\n"
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1562,9 +1562,13 @@
   parseConcept();
   return;
 case tok::kw_requires: {
-  bool ParsedClause = parseRequires();
-  if (ParsedClause)
-return;
+  if (Style.isCpp()) {
+bool ParsedClause = parseRequires();
+if (ParsedClause)
+  return;
+  } else {
+nextToken();
+  }
   break;
 }
 case tok::kw_enum:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D120313: [clang][www] Port make_cxx_dr_status script to Python3

2022-02-22 Thread Timm Bäder 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 rG02571f86bb01: [clang][www] Port make_cxx_dr_status script to 
Python3 (authored by tbaeder).

Changed prior to commit:
  https://reviews.llvm.org/D120313?vs=410486&id=410525#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120313

Files:
  clang/www/cxx_dr_status.html
  clang/www/make_cxx_dr_status

Index: clang/www/make_cxx_dr_status
===
--- clang/www/make_cxx_dr_status
+++ clang/www/make_cxx_dr_status
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
 import sys, os, re
 
 index = 'cwg_index.html'
@@ -10,7 +10,7 @@
 elif len(sys.argv) == 2:
   index = sys.argv[1]
 else:
-  print >>sys.stderr, 'Usage: make_drs []'
+  print('Usage: make_drs []', file=sys.stderr)
   sys.exit(1)
 
 class DR:
@@ -38,17 +38,16 @@
 continue
   test_cpp = os.path.join(dr_test_dir, test_cpp)
   found_any = False;
-  for match in re.finditer(status_re, file(test_cpp, 'r').read()):
+  for match in re.finditer(status_re, open(test_cpp, 'r').read()):
 status_map[int(match.group(1))] = match.group(2)
 found_any = True
   if not found_any:
-print >> sys.stderr, "warning:%s: no '// dr123: foo' comments in this file" % test_cpp
+print("warning:%s: no '// dr123: foo' comments in this file" % test_cpp, file=sys.stderr)
 
-drs = sorted((parse(dr) for dr in file(index, 'r').read().split('')[2:]),
+drs = sorted((parse(dr) for dr in open(index, 'r').read().split('')[2:]),
  key = lambda dr: dr.issue)
-out_file = file(output, 'w')
-
-print >> out_file, '''\
+out_file = open(output, 'w')
+out_file.write('''\
 http://www.w3.org/TR/html4/strict.dtd";>
 
@@ -90,7 +89,7 @@
 Status
 Issue title
 Available in Clang?
-  '''
+  ''')
 
 latest_release = 13
 
@@ -143,7 +142,7 @@
   try:
 _, avail_style = availability(int(dup))
   except:
-print >>sys.stderr, "issue %s marked as sup %s" % (issue, dup)
+print("issue %s marked as sup %s" % (issue, dup), file=sys.stderr)
 avail_style = ' class="none"'
   elif status.startswith('dup '):
 dup = int(status.split(' ', 1)[1])
@@ -174,20 +173,23 @@
 if not avail.startswith('Sup') and not avail.startswith('Dup'):
   count[avail] = count.get(avail, 0) + 1
 
-  print >> out_file, '''\
+  out_file.write('''
   
 https://wg21.link/cwg%s";>%s
 %s
 %s
 %s
-  ''' % (row_style, dr.issue, dr.issue, dr.issue, dr.status, dr.title, avail_style, avail)
+  ''' % (row_style, dr.issue, dr.issue, dr.issue, dr.status, dr.title, avail_style, avail))
 
 for status, num in sorted(count.items()):
-  print "%s: %s" % (status, num)
+  print("%s: %s" % (status, num))
 
-print >> out_file, '''\
+out_file.write('''\
 
 
 
 
-'''
+
+''')
+out_file.close()
+
Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -7304,11 +7304,11 @@
 Updating Annex C to C99
 Not resolved
   
-  
+  
 https://wg21.link/cwg1249";>1249
-drafting
+DRWP
 Cv-qualification of nested lambda capture
-Not resolved
+Unknown
   
   
 https://wg21.link/cwg1250";>1250
@@ -10006,9 +10006,9 @@
   
   
 https://wg21.link/cwg1699";>1699
-open
+extension
 Does befriending a class befriend its friends?
-Not resolved
+Extension
   
   
 https://wg21.link/cwg1700";>1700
@@ -10154,11 +10154,11 @@
 Multicharacter user-defined character literals
 Not resolved
   
-  
+  
 https://wg21.link/cwg1724";>1724
-drafting
+DRWP
 Unclear rules for deduction failure
-Not resolved
+Unknown
   
   
 https://wg21.link/cwg1725";>1725
@@ -10166,11 +10166,11 @@
 Trailing return type with nested function declarator
 Unknown
   
-  
+  
 https://wg21.link/cwg1726";>1726
-drafting
+DR
 Declarator operators and conversion function
-Not resolved
+Unknown
   
   
 https://wg21.link/cwg1727";>1727
@@ -10208,11 +10208,11 @@
 Defining types in conditions and range-based for statements
 Unknown
   
-  
+  
 https://wg21.link/cwg1733";>1733
-drafting
+DRWP
 Return type and value for operator= with ref-qualifier
-Not resolved
+Unknown
   
   
 https://wg21.link/cwg1734";>1734
@@ -14154,7 +14154,7 @@
 https://wg21.link/cwg2390";>2390
 CD5
 Is the argument of __has_cpp_attribute macro-expanded?
-Unknown
+Yes
   
   
 https://wg21.link/cwg2391";>2391
@@ -14194,7 +14194,7 @@
   
   
 https://wg21.link/cwg2397";>2397
-DR
+DRWP
 auto specifier for pointers and references to arrays
 Unknown
   
@@ -14250,7 +14250,7 @@
 https://wg21.link/cwg2406";>2406
 CD5
 [[f

[PATCH] D113319: [clang-format] Improve require and concept handling

2022-02-22 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

In D113319#3337485 , @krasimir wrote:

> It appears that after this patch clang-format started breaking up `requires` 
> in javascript, e.g.:
>
>   // before
>   function f() {
> var requires = {};
>   }
>   // after
>   function f() {
> var
>   requires
> = {};
>   }
>
> Could we restrict the requires logic only to (obj)C++? (normally I'd go and 
> come up with a patch for cases like this, but this patch is quite large and 
> it's not immediately clear where's the best place for this restriction).

Addressed in https://reviews.llvm.org/D120324.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113319

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


[PATCH] D118588: [C++20][Modules]5/8] Diagnose wrong import/export for partition CMIs.

2022-02-22 Thread Iain Sandoe via Phabricator via cfe-commits
iains updated this revision to Diff 410527.
iains added a comment.

rebased, revised testcases to use split-file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118588

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaModule.cpp
  clang/test/Modules/cxx20-10-3-ex1.cpp
  clang/test/Modules/cxx20-10-3-ex2.cpp
  clang/test/Modules/cxx20-import-diagnostics-a.cpp

Index: clang/test/Modules/cxx20-import-diagnostics-a.cpp
===
--- clang/test/Modules/cxx20-import-diagnostics-a.cpp
+++ clang/test/Modules/cxx20-import-diagnostics-a.cpp
@@ -117,13 +117,13 @@
 
 module B;
 
-import B; // expected-error {{import of module 'B' appears within same top-level module 'B'}}
+import B; // expected-error {{import of module 'B' appears within its own implementation}}
 
 #elif TU == 9
 
 export module B;
 
-import B; // expected-error {{import of module 'B' appears within same top-level module 'B'}}
+import B; // expected-error {{import of module 'B' appears within its own interface}}
 
 #elif TU == 10
 
Index: clang/test/Modules/cxx20-10-3-ex2.cpp
===
--- /dev/null
+++ clang/test/Modules/cxx20-10-3-ex2.cpp
@@ -0,0 +1,25 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/std10-3-ex2-tu1.cpp \
+// RUN:  -o %t/M.pcm
+
+// RUN: %clang_cc1 -std=c++20 -S %t/std10-3-ex2-tu2.cpp \
+// RUN:  -fmodule-file=%t/M.pcm -o %t/tu_8.s -verify
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/std10-3-ex2-tu3.cpp \
+// RUN:  -o %t/M.pcm -verify
+
+//--- std10-3-ex2-tu1.cpp
+export module M;
+
+//--- std10-3-ex2-tu2.cpp
+module M;
+  // error: cannot import M in its own unit
+import M; // expected-error {{import of module 'M' appears within its own implementation}}
+
+//--- std10-3-ex2-tu3.cpp
+export module M;
+  // error: cannot import M in its own unit
+import M; // expected-error {{import of module 'M' appears within its own interface}}
Index: clang/test/Modules/cxx20-10-3-ex1.cpp
===
--- /dev/null
+++ clang/test/Modules/cxx20-10-3-ex1.cpp
@@ -0,0 +1,36 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/std10-3-ex1-tu1.cpp \
+// RUN:  -o %t/M_PartImpl.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/std10-3-ex1-tu2.cpp \
+// RUN:  -fmodule-file=%t/M_PartImpl.pcm -o %t/M.pcm -verify
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/std10-3-ex1-tu3.cpp \
+// RUN:  -o %t/M_Part.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/std10-3-ex1-tu4.cpp \
+// RUN:  -fmodule-file=%t/M_Part.pcm -o %t/M.pcm
+
+//--- std10-3-ex1-tu1.cpp
+module M:PartImpl;
+
+// expected-no-diagnostics
+
+//--- std10-3-ex1-tu2.cpp
+export module M;
+ // error: exported partition :Part is an implementation unit
+export import :PartImpl; // expected-error {{module partition implementations cannot be exported}}
+
+//--- std10-3-ex1-tu3.cpp
+export module M:Part;
+
+// expected-no-diagnostics
+
+//--- std10-3-ex1-tu4.cpp
+export module M;
+export import :Part;
+
+// expected-no-diagnostics
Index: clang/lib/Sema/SemaModule.cpp
===
--- clang/lib/Sema/SemaModule.cpp
+++ clang/lib/Sema/SemaModule.cpp
@@ -403,10 +403,16 @@
   }
 
   // Diagnose self-import before attempting a load.
+  // [module.import]/9
+  // A module implementation unit of a module M that is not a module partition
+  // shall not contain a module-import-declaration nominating M.
+  // (for an implementation, the module interface is imported implicitly,
+  //  but that's handled in the module decl code).
+
   if (getLangOpts().CPlusPlusModules && isCurrentModulePurview() &&
   getCurrentModule()->Name == ModuleName) {
-Diag(ImportLoc, diag::err_module_self_import)
-<< ModuleName << getLangOpts().CurrentModule;
+Diag(ImportLoc, diag::err_module_self_import_cxx20)
+<< ModuleName << !ModuleScopes.back().ModuleInterface;
 return true;
   }
 
@@ -440,8 +446,7 @@
   // of the same top-level module. Until we do, make it an error rather than
   // silently ignoring the import.
   // FIXME: Should we warn on a redundant import of the current module?
-  if (!getLangOpts().CPlusPlusModules &&
-  Mod->getTopLevelModuleName() == getLangOpts().CurrentModule &&
+  if (Mod->getTopLevelModuleName() == getLangOpts().CurrentModule &&
   (getLangOpts().isCompilingModule() || !getLangOpts().ModulesTS)) {
 Diag(ImportLoc, getLangOpts().isCompilingModule()
 ? diag::err_module_self_import
@@ -482,7 +487,12 @@
   if (!ModuleScopes.empty())
 Context.addModuleInitializer(Mod

[PATCH] D120325: [analyzer] Don't crash if the analyzer-constraint is set to Z3, but llvm is not built with it

2022-02-22 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus created this revision.
Szelethus added reviewers: NoQ, dkrupp, steakhal, martong, balazske.
Szelethus added a project: clang.
Herald added subscribers: ASDenysPetrov, gamesh411, donat.nagy, 
mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, xazax.hun.
Szelethus requested review of this revision.
Herald added a subscriber: cfe-commits.

Exactly what it says on the tin! We had a nasty crash with the following 
incovation:

  $ clang --analyze -Xclang -analyzer-constraints=z3 test.c
  fatal error: error in backend: LLVM was not compiled with Z3 support, rebuild 
with -DLLVM_ENABLE_Z3_SOLVER=ON
  ...  ...


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120325

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Analysis/missing-z3-nocrash.c
  clang/test/lit.cfg.py


Index: clang/test/lit.cfg.py
===
--- clang/test/lit.cfg.py
+++ clang/test/lit.cfg.py
@@ -100,6 +100,8 @@
 
 if config.clang_staticanalyzer_z3:
 config.available_features.add('z3')
+else:
+config.available_features.add('no-z3')
 
 check_analyzer_fixit_path = os.path.join(
 config.test_source_root, "Analysis", "check-analyzer-fixit.py")
Index: clang/test/Analysis/missing-z3-nocrash.c
===
--- /dev/null
+++ clang/test/Analysis/missing-z3-nocrash.c
@@ -0,0 +1,5 @@
+// RUN: not %clang_analyze_cc1 -analyzer-constraints=z3 %s 2>&1 | FileCheck %s
+// REQUIRES: no-z3
+
+// CHECK: error: analyzer constraint manager 'z3' is only available if LLVM
+// CHECK: was built with -DLLVM_ENABLE_Z3_SOLVER=ON
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -915,6 +915,11 @@
   Diags.Report(diag::err_drv_invalid_value)
 << A->getAsString(Args) << Name;
 } else {
+#if !LLVM_WITH_Z3
+  if (Value == AnalysisConstraints::Z3ConstraintsModel) {
+Diags.Report(diag::err_analyzer_not_built_with_z3);
+  }
+#endif // LLVM_WITH_Z3
   Opts.AnalysisConstraintsOpt = Value;
 }
   }
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -441,6 +441,9 @@
   "invalid input for checker option '%0', that expects %1">;
 def err_analyzer_checker_incompatible_analyzer_option : Error<
   "checker cannot be enabled with analyzer option '%0' == %1">;
+def err_analyzer_not_built_with_z3 : Error<
+  "analyzer constraint manager 'z3' is only available if LLVM was built with "
+  "-DLLVM_ENABLE_Z3_SOLVER=ON">;
 
 def warn_drv_needs_hvx : Warning<
   "%0 requires HVX, use -mhvx/-mhvx= to enable it">,


Index: clang/test/lit.cfg.py
===
--- clang/test/lit.cfg.py
+++ clang/test/lit.cfg.py
@@ -100,6 +100,8 @@
 
 if config.clang_staticanalyzer_z3:
 config.available_features.add('z3')
+else:
+config.available_features.add('no-z3')
 
 check_analyzer_fixit_path = os.path.join(
 config.test_source_root, "Analysis", "check-analyzer-fixit.py")
Index: clang/test/Analysis/missing-z3-nocrash.c
===
--- /dev/null
+++ clang/test/Analysis/missing-z3-nocrash.c
@@ -0,0 +1,5 @@
+// RUN: not %clang_analyze_cc1 -analyzer-constraints=z3 %s 2>&1 | FileCheck %s
+// REQUIRES: no-z3
+
+// CHECK: error: analyzer constraint manager 'z3' is only available if LLVM
+// CHECK: was built with -DLLVM_ENABLE_Z3_SOLVER=ON
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -915,6 +915,11 @@
   Diags.Report(diag::err_drv_invalid_value)
 << A->getAsString(Args) << Name;
 } else {
+#if !LLVM_WITH_Z3
+  if (Value == AnalysisConstraints::Z3ConstraintsModel) {
+Diags.Report(diag::err_analyzer_not_built_with_z3);
+  }
+#endif // LLVM_WITH_Z3
   Opts.AnalysisConstraintsOpt = Value;
 }
   }
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -441,6 +441,9 @@
   "invalid input for checker option '%0', that expects %1">;
 def err_analyzer_checker_incompatible_analyzer_option : Error<
   "checker cannot be enabled with analyzer option '%0' == %1">;
+def err_analyzer_not_built_with_z3 : Error<
+  "analyzer constraint manager 'z3' is only available if LLVM was buil

[PATCH] D118589: [C++20][Modules][6/8] Record direct module imports.

2022-02-22 Thread Iain Sandoe via Phabricator via cfe-commits
iains updated this revision to Diff 410528.
iains added a comment.

rebased.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118589

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaModule.cpp


Index: clang/lib/Sema/SemaModule.cpp
===
--- clang/lib/Sema/SemaModule.cpp
+++ clang/lib/Sema/SemaModule.cpp
@@ -513,6 +513,11 @@
 assert(ThisModule && "was expecting a module if building one");
   }
 
+  // In some cases we need to know if an entity was present in a directly-
+  // imported module (as opposed to a transitive import).  This avoids
+  // searching both Imports and Exports.
+  DirectModuleImports.insert(Mod);
+
   return Import;
 }
 
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -,6 +,9 @@
   /// The global module fragment of the current translation unit.
   clang::Module *GlobalModuleFragment = nullptr;
 
+  /// The modules we imported directly.
+  llvm::SmallPtrSet DirectModuleImports;
+
   /// Namespace definitions that we will export when they finish.
   llvm::SmallPtrSet DeferredExportedNamespaces;
 
@@ -2249,6 +2252,10 @@
 return Entity->getOwningModule();
   }
 
+  bool isModuleDirectlyImported(const Module *M) {
+return DirectModuleImports.contains(M);
+  }
+
   /// Make a merged definition of an existing hidden definition \p ND
   /// visible at the specified location.
   void makeMergedDefinitionVisible(NamedDecl *ND);


Index: clang/lib/Sema/SemaModule.cpp
===
--- clang/lib/Sema/SemaModule.cpp
+++ clang/lib/Sema/SemaModule.cpp
@@ -513,6 +513,11 @@
 assert(ThisModule && "was expecting a module if building one");
   }
 
+  // In some cases we need to know if an entity was present in a directly-
+  // imported module (as opposed to a transitive import).  This avoids
+  // searching both Imports and Exports.
+  DirectModuleImports.insert(Mod);
+
   return Import;
 }
 
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -,6 +,9 @@
   /// The global module fragment of the current translation unit.
   clang::Module *GlobalModuleFragment = nullptr;
 
+  /// The modules we imported directly.
+  llvm::SmallPtrSet DirectModuleImports;
+
   /// Namespace definitions that we will export when they finish.
   llvm::SmallPtrSet DeferredExportedNamespaces;
 
@@ -2249,6 +2252,10 @@
 return Entity->getOwningModule();
   }
 
+  bool isModuleDirectlyImported(const Module *M) {
+return DirectModuleImports.contains(M);
+  }
+
   /// Make a merged definition of an existing hidden definition \p ND
   /// visible at the specified location.
   void makeMergedDefinitionVisible(NamedDecl *ND);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D120266: [clang][CodeGen] Avoid emitting ifuncs with undefined resolvers

2022-02-22 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

So to clarify: The purpose of this patch is to change the call to an 'ifunc' 
(named FOO.ifunc) to an llvm::Function with the same name?  And this later gets 
replaced by the cpu-dispatch version in the other translation unit? (or, is a 
linker failure?).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120266

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


[PATCH] D113319: [clang-format] Improve require and concept handling

2022-02-22 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

In D113319#3337612 <https://reviews.llvm.org/D113319#3337612>, @krasimir wrote:

> It appears that this causes a regression by adding a space in-between pointer 
> dereferences `*p` -> `* p` in some cases, e.g. formatting this with llvm 
> style:
>
>   // before
>   void f() {
> while (p < a && *p == 'a')
>   p++;
>   }
>   // after
>   void f() {
> while (p < a && * p == 'a')
>   p++;
>   }

`*` in `*p` is indeed annotated as a binary operator now:

  
clang-format-main-20220110-5ff916ab72b26e667bd5d2e4a762650ba479c781--style=file 
--debug-only=format-token-annotator test.cpp
  AnnotatedTokens(L=0):
   M=0 C=0 T=Unknown S=1 F=0 B=0 BK=0 P=0 Name=while L=5 PPK=2 FakeLParens= 
FakeRParens=0 II=0x2f4bf80a6a0 Text='while'
   M=0 C=0 T=Unknown S=1 F=0 B=0 BK=0 P=23 Name=l_paren L=7 PPK=2 FakeLParens= 
FakeRParens=0 II=0x0 Text='('
   M=0 C=1 T=Unknown S=0 F=0 B=0 BK=0 P=59 Name=identifier L=8 PPK=2 
FakeLParens=10/5/ FakeRParens=0 II=0x2f4bf806fd8 Text='p'
   M=0 C=0 T=BinaryOperator S=1 F=0 B=0 BK=0 P=50 Name=less L=10 PPK=2 
FakeLParens= FakeRParens=0 II=0x0 Text='<'
   M=0 C=1 T=Unknown S=1 F=0 B=0 BK=0 P=50 Name=identifier L=12 PPK=2 
FakeLParens= FakeRParens=1 II=0x2f4bf807008 Text='q'
   M=0 C=0 T=BinaryOperator S=1 F=0 B=0 BK=0 P=45 Name=ampamp L=15 PPK=2 
FakeLParens= FakeRParens=0 II=0x0 Text='&&'
   M=0 C=1 T=UnaryOperator S=1 F=0 B=0 BK=0 P=45 Name=star L=17 PPK=2 
FakeLParens=0/ FakeRParens=0 II=0x0 Text='*'
   M=0 C=0 T=Unknown S=0 F=0 B=0 BK=0 P=100 Name=identifier L=18 PPK=2 
FakeLParens= FakeRParens=2 II=0x2f4bf806fd8 Text='p'
   M=0 C=0 T=Unknown S=0 F=0 B=0 BK=0 P=43 Name=r_paren L=19 PPK=2 FakeLParens= 
FakeRParens=0 II=0x0 Text=')'
  
  AnnotatedTokens(L=1):
   M=0 C=0 T=Unknown S=1 F=0 B=0 BK=0 P=0 Name=semi L=1 PPK=2 FakeLParens= 
FakeRParens=0 II=0x0 Text=';'
  
  AnnotatedTokens(L=0):
   M=0 C=0 T=Unknown S=1 F=0 B=0 BK=0 P=0 Name=eof L=0 PPK=2 FakeLParens= 
FakeRParens=0 II=0x0 Text=''
  
  while (p < q && *p)
;

whereas it was (correctly) a unary operator:

  clang-format-main-20220222-e0219872--style=file 
--debug-only=format-token-annotator test.cpp
  AnnotatedTokens(L=0):
   M=0 C=0 T=Unknown S=1 F=0 B=0 BK=0 P=0 Name=while L=5 PPK=2 FakeLParens= 
FakeRParens=0 II=0x23639666fa0 Text='while'
   M=0 C=0 T=Unknown S=1 F=0 B=0 BK=0 P=23 Name=l_paren L=7 PPK=2 FakeLParens= 
FakeRParens=0 II=0x0 Text='('
   M=0 C=1 T=Unknown S=0 F=0 B=0 BK=0 P=59 Name=identifier L=8 PPK=2 
FakeLParens=10/5/ FakeRParens=0 II=0x236396a30a0 Text='p'
   M=0 C=0 T=BinaryOperator S=1 F=0 B=0 BK=0 P=50 Name=less L=10 PPK=2 
FakeLParens= FakeRParens=0 II=0x0 Text='<'
   M=0 C=1 T=Unknown S=1 F=0 B=0 BK=0 P=50 Name=identifier L=12 PPK=2 
FakeLParens= FakeRParens=1 II=0x236396a30d0 Text='q'
   M=0 C=0 T=BinaryOperator S=1 F=0 B=0 BK=0 P=45 Name=ampamp L=15 PPK=2 
FakeLParens= FakeRParens=0 II=0x0 Text='&&'
   M=0 C=1 T=BinaryOperator S=1 F=0 B=0 BK=0 P=45 Name=star L=17 PPK=2 
FakeLParens=14/ FakeRParens=0 II=0x0 Text='*'
   M=0 C=1 T=Unknown S=1 F=0 B=0 BK=0 P=54 Name=identifier L=19 PPK=2 
FakeLParens= FakeRParens=2 II=0x236396a30a0 Text='p'
   M=0 C=0 T=Unknown S=0 F=0 B=0 BK=0 P=43 Name=r_paren L=20 PPK=2 FakeLParens= 
FakeRParens=0 II=0x0 Text=')'
  
  AnnotatedTokens(L=1):
   M=0 C=0 T=Unknown S=1 F=0 B=0 BK=0 P=0 Name=semi L=1 PPK=2 FakeLParens= 
FakeRParens=0 II=0x0 Text=';'
  
  AnnotatedTokens(L=0):
   M=0 C=0 T=Unknown S=1 F=0 B=0 BK=0 P=0 Name=eof L=0 PPK=2 FakeLParens= 
FakeRParens=0 II=0x0 Text=''
  
  while (p < q && * p)
;


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113319

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


[PATCH] D120324: [clang-format] Avoid parsing "requires" as a keyword in non-C++-like languages.

2022-02-22 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir accepted this revision.
krasimir added a comment.
This revision is now accepted and ready to land.

Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120324

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


[PATCH] D119199: replace clang LLVM_ENABLE_PLUGINS -> CLANG_PLUGIN_SUPPORT in tests

2022-02-22 Thread Jameson Nash via Phabricator via cfe-commits
vtjnash added a comment.

Is that a bug in clang or in MSVC2019? We expected that CLANG_PLUGIN_SUPPORT=ON 
can expose problems with the Windows linker, and we add new tests here for 
verifying that configuration is functioning as expected. You might need to 
disable CLANG_PLUGIN_SUPPORT on that target?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119199

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


[clang] f8cedc6 - [clang] Never wrap a nullptr in CXXNewExpr::getArraySize()

2022-02-22 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2022-02-22T16:27:32+01:00
New Revision: f8cedc642d9b85720cb7175ef25ddde90a3fbca2

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

LOG: [clang] Never wrap a nullptr in CXXNewExpr::getArraySize()

Otherwise callers of these functions have to check both the return value
for and the contents of the returned llvm::Optional.

Fixes #53742

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

Added: 
clang/test/AST/issue53742.cpp

Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/AST/ExprCXX.h
clang/lib/AST/ExprConstant.cpp
clang/lib/AST/StmtPrinter.cpp
clang/lib/Sema/TreeTransform.h

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 499b065fe6e07..8de1e65a83dc4 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -54,6 +54,14 @@ Major New Features
   There is an analogous ``zero_call_used_regs`` attribute to allow for finer
   control of this feature.
 
+Bug Fixes
+--
+- ``CXXNewExpr::getArraySize()`` previously returned a ``llvm::Optional``
+  wrapping a ``nullptr`` when the ``CXXNewExpr`` did not have an array
+  size expression. This was fixed and ``::getArraySize()`` will now always
+  either return ``None`` or a ``llvm::Optional`` wrapping a valid ``Expr*``.
+  This fixes `Issue 
#53742`_.
+
 Improvements to Clang's diagnostics
 ^^^
 
@@ -83,7 +91,8 @@ Attribute Changes in Clang
 - Added support for parameter pack expansion in `clang::annotate`.
 
 - The ``overloadable`` attribute can now be written in all of the syntactic
-  locations a declaration attribute may appear. Fixes PR53805.
+  locations a declaration attribute may appear.
+  This fixes `Issue 
#53805`_.
 
 Windows Support
 ---

diff  --git a/clang/include/clang/AST/ExprCXX.h 
b/clang/include/clang/AST/ExprCXX.h
index 161287adce4ca..3da9290c7dfbe 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -2261,15 +2261,32 @@ class CXXNewExpr final
 
   bool isArray() const { return CXXNewExprBits.IsArray; }
 
+  /// This might return None even if isArray() returns true,
+  /// since there might not be an array size expression.
+  /// If the result is not-None, it will never wrap a nullptr.
   Optional getArraySize() {
 if (!isArray())
   return None;
-return cast_or_null(getTrailingObjects()[arraySizeOffset()]);
+
+if (auto *Result =
+cast_or_null(getTrailingObjects()[arraySizeOffset()]))
+  return Result;
+
+return None;
   }
+
+  /// This might return None even if isArray() returns true,
+  /// since there might not be an array size expression.
+  /// If the result is not-None, it will never wrap a nullptr.
   Optional getArraySize() const {
 if (!isArray())
   return None;
-return cast_or_null(getTrailingObjects()[arraySizeOffset()]);
+
+if (auto *Result =
+cast_or_null(getTrailingObjects()[arraySizeOffset()]))
+  return Result;
+
+return None;
   }
 
   unsigned getNumPlacementArgs() const {

diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 163109bf7c9f5..99f136a72d6fe 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -9427,7 +9427,7 @@ bool PointerExprEvaluator::VisitCXXNewExpr(const 
CXXNewExpr *E) {
   bool ValueInit = false;
 
   QualType AllocType = E->getAllocatedType();
-  if (Optional ArraySize = E->getArraySize()) {
+  if (Optional ArraySize = E->getArraySize()) {
 const Expr *Stripped = *ArraySize;
 for (; auto *ICE = dyn_cast(Stripped);
  Stripped = ICE->getSubExpr())

diff  --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp
index 746bf8c21cd72..5ad935591ecd9 100644
--- a/clang/lib/AST/StmtPrinter.cpp
+++ b/clang/lib/AST/StmtPrinter.cpp
@@ -2132,10 +2132,10 @@ void StmtPrinter::VisitCXXNewExpr(CXXNewExpr *E) {
   if (E->isParenTypeId())
 OS << "(";
   std::string TypeS;
-  if (Optional Size = E->getArraySize()) {
+  if (E->isArray()) {
 llvm::raw_string_ostream s(TypeS);
 s << '[';
-if (*Size)
+if (Optional Size = E->getArraySize())
   (*Size)->printPretty(s, Helper, Policy);
 s << ']';
   }

diff  --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 466a156add516..0716689d4b626 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -11912,9 +11912,9 @@ TreeTransform::TransformCXXNewExpr(CXXNewExpr 
*E) {
 
   // Transform the size of the array we're allocating (if any).
   Optional ArraySize;
-  if (Optional OldArraySize = E->getArraySize()

[PATCH] D119525: [clang] Fix crash when array size is missing in initializer

2022-02-22 Thread Timm Bäder via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
tbaeder marked an inline comment as done.
Closed by commit rGf8cedc642d9b: [clang] Never wrap a nullptr in 
CXXNewExpr::getArraySize() (authored by tbaeder).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119525

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ExprCXX.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/Sema/TreeTransform.h
  clang/test/AST/issue53742.cpp

Index: clang/test/AST/issue53742.cpp
===
--- /dev/null
+++ clang/test/AST/issue53742.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only %s -verify
+
+struct Data {
+  char *a;
+  char *b;
+  bool *c;
+};
+
+int main() {
+  Data in;
+  in.a = new char[](); // expected-error {{cannot determine allocated array size from initializer}}
+  in.c = new bool[100]();
+  in.b = new char[100]();
+}
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -11912,9 +11912,9 @@
 
   // Transform the size of the array we're allocating (if any).
   Optional ArraySize;
-  if (Optional OldArraySize = E->getArraySize()) {
+  if (E->isArray()) {
 ExprResult NewArraySize;
-if (*OldArraySize) {
+if (Optional OldArraySize = E->getArraySize()) {
   NewArraySize = getDerived().TransformExpr(*OldArraySize);
   if (NewArraySize.isInvalid())
 return ExprError();
Index: clang/lib/AST/StmtPrinter.cpp
===
--- clang/lib/AST/StmtPrinter.cpp
+++ clang/lib/AST/StmtPrinter.cpp
@@ -2132,10 +2132,10 @@
   if (E->isParenTypeId())
 OS << "(";
   std::string TypeS;
-  if (Optional Size = E->getArraySize()) {
+  if (E->isArray()) {
 llvm::raw_string_ostream s(TypeS);
 s << '[';
-if (*Size)
+if (Optional Size = E->getArraySize())
   (*Size)->printPretty(s, Helper, Policy);
 s << ']';
   }
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -9427,7 +9427,7 @@
   bool ValueInit = false;
 
   QualType AllocType = E->getAllocatedType();
-  if (Optional ArraySize = E->getArraySize()) {
+  if (Optional ArraySize = E->getArraySize()) {
 const Expr *Stripped = *ArraySize;
 for (; auto *ICE = dyn_cast(Stripped);
  Stripped = ICE->getSubExpr())
Index: clang/include/clang/AST/ExprCXX.h
===
--- clang/include/clang/AST/ExprCXX.h
+++ clang/include/clang/AST/ExprCXX.h
@@ -2261,15 +2261,32 @@
 
   bool isArray() const { return CXXNewExprBits.IsArray; }
 
+  /// This might return None even if isArray() returns true,
+  /// since there might not be an array size expression.
+  /// If the result is not-None, it will never wrap a nullptr.
   Optional getArraySize() {
 if (!isArray())
   return None;
-return cast_or_null(getTrailingObjects()[arraySizeOffset()]);
+
+if (auto *Result =
+cast_or_null(getTrailingObjects()[arraySizeOffset()]))
+  return Result;
+
+return None;
   }
+
+  /// This might return None even if isArray() returns true,
+  /// since there might not be an array size expression.
+  /// If the result is not-None, it will never wrap a nullptr.
   Optional getArraySize() const {
 if (!isArray())
   return None;
-return cast_or_null(getTrailingObjects()[arraySizeOffset()]);
+
+if (auto *Result =
+cast_or_null(getTrailingObjects()[arraySizeOffset()]))
+  return Result;
+
+return None;
   }
 
   unsigned getNumPlacementArgs() const {
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -54,6 +54,14 @@
   There is an analogous ``zero_call_used_regs`` attribute to allow for finer
   control of this feature.
 
+Bug Fixes
+--
+- ``CXXNewExpr::getArraySize()`` previously returned a ``llvm::Optional``
+  wrapping a ``nullptr`` when the ``CXXNewExpr`` did not have an array
+  size expression. This was fixed and ``::getArraySize()`` will now always
+  either return ``None`` or a ``llvm::Optional`` wrapping a valid ``Expr*``.
+  This fixes `Issue #53742`_.
+
 Improvements to Clang's diagnostics
 ^^^
 
@@ -83,7 +91,8 @@
 - Added support for parameter pack expansion in `clang::annotate`.
 
 - The ``overloadable`` attribute can now be written in all of the syntactic
-  locations a declaration attribute may appear. Fixes PR53805.
+  locations a declaration attr

[clang] 535a230 - Fix docs build after f8cedc642d9b85720cb7175ef25ddde90a3fbca2

2022-02-22 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2022-02-22T16:35:35+01:00
New Revision: 535a23053bbb0945b7ed0925cbc7d6d7227487f7

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

LOG: Fix docs build after f8cedc642d9b85720cb7175ef25ddde90a3fbca2

Looks like rst doesn't like '#' in link texts. Just remove it.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 8de1e65a83dc..7e92224901d4 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -60,7 +60,7 @@ Bug Fixes
   wrapping a ``nullptr`` when the ``CXXNewExpr`` did not have an array
   size expression. This was fixed and ``::getArraySize()`` will now always
   either return ``None`` or a ``llvm::Optional`` wrapping a valid ``Expr*``.
-  This fixes `Issue 
#53742`_.
+  This fixes `Issue 53742`_.
 
 Improvements to Clang's diagnostics
 ^^^
@@ -92,7 +92,7 @@ Attribute Changes in Clang
 
 - The ``overloadable`` attribute can now be written in all of the syntactic
   locations a declaration attribute may appear.
-  This fixes `Issue 
#53805`_.
+  This fixes `Issue 53805`_.
 
 Windows Support
 ---



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


[PATCH] D120251: [clang][driver][wasm] Fix libstdc++ target-dependent include dir

2022-02-22 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added a comment.

In D120251#3336981 , @tbaeder wrote:

> @sbc100 Do you think we should add `/backward` as well? `Gnu.cpp` does that 
> it seems: 
> https://github.com/llvm/llvm-project/blob/main/clang/lib/Driver/ToolChains/Gnu.cpp#L2959-L2960

I don't see why not.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120251

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


[PATCH] D104931: [AArch64] Wire up ILP32 ABI support in Clang

2022-02-22 Thread Amanieu d'Antras via Phabricator via cfe-commits
Amanieu added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104931

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


[clang] fee4a97 - [clang-format] Use FormatToken::is* functions without passing through `Tok`. NFC.

2022-02-22 Thread Marek Kurdej via cfe-commits

Author: Marek Kurdej
Date: 2022-02-22T16:41:15+01:00
New Revision: fee4a9712f58caa9f1c3fc6c76ac46c5407475b6

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

LOG: [clang-format] Use FormatToken::is* functions without passing through 
`Tok`. NFC.

Added: 


Modified: 
clang/lib/Format/ContinuationIndenter.cpp
clang/lib/Format/FormatTokenLexer.cpp
clang/lib/Format/TokenAnnotator.cpp
clang/lib/Format/UnwrappedLineParser.cpp

Removed: 




diff  --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index ec268e74fd97..62e0d01871e8 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -1634,7 +1634,7 @@ void 
ContinuationIndenter::moveStatePastScopeOpener(LineState &State,
   NewState.HasMultipleNestedBlocks = (Current.BlockParameterCount > 1);
 
   if (Style.BraceWrapping.BeforeLambdaBody && Current.Next != nullptr &&
-  Current.Tok.is(tok::l_paren)) {
+  Current.is(tok::l_paren)) {
 // Search for any parameter that is a lambda
 FormatToken const *next = Current.Next;
 while (next != nullptr) {

diff  --git a/clang/lib/Format/FormatTokenLexer.cpp 
b/clang/lib/Format/FormatTokenLexer.cpp
index 1540c14686fa..a48db4ef6d90 100644
--- a/clang/lib/Format/FormatTokenLexer.cpp
+++ b/clang/lib/Format/FormatTokenLexer.cpp
@@ -91,7 +91,7 @@ ArrayRef FormatTokenLexer::lex() {
   handleCSharpVerbatimAndInterpolatedStrings();
 if (Tokens.back()->NewlinesBefore > 0 || Tokens.back()->IsMultiline)
   FirstInLineIndex = Tokens.size() - 1;
-  } while (Tokens.back()->Tok.isNot(tok::eof));
+  } while (Tokens.back()->isNot(tok::eof));
   return Tokens;
 }
 
@@ -851,7 +851,7 @@ FormatToken *FormatTokenLexer::getNextToken() {
 
   // Consume and record whitespace until we find a significant token.
   unsigned WhitespaceLength = TrailingWhitespace;
-  while (FormatTok->Tok.is(tok::unknown)) {
+  while (FormatTok->is(tok::unknown)) {
 StringRef Text = FormatTok->TokenText;
 auto EscapesNewline = [&](int pos) {
   // A '\r' here is just part of '\r\n'. Skip it.
@@ -965,12 +965,12 @@ FormatToken *FormatTokenLexer::getNextToken() {
   FormatTok->OriginalColumn = Column;
 
   TrailingWhitespace = 0;
-  if (FormatTok->Tok.is(tok::comment)) {
+  if (FormatTok->is(tok::comment)) {
 // FIXME: Add the trimmed whitespace to Column.
 StringRef UntrimmedText = FormatTok->TokenText;
 FormatTok->TokenText = FormatTok->TokenText.rtrim(" \t\v\f");
 TrailingWhitespace = UntrimmedText.size() - FormatTok->TokenText.size();
-  } else if (FormatTok->Tok.is(tok::raw_identifier)) {
+  } else if (FormatTok->is(tok::raw_identifier)) {
 IdentifierInfo &Info = IdentTable.get(FormatTok->TokenText);
 FormatTok->Tok.setIdentifierInfo(&Info);
 FormatTok->Tok.setKind(Info.getTokenID());
@@ -985,12 +985,12 @@ FormatToken *FormatTokenLexer::getNextToken() {
   FormatTok->Tok.setKind(tok::identifier);
   FormatTok->Tok.setIdentifierInfo(nullptr);
 }
-  } else if (FormatTok->Tok.is(tok::greatergreater)) {
+  } else if (FormatTok->is(tok::greatergreater)) {
 FormatTok->Tok.setKind(tok::greater);
 FormatTok->TokenText = FormatTok->TokenText.substr(0, 1);
 ++Column;
 StateStack.push(LexerState::TOKEN_STASHED);
-  } else if (FormatTok->Tok.is(tok::lessless)) {
+  } else if (FormatTok->is(tok::lessless)) {
 FormatTok->Tok.setKind(tok::less);
 FormatTok->TokenText = FormatTok->TokenText.substr(0, 1);
 ++Column;

diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 9a020eb6ca7d..7649263a18a1 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -114,7 +114,7 @@ class AnnotatingParser {
 // If there's a template keyword before the opening angle bracket, this is 
a
 // template parameter, not an argument.
 Contexts.back().InTemplateArgument =
-Left->Previous && Left->Previous->Tok.isNot(tok::kw_template);
+Left->Previous && Left->Previous->isNot(tok::kw_template);
 
 if (Style.Language == FormatStyle::LK_Java &&
 CurrentToken->is(tok::question))
@@ -1266,7 +1266,7 @@ class AnnotatingParser {
   return LT_ImportStatement;
 }
 
-if (CurrentToken->Tok.is(tok::numeric_constant)) {
+if (CurrentToken->is(tok::numeric_constant)) {
   CurrentToken->SpacesRequiredBefore = 1;
   return Type;
 }
@@ -1743,7 +1743,7 @@ class AnnotatingParser {
  tok::coloncolon))
 if (FormatToken *AfterParen = Current.MatchingParen->Next) {
   // Make sure this isn't the return type of an Obj-C block declaration
-  if (AfterParen->Tok.isNot(tok::caret)) {
+ 

[PATCH] D119128: [analyzer] Fix taint propagation by remembering to the location context

2022-02-22 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

Can we reopen this if the code is not upstream at this time?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119128

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


[clang] 071f870 - [clang-format] Avoid parsing "requires" as a keyword in non-C++-like languages.

2022-02-22 Thread Marek Kurdej via cfe-commits

Author: Marek Kurdej
Date: 2022-02-22T16:55:38+01:00
New Revision: 071f870e7ff0a3d04f0d93852ff7c29b59111f78

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

LOG: [clang-format] Avoid parsing "requires" as a keyword in non-C++-like 
languages.

Fixes the issue raised post-review in D113319 (cf. 
https://reviews.llvm.org/D113319#3337485).

Reviewed By: krasimir

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

Added: 


Modified: 
clang/lib/Format/UnwrappedLineParser.cpp
clang/unittests/Format/FormatTestJS.cpp

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index 35465bf9a85b..e2cbcea14d7a 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -1563,9 +1563,13 @@ void 
UnwrappedLineParser::parseStructuralElement(IfStmtKind *IfKind,
   parseConcept();
   return;
 case tok::kw_requires: {
-  bool ParsedClause = parseRequires();
-  if (ParsedClause)
-return;
+  if (Style.isCpp()) {
+bool ParsedClause = parseRequires();
+if (ParsedClause)
+  return;
+  } else {
+nextToken();
+  }
   break;
 }
 case tok::kw_enum:

diff  --git a/clang/unittests/Format/FormatTestJS.cpp 
b/clang/unittests/Format/FormatTestJS.cpp
index d84533e8a2b0..67df2d41731a 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -323,6 +323,7 @@ TEST_F(FormatTestJS, ReservedWords) {
   verifyFormat("var struct = 2;");
   verifyFormat("var union = 2;");
   verifyFormat("var interface = 2;");
+  verifyFormat("var requires = {};");
   verifyFormat("interface = 2;");
   verifyFormat("x = interface instanceof y;");
   verifyFormat("interface Test {\n"



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


[PATCH] D120324: [clang-format] Avoid parsing "requires" as a keyword in non-C++-like languages.

2022-02-22 Thread Marek Kurdej 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 rG071f870e7ff0: [clang-format] Avoid parsing 
"requires" as a keyword in non-C++-like languages. (authored by 
curdeius).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120324

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTestJS.cpp


Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -323,6 +323,7 @@
   verifyFormat("var struct = 2;");
   verifyFormat("var union = 2;");
   verifyFormat("var interface = 2;");
+  verifyFormat("var requires = {};");
   verifyFormat("interface = 2;");
   verifyFormat("x = interface instanceof y;");
   verifyFormat("interface Test {\n"
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1563,9 +1563,13 @@
   parseConcept();
   return;
 case tok::kw_requires: {
-  bool ParsedClause = parseRequires();
-  if (ParsedClause)
-return;
+  if (Style.isCpp()) {
+bool ParsedClause = parseRequires();
+if (ParsedClause)
+  return;
+  } else {
+nextToken();
+  }
   break;
 }
 case tok::kw_enum:


Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -323,6 +323,7 @@
   verifyFormat("var struct = 2;");
   verifyFormat("var union = 2;");
   verifyFormat("var interface = 2;");
+  verifyFormat("var requires = {};");
   verifyFormat("interface = 2;");
   verifyFormat("x = interface instanceof y;");
   verifyFormat("interface Test {\n"
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1563,9 +1563,13 @@
   parseConcept();
   return;
 case tok::kw_requires: {
-  bool ParsedClause = parseRequires();
-  if (ParsedClause)
-return;
+  if (Style.isCpp()) {
+bool ParsedClause = parseRequires();
+if (ParsedClause)
+  return;
+  } else {
+nextToken();
+  }
   break;
 }
 case tok::kw_enum:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D120310: [clang][analyzer] Add modeling of 'errno' (work-in-progress).

2022-02-22 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

Good start!

However, I'm not a big fan of coupling the testing checker with the actual 
modeling checker.
IMO we should have a distinct checker, similarly to `TaintTester`. That way you 
could do even fancier things like:
define `mylib_may_fail()`, bifurcate and return `true` for the success case, on 
which it wouldn't touch `errno`; and on the failure case return `false` and set 
the `errno` to some concrete value that we could check against.

But I'm also fine with the current approach, providing the `set_errno(SVal)` 
introspection function.




Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h:767-768
s->getType()->isBlockPointerType());
-assert(isa(sreg) || isa(sreg));
+assert(isa(sreg) || isa(sreg) ||
+   isa(sreg));
   }

At this point, I'm not even sure if we should assert any of these.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h:1378
 
   /// Retrieve or create a "symbolic" memory region.
+  const SymbolicRegion *





Comment at: clang/lib/StaticAnalyzer/Checkers/Errno.h:22
+namespace ento {
+namespace errno_check {
+

I think we can settle on something better. What about calling it simply `errno`?



Comment at: clang/lib/StaticAnalyzer/Checkers/Errno.h:24-26
+/// Returns if modeling of 'errno' is available.
+/// If not, the other functions here should not be used.
+bool isErrnoAvailable(ProgramStateRef State);

I don't think we need this.
In `getErrnoValue()` we should simply return `UnknownVal` if we don't have 
'errno.
And in `setErrnoValue()` we should return the incoming `State` unmodified.

THat being said, only a top-level `Check::BeginFunction` callback could see an 
'errno' uninitialized, which I don't think is a real issue.
All the rest of the callbacks would run after it's initialized, thus would 
behave as expected.
And in case the translation unit doesn't have nor 'errno' variable nor 
'errno_location_ish' functions, ignoring these `set/get` functions is actually 
the expected behavior.

Having to check `isErrnoAvailable()` would be really an anti-pattern.



Comment at: clang/lib/StaticAnalyzer/Checkers/ErrnoChecker.cpp:32
+// FIXME: Is there a system where it is not called "errno" but is a variable?
+const char *ErrnoVarName = "errno";
+// Names of functions that return a location of the "errno" value.

Why don't you use `StringRef` here as well?



Comment at: clang/lib/StaticAnalyzer/Checkers/ErrnoChecker.cpp:35
+// FIXME: Check if there are other similar function names.
+llvm::StringRef ErrnoLocationFuncNames[] = {"__errno_location"};
+

`compiler-rt/lib/sanitizer_common/sanitizer_errno.h` has a list of the possible 
names for this API.:
`__error`, `__errno`, `___errno`, `_errno` or `__errno_location`

That being said, you should `eval::Call` all of these, and bind the return 
value to the memorized errno region.
At this point, this should be a `CallDescriptionSet` within the checker.



Comment at: clang/lib/StaticAnalyzer/Checkers/ErrnoChecker.cpp:60
+/// Returns null if there isn't any associated memory region.
+inline const MemRegion *getErrnoRegion(ProgramStateRef State) {
+  return reinterpret_cast(State->get());

For function definitions, we should use `static` instead of anonymous 
namespaces.
That being said, I don't think `inline` will do anything in this context.



Comment at: clang/lib/StaticAnalyzer/Checkers/ErrnoChecker.cpp:66
+
+void ErrnoChecker::checkBeginFunction(CheckerContext &C) const {
+  if (!C.inTopFrame())

I would expect a comment stating that:
- We inspect if we have a VarDecl naming "errno", it returns that Decl.
- Otherwise, it will look for some common `errno_location` function names and 
return that Decl. 



Comment at: clang/lib/StaticAnalyzer/Checkers/ErrnoChecker.cpp:88
+
+  auto GetErrnoFunc = [&ACtx]() -> const FunctionDecl * {
+SmallVector LookupRes;

I think you can hoist these lambdas into static functions.
This handler is already big enough.



Comment at: clang/lib/StaticAnalyzer/Checkers/ErrnoChecker.cpp:99
+   FD->isExternC() && FD->getNumParams() == 0 &&
+   FD->getReturnType() == ACtx.getPointerType(ACtx.IntTy);
+  return false;

I don't think any of these actually return the canonic versions.



Comment at: clang/lib/StaticAnalyzer/Checkers/ErrnoChecker.cpp:118
+assert(ErrnoR && "Memory region should exist for the 'errno' variable.");
+State = State->set(reinterpret_cast(ErrnoR));
+  } else if (GetErrnoFunc()) {

Ah, I've seen and done these reinterpret casts.
Could you please check why don't we have a partial specialization 

[PATCH] D118875: [compiler-rt][builtins] build the macOS compiler-rt built-ins with Mac Catalyst support

2022-02-22 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Is landing this blocked on anything?


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

https://reviews.llvm.org/D118875

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


[PATCH] D118598: [C++20][Modules][7/8] Find the primary interface name for a module.

2022-02-22 Thread Iain Sandoe via Phabricator via cfe-commits
iains updated this revision to Diff 410539.
iains added a comment.

rebased, addressed review comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118598

Files:
  clang/include/clang/Basic/Module.h
  clang/lib/Sema/SemaModule.cpp


Index: clang/lib/Sema/SemaModule.cpp
===
--- clang/lib/Sema/SemaModule.cpp
+++ clang/lib/Sema/SemaModule.cpp
@@ -382,17 +382,10 @@
 // We already checked that we are in a module purview in the parser.
 assert(!ModuleScopes.empty() && "in a module purview, but no module?");
 Module *NamedMod = ModuleScopes.back().Module;
-if (ModuleScopes.back().IsPartition) {
-  // We're importing a partition into a partition, find the name of the
-  // owning named module.
-  size_t P = NamedMod->Name.find_first_of(":");
-  ModuleName = NamedMod->Name.substr(0, P + 1);
-} else {
-  // We're importing a partition into the named module itself (either the
-  // interface or an implementation TU).
-  ModuleName = NamedMod->Name;
-  ModuleName += ":";
-}
+// If we are importing into a partition, find the owning named module,
+// otherwise, the name of the importing named module.
+ModuleName = NamedMod->getPrimaryModuleInterfaceName().str();
+ModuleName += ":";
 ModuleName += stringFromPath(Partition);
 ModuleNameLoc = {PP.getIdentifierInfo(ModuleName), Partition[0].second};
 Partition = ModuleIdPath(ModuleNameLoc);
Index: clang/include/clang/Basic/Module.h
===
--- clang/include/clang/Basic/Module.h
+++ clang/include/clang/Basic/Module.h
@@ -517,6 +517,16 @@
   /// Is this a module partition.
   bool isModulePartition() const { return Name.find(':') != std::string::npos; 
}
 
+  /// Get the primary module interface name from a partition.
+  StringRef getPrimaryModuleInterfaceName() const {
+if (Kind == ModulePartitionInterface ||
+Kind == ModulePartitionImplementation) {
+  auto pos = Name.find(':');
+  return StringRef(Name.data(), pos);
+}
+return Name;
+  }
+
   /// Retrieve the full name of this module, including the path from
   /// its top-level module.
   /// \param AllowStringLiterals If \c true, components that might not be


Index: clang/lib/Sema/SemaModule.cpp
===
--- clang/lib/Sema/SemaModule.cpp
+++ clang/lib/Sema/SemaModule.cpp
@@ -382,17 +382,10 @@
 // We already checked that we are in a module purview in the parser.
 assert(!ModuleScopes.empty() && "in a module purview, but no module?");
 Module *NamedMod = ModuleScopes.back().Module;
-if (ModuleScopes.back().IsPartition) {
-  // We're importing a partition into a partition, find the name of the
-  // owning named module.
-  size_t P = NamedMod->Name.find_first_of(":");
-  ModuleName = NamedMod->Name.substr(0, P + 1);
-} else {
-  // We're importing a partition into the named module itself (either the
-  // interface or an implementation TU).
-  ModuleName = NamedMod->Name;
-  ModuleName += ":";
-}
+// If we are importing into a partition, find the owning named module,
+// otherwise, the name of the importing named module.
+ModuleName = NamedMod->getPrimaryModuleInterfaceName().str();
+ModuleName += ":";
 ModuleName += stringFromPath(Partition);
 ModuleNameLoc = {PP.getIdentifierInfo(ModuleName), Partition[0].second};
 Partition = ModuleIdPath(ModuleNameLoc);
Index: clang/include/clang/Basic/Module.h
===
--- clang/include/clang/Basic/Module.h
+++ clang/include/clang/Basic/Module.h
@@ -517,6 +517,16 @@
   /// Is this a module partition.
   bool isModulePartition() const { return Name.find(':') != std::string::npos; }
 
+  /// Get the primary module interface name from a partition.
+  StringRef getPrimaryModuleInterfaceName() const {
+if (Kind == ModulePartitionInterface ||
+Kind == ModulePartitionImplementation) {
+  auto pos = Name.find(':');
+  return StringRef(Name.data(), pos);
+}
+return Name;
+  }
+
   /// Retrieve the full name of this module, including the path from
   /// its top-level module.
   /// \param AllowStringLiterals If \c true, components that might not be
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119199: replace clang LLVM_ENABLE_PLUGINS -> CLANG_PLUGIN_SUPPORT in tests

2022-02-22 Thread Cristian Adam via Phabricator via cfe-commits
cristian.adam added a comment.

In D119199#3337699 , @vtjnash wrote:

> Is that a bug in clang or in MSVC2019? We expected that 
> CLANG_PLUGIN_SUPPORT=ON can expose problems with the Windows linker, and we 
> add new tests here for verifying that configuration is functioning as 
> expected. You might need to disable CLANG_PLUGIN_SUPPORT on that target?

I don't know. I "fixed" it by commenting out the whole creation of the target, 
the same way as the `LLVM_INSTALL_TOOLCHAIN_ONLY` does, which would be the 
other workaround, to just use `LLVM_INSTALL_TOOLCHAIN_ONLY`.

  diff --git a/clang-tools-extra/test/CMakeLists.txt 
b/clang-tools-extra/test/CMakeLists.txt
  index 170e5f8bd197..e8b897893776 100644
  --- a/clang-tools-extra/test/CMakeLists.txt
  +++ b/clang-tools-extra/test/CMakeLists.txt
  @@ -80,6 +80,7 @@ foreach(dep ${LLVM_UTILS_DEPS})
 endif()
   endforeach()
  
  +#[[
   if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
 llvm_add_library(
 CTTestTidyModule
  @@ -106,6 +107,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
 endif()
 endif()
   endif()
  +#]]


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119199

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


[PATCH] D118757: [AArch64] Remove unused feature flags from AArch64TargetInfo

2022-02-22 Thread Son Tuan Vu 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 rG8e10448cbbd9: [AArch64] Remove unused feature flags from 
AArch64TargetInfo (authored by tyb0807).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118757

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h


Index: clang/lib/Basic/Targets/AArch64.h
===
--- clang/lib/Basic/Targets/AArch64.h
+++ clang/lib/Basic/Targets/AArch64.h
@@ -30,7 +30,6 @@
 
   unsigned FPU;
   bool HasCRC;
-  bool HasCrypto;
   bool HasAES;
   bool HasSHA2;
   bool HasSHA3;
@@ -54,7 +53,6 @@
   bool HasMatmulFP32;
   bool HasLSE;
   bool HasFlagM;
-  bool HasHBC;
   bool HasMOPS;
 
   llvm::AArch64::ArchKind ArchKind;
Index: clang/lib/Basic/Targets/AArch64.cpp
===
--- clang/lib/Basic/Targets/AArch64.cpp
+++ clang/lib/Basic/Targets/AArch64.cpp
@@ -525,7 +525,6 @@
  DiagnosticsEngine &Diags) {
   FPU = FPUMode;
   HasCRC = false;
-  HasCrypto = false;
   HasAES = false;
   HasSHA2 = false;
   HasSHA3 = false;
@@ -548,7 +547,6 @@
   HasMatmulFP64 = false;
   HasMatmulFP32 = false;
   HasLSE = false;
-  HasHBC = false;
   HasMOPS = false;
 
   ArchKind = llvm::AArch64::ArchKind::INVALID;
@@ -599,8 +597,6 @@
 }
 if (Feature == "+crc")
   HasCRC = true;
-if (Feature == "+crypto")
-  HasCrypto = true;
 if (Feature == "+aes")
   HasAES = true;
 if (Feature == "+sha2")
@@ -665,8 +661,6 @@
   HasRandGen = true;
 if (Feature == "+flagm")
   HasFlagM = true;
-if (Feature == "+hbc")
-  HasHBC = true;
 if (Feature == "+mops")
   HasMOPS = true;
   }


Index: clang/lib/Basic/Targets/AArch64.h
===
--- clang/lib/Basic/Targets/AArch64.h
+++ clang/lib/Basic/Targets/AArch64.h
@@ -30,7 +30,6 @@
 
   unsigned FPU;
   bool HasCRC;
-  bool HasCrypto;
   bool HasAES;
   bool HasSHA2;
   bool HasSHA3;
@@ -54,7 +53,6 @@
   bool HasMatmulFP32;
   bool HasLSE;
   bool HasFlagM;
-  bool HasHBC;
   bool HasMOPS;
 
   llvm::AArch64::ArchKind ArchKind;
Index: clang/lib/Basic/Targets/AArch64.cpp
===
--- clang/lib/Basic/Targets/AArch64.cpp
+++ clang/lib/Basic/Targets/AArch64.cpp
@@ -525,7 +525,6 @@
  DiagnosticsEngine &Diags) {
   FPU = FPUMode;
   HasCRC = false;
-  HasCrypto = false;
   HasAES = false;
   HasSHA2 = false;
   HasSHA3 = false;
@@ -548,7 +547,6 @@
   HasMatmulFP64 = false;
   HasMatmulFP32 = false;
   HasLSE = false;
-  HasHBC = false;
   HasMOPS = false;
 
   ArchKind = llvm::AArch64::ArchKind::INVALID;
@@ -599,8 +597,6 @@
 }
 if (Feature == "+crc")
   HasCRC = true;
-if (Feature == "+crypto")
-  HasCrypto = true;
 if (Feature == "+aes")
   HasAES = true;
 if (Feature == "+sha2")
@@ -665,8 +661,6 @@
   HasRandGen = true;
 if (Feature == "+flagm")
   HasFlagM = true;
-if (Feature == "+hbc")
-  HasHBC = true;
 if (Feature == "+mops")
   HasMOPS = true;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8e10448 - [AArch64] Remove unused feature flags from AArch64TargetInfo

2022-02-22 Thread via cfe-commits

Author: tyb0807
Date: 2022-02-22T16:13:44Z
New Revision: 8e10448cbbd98e2496f8bc8985b6ee499b7ffcdd

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

LOG: [AArch64] Remove unused feature flags from AArch64TargetInfo

This removes two feature flags from `AArch64TargetInfo` class:

- `HasHBC`: this feature does not involve generating any IR intrinsics,
so clang does not need to know about whether it is set

- `HasCrypto`: this feature is deprecated in favor of finer grained
features such as AES, SHA2, SHA3 and SM4. The associated ACLE macro
__ARM_FEATURE_CRYPTO is thus no longer used.

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

Added: 


Modified: 
clang/lib/Basic/Targets/AArch64.cpp
clang/lib/Basic/Targets/AArch64.h

Removed: 




diff  --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index b04508570ad7..bd03d88b2d5a 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -525,7 +525,6 @@ bool 
AArch64TargetInfo::handleTargetFeatures(std::vector &Features,
  DiagnosticsEngine &Diags) {
   FPU = FPUMode;
   HasCRC = false;
-  HasCrypto = false;
   HasAES = false;
   HasSHA2 = false;
   HasSHA3 = false;
@@ -548,7 +547,6 @@ bool 
AArch64TargetInfo::handleTargetFeatures(std::vector &Features,
   HasMatmulFP64 = false;
   HasMatmulFP32 = false;
   HasLSE = false;
-  HasHBC = false;
   HasMOPS = false;
 
   ArchKind = llvm::AArch64::ArchKind::INVALID;
@@ -599,8 +597,6 @@ bool 
AArch64TargetInfo::handleTargetFeatures(std::vector &Features,
 }
 if (Feature == "+crc")
   HasCRC = true;
-if (Feature == "+crypto")
-  HasCrypto = true;
 if (Feature == "+aes")
   HasAES = true;
 if (Feature == "+sha2")
@@ -665,8 +661,6 @@ bool 
AArch64TargetInfo::handleTargetFeatures(std::vector &Features,
   HasRandGen = true;
 if (Feature == "+flagm")
   HasFlagM = true;
-if (Feature == "+hbc")
-  HasHBC = true;
 if (Feature == "+mops")
   HasMOPS = true;
   }

diff  --git a/clang/lib/Basic/Targets/AArch64.h 
b/clang/lib/Basic/Targets/AArch64.h
index 9e22aeaff251..bd6812d1257c 100644
--- a/clang/lib/Basic/Targets/AArch64.h
+++ b/clang/lib/Basic/Targets/AArch64.h
@@ -30,7 +30,6 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public 
TargetInfo {
 
   unsigned FPU;
   bool HasCRC;
-  bool HasCrypto;
   bool HasAES;
   bool HasSHA2;
   bool HasSHA3;
@@ -54,7 +53,6 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public 
TargetInfo {
   bool HasMatmulFP32;
   bool HasLSE;
   bool HasFlagM;
-  bool HasHBC;
   bool HasMOPS;
 
   llvm::AArch64::ArchKind ArchKind;



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


[PATCH] D119720: [ARM] Pass for Cortex-A57 and Cortex-A72 Fused AES Erratum

2022-02-22 Thread Sam Elliott via Phabricator via cfe-commits
lenary added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119720

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


[clang] 79c9072 - Restore documentation for __builtin_assume

2022-02-22 Thread via cfe-commits

Author: serge-sans-paille
Date: 2022-02-22T17:19:11+01:00
New Revision: 79c9072dc009693477242bc1347a2a6c3e419423

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

LOG: Restore documentation for __builtin_assume

This got removed by 6cacd420a1d72bca7809e6b516fb1e18ac6056c8, and that was a
mistake.

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

Added: 


Modified: 
clang/docs/LanguageExtensions.rst

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index f45d88092eb4..865a877b0219 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -2205,6 +2205,39 @@ Query for this feature with 
``__has_builtin(__builtin_alloca_with_align)``.
 
 .. _langext-__builtin_assume:
 
+``__builtin_assume``
+
+
+``__builtin_assume`` is used to provide the optimizer with a boolean
+invariant that is defined to be true.
+
+**Syntax**:
+
+.. code-block:: c++
+
+__builtin_assume(bool)
+
+**Example of Use**:
+
+.. code-block:: c++
+
+  int foo(int x) {
+  __builtin_assume(x != 0);
+  // The optimizer may short-circuit this check using the invariant.
+  if (x == 0)
+return do_something();
+  return do_something_else();
+  }
+
+**Description**:
+
+The boolean argument to this function is defined to be true. The optimizer may
+analyze the form of the expression provided as the argument and deduce from
+that information used to optimize the program. If the condition is violated
+during execution, the behavior is undefined. The argument itself is 
+
+Query for this feature with ``__has_builtin(__builtin_assume)``.
+
 ``__builtin_call_with_static_chain``
 
 



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


[PATCH] D120205: Restore documentation for __builtin_assume

2022-02-22 Thread serge 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 rG79c9072dc009: Restore documentation for __builtin_assume 
(authored by serge-sans-paille).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120205

Files:
  clang/docs/LanguageExtensions.rst


Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -2205,6 +2205,39 @@
 
 .. _langext-__builtin_assume:
 
+``__builtin_assume``
+
+
+``__builtin_assume`` is used to provide the optimizer with a boolean
+invariant that is defined to be true.
+
+**Syntax**:
+
+.. code-block:: c++
+
+__builtin_assume(bool)
+
+**Example of Use**:
+
+.. code-block:: c++
+
+  int foo(int x) {
+  __builtin_assume(x != 0);
+  // The optimizer may short-circuit this check using the invariant.
+  if (x == 0)
+return do_something();
+  return do_something_else();
+  }
+
+**Description**:
+
+The boolean argument to this function is defined to be true. The optimizer may
+analyze the form of the expression provided as the argument and deduce from
+that information used to optimize the program. If the condition is violated
+during execution, the behavior is undefined. The argument itself is 
+
+Query for this feature with ``__has_builtin(__builtin_assume)``.
+
 ``__builtin_call_with_static_chain``
 
 


Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -2205,6 +2205,39 @@
 
 .. _langext-__builtin_assume:
 
+``__builtin_assume``
+
+
+``__builtin_assume`` is used to provide the optimizer with a boolean
+invariant that is defined to be true.
+
+**Syntax**:
+
+.. code-block:: c++
+
+__builtin_assume(bool)
+
+**Example of Use**:
+
+.. code-block:: c++
+
+  int foo(int x) {
+  __builtin_assume(x != 0);
+  // The optimizer may short-circuit this check using the invariant.
+  if (x == 0)
+return do_something();
+  return do_something_else();
+  }
+
+**Description**:
+
+The boolean argument to this function is defined to be true. The optimizer may
+analyze the form of the expression provided as the argument and deduce from
+that information used to optimize the program. If the condition is violated
+during execution, the behavior is undefined. The argument itself is 
+
+Query for this feature with ``__has_builtin(__builtin_assume)``.
+
 ``__builtin_call_with_static_chain``
 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   3   >