[PATCH] D127189: [clang][AIX] Add option to control quadword lock free atomics ABI on AIX

2022-07-21 Thread Kai Luo via Phabricator via cfe-commits
lkail added inline comments.



Comment at: clang/include/clang/Driver/Options.td:3611
   HelpText<"Enable the default Altivec ABI on AIX (AIX only). Uses only 
volatile vector registers.">;
+def maix_quadword_atomics : Flag<["-"], "maix64-quadword-atomics">,
+  Group, Flags<[CC1Option]>,

shchenz wrote:
> amyk wrote:
> > Would it be better if we called this `maix64-quadword-atomics` instead? 
> Do we need to change the backend check below too?
> ```
> bool PPCTargetLowering::shouldInlineQuadwordAtomics() const {
>   // TODO: 16-byte atomic type support for AIX is in progress; we should be 
> able
>   // to inline 16-byte atomic ops on AIX too in the future.
>   return Subtarget.isPPC64() &&
>  (EnableQuadwordAtomics || !Subtarget.getTargetTriple().isOSAIX()) &&
>  Subtarget.hasQuadwordAtomics();
> }
> ```
We don't need to change this yet. When we are compiling a quadword lock free 
libatomic, we use options `-mabi=quadword-atomics -mllvm -ppc-quadword-atomics` 
to enforce generating quadword lock-free code on AIX.



Comment at: clang/lib/Basic/Targets/PPC.cpp:854
+  HasQuadwordAtomics)
+MaxAtomicInlineWidth = 128;
 }

shchenz wrote:
> Can we set `MaxAtomicInlineWidth` in `PPC64TargetInfo::setMaxAtomicWidth()`? 
> There is a `TODO` there
The `TODO` marks our roadmap towards enabling quardword lock free atomics on 
AIX too. Putting adjustment here is implementation reason: we don't context of 
`LanguageOptions` in `PPC64TargetInfo::PPC64TargetInfo`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127189

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


[PATCH] D130331: [C++20] [Modules] Disable preferred_name when writing a C++20 Module interface

2022-07-21 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added inline comments.



Comment at: clang/lib/Serialization/ASTWriter.cpp:4353
+  // https://github.com/llvm/llvm-project/issues/56490 for example.
+  if (!A || (isa(A) && Writer->isWritingNamedModules()))
 return Record.push_back(0);

The `Writer->isWritingNamedModules()` part is necessary. Otherwise we would 
break the 
https://github.com/llvm/llvm-project/blob/main/clang/test/PCH/decl-attrs.cpp 
test. The reason why the bug is not found by the user of PCH or clang modules 
is that a header generally would be guarded by `#ifndef ... #define` fashion. 
And if we remove the guard, the compiler would emit an error for duplicated 
definition. So the problem only lives in C++20 Named Modules.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130331

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


[PATCH] D127189: [clang][AIX] Add option to control quadword lock free atomics ABI on AIX

2022-07-21 Thread Kai Luo via Phabricator via cfe-commits
lkail added a comment.

> Can we use the feature bit FeatureQuadwordAtomic to decide whether QuadAtomic 
> is supported or not on AIX? Like what we do for Linux.

`FeatureQuadwordAtomic` is for cpu level control, while 
`-mabi=quadword-atomics` is for ABI level. AIX running on pwr8+ also features 
`FeatureQuadwordAtomic`, but in the case described in the patch summary, 
sometimes we can't enable quadword lock free atomics on AIX by default, so that 
clang generate libcalls into libatomic rather than inlining lock free 
operations. libatomic has the final decision to use lock-free version or not.

> The reason we need this option is: we may need to compile a lock free 
> libatomic on a Power7 or below target?

We need to compile a quadword lock free libatomic for CPUs above pwr8.

> If so, do we have similar issue on Linux? Thanks.

On Linux, `clang` is linking against GNU's libatomic by default, that depends 
on GNU libatomic's behaviour.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127189

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


[PATCH] D129748: [C++20] [Modules] Warn for the use of preferred_name in modules

2022-07-21 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

In D129748#3668446 , @erichkeane 
wrote:

> In D129748#3667932 , @ChuanqiXu 
> wrote:
>
>> @erichkeane @aaron.ballman @tahonermann I get another idea. We could tell 
>> the user honestly that we couldn't handle it (temporarily). We could still 
>> modularize the STL by a trick: 
>> https://github.com/ChuanqiXu9/stdmodules/blob/e81f4e9e74f96021f2e45c48f44da93e806c4524/Makefile#L3
>>
>> In this way, we don't need to worry about the dirty implementation pollutes 
>> the sources. (I think it is not bad to emit a warning to tell the user we 
>> couldn't do something (now).)
>
> Thats a heck of an "STL Trick".  The diagnostic itself needs some rewording, 
> and I don't know if we do diagnostics for our implementation deficiencies.

I know there was an example. In clang14.x and before, when we write module 
partitions, the compiler would say "sorry, module partitions are not yet 
supported". We can find this in 
https://github.com/llvm/llvm-project/commit/69350e569dc47f871590243b5e46a68520640dcd.

> I still consider the 'disable the attribute' as perhaps the 'best idea' for 
> now other than fixing the bug, but had suggested earlier doing it NOT at the 
> SemaDeclAttr level, but to do it at the ASTWriter-when-in-modules level.

It looks better to workaround it in ASTWriter in Sema to me. I sent another 
revision D130331  as an alternative since the 
current revision looks acceptable to me. I will be happy if either of them get 
accepted.


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

https://reviews.llvm.org/D129748

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


[PATCH] D130331: [C++20] [Modules] Disable preferred_name when writing a C++20 Module interface

2022-07-21 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu created this revision.
ChuanqiXu added reviewers: erichkeane, tahonermann, aaron.ballman.
ChuanqiXu added a project: clang-modules.
Herald added a project: All.
ChuanqiXu requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This is an alternative to D129748 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130331

Files:
  clang/include/clang/Serialization/ASTWriter.h
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/Modules/preferred_name.cppm


Index: clang/test/Modules/preferred_name.cppm
===
--- /dev/null
+++ clang/test/Modules/preferred_name.cppm
@@ -0,0 +1,39 @@
+// Tests that the ODR check wouldn't produce false-positive result for 
preferred_name attribute.
+//
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 -std=c++20 %t/A.cppm -emit-module-interface -o %t/A.pcm
+// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t -I%t %t/Use.cppm 
-verify -fsyntax-only
+//
+//--- foo.h
+template
+class foo_templ;
+
+typedef foo_templ foo;
+
+template
+class
+__attribute__((__preferred_name__(foo)))
+foo_templ {
+public:
+foo_templ() {}
+};
+
+inline foo_templ bar()
+{
+  return foo_templ();
+}
+
+//--- A.cppm
+module;
+#include "foo.h"
+export module A;
+
+//--- Use.cppm
+// expected-no-diagnostics
+module;
+#include "foo.h"
+export module Use;
+import A;
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -4347,8 +4347,12 @@
 
 void ASTRecordWriter::AddAttr(const Attr *A) {
   auto  = *this;
-  if (!A)
+  // FIXME: Clang can't handle the serialization/deserialization of
+  // preferred_name properly now. See
+  // https://github.com/llvm/llvm-project/issues/56490 for example.
+  if (!A || (isa(A) && Writer->isWritingNamedModules()))
 return Record.push_back(0);
+
   Record.push_back(A->getKind() + 1); // FIXME: stable encoding, target attrs
 
   Record.AddIdentifierRef(A->getAttrName());
Index: clang/lib/Serialization/ASTReaderDecl.cpp
===
--- clang/lib/Serialization/ASTReaderDecl.cpp
+++ clang/lib/Serialization/ASTReaderDecl.cpp
@@ -2922,7 +2922,8 @@
 /// Reads attributes from the current stream position.
 void ASTRecordReader::readAttributes(AttrVec ) {
   for (unsigned I = 0, E = readInt(); I != E; ++I)
-Attrs.push_back(readAttr());
+if (auto *Attr = readAttr())
+  Attrs.push_back(Attr);
 }
 
 
//===--===//
Index: clang/include/clang/Serialization/ASTWriter.h
===
--- clang/include/clang/Serialization/ASTWriter.h
+++ clang/include/clang/Serialization/ASTWriter.h
@@ -703,6 +703,10 @@
   bool hasChain() const { return Chain; }
   ASTReader *getChain() const { return Chain; }
 
+  bool isWritingNamedModules() const {
+return WritingModule && WritingModule->isModulePurview();
+  }
+
 private:
   // ASTDeserializationListener implementation
   void ReaderInitialized(ASTReader *Reader) override;


Index: clang/test/Modules/preferred_name.cppm
===
--- /dev/null
+++ clang/test/Modules/preferred_name.cppm
@@ -0,0 +1,39 @@
+// Tests that the ODR check wouldn't produce false-positive result for preferred_name attribute.
+//
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 -std=c++20 %t/A.cppm -emit-module-interface -o %t/A.pcm
+// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t -I%t %t/Use.cppm -verify -fsyntax-only
+//
+//--- foo.h
+template
+class foo_templ;
+
+typedef foo_templ foo;
+
+template
+class
+__attribute__((__preferred_name__(foo)))
+foo_templ {
+public:
+foo_templ() {}
+};
+
+inline foo_templ bar()
+{
+  return foo_templ();
+}
+
+//--- A.cppm
+module;
+#include "foo.h"
+export module A;
+
+//--- Use.cppm
+// expected-no-diagnostics
+module;
+#include "foo.h"
+export module Use;
+import A;
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -4347,8 +4347,12 @@
 
 void ASTRecordWriter::AddAttr(const Attr *A) {
   auto  = *this;
-  if (!A)
+  // FIXME: Clang can't handle the serialization/deserialization of
+  // preferred_name properly now. See
+  // https://github.com/llvm/llvm-project/issues/56490 for example.
+  if (!A || (isa(A) && Writer->isWritingNamedModules()))
 return Record.push_back(0);
+
   Record.push_back(A->getKind() + 1); // FIXME: stable encoding, target attrs
 
   

[PATCH] D130255: [Clang][LoongArch] Add initial LoongArch target and driver support

2022-07-21 Thread Lu Weining via Phabricator via cfe-commits
SixWeining added inline comments.



Comment at: clang/lib/Basic/Targets/LoongArch.cpp:26
+  // TODO: To be implemented in future.
+  return ArrayRef();
+}

MaskRay wrote:
> `return {}`
Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130255

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


[PATCH] D130255: [Clang][LoongArch] Add initial LoongArch target and driver support

2022-07-21 Thread Lu Weining via Phabricator via cfe-commits
SixWeining updated this revision to Diff 446705.
SixWeining marked 9 inline comments as done.
SixWeining added a comment.

Address @MaskRay's comments. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130255

Files:
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Basic/Targets.cpp
  clang/lib/Basic/Targets/LoongArch.cpp
  clang/lib/Basic/Targets/LoongArch.h
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
  clang/lib/Driver/ToolChains/Arch/LoongArch.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Clang.h
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/test/Driver/Inputs/multilib_loongarch_linux_sdk/bin/.keep
  clang/test/Driver/Inputs/multilib_loongarch_linux_sdk/include/.keep
  
clang/test/Driver/Inputs/multilib_loongarch_linux_sdk/lib/gcc/loongarch64-unknown-linux-gnu/12.1.0/base/lp64d/crtbegin.o
  
clang/test/Driver/Inputs/multilib_loongarch_linux_sdk/lib/gcc/loongarch64-unknown-linux-gnu/12.1.0/base/lp64f/crtbegin.o
  
clang/test/Driver/Inputs/multilib_loongarch_linux_sdk/lib/gcc/loongarch64-unknown-linux-gnu/12.1.0/base/lp64s/crtbegin.o
  
clang/test/Driver/Inputs/multilib_loongarch_linux_sdk/lib/gcc/loongarch64-unknown-linux-gnu/12.1.0/crtbegin.o
  
clang/test/Driver/Inputs/multilib_loongarch_linux_sdk/loongarch64-unknown-linux-gnu/bin/ld
  
clang/test/Driver/Inputs/multilib_loongarch_linux_sdk/loongarch64-unknown-linux-gnu/lib/.keep
  
clang/test/Driver/Inputs/multilib_loongarch_linux_sdk/loongarch64-unknown-linux-gnu/lib64/.keep
  clang/test/Driver/Inputs/multilib_loongarch_linux_sdk/sysroot/usr/lib/.keep
  clang/test/Driver/Inputs/multilib_loongarch_linux_sdk/sysroot/usr/lib64/.keep
  clang/test/Driver/frame-pointer.c
  clang/test/Driver/loongarch-abi-error.c
  clang/test/Driver/loongarch-abi.c
  clang/test/Driver/loongarch64-toolchain.c
  clang/test/Preprocessor/init-loongarch.c

Index: clang/test/Preprocessor/init-loongarch.c
===
--- /dev/null
+++ clang/test/Preprocessor/init-loongarch.c
@@ -0,0 +1,641 @@
+// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=loongarch32 /dev/null \
+// RUN:   | FileCheck --match-full-lines --check-prefix=LA32 %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=loongarch32-unknown-linux /dev/null \
+// RUN:   | FileCheck --match-full-lines --check-prefixes=LA32,LA32-LINUX %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=loongarch32 \
+// RUN: -fforce-enable-int128 /dev/null | FileCheck --match-full-lines \
+// RUN: --check-prefixes=LA32,LA32-INT128 %s
+
+// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=loongarch64 /dev/null \
+// RUN:   | FileCheck --match-full-lines --check-prefix=LA64 %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=loongarch64-unknown-linux /dev/null \
+// RUN:   | FileCheck --match-full-lines --check-prefixes=LA64,LA64-LINUX %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=loongarch64 \
+// RUN: -fforce-enable-int128 /dev/null | FileCheck --match-full-lines \
+// RUN: --check-prefixes=LA64,LA64-INT128 %s
+
+ Note that common macros are tested in init.c, such as __VERSION__. So they're not listed here.
+
+// LA32: #define _ILP32 1
+// LA32: #define __ATOMIC_ACQUIRE 2
+// LA32-NEXT: #define __ATOMIC_ACQ_REL 4
+// LA32-NEXT: #define __ATOMIC_CONSUME 1
+// LA32-NEXT: #define __ATOMIC_RELAXED 0
+// LA32-NEXT: #define __ATOMIC_RELEASE 3
+// LA32-NEXT: #define __ATOMIC_SEQ_CST 5
+// LA32: #define __BIGGEST_ALIGNMENT__ 16
+// LA32: #define __BITINT_MAXWIDTH__ 128
+// LA32: #define __BOOL_WIDTH__ 8
+// LA32: #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
+// LA32: #define __CHAR16_TYPE__ unsigned short
+// LA32: #define __CHAR32_TYPE__ unsigned int
+// LA32: #define __CHAR_BIT__ 8
+// LA32: #define __CLANG_ATOMIC_BOOL_LOCK_FREE 1
+// LA32: #define __CLANG_ATOMIC_CHAR16_T_LOCK_FREE 1
+// LA32: #define __CLANG_ATOMIC_CHAR32_T_LOCK_FREE 1
+// LA32: #define __CLANG_ATOMIC_CHAR_LOCK_FREE 1
+// LA32: #define __CLANG_ATOMIC_INT_LOCK_FREE 1
+// LA32: #define __CLANG_ATOMIC_LLONG_LOCK_FREE 1
+// LA32: #define __CLANG_ATOMIC_LONG_LOCK_FREE 1
+// LA32: #define __CLANG_ATOMIC_POINTER_LOCK_FREE 1
+// LA32: #define __CLANG_ATOMIC_SHORT_LOCK_FREE 1
+// LA32: #define __CLANG_ATOMIC_WCHAR_T_LOCK_FREE 1
+// LA32: #define __DBL_DECIMAL_DIG__ 17
+// LA32: #define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+// LA32: #define __DBL_DIG__ 15
+// LA32: #define __DBL_EPSILON__ 2.2204460492503131e-16
+// LA32: #define __DBL_HAS_DENORM__ 1
+// LA32: #define __DBL_HAS_INFINITY__ 1
+// LA32: #define __DBL_HAS_QUIET_NAN__ 1
+// LA32: #define __DBL_MANT_DIG__ 53
+// LA32: #define __DBL_MAX_10_EXP__ 308
+// LA32: #define __DBL_MAX_EXP__ 1024
+// LA32: #define __DBL_MAX__ 1.7976931348623157e+308
+// 

[PATCH] D130066: [pseudo] Key guards by RuleID, add guards to literals (and 0).

2022-07-21 Thread Amy Kwan via Phabricator via cfe-commits
amyk added a comment.

Hi!

It appears that this patch is causing a build failure on a couple PPC bots that 
build with shared libraries:
https://lab.llvm.org/buildbot/#/builders/57/builds/20179
https://lab.llvm.org/buildbot/#/builders/121/builds/21678

The specific error that occurs looks like this:

  2.485 [936/22/19] Linking CXX shared library lib/libclangPseudoCXX.so.15git
  FAILED: lib/libclangPseudoCXX.so.15git 
  : && /home/buildbots/clang.11.0.0/bin/clang++ 
--gcc-toolchain=/opt/rh/devtoolset-7/root/usr -fPIC -fPIC 
-fvisibility-inlines-hidden -Werror -Werror=date-time 
-Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter 
-Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic 
-Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -fdiagnostics-color -ffunction-sections 
-fdata-sections -fno-common -Woverloaded-virtual -Wno-nested-anon-types -O3 
-DNDEBUG  -Wl,-z,defs -Wl,-z,nodelete   
-Wl,-rpath-link,/home/buildbots/docker-RHEL-buildbot/SetupBot/worker_env/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/./lib
  -Wl,--gc-sections -shared -Wl,-soname,libclangPseudoCXX.so.15git -o 
lib/libclangPseudoCXX.so.15git 
tools/clang/tools/extra/pseudo/lib/cxx/CMakeFiles/obj.clangPseudoCXX.dir/CXX.cpp.o
  -Wl,-rpath,"\$ORIGIN/../lib"  lib/libclangPseudo.so.15git  
lib/libclangPseudoGrammar.so.15git  lib/libLLVMSupport.so.15git  
-Wl,-rpath-link,/home/buildbots/docker-RHEL-buildbot/SetupBot/worker_env/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/lib
 && :
  
tools/clang/tools/extra/pseudo/lib/cxx/CMakeFiles/obj.clangPseudoCXX.dir/CXX.cpp.o:(.toc+0x10):
 undefined reference to `clang::charinfo::InfoTable'
  clang++: error: linker command failed with exit code 1 (use -v to see 
invocation)

Would you be able to take a look at this issue (or revert the patch if this 
requires more time to resolve)? Thank you in advance.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130066

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


[PATCH] D130301: [Clang] Fix how we set the NumPositiveBits on an E numDecl to cover the case of single enumerator with value zero or an empty enum

2022-07-21 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik updated this revision to Diff 446702.
shafik added a comment.
Herald added a subscriber: Enna1.

-Modified UBSan test to cover the empty enum case. I also refactored the test 
which was pretty clever but hard to work with as is.


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

https://reviews.llvm.org/D130301

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CodeGenCXX/pr12251.cpp
  compiler-rt/test/ubsan/TestCases/Misc/enum.cpp


Index: compiler-rt/test/ubsan/TestCases/Misc/enum.cpp
===
--- compiler-rt/test/ubsan/TestCases/Misc/enum.cpp
+++ compiler-rt/test/ubsan/TestCases/Misc/enum.cpp
@@ -1,21 +1,28 @@
-// RUN: %clangxx -fsanitize=enum %s -O3 -o %t && %run %t 2>&1 | FileCheck %s 
--check-prefix=CHECK-PLAIN
-// RUN: %clangxx -fsanitize=enum -std=c++11 -DE="class E" %s -O3 -o %t && %run 
%t
-// RUN: %clangxx -fsanitize=enum -std=c++11 -DE="class E : bool" %s -O3 -o %t 
&& not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-BOOL
+// RUN: %clangxx -fsanitize=enum %s -O3 -o %t && %run %t 2>&1 | FileCheck %s 
--check-prefix=CHECK
 
 // FIXME: UBSan fails to add the correct instrumentation code for some reason 
on
 // Windows.
 // XFAIL: windows-msvc
 
-enum E { a = 1 } e;
-#undef E
+enum E { a = 1 };
+enum class EClass { a = 1 };
+enum class EBool : bool { a = 1 } e3;
+enum EEmpty {};
 
 int main(int argc, char **argv) {
-  // memset(, 0xff, sizeof(e));
-  for (unsigned char *p = (unsigned char*) p != (unsigned char*)( + 1); 
++p)
+  E e1 = static_cast(0x);
+  EClass e2 = static_cast(0x);
+  EEmpty e4 = static_cast(1);
+  EEmpty e5 = static_cast(2);
+
+  for (unsigned char *p = (unsigned char *) p != (unsigned char *)( + 
1);
+   ++p)
 *p = 0xff;
 
-  // CHECK-PLAIN: error: load of value 4294967295, which is not a valid value 
for type 'enum E'
-  // FIXME: Support marshalling and display of enum class values.
-  // CHECK-BOOL: error: load of value , which is not a valid value 
for type 'enum E'
-  return (int)e != -1;
+  // CHECK: error: load of value 4294967295, which is not a valid value for 
type 'E'
+  return ((int)e1 != -1) & ((int)e2 != -1) &
+ // CHECK: error: load of value , which is not a valid value 
for type 'enum EBool'
+ ((int)e3 != -1) & ((int)e4 == 1) &
+ // CHECK: error: load of value 2, which is not a valid value for type 
'EEmpty'
+ ((int)e5 == 2);
 }
Index: clang/test/CodeGenCXX/pr12251.cpp
===
--- clang/test/CodeGenCXX/pr12251.cpp
+++ clang/test/CodeGenCXX/pr12251.cpp
@@ -18,14 +18,14 @@
   return *x;
 }
 // CHECK-LABEL: define{{.*}} i32 @_Z2g1P2e1
-// CHECK: ret i32 0
+// CHECK: ret i32 %0
 
 enum e2 { e2_a = 0 };
 e2 g2(e2 *x) {
   return *x;
 }
 // CHECK-LABEL: define{{.*}} i32 @_Z2g2P2e2
-// CHECK: ret i32 0
+// CHECK: ret i32 %0
 
 enum e3 { e3_a = 16 };
 e3 g3(e3 *x) {
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -18878,14 +18878,24 @@
 const llvm::APSInt  = ECD->getInitVal();
 
 // Keep track of the size of positive and negative values.
-if (InitVal.isUnsigned() || InitVal.isNonNegative())
-  NumPositiveBits = std::max(NumPositiveBits,
- (unsigned)InitVal.getActiveBits());
-else
+if (InitVal.isUnsigned() || InitVal.isNonNegative()) {
+  // If the enumerator is zero that should still be counted as a positive
+  // bit since we need a bit to store the value zero
+  const unsigned ActiveBits =
+  InitVal.getActiveBits() ? InitVal.getActiveBits() : 1;
+  NumPositiveBits = std::max(NumPositiveBits, ActiveBits);
+} else
   NumNegativeBits = std::max(NumNegativeBits,
  (unsigned)InitVal.getMinSignedBits());
   }
 
+  // If we have have a empty set of enumerators we still need one bit.
+  // From [dcl.enum]p8
+  // If the enumerator-list is empty, the values of the enumeration are as if
+  // the enumeration had a single enumerator with value 0
+  if (!NumPositiveBits && !NumNegativeBits)
+NumPositiveBits = 1;
+
   // Figure out the type that should be used for this enum.
   QualType BestType;
   unsigned BestWidth;


Index: compiler-rt/test/ubsan/TestCases/Misc/enum.cpp
===
--- compiler-rt/test/ubsan/TestCases/Misc/enum.cpp
+++ compiler-rt/test/ubsan/TestCases/Misc/enum.cpp
@@ -1,21 +1,28 @@
-// RUN: %clangxx -fsanitize=enum %s -O3 -o %t && %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-PLAIN
-// RUN: %clangxx -fsanitize=enum -std=c++11 -DE="class E" %s -O3 -o %t && %run %t
-// RUN: %clangxx -fsanitize=enum -std=c++11 -DE="class E : bool" %s -O3 -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-BOOL
+// RUN: %clangxx -fsanitize=enum %s -O3 -o %t && %run %t 

[PATCH] D129138: [clang] [docs] Update the changes of C++20 Modules in clang15

2022-07-21 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

@iains I'm going to land this in next Monday if all the dependent patch landed. 
Do you feel good with this?


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

https://reviews.llvm.org/D129138

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


[PATCH] D127189: [clang][AIX] Add option to control quadword lock free atomics ABI on AIX

2022-07-21 Thread ChenZheng via Phabricator via cfe-commits
shchenz added a comment.

Can we use the feature bit `FeatureQuadwordAtomic` to decide whether QuadAtomic 
is supported or not on AIX? Like what we do for Linux.

The reason we need this option is: we may need to compile a lock free libatomic 
on a Power7 or below target? If so, do we have similar issue on Linux? Thanks.




Comment at: clang/include/clang/Driver/Options.td:3611
   HelpText<"Enable the default Altivec ABI on AIX (AIX only). Uses only 
volatile vector registers.">;
+def maix_quadword_atomics : Flag<["-"], "maix64-quadword-atomics">,
+  Group, Flags<[CC1Option]>,

amyk wrote:
> Would it be better if we called this `maix64-quadword-atomics` instead? 
Do we need to change the backend check below too?
```
bool PPCTargetLowering::shouldInlineQuadwordAtomics() const {
  // TODO: 16-byte atomic type support for AIX is in progress; we should be able
  // to inline 16-byte atomic ops on AIX too in the future.
  return Subtarget.isPPC64() &&
 (EnableQuadwordAtomics || !Subtarget.getTargetTriple().isOSAIX()) &&
 Subtarget.hasQuadwordAtomics();
}
```



Comment at: clang/lib/Basic/Targets/PPC.cpp:854
+  HasQuadwordAtomics)
+MaxAtomicInlineWidth = 128;
 }

Can we set `MaxAtomicInlineWidth` in `PPC64TargetInfo::setMaxAtomicWidth()`? 
There is a `TODO` there


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127189

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


[PATCH] D128695: [ODRHash diagnostics] Move `ODRDiagsEmitter` to libAST in separate files. NFC.

2022-07-21 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

In D128695#3670552 , @ChuanqiXu wrote:

> It looks like we lack a patch to use it in parser, right?

Kinda. Things get a little bit more complicated before we can do that. But to 
see the bigger picture, I've published all planned intermediate steps with the 
final D130327 . And there in 
clang/lib/Parse/ParseObjc.cpp you can see how `ODRDiagsEmitter` is used in the 
parser.

I'm not opening those patches for review yet as I want to polish them a little 
bit and to test all of this stuff on real projects. Landing all of NFC stuff 
should be sufficient to start testing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128695

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


[PATCH] D130327: [ODRHash] Detect duplicate `ObjCProtocolDecl` ODR mismatches during parsing.

2022-07-21 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai created this revision.
Herald added a subscriber: ributzka.
Herald added a project: All.
vsapsai requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When during parsing we encountered a duplicate `ObjCProtocolDecl`, we
were always emitting an error. With this change we accept

- when a previous `ObjCProtocolDecl` is in a hidden [sub]module;
- parsed `ObjCProtocolDecl` is the same as the previous one.

And in case of mismatches we provide more detailed error messages.

rdar://93069080


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130327

Files:
  clang/include/clang/AST/DeclObjC.h
  clang/include/clang/AST/ODRDiagsEmitter.h
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/DeclObjC.cpp
  clang/lib/AST/ODRDiagsEmitter.cpp
  clang/lib/Parse/ParseObjc.cpp
  clang/lib/Sema/SemaDeclObjC.cpp
  clang/test/Modules/compare-objc-protocol.m
  clang/test/Modules/hidden-duplicates.m

Index: clang/test/Modules/hidden-duplicates.m
===
--- /dev/null
+++ clang/test/Modules/hidden-duplicates.m
@@ -0,0 +1,56 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: %clang_cc1 -emit-llvm -o %t/test.bc -I %t/include %t/test.m -verify \
+// RUN:-fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache
+// RUN: %clang_cc1 -emit-llvm -o %t/test.bc -I %t/include %t/test.m -verify -DTEST_MAKE_HIDDEN_VISIBLE=1 \
+// RUN:-fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache
+// RUN: %clang_cc1 -emit-llvm -o %t/test.bc -I %t/include %t/test.m -verify -x objective-c++ \
+// RUN:-fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache
+// RUN: %clang_cc1 -emit-llvm -o %t/test.bc -I %t/include %t/test.m -verify -DTEST_MAKE_HIDDEN_VISIBLE=1 -x objective-c++ \
+// RUN:-fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache
+
+// Test parsing duplicate Objective-C entities when a previous entity is defined
+// in a hidden [sub]module and cannot be used.
+//
+// Testing with header guards and includes on purpose as tracking imports in
+// modules is a separate issue.
+
+//--- include/textual.h
+#ifndef TEXTUAL_H
+#define TEXTUAL_H
+
+@protocol TestProtocol
+- (void)someMethod;
+@end
+
+@protocol ForwardDeclaredProtocolWithoutDefinition;
+
+id protocolDefinition(id t);
+id forwardDeclaredProtocol(
+id t);
+
+#endif
+
+//--- include/empty.h
+//--- include/initially_hidden.h
+#include "textual.h"
+
+//--- include/module.modulemap
+module Piecewise {
+  module Empty {
+header "empty.h"
+  }
+  module InitiallyHidden {
+header "initially_hidden.h"
+export *
+  }
+}
+
+//--- test.m
+// Including empty.h loads the entire module Piecewise but keeps InitiallyHidden hidden.
+#include "empty.h"
+#include "textual.h"
+#ifdef TEST_MAKE_HIDDEN_VISIBLE
+#include "initially_hidden.h"
+#endif
+// expected-no-diagnostics
Index: clang/test/Modules/compare-objc-protocol.m
===
--- clang/test/Modules/compare-objc-protocol.m
+++ clang/test/Modules/compare-objc-protocol.m
@@ -19,6 +19,11 @@
 // RUN: %clang_cc1 -I%t/include -verify %t/test.m -fblocks -fobjc-arc \
 // RUN:-fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache
 
+// Run the same test with second.h being modular
+// RUN: cat %t/include/second.modulemap >> %t/include/module.modulemap
+// RUN: %clang_cc1 -I%t/include -verify %t/test.m -fblocks -fobjc-arc -DTEST_MODULAR=1 \
+// RUN:-fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache
+
 // In non-modular case we ignore protocol redefinitions. But with modules
 // previous definition can come from a hidden [sub]module. And in this case we
 // allow a new definition if it is equivalent to the hidden one.
@@ -47,6 +52,7 @@
 export *
   }
 }
+//--- include/second.modulemap
 module Second {
   header "second.h"
   export *
@@ -99,17 +105,21 @@
 
 id compareProtocolPresence1;
 // expected-error@first.h:* {{'CompareProtocolPresence1' has different definitions in different modules; first difference is definition in module 'First.Hidden' found 1 referenced protocol}}
+#ifdef TEST_MODULAR
 // expected-note@second.h:* {{but in 'Second' found 0 referenced protocols}}
+#else
+// expected-note@second.h:* {{but in definition here found 0 referenced protocols}}
+#endif
 id compareProtocolPresence2;
 // expected-error@first.h:* {{'CompareProtocolPresence2' has different definitions in different modules; first difference is definition in module 'First.Hidden' found 0 referenced protocols}}
-// expected-note@second.h:* {{but in 'Second' found 1 referenced protocol}}
+// expected-note-re@second.h:* {{but in {{'Second'|definition here}} found 1 referenced protocol}}
 
 id compareDifferentProtocols;
 // expected-error@first.h:* 

[PATCH] D130326: [ODRHash] Hash `ObjCPropertyDecl` and diagnose discovered mismatches.

2022-07-21 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai created this revision.
Herald added a subscriber: ributzka.
Herald added a project: All.
vsapsai 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/D130326

Files:
  clang/include/clang/AST/ODRDiagsEmitter.h
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/lib/AST/ODRDiagsEmitter.cpp
  clang/lib/AST/ODRHash.cpp
  clang/test/Modules/compare-objc-protocol.m

Index: clang/test/Modules/compare-objc-protocol.m
===
--- clang/test/Modules/compare-objc-protocol.m
+++ clang/test/Modules/compare-objc-protocol.m
@@ -242,3 +242,108 @@
 // expected-note@second.h:* {{but in 'Second' found 'required' method control}}
 id compareMethodRequirednessDefault; // no error
 #endif
+
+#if defined(FIRST)
+@protocol CompareMatchingProperties
+@property int matchingPropName;
+@end
+
+@protocol ComparePropertyPresence1
+@property int propPresence1;
+@end
+@protocol ComparePropertyPresence2
+@end
+
+@protocol ComparePropertyName
+@property int propNameA;
+@end
+
+@protocol ComparePropertyType
+@property int propType;
+@end
+
+@protocol ComparePropertyOrder
+@property int propOrderX;
+@property int propOrderY;
+@end
+
+@protocol CompareMatchingPropertyAttributes
+@property (nonatomic, assign) int matchingProp;
+@end
+@protocol ComparePropertyAttributes
+@property (nonatomic) int propAttributes;
+@end
+// Edge cases.
+@protocol CompareFirstImplAttribute
+@property int firstImplAttribute;
+@end
+@protocol CompareLastImplAttribute
+// Cannot test with protocols 'direct' attribute because it's not allowed.
+@property (class) int lastImplAttribute;
+@end
+#elif defined(SECOND)
+@protocol CompareMatchingProperties
+@property int matchingPropName;
+@end
+
+@protocol ComparePropertyPresence1
+@end
+@protocol ComparePropertyPresence2
+@property int propPresence2;
+@end
+
+@protocol ComparePropertyName
+@property int propNameB;
+@end
+
+@protocol ComparePropertyType
+@property float propType;
+@end
+
+@protocol ComparePropertyOrder
+@property int propOrderY;
+@property int propOrderX;
+@end
+
+@protocol CompareMatchingPropertyAttributes
+@property (assign, nonatomic) int matchingProp;
+@end
+@protocol ComparePropertyAttributes
+@property (atomic) int propAttributes;
+@end
+// Edge cases.
+@protocol CompareFirstImplAttribute
+@property (readonly) int firstImplAttribute;
+@end
+@protocol CompareLastImplAttribute
+@property int lastImplAttribute;
+@end
+#else
+id compareMatchingProperties;
+id comparePropertyPresence1;
+// expected-error@first.h:* {{'ComparePropertyPresence1' has different definitions in different modules; first difference is definition in module 'First.Hidden' found property}}
+// expected-note@second.h:* {{but in 'Second' found end of class}}
+id comparePropertyPresence2;
+// expected-error@first.h:* {{'ComparePropertyPresence2' has different definitions in different modules; first difference is definition in module 'First.Hidden' found end of class}}
+// expected-note@second.h:* {{but in 'Second' found property}}
+id comparePropertyName;
+// expected-error@first.h:* {{'ComparePropertyName' has different definitions in different modules; first difference is definition in module 'First.Hidden' found property 'propNameA'}}
+// expected-note@second.h:* {{but in 'Second' found property 'propNameB'}}
+id comparePropertyType;
+// expected-error@first.h:* {{'ComparePropertyType' has different definitions in different modules; first difference is definition in module 'First.Hidden' found property 'propType' with type 'int'}}
+// expected-note@second.h:* {{but in 'Second' found property 'propType' with type 'float'}}
+id comparePropertyOrder;
+// expected-error@first.h:* {{'ComparePropertyOrder' has different definitions in different modules; first difference is definition in module 'First.Hidden' found property 'propOrderX'}}
+// expected-note@second.h:* {{but in 'Second' found property 'propOrderY'}}
+
+id compareMatchingPropertyAttributes;
+id comparePropertyAttributes;
+// expected-error@first.h:* {{'ComparePropertyAttributes' has different definitions in different modules; first difference is definition in module 'First.Hidden' found property 'propAttributes' with 'nonatomic' attribute}}
+// expected-note@second.h:* {{but in 'Second' found property 'propAttributes' with different 'nonatomic' attribute}}
+id compareFirstImplAttribute;
+// expected-error@first.h:* {{'CompareFirstImplAttribute' has different definitions in different modules; first difference is definition in module 'First.Hidden' found property 'firstImplAttribute' with default 'readonly' attribute}}
+// expected-note@second.h:* {{but in 'Second' found property 'firstImplAttribute' with different 'readonly' attribute}}
+id compareLastImplAttribute;
+// expected-error@first.h:* {{'CompareLastImplAttribute' has different definitions in different modules; first difference 

[PATCH] D130273: [clang][Driver] Handle SPARC -mcpu=native etc.

2022-07-21 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:2225
+StringRef Name = A->getValue();
+
+std::string TuneCPU;

delete blank line after a variable declaration



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:2226
+
+std::string TuneCPU;
+if (Name == "native")

```
std::string TuneCPU(Name == "native" ? ... : ...)
if (!TuneCPU.empty()) {
  ...
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130273

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


[PATCH] D130325: [ODRHash] Hash `ObjCMethodDecl` and diagnose discovered mismatches.

2022-07-21 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai created this revision.
Herald added a subscriber: ributzka.
Herald added a project: All.
vsapsai 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/D130325

Files:
  clang/include/clang/AST/ODRDiagsEmitter.h
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/lib/AST/ODRDiagsEmitter.cpp
  clang/lib/AST/ODRHash.cpp
  clang/test/Modules/compare-objc-protocol.m

Index: clang/test/Modules/compare-objc-protocol.m
===
--- clang/test/Modules/compare-objc-protocol.m
+++ clang/test/Modules/compare-objc-protocol.m
@@ -111,3 +111,134 @@
 // expected-error@first.h:* {{'CompareProtocolOrder' has different definitions in different modules; first difference is definition in module 'First.Hidden' found 1st referenced protocol with name 'CommonProtocol'}}
 // expected-note@second.h:* {{but in 'Second' found 1st referenced protocol with different name 'ExtraProtocol'}}
 #endif
+
+#if defined(FIRST)
+@protocol CompareMatchingMethods
+- (float)matchingMethod:(int)arg;
+@end
+
+@protocol CompareMethodPresence1
+- (void)presenceMethod1;
+@end
+@protocol CompareMethodPresence2
+@end
+
+@protocol CompareMethodName
+- (void)methodNameA;
+@end
+
+@protocol CompareMethodArgCount
+- (void)methodArgCount:(int)arg0 :(int)arg1;
+@end
+@protocol CompareMethodArgName
+- (void)methodArgName:(int)argNameA;
+@end
+@protocol CompareMethodArgType
+- (void)methodArgType:(int)argType;
+@end
+
+@protocol CompareMethodReturnType
+- (int)methodReturnType;
+@end
+
+@protocol CompareMethodOrder
+- (void)methodOrderFirst;
+- (void)methodOrderSecond;
+@end
+
+@protocol CompareMethodClassInstance
+- (void)methodClassInstance;
+@end
+
+@protocol CompareMethodRequirednessExplicit
+@optional
+- (void)methodRequiredness;
+@end
+@protocol CompareMethodRequirednessDefault
+// @required is default
+- (void)methodRequiredness;
+@end
+#elif defined(SECOND)
+@protocol CompareMatchingMethods
+- (float)matchingMethod:(int)arg;
+@end
+
+@protocol CompareMethodPresence1
+@end
+@protocol CompareMethodPresence2
+- (void)presenceMethod2;
+@end
+
+@protocol CompareMethodName
+- (void)methodNameB;
+@end
+
+@protocol CompareMethodArgCount
+- (void)methodArgCount:(int)arg0;
+@end
+@protocol CompareMethodArgName
+- (void)methodArgName:(int)argNameB;
+@end
+@protocol CompareMethodArgType
+- (void)methodArgType:(float)argType;
+@end
+
+@protocol CompareMethodReturnType
+- (float)methodReturnType;
+@end
+
+@protocol CompareMethodOrder
+- (void)methodOrderSecond;
+- (void)methodOrderFirst;
+@end
+
+@protocol CompareMethodClassInstance
++ (void)methodClassInstance;
+@end
+
+@protocol CompareMethodRequirednessExplicit
+@required
+- (void)methodRequiredness;
+@end
+@protocol CompareMethodRequirednessDefault
+@required
+- (void)methodRequiredness;
+@end
+#else
+id compareMatchingMethods; // no error
+id compareMethodPresence1;
+// expected-error@first.h:* {{'CompareMethodPresence1' has different definitions in different modules; first difference is definition in module 'First.Hidden' found method}}
+// expected-note@second.h:* {{but in 'Second' found end of class}}
+id compareMethodPresence2;
+// expected-error@first.h:* {{'CompareMethodPresence2' has different definitions in different modules; first difference is definition in module 'First.Hidden' found end of class}}
+// expected-note@second.h:* {{but in 'Second' found method}}
+id compareMethodName;
+// expected-error@first.h:* {{'CompareMethodName' has different definitions in different modules; first difference is definition in module 'First.Hidden' found method 'methodNameA'}}
+// expected-note@second.h:* {{but in 'Second' found different method 'methodNameB'}}
+
+id compareMethodArgCount;
+// expected-error@first.h:* {{'CompareMethodArgCount' has different definitions in different modules; first difference is definition in module 'First.Hidden' found method 'methodArgCount::' that has 2 parameters}}
+// expected-note@second.h:* {{but in 'Second' found method 'methodArgCount:' that has 1 parameter}}
+id compareMethodArgName;
+// expected-error@first.h:* {{'CompareMethodArgName' has different definitions in different modules; first difference is definition in module 'First.Hidden' found method 'methodArgName:' with 1st parameter named 'argNameA'}}
+// expected-note@second.h:* {{but in 'Second' found method 'methodArgName:' with 1st parameter named 'argNameB'}}
+id compareMethodArgType;
+// expected-error@first.h:* {{'CompareMethodArgType' has different definitions in different modules; first difference is definition in module 'First.Hidden' found method 'methodArgType:' with 1st parameter of type 'int'}}
+// expected-note@second.h:* {{but in 'Second' found method 'methodArgType:' with 1st parameter of type 'float'}}
+
+id compareMethodReturnType;
+// expected-error@first.h:* {{'CompareMethodReturnType' has different definitions in 

[PATCH] D130273: [clang][Driver] Handle SPARC -mcpu=native etc.

2022-07-21 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

I notice that in gcc, -march/-mtune/-mcpu are handled in gcc/config/* and every 
port may have somewhat different behaviors. E.g. x86 and aarch64 are different 
(and I suspect x86 has the weird behavior).

Have you checked that whether this matches GCC? We need some clang/test/Driver 
tests for `"-cc1"{{.*}} "-target-cpu" "..."`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130273

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


[PATCH] D130324: [ODRHash] Hash `ObjCProtocolDecl` and diagnose discovered mismatches.

2022-07-21 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai created this revision.
Herald added a subscriber: ributzka.
Herald added a project: All.
vsapsai 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/D130324

Files:
  clang/include/clang/AST/DeclObjC.h
  clang/include/clang/AST/ODRDiagsEmitter.h
  clang/include/clang/AST/ODRHash.h
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/include/clang/Serialization/ASTReader.h
  clang/lib/AST/DeclObjC.cpp
  clang/lib/AST/ODRDiagsEmitter.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/Modules/compare-objc-protocol.m

Index: clang/test/Modules/compare-objc-protocol.m
===
--- /dev/null
+++ clang/test/Modules/compare-objc-protocol.m
@@ -0,0 +1,113 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+// Build first header file
+// RUN: echo "#define FIRST" >> %t/include/first.h
+// RUN: cat %t/test.m>> %t/include/first.h
+// RUN: echo "#undef FIRST"  >> %t/include/first.h
+
+// Build second header file
+// RUN: echo "#define SECOND" >> %t/include/second.h
+// RUN: cat %t/test.m >> %t/include/second.h
+// RUN: echo "#undef SECOND"  >> %t/include/second.h
+
+// Test that each header can compile
+// RUN: %clang_cc1 -fsyntax-only -x objective-c %t/include/first.h -fblocks -fobjc-arc
+// RUN: %clang_cc1 -fsyntax-only -x objective-c %t/include/second.h -fblocks -fobjc-arc
+
+// Run test
+// RUN: %clang_cc1 -I%t/include -verify %t/test.m -fblocks -fobjc-arc \
+// RUN:-fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache
+
+// In non-modular case we ignore protocol redefinitions. But with modules
+// previous definition can come from a hidden [sub]module. And in this case we
+// allow a new definition if it is equivalent to the hidden one.
+//
+// This test case is to verify equivalence checks.
+
+//--- include/common.h
+#ifndef COMMON_H
+#define COMMON_H
+@protocol CommonProtocol @end
+@protocol ExtraProtocol @end
+#endif
+
+//--- include/first-empty.h
+//--- include/module.modulemap
+module Common {
+  header "common.h"
+  export *
+}
+module First {
+  module Empty {
+header "first-empty.h"
+  }
+  module Hidden {
+header "first.h"
+export *
+  }
+}
+module Second {
+  header "second.h"
+  export *
+}
+
+//--- test.m
+#if defined(FIRST) || defined(SECOND)
+# include "common.h"
+#endif
+
+#if !defined(FIRST) && !defined(SECOND)
+# include "first-empty.h"
+# include "second.h"
+#endif
+
+#if defined(FIRST)
+@protocol CompareForwardDeclaration1;
+@protocol CompareForwardDeclaration2 @end
+#elif defined(SECOND)
+@protocol CompareForwardDeclaration1 @end
+@protocol CompareForwardDeclaration2;
+#else
+id compareForwardDeclaration1;
+id compareForwardDeclaration2;
+#endif
+
+#if defined(FIRST)
+@protocol CompareMatchingConformingProtocols @end
+@protocol ForwardProtocol;
+@protocol CompareMatchingConformingForwardProtocols @end
+
+@protocol CompareProtocolPresence1 @end
+@protocol CompareProtocolPresence2 @end
+
+@protocol CompareDifferentProtocols @end
+@protocol CompareProtocolOrder @end
+#elif defined(SECOND)
+@protocol CompareMatchingConformingProtocols @end
+@protocol ForwardProtocol @end
+@protocol CompareMatchingConformingForwardProtocols @end
+
+@protocol CompareProtocolPresence1 @end
+@protocol CompareProtocolPresence2 @end
+
+@protocol CompareDifferentProtocols @end
+@protocol CompareProtocolOrder @end
+#else
+id compareMatchingConformingProtocols;
+id compareMatchingConformingForwardProtocols;
+
+id compareProtocolPresence1;
+// expected-error@first.h:* {{'CompareProtocolPresence1' has different definitions in different modules; first difference is definition in module 'First.Hidden' found 1 referenced protocol}}
+// expected-note@second.h:* {{but in 'Second' found 0 referenced protocols}}
+id compareProtocolPresence2;
+// expected-error@first.h:* {{'CompareProtocolPresence2' has different definitions in different modules; first difference is definition in module 'First.Hidden' found 0 referenced protocols}}
+// expected-note@second.h:* {{but in 'Second' found 1 referenced protocol}}
+
+id compareDifferentProtocols;
+// expected-error@first.h:* {{'CompareDifferentProtocols' has different definitions in different modules; first difference is definition in module 'First.Hidden' found 1st referenced protocol with name 'CommonProtocol'}}
+// expected-note@second.h:* {{but in 'Second' found 1st referenced protocol with different name 'ExtraProtocol'}}
+id compareProtocolOrder;
+// expected-error@first.h:* {{'CompareProtocolOrder' has different definitions in different modules; first difference is definition in module 'First.Hidden' found 1st referenced protocol with name 'CommonProtocol'}}
+// expected-note@second.h:* {{but in 'Second' found 1st 

[clang] 2191528 - [Driver][test] Remove unused "-o %t.s" from frame-pointer*.c

2022-07-21 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2022-07-21T19:41:25-07:00
New Revision: 219152837375283bde1f1586b6d709b51941a90f

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

LOG: [Driver][test] Remove unused "-o %t.s" from frame-pointer*.c

Added: 


Modified: 
clang/test/Driver/frame-pointer-elim.cl
clang/test/Driver/frame-pointer.c

Removed: 




diff  --git a/clang/test/Driver/frame-pointer-elim.cl 
b/clang/test/Driver/frame-pointer-elim.cl
index c469d10a64be9..76f6607a1f175 100644
--- a/clang/test/Driver/frame-pointer-elim.cl
+++ b/clang/test/Driver/frame-pointer-elim.cl
@@ -1,8 +1,8 @@
-// RUN: %clang -target amdgcn-amd-amdhsa -### -S -O3 %s -o %t.s 2>&1 | 
FileCheck -check-prefix=CHECKNONE %s
-// RUN: %clang -target amdgcn-amd-amdhsa -### -S -O3 -fno-omit-frame-pointer 
%s -o %t.s 2>&1 | FileCheck -check-prefix=CHECKALL %s
-// RUN: %clang -target amdgcn-amd-amdhsa -### -S %s -o %t.s 2>&1 | FileCheck 
-check-prefix=CHECKALL %s
-// RUN: %clang -target amdgcn-amd-amdhsa -### -S -O0 %s -o %t.s 2>&1 | 
FileCheck -check-prefix=CHECKALL %s
-// RUN: %clang -target amdgcn-amd-amdhsa -### -S -cl-opt-disable %s -o %t.s 
2>&1 | FileCheck -check-prefix=CHECKALL %s
+// RUN: %clang --target=amdgcn-amd-amdhsa -### -S -O3 %s 2>&1 | FileCheck 
-check-prefix=CHECKNONE %s
+// RUN: %clang --target=amdgcn-amd-amdhsa -### -S -O3 -fno-omit-frame-pointer 
%s 2>&1 | FileCheck -check-prefix=CHECKALL %s
+// RUN: %clang --target=amdgcn-amd-amdhsa -### -S %s 2>&1 | FileCheck 
-check-prefix=CHECKALL %s
+// RUN: %clang --target=amdgcn-amd-amdhsa -### -S -O0 %s 2>&1 | FileCheck 
-check-prefix=CHECKALL %s
+// RUN: %clang --target=amdgcn-amd-amdhsa -### -S -cl-opt-disable %s 2>&1 | 
FileCheck -check-prefix=CHECKALL %s
 
 // CHECKNONE: -mframe-pointer=none
 // CHECKALL: -mframe-pointer=all

diff  --git a/clang/test/Driver/frame-pointer.c 
b/clang/test/Driver/frame-pointer.c
index 7d780f0722632..47884e4e20036 100644
--- a/clang/test/Driver/frame-pointer.c
+++ b/clang/test/Driver/frame-pointer.c
@@ -1,61 +1,61 @@
-// RUN: %clang -target i386-pc-linux -### -S -O0 %s -o %t.s 2>&1 | FileCheck 
-check-prefix=CHECK0-32 %s
-// RUN: %clang -target i386-pc-linux -### -S -O1 %s -o %t.s 2>&1 | FileCheck 
-check-prefix=CHECK1-32 %s
-// RUN: %clang -target i386-pc-linux -### -S -O2 %s -o %t.s 2>&1 | FileCheck 
-check-prefix=CHECK2-32 %s
-// RUN: %clang -target i386-pc-linux -### -S -O3 %s -o %t.s 2>&1 | FileCheck 
-check-prefix=CHECK3-32 %s
-// RUN: %clang -target i386-pc-linux -### -S -Os %s -o %t.s 2>&1 | FileCheck 
-check-prefix=CHECKs-32 %s
+// RUN: %clang --target=i386-pc-linux -### -S -O0 %s 2>&1 | FileCheck 
-check-prefix=CHECK0-32 %s
+// RUN: %clang --target=i386-pc-linux -### -S -O1 %s 2>&1 | FileCheck 
-check-prefix=CHECK1-32 %s
+// RUN: %clang --target=i386-pc-linux -### -S -O2 %s 2>&1 | FileCheck 
-check-prefix=CHECK2-32 %s
+// RUN: %clang --target=i386-pc-linux -### -S -O3 %s 2>&1 | FileCheck 
-check-prefix=CHECK3-32 %s
+// RUN: %clang --target=i386-pc-linux -### -S -Os %s 2>&1 | FileCheck 
-check-prefix=CHECKs-32 %s
 
 
-// RUN: %clang -target x86_64-pc-linux -### -S -O0 %s -o %t.s 2>&1 | FileCheck 
-check-prefix=CHECK0-64 %s
-// RUN: %clang -target x86_64-pc-linux -### -S -O1 %s -o %t.s 2>&1 | FileCheck 
-check-prefix=CHECK1-64 %s
-// RUN: %clang -target x86_64-pc-linux -### -S -O2 %s -o %t.s 2>&1 | FileCheck 
-check-prefix=CHECK2-64 %s
-// RUN: %clang -target x86_64-pc-linux -### -S -O3 %s -o %t.s 2>&1 | FileCheck 
-check-prefix=CHECK3-64 %s
-// RUN: %clang -target x86_64-pc-linux -### -S -Os %s -o %t.s 2>&1 | FileCheck 
-check-prefix=CHECKs-64 %s
-// RUN: %clang -target x86_64-pc-win32-macho -### -S -O3 %s -o %t.s 2>&1 | 
FileCheck -check-prefix=CHECK-MACHO-64 %s
+// RUN: %clang --target=x86_64-pc-linux -### -S -O0 %s 2>&1 | FileCheck 
-check-prefix=CHECK0-64 %s
+// RUN: %clang --target=x86_64-pc-linux -### -S -O1 %s 2>&1 | FileCheck 
-check-prefix=CHECK1-64 %s
+// RUN: %clang --target=x86_64-pc-linux -### -S -O2 %s 2>&1 | FileCheck 
-check-prefix=CHECK2-64 %s
+// RUN: %clang --target=x86_64-pc-linux -### -S -O3 %s 2>&1 | FileCheck 
-check-prefix=CHECK3-64 %s
+// RUN: %clang --target=x86_64-pc-linux -### -S -Os %s 2>&1 | FileCheck 
-check-prefix=CHECKs-64 %s
+// RUN: %clang --target=x86_64-pc-win32-macho -### -S -O3 %s 2>&1 | FileCheck 
-check-prefix=CHECK-MACHO-64 %s
 
 // Trust the above to get the optimizations right, and just test other targets
 // that want this by default.
-// RUN: %clang -target s390x-pc-linux -### -S -O0 %s -o %t.s 2>&1 | FileCheck 
-check-prefix=CHECK0-64 %s
-// RUN: %clang -target s390x-pc-linux -### -S -O1 %s -o %t.s 2>&1 | FileCheck 
-check-prefix=CHECK1-64 %s
+// RUN: %clang --target=s390x-pc-linux -### -S -O0 %s 2>&1 | FileCheck 
-check-prefix=CHECK0-64 %s
+// RUN: %clang 

[PATCH] D129573: [clang] add a diagnostic note 'while loop outside functions' at global scope

2022-07-21 Thread YingChi Long via Phabricator via cfe-commits
inclyc marked 2 inline comments as not done.
inclyc added inline comments.



Comment at: clang/test/Parser/while-loop-outside-function.c:3
+
+while // expected-error {{while loop outside of a function}}
+(1) {};

Thanks a lot for your suggestion, I replaced this statement with two lines to 
test if the diagnostics are correctly given at the token `while`.

The C++ test cases is also changed like this.



Comment at: clang/test/Parser/while-loop-outside-function.c:10
+
+int overload_return(); // expected-note {{previous declaration is here}}
+

This test case checks whether the program can correctly diagnose other errors 
after reporting our newly added error



Comment at: clang/test/Parser/while-loop-outside-function.c:24
+void correct() {
+while(1) {};
+while(1);

Should not give diagnostic information at these 2 lines of correct statements


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

https://reviews.llvm.org/D129573

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


[PATCH] D130255: [Clang][LoongArch] Add initial LoongArch target and driver support

2022-07-21 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/lib/Driver/ToolChains/Linux.cpp:480
+LibDir = std::string(getOSLibDir(Triple, Args));
+StringRef ABIName = tools::loongarch::getLoongArchABI(Args, Triple);
+Loader = ("ld-linux-loongarch-" + ABIName + ".so.1").str();

avoid simple variable which is only used once



Comment at: clang/test/Driver/loongarch64-toolchain.c:4
+
+// RUN: %clang %s -### -no-canonical-prefixes -target loongarch64 2>&1 | 
FileCheck -check-prefix=CC1 %s
+// CC1: clang{{.*}} "-cc1" "-triple" "loongarch64"

Just remove `-no-canonical-prefixes` and `clang{{.*}}` below. `"-cc1"` is 
sufficient to anchor a cc1 line.



Comment at: clang/test/Preprocessor/init-loongarch.c:21
+// LA32: #define __ATOMIC_ACQUIRE 2
+// LA32: #define __ATOMIC_ACQ_REL 4
+// LA32: #define __ATOMIC_CONSUME 1

Consider using `-NEXT` for related values


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130255

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


[PATCH] D129824: [RISCV] Set triple based on -march flag which can be deduced in more generic way

2022-07-21 Thread Philip Reames via Phabricator via cfe-commits
reames added a comment.

This was very briefly discussed at today's sync up call.  We were running short 
on time, so we didn't get a chance to talk through it, but there did seem to be 
a consensus that discussion on the interface implications was needed.  This 
should hopefully be on the agenda when we talk again in two weeks.


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

https://reviews.llvm.org/D129824

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


[PATCH] D130255: [Clang][LoongArch] Add initial LoongArch target and driver support

2022-07-21 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/lib/Basic/Targets/LoongArch.cpp:26
+  // TODO: To be implemented in future.
+  return ArrayRef();
+}

`return {}`



Comment at: clang/test/Driver/frame-pointer.c:60
 
+// RUN: %clang -target loongarch32 -### -S -O0 %s -o %t.s 2>&1 | FileCheck 
-check-prefix=CHECK0-32 %s
+// RUN: %clang -target loongarch32 -### -S -O1 %s -o %t.s 2>&1 | FileCheck 
-check-prefix=CHECK1-32 %s

Use `--target=` for new tests. `-target ` is a legacy syntax.



Comment at: clang/test/Driver/frame-pointer.c:71
+// RUN: %clang -target loongarch64 -### -S -Os %s -o %t.s 2>&1 | FileCheck 
-check-prefix=CHECKs-64 %s
+//
 // CHECK0-32: -mframe-pointer=all

remove `//` from the otherwise empty line



Comment at: clang/test/Driver/loongarch-abi-error.c:1
+// RUN: not %clang --target=loongarch32-unknown-elf %s -o %t.o -mabi=lp64s 
2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-LA32-LP64S %s

-fsyntax and remove `-o %t.o`



Comment at: clang/test/Driver/loongarch-abi.c:1
+// RUN: %clang --target=loongarch32-unknown-elf %s -### 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-ILP32D %s

The line isn't very song, no need to break it into two.



Comment at: clang/test/Preprocessor/init-loongarch.c:1
+// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=loongarch32 < /dev/null \
+// RUN:   | FileCheck --match-full-lines --check-prefix=LA32 %s

remove `< `


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130255

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


[PATCH] D130322: [clang][CodeGen] Only include ABIInfo.h where required (NFC)

2022-07-21 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay 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/D130322/new/

https://reviews.llvm.org/D130322

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


[PATCH] D129573: [clang] add a diagnostic note 'while loop outside functions' at global scope

2022-07-21 Thread YingChi Long via Phabricator via cfe-commits
inclyc updated this revision to Diff 446690.

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

https://reviews.llvm.org/D129573

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/Parse/ParseDecl.cpp
  clang/test/Parser/while-loop-outside-function.c
  clang/test/Parser/while-loop-outside-function.cpp

Index: clang/test/Parser/while-loop-outside-function.cpp
===
--- /dev/null
+++ clang/test/Parser/while-loop-outside-function.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+while // expected-error {{while loop outside of a function}}
+(true) {};
+
+// without semicolon
+while // expected-error {{while loop outside of a function}}
+(true) {}
+
+do { // expected-error {{expected unqualified-id}}
+int some_var = 1;
+some_var += 3;
+} 
+while // expected-error {{while loop outside of a function}}
+(true); 
+
+void someFunction() {
+while(true) {};
+}
+
+class SomeClass {
+public:
+while(true) {} // expected-error {{expected member name or ';' after declaration specifiers}}
+void some_fn() {
+while(true) {}
+}
+};
Index: clang/test/Parser/while-loop-outside-function.c
===
--- /dev/null
+++ clang/test/Parser/while-loop-outside-function.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+while // expected-error {{while loop outside of a function}}
+(1) {};
+
+// without semicolon
+while // expected-error {{while loop outside of a function}}
+(1) {}
+
+int overload_return(); // expected-note {{previous declaration is here}}
+
+void overload_return() // expected-error {{conflicting types for 'overload_return'}}
+{ 
+while(1) {};
+while(1);
+}
+
+while // expected-error {{while loop outside of a function}}
+(1); 
+
+void correct();
+
+void correct() {
+while(1) {};
+while(1);
+}
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -6344,23 +6344,27 @@
diag::err_expected_member_name_or_semi)
   << (D.getDeclSpec().isEmpty() ? SourceRange()
 : D.getDeclSpec().getSourceRange());
-} else if (getLangOpts().CPlusPlus) {
-  if (Tok.isOneOf(tok::period, tok::arrow))
-Diag(Tok, diag::err_invalid_operator_on_type) << Tok.is(tok::arrow);
-  else {
-SourceLocation Loc = D.getCXXScopeSpec().getEndLoc();
-if (Tok.isAtStartOfLine() && Loc.isValid())
-  Diag(PP.getLocForEndOfToken(Loc), diag::err_expected_unqualified_id)
-  << getLangOpts().CPlusPlus;
-else
-  Diag(getMissingDeclaratorIdLoc(D, Tok.getLocation()),
-   diag::err_expected_unqualified_id)
-  << getLangOpts().CPlusPlus;
-  }
 } else {
-  Diag(getMissingDeclaratorIdLoc(D, Tok.getLocation()),
-   diag::err_expected_either)
-  << tok::identifier << tok::l_paren;
+  if (Tok.getKind() == tok::TokenKind::kw_while) {
+Diag(Tok, diag::err_while_loop_outside_of_a_function);
+  } else if (getLangOpts().CPlusPlus) {
+if (Tok.isOneOf(tok::period, tok::arrow))
+  Diag(Tok, diag::err_invalid_operator_on_type) << Tok.is(tok::arrow);
+else {
+  SourceLocation Loc = D.getCXXScopeSpec().getEndLoc();
+  if (Tok.isAtStartOfLine() && Loc.isValid())
+Diag(PP.getLocForEndOfToken(Loc), diag::err_expected_unqualified_id)
+<< getLangOpts().CPlusPlus;
+  else
+Diag(getMissingDeclaratorIdLoc(D, Tok.getLocation()),
+ diag::err_expected_unqualified_id)
+<< getLangOpts().CPlusPlus;
+}
+  } else {
+Diag(getMissingDeclaratorIdLoc(D, Tok.getLocation()),
+ diag::err_expected_either)
+<< tok::identifier << tok::l_paren;
+  }
 }
 D.SetIdentifier(nullptr, Tok.getLocation());
 D.setInvalidType(true);
Index: clang/include/clang/Basic/DiagnosticParseKinds.td
===
--- clang/include/clang/Basic/DiagnosticParseKinds.td
+++ clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -538,6 +538,8 @@
   "cannot use %select{dot|arrow}0 operator on a type">;
 def err_expected_unqualified_id : Error<
   "expected %select{identifier|unqualified-id}0">;
+def err_while_loop_outside_of_a_function : Error<
+  "while loop outside of a function">; 
 def err_brackets_go_after_unqualified_id : Error<
   "brackets are not allowed here; to declare an array, "
   "place the brackets after the %select{identifier|name}0">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D130255: [Clang][LoongArch] Add initial LoongArch target and driver support

2022-07-21 Thread Lu Weining via Phabricator via cfe-commits
SixWeining added a comment.

In D130255#3668436 , @rengolin wrote:

> This looks great, thanks!
>
> Exciting that we can finally go all the way from C source to LoongArch binary.
>
> The changes look good to me, other than a few nits. But please wait for a day 
> or two for other people to review on their own time.

Thanks, Renato.

Because relocation hasn't been added to the backend, complex code (e.g. with 
function call) can't been compiled currently.
But at least, as you said,  we finally go all the way from C source to 
LoongArch binary. This is a start and further implementation will be added 
later.




Comment at: clang/lib/Basic/Targets/LoongArch.h:69
+// TODO: select appropriate ABI.
+ABI = "ilp32d";
+  }

rengolin wrote:
> nit: this should use `setABI`. Right now, there's no difference, but once the 
> function does more (like setting other ABI flags), you won't need to change 
> it here. Same for the 64-bit version.
Thanks. No problem.



Comment at: clang/lib/Driver/ToolChains/Arch/LoongArch.h:25
+} // end namespace loongarch
+} // namespace tools
+} // end namespace driver

rengolin wrote:
> nit: comment mismatch "end"
Thanks.



Comment at: clang/test/Driver/loongarch-abi.c:41
+
+// CHECK-LA32-LP64S: error: unknown target ABI 'lp64s'
+// CHECK-LA32-LP64F: error: unknown target ABI 'lp64f'

rengolin wrote:
> please, split between pass and error by adding a new `loongarch-abi-error.c` 
> and adding the `error` tests to it.
Thanks. No problem.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130255

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


[PATCH] D130255: [Clang][LoongArch] Add initial LoongArch target and driver support

2022-07-21 Thread Lu Weining via Phabricator via cfe-commits
SixWeining updated this revision to Diff 446688.
SixWeining marked 3 inline comments as done.
SixWeining added a comment.

Address @rengolin's comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130255

Files:
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Basic/Targets.cpp
  clang/lib/Basic/Targets/LoongArch.cpp
  clang/lib/Basic/Targets/LoongArch.h
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
  clang/lib/Driver/ToolChains/Arch/LoongArch.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Clang.h
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/test/Driver/Inputs/multilib_loongarch_linux_sdk/bin/.keep
  clang/test/Driver/Inputs/multilib_loongarch_linux_sdk/include/.keep
  
clang/test/Driver/Inputs/multilib_loongarch_linux_sdk/lib/gcc/loongarch64-unknown-linux-gnu/12.1.0/base/lp64d/crtbegin.o
  
clang/test/Driver/Inputs/multilib_loongarch_linux_sdk/lib/gcc/loongarch64-unknown-linux-gnu/12.1.0/base/lp64f/crtbegin.o
  
clang/test/Driver/Inputs/multilib_loongarch_linux_sdk/lib/gcc/loongarch64-unknown-linux-gnu/12.1.0/base/lp64s/crtbegin.o
  
clang/test/Driver/Inputs/multilib_loongarch_linux_sdk/lib/gcc/loongarch64-unknown-linux-gnu/12.1.0/crtbegin.o
  
clang/test/Driver/Inputs/multilib_loongarch_linux_sdk/loongarch64-unknown-linux-gnu/bin/ld
  
clang/test/Driver/Inputs/multilib_loongarch_linux_sdk/loongarch64-unknown-linux-gnu/lib/.keep
  
clang/test/Driver/Inputs/multilib_loongarch_linux_sdk/loongarch64-unknown-linux-gnu/lib64/.keep
  clang/test/Driver/Inputs/multilib_loongarch_linux_sdk/sysroot/usr/lib/.keep
  clang/test/Driver/Inputs/multilib_loongarch_linux_sdk/sysroot/usr/lib64/.keep
  clang/test/Driver/frame-pointer.c
  clang/test/Driver/loongarch-abi-error.c
  clang/test/Driver/loongarch-abi.c
  clang/test/Driver/loongarch64-toolchain.c
  clang/test/Preprocessor/init-loongarch.c

Index: clang/test/Preprocessor/init-loongarch.c
===
--- /dev/null
+++ clang/test/Preprocessor/init-loongarch.c
@@ -0,0 +1,641 @@
+// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=loongarch32 < /dev/null \
+// RUN:   | FileCheck --match-full-lines --check-prefix=LA32 %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=loongarch32-unknown-linux < /dev/null \
+// RUN:   | FileCheck --match-full-lines --check-prefixes=LA32,LA32-LINUX %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=loongarch32 \
+// RUN: -fforce-enable-int128 < /dev/null | FileCheck --match-full-lines \
+// RUN: --check-prefixes=LA32,LA32-INT128 %s
+
+// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=loongarch64 < /dev/null \
+// RUN:   | FileCheck --match-full-lines --check-prefix=LA64 %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=loongarch64-unknown-linux < /dev/null \
+// RUN:   | FileCheck --match-full-lines --check-prefixes=LA64,LA64-LINUX %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=loongarch64 \
+// RUN: -fforce-enable-int128 < /dev/null | FileCheck --match-full-lines \
+// RUN: --check-prefixes=LA64,LA64-INT128 %s
+
+ Note that common macros are tested in init.c, such as __VERSION__. So they're not listed here.
+
+// LA32: #define _ILP32 1
+// LA32: #define __ATOMIC_ACQUIRE 2
+// LA32: #define __ATOMIC_ACQ_REL 4
+// LA32: #define __ATOMIC_CONSUME 1
+// LA32: #define __ATOMIC_RELAXED 0
+// LA32: #define __ATOMIC_RELEASE 3
+// LA32: #define __ATOMIC_SEQ_CST 5
+// LA32: #define __BIGGEST_ALIGNMENT__ 16
+// LA32: #define __BITINT_MAXWIDTH__ 128
+// LA32: #define __BOOL_WIDTH__ 8
+// LA32: #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
+// LA32: #define __CHAR16_TYPE__ unsigned short
+// LA32: #define __CHAR32_TYPE__ unsigned int
+// LA32: #define __CHAR_BIT__ 8
+// LA32: #define __CLANG_ATOMIC_BOOL_LOCK_FREE 1
+// LA32: #define __CLANG_ATOMIC_CHAR16_T_LOCK_FREE 1
+// LA32: #define __CLANG_ATOMIC_CHAR32_T_LOCK_FREE 1
+// LA32: #define __CLANG_ATOMIC_CHAR_LOCK_FREE 1
+// LA32: #define __CLANG_ATOMIC_INT_LOCK_FREE 1
+// LA32: #define __CLANG_ATOMIC_LLONG_LOCK_FREE 1
+// LA32: #define __CLANG_ATOMIC_LONG_LOCK_FREE 1
+// LA32: #define __CLANG_ATOMIC_POINTER_LOCK_FREE 1
+// LA32: #define __CLANG_ATOMIC_SHORT_LOCK_FREE 1
+// LA32: #define __CLANG_ATOMIC_WCHAR_T_LOCK_FREE 1
+// LA32: #define __DBL_DECIMAL_DIG__ 17
+// LA32: #define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+// LA32: #define __DBL_DIG__ 15
+// LA32: #define __DBL_EPSILON__ 2.2204460492503131e-16
+// LA32: #define __DBL_HAS_DENORM__ 1
+// LA32: #define __DBL_HAS_INFINITY__ 1
+// LA32: #define __DBL_HAS_QUIET_NAN__ 1
+// LA32: #define __DBL_MANT_DIG__ 53
+// LA32: #define __DBL_MAX_10_EXP__ 308
+// LA32: #define __DBL_MAX_EXP__ 1024
+// LA32: #define __DBL_MAX__ 1.7976931348623157e+308
+// LA32: #define 

[PATCH] D128695: [ODRHash diagnostics] Move `ODRDiagsEmitter` to libAST in separate files. NFC.

2022-07-21 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

It looks like we lack a patch to use it in parser, right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128695

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


[PATCH] D128490: [ODRHash diagnostics] Transform method `ASTReader::diagnoseOdrViolations` into a class `ODRDiagsEmitter`. NFC.

2022-07-21 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

In D128490#3670441 , @vsapsai wrote:

> Sorry for the huge amount of changes in ASTReader.cpp but most of them are 
> indentation changes, so I hope it's not too bad. I've tried to minimize the 
> changes unrelated to introducing `ODRDiagsEmitter` but if anybody has other 
> ideas/requests, I'm totally willing to reduce the load on reviewers.

For these indentation changes, maybe it is a good idea to edit the 
`.git-blame-ignore-revs` files in the root path.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128490

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


[PATCH] D130322: [clang][CodeGen] Only include ABIInfo.h where required (NFC)

2022-07-21 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added inline comments.



Comment at: clang/lib/CodeGen/ABIInfo.h:39
-namespace swiftcall {
-  class SwiftAggLowering;
-}

Not used in this file. (This class does not seem to be used anywhere.)



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130322

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


[PATCH] D130322: [clang][CodeGen] Only include ABIInfo.h where required (NFC)

2022-07-21 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 updated this revision to Diff 446685.
barannikov88 added a comment.

Removed forward declaration of non-existent class.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130322

Files:
  clang/lib/CodeGen/ABIInfo.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGCall.h
  clang/lib/CodeGen/CGObjCRuntime.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/SwiftCallingConv.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/TargetInfo.h

Index: clang/lib/CodeGen/TargetInfo.h
===
--- clang/lib/CodeGen/TargetInfo.h
+++ clang/lib/CodeGen/TargetInfo.h
@@ -43,10 +43,10 @@
 /// codegeneration issues, like target-specific attributes, builtins and so
 /// on.
 class TargetCodeGenInfo {
-  std::unique_ptr Info = nullptr;
+  std::unique_ptr Info;
 
 public:
-  TargetCodeGenInfo(std::unique_ptr Info) : Info(std::move(Info)) {}
+  TargetCodeGenInfo(std::unique_ptr Info);
   virtual ~TargetCodeGenInfo();
 
   /// getABIInfo() - Returns ABI info helper for the target.
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -443,6 +443,9 @@
   return Address(PHI, Addr1.getElementType(), Align);
 }
 
+TargetCodeGenInfo::TargetCodeGenInfo(std::unique_ptr Info)
+: Info(std::move(Info)) {}
+
 TargetCodeGenInfo::~TargetCodeGenInfo() = default;
 
 // If someone can figure out a general rule for this, that would be great.
Index: clang/lib/CodeGen/SwiftCallingConv.cpp
===
--- clang/lib/CodeGen/SwiftCallingConv.cpp
+++ clang/lib/CodeGen/SwiftCallingConv.cpp
@@ -11,9 +11,10 @@
 //===--===//
 
 #include "clang/CodeGen/SwiftCallingConv.h"
-#include "clang/Basic/TargetInfo.h"
+#include "ABIInfo.h"
 #include "CodeGenModule.h"
 #include "TargetInfo.h"
+#include "clang/Basic/TargetInfo.h"
 
 using namespace clang;
 using namespace CodeGen;
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -11,6 +11,7 @@
 //===--===//
 
 #include "CodeGenModule.h"
+#include "ABIInfo.h"
 #include "CGBlocks.h"
 #include "CGCUDARuntime.h"
 #include "CGCXXABI.h"
@@ -32,7 +33,6 @@
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/Mangle.h"
-#include "clang/AST/RecordLayout.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/StmtVisitor.h"
 #include "clang/Basic/Builtins.h"
Index: clang/lib/CodeGen/CGObjCRuntime.h
===
--- clang/lib/CodeGen/CGObjCRuntime.h
+++ clang/lib/CodeGen/CGObjCRuntime.h
@@ -34,6 +34,7 @@
 
 namespace clang {
 namespace CodeGen {
+  class CGFunctionInfo;
   class CodeGenFunction;
 }
 
Index: clang/lib/CodeGen/CGCall.h
===
--- clang/lib/CodeGen/CGCall.h
+++ clang/lib/CodeGen/CGCall.h
@@ -22,9 +22,6 @@
 #include "clang/AST/Type.h"
 #include "llvm/IR/Value.h"
 
-// FIXME: Restructure so we don't have to expose so much stuff.
-#include "ABIInfo.h"
-
 namespace llvm {
 class Type;
 class Value;
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -10,6 +10,7 @@
 //
 //===--===//
 
+#include "ABIInfo.h"
 #include "CGCUDARuntime.h"
 #include "CGCXXABI.h"
 #include "CGObjCRuntime.h"
Index: clang/lib/CodeGen/ABIInfo.h
===
--- clang/lib/CodeGen/ABIInfo.h
+++ clang/lib/CodeGen/ABIInfo.h
@@ -35,10 +35,6 @@
   class CodeGenTypes;
   class SwiftABIInfo;
 
-namespace swiftcall {
-  class SwiftAggLowering;
-}
-
   // FIXME: All of this stuff should be part of the target interface
   // somehow. It is currently here because it is not clear how to factor
   // the targets to support this, since the Targets currently live in a
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D130322: [clang][CodeGen] Only include ABIInfo.h where required (NFC)

2022-07-21 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added a comment.

To reviewers: if you are OK with the patch, could you please merge it? I don't 
have permission yet.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130322

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


[PATCH] D130322: [clang][CodeGen] Only include ABIInfo.h where required (NFC)

2022-07-21 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.h:49
 public:
-  TargetCodeGenInfo(std::unique_ptr Info) : Info(std::move(Info)) {}
+  TargetCodeGenInfo(std::unique_ptr Info);
   virtual ~TargetCodeGenInfo();

Had to do this due to "incomplete class" error. Should not change a thing 
because this constructor is ever used in TargetInfo.cpp, where it now resides.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130322

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


[PATCH] D130322: [clang][CodeGen] Only include ABIInfo.h where required (NFC)

2022-07-21 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added inline comments.



Comment at: clang/lib/CodeGen/CGCall.h:26
-// FIXME: Restructure so we don't have to expose so much stuff.
-#include "ABIInfo.h"
-

This is the main change. The included file was not used here at all.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130322

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


[PATCH] D130322: [clang][CodeGen] Only include ABIInfo.h where required

2022-07-21 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 created this revision.
Herald added a project: All.
barannikov88 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/D130322

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGCall.h
  clang/lib/CodeGen/CGObjCRuntime.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/SwiftCallingConv.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/TargetInfo.h

Index: clang/lib/CodeGen/TargetInfo.h
===
--- clang/lib/CodeGen/TargetInfo.h
+++ clang/lib/CodeGen/TargetInfo.h
@@ -43,10 +43,10 @@
 /// codegeneration issues, like target-specific attributes, builtins and so
 /// on.
 class TargetCodeGenInfo {
-  std::unique_ptr Info = nullptr;
+  std::unique_ptr Info;
 
 public:
-  TargetCodeGenInfo(std::unique_ptr Info) : Info(std::move(Info)) {}
+  TargetCodeGenInfo(std::unique_ptr Info);
   virtual ~TargetCodeGenInfo();
 
   /// getABIInfo() - Returns ABI info helper for the target.
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -443,6 +443,9 @@
   return Address(PHI, Addr1.getElementType(), Align);
 }
 
+TargetCodeGenInfo::TargetCodeGenInfo(std::unique_ptr Info)
+: Info(std::move(Info)) {}
+
 TargetCodeGenInfo::~TargetCodeGenInfo() = default;
 
 // If someone can figure out a general rule for this, that would be great.
Index: clang/lib/CodeGen/SwiftCallingConv.cpp
===
--- clang/lib/CodeGen/SwiftCallingConv.cpp
+++ clang/lib/CodeGen/SwiftCallingConv.cpp
@@ -11,9 +11,10 @@
 //===--===//
 
 #include "clang/CodeGen/SwiftCallingConv.h"
-#include "clang/Basic/TargetInfo.h"
+#include "ABIInfo.h"
 #include "CodeGenModule.h"
 #include "TargetInfo.h"
+#include "clang/Basic/TargetInfo.h"
 
 using namespace clang;
 using namespace CodeGen;
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -11,6 +11,7 @@
 //===--===//
 
 #include "CodeGenModule.h"
+#include "ABIInfo.h"
 #include "CGBlocks.h"
 #include "CGCUDARuntime.h"
 #include "CGCXXABI.h"
@@ -32,7 +33,6 @@
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/Mangle.h"
-#include "clang/AST/RecordLayout.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/StmtVisitor.h"
 #include "clang/Basic/Builtins.h"
Index: clang/lib/CodeGen/CGObjCRuntime.h
===
--- clang/lib/CodeGen/CGObjCRuntime.h
+++ clang/lib/CodeGen/CGObjCRuntime.h
@@ -34,6 +34,7 @@
 
 namespace clang {
 namespace CodeGen {
+  class CGFunctionInfo;
   class CodeGenFunction;
 }
 
Index: clang/lib/CodeGen/CGCall.h
===
--- clang/lib/CodeGen/CGCall.h
+++ clang/lib/CodeGen/CGCall.h
@@ -22,9 +22,6 @@
 #include "clang/AST/Type.h"
 #include "llvm/IR/Value.h"
 
-// FIXME: Restructure so we don't have to expose so much stuff.
-#include "ABIInfo.h"
-
 namespace llvm {
 class Type;
 class Value;
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -10,6 +10,7 @@
 //
 //===--===//
 
+#include "ABIInfo.h"
 #include "CGCUDARuntime.h"
 #include "CGCXXABI.h"
 #include "CGObjCRuntime.h"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128695: [ODRHash diagnostics] Move `ODRDiagsEmitter` to libAST in separate files. NFC.

2022-07-21 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

If anybody knows how to demonstrate the code was moved without modification in 
process, I'll be happy to do that. Unfortunately, the only thing I've found is 
that it should be auto-detected.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128695

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


[PATCH] D128490: [ODRHash diagnostics] Transform method `ASTReader::diagnoseOdrViolations` into a class `ODRDiagsEmitter`. NFC.

2022-07-21 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Sorry for the huge amount of changes in ASTReader.cpp but most of them are 
indentation changes, so I hope it's not too bad. I've tried to minimize the 
changes unrelated to introducing `ODRDiagsEmitter` but if anybody has other 
ideas/requests, I'm totally willing to reduce the load on reviewers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128490

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


[PATCH] D130138: [modules] Replace `-Wauto-import` with `-Rmodule-include-translation`.

2022-07-21 Thread Volodymyr Sapsai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG381fcaa1365b: [modules] Replace `-Wauto-import` with 
`-Rmodule-include-translation`. (authored by vsapsai).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130138

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/lib/Lex/PPDirectives.cpp
  clang/test/Modules/auto-module-import.m
  clang/test/Modules/conflicts.m
  clang/test/Modules/cxx20-include-translation.cpp
  clang/test/Modules/framework-name.m
  clang/test/Modules/global_index.m
  clang/test/Modules/implementation-of-module.m
  clang/test/Modules/inferred-frameworks.m
  clang/test/Modules/inferred-submodules.m
  clang/test/Modules/requires.m
  clang/test/Modules/requires.mm
  clang/test/Modules/resolution-change.m
  clang/test/Modules/subframeworks.m
  clang/test/Modules/submodules.m
  clang/test/VFS/real-path-found-first.m

Index: clang/test/VFS/real-path-found-first.m
===
--- clang/test/VFS/real-path-found-first.m
+++ clang/test/VFS/real-path-found-first.m
@@ -11,13 +11,13 @@
 
 // Build
 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t-cache -F %t \
-// RUN: -ivfsoverlay %t.yaml -fsyntax-only %s -verify -Wauto-import \
+// RUN: -ivfsoverlay %t.yaml -fsyntax-only %s -verify -Rmodule-include-translation \
 // RUN: -Werror=non-modular-include-in-framework-module
 
 // Rebuild
 // RUN: echo ' ' >> %t/SomeFramework.framework/Modules/module.modulemap
 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t-cache -F %t \
-// RUN: -ivfsoverlay %t.yaml -fsyntax-only %s -verify -Wauto-import \
+// RUN: -ivfsoverlay %t.yaml -fsyntax-only %s -verify -Rmodule-include-translation \
 // RUN: -Werror=non-modular-include-in-framework-module
 
 // Load from PCH
@@ -32,11 +32,11 @@
 
 // While indexing
 // RUN: c-index-test -index-file %s -fmodules -fimplicit-module-maps -fmodules-cache-path=%t-cache -F %t \
-// RUN: -ivfsoverlay %t.yaml -fsyntax-only -Wauto-import \
+// RUN: -ivfsoverlay %t.yaml -fsyntax-only -Rmodule-include-translation \
 // RUN: -Werror=non-modular-include-in-framework-module | FileCheck %s
 // RUN: echo ' ' >> %t/SomeFramework.framework/Modules/module.modulemap
 // RUN: c-index-test -index-file %s -fmodules -fimplicit-module-maps -fmodules-cache-path=%t-cache -F %t \
-// RUN: -ivfsoverlay %t.yaml -fsyntax-only -Wauto-import \
+// RUN: -ivfsoverlay %t.yaml -fsyntax-only -Rmodule-include-translation \
 // RUN: -Werror=non-modular-include-in-framework-module | FileCheck %s
 // CHECK: warning: treating
 // CHECK-NOT: error
@@ -49,11 +49,11 @@
 
 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t-cache -F %t \
 // RUN: -ivfsoverlay %t.yaml -ivfsoverlay %t2.yaml -fsyntax-only %s -verify \
-// RUN: -Wauto-import -Werror=non-modular-include-in-framework-module
+// RUN: -Rmodule-include-translation -Werror=non-modular-include-in-framework-module
 // RUN: echo ' ' >> %t/hide_module.map
 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t-cache -F %t \
 // RUN: -ivfsoverlay %t.yaml -ivfsoverlay %t2.yaml -fsyntax-only %s -verify \
-// RUN: -Wauto-import -Werror=non-modular-include-in-framework-module
+// RUN: -Rmodule-include-translation -Werror=non-modular-include-in-framework-module
 
 // Within a module build
 // RUN: echo '@import import_some_frame;' | \
@@ -67,8 +67,8 @@
 // RUN:  -Werror=non-modular-include-in-framework-module -x objective-c -I %t
 
 #ifndef WITH_PREFIX
-#import  // expected-warning{{treating}}
-#import  // expected-warning{{treating}}
-#import  // expected-warning{{treating}}
+#import  // expected-remark{{treating}}
+#import  // expected-remark{{treating}}
+#import  // expected-remark{{treating}}
 @import SomeFramework.public_header2;
 #endif
Index: clang/test/Modules/submodules.m
===
--- clang/test/Modules/submodules.m
+++ clang/test/Modules/submodules.m
@@ -1,6 +1,6 @@
 
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -Wauto-import -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs %s -verify
+// RUN: %clang_cc1 -Rmodule-include-translation -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs %s -verify
 // expected-no-diagnostics
 
 // Note: transitively imports Module.Sub2.
Index: clang/test/Modules/subframeworks.m
===
--- clang/test/Modules/subframeworks.m
+++ clang/test/Modules/subframeworks.m
@@ -1,6 +1,6 @@
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -Wauto-import -Wno-private-module -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs -F %S/Inputs/DependsOnModule.framework/Frameworks %s 

[clang] 381fcaa - [modules] Replace `-Wauto-import` with `-Rmodule-include-translation`.

2022-07-21 Thread Volodymyr Sapsai via cfe-commits

Author: Volodymyr Sapsai
Date: 2022-07-21T17:42:04-07:00
New Revision: 381fcaa1365b4fd8f9682a6a1e09f5b3fd4bbfc2

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

LOG: [modules] Replace `-Wauto-import` with `-Rmodule-include-translation`.

Diagnostic for `-Wauto-import` shouldn't be a warning because it doesn't
represent a potential problem in code that should be fixed. And the
emitted fix-it is likely to trigger `-Watimport-in-framework-header`
which makes it challenging to have a warning-free codebase. But it is
still useful to see how include directives are translated into modular
imports and which module a header belongs to, that's why keep it as a remark.

Keep `-Wauto-import` for now to allow a gradual migration for codebases
using `-Wno-auto-import`, e.g., `-Weverything -Wno-auto-import`.

rdar://79594287

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticLexKinds.td
clang/lib/Lex/PPDirectives.cpp
clang/test/Modules/auto-module-import.m
clang/test/Modules/conflicts.m
clang/test/Modules/cxx20-include-translation.cpp
clang/test/Modules/framework-name.m
clang/test/Modules/global_index.m
clang/test/Modules/implementation-of-module.m
clang/test/Modules/inferred-frameworks.m
clang/test/Modules/inferred-submodules.m
clang/test/Modules/requires.m
clang/test/Modules/requires.mm
clang/test/Modules/resolution-change.m
clang/test/Modules/subframeworks.m
clang/test/Modules/submodules.m
clang/test/VFS/real-path-found-first.m

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 53e246a39ed86..4412c93683ed3 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -35,7 +35,7 @@ def ArrayParameter : DiagGroup<"array-parameter">;
 def AutoDisableVptrSanitizer : DiagGroup<"auto-disable-vptr-sanitizer">;
 def Availability : DiagGroup<"availability">;
 def Section : DiagGroup<"section">;
-def AutoImport : DiagGroup<"auto-import">;
+def : DiagGroup<"auto-import">;
 def FrameworkHdrQuotedInclude : 
DiagGroup<"quoted-include-in-framework-header">;
 def FrameworkIncludePrivateFromPublic :
   DiagGroup<"framework-include-private-from-public">;
@@ -490,6 +490,7 @@ def ModuleBuild : DiagGroup<"module-build">;
 def ModuleImport : DiagGroup<"module-import">;
 def ModuleConflict : DiagGroup<"module-conflict">;
 def ModuleFileExtension : DiagGroup<"module-file-extension">;
+def ModuleIncludeDirectiveTranslation : 
DiagGroup<"module-include-translation">;
 def RoundTripCC1Args : DiagGroup<"round-trip-cc1-args">;
 def NewlineEOF : DiagGroup<"newline-eof">;
 def Nullability : DiagGroup<"nullability">;

diff  --git a/clang/include/clang/Basic/DiagnosticLexKinds.td 
b/clang/include/clang/Basic/DiagnosticLexKinds.td
index dd09097044926..5d3abb1f9b702 100644
--- a/clang/include/clang/Basic/DiagnosticLexKinds.td
+++ b/clang/include/clang/Basic/DiagnosticLexKinds.td
@@ -851,9 +851,9 @@ def warn_framework_include_private_from_public : Warning<
   "public framework header includes private framework header '%0'"
   >, InGroup;
 
-def warn_auto_module_import : Warning<
+def remark_pp_include_directive_modular_translation : Remark<
   "treating #%select{include|import|include_next|__include_macros}0 as an "
-  "import of module '%1'">, InGroup, DefaultIgnore;
+  "import of module '%1'">, InGroup;
 def note_implicit_top_level_module_import_here : Note<
   "submodule of top-level module '%0' implicitly imported here">;
 def warn_uncovered_module_header : Warning<

diff  --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 352e1f2178193..4679cb4e7a34b 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -1806,22 +1806,14 @@ static void diagnoseAutoModuleImport(
 Preprocessor , SourceLocation HashLoc, Token ,
 ArrayRef> Path,
 SourceLocation PathEnd) {
-  StringRef ImportKeyword;
-  if (PP.getLangOpts().ObjC)
-ImportKeyword = "@import";
-  else if (PP.getLangOpts().ModulesTS || PP.getLangOpts().CPlusPlusModules)
-ImportKeyword = "import";
-  else
-return; // no import syntax available
-
   SmallString<128> PathString;
   for (size_t I = 0, N = Path.size(); I != N; ++I) {
 if (I)
   PathString += '.';
 PathString += Path[I].first->getName();
   }
-  int IncludeKind = 0;
 
+  int IncludeKind = 0;
   switch (IncludeTok.getIdentifierInfo()->getPPKeywordID()) {
   case tok::pp_include:
 IncludeKind = 0;
@@ -1843,12 +1835,8 @@ static void diagnoseAutoModuleImport(
 llvm_unreachable("unknown include directive kind");
   }
 
-  

[PATCH] D130138: [modules] Replace `-Wauto-import` with `-Rmodule-include-translation`.

2022-07-21 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Thanks for the review!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130138

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


[PATCH] D28213: [Frontend] Correct values of ATOMIC_*_LOCK_FREE to match builtin

2022-07-21 Thread Ryan Prichard 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 rG02a25279aedc: [Frontend] Correct values of 
ATOMIC_*_LOCK_FREE to match builtin (authored by rprichard).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D28213

Files:
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/test/Preprocessor/init-x86.c
  clang/test/Sema/atomic-ops.c


Index: clang/test/Sema/atomic-ops.c
===
--- clang/test/Sema/atomic-ops.c
+++ clang/test/Sema/atomic-ops.c
@@ -33,11 +33,7 @@
 _Static_assert(__GCC_ATOMIC_INT_LOCK_FREE == __CLANG_ATOMIC_INT_LOCK_FREE, "");
 _Static_assert(__GCC_ATOMIC_LONG_LOCK_FREE == 2, "");
 _Static_assert(__GCC_ATOMIC_LONG_LOCK_FREE == __CLANG_ATOMIC_LONG_LOCK_FREE, 
"");
-#ifdef __i386__
-_Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == 1, "");
-#else
 _Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == 2, "");
-#endif
 _Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == __CLANG_ATOMIC_LLONG_LOCK_FREE, 
"");
 _Static_assert(__GCC_ATOMIC_POINTER_LOCK_FREE == 2, "");
 _Static_assert(__GCC_ATOMIC_POINTER_LOCK_FREE == 
__CLANG_ATOMIC_POINTER_LOCK_FREE, "");
Index: clang/test/Preprocessor/init-x86.c
===
--- clang/test/Preprocessor/init-x86.c
+++ clang/test/Preprocessor/init-x86.c
@@ -185,9 +185,9 @@
 // I386:#define __i386__ 1
 // I386:#define i386 1
 
-// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=i386-pc-linux-gnu -target-cpu pentium4 < /dev/null | FileCheck 
-match-full-lines -check-prefix I386-LINUX -check-prefix I386-LINUX-ALIGN32 %s
-// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=i386-pc-linux-gnu -target-cpu pentium4 < /dev/null | FileCheck 
-match-full-lines -check-prefix I386-LINUX -check-prefix I386-LINUX-CXX 
-check-prefix I386-LINUX-ALIGN32 %s
-// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=i386-pc-linux-gnu -target-cpu pentium4 -malign-double < /dev/null | 
FileCheck -match-full-lines -check-prefix I386-LINUX -check-prefix 
I386-LINUX-ALIGN64 %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=i386-pc-linux-gnu -target-cpu i486 < /dev/null | FileCheck 
-match-full-lines -check-prefix I386-LINUX -check-prefix I386-LINUX-ALIGN32 %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=i386-pc-linux-gnu -target-cpu pentium4 < /dev/null | FileCheck 
-match-full-lines -check-prefix I386-LINUX -check-prefix I386-LINUX-ALIGN64 %s
+// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=i386-pc-linux-gnu -target-cpu pentium4 < /dev/null | FileCheck 
-match-full-lines -check-prefix I386-LINUX -check-prefix I386-LINUX-ALIGN64 
-check-prefix I386-LINUX-CXX %s
 //
 // I386-LINUX-NOT:#define _LP64
 // I386-LINUX:#define __BIGGEST_ALIGNMENT__ 16
Index: clang/lib/Frontend/InitPreprocessor.cpp
===
--- clang/lib/Frontend/InitPreprocessor.cpp
+++ clang/lib/Frontend/InitPreprocessor.cpp
@@ -298,12 +298,12 @@
 
 /// Get the value the ATOMIC_*_LOCK_FREE macro should have for a type with
 /// the specified properties.
-static const char *getLockFreeValue(unsigned TypeWidth, unsigned TypeAlign,
-unsigned InlineWidth) {
+static const char *getLockFreeValue(unsigned TypeWidth, unsigned InlineWidth) {
   // Fully-aligned, power-of-2 sizes no larger than the inline
   // width will be inlined as lock-free operations.
-  if (TypeWidth == TypeAlign && (TypeWidth & (TypeWidth - 1)) == 0 &&
-  TypeWidth <= InlineWidth)
+  // Note: we do not need to check alignment since _Atomic(T) is always
+  // appropriately-aligned in clang.
+  if ((TypeWidth & (TypeWidth - 1)) == 0 && TypeWidth <= InlineWidth)
 return "2"; // "always lock free"
   // We cannot be certain what operations the lib calls might be
   // able to implement as lock-free on future processors.
@@ -1142,7 +1142,6 @@
 #define DEFINE_LOCK_FREE_MACRO(TYPE, Type) 
\
   Builder.defineMacro(Prefix + #TYPE "_LOCK_FREE", 
\
   getLockFreeValue(TI.get##Type##Width(),  
\
-   TI.get##Type##Align(),  
\
InlineWidthBits));
 DEFINE_LOCK_FREE_MACRO(BOOL, Bool);
 DEFINE_LOCK_FREE_MACRO(CHAR, Char);
@@ -1157,7 +1156,6 @@
 DEFINE_LOCK_FREE_MACRO(LLONG, LongLong);
 Builder.defineMacro(Prefix + "POINTER_LOCK_FREE",
 getLockFreeValue(TI.getPointerWidth(0),
- TI.getPointerAlign(0),
  InlineWidthBits));
 #undef DEFINE_LOCK_FREE_MACRO
   };


Index: 

[PATCH] D127465: [CUDA] Ignore __CLANG_ATOMIC_LLONG_LOCK_FREE on i386

2022-07-21 Thread Ryan Prichard 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 rG408a2638fda6: [CUDA] Ignore __CLANG_ATOMIC_LLONG_LOCK_FREE 
on i386 (authored by rprichard).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127465

Files:
  clang/test/Preprocessor/cuda-types.cu


Index: clang/test/Preprocessor/cuda-types.cu
===
--- clang/test/Preprocessor/cuda-types.cu
+++ clang/test/Preprocessor/cuda-types.cu
@@ -1,48 +1,53 @@
-// Check that types, widths, __GCC_ATOMIC* macros, etc. match on the host and
+// Check that types, widths, __CLANG_ATOMIC* macros, etc. match on the host and
 // device sides of CUDA compilations.  Note that we filter out long double, as
 // this is intentionally different on host and device.
 //
+// Also ignore __CLANG_ATOMIC_LLONG_LOCK_FREE on i386. The default host CPU for
+// an i386 triple is typically at least an i586, which has cmpxchg8b (Clang
+// feature, "cx8"). Therefore, __CLANG_ATOMIC_LLONG_LOCK_FREE is 2 on the host,
+// but the value should be 1 for the device.
+//
 // FIXME: We really should make __GCC_HAVE_SYNC_COMPARE_AND_SWAP identical on
 // host and device, but architecturally this is difficult at the moment.
 
 // RUN: mkdir -p %t
 
 // RUN: %clang --cuda-host-only -nocudainc -target i386-unknown-linux-gnu -x 
cuda -E -dM -o - /dev/null \
-// RUN:   | grep -E 'define __[^ ]*(TYPE|MAX|SIZEOF|WIDTH)|define 
__GCC_ATOMIC' \
-// RUN:   | grep -Ev '__LDBL|_LONG_DOUBLE' > %t/i386-host-defines-filtered
+// RUN:   | grep -E 'define __[^ ]*(TYPE|MAX|SIZEOF|WIDTH)|define 
__CLANG_ATOMIC' \
+// RUN:   | grep -Ev '__LDBL|_LONG_DOUBLE|_ATOMIC_LLONG_LOCK_FREE' > 
%t/i386-host-defines-filtered
 // RUN: %clang --cuda-device-only -nocudainc -nocudalib -target 
i386-unknown-linux-gnu -x cuda -E -dM -o - /dev/null \
-// RUN:   | grep -E 'define __[^ ]*(TYPE|MAX|SIZEOF|WIDTH)|define 
__GCC_ATOMIC' \
-// RUN:   | grep -Ev '__LDBL|_LONG_DOUBLE' > %t/i386-device-defines-filtered
+// RUN:   | grep -E 'define __[^ ]*(TYPE|MAX|SIZEOF|WIDTH)|define 
__CLANG_ATOMIC' \
+// RUN:   | grep -Ev '__LDBL|_LONG_DOUBLE|_ATOMIC_LLONG_LOCK_FREE' > 
%t/i386-device-defines-filtered
 // RUN: diff %t/i386-host-defines-filtered %t/i386-device-defines-filtered
 
 // RUN: %clang --cuda-host-only -nocudainc -target x86_64-unknown-linux-gnu -x 
cuda -E -dM -o - /dev/null \
-// RUN:   | grep -E 'define __[^ ]*(TYPE|MAX|SIZEOF|WIDTH)|define 
__GCC_ATOMIC' \
+// RUN:   | grep -E 'define __[^ ]*(TYPE|MAX|SIZEOF|WIDTH)|define 
__CLANG_ATOMIC' \
 // RUN:   | grep -Ev '__LDBL|_LONG_DOUBLE' > %t/x86_64-host-defines-filtered
 // RUN: %clang --cuda-device-only -nocudainc -nocudalib -target 
x86_64-unknown-linux-gnu -x cuda -E -dM -o - /dev/null \
-// RUN:   | grep -E 'define __[^ ]*(TYPE|MAX|SIZEOF|WIDTH)|define 
__GCC_ATOMIC' \
+// RUN:   | grep -E 'define __[^ ]*(TYPE|MAX|SIZEOF|WIDTH)|define 
__CLANG_ATOMIC' \
 // RUN:   | grep -Ev '__LDBL|_LONG_DOUBLE' > %t/x86_64-device-defines-filtered
 // RUN: diff %t/x86_64-host-defines-filtered %t/x86_64-device-defines-filtered
 
 // RUN: %clang --cuda-host-only -nocudainc -target powerpc64-unknown-linux-gnu 
-x cuda -E -dM -o - /dev/null \
-// RUN:   | grep -E 'define __[^ ]*(TYPE|MAX|SIZEOF|WIDTH)|define 
__GCC_ATOMIC' \
+// RUN:   | grep -E 'define __[^ ]*(TYPE|MAX|SIZEOF|WIDTH)|define 
__CLANG_ATOMIC' \
 // RUN:   | grep -Ev '__LDBL|_LONG_DOUBLE' > %t/powerpc64-host-defines-filtered
 // RUN: %clang --cuda-device-only -nocudainc -nocudalib -target 
powerpc64-unknown-linux-gnu -x cuda -E -dM -o - /dev/null \
-// RUN:   | grep -E 'define __[^ ]*(TYPE|MAX|SIZEOF|WIDTH)|define 
__GCC_ATOMIC' \
+// RUN:   | grep -E 'define __[^ ]*(TYPE|MAX|SIZEOF|WIDTH)|define 
__CLANG_ATOMIC' \
 // RUN:   | grep -Ev '__LDBL|_LONG_DOUBLE' > 
%t/powerpc64-device-defines-filtered
 // RUN: diff %t/powerpc64-host-defines-filtered 
%t/powerpc64-device-defines-filtered
 
 // RUN: %clang --cuda-host-only -nocudainc -target i386-windows-msvc -x cuda 
-E -dM -o - /dev/null \
-// RUN:   | grep -E 'define __[^ ]*(TYPE|MAX|SIZEOF|WIDTH)|define 
__GCC_ATOMIC' \
-// RUN:   | grep -Ev '__LDBL|_LONG_DOUBLE' > %t/i386-msvc-host-defines-filtered
+// RUN:   | grep -E 'define __[^ ]*(TYPE|MAX|SIZEOF|WIDTH)|define 
__CLANG_ATOMIC' \
+// RUN:   | grep -Ev '__LDBL|_LONG_DOUBLE|_ATOMIC_LLONG_LOCK_FREE' > 
%t/i386-msvc-host-defines-filtered
 // RUN: %clang --cuda-device-only -nocudainc -nocudalib -target 
i386-windows-msvc -x cuda -E -dM -o - /dev/null \
-// RUN:   | grep -E 'define __[^ ]*(TYPE|MAX|SIZEOF|WIDTH)|define 
__GCC_ATOMIC' \
-// RUN:   | grep -Ev '__LDBL|_LONG_DOUBLE' > 
%t/i386-msvc-device-defines-filtered
+// RUN:   | grep -E 'define __[^ ]*(TYPE|MAX|SIZEOF|WIDTH)|define 
__CLANG_ATOMIC' \
+// RUN:   | grep -Ev '__LDBL|_LONG_DOUBLE|_ATOMIC_LLONG_LOCK_FREE' > 

[clang] 02a2527 - [Frontend] Correct values of ATOMIC_*_LOCK_FREE to match builtin

2022-07-21 Thread Ryan Prichard via cfe-commits

Author: Ryan Prichard
Date: 2022-07-21T17:23:29-07:00
New Revision: 02a25279aedcd959d060bba585adc0fe1cec3782

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

LOG: [Frontend] Correct values of ATOMIC_*_LOCK_FREE to match builtin

Correct the logic used to set `ATOMIC_*_LOCK_FREE` preprocessor macros not
to rely on the ABI alignment of types. Instead, just assume all those
types are aligned correctly by default since clang uses safe alignment
for `_Atomic` types even if the underlying types are aligned to a lower
boundary by default.

For example, the `long long` and `double` types on x86 are aligned to
32-bit boundary by default. However, `_Atomic long long` and `_Atomic
double` are aligned to 64-bit boundary, therefore satisfying
the requirements of lock-free atomic operations.

This fixes PR #19355 by correcting the value of
`__GCC_ATOMIC_LLONG_LOCK_FREE` on x86, and therefore also fixing
the assumption made in libc++ tests. This also fixes PR #30581 by
applying a consistent logic between the functions used to implement
both interfaces.

Reviewed By: hfinkel, efriedma

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

Added: 


Modified: 
clang/lib/Frontend/InitPreprocessor.cpp
clang/test/Preprocessor/init-x86.c
clang/test/Sema/atomic-ops.c

Removed: 




diff  --git a/clang/lib/Frontend/InitPreprocessor.cpp 
b/clang/lib/Frontend/InitPreprocessor.cpp
index 655490ba06e5d..20bfbf144a30a 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -298,12 +298,12 @@ static void DefineFastIntType(unsigned TypeWidth, bool 
IsSigned,
 
 /// Get the value the ATOMIC_*_LOCK_FREE macro should have for a type with
 /// the specified properties.
-static const char *getLockFreeValue(unsigned TypeWidth, unsigned TypeAlign,
-unsigned InlineWidth) {
+static const char *getLockFreeValue(unsigned TypeWidth, unsigned InlineWidth) {
   // Fully-aligned, power-of-2 sizes no larger than the inline
   // width will be inlined as lock-free operations.
-  if (TypeWidth == TypeAlign && (TypeWidth & (TypeWidth - 1)) == 0 &&
-  TypeWidth <= InlineWidth)
+  // Note: we do not need to check alignment since _Atomic(T) is always
+  // appropriately-aligned in clang.
+  if ((TypeWidth & (TypeWidth - 1)) == 0 && TypeWidth <= InlineWidth)
 return "2"; // "always lock free"
   // We cannot be certain what operations the lib calls might be
   // able to implement as lock-free on future processors.
@@ -1142,7 +1142,6 @@ static void InitializePredefinedMacros(const TargetInfo 
,
 #define DEFINE_LOCK_FREE_MACRO(TYPE, Type) 
\
   Builder.defineMacro(Prefix + #TYPE "_LOCK_FREE", 
\
   getLockFreeValue(TI.get##Type##Width(),  
\
-   TI.get##Type##Align(),  
\
InlineWidthBits));
 DEFINE_LOCK_FREE_MACRO(BOOL, Bool);
 DEFINE_LOCK_FREE_MACRO(CHAR, Char);
@@ -1157,7 +1156,6 @@ static void InitializePredefinedMacros(const TargetInfo 
,
 DEFINE_LOCK_FREE_MACRO(LLONG, LongLong);
 Builder.defineMacro(Prefix + "POINTER_LOCK_FREE",
 getLockFreeValue(TI.getPointerWidth(0),
- TI.getPointerAlign(0),
  InlineWidthBits));
 #undef DEFINE_LOCK_FREE_MACRO
   };

diff  --git a/clang/test/Preprocessor/init-x86.c 
b/clang/test/Preprocessor/init-x86.c
index 339941fcf3ee6..9c4e328bdf79d 100644
--- a/clang/test/Preprocessor/init-x86.c
+++ b/clang/test/Preprocessor/init-x86.c
@@ -185,9 +185,9 @@
 // I386:#define __i386__ 1
 // I386:#define i386 1
 
-// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=i386-pc-linux-gnu -target-cpu pentium4 < /dev/null | FileCheck 
-match-full-lines -check-prefix I386-LINUX -check-prefix I386-LINUX-ALIGN32 %s
-// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=i386-pc-linux-gnu -target-cpu pentium4 < /dev/null | FileCheck 
-match-full-lines -check-prefix I386-LINUX -check-prefix I386-LINUX-CXX 
-check-prefix I386-LINUX-ALIGN32 %s
-// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=i386-pc-linux-gnu -target-cpu pentium4 -malign-double < /dev/null | 
FileCheck -match-full-lines -check-prefix I386-LINUX -check-prefix 
I386-LINUX-ALIGN64 %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=i386-pc-linux-gnu -target-cpu i486 < /dev/null | FileCheck 
-match-full-lines -check-prefix I386-LINUX -check-prefix I386-LINUX-ALIGN32 %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=i386-pc-linux-gnu 

[clang] 408a263 - [CUDA] Ignore __CLANG_ATOMIC_LLONG_LOCK_FREE on i386

2022-07-21 Thread Ryan Prichard via cfe-commits

Author: Ryan Prichard
Date: 2022-07-21T17:23:29-07:00
New Revision: 408a2638fda63b381f8750e16c78bc3c845cfdfd

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

LOG: [CUDA] Ignore __CLANG_ATOMIC_LLONG_LOCK_FREE on i386

The default host CPU for an i386 triple is typically at least an i586,
which has cmpxchg8b (Clang feature, "cx8"). Therefore,
`__CLANG_ATOMIC_LLONG_LOCK_FREE` is 2 on the host, but the value should
be 1 for the device.

Also, grep for `__CLANG_ATOMIC_*` instead of `__GCC_ATOMIC_*`. The CLANG
macros are always emitted, but the GCC macros are omitted for the
*-windows-msvc targets. The `__GCC_HAVE_SYNC_COMPARE_AND_SWAP` macro
always has GCC in its name, not CLANG, however.

Reviewed By: tra

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

Added: 


Modified: 
clang/test/Preprocessor/cuda-types.cu

Removed: 




diff  --git a/clang/test/Preprocessor/cuda-types.cu 
b/clang/test/Preprocessor/cuda-types.cu
index b4de7fda147d7..0ff0d057830dc 100644
--- a/clang/test/Preprocessor/cuda-types.cu
+++ b/clang/test/Preprocessor/cuda-types.cu
@@ -1,48 +1,53 @@
-// Check that types, widths, __GCC_ATOMIC* macros, etc. match on the host and
+// Check that types, widths, __CLANG_ATOMIC* macros, etc. match on the host and
 // device sides of CUDA compilations.  Note that we filter out long double, as
 // this is intentionally 
diff erent on host and device.
 //
+// Also ignore __CLANG_ATOMIC_LLONG_LOCK_FREE on i386. The default host CPU for
+// an i386 triple is typically at least an i586, which has cmpxchg8b (Clang
+// feature, "cx8"). Therefore, __CLANG_ATOMIC_LLONG_LOCK_FREE is 2 on the host,
+// but the value should be 1 for the device.
+//
 // FIXME: We really should make __GCC_HAVE_SYNC_COMPARE_AND_SWAP identical on
 // host and device, but architecturally this is 
diff icult at the moment.
 
 // RUN: mkdir -p %t
 
 // RUN: %clang --cuda-host-only -nocudainc -target i386-unknown-linux-gnu -x 
cuda -E -dM -o - /dev/null \
-// RUN:   | grep -E 'define __[^ ]*(TYPE|MAX|SIZEOF|WIDTH)|define 
__GCC_ATOMIC' \
-// RUN:   | grep -Ev '__LDBL|_LONG_DOUBLE' > %t/i386-host-defines-filtered
+// RUN:   | grep -E 'define __[^ ]*(TYPE|MAX|SIZEOF|WIDTH)|define 
__CLANG_ATOMIC' \
+// RUN:   | grep -Ev '__LDBL|_LONG_DOUBLE|_ATOMIC_LLONG_LOCK_FREE' > 
%t/i386-host-defines-filtered
 // RUN: %clang --cuda-device-only -nocudainc -nocudalib -target 
i386-unknown-linux-gnu -x cuda -E -dM -o - /dev/null \
-// RUN:   | grep -E 'define __[^ ]*(TYPE|MAX|SIZEOF|WIDTH)|define 
__GCC_ATOMIC' \
-// RUN:   | grep -Ev '__LDBL|_LONG_DOUBLE' > %t/i386-device-defines-filtered
+// RUN:   | grep -E 'define __[^ ]*(TYPE|MAX|SIZEOF|WIDTH)|define 
__CLANG_ATOMIC' \
+// RUN:   | grep -Ev '__LDBL|_LONG_DOUBLE|_ATOMIC_LLONG_LOCK_FREE' > 
%t/i386-device-defines-filtered
 // RUN: 
diff  %t/i386-host-defines-filtered %t/i386-device-defines-filtered
 
 // RUN: %clang --cuda-host-only -nocudainc -target x86_64-unknown-linux-gnu -x 
cuda -E -dM -o - /dev/null \
-// RUN:   | grep -E 'define __[^ ]*(TYPE|MAX|SIZEOF|WIDTH)|define 
__GCC_ATOMIC' \
+// RUN:   | grep -E 'define __[^ ]*(TYPE|MAX|SIZEOF|WIDTH)|define 
__CLANG_ATOMIC' \
 // RUN:   | grep -Ev '__LDBL|_LONG_DOUBLE' > %t/x86_64-host-defines-filtered
 // RUN: %clang --cuda-device-only -nocudainc -nocudalib -target 
x86_64-unknown-linux-gnu -x cuda -E -dM -o - /dev/null \
-// RUN:   | grep -E 'define __[^ ]*(TYPE|MAX|SIZEOF|WIDTH)|define 
__GCC_ATOMIC' \
+// RUN:   | grep -E 'define __[^ ]*(TYPE|MAX|SIZEOF|WIDTH)|define 
__CLANG_ATOMIC' \
 // RUN:   | grep -Ev '__LDBL|_LONG_DOUBLE' > %t/x86_64-device-defines-filtered
 // RUN: 
diff  %t/x86_64-host-defines-filtered %t/x86_64-device-defines-filtered
 
 // RUN: %clang --cuda-host-only -nocudainc -target powerpc64-unknown-linux-gnu 
-x cuda -E -dM -o - /dev/null \
-// RUN:   | grep -E 'define __[^ ]*(TYPE|MAX|SIZEOF|WIDTH)|define 
__GCC_ATOMIC' \
+// RUN:   | grep -E 'define __[^ ]*(TYPE|MAX|SIZEOF|WIDTH)|define 
__CLANG_ATOMIC' \
 // RUN:   | grep -Ev '__LDBL|_LONG_DOUBLE' > %t/powerpc64-host-defines-filtered
 // RUN: %clang --cuda-device-only -nocudainc -nocudalib -target 
powerpc64-unknown-linux-gnu -x cuda -E -dM -o - /dev/null \
-// RUN:   | grep -E 'define __[^ ]*(TYPE|MAX|SIZEOF|WIDTH)|define 
__GCC_ATOMIC' \
+// RUN:   | grep -E 'define __[^ ]*(TYPE|MAX|SIZEOF|WIDTH)|define 
__CLANG_ATOMIC' \
 // RUN:   | grep -Ev '__LDBL|_LONG_DOUBLE' > 
%t/powerpc64-device-defines-filtered
 // RUN: 
diff  %t/powerpc64-host-defines-filtered %t/powerpc64-device-defines-filtered
 
 // RUN: %clang --cuda-host-only -nocudainc -target i386-windows-msvc -x cuda 
-E -dM -o - /dev/null \
-// RUN:   | grep -E 'define __[^ ]*(TYPE|MAX|SIZEOF|WIDTH)|define 
__GCC_ATOMIC' \
-// RUN:   | grep -Ev '__LDBL|_LONG_DOUBLE' > 

[PATCH] D129573: [clang] add a diagnostic note 'while loop outside functions' at global scope

2022-07-21 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added inline comments.



Comment at: clang/test/Parser/while-loop-outside-function.c:4
+// basic
+while(1) {}; // expected-error {{while loop outside of a function}}
+

What I meant is something like this, we test that the error caret would be 
placed on the while keyword.
You have to break it down like this as you can't express in the verifier where 
an error would occur inside a line.



Comment at: clang/test/Parser/while-loop-outside-function.c:22
+// recovery
+void some_fn();
+

To demonstrate recovery, I think it would make sense to try to use this 
declaration later, and test that it would work.
Ie you can try to 'overload' on the return type and see that you get the 
expected error.


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

https://reviews.llvm.org/D129573

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


[PATCH] D129401: [libLTO] Set data-sections by default in libLTO.

2022-07-21 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.

There are some nits for tests. I'll step away and just LGTM.




Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:579
+  else if (Args.hasArg(options::OPT_fno_data_sections))
+CmdArgs.push_back("-plugin-opt=-data-sections=0");
 

Is -plugin-opt=-data-sections=0 a problem for `!UseSeparateSections` targets?



Comment at: clang/test/Driver/forwarding-sections-liblto.c:1
+// RUN: touch %t.o
+// RUN: %clang --target=x86_64-unknown-linux -### %t.o -flto 2>&1 | FileCheck 
%s

You may just place these tests into function-sections.c. It seems fine to 
additionally test data-sections in the file.

(Even if a new test is needed, I'd avoid `-liblto` and use `-lto` instead`. But 
the extra file seems too specific. The test can well be placed in an existing 
file.)



Comment at: clang/test/Driver/forwarding-sections-liblto.c:2
+// RUN: touch %t.o
+// RUN: %clang --target=x86_64-unknown-linux -### %t.o -flto 2>&1 | FileCheck 
%s
+// RUN: %clang --target=x86_64-unknown-linux -### %t.o -flto 2>&1 \

Instead of `touch %t.o`, just use `%s`



Comment at: clang/test/Driver/forwarding-sections-liblto.c:10
+
+// CHECK-NOT: "-plugin-opt=-function-sections=1"
+// CHECK-NOT: "-plugin-opt=-function-sections=0"

Just use `// CHECK-NOT: "-plugin-opt=-function-sections`. No need to duplicate 
it for 0 and 1.

Ditto for data-sections



Comment at: llvm/test/LTO/PowerPC/data-sections-linux.ll:20
+
+; CHECK-NO-DATA-SECTIONS-NOT: .var
+; CHECK-NO-DATA-SECTIONS:  g O .bss {{.*}} var

What does this `...-NOT: .var` do?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129401

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


[PATCH] D128927: [libc++] Always build c++experimental.a

2022-07-21 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

In D128927#3665748 , @hans wrote:

> In D128927#3662659 , @ldionne wrote:
>
>> The weird part here is that you're configuring libc++, but you are building 
>> neither the static nor the shared library. I don't understand why you do 
>> that, and that may hide some other more fundamental issue in your setup.
>
> Yes, I wish we weren't weird.
> The reason libc++ is part of our build is that we want the headers so that 
> our newly built Clang will be able to build c++ files. 
> https://bugs.chromium.org/p/chromium/issues/detail?id=1067216#c7 has the 
> background for our current situation.
>
> In https://github.com/llvm/llvm-zorg/pull/28 you mentioned that "for a couple 
> of years now, Clang and libc++ are entirely separate projects w.r.t. how they 
> are shipped on Apple platforms, and it doesn't make sense to build libc++ at 
> the same time as Clang anymore".
> Does that mean the libc++ headers have moved to the SDK now, and if so from 
> what version? If it's in the SDK version we use (I'd have to check), perhaps 
> that would allow us to stop building like this.

Yes, the libc++ headers are in the SDK. They have been since Xcode 12 if I'm 
not mistaken. They are *also* still shipped in the Clang toolchain, but that 
will change eventually -- there are a few things blocking us from doing that, 
but they will go away eventually.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128927

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


[PATCH] D126731: [pseudo] Eliminate dependencies from clang-pseudo-gen. NFC

2022-07-21 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Looks like this breaks a modular build. I.e.,

  cmake -GNinja ~/Projects/llvm/llvm-project/llvm \
-DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra" \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DLLVM_ENABLE_MODULES=ON
  ninja clangPseudoGrammar

fails with

  While building module 'Clang_Basic' imported from 
/Users/vsapsai/Projects/llvm/llvm-project/clang-tools-extra/pseudo/include/clang-pseudo/grammar/Grammar.h:55:
  In file included from :4:
  
/Users/vsapsai/Projects/llvm/llvm-project/clang/include/clang/Basic/AttrKinds.h:27:10:
 fatal error: 'clang/Basic/AttrList.inc' file not found
  #include "clang/Basic/AttrList.inc"
   ^~
  While building module 'Clang_Basic' imported from 
/Users/vsapsai/Projects/llvm/llvm-project/clang-tools-extra/pseudo/include/clang-pseudo/grammar/Grammar.h:55:
  While building module 'LLVM_Frontend_OpenMP' imported from 
/Users/vsapsai/Projects/llvm/llvm-project/clang/include/clang/Basic/TargetInfo.h:34:
  In file included from :2:
  
/Users/vsapsai/Projects/llvm/llvm-project/llvm/include/llvm/Frontend/OpenMP/OMPConstants.h:20:10:
 fatal error: 'llvm/Frontend/OpenMP/OMP.h.inc' file not found
  #include "llvm/Frontend/OpenMP/OMP.h.inc"
   ^~~~
  In file included from 
/Users/vsapsai/Projects/llvm/llvm-project/clang-tools-extra/pseudo/lib/grammar/LRGraph.cpp:9:
  In file included from 
/Users/vsapsai/Projects/llvm/llvm-project/clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRGraph.h:34:
  
/Users/vsapsai/Projects/llvm/llvm-project/clang-tools-extra/pseudo/include/clang-pseudo/grammar/Grammar.h:55:10:
 fatal error: could not build module 'Clang_Basic'
  #include "clang/Basic/TokenKinds.h"
   ^~
  3 errors generated.

My understanding is that the module 'Clang_Basic' needs .inc headers and this 
module is pulled in by `#include "clang/Basic/TokenKinds.h"` at 
"clang-tools-extra/pseudo/include/clang-pseudo/grammar/Grammar.h:55". When 
those .inc headers aren't generated, the build fails. Don't know what would be 
the best way to fix the issue, I was able to fix the build by commenting out 
`list(REMOVE_ITEM LLVM_COMMON_DEPENDS clang-tablegen-targets)` in 
"lib/grammar/CMakeLists.txt".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126731

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


[PATCH] D130306: [clang][dataflow] Analyze calls to in-TU functions

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

There are many ways to introduce context sensitivity into the framework, this 
patch seems to take the "inline substitution" approach, the same approach the 
Clang Static Analyzer is taking. While this approach is relatively easy to 
implement and has great precision, it also has some scalability problems. Did 
you also consider a summary-based approach? In general, I believe the inline 
substitution approach results in an easier to use interface for the users of 
the framework, but I am a bit concerned about the scalability problems.

Some other related questions:

- Why call noop analysis? As far as I understand, this would only update the 
environment but not the lattice of the current analysis, i.e., if the analysis 
is computing some information like liveness, that information would not be 
context sensitive. Do I miss something?
- Why limit the call depth to 1? The patch mentions recursive functions. In 
case of the Clang Static Analyzer, the call depth is 4. I think if we go with 
the inline substitution approach, we want this parameter to be tunable, because 
different analyses might have different sweet spots for the call stack depth.
- The CSA also has other tunables, e.g., small functions are always inlined and 
large functions are never inlined.
- Currently, it looks like the framework assumes functions that cannot be 
inlined are not doing anything. This is an unsound assumption, and I wonder if 
we should change that before we try to settle on the best values for the 
tunable parameters.
- The current code might do a bit too much work. E.g. consider:

  while (...) {
inlinableCall();
  }

As far as I understand, the current approach would start the analysis of 
`inlinableCall` from scratch in each iteration. I wonder if we actually want to 
preserve the state between the iterations, so we do not always reevaluate the 
call from scratch. Currently, it might not be a big deal as the fixed-point 
iteration part is disabled. But this could be a perf problem in the future, 
unless I miss something.

- I think the environment currently is not really up to context-sensitive 
evaluation. Consider a recursive function:

  void f(int a) {
++a;
if (a < 10)
f(a);
  }

Here, when the recursive call is evaluated, it is ambiguous what `a` refers to. 
Is it the argument of the caller or the callee? To solve this ambiguity, the 
calling context needs to be the part of the values in the environment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130306

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


[PATCH] D130305: [clang][dataflow] Refactor ApplyBuiltinTransfer field out into DataflowAnalysisOptions struct

2022-07-21 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h:66
   explicit DataflowAnalysis(ASTContext ) : Context(Context) {}
   explicit DataflowAnalysis(ASTContext , bool ApplyBuiltinTransfer)
   : TypeErasedDataflowAnalysis(ApplyBuiltinTransfer), Context(Context) {}

Will you remove this bool overload in a later patch?



Comment at: 
clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h:38
+  // analysis).
+  bool ApplyBuiltinTransfer;
+};

xazax.hun wrote:
> I think it might be better to have a default value.
+1, uninitialized data is tricky to handle -- especially if we add more options 
in future.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130305

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


[PATCH] D129048: Rewording the "static_assert" to static assertion

2022-07-21 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

The libc++ CI runs pre-commit only, and it runs on all commits that touch 
something under `libcxx/`, `libcxxabi/`, `runtimes/` and `libunwind/`. In 
particular, it won't trigger if you make changes to `clang/` only -- that would 
create too much traffic and concretely it wouldn't help much, as we're rarely 
broken by Clang changes (this is an exception). Once the tests under `libcxx/` 
were touched, the libc++ CI triggered, I found this build for instance: 
https://buildkite.com/llvm-project/libcxx-ci/builds/12210. I do think it boils 
down to familiarity -- while the Clang pre-commit CI is sometimes overlooked 
because it fails spuriously, the libc++ CI usually doesn't, so when it fails, 
there's usually a good reason. I do understand why someone mostly familiar with 
the Clang workflow could think they needed to be overlooked, though.

Concretely, libc++ supports the two latest releases of Clang, and so the CI 
tests against those. In fact, we run most of the tests using pre-installed 
Clangs since it allows us to bypass building Clang itself, which is a necessary 
optimization in the current setup. Regarding the tests themselves, I am able to 
find the following kind of output in the CI job that failed:

  FAIL: llvm-libc++-shared.cfg.in :: std/numerics/numbers/illformed.verify.cpp 
(4388 of 7532)
  [...]
  error: 'error' diagnostics expected but not seen:
File 
/home/libcxx-builder/.buildkite-agent/builds/2b1c77dd9e90-1/llvm-project/libcxx-ci/build/generic-cxx2b/include/c++/v1/numbers
 Line * (directive at 
/home/libcxx-builder/.buildkite-agent/builds/2b1c77dd9e90-1/llvm-project/libcxx-ci/libcxx/test/std/numerics/numbers/illformed.verify.cpp:15):
 static assertion failed{{.*}}A program that instantiates a primary template of 
a mathematical constant variable template is ill-formed.
  error: 'error' diagnostics seen but not expected:
File 
/home/libcxx-builder/.buildkite-agent/builds/2b1c77dd9e90-1/llvm-project/libcxx-ci/build/generic-cxx2b/include/c++/v1/numbers
 Line 83: static_assert failed due to requirement '__false' "A program 
that instantiates a primary template of a mathematical constant variable 
template is ill-formed."
  2 errors generated.
   

IMO this is reasonable output, in fact it's pretty much as good as we could 
have had. So I'm not taking any action item regarding improving the output of 
our CI, but I'm entirely open to suggestions if somebody has some.

In D129048#3669568 , @aaron.ballman 
wrote:

> At a high-level, I think it boils down to familiarity. If we can get the 
> libc++ CI to run as part of precommit CI (assuming precommit CI can be made 
> to run with reliable results, which is a bit of a question mark),

It is pretty reliable. However, I don't think it'll ever become reasonable to 
run the full libc++ CI on every Clang patch due to resource limitations.

> It would have also helped to catch the cause for the initial revert where 
> everyone thought the patch was ready to land.

100% agreed, however this is blocked on the resource limitations mentioned 
above. I guess one thing we could do here is trigger a simple bootstrapping 
build of Clang and run the libc++ tests in a single configuration even on 
changes to `clang/`. That might catch most issues and perhaps that would be 
small enough to be scalable. I'll experiment with that after the release.

> Another thing that would help would be to get the libc++ test bots into the 
> LLVM lab (https://lab.llvm.org/buildbot/#/builders)

Libc++ CI is pre-commit, the lab is post-commit only AFAICT. I also don't know 
whether there's a way to bridge between BuildKite and BuildBot, and what that 
would look like. So while I share the desire to have a single place to look for 
all LLVM wide CI, I'm not sure it is possible given the variety of technologies 
used.

> and ensure that they're sending failure emails to everyone on the blame list 
> including people who land a patch on behalf of others.

100% agreed here -- this is one problem with our current setup.

> It looks like we have one builder for libc++, but it doesn't appear to be 
> working recently: https://lab.llvm.org/buildbot/#/builders/156.

Yeah, this one needs to be removed, it's a remnant of when we used to have 
libc++ CI on BuildBot.

Okay, so to summarize:

1. I'll experiment with a simple job that runs the libc++ pre-commit CI on 
every patch to Clang. We'll see if that scales.
2. I'll look into sending blame emails from the ongoing (every 3h) job that 
runs the whole libc++ CI. This is basically equivalent to the buildbot 
functionality and it's arguably something that we're missing here. I have no 
idea how to do that, though, but it must be possible.
3. Usually, for these types of failures, we actually notice and fix it on our 
end without requesting a revert. For this kind of change, my opinion is that 
the burden of fixing the code should have been on us, kind of like when the 

[PATCH] D130305: [clang][dataflow] Refactor ApplyBuiltinTransfer field out into DataflowAnalysisOptions struct

2022-07-21 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: 
clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h:38
+  // analysis).
+  bool ApplyBuiltinTransfer;
+};

I think it might be better to have a default value.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130305

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


[PATCH] D130303: Handle template parameter-dependent bit field widths in libclang

2022-07-21 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Dmitri, do you know a good libclang point of contact for the new API?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130303

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


[PATCH] D130308: WIP: [clang] extend getCommonSugaredType to merge sugar nodes

2022-07-21 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added inline comments.



Comment at: clang/lib/AST/ASTContext.cpp:12670
+  return QualType();
+// FIXME: The modified types can be different as well.
+// FIXME: It's inneficient to have to unify the modified types.

rsmith wrote:
> Should we bail out if this happens, as we do in the other cases above?
I think this means what we are trying to merge is unrelated, so yes. I just 
didn't come up with a test case yet :)



Comment at: clang/lib/AST/ASTContext.cpp:12695-12696
+if (CD)
+  As = getCommonTemplateArguments(Ctx, AX->getTypeConstraintArguments(),
+  AY->getTypeConstraintArguments());
+return Ctx.getAutoType(Underlying, AX->getKeyword(),

rsmith wrote:
> These template arguments might in general be unrelated. Is that a problem 
> here? Eg:
> 
> ```
> template typename Predicate> concept satisfies 
> = Predicate::value;
> auto f(bool c) {
>   satisfies auto x = 0;
>   satisfies auto y = 0;
>   // Common sugar here should presumably be "unconstrained auto deduced as 
> `int`".
>   return c ? x : y;
> }
> ```
Right, yes, we should bail out in that case as well I think.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130308

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


[PATCH] D130308: WIP: [clang] extend getCommonSugaredType to merge sugar nodes

2022-07-21 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/AST/ASTContext.cpp:12654
+  return QualType();
+// FIXME: It's inneficient to have to unify the original types.
+return Ctx.getAdjustedType(Ctx.getCommonSugaredType(OX, OY), Underlying);

Typo "inefficient" (multiple instances)



Comment at: clang/lib/AST/ASTContext.cpp:12670
+  return QualType();
+// FIXME: The modified types can be different as well.
+// FIXME: It's inneficient to have to unify the modified types.

Should we bail out if this happens, as we do in the other cases above?



Comment at: clang/lib/AST/ASTContext.cpp:12695-12696
+if (CD)
+  As = getCommonTemplateArguments(Ctx, AX->getTypeConstraintArguments(),
+  AY->getTypeConstraintArguments());
+return Ctx.getAutoType(Underlying, AX->getKeyword(),

These template arguments might in general be unrelated. Is that a problem here? 
Eg:

```
template typename Predicate> concept satisfies = 
Predicate::value;
auto f(bool c) {
  satisfies auto x = 0;
  satisfies auto y = 0;
  // Common sugar here should presumably be "unconstrained auto deduced as 
`int`".
  return c ? x : y;
}
```



Comment at: clang/lib/AST/ASTContext.cpp:12698-12699
+return Ctx.getAutoType(Underlying, AX->getKeyword(),
+   AX->isInstantiationDependentType(),
+   AX->containsUnexpandedParameterPack(), CD, As);
+  }

Instantiation-dependence and "contains unexpanded parameter pack" can depend on 
which sugar we choose to preserve. I think you strictly-speaking would need to 
recompute these based on the sugar we end up with rather than inheriting them 
from `AX`.



Comment at: clang/lib/AST/ASTContext.cpp:12767-12769
+if (!declaresSameEntity(DX, DY))
+  return QualType();
+return Ctx.getUsingType(::getCommonDecl(DX, DY), Underlying);

Can avoid a repeated check here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130308

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


[PATCH] D130311: [RISCV] Enable strict FP in clang as long as Zve* or V are not enabled.

2022-07-21 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:933
+  if (!Subtarget.hasVInstructions())
+IsStrictFPEnabled = true;
+

Setting this to true disables some code in SelectionDAGISel.cpp that make 
ISD::STRICT_* nodes compile even if the target hasn't done the work.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130311

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


[PATCH] D130311: [RISCV] Enable strict FP in clang as long as Zve* or V are not enabled.

2022-07-21 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/test/CodeGen/builtin_float_strictfp.c:3
 // RUN: %clang_cc1 -no-opaque-pointers -emit-llvm -triple ppc64-be 
-ffp-exception-behavior=maytrap -o - %s | FileCheck %s 
--check-prefixes=CHECK,NOFP16
+// RUN: %clang_cc1 -no-opaque-pointers -emit-llvm -triple riscv64 
-ffp-exception-behavior=maytrap -o - %s | FileCheck %s 
--check-prefixes=CHECK,FP16
 

I just picked a test to have some coverage that the strict FP is enabled. Most 
strict FP tests use `-Xclang -fexperimental-strict-floating-point` to avoid 
needing a specific target.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130311

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


[PATCH] D130311: [RISCV] Enable strict FP in clang as long as Zve* or V are not enabled.

2022-07-21 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.
craig.topper added reviewers: reames, asb, luismarques, arcbbb, frasercrmck, 
kito-cheng.
Herald added subscribers: sunshaoce, VincentWu, luke957, StephenFan, vkmr, 
evandro, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, 
the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, 
shiva0217, niosHD, sabuasal, simoncook, johnrusso, rbar, hiraditya, arichardson.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added subscribers: pcwang-thead, eopXD, MaskRay.
Herald added projects: clang, LLVM.

As far as I know, scalar support for strict FP in the backend is
complete. Unfortunately, vector is missing.

This patch enables strict FP support as long as there's no chance
of any vector code. This isn't ideal, but it's a start.

Given the proximity to the LLVM 15 branch, I don't intend to commit this
until after that if this is approved.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130311

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Basic/Targets/RISCV.h
  clang/test/CodeGen/builtin_float_strictfp.c
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp


Index: llvm/lib/Target/RISCV/RISCVISelLowering.cpp
===
--- llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -928,6 +928,10 @@
 }
   }
 
+  // FIXME: Strict FP support is incomplete for vectors.
+  if (!Subtarget.hasVInstructions())
+IsStrictFPEnabled = true;
+
   // Function alignments.
   const Align FunctionAlignment(Subtarget.hasStdExtC() ? 2 : 4);
   setMinFunctionAlignment(FunctionAlignment);
Index: clang/test/CodeGen/builtin_float_strictfp.c
===
--- clang/test/CodeGen/builtin_float_strictfp.c
+++ clang/test/CodeGen/builtin_float_strictfp.c
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -no-opaque-pointers -emit-llvm -triple x86_64-windows-pc 
-ffp-exception-behavior=maytrap -o - %s | FileCheck %s 
--check-prefixes=CHECK,FP16
 // RUN: %clang_cc1 -no-opaque-pointers -emit-llvm -triple ppc64-be 
-ffp-exception-behavior=maytrap -o - %s | FileCheck %s 
--check-prefixes=CHECK,NOFP16
+// RUN: %clang_cc1 -no-opaque-pointers -emit-llvm -triple riscv64 
-ffp-exception-behavior=maytrap -o - %s | FileCheck %s 
--check-prefixes=CHECK,FP16
 
 // test to ensure that these builtins don't do the variadic promotion of 
float->double.
 
Index: clang/lib/Basic/Targets/RISCV.h
===
--- clang/lib/Basic/Targets/RISCV.h
+++ clang/lib/Basic/Targets/RISCV.h
@@ -41,6 +41,7 @@
 HasRISCVVTypes = true;
 MCountName = "_mcount";
 HasFloat16 = true;
+HasStrictFP = true;
   }
 
   bool setCPU(const std::string ) override {
Index: clang/lib/Basic/Targets/RISCV.cpp
===
--- clang/lib/Basic/Targets/RISCV.cpp
+++ clang/lib/Basic/Targets/RISCV.cpp
@@ -282,6 +282,10 @@
   if (ABI.empty())
 ABI = ISAInfo->computeDefaultABI().str();
 
+  // StrictFP support for vectors is incomplete.
+  if (ISAInfo->hasExtension("zve32x"))
+HasStrictFP = false;
+
   return true;
 }
 


Index: llvm/lib/Target/RISCV/RISCVISelLowering.cpp
===
--- llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -928,6 +928,10 @@
 }
   }
 
+  // FIXME: Strict FP support is incomplete for vectors.
+  if (!Subtarget.hasVInstructions())
+IsStrictFPEnabled = true;
+
   // Function alignments.
   const Align FunctionAlignment(Subtarget.hasStdExtC() ? 2 : 4);
   setMinFunctionAlignment(FunctionAlignment);
Index: clang/test/CodeGen/builtin_float_strictfp.c
===
--- clang/test/CodeGen/builtin_float_strictfp.c
+++ clang/test/CodeGen/builtin_float_strictfp.c
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -no-opaque-pointers -emit-llvm -triple x86_64-windows-pc -ffp-exception-behavior=maytrap -o - %s | FileCheck %s --check-prefixes=CHECK,FP16
 // RUN: %clang_cc1 -no-opaque-pointers -emit-llvm -triple ppc64-be -ffp-exception-behavior=maytrap -o - %s | FileCheck %s --check-prefixes=CHECK,NOFP16
+// RUN: %clang_cc1 -no-opaque-pointers -emit-llvm -triple riscv64 -ffp-exception-behavior=maytrap -o - %s | FileCheck %s --check-prefixes=CHECK,FP16
 
 // test to ensure that these builtins don't do the variadic promotion of float->double.
 
Index: clang/lib/Basic/Targets/RISCV.h
===
--- clang/lib/Basic/Targets/RISCV.h
+++ clang/lib/Basic/Targets/RISCV.h
@@ -41,6 +41,7 @@
 HasRISCVVTypes = true;
 MCountName = "_mcount";
 HasFloat16 = true;
+HasStrictFP = true;
   }
 
   bool setCPU(const std::string ) override {
Index: clang/lib/Basic/Targets/RISCV.cpp

[PATCH] D130308: WIP: [clang] extend getCommonSugaredType to merge sugar nodes

2022-07-21 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 446644.
mizvekov planned changes to this revision.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130308

Files:
  clang/include/clang/AST/ASTContext.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/SemaCXX/sugar-common-types.cpp

Index: clang/test/SemaCXX/sugar-common-types.cpp
===
--- clang/test/SemaCXX/sugar-common-types.cpp
+++ clang/test/SemaCXX/sugar-common-types.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++20 -fenable-matrix
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++20 -fenable-matrix -triple i686-pc-win32
 
 enum class N {};
 
@@ -38,3 +38,61 @@
 N t7 = X4() + Y4(); // expected-error {{rvalue of type 'B4'}}
 N t8 = X4() * Y4(); // expected-error {{rvalue of type 'B4'}}
 N t9 = X5() * Y5(); // expected-error {{rvalue of type 'A4 __attribute__((matrix_type(3, 3)))'}}
+
+template  struct S1 {
+  template  struct S2 {};
+};
+
+N t10 = 0 ? S1() : S1(); // expected-error {{from 'S1' (aka 'S1')}}
+N t11 = 0 ? S1::S2() : S1::S2(); // expected-error {{from 'S1::S2' (aka 'S2')}}
+
+template  using Al = S1;
+
+N t12 = 0 ? Al() : Al(); // expected-error {{from 'Al' (aka 'S1')}}
+
+#define AS1 __attribute__((address_space(1)))
+#define AS2 __attribute__((address_space(1)))
+using AS1X1 = AS1 B1;
+using AS1Y1 = AS1 B1;
+using AS2Y1 = AS2 B1;
+N t13 = 0 ? (AS1X1){} : (AS1Y1){}; // expected-error {{rvalue of type 'AS1 B1' (aka '__attribute__((address_space(1))) int')}}
+N t14 = 0 ? (AS1X1){} : (AS2Y1){}; // expected-error {{rvalue of type '__attribute__((address_space(1))) B1' (aka '__attribute__((address_space(1))) int')}}
+
+using FX1 = X1 ();
+using FY1 = Y1 ();
+N t15 = 0 ? (FX1*){} : (FY1*){}; // expected-error {{rvalue of type 'B1 (*)()' (aka 'int (*)()')}}
+
+struct SS1 {};
+using SB1 = SS1;
+using SX1 = SB1;
+using SY1 = SB1;
+
+using MFX1 = X1 SX1::*();
+using MFY1 = Y1 SY1::*();
+
+N t16 = 0 ? (MFX1*){} : (MFY1*){}; // expected-error {{rvalue of type 'B1 SB1::*(*)()'}}
+
+N t17 = 0 ? (FX1 SX1::*){} : (FY1 SY1::*){}; // expected-error {{rvalue of type 'B1 (SB1::*)() __attribute__((thiscall))'}}
+
+N t18 = 0 ? (__typeof(X1*)){} : (__typeof(Y1*)){}; // expected-error {{rvalue of type 'typeof(B1 *)' (aka 'int *')}}
+
+struct Enums {
+  enum X : B1;
+  enum Y : ::B1;
+};
+using EnumsB = Enums;
+using EnumsX = EnumsB;
+using EnumsY = EnumsB;
+
+N t19 = 0 ? (__underlying_type(EnumsX::X)){} : (__underlying_type(EnumsY::Y)){};
+// expected-error@-1 {{rvalue of type 'B1' (aka 'int')}}
+
+N t20 = 0 ? (__underlying_type(EnumsX::X)){} : (__underlying_type(EnumsY::X)){};
+// expected-error@-1 {{rvalue of type '__underlying_type(Enums::X)' (aka 'int')}}
+
+using SBTF1 = SS1 [[clang::btf_type_tag("1")]];
+using SBTF2 = ::SS1 [[clang::btf_type_tag("1")]];
+using SBTF3 = ::SS1 [[clang::btf_type_tag("2")]];
+
+N t21 = 0 ? (SBTF1){} : (SBTF3){}; // expected-error {{from 'SS1'}}
+N t22 = 0 ? (SBTF1){} : (SBTF2){}; // expected-error {{from 'SS1 btf_type_tag(1)' (aka 'SS1')}}
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -3776,13 +3776,11 @@
 //   - If A is an array type, the pointer type produced by the
 // array-to-pointer standard conversion (4.2) is used in place of
 // A for type deduction; otherwise,
-if (ArgType->isArrayType())
-  ArgType = S.Context.getArrayDecayedType(ArgType);
 //   - If A is a function type, the pointer type produced by the
 // function-to-pointer standard conversion (4.3) is used in place
 // of A for type deduction; otherwise,
-else if (ArgType->isFunctionType())
-  ArgType = S.Context.getPointerType(ArgType);
+if (ArgType->canDecayToPointerType())
+  ArgType = S.Context.getDecayedType(ArgType);
 else {
   // - If A is a cv-qualified type, the top level cv-qualifiers of A's
   //   type are ignored for type deduction.
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -3329,6 +3329,26 @@
   return QualType(AT, 0);
 }
 
+QualType ASTContext::getDecayedType(QualType T, QualType Decayed) const {
+  llvm::FoldingSetNodeID ID;
+  AdjustedType::Profile(ID, T, Decayed);
+  void *InsertPos = nullptr;
+  AdjustedType *AT = AdjustedTypes.FindNodeOrInsertPos(ID, InsertPos);
+  if (AT)
+return QualType(AT, 0);
+
+  QualType Canonical = getCanonicalType(Decayed);
+
+  // Get the new insert position for the node we care about.
+  AT = AdjustedTypes.FindNodeOrInsertPos(ID, InsertPos);
+  assert(!AT && "Shouldn't be in the map!");
+
+  AT = new (*this, TypeAlignment) DecayedType(T, Decayed, 

[PATCH] D130308: WIP: [clang] extend getCommonSugaredType to merge sugar nodes

2022-07-21 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov created this revision.
Herald added projects: clang, All.
Herald added a subscriber: cfe-commits.
mizvekov requested review of this revision.

Depends on D128095 

Signed-off-by: Matheus Izvekov 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130308

Files:
  clang/include/clang/AST/ASTContext.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/SemaCXX/sugar-common-types.cpp

Index: clang/test/SemaCXX/sugar-common-types.cpp
===
--- clang/test/SemaCXX/sugar-common-types.cpp
+++ clang/test/SemaCXX/sugar-common-types.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++20 -fenable-matrix
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++20 -fenable-matrix -triple i686-pc-win32
 
 enum class N {};
 
@@ -38,3 +38,61 @@
 N t7 = X4() + Y4(); // expected-error {{rvalue of type 'B4'}}
 N t8 = X4() * Y4(); // expected-error {{rvalue of type 'B4'}}
 N t9 = X5() * Y5(); // expected-error {{rvalue of type 'A4 __attribute__((matrix_type(3, 3)))'}}
+
+template  struct S1 {
+  template  struct S2 {};
+};
+
+N t10 = 0 ? S1() : S1(); // expected-error {{from 'S1' (aka 'S1')}}
+N t11 = 0 ? S1::S2() : S1::S2(); // expected-error {{from 'S1::S2' (aka 'S2')}}
+
+template  using Al = S1;
+
+N t12 = 0 ? Al() : Al(); // expected-error {{from 'Al' (aka 'S1')}}
+
+#define AS1 __attribute__((address_space(1)))
+#define AS2 __attribute__((address_space(1)))
+using AS1X1 = AS1 B1;
+using AS1Y1 = AS1 B1;
+using AS2Y1 = AS2 B1;
+N t13 = 0 ? (AS1X1){} : (AS1Y1){}; // expected-error {{rvalue of type 'AS1 B1' (aka '__attribute__((address_space(1))) int')}}
+N t14 = 0 ? (AS1X1){} : (AS2Y1){}; // expected-error {{rvalue of type '__attribute__((address_space(1))) B1' (aka '__attribute__((address_space(1))) int')}}
+
+using FX1 = X1 ();
+using FY1 = Y1 ();
+N t15 = 0 ? (FX1*){} : (FY1*){}; // expected-error {{rvalue of type 'B1 (*)()' (aka 'int (*)()')}}
+
+struct SS1 {};
+using SB1 = SS1;
+using SX1 = SB1;
+using SY1 = SB1;
+
+using MFX1 = X1 SX1::*();
+using MFY1 = Y1 SY1::*();
+
+N t16 = 0 ? (MFX1*){} : (MFY1*){}; // expected-error {{rvalue of type 'B1 SB1::*(*)()'}}
+
+N t17 = 0 ? (FX1 SX1::*){} : (FY1 SY1::*){}; // expected-error {{rvalue of type 'B1 (SB1::*)() __attribute__((thiscall))'}}
+
+N t18 = 0 ? (__typeof(X1*)){} : (__typeof(Y1*)){}; // expected-error {{rvalue of type 'typeof(B1 *)' (aka 'int *')}}
+
+struct Enums {
+  enum X : B1;
+  enum Y : ::B1;
+};
+using EnumsB = Enums;
+using EnumsX = EnumsB;
+using EnumsY = EnumsB;
+
+N t19 = 0 ? (__underlying_type(EnumsX::X)){} : (__underlying_type(EnumsY::Y)){};
+// expected-error@-1 {{rvalue of type 'B1' (aka 'int')}}
+
+N t20 = 0 ? (__underlying_type(EnumsX::X)){} : (__underlying_type(EnumsY::X)){};
+// expected-error@-1 {{rvalue of type '__underlying_type(Enums::X)' (aka 'int')}}
+
+using SBTF1 = SS1 [[clang::btf_type_tag("1")]];
+using SBTF2 = ::SS1 [[clang::btf_type_tag("1")]];
+using SBTF3 = ::SS1 [[clang::btf_type_tag("2")]];
+
+N t21 = 0 ? (SBTF1){} : (SBTF3){}; // expected-error {{from 'SS1'}}
+N t22 = 0 ? (SBTF1){} : (SBTF2){}; // expected-error {{from 'SS1 btf_type_tag(1)' (aka 'SS1')}}
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -3776,13 +3776,11 @@
 //   - If A is an array type, the pointer type produced by the
 // array-to-pointer standard conversion (4.2) is used in place of
 // A for type deduction; otherwise,
-if (ArgType->isArrayType())
-  ArgType = S.Context.getArrayDecayedType(ArgType);
 //   - If A is a function type, the pointer type produced by the
 // function-to-pointer standard conversion (4.3) is used in place
 // of A for type deduction; otherwise,
-else if (ArgType->isFunctionType())
-  ArgType = S.Context.getPointerType(ArgType);
+if (ArgType->canDecayToPointerType())
+  ArgType = S.Context.getDecayedType(ArgType);
 else {
   // - If A is a cv-qualified type, the top level cv-qualifiers of A's
   //   type are ignored for type deduction.
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -3329,6 +3329,26 @@
   return QualType(AT, 0);
 }
 
+QualType ASTContext::getDecayedType(QualType T, QualType Decayed) const {
+  llvm::FoldingSetNodeID ID;
+  AdjustedType::Profile(ID, T, Decayed);
+  void *InsertPos = nullptr;
+  AdjustedType *AT = AdjustedTypes.FindNodeOrInsertPos(ID, InsertPos);
+  if (AT)
+return QualType(AT, 0);
+
+  QualType Canonical = getCanonicalType(Decayed);
+
+  // Get the new insert position for the node we care about.
+  AT = AdjustedTypes.FindNodeOrInsertPos(ID, InsertPos);
+  assert(!AT && 

[PATCH] D130299: [clang-format] FIX: Misformatting lambdas with trailing return type 'auto' in braced lists

2022-07-21 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

Could you please add full git context?
Was the problem due to misannotation of `auto`? If so, could you add an 
annotator test?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130299

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


[PATCH] D130306: [clang][dataflow] Analyze calls to in-TU functions

2022-07-21 Thread Sam Estep via Phabricator via cfe-commits
samestep created this revision.
Herald added subscribers: martong, tschuett, xazax.hun.
Herald added a reviewer: NoQ.
Herald added a project: All.
samestep requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Depends On D130305 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130306

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
  clang/include/clang/Analysis/FlowSensitive/Transfer.h
  clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
  clang/lib/Analysis/FlowSensitive/Transfer.cpp
  clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
  clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -39,14 +39,14 @@
 
 template 
 void runDataflow(llvm::StringRef Code, Matcher Match,
-  LangStandard::Kind Std = LangStandard::lang_cxx17,
-  bool ApplyBuiltinTransfer = true,
-  llvm::StringRef TargetFun = "target") {
+ DataflowAnalysisOptions Options,
+ LangStandard::Kind Std = LangStandard::lang_cxx17,
+ llvm::StringRef TargetFun = "target") {
   ASSERT_THAT_ERROR(
   test::checkDataflow(
   Code, TargetFun,
-  [ApplyBuiltinTransfer](ASTContext , Environment &) {
-return NoopAnalysis(C, ApplyBuiltinTransfer);
+  [Options](ASTContext , Environment &) {
+return NoopAnalysis(C, Options);
   },
   [](
   llvm::ArrayRef<
@@ -54,12 +54,19 @@
   Results,
   ASTContext ) { Match(Results, ASTCtx); },
   {"-fsyntax-only", "-fno-delayed-template-parsing",
-"-std=" +
-std::string(
-LangStandard::getLangStandardForKind(Std).getName())}),
+   "-std=" + std::string(
+ LangStandard::getLangStandardForKind(Std).getName())}),
   llvm::Succeeded());
 }
 
+template 
+void runDataflow(llvm::StringRef Code, Matcher Match,
+ LangStandard::Kind Std = LangStandard::lang_cxx17,
+ bool ApplyBuiltinTransfer = true,
+ llvm::StringRef TargetFun = "target") {
+  runDataflow(Code, Match, {ApplyBuiltinTransfer}, Std, TargetFun);
+}
+
 TEST(TransferTest, IntVarDeclNotTrackedWhenTransferDisabled) {
   std::string Code = R"(
 void target() {
@@ -3862,4 +3869,94 @@
   });
 }
 
+TEST(TransferTest, ContextSensitiveOptionDisabled) {
+  std::string Code = R"(
+bool GiveBool();
+void SetBool(bool ) { Var = true; }
+
+void target() {
+  bool Foo = GiveBool();
+  SetBool(Foo);
+  // [[p]]
+}
+  )";
+  runDataflow(Code,
+  [](llvm::ArrayRef<
+ std::pair>>
+ Results,
+ ASTContext ) {
+ASSERT_THAT(Results, ElementsAre(Pair("p", _)));
+const Environment  = Results[0].second.Env;
+
+const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
+ASSERT_THAT(FooDecl, NotNull());
+
+auto  =
+*cast(Env.getValue(*FooDecl, SkipPast::None));
+EXPECT_FALSE(Env.flowConditionImplies(FooVal));
+  },
+  {/*.ApplyBuiltinTransfer=*/true,
+   /*.BuiltinTransferOptions=*/{/*.ContextSensitive=*/false}});
+}
+
+TEST(TransferTest, ContextSensitiveSetTrue) {
+  std::string Code = R"(
+bool GiveBool();
+void SetBool(bool ) { Var = true; }
+
+void target() {
+  bool Foo = GiveBool();
+  SetBool(Foo);
+  // [[p]]
+}
+  )";
+  runDataflow(Code,
+  [](llvm::ArrayRef<
+ std::pair>>
+ Results,
+ ASTContext ) {
+ASSERT_THAT(Results, ElementsAre(Pair("p", _)));
+const Environment  = Results[0].second.Env;
+
+const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
+ASSERT_THAT(FooDecl, NotNull());
+
+auto  =
+*cast(Env.getValue(*FooDecl, SkipPast::None));
+EXPECT_TRUE(Env.flowConditionImplies(FooVal));
+  },
+  {/*.ApplyBuiltinTransfer=*/true,
+   /*.BuiltinTransferOptions=*/{/*.ContextSensitive=*/true}});
+}
+
+TEST(TransferTest, ContextSensitiveSetFalse) {
+  std::string Code = R"(
+bool GiveBool();
+void SetBool(bool ) { Var = false; }
+
+void target() {
+  bool Foo = GiveBool();
+  SetBool(Foo);
+  // [[p]]
+}
+  )";
+  runDataflow(Code,
+  

[PATCH] D130305: [clang][dataflow] Refactor ApplyBuiltinTransfer field out into DataflowAnalysisOptions struct

2022-07-21 Thread Sam Estep via Phabricator via cfe-commits
samestep created this revision.
Herald added subscribers: martong, tschuett, xazax.hun.
Herald added a reviewer: NoQ.
Herald added a project: All.
samestep requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Depends On D130304 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130305

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
  clang/include/clang/Analysis/FlowSensitive/NoopAnalysis.h
  clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h


Index: clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
===
--- clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
+++ clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
@@ -30,6 +30,14 @@
 namespace clang {
 namespace dataflow {
 
+struct DataflowAnalysisOptions {
+  /// Determines whether to apply the built-in transfer functions.
+  // FIXME: Remove this option once the framework supports composing analyses
+  // (at which point the built-in transfer functions can be simply a standalone
+  // analysis).
+  bool ApplyBuiltinTransfer;
+};
+
 /// Type-erased lattice element container.
 ///
 /// Requirements:
@@ -42,16 +50,15 @@
 
 /// Type-erased base class for dataflow analyses built on a single lattice 
type.
 class TypeErasedDataflowAnalysis : public Environment::ValueModel {
-  /// Determines whether to apply the built-in transfer functions.
-  // FIXME: Remove this option once the framework supports composing analyses
-  // (at which point the built-in transfer functions can be simply a standalone
-  // analysis).
-  bool ApplyBuiltinTransfer;
+  DataflowAnalysisOptions Options;
 
 public:
-  TypeErasedDataflowAnalysis() : ApplyBuiltinTransfer(true) {}
+  TypeErasedDataflowAnalysis()
+  : TypeErasedDataflowAnalysis(/*ApplyBuiltinTransfer=*/true) {}
   TypeErasedDataflowAnalysis(bool ApplyBuiltinTransfer)
-  : ApplyBuiltinTransfer(ApplyBuiltinTransfer) {}
+  : Options({ApplyBuiltinTransfer}) {}
+  TypeErasedDataflowAnalysis(DataflowAnalysisOptions Options)
+  : Options(Options) {}
 
   virtual ~TypeErasedDataflowAnalysis() {}
 
@@ -80,7 +87,7 @@
 
   /// Determines whether to apply the built-in transfer functions, which model
   /// the heap and stack in the `Environment`.
-  bool applyBuiltinTransfer() const { return ApplyBuiltinTransfer; }
+  bool applyBuiltinTransfer() const { return Options.ApplyBuiltinTransfer; }
 };
 
 /// Type-erased model of the program at a given program point.
Index: clang/include/clang/Analysis/FlowSensitive/NoopAnalysis.h
===
--- clang/include/clang/Analysis/FlowSensitive/NoopAnalysis.h
+++ clang/include/clang/Analysis/FlowSensitive/NoopAnalysis.h
@@ -32,6 +32,9 @@
   : DataflowAnalysis(Context,
 ApplyBuiltinTransfer) {}
 
+  NoopAnalysis(ASTContext , DataflowAnalysisOptions Options)
+  : DataflowAnalysis(Context, Options) {}
+
   static NoopLattice initialElement() { return {}; }
 
   void transfer(const Stmt *S, NoopLattice , Environment ) {}
Index: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
===
--- clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
+++ clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
@@ -65,6 +65,9 @@
   explicit DataflowAnalysis(ASTContext ) : Context(Context) {}
   explicit DataflowAnalysis(ASTContext , bool ApplyBuiltinTransfer)
   : TypeErasedDataflowAnalysis(ApplyBuiltinTransfer), Context(Context) {}
+  explicit DataflowAnalysis(ASTContext ,
+DataflowAnalysisOptions Options)
+  : TypeErasedDataflowAnalysis(Options), Context(Context) {}
 
   ASTContext () final { return Context; }
 


Index: clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
===
--- clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
+++ clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
@@ -30,6 +30,14 @@
 namespace clang {
 namespace dataflow {
 
+struct DataflowAnalysisOptions {
+  /// Determines whether to apply the built-in transfer functions.
+  // FIXME: Remove this option once the framework supports composing analyses
+  // (at which point the built-in transfer functions can be simply a standalone
+  // analysis).
+  bool ApplyBuiltinTransfer;
+};
+
 /// Type-erased lattice element container.
 ///
 /// Requirements:
@@ -42,16 +50,15 @@
 
 /// Type-erased base class for dataflow analyses built on a single lattice type.
 class TypeErasedDataflowAnalysis : public Environment::ValueModel {
-  /// Determines whether to apply the built-in transfer functions.
-  // 

[PATCH] D130304: [clang][dataflow] Move NoopAnalysis from unittests to include

2022-07-21 Thread Sam Estep via Phabricator via cfe-commits
samestep created this revision.
Herald added subscribers: martong, tschuett, xazax.hun.
Herald added a reviewer: NoQ.
Herald added a project: All.
samestep 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/D130304

Files:
  clang/docs/tools/clang-formatted-files.txt
  clang/include/clang/Analysis/FlowSensitive/NoopAnalysis.h
  clang/unittests/Analysis/FlowSensitive/ChromiumCheckModelTest.cpp
  clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp
  clang/unittests/Analysis/FlowSensitive/NoopAnalysis.h
  clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp
  clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
  clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
@@ -6,7 +6,6 @@
 //
 //===--===//
 
-#include "NoopAnalysis.h"
 #include "TestingSupport.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/ExprCXX.h"
@@ -18,6 +17,7 @@
 #include "clang/Analysis/FlowSensitive/DataflowAnalysisContext.h"
 #include "clang/Analysis/FlowSensitive/DataflowEnvironment.h"
 #include "clang/Analysis/FlowSensitive/DataflowLattice.h"
+#include "clang/Analysis/FlowSensitive/NoopAnalysis.h"
 #include "clang/Analysis/FlowSensitive/Value.h"
 #include "clang/Analysis/FlowSensitive/WatchedLiteralsSolver.h"
 #include "clang/Tooling/Tooling.h"
Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -6,13 +6,13 @@
 //
 //===--===//
 
-#include "NoopAnalysis.h"
 #include "TestingSupport.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Analysis/FlowSensitive/DataflowEnvironment.h"
+#include "clang/Analysis/FlowSensitive/NoopAnalysis.h"
 #include "clang/Analysis/FlowSensitive/StorageLocation.h"
 #include "clang/Analysis/FlowSensitive/Value.h"
 #include "clang/Basic/LangStandard.h"
Index: clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp
@@ -1,8 +1,8 @@
 #include "TestingSupport.h"
-#include "NoopAnalysis.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Analysis/FlowSensitive/NoopAnalysis.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Testing/Support/Error.h"
 #include "gmock/gmock.h"
Index: clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp
@@ -7,9 +7,9 @@
 //===--===//
 
 #include "clang/Analysis/FlowSensitive/DataflowEnvironment.h"
-#include "NoopAnalysis.h"
 #include "TestingSupport.h"
 #include "clang/Analysis/FlowSensitive/DataflowAnalysisContext.h"
+#include "clang/Analysis/FlowSensitive/NoopAnalysis.h"
 #include "clang/Analysis/FlowSensitive/Value.h"
 #include "clang/Analysis/FlowSensitive/WatchedLiteralsSolver.h"
 #include "gmock/gmock.h"
Index: clang/unittests/Analysis/FlowSensitive/ChromiumCheckModelTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/ChromiumCheckModelTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/ChromiumCheckModelTest.cpp
@@ -8,10 +8,10 @@
 // FIXME: Move this to clang/unittests/Analysis/FlowSensitive/Models.
 
 #include "clang/Analysis/FlowSensitive/Models/ChromiumCheckModel.h"
-#include "NoopAnalysis.h"
 #include "TestingSupport.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Analysis/FlowSensitive/NoopAnalysis.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringExtras.h"
Index: clang/include/clang/Analysis/FlowSensitive/NoopAnalysis.h
===
--- clang/include/clang/Analysis/FlowSensitive/NoopAnalysis.h
+++ clang/include/clang/Analysis/FlowSensitive/NoopAnalysis.h

[PATCH] D130303: Handle template parameter-dependent bit field widths in libclang

2022-07-21 Thread Collin Baker via Phabricator via cfe-commits
collinbaker created this revision.
collinbaker added a reviewer: rnk.
Herald added a subscriber: arphaman.
Herald added a project: All.
collinbaker requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

In a class template, a bit field's width may depend on a template
parameter. In this case the width expression cannot be evaluated.

Previously clang_getFieldDeclBitWidth() would assert, or cause memory
unsafety and return an invalid result if assertions are disabled.

This adds a check for this case which returns an error code. An
additional function clang_isFieldDeclBitWidthDependent() as added for
users to check for this case.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130303

Files:
  clang/include/clang-c/Index.h
  clang/tools/libclang/CXType.cpp


Index: clang/tools/libclang/CXType.cpp
===
--- clang/tools/libclang/CXType.cpp
+++ clang/tools/libclang/CXType.cpp
@@ -15,6 +15,7 @@
 #include "CXString.h"
 #include "CXTranslationUnit.h"
 #include "CXType.h"
+#include "clang-c/Index.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/DeclTemplate.h"
@@ -377,6 +378,21 @@
   return ULLONG_MAX;
 }
 
+unsigned clang_isFieldDeclBitWidthDependent(CXCursor C) {
+  using namespace cxcursor;
+
+  if (clang_isDeclaration(C.kind)) {
+const Decl *D = getCursorDecl(C);
+
+if (const FieldDecl *FD = dyn_cast_or_null(D)) {
+  if (FD->isBitField() && FD->getBitWidth()->isValueDependent())
+return 1;
+}
+  }
+
+  return 0;
+}
+
 int clang_getFieldDeclBitWidth(CXCursor C) {
   using namespace cxcursor;
 
@@ -384,7 +400,7 @@
 const Decl *D = getCursorDecl(C);
 
 if (const FieldDecl *FD = dyn_cast_or_null(D)) {
-  if (FD->isBitField())
+  if (FD->isBitField() && !FD->getBitWidth()->isValueDependent())
 return FD->getBitWidthValue(getCursorContext(C));
 }
   }
Index: clang/include/clang-c/Index.h
===
--- clang/include/clang-c/Index.h
+++ clang/include/clang-c/Index.h
@@ -3545,10 +3545,19 @@
 CINDEX_LINKAGE unsigned long long
 clang_getEnumConstantDeclUnsignedValue(CXCursor C);
 
+/**
+ * Returns non-zero if a bit field's width depends on template parameters.
+ *
+ * If the cursor does not reference a bit field declaration or if the bit
+ * field's width does not depend on template parameters, 0 is returned.
+ */
+CINDEX_LINKAGE unsigned clang_isFieldDeclBitWidthDependent(CXCursor C);
+
 /**
  * Retrieve the bit width of a bit field declaration as an integer.
  *
- * If a cursor that is not a bit field declaration is passed in, -1 is 
returned.
+ * If a cursor that is not a bit field declaration is passed in, or if the bit
+ * field's width expression cannot be evaluated, -1 is returned.
  */
 CINDEX_LINKAGE int clang_getFieldDeclBitWidth(CXCursor C);
 


Index: clang/tools/libclang/CXType.cpp
===
--- clang/tools/libclang/CXType.cpp
+++ clang/tools/libclang/CXType.cpp
@@ -15,6 +15,7 @@
 #include "CXString.h"
 #include "CXTranslationUnit.h"
 #include "CXType.h"
+#include "clang-c/Index.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/DeclTemplate.h"
@@ -377,6 +378,21 @@
   return ULLONG_MAX;
 }
 
+unsigned clang_isFieldDeclBitWidthDependent(CXCursor C) {
+  using namespace cxcursor;
+
+  if (clang_isDeclaration(C.kind)) {
+const Decl *D = getCursorDecl(C);
+
+if (const FieldDecl *FD = dyn_cast_or_null(D)) {
+  if (FD->isBitField() && FD->getBitWidth()->isValueDependent())
+return 1;
+}
+  }
+
+  return 0;
+}
+
 int clang_getFieldDeclBitWidth(CXCursor C) {
   using namespace cxcursor;
 
@@ -384,7 +400,7 @@
 const Decl *D = getCursorDecl(C);
 
 if (const FieldDecl *FD = dyn_cast_or_null(D)) {
-  if (FD->isBitField())
+  if (FD->isBitField() && !FD->getBitWidth()->isValueDependent())
 return FD->getBitWidthValue(getCursorContext(C));
 }
   }
Index: clang/include/clang-c/Index.h
===
--- clang/include/clang-c/Index.h
+++ clang/include/clang-c/Index.h
@@ -3545,10 +3545,19 @@
 CINDEX_LINKAGE unsigned long long
 clang_getEnumConstantDeclUnsignedValue(CXCursor C);
 
+/**
+ * Returns non-zero if a bit field's width depends on template parameters.
+ *
+ * If the cursor does not reference a bit field declaration or if the bit
+ * field's width does not depend on template parameters, 0 is returned.
+ */
+CINDEX_LINKAGE unsigned clang_isFieldDeclBitWidthDependent(CXCursor C);
+
 /**
  * Retrieve the bit width of a bit field declaration as an integer.
  *
- * If a cursor that is not a bit field declaration is passed in, -1 is returned.
+ * If a cursor that is not a bit field declaration is passed in, or if the bit
+ * field's width expression 

[PATCH] D130231: [WIP][clang-doc] Improve the Markdown output

2022-07-21 Thread Paul Kirth via Phabricator via cfe-commits
paulkirth added a comment.

Overall I like the direction of the patch, I know this is WIP, but I've left 
some small question inline regarding scope and work tracking.




Comment at: clang-tools-extra/clang-doc/MDGenerator.cpp:23-52
+static std::string genEscaped(StringRef Name) {
+  std::string Buffer;
+  llvm::raw_string_ostream Stream(Buffer);
+  for (unsigned I = 0, E = Name.size(); I != E; ++I) {
+unsigned char C = Name[I];
+switch (C) {
+  case '\\':

This isn't something I expect to get addressed in this patch, but I feel like 
I've seen this same pattern of escaping characters repeated throughout the 
codebase. Maybe we should add a TODO regarding it? I'm also fine with ignoring 
this.



Comment at: clang-tools-extra/clang-doc/MDGenerator.cpp:110-113
+// TODO: @return is a block command and should be included in the 
"Returns" table.
+// TODO: @see block commands should be grouped and rendered as "See Also" 
section.
+// TODO: Figure out handling for @brief.
+// TODO: What other block commands need special handling?

Are these TODOs (and the others throughout the patch) something you plan to 
address in this patch before landing? or are they future improvements? If the 
latter, maybe we should file an issue on github reference it here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130231

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


[PATCH] D129973: [clang] Pass FoundDecl to DeclRefExpr creator for operator overloads

2022-07-21 Thread Danny Mösch via Phabricator via cfe-commits
SimplyDanny updated this revision to Diff 446629.
SimplyDanny added a comment.

Rebased commit onto current main branch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129973

Files:
  clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/AST/ast-dump-overloaded-operators.cpp
  clang/test/Index/annotate-operator-call-expr.cpp
  clang/test/Index/cursor-ref-names.cpp
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -4675,6 +4675,9 @@
   EXPECT_TRUE(notMatches(
 "namespace a { void f(); } using a::f; void g() { a::f(); }",
 declRefExpr(throughUsingDecl(anything();
+  EXPECT_TRUE(matches(
+"struct S {}; namespace a { int operator+(S s1, S s2); } using a::operator+; int g() { return S() + S(); }",
+declRefExpr(throughUsingDecl(anything();
 }
 
 TEST(SingleDecl, IsSingleDecl) {
Index: clang/test/Index/cursor-ref-names.cpp
===
--- clang/test/Index/cursor-ref-names.cpp
+++ clang/test/Index/cursor-ref-names.cpp
@@ -33,9 +33,9 @@
 // CHECK: cursor-ref-names.cpp:18:5: CallExpr=func:8:10 Extent=[18:5 - 18:16]
 // CHECK: cursor-ref-names.cpp:18:10: MemberRefExpr=func:8:10 SingleRefName=[18:10 - 18:14] RefName=[18:10 - 18:14] Extent=[18:5 - 18:14]
 // CHECK: cursor-ref-names.cpp:18:5: DeclRefExpr=inst:17:9 Extent=[18:5 - 18:9]
-// CHECK: cursor-ref-names.cpp:19:5: CallExpr=operator[]:4:9 SingleRefName=[19:9 - 19:12] RefName=[19:9 - 19:10] RefName=[19:11 - 19:12] Extent=[19:5 - 19:12]
+// CHECK: cursor-ref-names.cpp:19:5: CallExpr=operator[]:4:9 Extent=[19:5 - 19:12] 
 // CHECK: cursor-ref-names.cpp:19:5: DeclRefExpr=inst:17:9 Extent=[19:5 - 19:9]
-// CHECK: cursor-ref-names.cpp:19:9: DeclRefExpr=operator[]:4:9 RefName=[19:9 - 19:10] RefName=[19:11 - 19:12] Extent=[19:9 - 19:12]
+// CHECK: cursor-ref-names.cpp:19:9: DeclRefExpr=operator[]:4:9 Extent=[19:9 - 19:10]
 // CHECK: cursor-ref-names.cpp:20:5: CallExpr=operator[]:4:9 Extent=[20:5 - 20:23]
 // CHECK: cursor-ref-names.cpp:20:10: MemberRefExpr=operator[]:4:9 SingleRefName=[20:10 - 20:20] RefName=[20:10 - 20:18] RefName=[20:18 - 20:19] RefName=[20:19 - 20:20] Extent=[20:5 - 20:20]
 // CHECK: cursor-ref-names.cpp:20:5: DeclRefExpr=inst:17:9 Extent=[20:5 - 20:9]
Index: clang/test/Index/annotate-operator-call-expr.cpp
===
--- clang/test/Index/annotate-operator-call-expr.cpp
+++ clang/test/Index/annotate-operator-call-expr.cpp
@@ -17,68 +17,68 @@
 
 // RUN: c-index-test -test-annotate-tokens=%s:7:1:7:100 %s -std=c++11 -Wno-unused-value | FileCheck %s -check-prefix=CHECK1
 // CHECK1: Identifier: "foo" [7:3 - 7:6] DeclRefExpr=foo:6:18
-// CHECK1: Punctuation: "(" [7:6 - 7:7] DeclRefExpr=operator():3:7 RefName=[7:6 - 7:7] RefName=[7:7 - 7:8]
-// CHECK1: Punctuation: ")" [7:7 - 7:8] DeclRefExpr=operator():3:7 RefName=[7:6 - 7:7] RefName=[7:7 - 7:8]
+// CHECK1: Punctuation: "(" [7:6 - 7:7] CallExpr=operator():3:7
+// CHECK1: Punctuation: ")" [7:7 - 7:8] CallExpr=operator():3:7
 // CHECK1: Punctuation: ";" [7:8 - 7:9] CompoundStmt=
 
 // RUN: c-index-test -test-annotate-tokens=%s:8:1:8:100 %s -std=c++11 -Wno-unused-value | FileCheck %s -check-prefix=CHECK2
-// CHECK2: Punctuation: "(" [8:6 - 8:7] DeclRefExpr=operator():3:7 RefName=[8:6 - 8:7] RefName=[8:12 - 8:13]
+// CHECK2: Punctuation: "(" [8:6 - 8:7] CallExpr=operator():3:7
 // CHECK2: Identifier: "index" [8:7 - 8:12] DeclRefExpr=index:6:27
-// CHECK2: Punctuation: ")" [8:12 - 8:13] DeclRefExpr=operator():3:7 RefName=[8:6 - 8:7] RefName=[8:12 - 8:13]
+// CHECK2: Punctuation: ")" [8:12 - 8:13] CallExpr=operator():3:7
 // CHECK2: Punctuation: ";" [8:13 - 8:14] CompoundStmt=
 
 // RUN: c-index-test -test-annotate-tokens=%s:10:1:10:100 %s -std=c++11 -Wno-unused-value | FileCheck %s -check-prefix=CHECK3
 // CHECK3: Identifier: "foo" [10:3 - 10:6] DeclRefExpr=foo:6:18
-// CHECK3: Punctuation: "[" [10:6 - 10:7] DeclRefExpr=operator[]:2:7 RefName=[10:6 - 10:7] RefName=[10:12 - 10:13]
+// CHECK3: Punctuation: "[" [10:6 - 10:7] CallExpr=operator[]:2:7
 // CHECK3: Identifier: "index" [10:7 - 10:12] DeclRefExpr=index:6:27
-// CHECK3: Punctuation: "]" [10:12 - 10:13] DeclRefExpr=operator[]:2:7 RefName=[10:6 - 10:7] RefName=[10:12 - 10:13]
+// CHECK3: Punctuation: "]" [10:12 - 10:13] CallExpr=operator[]:2:7
 // CHECK3: Punctuation: ";" [10:13 - 10:14] CompoundStmt=
 
 // RUN: c-index-test -test-annotate-tokens=%s:11:1:11:100 %s -std=c++11 -Wno-unused-value | FileCheck %s -check-prefix=CHECK4
 // CHECK4: Identifier: "foo" [11:3 - 11:6] DeclRefExpr=foo:6:18
-// CHECK4: 

[clang] ccc12a2 - [OpenMP][NFC] Claim iterators in 'map' clause and motion clauses

2022-07-21 Thread Chi Chun Chen via cfe-commits

Author: Chi Chun Chen
Date: 2022-07-21T15:50:22-05:00
New Revision: ccc12a2376105d28b6acce59b4319df2051a0833

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

LOG: [OpenMP][NFC] Claim iterators in 'map' clause and motion clauses

Added: 


Modified: 
clang/docs/OpenMPSupport.rst

Removed: 




diff  --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index efabe927d6df..af405d2202a8 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -291,7 +291,7 @@ implementation.
 
+--+--+--+---+
 | device   | has_device_addr clause on target construct
   | :none:`unclaimed`| 
  |
 
+--+--+--+---+
-| device   | iterators in map clause or motion clauses 
   | :none:`unclaimed`| 
  |
+| device   | iterators in map clause or motion clauses 
   | :part:`worked on`| 
  |
 
+--+--+--+---+
 | device   | indirect clause on declare target directive   
   | :none:`unclaimed`| 
  |
 
+--+--+--+---+



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


[PATCH] D130066: [pseudo] Key guards by RuleID, add guards to literals (and 0).

2022-07-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/pseudo/gen/Main.cpp:102
   llvm::StringRef Name = G.table().AttributeValues[EID];
-  assert(!Name.empty());
   Out.os() << llvm::formatv("EXTENSION({0}, {1})\n", Name, EID);

hokein wrote:
> I think this invariant is still true even in this patch, ExtensionID for 
> empty attribute value is 0, and we start from 1 in the loop.
Hmm, the assert was firing...

Ah I see what was going on: we were inserting "" at 0 but were inserting it 
*again* if it was in UniqueAttributeValues, so we had two copies. Fixed.



Comment at: clang-tools-extra/pseudo/lib/cxx/CXX.cpp:156
 
 llvm::DenseMap buildGuards() {
+#define TOKEN_GUARD(kind, cond)
\

hokein wrote:
> we might probably to consider to split it out from the CXX.cpp at some point 
> in the future. I think currently it is fine.
Yeah, I'd like to keep this all lumped together with no public interfaces for 
now until the patterns are stable - I wouldn't be surprised if we have to 
refactor these macros a few more times.



Comment at: clang-tools-extra/pseudo/lib/cxx/CXX.cpp:171
+  {(RuleID)Rule::non_function_declarator_0declarator,
+   SYMBOL_GUARD(declarator, !isFunctionDeclarator())},
+  {(RuleID)Rule::contextual_override_0identifier,

hokein wrote:
> nit: add a blank line, I think function-declarator guard is different than 
> the contextual-sensitive guard.
Yeah, good call.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130066

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


[clang-tools-extra] 3132e9c - [pseudo] Key guards by RuleID, add guards to literals (and 0).

2022-07-21 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2022-07-21T22:42:31+02:00
New Revision: 3132e9cd7c9fda63f7c0babf8bd5f6d755ce9027

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

LOG: [pseudo] Key guards by RuleID, add guards to literals (and 0).

After this, NUMERIC_CONSTANT and strings should parse only one way.

There are 8 types of literals, and 24 valid (literal, TokenKind) pairs.
This means adding 8 new named guards (or 24, if we want to assert the token).

It seems fairly clear to me at this point that the guard names are unneccesary
indirection: the guards are in fact coupled to the rule signature.

(Also add the zero guard I forgot in the previous patch.)

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

Added: 
clang-tools-extra/pseudo/test/cxx/literals.cpp

Modified: 
clang-tools-extra/pseudo/include/clang-pseudo/Language.h
clang-tools-extra/pseudo/include/clang-pseudo/grammar/Grammar.h
clang-tools-extra/pseudo/lib/GLR.cpp
clang-tools-extra/pseudo/lib/cxx/CXX.cpp
clang-tools-extra/pseudo/lib/cxx/cxx.bnf
clang-tools-extra/pseudo/lib/grammar/Grammar.cpp
clang-tools-extra/pseudo/lib/grammar/GrammarBNF.cpp
clang-tools-extra/pseudo/test/cxx/mixed-designator.cpp
clang-tools-extra/pseudo/tool/ClangPseudo.cpp
clang-tools-extra/pseudo/unittests/GLRTest.cpp
clang-tools-extra/pseudo/unittests/GrammarTest.cpp

Removed: 




diff  --git a/clang-tools-extra/pseudo/include/clang-pseudo/Language.h 
b/clang-tools-extra/pseudo/include/clang-pseudo/Language.h
index 410ca075a5da4..3696543915cba 100644
--- a/clang-tools-extra/pseudo/include/clang-pseudo/Language.h
+++ b/clang-tools-extra/pseudo/include/clang-pseudo/Language.h
@@ -46,7 +46,7 @@ struct Language {
   LRTable Table;
 
   // Binding extension ids to corresponding implementations.
-  llvm::DenseMap Guards;
+  llvm::DenseMap Guards;
   llvm::DenseMap RecoveryStrategies;
 
   // FIXME: add clang::LangOptions.

diff  --git a/clang-tools-extra/pseudo/include/clang-pseudo/grammar/Grammar.h 
b/clang-tools-extra/pseudo/include/clang-pseudo/grammar/Grammar.h
index ef22f71d801c0..a3d85aacef23e 100644
--- a/clang-tools-extra/pseudo/include/clang-pseudo/grammar/Grammar.h
+++ b/clang-tools-extra/pseudo/include/clang-pseudo/grammar/Grammar.h
@@ -28,12 +28,12 @@
 //  ), and an extension point corresponds to a piece of native code. For
 //  example, C++ grammar has a rule:
 //
-//contextual-override := IDENTIFIER [guard=Override]
+//   compound_statement := { statement-seq [recover=Brackets] }
 //
-//  GLR parser only conducts the reduction of the rule if the IDENTIFIER
-//  content is `override`. This Override guard is implemented in CXX.cpp by
-//  binding the ExtensionID for the `Override` value to a specific C++ function
-//  that performs the check.
+//  The `recover` attribute instructs the parser that we should perform error
+//  recovery if parsing the statement-seq fails. The `Brackets` recovery
+//  heuristic is implemented in CXX.cpp by binding the ExtensionID for the
+//  `Recovery` value to a specific C++ function that finds the recovery point.
 //
 //  Notions about the BNF grammar:
 //  - "_" is the start symbol of the augmented grammar;
@@ -118,11 +118,8 @@ struct Rule {
   uint8_t Size : SizeBits; // Size of the Sequence
   SymbolID Sequence[MaxElements];
 
-  // A guard extension controls whether a reduction of a rule will be conducted
-  // by the GLR parser.
-  // 0 is sentinel unset extension ID, indicating there is no guard extension
-  // being set for this rule.
-  ExtensionID Guard = 0;
+  // A guarded rule has extra logic to determine whether the RHS is eligible.
+  bool Guarded = false;
 
   // Specifies the index within Sequence eligible for error recovery.
   // Given stmt := { stmt-seq_opt }, if we fail to parse the stmt-seq then we
@@ -136,7 +133,7 @@ struct Rule {
 return llvm::ArrayRef(Sequence, Size);
   }
   friend bool operator==(const Rule , const Rule ) {
-return L.Target == R.Target && L.seq() == R.seq() && L.Guard == R.Guard;
+return L.Target == R.Target && L.seq() == R.seq() && L.Guarded == 
R.Guarded;
   }
 };
 

diff  --git a/clang-tools-extra/pseudo/lib/GLR.cpp 
b/clang-tools-extra/pseudo/lib/GLR.cpp
index 1664089725197..df8381d04326b 100644
--- a/clang-tools-extra/pseudo/lib/GLR.cpp
+++ b/clang-tools-extra/pseudo/lib/GLR.cpp
@@ -416,11 +416,11 @@ class GLRReduce {
   }
 
 private:
-  bool canReduce(ExtensionID GuardID, RuleID RID,
+  bool canReduce(const Rule , RuleID RID,
  llvm::ArrayRef RHS) const {
-if (!GuardID)
+if (!R.Guarded)
   return true;
-if (auto Guard = Lang.Guards.lookup(GuardID))
+if (auto Guard = Lang.Guards.lookup(RID))
   return Guard(RHS, Params.Code);
 LLVM_DEBUG(llvm::dbgs()

[PATCH] D130066: [pseudo] Key guards by RuleID, add guards to literals (and 0).

2022-07-21 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
sammccall marked 6 inline comments as done.
Closed by commit rG3132e9cd7c9f: [pseudo] Key guards by RuleID, add guards to 
literals (and 0). (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D130066?vs=446061=446623#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130066

Files:
  clang-tools-extra/pseudo/include/clang-pseudo/Language.h
  clang-tools-extra/pseudo/include/clang-pseudo/grammar/Grammar.h
  clang-tools-extra/pseudo/lib/GLR.cpp
  clang-tools-extra/pseudo/lib/cxx/CXX.cpp
  clang-tools-extra/pseudo/lib/cxx/cxx.bnf
  clang-tools-extra/pseudo/lib/grammar/Grammar.cpp
  clang-tools-extra/pseudo/lib/grammar/GrammarBNF.cpp
  clang-tools-extra/pseudo/test/cxx/literals.cpp
  clang-tools-extra/pseudo/test/cxx/mixed-designator.cpp
  clang-tools-extra/pseudo/tool/ClangPseudo.cpp
  clang-tools-extra/pseudo/unittests/GLRTest.cpp
  clang-tools-extra/pseudo/unittests/GrammarTest.cpp

Index: clang-tools-extra/pseudo/unittests/GrammarTest.cpp
===
--- clang-tools-extra/pseudo/unittests/GrammarTest.cpp
+++ clang-tools-extra/pseudo/unittests/GrammarTest.cpp
@@ -102,16 +102,11 @@
 TEST_F(GrammarTest, Annotation) {
   build(R"bnf(
 _ := x
-
-x := y [guard=value]
-y := IDENTIFIER [guard=final]
-
+x := IDENTIFIER [guard]
   )bnf");
-  ASSERT_TRUE(Diags.empty());
-  EXPECT_EQ(G.lookupRule(ruleFor("_")).Guard, 0);
-  EXPECT_GT(G.lookupRule(ruleFor("x")).Guard, 0);
-  EXPECT_GT(G.lookupRule(ruleFor("y")).Guard, 0);
-  EXPECT_NE(G.lookupRule(ruleFor("x")).Guard, G.lookupRule(ruleFor("y")).Guard);
+  ASSERT_THAT(Diags, IsEmpty());
+  EXPECT_FALSE(G.lookupRule(ruleFor("_")).Guarded);
+  EXPECT_TRUE(G.lookupRule(ruleFor("x")).Guarded);
 }
 
 TEST_F(GrammarTest, MangleName) {
Index: clang-tools-extra/pseudo/unittests/GLRTest.cpp
===
--- clang-tools-extra/pseudo/unittests/GLRTest.cpp
+++ clang-tools-extra/pseudo/unittests/GLRTest.cpp
@@ -631,10 +631,10 @@
   build(R"bnf(
 _ := start
 
-start := IDENTIFIER [guard=TestOnly]
+start := IDENTIFIER [guard]
   )bnf");
   TestLang.Guards.try_emplace(
-  extensionID("TestOnly"),
+  ruleFor("start"),
   [&](llvm::ArrayRef RHS, const TokenStream ) {
 assert(RHS.size() == 1 &&
RHS.front()->symbol() == tokenSymbol(clang::tok::identifier));
@@ -647,7 +647,7 @@
   const TokenStream  = cook(lex(Input, LOptions), LOptions);
   EXPECT_EQ(glrParse({Succeeded, Arena, GSStack}, id("start"), TestLang)
 .dumpRecursive(TestLang.G),
-"[  0, end) start := IDENTIFIER [guard=TestOnly]\n"
+"[  0, end) start := IDENTIFIER [guard]\n"
 "[  0, end) └─IDENTIFIER := tok[0]\n");
 
   Input = "notest";
Index: clang-tools-extra/pseudo/tool/ClangPseudo.cpp
===
--- clang-tools-extra/pseudo/tool/ClangPseudo.cpp
+++ clang-tools-extra/pseudo/tool/ClangPseudo.cpp
@@ -45,6 +45,8 @@
 desc("Strip directives and select conditional sections"));
 static opt PrintStatistics("print-statistics", desc("Print GLR parser statistics"));
 static opt PrintForest("print-forest", desc("Print parse forest"));
+static opt ForestAbbrev("forest-abbrev", desc("Abbreviate parse forest"),
+  init(true));
 static opt HTMLForest("html-forest",
desc("output file for HTML forest"));
 static opt StartSymbol("start-symbol",
@@ -153,7 +155,7 @@
 glrParse(clang::pseudo::ParseParams{*ParseableStream, Arena, GSS},
  *StartSymID, Lang);
 if (PrintForest)
-  llvm::outs() << Root.dumpRecursive(Lang.G, /*Abbreviated=*/true);
+  llvm::outs() << Root.dumpRecursive(Lang.G, /*Abbreviated=*/ForestAbbrev);
 
 if (HTMLForest.getNumOccurrences()) {
   std::error_code EC;
Index: clang-tools-extra/pseudo/test/cxx/mixed-designator.cpp
===
--- clang-tools-extra/pseudo/test/cxx/mixed-designator.cpp
+++ clang-tools-extra/pseudo/test/cxx/mixed-designator.cpp
@@ -5,16 +5,16 @@
 // CHECK-NEXT: ├─{ := tok[3]
 // CHECK-NEXT: ├─initializer-list
 // CHECK-NEXT: │ ├─initializer-list
-// CHECK-NEXT: │ │ ├─initializer-list~literal
-// CHECK:  │ │ ├─, := tok[5]
+// CHECK-NEXT: │ │ ├─initializer-list~NUMERIC_CONSTANT
+// CHECK-NEXT: │ │ ├─, := tok[5]
 // CHECK-NEXT: │ │ └─initializer-list-item
 // CHECK-NEXT: │ │   ├─designator
 // CHECK-NEXT: │ │   │ ├─. := tok[6]
 // CHECK-NEXT: │ │   │ └─IDENTIFIER := tok[7]
 // CHECK-NEXT: │ │   └─brace-or-equal-initializer
 // CHECK-NEXT: │ │ ├─= := tok[8]
-// 

[PATCH] D130301: [Clang] Fix how we set the NumPositiveBits on an E numDecl to cover the case of single enumerator with value zero or an empty enum

2022-07-21 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik created this revision.
shafik added reviewers: aaron.ballman, erichkeane, tahonermann.
Herald added a project: All.
shafik requested review of this revision.

Currently in `Sema::ActOnEnumBody(...)` when calculating `NumPositiveBits` we 
miss the case where there is only a single enumerator with value zero and the 
case of an empty enum. In both cases we end up with zero positive bits when in 
fact we need one bit to store the value zero.

This PR updates the calculation to account for these cases.

Relevant C++ standard quotes are `[dcl.enum]p7`:

> .., If the enumerator-list is empty, the underlying type is as if the 
> enumeration had a single enumerator with value 0.

and `[dcl.enum]p8`:

> ... Otherwise, the values of the enumeration are the values representable by 
> a hypothetical
> integer type with minimal width M such that all enumerators can be 
> represented. The width of the smallest
> bit-field large enough to hold all the values of the enumeration type is M. 
> ...


https://reviews.llvm.org/D130301

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CodeGenCXX/pr12251.cpp


Index: clang/test/CodeGenCXX/pr12251.cpp
===
--- clang/test/CodeGenCXX/pr12251.cpp
+++ clang/test/CodeGenCXX/pr12251.cpp
@@ -18,14 +18,14 @@
   return *x;
 }
 // CHECK-LABEL: define{{.*}} i32 @_Z2g1P2e1
-// CHECK: ret i32 0
+// CHECK: ret i32 %0
 
 enum e2 { e2_a = 0 };
 e2 g2(e2 *x) {
   return *x;
 }
 // CHECK-LABEL: define{{.*}} i32 @_Z2g2P2e2
-// CHECK: ret i32 0
+// CHECK: ret i32 %0
 
 enum e3 { e3_a = 16 };
 e3 g3(e3 *x) {
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -18878,14 +18878,24 @@
 const llvm::APSInt  = ECD->getInitVal();
 
 // Keep track of the size of positive and negative values.
-if (InitVal.isUnsigned() || InitVal.isNonNegative())
-  NumPositiveBits = std::max(NumPositiveBits,
- (unsigned)InitVal.getActiveBits());
-else
+if (InitVal.isUnsigned() || InitVal.isNonNegative()) {
+  // If the enumerator is zero that should still be counted as a positive
+  // bit since we need a bit to store the value zero
+  const unsigned ActiveBits =
+  InitVal.getActiveBits() ? InitVal.getActiveBits() : 1;
+  NumPositiveBits = std::max(NumPositiveBits, ActiveBits);
+} else
   NumNegativeBits = std::max(NumNegativeBits,
  (unsigned)InitVal.getMinSignedBits());
   }
 
+  // If we have have a empty set of enumerators we still need one bit.
+  // From [dcl.enum]p8
+  // If the enumerator-list is empty, the values of the enumeration are as if
+  // the enumeration had a single enumerator with value 0
+  if (!NumPositiveBits && !NumNegativeBits)
+NumPositiveBits = 1;
+
   // Figure out the type that should be used for this enum.
   QualType BestType;
   unsigned BestWidth;


Index: clang/test/CodeGenCXX/pr12251.cpp
===
--- clang/test/CodeGenCXX/pr12251.cpp
+++ clang/test/CodeGenCXX/pr12251.cpp
@@ -18,14 +18,14 @@
   return *x;
 }
 // CHECK-LABEL: define{{.*}} i32 @_Z2g1P2e1
-// CHECK: ret i32 0
+// CHECK: ret i32 %0
 
 enum e2 { e2_a = 0 };
 e2 g2(e2 *x) {
   return *x;
 }
 // CHECK-LABEL: define{{.*}} i32 @_Z2g2P2e2
-// CHECK: ret i32 0
+// CHECK: ret i32 %0
 
 enum e3 { e3_a = 16 };
 e3 g3(e3 *x) {
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -18878,14 +18878,24 @@
 const llvm::APSInt  = ECD->getInitVal();
 
 // Keep track of the size of positive and negative values.
-if (InitVal.isUnsigned() || InitVal.isNonNegative())
-  NumPositiveBits = std::max(NumPositiveBits,
- (unsigned)InitVal.getActiveBits());
-else
+if (InitVal.isUnsigned() || InitVal.isNonNegative()) {
+  // If the enumerator is zero that should still be counted as a positive
+  // bit since we need a bit to store the value zero
+  const unsigned ActiveBits =
+  InitVal.getActiveBits() ? InitVal.getActiveBits() : 1;
+  NumPositiveBits = std::max(NumPositiveBits, ActiveBits);
+} else
   NumNegativeBits = std::max(NumNegativeBits,
  (unsigned)InitVal.getMinSignedBits());
   }
 
+  // If we have have a empty set of enumerators we still need one bit.
+  // From [dcl.enum]p8
+  // If the enumerator-list is empty, the values of the enumeration are as if
+  // the enumeration had a single enumerator with value 0
+  if (!NumPositiveBits && !NumNegativeBits)
+NumPositiveBits = 1;
+
   // Figure out the type that should be used for this enum.
   QualType BestType;
   unsigned BestWidth;
___
cfe-commits 

[PATCH] D129398: [ASTMatchers] Add a new matcher for callee declarations of Obj-C message expressions

2022-07-21 Thread Ziqing Luo via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb17baa1db613: [ASTMatchers] Adding a new matcher for callee 
declarations of Obj-C (authored by ziqingluo-90).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129398

Files:
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
  clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp

Index: clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
===
--- clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
+++ clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp
@@ -198,13 +198,32 @@
constructMatcher("hasName", StringRef("x")
   .getTypedMatcher();
 
+  Matcher ObjCMsgExpr =
+  constructMatcher(
+  "objcMessageExpr",
+  constructMatcher(
+  "callee",
+  constructMatcher("objcMethodDecl",
+   constructMatcher("hasName", StringRef("x")
+  .getTypedMatcher();
+
   std::string Code = "class Y { public: void x(); }; void z() { Y y; y.x(); }";
   EXPECT_FALSE(matches(Code, CallExpr0));
   EXPECT_TRUE(matches(Code, CallExpr1));
+  EXPECT_FALSE(matches(Code, ObjCMsgExpr));
 
   Code = "class Z { public: void z() { this->z(); } };";
   EXPECT_TRUE(matches(Code, CallExpr0));
   EXPECT_FALSE(matches(Code, CallExpr1));
+  EXPECT_FALSE(matches(Code, ObjCMsgExpr));
+
+  Code = "@interface I "
+ "+ (void)x; "
+ "@end\n"
+ "int main() { [I x]; }";
+  EXPECT_FALSE(matchesObjC(Code, CallExpr0));
+  EXPECT_FALSE(matchesObjC(Code, CallExpr1));
+  EXPECT_TRUE(matchesObjC(Code, ObjCMsgExpr));
 
   Matcher DeclDecl = declaratorDecl(hasTypeLoc(
   constructMatcher(
Index: clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -2307,6 +2307,45 @@
   hasName("cc"), hasInitializer(integerLiteral(equals(1));
 }
 
+TEST(ASTMatchersTestObjC, ObjCMessageCalees) {
+  StatementMatcher MessagingFoo =
+  objcMessageExpr(callee(objcMethodDecl(hasName("foo";
+
+  EXPECT_TRUE(matchesObjC("@interface I"
+  "+ (void)foo;"
+  "@end\n"
+  "int main() {"
+  "  [I foo];"
+  "}",
+  MessagingFoo));
+  EXPECT_TRUE(notMatchesObjC("@interface I"
+ "+ (void)foo;"
+ "+ (void)bar;"
+ "@end\n"
+ "int main() {"
+ "  [I bar];"
+ "}",
+ MessagingFoo));
+  EXPECT_TRUE(matchesObjC("@interface I"
+  "- (void)foo;"
+  "- (void)bar;"
+  "@end\n"
+  "int main() {"
+  "  I *i;"
+  "  [i foo];"
+  "}",
+  MessagingFoo));
+  EXPECT_TRUE(notMatchesObjC("@interface I"
+ "- (void)foo;"
+ "- (void)bar;"
+ "@end\n"
+ "int main() {"
+ "  I *i;"
+ "  [i bar];"
+ "}",
+ MessagingFoo));
+}
+
 TEST(ASTMatchersTestObjC, ObjCMessageExpr) {
   // Don't find ObjCMessageExpr where none are present.
   EXPECT_TRUE(notMatchesObjC("", objcMessageExpr(anything(;
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -3838,8 +3838,9 @@
   InnerMatcher.matches(*ExprNode, Finder, Builder));
 }
 
-/// Matches if the call expression's callee's declaration matches the
-/// given matcher.
+/// Matches 1) if the call expression's callee's declaration matches the
+/// given matcher; or 2) if the Obj-C message expression's callee's method
+/// declaration matches the given matcher.
 ///
 /// Example matches y.x() (matcher = callExpr(callee(
 ///cxxMethodDecl(hasName("x")
@@ -3847,9 +3848,31 @@
 ///   class Y { public: void x(); };
 ///   void z() { Y y; y.x(); }
 /// \endcode
-AST_MATCHER_P_OVERLOAD(CallExpr, callee, internal::Matcher, InnerMatcher,
-   1) {
-  return callExpr(hasDeclaration(InnerMatcher)).matches(Node, Finder, Builder);
+///
+/// 

[clang] b17baa1 - [ASTMatchers] Adding a new matcher for callee declarations of Obj-C

2022-07-21 Thread Ziqing Luo via cfe-commits

Author: Ziqing Luo
Date: 2022-07-21T13:35:31-07:00
New Revision: b17baa1db613a2ce777aa122feb87488750a64d0

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

LOG: [ASTMatchers] Adding a new matcher for callee declarations of Obj-C
message expressions

For an Obj-C message expression `[o m]`, the adding matcher will match
the declaration of the method `m`.  This commit overloads the existing
`callee` ASTMatcher, which originally was only for C/C++ nodes but
also applies to Obj-C messages now.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang/docs/LibASTMatchersReference.html
clang/include/clang/ASTMatchers/ASTMatchers.h
clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp

Removed: 




diff  --git a/clang/docs/LibASTMatchersReference.html 
b/clang/docs/LibASTMatchersReference.html
index 03ca48cc1a9b3..4ac9ab0090cd4 100644
--- a/clang/docs/LibASTMatchersReference.html
+++ b/clang/docs/LibASTMatchersReference.html
@@ -7255,14 +7255,24 @@ AST Traversal Matchers
 
 
 
-Matcherhttps://clang.llvm.org/doxygen/classclang_1_1CallExpr.html;>CallExprcalleeMatcherhttps://clang.llvm.org/doxygen/classclang_1_1Decl.html;>Decl 
InnerMatcher
-Matches if the call 
expression's callee's declaration matches the
-given matcher.
+Matcherhttps://clang.llvm.org/doxygen/classclang_1_1CallExpr.html;>CallExprcalleeMatcherhttps://clang.llvm.org/doxygen/classclang_1_1Decl.html;>Decl 
InnerMatcher
+Matches 1) if the call 
expression's callee's declaration matches the
+given matcher; or 2) if the Obj-C message expression's callee's method
+declaration matches the given matcher.
 
 Example matches y.x() (matcher = callExpr(callee(
cxxMethodDecl(hasName("x")
   class Y { public: void x(); };
   void z() { Y y; y.x(); }
+
+Example 2. Matches [I foo] with
+objcMessageExpr(callee(objcMethodDecl(hasName("foo"
+
+  @interface I: NSObject
+  +(void)foo;
+  @end
+  ...
+  [I foo]
 
 
 
@@ -8814,6 +8824,27 @@ AST Traversal Matchers
 
 
 
+Matcherhttps://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html;>ObjCMessageExprcalleeMatcherhttps://clang.llvm.org/doxygen/classclang_1_1Decl.html;>Decl 
InnerMatcher
+Matches 1) if the call 
expression's callee's declaration matches the
+given matcher; or 2) if the Obj-C message expression's callee's method
+declaration matches the given matcher.
+
+Example matches y.x() (matcher = callExpr(callee(
+   cxxMethodDecl(hasName("x")
+  class Y { public: void x(); };
+  void z() { Y y; y.x(); }
+
+Example 2. Matches [I foo] with
+objcMessageExpr(callee(objcMethodDecl(hasName("foo"
+
+  @interface I: NSObject
+  +(void)foo;
+  @end
+  ...
+  [I foo]
+
+
+
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html;>ObjCMessageExprhasAnyArgumentMatcherhttps://clang.llvm.org/doxygen/classclang_1_1Expr.html;>Expr 
InnerMatcher
 Matches any argument 
of a call expression or a constructor call
 expression, or an ObjC-message-send expression.

diff  --git a/clang/include/clang/ASTMatchers/ASTMatchers.h 
b/clang/include/clang/ASTMatchers/ASTMatchers.h
index ae5502d7af71b..9f4d807c232dc 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -3838,8 +3838,9 @@ AST_MATCHER_P(CallExpr, callee, internal::Matcher,
   InnerMatcher.matches(*ExprNode, Finder, Builder));
 }
 
-/// Matches if the call expression's callee's declaration matches the
-/// given matcher.
+/// Matches 1) if the call expression's callee's declaration matches the
+/// given matcher; or 2) if the Obj-C message expression's callee's method
+/// declaration matches the given matcher.
 ///
 /// Example matches y.x() (matcher = callExpr(callee(
 ///cxxMethodDecl(hasName("x")
@@ -3847,9 +3848,31 @@ AST_MATCHER_P(CallExpr, callee, internal::Matcher,
 ///   class Y { public: void x(); };
 ///   void z() { Y y; y.x(); }
 /// \endcode
-AST_MATCHER_P_OVERLOAD(CallExpr, callee, internal::Matcher, InnerMatcher,
-   1) {
-  return callExpr(hasDeclaration(InnerMatcher)).matches(Node, Finder, Builder);
+///
+/// Example 2. Matches [I foo] with
+/// objcMessageExpr(callee(objcMethodDecl(hasName("foo"
+///
+/// \code
+///   @interface I: NSObject
+///   +(void)foo;
+///   @end
+///   ...
+///   [I foo]
+/// \endcode
+AST_POLYMORPHIC_MATCHER_P_OVERLOAD(
+callee, AST_POLYMORPHIC_SUPPORTED_TYPES(ObjCMessageExpr, CallExpr),
+internal::Matcher, InnerMatcher, 1) {
+  if (const auto *CallNode = dyn_cast())
+return callExpr(hasDeclaration(InnerMatcher))
+.matches(Node, Finder, 

[PATCH] D130299: [clang-format] FIX: Misformatting lambdas with trailing return type 'auto' in braced lists

2022-07-21 Thread Denis Fatkulin via Phabricator via cfe-commits
denis-fatkulin created this revision.
denis-fatkulin added a reviewer: rsmith.
denis-fatkulin added a project: clang-format.
Herald added a project: All.
denis-fatkulin requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Lambdas with trailing return type 'auto' are formatted incorrectly in braced 
lists. The simpliest reproduction code is:

  cpp
  auto list = {[]() -> auto { return 0; }};

Was reported at https://github.com/llvm/llvm-project/issues/54798


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130299

Files:
  clang/lib/Format/TokenAnnotator.cpp
  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
@@ -23546,6 +23546,13 @@
   verifyFormat("auto lambda = [ = a]() { a = 2; };", AlignStyle);
 }
 
+TEST_F(FormatTest, LambdaWithTrailingAutoInBracedList) {
+  FormatStyle Style = getLLVMStyle();
+  verifyFormat("auto list = {[]() -> auto { return Val; }};", Style);
+  verifyFormat("auto list = {[]() -> auto * { return Ptr; }};", Style);
+  verifyFormat("auto list = {[]() -> auto & { return Ref; }};", Style);
+}
+
 TEST_F(FormatTest, SpacesInConditionalStatement) {
   FormatStyle Spaces = getLLVMStyle();
   Spaces.IfMacros.clear();
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2108,6 +2108,7 @@
 case tok::l_square:
   parseSquare();
   break;
+case tok::kw_auto:
 case tok::kw_class:
 case tok::kw_template:
 case tok::kw_typename:
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3310,6 +3310,10 @@
 }
   }
 
+  // Lambda with trailing return type 'auto': []() -> auto { return T; }
+  if (Left.is(tok::kw_auto) && Right.getType() == TT_LambdaLBrace)
+return true;
+
   // auto{x} auto(x)
   if (Left.is(tok::kw_auto) && Right.isOneOf(tok::l_paren, tok::l_brace))
 return false;


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -23546,6 +23546,13 @@
   verifyFormat("auto lambda = [ = a]() { a = 2; };", AlignStyle);
 }
 
+TEST_F(FormatTest, LambdaWithTrailingAutoInBracedList) {
+  FormatStyle Style = getLLVMStyle();
+  verifyFormat("auto list = {[]() -> auto { return Val; }};", Style);
+  verifyFormat("auto list = {[]() -> auto * { return Ptr; }};", Style);
+  verifyFormat("auto list = {[]() -> auto & { return Ref; }};", Style);
+}
+
 TEST_F(FormatTest, SpacesInConditionalStatement) {
   FormatStyle Spaces = getLLVMStyle();
   Spaces.IfMacros.clear();
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2108,6 +2108,7 @@
 case tok::l_square:
   parseSquare();
   break;
+case tok::kw_auto:
 case tok::kw_class:
 case tok::kw_template:
 case tok::kw_typename:
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3310,6 +3310,10 @@
 }
   }
 
+  // Lambda with trailing return type 'auto': []() -> auto { return T; }
+  if (Left.is(tok::kw_auto) && Right.getType() == TT_LambdaLBrace)
+return true;
+
   // auto{x} auto(x)
   if (Left.is(tok::kw_auto) && Right.isOneOf(tok::l_paren, tok::l_brace))
 return false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129048: Rewording the "static_assert" to static assertion

2022-07-21 Thread Mark de Wever via Phabricator via cfe-commits
Mordante added a comment.

In D129048#3669568 , @aaron.ballman 
wrote:

> In D129048#3669069 , @Mordante 
> wrote:
>
>> In D129048#3668905 , 
>> @aaron.ballman wrote:
>>
>>> In D129048#3668846 , @ldionne 
>>> wrote:
>>>
 In D129048#3668594 , @philnik 
 wrote:

> Also, please wait for #libc  approval 
> next time.

 This, x1000.

 We go through the trouble of having excellent pre-commit testing and 
 automatic review groups assigned to reviews, please don't bypass that.
>>>
>>> We certainly will keep this in mind for the future, thanks for pointing it 
>>> out! However, the precommit CI behavior confused multiple Clang 
>>> contributors (I also thought the bot was misconfigured because Clang tests 
>>> are never run against old Clang versions), the output did not clearly 
>>> identify what was wrong or how to address it, and the difficulties with 
>>> testing this locally are all things the libc++ maintainers should also keep 
>>> in mind.
>>
>> What can we do to make it easier for Clang contributors to understand the 
>> libc++ CI?
>> Maybe we can discuss it on Discord.
>
> That's a great question to be asking, so thank you! I'm not on Discord (still 
> on IRC though), but I'm happy to chat about it via whatever means works for 
> us.
>
> At a high-level, I think it boils down to familiarity. If we can get the 
> libc++ CI to run as part of precommit CI (assuming precommit CI can be made 
> to run with reliable results, which is a bit of a question mark), then I 
> think that will help get all clang contributors more familiar with the libc++ 
> testing behavior over time, because we'll be far more used to seeing it when 
> we cause a failure. It would have also helped to catch the cause for the 
> initial revert where everyone thought the patch was ready to land. Another 
> thing that would help would be to get the libc++ test bots into the LLVM lab 
> (https://lab.llvm.org/buildbot/#/builders) and ensure that they're sending 
> failure emails to everyone on the blame list including people who land a 
> patch on behalf of others. It looks like we have one builder for libc++, but 
> it doesn't appear to be working recently: 
> https://lab.llvm.org/buildbot/#/builders/156.

As @ldionne said we mainly use a pre-commit CI instead of a post-commit CI. I 
agree that it's probably a lack of familiarity, so let's try to remedy that. 
That will make everybody happier.

I'll reach out to you on IRC either tomorrow or next week. Then we can discuss 
how we can get the clang contributors more familiar with libc++'s way of 
testing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129048

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


[PATCH] D117973: [cmake] Support custom package install paths

2022-07-21 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 added a subscriber: nikic.
Ericson2314 added a comment.

@nikic if you are still around, might you want to review this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117973

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


[PATCH] D117973: [cmake] Support custom package install paths

2022-07-21 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 updated this revision to Diff 446609.
Ericson2314 added a comment.

- Rebase

- Some `set` -> `extend_path`

- Fix spelling / comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117973

Files:
  clang/cmake/modules/CMakeLists.txt
  cmake/Modules/FindPrefixFromConfig.cmake
  cmake/Modules/GNUInstallPackageDir.cmake
  flang/cmake/modules/CMakeLists.txt
  lld/cmake/modules/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake
  llvm/cmake/modules/CMakeLists.txt
  mlir/cmake/modules/CMakeLists.txt
  polly/cmake/CMakeLists.txt

Index: polly/cmake/CMakeLists.txt
===
--- polly/cmake/CMakeLists.txt
+++ polly/cmake/CMakeLists.txt
@@ -1,10 +1,19 @@
 # Keep this in sync with llvm/cmake/CMakeLists.txt!
 
+include(GNUInstallPackageDir)
 include(ExtendPath)
 include(FindPrefixFromConfig)
 
-set(LLVM_INSTALL_PACKAGE_DIR "lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
-set(POLLY_INSTALL_PACKAGE_DIR "lib${LLVM_LIBDIR_SUFFIX}/cmake/polly")
+set(POLLY_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/polly" CACHE STRING
+  "Path for CMake subdirectory for Polly (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/polly')")
+# CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below.
+set(polly_cmake_builddir "${POLLY_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/polly")
+
+set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING
+  "Path for CMake subdirectory for LLVM (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/llvm')")
+# CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below.
+set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
+
 if (CMAKE_CONFIGURATION_TYPES)
   set(POLLY_EXPORTS_FILE_NAME "PollyExports-$>.cmake")
 else()
@@ -28,9 +37,6 @@
   set(POLLY_CONFIG_TARGET_${tgt}_TYPE ${tgt_type})
 endforeach()
 
-set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
-set(POLLY_CONFIG_LLVM_CMAKE_DIR "${llvm_cmake_builddir}")
-
 # generate the import code for bundled/undbundled libisl versions
 if (NOT POLLY_BUNDLED_ISL)
   get_property(incl TARGET ISL PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
@@ -50,7 +56,8 @@
 
 # Generate PollyConfig.cmake for the build tree.
 set(POLLY_CONFIG_CODE "")
-set(POLLY_CONFIG_CMAKE_DIR "${CMAKE_BINARY_DIR}/${POLLY_INSTALL_PACKAGE_DIR}")
+set(POLLY_CONFIG_LLVM_CMAKE_DIR "${llvm_cmake_builddir}")
+set(POLLY_CONFIG_CMAKE_DIR "${polly_cmake_builddir}")
 set(POLLY_CONFIG_INCLUDE_DIRS
   ${POLLY_SOURCE_DIR}/include
   ${ISL_INCLUDE_DIRS}
@@ -73,11 +80,11 @@
 # the imported locations
 configure_file(
   ${CMAKE_CURRENT_SOURCE_DIR}/PollyConfig.cmake.in
-  ${POLLY_CONFIG_CMAKE_DIR}/PollyConfig.cmake
+  ${polly_cmake_builddir}/PollyConfig.cmake
   @ONLY)
 
 file(GENERATE
-  OUTPUT ${POLLY_CONFIG_CMAKE_DIR}/${POLLY_EXPORTS_FILE_NAME}
+  OUTPUT ${polly_cmake_builddir}/${POLLY_EXPORTS_FILE_NAME}
   CONTENT "${POLLY_EXPORTS}")
 
 
Index: mlir/cmake/modules/CMakeLists.txt
===
--- mlir/cmake/modules/CMakeLists.txt
+++ mlir/cmake/modules/CMakeLists.txt
@@ -1,3 +1,4 @@
+include(GNUInstallPackageDir)
 include(ExtendPath)
 include(LLVMDistributionSupport)
 include(FindPrefixFromConfig)
@@ -5,12 +6,16 @@
 # Generate a list of CMake library targets so that other CMake projects can
 # link against them. LLVM calls its version of this file LLVMExports.cmake, but
 # the usual CMake convention seems to be ${Project}Targets.cmake.
-set(MLIR_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/mlir)
-set(mlir_cmake_builddir "${CMAKE_BINARY_DIR}/${MLIR_INSTALL_PACKAGE_DIR}")
+set(MLIR_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/mlir" CACHE STRING
+  "Path for CMake subdirectory for Polly (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/polly')")
+# CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below.
+set(mlir_cmake_builddir "${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/mlir")
 
 # Keep this in sync with llvm/cmake/CMakeLists.txt!
-set(LLVM_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm)
-set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
+set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING
+  "Path for CMake subdirectory for LLVM (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/llvm')")
+# CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below.
+set(llvm_cmake_builddir "${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
 
 get_property(MLIR_EXPORTS GLOBAL PROPERTY MLIR_EXPORTS)
 export(TARGETS ${MLIR_EXPORTS} FILE ${mlir_cmake_builddir}/MLIRTargets.cmake)
@@ -51,8 +56,8 @@
 
 # Generate MLIRConfig.cmake for the install tree.
 find_prefix_from_config(MLIR_CONFIG_CODE MLIR_INSTALL_PREFIX "${MLIR_INSTALL_PACKAGE_DIR}")
-set(MLIR_CONFIG_CMAKE_DIR "\${MLIR_INSTALL_PREFIX}/${MLIR_INSTALL_PACKAGE_DIR}")
-set(MLIR_CONFIG_LLVM_CMAKE_DIR 

[PATCH] D117977: [cmake] Don't export `LLVM_TOOLS_INSTALL_DIR` anymore

2022-07-21 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 added a comment.

Thanks @nikic


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117977

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


[PATCH] D129222: [pseudo] Implement a guard to determine function declarator.

2022-07-21 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

In D129222#3668158 , @sammccall wrote:

> I think what's going on here: outer cmake invokes this opaque external 
> command (which just _happens_ to be cmake --build) to produce an exe. The 
> outer cmake has no special knowledge of what the inner cmake is going to use 
> as inputs, so i it never invalidates the exe and invokes inner cmake again. 
> Having the native exe depend on the target exe is a hack: it means that it 
> (indirectly) depends on the right set of sources and is invalidated when they 
> change. (In a perfect world we wouldn't build the target clang-pseudo-gen at 
> all)

Yeah I agree, I just meant that `build_native_tool` (From 
https://reviews.llvm.org/rG2955192df8ac270515b5fa4aaa9e9380148e7f00) might as 
well just always add this dependency itself. I think that anything that uses it 
and forgets to add this dependency would be a bug anyway.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129222

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


[PATCH] D129973: [clang] Pass FoundDecl to DeclRefExpr creator for operator overloads

2022-07-21 Thread Danny Mösch via Phabricator via cfe-commits
SimplyDanny marked an inline comment as done.
SimplyDanny added inline comments.



Comment at: clang/test/AST/ast-dump-overloaded-operators.cpp:65
+// CHECK-NEXT:   |-ImplicitCastExpr {{.*}}  'void (*)(E, E)' 

+// CHECK-NEXT:   | `-DeclRefExpr {{.*}}  'void (E, E)' lvalue 
Function {{.*}} 'operator-' 'void (E, E)' (UsingShadow {{.*}} 'operator-')
+// CHECK-NEXT:   |-CXXScalarValueInitExpr {{.*}}  'E'

This verifies the AST dump. The new part is the `UsingShadow` at the end of 
this line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129973

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


[PATCH] D129401: [libLTO] Set data-sections by default in libLTO.

2022-07-21 Thread Quinn Pham via Phabricator via cfe-commits
quinnp updated this revision to Diff 446597.
quinnp marked 3 inline comments as done.
quinnp added a comment.

Adressed review comments.

- Modified how `llvm-lto` test-cases check the `llvm-objdump -t` output.
- Renamed `gold-lto-sections.c` to `forwarding-sections-liblto.c` and modified 
the test to use the `RUN` lines from `forwarding-sections-liblto.c` with the 
target specified using `--target=`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129401

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/forwarding-sections-liblto.c
  clang/test/Driver/gold-lto-sections.c
  llvm/lib/LTO/LTOCodeGenerator.cpp
  llvm/test/LTO/PowerPC/data-sections-aix.ll
  llvm/test/LTO/PowerPC/data-sections-linux.ll

Index: llvm/test/LTO/PowerPC/data-sections-linux.ll
===
--- /dev/null
+++ llvm/test/LTO/PowerPC/data-sections-linux.ll
@@ -0,0 +1,21 @@
+; RUN: rm -rf %t
+; RUN: mkdir %t
+; RUN: llvm-as %s -o %t/bc.bc
+; RUN: llvm-lto -exported-symbol var -O0 %t/bc.bc -o %t/default.o
+; RUN: llvm-lto -exported-symbol var -O0 --data-sections=1 %t/bc.bc -o \
+; RUN:   %t/data-sections.o
+; RUN: llvm-lto -exported-symbol var -O0 --data-sections=0 %t/bc.bc -o \
+; RUN:   %t/no-data-sections.o
+; RUN: llvm-objdump -t %t/default.o | FileCheck %s
+; RUN: llvm-objdump -t %t/data-sections.o | FileCheck %s
+; RUN: llvm-objdump -t %t/no-data-sections.o | FileCheck --check-prefix \
+; RUN:   CHECK-NO-DATA-SECTIONS %s
+
+target triple = "powerpc64le-unknown-linux-gnu"
+
+@var = global i32 0
+
+; CHECK:   g O .bss.var {{.*}} var
+
+; CHECK-NO-DATA-SECTIONS-NOT: .var
+; CHECK-NO-DATA-SECTIONS:  g O .bss {{.*}} var
Index: llvm/test/LTO/PowerPC/data-sections-aix.ll
===
--- /dev/null
+++ llvm/test/LTO/PowerPC/data-sections-aix.ll
@@ -0,0 +1,21 @@
+; RUN: rm -rf %t
+; RUN: mkdir %t
+; RUN: llvm-as %s -o %t/bc.bc
+; RUN: llvm-lto -exported-symbol var -O0 %t/bc.bc -o %t/default.o
+; RUN: llvm-lto -exported-symbol var -O0 --data-sections=1 %t/bc.bc -o \
+; RUN:   %t/data-sections.o
+; RUN: llvm-lto -exported-symbol var -O0 --data-sections=0 %t/bc.bc -o \
+; RUN:   %t/no-data-sections.o
+; RUN: llvm-objdump -t %t/default.o | FileCheck %s
+; RUN: llvm-objdump -t %t/data-sections.o | FileCheck %s
+; RUN: llvm-objdump -t %t/no-data-sections.o | FileCheck --check-prefix \
+; RUN:   CHECK-NO-DATA-SECTIONS %s
+
+target triple = "powerpc-ibm-aix7.2.0.0"
+
+@var = global i32 0
+
+; CHECK-NOT:  (csect: .data)
+; CHECK:   g O .data {{.*}} var
+
+; CHECK-NO-DATA-SECTIONS:  g O .data (csect: .data) {{.*}} var
Index: llvm/lib/LTO/LTOCodeGenerator.cpp
===
--- llvm/lib/LTO/LTOCodeGenerator.cpp
+++ llvm/lib/LTO/LTOCodeGenerator.cpp
@@ -19,6 +19,7 @@
 #include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/Analysis/TargetTransformInfo.h"
 #include "llvm/Bitcode/BitcodeWriter.h"
+#include "llvm/CodeGen/CommandFlags.h"
 #include "llvm/CodeGen/ParallelCG.h"
 #include "llvm/CodeGen/TargetSubtargetInfo.h"
 #include "llvm/Config/config.h"
@@ -344,6 +345,11 @@
   Config.CPU = "cyclone";
   }
 
+  // If data-sections is not explicitly set or unset, set data-sections by
+  // default to match the behaviour of lld and gold plugin.
+  if (!codegen::getExplicitDataSections())
+Config.Options.DataSections = true;
+
   TargetMach = createTargetMachine();
   assert(TargetMach && "Unable to create target machine");
 
Index: clang/test/Driver/gold-lto-sections.c
===
--- clang/test/Driver/gold-lto-sections.c
+++ /dev/null
@@ -1,8 +0,0 @@
-// RUN: touch %t.o
-//
-// RUN: %clang -target x86_64-unknown-linux -### %t.o -flto 2>&1 \
-// RUN: -Wl,-plugin-opt=foo -O3 \
-// RUN: -ffunction-sections -fdata-sections \
-// RUN: | FileCheck %s
-// CHECK: "-plugin-opt=-function-sections"
-// CHECK: "-plugin-opt=-data-sections"
Index: clang/test/Driver/forwarding-sections-liblto.c
===
--- /dev/null
+++ clang/test/Driver/forwarding-sections-liblto.c
@@ -0,0 +1,17 @@
+// RUN: touch %t.o
+// RUN: %clang --target=x86_64-unknown-linux -### %t.o -flto 2>&1 | FileCheck %s
+// RUN: %clang --target=x86_64-unknown-linux -### %t.o -flto 2>&1 \
+// RUN:   -ffunction-sections -fdata-sections | FileCheck %s \
+// RUN:   --check-prefix=CHECK-SECTIONS
+// RUN: %clang --target=x86_64-unknown-linux -### %t.o -flto 2>&1 \
+// RUN:   -fno-function-sections -fno-data-sections | FileCheck %s \
+// RUN:   --check-prefix=CHECK-NO-SECTIONS
+
+// CHECK-NOT: "-plugin-opt=-function-sections=1"
+// CHECK-NOT: "-plugin-opt=-function-sections=0"
+// CHECK-NOT: 

[PATCH] D129973: [clang] Pass FoundDecl to DeclRefExpr creator for operator overloads

2022-07-21 Thread Danny Mösch via Phabricator via cfe-commits
SimplyDanny marked an inline comment as done.
SimplyDanny added inline comments.



Comment at: clang/test/Index/annotate-operator-call-expr.cpp:21
+// CHECK1: Punctuation: "(" [7:6 - 7:7] CallExpr=operator():3:7
+// CHECK1: Punctuation: ")" [7:7 - 7:8] CallExpr=operator():3:7
 // CHECK1: Punctuation: ";" [7:8 - 7:9] CompoundStmt=

I updated the test expectation without actually knowing whether the test 
references are correct(er) now. There seems to be some loss of information and 
some `CallExpr`s are now seen as `DeclRefExpr`s. Please tell me if these 
changes are okay. I rather made them to have a basis for discussions.



Comment at: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp:4679
+  EXPECT_TRUE(matches(
+"struct S {}; namespace a { int operator+(S s1, S s2) { return 0; }; } 
using a::operator+; int g() { S a, b; return a + b; }",
+declRefExpr(throughUsingDecl(anything();

shafik wrote:
> You have a trailing `;` after the definition of `a::operator+` please remove 
> it.
Made it a declaration which is sufficient for the test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129973

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


[PATCH] D117977: [cmake] Don't export `LLVM_TOOLS_INSTALL_DIR` anymore

2022-07-21 Thread John Ericson 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 rG07b749800c5c: [cmake] Dont export 
`LLVM_TOOLS_INSTALL_DIR` anymore (authored by Ericson2314).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117977

Files:
  bolt/tools/CMakeLists.txt
  bolt/tools/driver/CMakeLists.txt
  bolt/tools/heatmap/CMakeLists.txt
  bolt/tools/merge-fdata/CMakeLists.txt
  clang/CMakeLists.txt
  clang/cmake/modules/AddClang.cmake
  flang/CMakeLists.txt
  flang/cmake/modules/AddFlang.cmake
  lld/CMakeLists.txt
  lld/cmake/modules/AddLLD.cmake
  llvm/cmake/modules/AddLLVM.cmake
  llvm/cmake/modules/CMakeLists.txt
  llvm/cmake/modules/LLVMConfig.cmake.in
  llvm/cmake/modules/TableGen.cmake
  mlir/CMakeLists.txt
  mlir/cmake/modules/AddMLIR.cmake
  mlir/tools/mlir-cpu-runner/CMakeLists.txt
  mlir/tools/mlir-linalg-ods-gen/CMakeLists.txt
  mlir/tools/mlir-lsp-server/CMakeLists.txt
  mlir/tools/mlir-opt/CMakeLists.txt
  mlir/tools/mlir-pdll-lsp-server/CMakeLists.txt
  mlir/tools/mlir-reduce/CMakeLists.txt
  mlir/tools/mlir-spirv-cpu-runner/CMakeLists.txt
  mlir/tools/mlir-translate/CMakeLists.txt
  mlir/tools/mlir-vulkan-runner/CMakeLists.txt
  mlir/tools/tblgen-lsp-server/CMakeLists.txt
  openmp/libomptarget/tools/CMakeLists.txt
  openmp/libomptarget/tools/deviceinfo/CMakeLists.txt

Index: openmp/libomptarget/tools/deviceinfo/CMakeLists.txt
===
--- openmp/libomptarget/tools/deviceinfo/CMakeLists.txt
+++ openmp/libomptarget/tools/deviceinfo/CMakeLists.txt
@@ -12,7 +12,7 @@
 
 libomptarget_say("Building the llvm-omp-device-info tool")
 
-add_llvm_tool(llvm-omp-device-info llvm-omp-device-info.cpp)
+add_openmp_tool(llvm-omp-device-info llvm-omp-device-info.cpp)
 
 llvm_update_compile_flags(llvm-omp-device-info)
 
Index: openmp/libomptarget/tools/CMakeLists.txt
===
--- openmp/libomptarget/tools/CMakeLists.txt
+++ openmp/libomptarget/tools/CMakeLists.txt
@@ -10,4 +10,18 @@
 #
 ##===--===##
 
+set(OPENMP_TOOLS_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH
+"Path for binary subdirectory (defaults to '${CMAKE_INSTALL_BINDIR}')")
+mark_as_advanced(OPENMP_TOOLS_INSTALL_DIR)
+
+# Move these macros to AddOpenMP if such a CMake module is ever created.
+
+macro(add_openmp_tool name)
+  llvm_add_tool(OPENMP ${ARGV})
+endmacro()
+
+macro(add_openmp_tool_symlink name)
+  llvm_add_tool_symlink(OPENMP ${ARGV})
+endmacro()
+
 add_subdirectory(deviceinfo)
Index: mlir/tools/tblgen-lsp-server/CMakeLists.txt
===
--- mlir/tools/tblgen-lsp-server/CMakeLists.txt
+++ mlir/tools/tblgen-lsp-server/CMakeLists.txt
@@ -2,7 +2,7 @@
   TableGenLspServerLib
   )
 
-add_llvm_tool(tblgen-lsp-server
+add_mlir_tool(tblgen-lsp-server
   tblgen-lsp-server.cpp
 
   DEPENDS
Index: mlir/tools/mlir-vulkan-runner/CMakeLists.txt
===
--- mlir/tools/mlir-vulkan-runner/CMakeLists.txt
+++ mlir/tools/mlir-vulkan-runner/CMakeLists.txt
@@ -88,7 +88,7 @@
 LIST(APPEND targets_to_link "LLVM${t}")
   ENDFOREACH(t)
 
-  add_llvm_tool(mlir-vulkan-runner
+  add_mlir_tool(mlir-vulkan-runner
 mlir-vulkan-runner.cpp
 
 DEPENDS
Index: mlir/tools/mlir-translate/CMakeLists.txt
===
--- mlir/tools/mlir-translate/CMakeLists.txt
+++ mlir/tools/mlir-translate/CMakeLists.txt
@@ -5,7 +5,7 @@
 get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
 get_property(translation_libs GLOBAL PROPERTY MLIR_TRANSLATION_LIBS)
 
-add_llvm_tool(mlir-translate
+add_mlir_tool(mlir-translate
   mlir-translate.cpp
   )
 llvm_update_compile_flags(mlir-translate)
Index: mlir/tools/mlir-spirv-cpu-runner/CMakeLists.txt
===
--- mlir/tools/mlir-spirv-cpu-runner/CMakeLists.txt
+++ mlir/tools/mlir-spirv-cpu-runner/CMakeLists.txt
@@ -5,7 +5,7 @@
 if (MLIR_ENABLE_SPIRV_CPU_RUNNER)
   message(STATUS "Building SPIR-V CPU runner")
 
-  add_llvm_tool(mlir-spirv-cpu-runner
+  add_mlir_tool(mlir-spirv-cpu-runner
 mlir-spirv-cpu-runner.cpp
   )
 
Index: mlir/tools/mlir-reduce/CMakeLists.txt
===
--- mlir/tools/mlir-reduce/CMakeLists.txt
+++ mlir/tools/mlir-reduce/CMakeLists.txt
@@ -17,7 +17,7 @@
   MLIRReduceLib
   )
 
-add_llvm_tool(mlir-reduce
+add_mlir_tool(mlir-reduce
   mlir-reduce.cpp
 
   DEPENDS
Index: mlir/tools/mlir-pdll-lsp-server/CMakeLists.txt
===
--- mlir/tools/mlir-pdll-lsp-server/CMakeLists.txt
+++ mlir/tools/mlir-pdll-lsp-server/CMakeLists.txt
@@ 

[clang] 07b7498 - [cmake] Don't export `LLVM_TOOLS_INSTALL_DIR` anymore

2022-07-21 Thread John Ericson via cfe-commits

Author: John Ericson
Date: 2022-07-21T19:04:00Z
New Revision: 07b749800c5cd4105d49ab46be5f0a2079dd709a

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

LOG: [cmake] Don't export `LLVM_TOOLS_INSTALL_DIR` anymore

First of all, `LLVM_TOOLS_INSTALL_DIR` put there breaks our NixOS
builds, because `LLVM_TOOLS_INSTALL_DIR` defined the same as
`CMAKE_INSTALL_BINDIR` becomes an *absolute* path, and then when
downstream projects try to install there too this breaks because our
builds always install to fresh directories for isolation's sake.

Second of all, note that `LLVM_TOOLS_INSTALL_DIR` stands out against the
other specially crafted `LLVM_CONFIG_*` variables substituted in
`llvm/cmake/modules/LLVMConfig.cmake.in`.

@beanz added it in d0e1c2a550ef348aae036d0fe78cab6f038c420c to fix a
dangling reference in `AddLLVM`, but I am suspicious of how this
variable doesn't follow the pattern.

Those other ones are carefully made to be build-time vs install-time
variables depending on which `LLVMConfig.cmake` is being generated, are
carefully made relative as appropriate, etc. etc. For my NixOS use-case
they are also fine because they are never used as downstream install
variables, only for reading not writing.

To avoid the problems I face, and restore symmetry, I deleted the
exported and arranged to have many `${project}_TOOLS_INSTALL_DIR`s.
`AddLLVM` now instead expects each project to define its own, and they
do so based on `CMAKE_INSTALL_BINDIR`. `LLVMConfig` still exports
`LLVM_TOOLS_BINARY_DIR` which is the location for the tools defined in
the usual way, matching the other remaining exported variables.

For the `AddLLVM` changes, I tried to copy the existing pattern of
internal vs non-internal or for LLVM vs for downstream function/macro
names, but it would good to confirm I did that correctly.

Reviewed By: nikic

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

Added: 


Modified: 
bolt/tools/CMakeLists.txt
bolt/tools/driver/CMakeLists.txt
bolt/tools/heatmap/CMakeLists.txt
bolt/tools/merge-fdata/CMakeLists.txt
clang/CMakeLists.txt
clang/cmake/modules/AddClang.cmake
flang/CMakeLists.txt
flang/cmake/modules/AddFlang.cmake
lld/CMakeLists.txt
lld/cmake/modules/AddLLD.cmake
llvm/cmake/modules/AddLLVM.cmake
llvm/cmake/modules/CMakeLists.txt
llvm/cmake/modules/LLVMConfig.cmake.in
llvm/cmake/modules/TableGen.cmake
mlir/CMakeLists.txt
mlir/cmake/modules/AddMLIR.cmake
mlir/tools/mlir-cpu-runner/CMakeLists.txt
mlir/tools/mlir-linalg-ods-gen/CMakeLists.txt
mlir/tools/mlir-lsp-server/CMakeLists.txt
mlir/tools/mlir-opt/CMakeLists.txt
mlir/tools/mlir-pdll-lsp-server/CMakeLists.txt
mlir/tools/mlir-reduce/CMakeLists.txt
mlir/tools/mlir-spirv-cpu-runner/CMakeLists.txt
mlir/tools/mlir-translate/CMakeLists.txt
mlir/tools/mlir-vulkan-runner/CMakeLists.txt
mlir/tools/tblgen-lsp-server/CMakeLists.txt
openmp/libomptarget/tools/CMakeLists.txt
openmp/libomptarget/tools/deviceinfo/CMakeLists.txt

Removed: 




diff  --git a/bolt/tools/CMakeLists.txt b/bolt/tools/CMakeLists.txt
index 1fe85145d79a1..91b00a5438af3 100644
--- a/bolt/tools/CMakeLists.txt
+++ b/bolt/tools/CMakeLists.txt
@@ -1,3 +1,17 @@
+set(BOLT_TOOLS_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH
+"Path for binary subdirectory (defaults to '${CMAKE_INSTALL_BINDIR}')")
+mark_as_advanced(BOLT_TOOLS_INSTALL_DIR)
+
+# Move these macros to AddBolt if such a CMake module is ever created.
+
+macro(add_bolt_tool name)
+  llvm_add_tool(BOLT ${ARGV})
+endmacro()
+
+macro(add_bolt_tool_symlink name)
+  llvm_add_tool_symlink(BOLT ${ARGV})
+endmacro()
+
 add_subdirectory(driver)
 add_subdirectory(llvm-bolt-fuzzer)
 add_subdirectory(merge-fdata)

diff  --git a/bolt/tools/driver/CMakeLists.txt 
b/bolt/tools/driver/CMakeLists.txt
index 2338ccec11d2b..e56be15dbcff6 100644
--- a/bolt/tools/driver/CMakeLists.txt
+++ b/bolt/tools/driver/CMakeLists.txt
@@ -11,7 +11,7 @@ else()
   set(BOLT_DRIVER_DEPS "")
 endif()
 
-add_llvm_tool(llvm-bolt
+add_bolt_tool(llvm-bolt
   llvm-bolt.cpp
 
   DEPENDS
@@ -25,8 +25,8 @@ target_link_libraries(llvm-bolt
   LLVMBOLTUtils
   )
 
-add_llvm_tool_symlink(perf2bolt llvm-bolt)
-add_llvm_tool_symlink(llvm-bolt
diff  llvm-bolt)
+add_bolt_tool_symlink(perf2bolt llvm-bolt)
+add_bolt_tool_symlink(llvm-bolt
diff  llvm-bolt)
 
 set(BOLT_DEPENDS
   llvm-bolt

diff  --git a/bolt/tools/heatmap/CMakeLists.txt 
b/bolt/tools/heatmap/CMakeLists.txt
index 820b268125e85..cb8e7ee2605c4 100644
--- a/bolt/tools/heatmap/CMakeLists.txt
+++ b/bolt/tools/heatmap/CMakeLists.txt
@@ -5,7 +5,7 @@ set(LLVM_LINK_COMPONENTS
   Support
   )
 
-add_llvm_tool(llvm-bolt-heatmap
+add_bolt_tool(llvm-bolt-heatmap
   heatmap.cpp
   )
 

diff  --git 

[PATCH] D129973: [clang] Pass FoundDecl to DeclRefExpr creator for operator overloads

2022-07-21 Thread Danny Mösch via Phabricator via cfe-commits
SimplyDanny updated this revision to Diff 446592.
SimplyDanny added a comment.
Herald added a subscriber: arphaman.

Added a test for the AST dump and updated some test references.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129973

Files:
  clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/AST/ast-dump-overloaded-operators.cpp
  clang/test/Index/annotate-operator-call-expr.cpp
  clang/test/Index/cursor-ref-names.cpp
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -4675,6 +4675,9 @@
   EXPECT_TRUE(notMatches(
 "namespace a { void f(); } using a::f; void g() { a::f(); }",
 declRefExpr(throughUsingDecl(anything();
+  EXPECT_TRUE(matches(
+"struct S {}; namespace a { int operator+(S s1, S s2); } using a::operator+; int g() { return S() + S(); }",
+declRefExpr(throughUsingDecl(anything();
 }
 
 TEST(SingleDecl, IsSingleDecl) {
Index: clang/test/Index/cursor-ref-names.cpp
===
--- clang/test/Index/cursor-ref-names.cpp
+++ clang/test/Index/cursor-ref-names.cpp
@@ -33,9 +33,9 @@
 // CHECK: cursor-ref-names.cpp:18:5: CallExpr=func:8:10 Extent=[18:5 - 18:16]
 // CHECK: cursor-ref-names.cpp:18:10: MemberRefExpr=func:8:10 SingleRefName=[18:10 - 18:14] RefName=[18:10 - 18:14] Extent=[18:5 - 18:14]
 // CHECK: cursor-ref-names.cpp:18:5: DeclRefExpr=inst:17:9 Extent=[18:5 - 18:9]
-// CHECK: cursor-ref-names.cpp:19:5: CallExpr=operator[]:4:9 SingleRefName=[19:9 - 19:12] RefName=[19:9 - 19:10] RefName=[19:11 - 19:12] Extent=[19:5 - 19:12]
+// CHECK: cursor-ref-names.cpp:19:5: CallExpr=operator[]:4:9 Extent=[19:5 - 19:12] 
 // CHECK: cursor-ref-names.cpp:19:5: DeclRefExpr=inst:17:9 Extent=[19:5 - 19:9]
-// CHECK: cursor-ref-names.cpp:19:9: DeclRefExpr=operator[]:4:9 RefName=[19:9 - 19:10] RefName=[19:11 - 19:12] Extent=[19:9 - 19:12]
+// CHECK: cursor-ref-names.cpp:19:9: DeclRefExpr=operator[]:4:9 Extent=[19:9 - 19:10]
 // CHECK: cursor-ref-names.cpp:20:5: CallExpr=operator[]:4:9 Extent=[20:5 - 20:23]
 // CHECK: cursor-ref-names.cpp:20:10: MemberRefExpr=operator[]:4:9 SingleRefName=[20:10 - 20:20] RefName=[20:10 - 20:18] RefName=[20:18 - 20:19] RefName=[20:19 - 20:20] Extent=[20:5 - 20:20]
 // CHECK: cursor-ref-names.cpp:20:5: DeclRefExpr=inst:17:9 Extent=[20:5 - 20:9]
Index: clang/test/Index/annotate-operator-call-expr.cpp
===
--- clang/test/Index/annotate-operator-call-expr.cpp
+++ clang/test/Index/annotate-operator-call-expr.cpp
@@ -17,68 +17,68 @@
 
 // RUN: c-index-test -test-annotate-tokens=%s:7:1:7:100 %s -std=c++11 -Wno-unused-value | FileCheck %s -check-prefix=CHECK1
 // CHECK1: Identifier: "foo" [7:3 - 7:6] DeclRefExpr=foo:6:18
-// CHECK1: Punctuation: "(" [7:6 - 7:7] DeclRefExpr=operator():3:7 RefName=[7:6 - 7:7] RefName=[7:7 - 7:8]
-// CHECK1: Punctuation: ")" [7:7 - 7:8] DeclRefExpr=operator():3:7 RefName=[7:6 - 7:7] RefName=[7:7 - 7:8]
+// CHECK1: Punctuation: "(" [7:6 - 7:7] CallExpr=operator():3:7
+// CHECK1: Punctuation: ")" [7:7 - 7:8] CallExpr=operator():3:7
 // CHECK1: Punctuation: ";" [7:8 - 7:9] CompoundStmt=
 
 // RUN: c-index-test -test-annotate-tokens=%s:8:1:8:100 %s -std=c++11 -Wno-unused-value | FileCheck %s -check-prefix=CHECK2
-// CHECK2: Punctuation: "(" [8:6 - 8:7] DeclRefExpr=operator():3:7 RefName=[8:6 - 8:7] RefName=[8:12 - 8:13]
+// CHECK2: Punctuation: "(" [8:6 - 8:7] CallExpr=operator():3:7
 // CHECK2: Identifier: "index" [8:7 - 8:12] DeclRefExpr=index:6:27
-// CHECK2: Punctuation: ")" [8:12 - 8:13] DeclRefExpr=operator():3:7 RefName=[8:6 - 8:7] RefName=[8:12 - 8:13]
+// CHECK2: Punctuation: ")" [8:12 - 8:13] CallExpr=operator():3:7
 // CHECK2: Punctuation: ";" [8:13 - 8:14] CompoundStmt=
 
 // RUN: c-index-test -test-annotate-tokens=%s:10:1:10:100 %s -std=c++11 -Wno-unused-value | FileCheck %s -check-prefix=CHECK3
 // CHECK3: Identifier: "foo" [10:3 - 10:6] DeclRefExpr=foo:6:18
-// CHECK3: Punctuation: "[" [10:6 - 10:7] DeclRefExpr=operator[]:2:7 RefName=[10:6 - 10:7] RefName=[10:12 - 10:13]
+// CHECK3: Punctuation: "[" [10:6 - 10:7] CallExpr=operator[]:2:7
 // CHECK3: Identifier: "index" [10:7 - 10:12] DeclRefExpr=index:6:27
-// CHECK3: Punctuation: "]" [10:12 - 10:13] DeclRefExpr=operator[]:2:7 RefName=[10:6 - 10:7] RefName=[10:12 - 10:13]
+// CHECK3: Punctuation: "]" [10:12 - 10:13] CallExpr=operator[]:2:7
 // CHECK3: Punctuation: ";" [10:13 - 10:14] CompoundStmt=
 
 // RUN: c-index-test -test-annotate-tokens=%s:11:1:11:100 %s -std=c++11 -Wno-unused-value | FileCheck %s -check-prefix=CHECK4
 // CHECK4: Identifier: 

[PATCH] D122255: Meta directive runtime support

2022-07-21 Thread Abid via Phabricator via cfe-commits
abidmalikwaterloo marked 4 inline comments as done.
abidmalikwaterloo added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:10852
+def err_omp_misplaced_default_clause : Error<
+  "misplaced default clause! Only one default clause is allowed in"
+  "metadirective in the end">;

jdoerfert wrote:
> ABataev wrote:
> > We do not use explamations in messages, better to have something `only 
> > single default ...`
> "allowed in" what? Also, there is no test for this, or is there?
It should be "Only one default clause is allowed.



Comment at: clang/lib/AST/OpenMPClause.cpp:1679
+  OS << ": ";
+}
+

jdoerfert wrote:
> I'm assuming we already have a printer for trait selectors, no? Doesn't 
> `OMPTraitInfo::print` do this already and actually handle scores?
Looked into the function. `OMPTraitInfo::print` can be used. The function needs 
to be extended as well to take the other traits as well.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:7439
+  }
+}
+

jdoerfert wrote:
> Why does this perform partial trait matching? We should have code for this. 
> Also, the logic for device_arch and vendor (which is most what there is), is 
> not what we want. Reuse the existing matching logic instead.
Ok. What do you mean by `existing matching logic`? 



Comment at: clang/lib/Sema/SemaStmt.cpp:4795
+   
+  CD->setBody(Res->getCapturedStmt());   
   RD->completeDefinition();

jdoerfert wrote:
> Unrelated. Please go over the patch and avoid these in the future. We have so 
> many comments that point out these things that now the comments make it hard 
> to read/review. 
An accidental tap. Removed


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122255

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


[PATCH] D117977: [cmake] Don't export `LLVM_TOOLS_INSTALL_DIR` anymore

2022-07-21 Thread Nikita Popov via Phabricator via cfe-commits
nikic accepted this revision.
nikic added a comment.

Still LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117977

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


[PATCH] D129048: Rewording the "static_assert" to static assertion

2022-07-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D129048#3669069 , @Mordante wrote:

> In D129048#3668905 , @aaron.ballman 
> wrote:
>
>> In D129048#3668846 , @ldionne 
>> wrote:
>>
>>> In D129048#3668594 , @philnik 
>>> wrote:
>>>
 Also, please wait for #libc  approval 
 next time.
>>>
>>> This, x1000.
>>>
>>> We go through the trouble of having excellent pre-commit testing and 
>>> automatic review groups assigned to reviews, please don't bypass that.
>>
>> We certainly will keep this in mind for the future, thanks for pointing it 
>> out! However, the precommit CI behavior confused multiple Clang contributors 
>> (I also thought the bot was misconfigured because Clang tests are never run 
>> against old Clang versions), the output did not clearly identify what was 
>> wrong or how to address it, and the difficulties with testing this locally 
>> are all things the libc++ maintainers should also keep in mind.
>
> What can we do to make it easier for Clang contributors to understand the 
> libc++ CI?
> Maybe we can discuss it on Discord.

That's a great question to be asking, so thank you! I'm not on Discord (still 
on IRC though), but I'm happy to chat about it via whatever means works for us.

At a high-level, I think it boils down to familiarity. If we can get the libc++ 
CI to run as part of precommit CI (assuming precommit CI can be made to run 
with reliable results, which is a bit of a question mark), then I think that 
will help get all clang contributors more familiar with the libc++ testing 
behavior over time, because we'll be far more used to seeing it when we cause a 
failure. It would have also helped to catch the cause for the initial revert 
where everyone thought the patch was ready to land. Another thing that would 
help would be to get the libc++ test bots into the LLVM lab 
(https://lab.llvm.org/buildbot/#/builders) and ensure that they're sending 
failure emails to everyone on the blame list including people who land a patch 
on behalf of others. It looks like we have one builder for libc++, but it 
doesn't appear to be working recently: 
https://lab.llvm.org/buildbot/#/builders/156.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129048

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


[PATCH] D117977: [cmake] Don't export `LLVM_TOOLS_INSTALL_DIR` anymore

2022-07-21 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 added a comment.

https://reviews.llvm.org/D130254 oh yay I learned from this the openmp failure 
is in fact spurious!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117977

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


[PATCH] D117973: [cmake] Support custom package install paths

2022-07-21 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 added a comment.

https://reviews.llvm.org/D130254 oh yay I learned from this the openmp failure 
is in fact spurious!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117973

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


[PATCH] D130254: [CMake][Clang] Copy folder without permissions

2022-07-21 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 added a comment.

LGMT. Also thanks I saw the same failures and was worried they were not 
spurious on my own patch. Glad to know they are!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130254

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


[PATCH] D130210: [SemaCXX] Set promotion type for enum if its type is promotable to integer type even if it has no definition.

2022-07-21 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu added a comment.

In D130210#3669464 , @aaron.ballman 
wrote:

> LGTM, though you should add a release note to clang/docs/ReleaseNotes.rst for 
> the bug fix. Thank you!

Added a release note.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130210

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


[PATCH] D130210: [SemaCXX] Set promotion type for enum if its type is promotable to integer type even if it has no definition.

2022-07-21 Thread Zequan Wu 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 rGd870a575631d: [SemaCXX] Set promotion type for enum if its 
type is promotable to integer type… (authored by zequanwu).

Changed prior to commit:
  https://reviews.llvm.org/D130210?vs=446551=446584#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130210

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CXX/conv/conv.prom/p4.cpp


Index: clang/test/CXX/conv/conv.prom/p4.cpp
===
--- clang/test/CXX/conv/conv.prom/p4.cpp
+++ clang/test/CXX/conv/conv.prom/p4.cpp
@@ -26,3 +26,10 @@
   // FIXME: DR1407 will make this ill-formed
   e = +false_ // desired-error {{conversion from 'int' to 'bool'}}
 };
+
+namespace GH56560 {
+enum GH56560_1 : bool;
+bool GH56560_2(GH56560_1 a, GH56560_1 b) {
+return a == b;
+}
+} // namespace GH56560
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -16209,7 +16209,10 @@
   ED->setIntegerTypeSourceInfo(TI);
 else
   ED->setIntegerType(QualType(EnumUnderlying.get(), 0));
-ED->setPromotionType(ED->getIntegerType());
+QualType EnumTy = ED->getIntegerType();
+ED->setPromotionType(EnumTy->isPromotableIntegerType()
+ ? Context.getPromotedIntegerType(EnumTy)
+ : EnumTy);
   }
 } else { // struct/union
   New = RecordDecl::Create(Context, Kind, SearchDC, KWLoc, Loc, Name,
@@ -16831,8 +16834,11 @@
   if (TypeSourceInfo *TI = EnumUnderlying.dyn_cast())
 ED->setIntegerTypeSourceInfo(TI);
   else
-ED->setIntegerType(QualType(EnumUnderlying.get(), 0));
-  ED->setPromotionType(ED->getIntegerType());
+ED->setIntegerType(QualType(EnumUnderlying.get(), 0));
+  QualType EnumTy = ED->getIntegerType();
+  ED->setPromotionType(EnumTy->isPromotableIntegerType()
+   ? Context.getPromotedIntegerType(EnumTy)
+   : EnumTy);
   assert(ED->isComplete() && "enum with type should be complete");
 }
   } else {
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -192,6 +192,8 @@
   Fixes `Issue 56310 `_.
 - Clang will now look through type sugar when checking a member function is a
   move assignment operator. Fixes `Issue 56456 
`_.
+- Fixed a crash when a variable with a bool enum type that has no definition
+  used in comparison operators. Fixes `Issue 56560 
`_.
 
 Improvements to Clang's diagnostics
 ^^^


Index: clang/test/CXX/conv/conv.prom/p4.cpp
===
--- clang/test/CXX/conv/conv.prom/p4.cpp
+++ clang/test/CXX/conv/conv.prom/p4.cpp
@@ -26,3 +26,10 @@
   // FIXME: DR1407 will make this ill-formed
   e = +false_ // desired-error {{conversion from 'int' to 'bool'}}
 };
+
+namespace GH56560 {
+enum GH56560_1 : bool;
+bool GH56560_2(GH56560_1 a, GH56560_1 b) {
+return a == b;
+}
+} // namespace GH56560
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -16209,7 +16209,10 @@
   ED->setIntegerTypeSourceInfo(TI);
 else
   ED->setIntegerType(QualType(EnumUnderlying.get(), 0));
-ED->setPromotionType(ED->getIntegerType());
+QualType EnumTy = ED->getIntegerType();
+ED->setPromotionType(EnumTy->isPromotableIntegerType()
+ ? Context.getPromotedIntegerType(EnumTy)
+ : EnumTy);
   }
 } else { // struct/union
   New = RecordDecl::Create(Context, Kind, SearchDC, KWLoc, Loc, Name,
@@ -16831,8 +16834,11 @@
   if (TypeSourceInfo *TI = EnumUnderlying.dyn_cast())
 ED->setIntegerTypeSourceInfo(TI);
   else
-ED->setIntegerType(QualType(EnumUnderlying.get(), 0));
-  ED->setPromotionType(ED->getIntegerType());
+ED->setIntegerType(QualType(EnumUnderlying.get(), 0));
+  QualType EnumTy = ED->getIntegerType();
+  ED->setPromotionType(EnumTy->isPromotableIntegerType()
+   ? Context.getPromotedIntegerType(EnumTy)
+   : EnumTy);
   assert(ED->isComplete() && "enum with type should be complete");
 }
   } else {
Index: clang/docs/ReleaseNotes.rst

[clang] d870a57 - [SemaCXX] Set promotion type for enum if its type is promotable to integer type even if it has no definition.

2022-07-21 Thread Zequan Wu via cfe-commits

Author: Zequan Wu
Date: 2022-07-21T11:23:21-07:00
New Revision: d870a575631d2cedab2ff237af8edd17916edc64

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

LOG: [SemaCXX] Set promotion type for enum if its type is promotable to integer 
type even if it has no definition.

EnumDecl's promotion type is set either to the parsed type or calculated type
after completing its definition. When it's bool type and has no definition,
its promotion type is bool which is not allowed by clang.

Fixes #56560.

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaDecl.cpp
clang/test/CXX/conv/conv.prom/p4.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index cb64cd21fe853..d65fcdbeaa62d 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -192,6 +192,8 @@ Bug Fixes
   Fixes `Issue 56310 `_.
 - Clang will now look through type sugar when checking a member function is a
   move assignment operator. Fixes `Issue 56456 
`_.
+- Fixed a crash when a variable with a bool enum type that has no definition
+  used in comparison operators. Fixes `Issue 56560 
`_.
 
 Improvements to Clang's diagnostics
 ^^^

diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 736c299f38bb8..8d2fc5331a0df 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -16209,7 +16209,10 @@ Decl *Sema::ActOnTag(Scope *S, unsigned TagSpec, 
TagUseKind TUK,
   ED->setIntegerTypeSourceInfo(TI);
 else
   ED->setIntegerType(QualType(EnumUnderlying.get(), 0));
-ED->setPromotionType(ED->getIntegerType());
+QualType EnumTy = ED->getIntegerType();
+ED->setPromotionType(EnumTy->isPromotableIntegerType()
+ ? Context.getPromotedIntegerType(EnumTy)
+ : EnumTy);
   }
 } else { // struct/union
   New = RecordDecl::Create(Context, Kind, SearchDC, KWLoc, Loc, Name,
@@ -16831,8 +16834,11 @@ Decl *Sema::ActOnTag(Scope *S, unsigned TagSpec, 
TagUseKind TUK,
   if (TypeSourceInfo *TI = EnumUnderlying.dyn_cast())
 ED->setIntegerTypeSourceInfo(TI);
   else
-ED->setIntegerType(QualType(EnumUnderlying.get(), 0));
-  ED->setPromotionType(ED->getIntegerType());
+ED->setIntegerType(QualType(EnumUnderlying.get(), 0));
+  QualType EnumTy = ED->getIntegerType();
+  ED->setPromotionType(EnumTy->isPromotableIntegerType()
+   ? Context.getPromotedIntegerType(EnumTy)
+   : EnumTy);
   assert(ED->isComplete() && "enum with type should be complete");
 }
   } else {

diff  --git a/clang/test/CXX/conv/conv.prom/p4.cpp 
b/clang/test/CXX/conv/conv.prom/p4.cpp
index 8c86d2a1838da..be422f362d6e3 100644
--- a/clang/test/CXX/conv/conv.prom/p4.cpp
+++ b/clang/test/CXX/conv/conv.prom/p4.cpp
@@ -26,3 +26,10 @@ enum B2 : bool {
   // FIXME: DR1407 will make this ill-formed
   e = +false_ // desired-error {{conversion from 'int' to 'bool'}}
 };
+
+namespace GH56560 {
+enum GH56560_1 : bool;
+bool GH56560_2(GH56560_1 a, GH56560_1 b) {
+return a == b;
+}
+} // namespace GH56560



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


[PATCH] D129311: [clang-format] Update return code

2022-07-21 Thread Sridhar Gopinath via Phabricator via cfe-commits
sridhar_gopinath marked 2 inline comments as done.
sridhar_gopinath added inline comments.



Comment at: clang/tools/clang-format/git-clang-format:579
 with temporary_index_file(old_tree):
-  subprocess.check_call(['git', 'checkout', '--patch', new_tree])
+  subprocess.run(['git', 'checkout', '--patch', new_tree], check=True)
 index_tree = old_tree

owenpan wrote:
> Good catch with `check=True`. Should we add it to the other two instances of 
> `run()` above?
Not really. We want the above two commands to return non-zero exit code when 
there is a diff. Adding `check=True` will crash the process in such cases.



Comment at: clang/tools/clang-format/git-clang-format:539-540
   # filter.
-  subprocess.check_call(['git', 'diff', '--diff-filter=M', old_tree, new_tree,
- '--'])
+  subprocess.check_call(['git', 'diff', '--diff-filter=M',
+old_tree, new_tree, '--exit-code', '--'])
 

owenpan wrote:
> sridhar_gopinath wrote:
> > owenpan wrote:
> > > `--exit-code` is implied?
> > `--exit-code` is not implied. From the docs:
> > ```
> > --exit-code
> > Make the program exit with codes similar to diff(1). That is, it exits with 
> > 1 if there were differences and 0 means no differences.
> > ```
> > `--exit-code` is not implied. From the docs:
> > ```
> > --exit-code
> > Make the program exit with codes similar to diff(1). That is, it exits with 
> > 1 if there were differences and 0 means no differences.
> > ```
> 
> From 
> https://git-scm.com/docs/git-diff#Documentation/git-diff.txt-emgitdiffemltoptionsgt--no-index--ltpathgtltpathgt:
> ```
> git diff [] --no-index [--]  
> This form is to compare the given two paths on the filesystem. You can omit 
> the --no-index option when running the command in a working tree controlled 
> by Git and at least one of the paths points outside the working tree, or when 
> running the command outside a working tree controlled by Git. This form 
> implies --exit-code.
> ```
This seems to be an incorrect usage of `--` in the git-diff command.

`--` is used in git-diff to diff between two paths. In such cases, 
`--exit-code` is implied. But when diffing two commits, `--` is not needed. In 
this script, git-diff is used only on commits. The `old-tree` and `new-tree` 
variables point to git-tree hashes. Hence, using `--` on the git hashes is 
incorrect as git tries to interpret the hashes as file names. This issue was 
not seen earlier because it was added at the end of the command and was being 
omitted.

Now, since the git-diff is not on paths, `--exit-code` is not implied. For diff 
of hashes, `--exit-code` has to be specified explicitely.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129311

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


[PATCH] D130254: [CMake][Clang] Copy folder without permissions

2022-07-21 Thread Tom Stellard via Phabricator via cfe-commits
tstellar accepted this revision.
tstellar added a comment.
This revision is now accepted and ready to land.

LGTM.

Those pre-commit failure seem to be unrelated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130254

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


[PATCH] D129311: [clang-format] Update return code

2022-07-21 Thread Sridhar Gopinath via Phabricator via cfe-commits
sridhar_gopinath updated this revision to Diff 446581.
sridhar_gopinath added a comment.

Removed '--' in the git-diff commands as it only applies to files
and not commits.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129311

Files:
  clang/tools/clang-format/git-clang-format


Index: clang/tools/clang-format/git-clang-format
===
--- clang/tools/clang-format/git-clang-format
+++ clang/tools/clang-format/git-clang-format
@@ -198,16 +198,16 @@
 return 0
 
   if opts.diff:
-print_diff(old_tree, new_tree)
-  elif opts.diffstat:
-print_diffstat(old_tree, new_tree)
-  else:
-changed_files = apply_changes(old_tree, new_tree, force=opts.force,
-  patch_mode=opts.patch)
-if (opts.verbose >= 0 and not opts.patch) or opts.verbose >= 1:
-  print('changed files:')
-  for filename in changed_files:
-print('%s' % filename)
+return print_diff(old_tree, new_tree)
+  if opts.diffstat:
+return print_diffstat(old_tree, new_tree)
+
+  changed_files = apply_changes(old_tree, new_tree, force=opts.force,
+patch_mode=opts.patch)
+  if (opts.verbose >= 0 and not opts.patch) or opts.verbose >= 1:
+print('changed files:')
+for filename in changed_files:
+  print('%s' % filename)
 
   return 1
 
@@ -536,8 +536,8 @@
   # We also only print modified files since `new_tree` only contains the files
   # that were modified, so unmodified files would show as deleted without the
   # filter.
-  subprocess.check_call(['git', 'diff', '--diff-filter=M', old_tree, new_tree,
- '--'])
+  return subprocess.run(['git', 'diff', '--diff-filter=M',
+'--exit-code', old_tree, new_tree]).returncode
 
 def print_diffstat(old_tree, new_tree):
   """Print the diffstat between the two trees to stdout."""
@@ -548,8 +548,8 @@
   # We also only print modified files since `new_tree` only contains the files
   # that were modified, so unmodified files would show as deleted without the
   # filter.
-  subprocess.check_call(['git', 'diff', '--diff-filter=M', '--stat', old_tree, 
new_tree,
- '--'])
+  return subprocess.run(['git', 'diff', '--diff-filter=M', '--exit-code',
+ '--stat', old_tree, new_tree]).returncode
 
 def apply_changes(old_tree, new_tree, force=False, patch_mode=False):
   """Apply the changes in `new_tree` to the working directory.
@@ -575,7 +575,7 @@
 # better message, "Apply ... to index and worktree".  This is not quite
 # right, since it won't be applied to the user's index, but oh well.
 with temporary_index_file(old_tree):
-  subprocess.check_call(['git', 'checkout', '--patch', new_tree])
+  subprocess.run(['git', 'checkout', '--patch', new_tree], check=True)
 index_tree = old_tree
   else:
 with temporary_index_file(new_tree):


Index: clang/tools/clang-format/git-clang-format
===
--- clang/tools/clang-format/git-clang-format
+++ clang/tools/clang-format/git-clang-format
@@ -198,16 +198,16 @@
 return 0
 
   if opts.diff:
-print_diff(old_tree, new_tree)
-  elif opts.diffstat:
-print_diffstat(old_tree, new_tree)
-  else:
-changed_files = apply_changes(old_tree, new_tree, force=opts.force,
-  patch_mode=opts.patch)
-if (opts.verbose >= 0 and not opts.patch) or opts.verbose >= 1:
-  print('changed files:')
-  for filename in changed_files:
-print('%s' % filename)
+return print_diff(old_tree, new_tree)
+  if opts.diffstat:
+return print_diffstat(old_tree, new_tree)
+
+  changed_files = apply_changes(old_tree, new_tree, force=opts.force,
+patch_mode=opts.patch)
+  if (opts.verbose >= 0 and not opts.patch) or opts.verbose >= 1:
+print('changed files:')
+for filename in changed_files:
+  print('%s' % filename)
 
   return 1
 
@@ -536,8 +536,8 @@
   # We also only print modified files since `new_tree` only contains the files
   # that were modified, so unmodified files would show as deleted without the
   # filter.
-  subprocess.check_call(['git', 'diff', '--diff-filter=M', old_tree, new_tree,
- '--'])
+  return subprocess.run(['git', 'diff', '--diff-filter=M',
+'--exit-code', old_tree, new_tree]).returncode
 
 def print_diffstat(old_tree, new_tree):
   """Print the diffstat between the two trees to stdout."""
@@ -548,8 +548,8 @@
   # We also only print modified files since `new_tree` only contains the files
   # that were modified, so unmodified files would show as deleted without the
   # filter.
-  subprocess.check_call(['git', 'diff', '--diff-filter=M', '--stat', old_tree, new_tree,
- '--'])

[PATCH] D130210: [SemaCXX] Set promotion type for enum if its type is promotable to integer type even if it has no definition.

2022-07-21 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, though you should add a release note to clang/docs/ReleaseNotes.rst for 
the bug fix. Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130210

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


[PATCH] D129536: [CUDA][FIX] Make shfl[_sync] for unsigned long long non-recursive

2022-07-21 Thread Johannes Doerfert 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 rG48d6f5240187: [CUDA][FIX] Make shfl[_sync] for unsigned long 
long non-recursive (authored by jdoerfert).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129536

Files:
  clang/lib/Headers/__clang_cuda_intrinsics.h
  clang/test/CodeGenCUDA/shuffle_long_long.cu


Index: clang/test/CodeGenCUDA/shuffle_long_long.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/shuffle_long_long.cu
@@ -0,0 +1,61 @@
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -emit-llvm 
-target-cpu sm_30 %s -o - | FileCheck %s --check-prefix=NO_SYNC
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -emit-llvm 
-target-cpu sm_30 -target-feature +ptx70 -DSYNC -DCUDA_VERSION=9000 %s -o - | 
FileCheck %s --check-prefix=SYNC
+
+#include "Inputs/cuda.h"
+
+__device__ void *memcpy(void *dest, const void *src, size_t n);
+
+#define warpSize 32
+#include <__clang_cuda_intrinsics.h>
+
+__device__ void use(unsigned long long, long long);
+
+// Test function, 4 shfl calls.
+// NO_SYNC: define{{.*}} @_Z14test_long_longv
+// NO_SYNC: call noundef i64 @_Z6__shflyii(
+// NO_SYNC: call noundef i64 @_Z6__shflxii(
+
+// SYNC: define{{.*}} @_Z14test_long_longv
+// SYNC:call noundef i64 @_Z11__shfl_syncjyii(
+// SYNC:call noundef i64 @_Z11__shfl_syncjxii(
+
+// unsigned long long -> long long
+// NO_SYNC: define{{.*}} @_Z6__shflyii
+// NO_SYNC: call noundef i64 @_Z6__shflxii(
+
+// long long -> int + int
+// NO_SYNC: define{{.*}} @_Z6__shflxii
+// NO_SYNC: call noundef i32 @_Z6__shfliii(
+// NO_SYNC: call noundef i32 @_Z6__shfliii(
+
+// NO_SYNC: define{{.*}} @_Z6__shfliii
+// NO_SYNC:   call i32 @llvm.nvvm.shfl.idx.i32
+
+// unsigned long long -> long long
+// SYNC: _Z11__shfl_syncjyii
+// SYNC: call noundef i64 @_Z11__shfl_syncjxii(
+
+// long long -> int + int
+// SYNC: define{{.*}} @_Z11__shfl_syncjxii
+// SYNC: call noundef i32 @_Z11__shfl_syncjiii(
+// SYNC: call noundef i32 @_Z11__shfl_syncjiii(
+
+// SYNC: define{{.*}} @_Z11__shfl_syncjiii
+// SYNC:  call i32 @llvm.nvvm.shfl.sync.idx.i32
+
+__device__ void test_long_long() {
+  unsigned long long ull = 13;
+  long long ll = 17;
+#ifndef SYNC
+  ull = __shfl(ull, 7, 32);
+  ll = __shfl(ll, 7, 32);
+  use(ull, ll);
+#else
+  ull = __shfl_sync(0x11, ull, 7, 32);
+  ll = __shfl_sync(0x11, ll, 7, 32);
+  use(ull, ll);
+#endif
+}
+
Index: clang/lib/Headers/__clang_cuda_intrinsics.h
===
--- clang/lib/Headers/__clang_cuda_intrinsics.h
+++ clang/lib/Headers/__clang_cuda_intrinsics.h
@@ -71,8 +71,8 @@
   }
\
   inline __device__ unsigned long long __FnName(   
\
   unsigned long long __val, __Type __offset, int __width = warpSize) { 
\
-return static_cast(::__FnName( 
\
-static_cast(__val), __offset, __width));   
\
+return static_cast(
\
+::__FnName(static_cast(__val), __offset, __width)); 
\
   }
\
   inline __device__ double __FnName(double __val, __Type __offset, 
\
 int __width = warpSize) {  
\
@@ -139,8 +139,8 @@
   inline __device__ unsigned long long __FnName(   
\
   unsigned int __mask, unsigned long long __val, __Type __offset,  
\
   int __width = warpSize) {
\
-return static_cast(::__FnName( 
\
-__mask, static_cast(__val), __offset, __width));   
\
+return static_cast(
\
+::__FnName(__mask, static_cast(__val), __offset, __width)); 
\
   }
\
   inline __device__ long __FnName(unsigned int __mask, long __val, 
\
   __Type __offset, int __width = warpSize) {   
\


Index: clang/test/CodeGenCUDA/shuffle_long_long.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/shuffle_long_long.cu
@@ -0,0 +1,61 @@
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -emit-llvm -target-cpu sm_30 %s -o - | FileCheck %s --check-prefix=NO_SYNC
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -emit-llvm -target-cpu sm_30 -target-feature +ptx70 -DSYNC -DCUDA_VERSION=9000 %s -o - | 

  1   2   3   >