[clang] [RISCV] Update Zicntr and Zihpm to version 2p0 (PR #66323)

2023-09-14 Thread Yueh-Ting Chen via cfe-commits


@@ -629,7 +629,7 @@ TEST(getTargetFeatureForExtension, 
RetrieveTargetFeatureFromOneExt) {
 
 TEST(RiscvExtensionsHelp, CheckExtensions) {
   std::string ExpectedOutput =
-R"(All available -march extensions for RISC-V
+  R"(All available -march extensions for RISC-V

eopXD wrote:

This change doesn't seem necessary

https://github.com/llvm/llvm-project/pull/66323
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D158502: [clang][Interp] Actually consider ConstantExpr result

2023-09-14 Thread Timm Bäder via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG293ae0b4b45f: [clang][Interp] Actually consider ConstantExpr 
result (authored by tbaeder).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158502

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp


Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -634,8 +634,14 @@
 
 template 
 bool ByteCodeExprGen::VisitConstantExpr(const ConstantExpr *E) {
-  // TODO: Check if the ConstantExpr already has a value set and if so,
-  //   use that instead of evaluating it again.
+  // Try to emit the APValue directly, without visiting the subexpr.
+  // This will only fail if we can't emit the APValue, so won't emit any
+  // diagnostics or any double values.
+  std::optional T = classify(E->getType());
+  if (T && E->hasAPValueResult() &&
+  this->visitAPValue(E->getAPValueResult(), *T, E))
+return true;
+
   return this->delegate(E->getSubExpr());
 }
 


Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -634,8 +634,14 @@
 
 template 
 bool ByteCodeExprGen::VisitConstantExpr(const ConstantExpr *E) {
-  // TODO: Check if the ConstantExpr already has a value set and if so,
-  //   use that instead of evaluating it again.
+  // Try to emit the APValue directly, without visiting the subexpr.
+  // This will only fail if we can't emit the APValue, so won't emit any
+  // diagnostics or any double values.
+  std::optional T = classify(E->getType());
+  if (T && E->hasAPValueResult() &&
+  this->visitAPValue(E->getAPValueResult(), *T, E))
+return true;
+
   return this->delegate(E->getSubExpr());
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D158169: [X86] Fix i128 argument passing under SysV ABI

2023-09-14 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

In D158169#4645012 , @RalfJung wrote:

>> I think the CCIfSplit means it was larger than i64 to start.
>
> What about the case where `R9` would take the *second* half of a split i128 
> (i.e., the value gets split across `R8` and `R9`)? Does that still work after 
> this patch?

Yes, this is the case tested in `@in_reg`. `CCIfSplit` only matches the first 
part of a split value, not all parts of it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158169

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


[clang] Extend `retcon.once` coroutines lowering to optionally produce a normal result (PR #66333)

2023-09-14 Thread Anton Korobeynikov via cfe-commits

https://github.com/asl edited https://github.com/llvm/llvm-project/pull/66333
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Extend `retcon.once` coroutines lowering to optionally produce a normal result (PR #66333)

2023-09-14 Thread Chuanqi Xu via cfe-commits




ChuanqiXu9 wrote:

It looks like we need to touch  the section `Returned-Continuation Lowering` too

https://github.com/llvm/llvm-project/pull/66333
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Extend `retcon.once` coroutines lowering to optionally produce a normal result (PR #66333)

2023-09-14 Thread Chuanqi Xu via cfe-commits


@@ -3046,7 +3046,8 @@ void coro::buildCoroutineFrame(
   // Collect the spills for arguments and other not-materializable values.
   for (Argument &A : F.args())
 for (User *U : A.users())
-  if (Checker.isDefinitionAcrossSuspend(A, U))
+  if (Checker.isDefinitionAcrossSuspend(A, U) ||
+  isa(U))

ChuanqiXu9 wrote:

We do we need to include CoroEnd explicitly here?

https://github.com/llvm/llvm-project/pull/66333
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Replace llvm.memcpy et al's i1 isVolatile with i8 VolFlags (PR #65748)

2023-09-14 Thread Nikita Popov via cfe-commits

https://github.com/nikic review_request_removed 
https://github.com/llvm/llvm-project/pull/65748
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Replace llvm.memcpy et al's i1 isVolatile with i8 VolFlags (PR #65748)

2023-09-14 Thread Nikita Popov via cfe-commits

https://github.com/nikic review_request_removed 
https://github.com/llvm/llvm-project/pull/65748
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Replace llvm.memcpy et al's i1 isVolatile with i8 VolFlags (PR #65748)

2023-09-14 Thread Nikita Popov via cfe-commits

https://github.com/nikic review_request_removed 
https://github.com/llvm/llvm-project/pull/65748
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Replace llvm.memcpy et al's i1 isVolatile with i8 VolFlags (PR #65748)

2023-09-14 Thread Nikita Popov via cfe-commits

https://github.com/nikic review_requested 
https://github.com/llvm/llvm-project/pull/65748
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix CXXRewrittenBinaryOperator::getDecomposedForm to handle case when spaceship operator returns comparison category by reference (PR #66270)

2023-09-14 Thread Mariya Podchishchaeva via cfe-commits

https://github.com/Fznamznon commented:

Perhaps it needs a release note?

https://github.com/llvm/llvm-project/pull/66270
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix CXXRewrittenBinaryOperator::getDecomposedForm to handle case when spaceship operator returns comparison category by reference (PR #66270)

2023-09-14 Thread Mariya Podchishchaeva via cfe-commits

https://github.com/Fznamznon review_requested 
https://github.com/llvm/llvm-project/pull/66270
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [RISCV] Install sifive_vector.h to riscv-resource-headers (PR #66330)

2023-09-14 Thread Yueh-Ting Chen via cfe-commits

eopXD wrote:

> > Maybe test coverage with `-I %resource_dir`?
> 
> Which file should I place the test?

`clang/test/Headers/`

https://github.com/llvm/llvm-project/pull/66330
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Update GoogleTest to v1.14.0 (PR #65823)

2023-09-14 Thread via cfe-commits

mikaelholmen wrote:

I see compilation problems with this patch.
By mistake I originally posted about the problems in
https://github.com/llvm/llvm-project/issues/66268#issuecomment-1718791073

So the problem: On a RHEL7 server we see stuff like:
`
In file included from 
/repo/uabelho/dev-main/compiler-rt/lib/memprof/tests/driver.cpp:9:
In file included from 
/repo/uabelho/dev-main/runtimes/../third-party/unittest/googletest/include/gtest/gtest.h:65:
In file included from 
/repo/uabelho/dev-main/runtimes/../third-party/unittest/googletest/include/gtest/gtest-death-test.h:43:
In file included from 
/repo/uabelho/dev-main/runtimes/../third-party/unittest/googletest/include/gtest/internal/gtest-death-test-internal.h:47:
/repo/uabelho/dev-main/runtimes/../third-party/unittest/googletest/include/gtest/gtest-matchers.h:728:50:
 error: too few template arguments for class template 'equal_to'
  728 |   : ComparisonBase, Rhs, std::equal_to<>>(rhs) {}
  |  ^
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/bits/stl_function.h:204:12:
 note: template is declared here
  203 |   template
  |   ~~
  204 | struct equal_to : public binary_function<_Tp, _Tp, bool>
  |^
`
so it looks like it's when it's using the newly built clang to compile 
 compiler-rt/lib/memprof/tests/driver.cpp
it's using header files from the host and those headers are too old for the 
updated GoogleTest.

If we don't build builtins (LLVM_BUILTIN_TARGETS) I don't see any problems.




https://github.com/llvm/llvm-project/pull/65823
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 84216d1 - [clang] Don't inherit dllimport/dllexport to exclude_from_explicit_instantiation members during explicit instantiation (#65961)

2023-09-14 Thread via cfe-commits

Author: Hans
Date: 2023-09-14T10:20:01+02:00
New Revision: 84216d17359fcf6c314726d9f8d0416f8118d968

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

LOG: [clang] Don't inherit dllimport/dllexport to 
exclude_from_explicit_instantiation members during explicit instantiation 
(#65961)

This is a continuation of https://reviews.llvm.org/D155713

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

Added: 
clang/test/CodeGenCXX/attr-exclude_from_explicit_instantiation.dllimport.cpp
clang/test/SemaCXX/attr-exclude_from_explicit_instantiation.dllimport.cpp

Modified: 
clang/lib/Sema/SemaDeclCXX.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 2b2b7391f88fd54..1f2bb1edd3b7be5 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -6602,6 +6602,13 @@ void Sema::checkClassLevelDLLAttribute(CXXRecordDecl 
*Class) {
 if (!VD && !MD)
   continue;
 
+if ((TSK == TSK_ExplicitInstantiationDeclaration ||
+ TSK == TSK_ExplicitInstantiationDefinition) &&
+Member->hasAttr()) {
+  // Skip members excluded from instantiation.
+  continue;
+}
+
 if (MD) {
   // Don't process deleted methods.
   if (MD->isDeleted())

diff  --git 
a/clang/test/CodeGenCXX/attr-exclude_from_explicit_instantiation.dllimport.cpp 
b/clang/test/CodeGenCXX/attr-exclude_from_explicit_instantiation.dllimport.cpp
new file mode 100644
index 000..b3c804839be1ee4
--- /dev/null
+++ 
b/clang/test/CodeGenCXX/attr-exclude_from_explicit_instantiation.dllimport.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-windows -fms-extensions -emit-llvm 
-O0 -o - %s | FileCheck %s
+
+// Test that dllimport and exclude_from_explicit_instantiation work properly
+// together. Specifically, we check that when 
exclude_from_explicit_instantiation
+// is used on a method, the compiler doesn't expect it to be provided 
externally
+// even if it is marked with dllimport.
+//
+// https://github.com/llvm/llvm-project/issues/40363
+
+#define DLLIMPORT __declspec(dllimport)
+#define DLLEXPORT __declspec(dllexport)
+#define EXCLUDE_FROM_EXPLICIT_INSTANTIATION 
__attribute__((exclude_from_explicit_instantiation))
+
+template 
+struct DLLIMPORT Foo {
+  EXCLUDE_FROM_EXPLICIT_INSTANTIATION void x() {}
+};
+
+template 
+struct Bar {
+  EXCLUDE_FROM_EXPLICIT_INSTANTIATION void x() {}
+};
+
+extern template struct Foo;
+extern template struct DLLIMPORT Bar;
+
+
+template 
+struct Baz {
+  EXCLUDE_FROM_EXPLICIT_INSTANTIATION void f() {}
+};
+
+template struct DLLEXPORT Baz;
+
+
+void test(Foo& foo, Bar& bar, Baz& baz) {
+  // Not imported.
+  // CHECK-DAG: define linkonce_odr dso_local void @"?x@?$Foo@H@@QEAAXXZ"
+  foo.x();
+
+  // Not imported.
+  // CHECK-DAG: define linkonce_odr dso_local void @"?x@?$Bar@H@@QEAAXXZ"
+  bar.x();
+
+  // Not exported.
+  // CHECK-DAG: define linkonce_odr dso_local void @"?f@?$Baz@H@@QEAAXXZ"
+  baz.f();
+}

diff  --git 
a/clang/test/SemaCXX/attr-exclude_from_explicit_instantiation.dllimport.cpp 
b/clang/test/SemaCXX/attr-exclude_from_explicit_instantiation.dllimport.cpp
new file mode 100644
index 000..bdca2d8895f516c
--- /dev/null
+++ b/clang/test/SemaCXX/attr-exclude_from_explicit_instantiation.dllimport.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-windows -fms-extensions -verify %s
+
+// Test that an entity marked as both dllimport and 
exclude_from_explicit_instantiation
+// isn't instantiated.
+
+#define DLLIMPORT __declspec(dllimport)
+#define EXCLUDE_FROM_EXPLICIT_INSTANTIATION 
__attribute__((exclude_from_explicit_instantiation))
+
+template 
+struct DLLIMPORT Foo {
+  EXCLUDE_FROM_EXPLICIT_INSTANTIATION void x();
+};
+
+template 
+struct Bar {
+  DLLIMPORT EXCLUDE_FROM_EXPLICIT_INSTANTIATION inline void x();
+};
+
+template 
+void Foo::x() { using Fail = typename T::fail; }
+
+template 
+DLLIMPORT inline void Bar::x() { using Fail = typename T::fail; }
+
+// expected-no-diagnostics
+template struct Foo;
+template struct Bar;



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


[clang] [clang] Don't inherit dllimport/dllexport to exclude_from_explicit_in… (PR #65961)

2023-09-14 Thread via cfe-commits

https://github.com/zmodem closed https://github.com/llvm/llvm-project/pull/65961
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [NFC] Minimize header includes (PR #66339)

2023-09-14 Thread Bill Wendling via cfe-commits

https://github.com/bwendling created 
https://github.com/llvm/llvm-project/pull/66339:

Minimize the headers included in header files to reduce the number of files 
that need recompiled after a change.

>From fafc158270aa454253d885111c297ab0aaaca7dc Mon Sep 17 00:00:00 2001
From: Bill Wendling 
Date: Thu, 14 Sep 2023 01:21:51 -0700
Subject: [PATCH] [NFC] Minimize header includes

Minimize the headers included in header files to reduce the number of
files that need recompiled after a change.
---
 .../include/clang/Basic/AttrSubjectMatchRules.h  |  4 +++-
 clang/include/clang/Basic/AttributeCommonInfo.h  |  4 +++-
 clang/include/clang/Basic/Attributes.h   |  4 ++--
 clang/lib/Basic/Attributes.cpp   | 16 +++-
 clang/lib/Basic/IdentifierTable.cpp  |  4 +---
 clang/lib/Parse/ParseStmt.cpp|  1 +
 6 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/clang/include/clang/Basic/AttrSubjectMatchRules.h 
b/clang/include/clang/Basic/AttrSubjectMatchRules.h
index e3dcb943e59d424..bec8122ea930a6a 100644
--- a/clang/include/clang/Basic/AttrSubjectMatchRules.h
+++ b/clang/include/clang/Basic/AttrSubjectMatchRules.h
@@ -9,10 +9,12 @@
 #ifndef LLVM_CLANG_BASIC_ATTRSUBJECTMATCHRULES_H
 #define LLVM_CLANG_BASIC_ATTRSUBJECTMATCHRULES_H
 
-#include "clang/Basic/SourceLocation.h"
 #include "llvm/ADT/DenseMap.h"
 
 namespace clang {
+
+class SourceRange;
+
 namespace attr {
 
 /// A list of all the recognized kinds of attributes.
diff --git a/clang/include/clang/Basic/AttributeCommonInfo.h 
b/clang/include/clang/Basic/AttributeCommonInfo.h
index e57adc4bf5b99a2..7dc05418498d0ae 100644
--- a/clang/include/clang/Basic/AttributeCommonInfo.h
+++ b/clang/include/clang/Basic/AttributeCommonInfo.h
@@ -13,12 +13,14 @@
 
 #ifndef LLVM_CLANG_BASIC_ATTRIBUTECOMMONINFO_H
 #define LLVM_CLANG_BASIC_ATTRIBUTECOMMONINFO_H
+
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/TokenKinds.h"
 
 namespace clang {
-class IdentifierInfo;
+
 class ASTRecordWriter;
+class IdentifierInfo;
 
 class AttributeCommonInfo {
 public:
diff --git a/clang/include/clang/Basic/Attributes.h 
b/clang/include/clang/Basic/Attributes.h
index 3fc5fbacdb2cbd6..61666a6f4d9ac4a 100644
--- a/clang/include/clang/Basic/Attributes.h
+++ b/clang/include/clang/Basic/Attributes.h
@@ -10,12 +10,12 @@
 #define LLVM_CLANG_BASIC_ATTRIBUTES_H
 
 #include "clang/Basic/AttributeCommonInfo.h"
-#include "clang/Basic/LangOptions.h"
-#include "clang/Basic/TargetInfo.h"
 
 namespace clang {
 
 class IdentifierInfo;
+class LangOptions;
+class TargetInfo;
 
 /// Return the version number associated with the attribute if we
 /// recognize and implement the attribute specified by the given information.
diff --git a/clang/lib/Basic/Attributes.cpp b/clang/lib/Basic/Attributes.cpp
index 1308e2d72f25f5b..bb495216ca93ca5 100644
--- a/clang/lib/Basic/Attributes.cpp
+++ b/clang/lib/Basic/Attributes.cpp
@@ -1,8 +1,22 @@
+//===--- Attributes.cpp 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file implements the AttributeCommonInfo interface.
+//
+//===--===//
+
 #include "clang/Basic/Attributes.h"
 #include "clang/Basic/AttrSubjectMatchRules.h"
-#include "clang/Basic/AttributeCommonInfo.h"
 #include "clang/Basic/IdentifierTable.h"
+#include "clang/Basic/LangOptions.h"
 #include "clang/Basic/ParsedAttrInfo.h"
+#include "clang/Basic/TargetInfo.h"
+
 using namespace clang;
 
 static int hasAttributeImpl(AttributeCommonInfo::Syntax Syntax, StringRef Name,
diff --git a/clang/lib/Basic/IdentifierTable.cpp 
b/clang/lib/Basic/IdentifierTable.cpp
index afb30268f2973ce..e5599d545541085 100644
--- a/clang/lib/Basic/IdentifierTable.cpp
+++ b/clang/lib/Basic/IdentifierTable.cpp
@@ -25,7 +25,6 @@
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Allocator.h"
-#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
@@ -52,8 +51,7 @@ namespace {
 
 /// A simple identifier lookup iterator that represents an
 /// empty sequence of identifiers.
-class EmptyLookupIterator : public IdentifierIterator
-{
+class EmptyLookupIterator : public IdentifierIterator {
 public:
   StringRef Next() override { return StringRef(); }
 };
diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp
index fb883c08a745cfa..2531147c23196ae 100644
--- a/clang/lib/Parse/ParseStmt.cpp
+++ b/clang/lib/Parse/ParseStmt.cpp
@@ -14,6 +14,7 @@
 #include "clang/AST/PrettyDeclStackTrace.h"
 #include "clang/Basic/Attributes.h"
 #include "clang/Basic/PrettyStackTrace.h"
+#include "clang/Bas

[clang] [NFC] Minimize header includes (PR #66339)

2023-09-14 Thread Bill Wendling via cfe-commits

https://github.com/bwendling review_requested 
https://github.com/llvm/llvm-project/pull/66339
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [NFC] Minimize header includes (PR #66339)

2023-09-14 Thread Bill Wendling via cfe-commits

https://github.com/bwendling review_requested 
https://github.com/llvm/llvm-project/pull/66339
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [X86] Align 128/256 variants to use void * as 512 variants. (PR #66310)

2023-09-14 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang approved this pull request.

LGTM.

https://github.com/llvm/llvm-project/pull/66310
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [X86] Align 128/256 variants to use void * as 512 variants. (PR #66310)

2023-09-14 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang edited 
https://github.com/llvm/llvm-project/pull/66310
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [X86] Align 128/256 variants to use void * as 512 variants. (PR #66310)

2023-09-14 Thread Phoebe Wang via cfe-commits


@@ -645,7 +645,7 @@ static __inline__ __m128i __DEFAULT_FN_ATTRS 
_mm_mul_epi32(__m128i __V1,
 /// \returns A 128-bit integer vector containing the data stored at the
 ///specified memory location.
 static __inline__ __m128i __DEFAULT_FN_ATTRS
-_mm_stream_load_si128(__m128i const *__V) {
+_mm_stream_load_si128(void const *__V) {

phoebewang wrote:

Move `const` first?

https://github.com/llvm/llvm-project/pull/66310
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [X86] Align 128/256 variants to use void * as 512 variants. (PR #66310)

2023-09-14 Thread Phoebe Wang via cfe-commits


@@ -2979,7 +2979,7 @@ _mm256_xor_si256(__m256i __a, __m256i __b)
 ///A pointer to the 32-byte aligned memory containing the vector to load.
 /// \returns A 256-bit integer vector loaded from memory.
 static __inline__ __m256i __DEFAULT_FN_ATTRS256
-_mm256_stream_load_si256(__m256i const *__V)
+_mm256_stream_load_si256(void const *__V)

phoebewang wrote:

Move `const` first?

https://github.com/llvm/llvm-project/pull/66310
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [X86] Align 128/256 variants to use void * as 512 variants. (PR #66310)

2023-09-14 Thread Phoebe Wang via cfe-commits


@@ -358,6 +358,12 @@ __m128i test_mm_stream_load_si128(__m128i const *a) {
   return _mm_stream_load_si128(a);
 }
 
+__m128i test_mm_stream_load_si128_void(void const *a) {

phoebewang wrote:

`const void`?

https://github.com/llvm/llvm-project/pull/66310
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [NFC] Minimize header includes (PR #66339)

2023-09-14 Thread via cfe-commits

https://github.com/llvmbot labeled 
https://github.com/llvm/llvm-project/pull/66339
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [NFC] Minimize header includes (PR #66339)

2023-09-14 Thread via cfe-commits

https://github.com/llvmbot labeled 
https://github.com/llvm/llvm-project/pull/66339
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [NFC] Minimize header includes (PR #66339)

2023-09-14 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang


Changes
Minimize the headers included in header files to reduce the number of files 
that need recompiled after a change.
--
Full diff: https://github.com/llvm/llvm-project/pull/66339.diff

6 Files Affected:

- (modified) clang/include/clang/Basic/AttrSubjectMatchRules.h (+3-1) 
- (modified) clang/include/clang/Basic/AttributeCommonInfo.h (+3-1) 
- (modified) clang/include/clang/Basic/Attributes.h (+2-2) 
- (modified) clang/lib/Basic/Attributes.cpp (+15-1) 
- (modified) clang/lib/Basic/IdentifierTable.cpp (+1-3) 
- (modified) clang/lib/Parse/ParseStmt.cpp (+1) 



diff --git a/clang/include/clang/Basic/AttrSubjectMatchRules.h 
b/clang/include/clang/Basic/AttrSubjectMatchRules.h
index e3dcb943e59d424..bec8122ea930a6a 100644
--- a/clang/include/clang/Basic/AttrSubjectMatchRules.h
+++ b/clang/include/clang/Basic/AttrSubjectMatchRules.h
@@ -9,10 +9,12 @@
 #ifndef LLVM_CLANG_BASIC_ATTRSUBJECTMATCHRULES_H
 #define LLVM_CLANG_BASIC_ATTRSUBJECTMATCHRULES_H
 
-#include "clang/Basic/SourceLocation.h"
 #include "llvm/ADT/DenseMap.h"
 
 namespace clang {
+
+class SourceRange;
+
 namespace attr {
 
 /// A list of all the recognized kinds of attributes.
diff --git a/clang/include/clang/Basic/AttributeCommonInfo.h 
b/clang/include/clang/Basic/AttributeCommonInfo.h
index e57adc4bf5b99a2..7dc05418498d0ae 100644
--- a/clang/include/clang/Basic/AttributeCommonInfo.h
+++ b/clang/include/clang/Basic/AttributeCommonInfo.h
@@ -13,12 +13,14 @@
 
 #ifndef LLVM_CLANG_BASIC_ATTRIBUTECOMMONINFO_H
 #define LLVM_CLANG_BASIC_ATTRIBUTECOMMONINFO_H
+
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/TokenKinds.h"
 
 namespace clang {
-class IdentifierInfo;
+
 class ASTRecordWriter;
+class IdentifierInfo;
 
 class AttributeCommonInfo {
 public:
diff --git a/clang/include/clang/Basic/Attributes.h 
b/clang/include/clang/Basic/Attributes.h
index 3fc5fbacdb2cbd6..61666a6f4d9ac4a 100644
--- a/clang/include/clang/Basic/Attributes.h
+++ b/clang/include/clang/Basic/Attributes.h
@@ -10,12 +10,12 @@
 #define LLVM_CLANG_BASIC_ATTRIBUTES_H
 
 #include "clang/Basic/AttributeCommonInfo.h"
-#include "clang/Basic/LangOptions.h"
-#include "clang/Basic/TargetInfo.h"
 
 namespace clang {
 
 class IdentifierInfo;
+class LangOptions;
+class TargetInfo;
 
 /// Return the version number associated with the attribute if we
 /// recognize and implement the attribute specified by the given information.
diff --git a/clang/lib/Basic/Attributes.cpp b/clang/lib/Basic/Attributes.cpp
index 1308e2d72f25f5b..bb495216ca93ca5 100644
--- a/clang/lib/Basic/Attributes.cpp
+++ b/clang/lib/Basic/Attributes.cpp
@@ -1,8 +1,22 @@
+//===--- Attributes.cpp 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file implements the AttributeCommonInfo interface.
+//
+//===--===//
+
 #include "clang/Basic/Attributes.h"
 #include "clang/Basic/AttrSubjectMatchRules.h"
-#include "clang/Basic/AttributeCommonInfo.h"
 #include "clang/Basic/IdentifierTable.h"
+#include "clang/Basic/LangOptions.h"
 #include "clang/Basic/ParsedAttrInfo.h"
+#include "clang/Basic/TargetInfo.h"
+
 using namespace clang;
 
 static int hasAttributeImpl(AttributeCommonInfo::Syntax Syntax, StringRef Name,
diff --git a/clang/lib/Basic/IdentifierTable.cpp 
b/clang/lib/Basic/IdentifierTable.cpp
index afb30268f2973ce..e5599d545541085 100644
--- a/clang/lib/Basic/IdentifierTable.cpp
+++ b/clang/lib/Basic/IdentifierTable.cpp
@@ -25,7 +25,6 @@
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Allocator.h"
-#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/raw_ostream.h"
 #include <cassert>
 #include <cstdio>
@@ -52,8 +51,7 @@ namespace {
 
 /// A simple identifier lookup iterator that represents an
 /// empty sequence of identifiers.
-class EmptyLookupIterator : public IdentifierIterator
-{
+class EmptyLookupIterator : public IdentifierIterator {
 public:
   StringRef Next() override { return StringRef(); }
 };
diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp
index fb883c08a745cfa..2531147c23196ae 100644
--- a/clang/lib/Parse/ParseStmt.cpp
+++ b/clang/lib/Parse/ParseStmt.cpp
@@ -14,6 +14,7 @@
 #include "clang/AST/PrettyDeclStackTrace.h"
 #include "clang/Basic/Attributes.h"
 #include "clang/Basic/PrettyStackTrace.h"
+#include "clang/Basic/TargetInfo.h"
 #include &quo

[PATCH] D148381: [Clang] Implement the 'counted_by' attribute

2023-09-14 Thread Bill Wendling via Phabricator via cfe-commits
void updated this revision to Diff 556749.
void added a comment.

Add release note.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148381

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/DeclBase.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/attr-counted-by.c
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/attr-counted-by.c

Index: clang/test/Sema/attr-counted-by.c
===
--- /dev/null
+++ clang/test/Sema/attr-counted-by.c
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -fstrict-flex-arrays=3 -fsyntax-only -verify %s
+
+#define __counted_by(f)  __attribute__((counted_by(f)))
+
+struct bar;
+
+struct not_found {
+  int bork;
+  struct bar *fam[] __counted_by(blork); // expected-error {{field 'blork' in 'counted_by' not found}}
+};
+
+int global; // expected-note {{variable 'global' is declared here}}
+
+struct found_outside_of_struct {
+  int bork;
+  struct bar *fam[] __counted_by(global); // expected-error {{field 'global' in 'counted_by' is not found in struct}}
+};
+
+struct self_referrential {
+  int bork;
+  struct bar *self[] __counted_by(self); // expected-error {{field 'self' in 'counted_by' cannot refer to the flexible array}}
+};
+
+struct non_int {
+  double non_integer; // expected-error {{field 'non_integer' in 'counted_by' is not a non-boolean integer type}}
+  struct bar *fam[] __counted_by(non_integer); // expected-note {{field 'non_integer' declared here}}
+};
+
+struct array_of_ints {
+  int non_integer[2]; // expected-error {{field 'non_integer' in 'counted_by' is not a non-boolean integer type}}
+  struct bar *fam[] __counted_by(non_integer); // expected-note {{field 'non_integer' declared here}}
+};
+
+struct not_a_fam {
+  double non_integer;
+  struct bar *non_fam __counted_by(non_integer); // expected-error {{'counted_by' only applies to flexible array members}}
+};
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -56,6 +56,7 @@
 // CHECK-NEXT: ConsumableAutoCast (SubjectMatchRule_record)
 // CHECK-NEXT: ConsumableSetOnRead (SubjectMatchRule_record)
 // CHECK-NEXT: Convergent (SubjectMatchRule_function)
+// CHECK-NEXT: CountedBy (SubjectMatchRule_field)
 // CHECK-NEXT: DLLExport (SubjectMatchRule_function, SubjectMatchRule_variable, SubjectMatchRule_record, SubjectMatchRule_objc_interface)
 // CHECK-NEXT: DLLImport (SubjectMatchRule_function, SubjectMatchRule_variable, SubjectMatchRule_record, SubjectMatchRule_objc_interface)
 // CHECK-NEXT: Destructor (SubjectMatchRule_function)
Index: clang/test/CodeGen/attr-counted-by.c
===
--- /dev/null
+++ clang/test/CodeGen/attr-counted-by.c
@@ -0,0 +1,227 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 3
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -DCOUNTED_BY -O2 -Wall -fsanitize=array-bounds,object-size,local-bounds -fstrict-flex-arrays=3 -emit-llvm -o - %s | FileCheck --check-prefix=SANITIZE-WITH-ATTR %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -DCOUNTED_BY -O2 -Wall -fstrict-flex-arrays=3 -emit-llvm -o - %s | FileCheck --check-prefix=NO-SANITIZE-WITH-ATTR %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -O2 -Wall -fsanitize=array-bounds,object-size,local-bounds -fstrict-flex-arrays=3 -emit-llvm -o - %s | FileCheck --check-prefix=SANITIZE-WITHOUT-ATTR %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -O2 -Wall -fstrict-flex-arrays=3 -emit-llvm -o - %s | FileCheck --check-prefix=NO-SANITIZE-WITHOUT-ATTR %s
+
+#if !__has_attribute(counted_by)
+#error "has attribute broken"
+#endif
+
+#ifdef COUNTED_BY
+#define __counted_by(member)__attribute__((__counted_by__(member)))
+#else
+#define __counted_by(member)
+#endif
+
+typedef long unsigned int size_t;
+
+struct annotated {
+  unsigned long flags;
+  int count;
+  int array[] __counted_by(count);
+};
+
+// SANITIZE-WITH-ATTR-LABEL: define dso_local void @test1(
+// SANITIZE-WITH-ATTR-SAME: ptr noundef [[P:%.*]], i32 noundef [[INDEX:%.*]], i32 noundef [[VAL:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
+// SANITIZE-WITH-ATTR-NEXT:  entry:
+// SANITIZE-WITH-ATTR-NEXT:[[COUNT:%.*]] = getelementptr inbounds [[STRUCT_ANNOTATED:%.*]], ptr [[P]], i64 0,

[PATCH] D158413: [Lex] Introduce Preprocessor::LexAll()

2023-09-14 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

ping!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158413

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


[PATCH] D158414: [LexerTest] Use LexAll() in StringifyArgs

2023-09-14 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

ping!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158414

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


[PATCH] D158415: [Lex] Handle repl_input_end in Preprocessor::LexAll()

2023-09-14 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

ping!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158415

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


[PATCH] D158415: [Lex] Handle repl_input_end in Preprocessor::LexAll()

2023-09-14 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

@Hahnfeld, let's move forward and rely on a post-commit review here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158415

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


[clang] [clang-format] Stop breaking unbreakable strings in JS (PR #66168)

2023-09-14 Thread via cfe-commits

alexfh wrote:

> Here is the new fix. #66321

Thanks! I think, I found another pattern where string literal breaking is not 
allowed - in parameters of `goog.module.get()` 
(https://google.github.io/closure-library/api/goog.module.html). I'm not 
completely sure, which tool produces the error I'm seeing and how relevant this 
is to the external users of Closure, but we definitely want a way to prevent 
breaking arguments of this function (or completely) - if not by default, then 
at least as a customizable style option.

> If it is not urgent, I prefer to wait a few days for reviews and then commit 
> the patch myself.

I used to work on this part of clang-format and now the code a bit, thus I feel 
comfortable approving this sort of a change. Another thing is that we need to 
get this fixed really soon. Another (safer and actually preferred) alternative 
is to revert the change and address problematic use cases before recommitting 
it, but I'm also fine with forward-fixing this as long as fixes don't require 
major changes that have potential for other problems to appear.

https://github.com/llvm/llvm-project/pull/66168
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D158413: [Lex] Introduce Preprocessor::LexAll()

2023-09-14 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added inline comments.



Comment at: clang/lib/Lex/Preprocessor.cpp:998
 
+std::vector Preprocessor::LexAll() {
+  std::vector toks;

Shouldn't we take the results as a `LexAll(std::vector &result)`?

Perhaps we should rename this interface to `LexTokensUntilEOF`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158413

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


[clang] [clang-format] More on unbreakable strings in TypeScript (PR #66321)

2023-09-14 Thread via cfe-commits

alexfh wrote:

LGTM

https://github.com/llvm/llvm-project/pull/66321
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D158415: [Lex] Handle repl_input_end in Preprocessor::LexAll()

2023-09-14 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

This revision cannot land without https://reviews.llvm.org/D158413 and for that 
one I really want to have feedback from somebody working in that area...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158415

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


[clang] [clang-format] More on unbreakable strings in TypeScript (PR #66321)

2023-09-14 Thread via cfe-commits

https://github.com/alexfh review_requested 
https://github.com/llvm/llvm-project/pull/66321
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] More on unbreakable strings in TypeScript (PR #66321)

2023-09-14 Thread via cfe-commits

https://github.com/alexfh approved this pull request.


https://github.com/llvm/llvm-project/pull/66321
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Extend `retcon.once` coroutines lowering to optionally produce a normal result (PR #66333)

2023-09-14 Thread Chuanqi Xu via cfe-commits

https://github.com/ChuanqiXu9 edited 
https://github.com/llvm/llvm-project/pull/66333
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Extend `retcon.once` coroutines lowering to optionally produce a normal result (PR #66333)

2023-09-14 Thread Chuanqi Xu via cfe-commits

https://github.com/ChuanqiXu9 commented:

> One of the main user of these kind of coroutines is swift. There yield-once 
> (retcon.once) coroutines are used to temporary "expose" pointers to internal 
> fields of various objects creating borrow scopes.
>
> However, in some cases it might be useful also to allow these coroutines to 
> produce a normal result, however, there is no way to represent this (as 
> compared to switched-resume kind of coroutines where C++ co_return is 
> transformed to a member / callback call on promise object).

Out of curiousity, why don't we  have the problem in the normal return 
continuation ABI?

https://github.com/llvm/llvm-project/pull/66333
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Extend `retcon.once` coroutines lowering to optionally produce a normal result (PR #66333)

2023-09-14 Thread Chuanqi Xu via cfe-commits


@@ -3046,7 +3046,8 @@ void coro::buildCoroutineFrame(
   // Collect the spills for arguments and other not-materializable values.
   for (Argument &A : F.args())
 for (User *U : A.users())
-  if (Checker.isDefinitionAcrossSuspend(A, U))
+  if (Checker.isDefinitionAcrossSuspend(A, U) ||
+  isa(U))

ChuanqiXu9 wrote:

Got it. Then it smells slightly bad. We have a lot `isDefinitionAcrossSuspend` 
uses and it looks easy to forget similar cases. I feel better to solve the 
issue fundamentally by introducing new intrinsics.

e.g., we can introduce  `token  llvm.coro.end.retcont.return_values(...)` and 
refactor `llvm.coro.end()` to `declare i1 @llvm.coro.end(ptr , i1 
, token )`. And for non-retcon-once ABI, we can fill the third 
argument as `none` simply. For retcon-once ABI, it should be easy to generate 
the actual ret too. 

Then we can avoid the `isDefinitionAcrossSuspend` problem automatically since 
the BB will be split around `coro.end`.

https://github.com/llvm/llvm-project/pull/66333
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [AArch64][Clang] Implement ACLE rintn intrinsics (PR #66112)

2023-09-14 Thread David Green via cfe-commits

https://github.com/davemgreen approved this pull request.

Thanks. LGTM

https://github.com/llvm/llvm-project/pull/66112
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [X86] Align 128/256 variants to use void * as 512 variants. (PR #66310)

2023-09-14 Thread Shengchen Kan via cfe-commits


@@ -1223,6 +1223,12 @@ __m256i test_mm256_stream_load_si256(__m256i const *a) {
   return _mm256_stream_load_si256(a);
 }
 
+__m256i test_mm256_stream_load_si256_const(void const *a) {

KanRobert wrote:

+1

https://github.com/llvm/llvm-project/pull/66310
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [NFC] Minimize header includes (PR #66339)

2023-09-14 Thread Anders Waldenborg via cfe-commits

https://github.com/wanders approved this pull request.

LGTM.

Assuming that clang/examples/Attribute/ still compiles fine  (it should be part 
of clang/test/Frontend/ tests)

https://github.com/llvm/llvm-project/pull/66339
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Allow MCTargetOptions to be parseable by -mllvm. (PR #66347)

2023-09-14 Thread Francesco Petrogalli via cfe-commits

https://github.com/fpetrogalli created 
https://github.com/llvm/llvm-project/pull/66347:

The cl::opt used by MCTargetOptions are not created until 
RegisterMCTargetOptionsFlags is instantiated. Due to this deferral the compiler 
driver -mllvm path is unable to parse flags such as --no-deprecated-warn which 
work properly in llvm-mc.

Move the instantiation into the frontend and cc1as and propagate the results 
into MCTargetOptions.

>From 72aab7cf85b7a2c09faf84ddd6a2d29af27834a7 Mon Sep 17 00:00:00 2001
From: Stephan Lachowsky 
Date: Thu, 14 Sep 2023 11:11:19 +0200
Subject: [PATCH] [clang] Allow MCTargetOptions to be parseable by -mllvm.

The cl::opt used by MCTargetOptions are not created until
RegisterMCTargetOptionsFlags is instantiated. Due to this deferral the
compiler driver -mllvm path is unable to parse flags such as
--no-deprecated-warn which work properly in llvm-mc.

Move the instantiation into the frontend and cc1as and propagate the
results into MCTargetOptions.
---
 clang/test/Misc/cc1as-mllvm-mc-options.s| 12 
 clang/test/Misc/compiler-mllvm-mc-options.c | 12 
 clang/tools/driver/cc1_main.cpp |  4 
 clang/tools/driver/cc1as_main.cpp   |  3 ++-
 4 files changed, 30 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/Misc/cc1as-mllvm-mc-options.s
 create mode 100644 clang/test/Misc/compiler-mllvm-mc-options.c

diff --git a/clang/test/Misc/cc1as-mllvm-mc-options.s 
b/clang/test/Misc/cc1as-mllvm-mc-options.s
new file mode 100644
index 000..189e3c546b8fd94
--- /dev/null
+++ b/clang/test/Misc/cc1as-mllvm-mc-options.s
@@ -0,0 +1,12 @@
+// Ensure MCTargetOptionsCommandFlags are parsable under -mllvm
+// RUN: %clang -cc1as -mllvm --help %s | FileCheck %s
+// CHECK: --asm-show-inst
+// CHECK: --dwarf-version
+// CHECK: --dwarf64
+// CHECK: --emit-dwarf-unwind
+// CHECK: --fatal-warnings
+// CHECK: --incremental-linker-compatible
+// CHECK: --mc-relax-all
+// CHECK: --no-deprecated-warn
+// CHECK: --no-type-check
+// CHECK: --no-warn
diff --git a/clang/test/Misc/compiler-mllvm-mc-options.c 
b/clang/test/Misc/compiler-mllvm-mc-options.c
new file mode 100644
index 000..10b2a1172968d66
--- /dev/null
+++ b/clang/test/Misc/compiler-mllvm-mc-options.c
@@ -0,0 +1,12 @@
+// Ensure MCTargetOptionsCommandFlags are parsable under -mllvm
+// RUN: %clang -mllvm --help -c %s -o /dev/null | FileCheck %s
+// CHECK: --asm-show-inst
+// CHECK: --dwarf-version
+// CHECK: --dwarf64
+// CHECK: --emit-dwarf-unwind
+// CHECK: --fatal-warnings
+// CHECK: --incremental-linker-compatible
+// CHECK: --mc-relax-all
+// CHECK: --no-deprecated-warn
+// CHECK: --no-type-check
+// CHECK: --no-warn
diff --git a/clang/tools/driver/cc1_main.cpp b/clang/tools/driver/cc1_main.cpp
index 9e7f8679b4cbdff..cc7089842a60c0d 100644
--- a/clang/tools/driver/cc1_main.cpp
+++ b/clang/tools/driver/cc1_main.cpp
@@ -28,6 +28,7 @@
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Config/llvm-config.h"
 #include "llvm/LinkAllPasses.h"
+#include "llvm/MC/MCTargetOptionsCommandFlags.h"
 #include "llvm/MC/TargetRegistry.h"
 #include "llvm/Option/Arg.h"
 #include "llvm/Option/ArgList.h"
@@ -53,6 +54,9 @@
 using namespace clang;
 using namespace llvm::opt;
 
+// Initialize MC Target option flags (for -mllvm)
+static llvm::mc::RegisterMCTargetOptionsFlags MOF;
+
 
//===--===//
 // Main driver
 
//===--===//
diff --git a/clang/tools/driver/cc1as_main.cpp 
b/clang/tools/driver/cc1as_main.cpp
index 3c5926073f026a6..3eb7c8c555bf186 100644
--- a/clang/tools/driver/cc1as_main.cpp
+++ b/clang/tools/driver/cc1as_main.cpp
@@ -36,6 +36,7 @@
 #include "llvm/MC/MCStreamer.h"
 #include "llvm/MC/MCSubtargetInfo.h"
 #include "llvm/MC/MCTargetOptions.h"
+#include "llvm/MC/MCTargetOptionsCommandFlags.h"
 #include "llvm/MC/TargetRegistry.h"
 #include "llvm/Option/Arg.h"
 #include "llvm/Option/ArgList.h"
@@ -408,7 +409,7 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts,
   std::unique_ptr MRI(TheTarget->createMCRegInfo(Opts.Triple));
   assert(MRI && "Unable to create target register info!");
 
-  MCTargetOptions MCOptions;
+  MCTargetOptions MCOptions = llvm::mc::InitMCTargetOptionsFromFlags();
   MCOptions.EmitDwarfUnwind = Opts.EmitDwarfUnwind;
   MCOptions.EmitCompactUnwindNonCanonical = Opts.EmitCompactUnwindNonCanonical;
   MCOptions.AsSecureLogFile = Opts.AsSecureLogFile;

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


[PATCH] D156363: [Driver] -###: exit with code 1 if hasErrorOccurred

2023-09-14 Thread Zixuan Wu via Phabricator via cfe-commits
zixuan-wu added a comment.
Herald added a subscriber: sunshaoce.

I am afraid there is also error at clang/test/Driver/as-options.s  when default 
triple is 'riscv32-unknown-elf'


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156363

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


[clang] [clang] Allow MCTargetOptions to be parseable by -mllvm. (PR #66347)

2023-09-14 Thread via cfe-commits

https://github.com/llvmbot labeled 
https://github.com/llvm/llvm-project/pull/66347
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Allow MCTargetOptions to be parseable by -mllvm. (PR #66347)

2023-09-14 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang


Changes
The cl::opt used by MCTargetOptions are not created until 
RegisterMCTargetOptionsFlags is instantiated. Due to this deferral the compiler 
driver -mllvm path is unable to parse flags such as --no-deprecated-warn which 
work properly in llvm-mc.

Move the instantiation into the frontend and cc1as and propagate the results 
into MCTargetOptions.
--
Full diff: https://github.com/llvm/llvm-project/pull/66347.diff

4 Files Affected:

- (added) clang/test/Misc/cc1as-mllvm-mc-options.s (+12) 
- (added) clang/test/Misc/compiler-mllvm-mc-options.c (+12) 
- (modified) clang/tools/driver/cc1_main.cpp (+4) 
- (modified) clang/tools/driver/cc1as_main.cpp (+2-1) 



diff --git a/clang/test/Misc/cc1as-mllvm-mc-options.s 
b/clang/test/Misc/cc1as-mllvm-mc-options.s
new file mode 100644
index 000..189e3c546b8fd94
--- /dev/null
+++ b/clang/test/Misc/cc1as-mllvm-mc-options.s
@@ -0,0 +1,12 @@
+// Ensure MCTargetOptionsCommandFlags are parsable under -mllvm
+// RUN: %clang -cc1as -mllvm --help %s | FileCheck %s
+// CHECK: --asm-show-inst
+// CHECK: --dwarf-version
+// CHECK: --dwarf64
+// CHECK: --emit-dwarf-unwind
+// CHECK: --fatal-warnings
+// CHECK: --incremental-linker-compatible
+// CHECK: --mc-relax-all
+// CHECK: --no-deprecated-warn
+// CHECK: --no-type-check
+// CHECK: --no-warn
diff --git a/clang/test/Misc/compiler-mllvm-mc-options.c 
b/clang/test/Misc/compiler-mllvm-mc-options.c
new file mode 100644
index 000..10b2a1172968d66
--- /dev/null
+++ b/clang/test/Misc/compiler-mllvm-mc-options.c
@@ -0,0 +1,12 @@
+// Ensure MCTargetOptionsCommandFlags are parsable under -mllvm
+// RUN: %clang -mllvm --help -c %s -o /dev/null | FileCheck %s
+// CHECK: --asm-show-inst
+// CHECK: --dwarf-version
+// CHECK: --dwarf64
+// CHECK: --emit-dwarf-unwind
+// CHECK: --fatal-warnings
+// CHECK: --incremental-linker-compatible
+// CHECK: --mc-relax-all
+// CHECK: --no-deprecated-warn
+// CHECK: --no-type-check
+// CHECK: --no-warn
diff --git a/clang/tools/driver/cc1_main.cpp b/clang/tools/driver/cc1_main.cpp
index 9e7f8679b4cbdff..cc7089842a60c0d 100644
--- a/clang/tools/driver/cc1_main.cpp
+++ b/clang/tools/driver/cc1_main.cpp
@@ -28,6 +28,7 @@
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Config/llvm-config.h"
 #include "llvm/LinkAllPasses.h"
+#include "llvm/MC/MCTargetOptionsCommandFlags.h"
 #include "llvm/MC/TargetRegistry.h"
 #include "llvm/Option/Arg.h"
 #include "llvm/Option/ArgList.h"
@@ -53,6 +54,9 @@
 using namespace clang;
 using namespace llvm::opt;
 
+// Initialize MC Target option flags (for -mllvm)
+static llvm::mc::RegisterMCTargetOptionsFlags MOF;
+
 
//===--===//
 // Main driver
 
//===--===//
diff --git a/clang/tools/driver/cc1as_main.cpp 
b/clang/tools/driver/cc1as_main.cpp
index 3c5926073f026a6..3eb7c8c555bf186 100644
--- a/clang/tools/driver/cc1as_main.cpp
+++ b/clang/tools/driver/cc1as_main.cpp
@@ -36,6 +36,7 @@
 #include "llvm/MC/MCStreamer.h"
 #include "llvm/MC/MCSubtargetInfo.h"
 #include "llvm/MC/MCTargetOptions.h"
+#include "llvm/MC/MCTargetOptionsCommandFlags.h"
 #include "llvm/MC/TargetRegistry.h"
 #include "llvm/Option/Arg.h"
 #include "llvm/Option/ArgList.h"
@@ -408,7 +409,7 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation 
&Opts,
   std::unique_ptr<MCRegisterInfo> 
MRI(TheTarget->createMCRegInfo(Opts.Triple));
   assert(MRI && "Unable to create target register 
info!");
 
-  MCTargetOptions MCOptions;
+  MCTargetOptions MCOptions = llvm::mc::InitMCTargetOptionsFromFlags();
   MCOptions.EmitDwarfUnwind = Opts.EmitDwarfUnwind;
   MCOptions.EmitCompactUnwindNonCanonical = Opts.EmitCompactUnwindNonCanonical;
   MCOptions.AsSecureLogFile = Opts.AsSecureLogFile;




https://github.com/llvm/llvm-project/pull/66347
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][bpf] Fix invalid RUN lines in stack protector warning test (PR #65251)

2023-09-14 Thread David Spickett via cfe-commits

DavidSpickett wrote:

I'm going to assume this is fine given that the test passes. We can always 
revert it if that is not the case.

https://github.com/llvm/llvm-project/pull/65251
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 7e6a5fe - [clang][bpf] Fix invalid RUN lines in stack protector warning test (#65251)

2023-09-14 Thread via cfe-commits

Author: David Spickett
Date: 2023-09-14T10:24:26+01:00
New Revision: 7e6a5fe1603f3f768e299de0bea2cde8bc3c31db

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

LOG: [clang][bpf] Fix invalid RUN lines in stack protector warning test (#65251)

2 of them were missing the ":" on the end.

Adding them broke the test so I had to add a new prefix just for the
warning runs only.

I manually checked the first RUNs and there is no warning emitted, as
expected.

Added: 


Modified: 
clang/test/CodeGen/bpf-stack-protector.c

Removed: 




diff  --git a/clang/test/CodeGen/bpf-stack-protector.c 
b/clang/test/CodeGen/bpf-stack-protector.c
index c17af890eac239a..f79a49e6aa686df 100644
--- a/clang/test/CodeGen/bpf-stack-protector.c
+++ b/clang/test/CodeGen/bpf-stack-protector.c
@@ -1,16 +1,16 @@
 // REQUIRES: bpf-registered-target
 
-// RUN %clang -target bpf -S -emit-llvm -o - %s -fno-stack-protector 2>&1 \
-// RUN| FileCheck -check-prefix=OFF -check-prefix=COMMON %s
+// RUN: %clang -target bpf -S -emit-llvm -o - %s -fno-stack-protector 2>&1 \
+// RUN:| FileCheck -check-prefix=OFF -check-prefix=COMMON %s
 
 // RUN: %clang -target bpf -S -emit-llvm -o - %s -fstack-protector 2>&1 \
-// RUN:| FileCheck -check-prefix=ON -check-prefix=COMMON %s
+// RUN:| FileCheck -check-prefix=ON -check-prefix=COMMON 
-check-prefix=WARNING %s
 
 // RUN: %clang -target bpf -S -emit-llvm -o - %s -fstack-protector-all 2>&1 \
-// RUN:| FileCheck -check-prefix=ALL -check-prefix=COMMON %s
+// RUN:| FileCheck -check-prefix=ALL -check-prefix=COMMON 
-check-prefix=WARNING %s
 
 // RUN: %clang -target bpf -S -emit-llvm -o - %s -fstack-protector-strong 2>&1 
\
-// RUN:| FileCheck -check-prefix=STRONG -check-prefix=COMMON %s
+// RUN:| FileCheck -check-prefix=STRONG -check-prefix=COMMON 
-check-prefix=WARNING %s
 
 typedef __SIZE_TYPE__ size_t;
 
@@ -22,7 +22,7 @@ char *strcpy(char *s1, const char *s2);
 //  ON: warning: ignoring '-fstack-protector'
 // ALL: warning: ignoring '-fstack-protector-all'
 //  STRONG: warning: ignoring '-fstack-protector-strong'
-// COMMON-SAME: option as it is not currently supported for target 'bpf'
+// WARNING-SAME: option as it is not currently supported for target 'bpf'
 
 // COMMON: define {{.*}}void @test1(ptr noundef %{{[0-9a-z]+}}) #[[A:.*]] {
 void test1(const char *msg) {



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


[clang] [clang][bpf] Fix invalid RUN lines in stack protector warning test (PR #65251)

2023-09-14 Thread David Spickett via cfe-commits

https://github.com/DavidSpickett closed 
https://github.com/llvm/llvm-project/pull/65251
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Allow MCTargetOptions to be parseable by -mllvm. (PR #66347)

2023-09-14 Thread Francesco Petrogalli via cfe-commits

https://github.com/fpetrogalli review_requested 
https://github.com/llvm/llvm-project/pull/66347
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Allow MCTargetOptions to be parseable by -mllvm. (PR #66347)

2023-09-14 Thread Francesco Petrogalli via cfe-commits

https://github.com/fpetrogalli review_requested 
https://github.com/llvm/llvm-project/pull/66347
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 0009032 - [NFC] Minimize header includes (#66339)

2023-09-14 Thread via cfe-commits

Author: Bill Wendling
Date: 2023-09-14T02:29:11-07:00
New Revision: 0009032a27f7c8461b7c107cb05b1eac61be7197

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

LOG: [NFC] Minimize header includes (#66339)

Minimize the headers included in header files to reduce the number of
files that need recompiled after a change.

Added: 


Modified: 
clang/include/clang/Basic/AttrSubjectMatchRules.h
clang/include/clang/Basic/AttributeCommonInfo.h
clang/include/clang/Basic/Attributes.h
clang/lib/Basic/Attributes.cpp
clang/lib/Basic/IdentifierTable.cpp
clang/lib/Parse/ParseStmt.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/AttrSubjectMatchRules.h 
b/clang/include/clang/Basic/AttrSubjectMatchRules.h
index e3dcb943e59d424..bec8122ea930a6a 100644
--- a/clang/include/clang/Basic/AttrSubjectMatchRules.h
+++ b/clang/include/clang/Basic/AttrSubjectMatchRules.h
@@ -9,10 +9,12 @@
 #ifndef LLVM_CLANG_BASIC_ATTRSUBJECTMATCHRULES_H
 #define LLVM_CLANG_BASIC_ATTRSUBJECTMATCHRULES_H
 
-#include "clang/Basic/SourceLocation.h"
 #include "llvm/ADT/DenseMap.h"
 
 namespace clang {
+
+class SourceRange;
+
 namespace attr {
 
 /// A list of all the recognized kinds of attributes.

diff  --git a/clang/include/clang/Basic/AttributeCommonInfo.h 
b/clang/include/clang/Basic/AttributeCommonInfo.h
index e57adc4bf5b99a2..7dc05418498d0ae 100644
--- a/clang/include/clang/Basic/AttributeCommonInfo.h
+++ b/clang/include/clang/Basic/AttributeCommonInfo.h
@@ -13,12 +13,14 @@
 
 #ifndef LLVM_CLANG_BASIC_ATTRIBUTECOMMONINFO_H
 #define LLVM_CLANG_BASIC_ATTRIBUTECOMMONINFO_H
+
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/TokenKinds.h"
 
 namespace clang {
-class IdentifierInfo;
+
 class ASTRecordWriter;
+class IdentifierInfo;
 
 class AttributeCommonInfo {
 public:

diff  --git a/clang/include/clang/Basic/Attributes.h 
b/clang/include/clang/Basic/Attributes.h
index 3fc5fbacdb2cbd6..61666a6f4d9ac4a 100644
--- a/clang/include/clang/Basic/Attributes.h
+++ b/clang/include/clang/Basic/Attributes.h
@@ -10,12 +10,12 @@
 #define LLVM_CLANG_BASIC_ATTRIBUTES_H
 
 #include "clang/Basic/AttributeCommonInfo.h"
-#include "clang/Basic/LangOptions.h"
-#include "clang/Basic/TargetInfo.h"
 
 namespace clang {
 
 class IdentifierInfo;
+class LangOptions;
+class TargetInfo;
 
 /// Return the version number associated with the attribute if we
 /// recognize and implement the attribute specified by the given information.

diff  --git a/clang/lib/Basic/Attributes.cpp b/clang/lib/Basic/Attributes.cpp
index 1308e2d72f25f5b..bb495216ca93ca5 100644
--- a/clang/lib/Basic/Attributes.cpp
+++ b/clang/lib/Basic/Attributes.cpp
@@ -1,8 +1,22 @@
+//===--- Attributes.cpp 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file implements the AttributeCommonInfo interface.
+//
+//===--===//
+
 #include "clang/Basic/Attributes.h"
 #include "clang/Basic/AttrSubjectMatchRules.h"
-#include "clang/Basic/AttributeCommonInfo.h"
 #include "clang/Basic/IdentifierTable.h"
+#include "clang/Basic/LangOptions.h"
 #include "clang/Basic/ParsedAttrInfo.h"
+#include "clang/Basic/TargetInfo.h"
+
 using namespace clang;
 
 static int hasAttributeImpl(AttributeCommonInfo::Syntax Syntax, StringRef Name,

diff  --git a/clang/lib/Basic/IdentifierTable.cpp 
b/clang/lib/Basic/IdentifierTable.cpp
index afb30268f2973ce..e5599d545541085 100644
--- a/clang/lib/Basic/IdentifierTable.cpp
+++ b/clang/lib/Basic/IdentifierTable.cpp
@@ -25,7 +25,6 @@
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Allocator.h"
-#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
@@ -52,8 +51,7 @@ namespace {
 
 /// A simple identifier lookup iterator that represents an
 /// empty sequence of identifiers.
-class EmptyLookupIterator : public IdentifierIterator
-{
+class EmptyLookupIterator : public IdentifierIterator {
 public:
   StringRef Next() override { return StringRef(); }
 };

diff  --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp
index fb883c08a745cfa..2531147c23196ae 100644
--- a/clang/lib/Parse/ParseStmt.cpp
+++ b/clang/lib/Parse/ParseStmt.cpp
@@ -14,6 +14,7 @@
 #include "clang/AST/PrettyDeclStackTrace.h"
 #include "clang/Basic/Attributes.h"
 #include "clang/Basic/PrettyStackTrace.h"
+#include "clang/Basic/TargetInfo.h"
 #include "clang/Basic/TokenKinds.h"
 #include "clan

[clang] [NFC] Minimize header includes (PR #66339)

2023-09-14 Thread Bill Wendling via cfe-commits

https://github.com/bwendling closed 
https://github.com/llvm/llvm-project/pull/66339
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 967604a - [clang][dataflow] In tests, error out if we didn't find any matching target functions. (#66197)

2023-09-14 Thread via cfe-commits

Author: martinboehme
Date: 2023-09-14T11:32:17+02:00
New Revision: 967604a07b1d5da15fb561d4ceae04cbaef02df7

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

LOG: [clang][dataflow] In tests, error out if we didn't find any matching 
target functions. (#66197)

Before, we were silently letting the test pass, which masks test bugs;
for an
example, see https://github.com/llvm/llvm-project/pull/66195.

Added: 


Modified: 
clang/unittests/Analysis/FlowSensitive/TestingSupport.h

Removed: 




diff  --git a/clang/unittests/Analysis/FlowSensitive/TestingSupport.h 
b/clang/unittests/Analysis/FlowSensitive/TestingSupport.h
index 0cf66c218f43fdc..44d962d5da9a97b 100644
--- a/clang/unittests/Analysis/FlowSensitive/TestingSupport.h
+++ b/clang/unittests/Analysis/FlowSensitive/TestingSupport.h
@@ -240,12 +240,15 @@ checkDataflow(AnalysisInputs AI,
 };
   }
 
-  for (const ast_matchers::BoundNodes &BN :
-   ast_matchers::match(ast_matchers::functionDecl(
-   ast_matchers::hasBody(ast_matchers::stmt()),
-   AI.TargetFuncMatcher)
-   .bind("target"),
-   Context)) {
+  SmallVector MatchResult = ast_matchers::match(
+  ast_matchers::functionDecl(ast_matchers::hasBody(ast_matchers::stmt()),
+ AI.TargetFuncMatcher)
+  .bind("target"),
+  Context);
+  if (MatchResult.empty())
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "didn't find any matching target 
functions");
+  for (const ast_matchers::BoundNodes &BN : MatchResult) {
 // Get the AST node of the target function.
 const FunctionDecl *Target = BN.getNodeAs("target");
 if (Target == nullptr)



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


[clang] [clang][dataflow] In tests, error out if we didn't find any matching target functions. (PR #66197)

2023-09-14 Thread via cfe-commits

https://github.com/martinboehme closed 
https://github.com/llvm/llvm-project/pull/66197
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer] TaintPropagation checker strlen() should not propagate (PR #66086)

2023-09-14 Thread Balazs Benics via cfe-commits

steakhal wrote:

I finished the review of this PR.

By looking at the disappeared reports you attached, I'm convinced that the 
`MsgTaintedBufferSize` diagnostics give little to no benefit in general. On the 
other side, I've seen good hits for OOBV2 in the presence of taint - even if 
that's rarely the case. On the theory side, I also believe that propagation 
should happen on `strlen` and similar functions.

Consequently, I agree with the raised problems, but I disagree with the 
approach.
I would rather remove the `MsgTaintedBufferSize` diagnostic to resolve those 
FPs.
Alternatively, we can also think of creating a heuristic to reduce such FPs. 
For e.g. check if the most significant bit of the allocation size is proven to 
be unset (aka. checked some meaningful upperbounds)  and suppress reports in 
that case, but report otherwise.
Would it be okay with you to proceed by not removing taint propagation?

On the same token, I think we should be able to separately enable/disable 
diagnostics on the GenericTaintChecker (including that they should not sink 
execution paths if they are disabled); but that's a different subject.


https://github.com/llvm/llvm-project/pull/66086
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer] TaintPropagation checker strlen() should not propagate (PR #66086)

2023-09-14 Thread Balazs Benics via cfe-commits

https://github.com/steakhal requested changes to this pull request.


https://github.com/llvm/llvm-project/pull/66086
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer] TaintPropagation checker strlen() should not propagate (PR #66086)

2023-09-14 Thread Balazs Benics via cfe-commits

https://github.com/steakhal edited 
https://github.com/llvm/llvm-project/pull/66086
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer] TaintPropagation checker strlen() should not propagate (PR #66086)

2023-09-14 Thread Balazs Benics via cfe-commits


@@ -915,24 +915,6 @@ void testStrndupa(size_t n) {
   clang_analyzer_isTainted_charp(result); // expected-warning {{YES}}
 }
 
-size_t strlen(const char *s);
-void testStrlen() {
-  char s[10];
-  scanf("%9s", s);
-
-  size_t result = strlen(s);
-  clang_analyzer_isTainted_int(result); // expected-warning {{YES}}
-}
-
-size_t strnlen(const char *s, size_t maxlen);
-void testStrnlen(size_t maxlen) {
-  char s[10];
-  scanf("%9s", s);
-
-  size_t result = strnlen(s, maxlen);
-  clang_analyzer_isTainted_int(result); // expected-warning {{YES}}
-}
-

steakhal wrote:

In general, I oppose removing FN tests. They are good at documenting intent, if 
for nothing else.
It might be even better to add comments there about why we think it's okay and 
intentional to not propagate taint there. Also, adding a PR link would give the 
possibility to look deeper to understand the why.

https://github.com/llvm/llvm-project/pull/66086
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 094a63a - [OpenMP][OMPIRBuilder] OpenMPIRBuilder support for requires directive

2023-09-14 Thread Sergio Afonso via cfe-commits

Author: Sergio Afonso
Date: 2023-09-14T10:33:54+01:00
New Revision: 094a63a20bf54f18efafbb6a727466da0f22a245

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

LOG: [OpenMP][OMPIRBuilder] OpenMPIRBuilder support for requires directive

This patch updates the `OpenMPIRBuilderConfig` structure to hold all
available 'requires' clauses, and it replicates part of the code
generation for the 'requires' registration function from clang in the
`OMPIRBuilder`, to be used with flang.

Porting the rest of features of the clang implementation to the IRBuilder
and sharing it between clang and flang remains for a future patch, due to the
complexity of the logic selecting the attributes of the generated
registration function.

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

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
mlir/lib/Target/LLVMIR/ModuleTranslation.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 380bab65c14f2e6..3b69305d050d769 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -480,27 +480,6 @@ enum OpenMPLocationFlags : unsigned {
   LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/OMP_IDENT_WORK_DISTRIBUTE)
 };
 
-namespace {
-LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();
-/// Values for bit flags for marking which requires clauses have been used.
-enum OpenMPOffloadingRequiresDirFlags : int64_t {
-  /// flag undefined.
-  OMP_REQ_UNDEFINED   = 0x000,
-  /// no requires clause present.
-  OMP_REQ_NONE= 0x001,
-  /// reverse_offload clause.
-  OMP_REQ_REVERSE_OFFLOAD = 0x002,
-  /// unified_address clause.
-  OMP_REQ_UNIFIED_ADDRESS = 0x004,
-  /// unified_shared_memory clause.
-  OMP_REQ_UNIFIED_SHARED_MEMORY   = 0x008,
-  /// dynamic_allocators clause.
-  OMP_REQ_DYNAMIC_ALLOCATORS  = 0x010,
-  LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/OMP_REQ_DYNAMIC_ALLOCATORS)
-};
-
-} // anonymous namespace
-
 /// Describes ident structure that describes a source location.
 /// All descriptions are taken from
 /// https://github.com/llvm/llvm-project/blob/main/openmp/runtime/src/kmp.h
@@ -1055,9 +1034,11 @@ static FieldDecl *addFieldToRecordDecl(ASTContext &C, 
DeclContext *DC,
 CGOpenMPRuntime::CGOpenMPRuntime(CodeGenModule &CGM)
 : CGM(CGM), OMPBuilder(CGM.getModule()) {
   KmpCriticalNameTy = llvm::ArrayType::get(CGM.Int32Ty, /*NumElements*/ 8);
-  llvm::OpenMPIRBuilderConfig Config(CGM.getLangOpts().OpenMPIsTargetDevice,
- isGPU(), hasRequiresUnifiedSharedMemory(),
- CGM.getLangOpts().OpenMPOffloadMandatory);
+  llvm::OpenMPIRBuilderConfig Config(
+  CGM.getLangOpts().OpenMPIsTargetDevice, isGPU(),
+  CGM.getLangOpts().OpenMPOffloadMandatory,
+  /*HasRequiresReverseOffload*/ false, /*HasRequiresUnifiedAddress*/ false,
+  hasRequiresUnifiedSharedMemory(), /*HasRequiresDynamicAllocators*/ 
false);
   OMPBuilder.initialize(CGM.getLangOpts().OpenMPIsTargetDevice
 ? CGM.getLangOpts().OMPHostIRFile
 : StringRef{});
@@ -10162,7 +10143,6 @@ llvm::Function 
*CGOpenMPRuntime::emitRequiresDirectiveRegFun() {
 std::string ReqName = getName({"omp_offloading", "requires_reg"});
 RequiresRegFn = CGM.CreateGlobalInitOrCleanUpFunction(FTy, ReqName, FI);
 CGF.StartFunction(GlobalDecl(), C.VoidTy, RequiresRegFn, FI, {});
-OpenMPOffloadingRequiresDirFlags Flags = OMP_REQ_NONE;
 // TODO: check for other requires clauses.
 // The requires directive takes effect only when a target region is
 // present in the compilation unit. Otherwise it is ignored and not
@@ -10172,11 +10152,10 @@ llvm::Function 
*CGOpenMPRuntime::emitRequiresDirectiveRegFun() {
 assert((HasEmittedTargetRegion || HasEmittedDeclareTargetRegion ||
 !OMPBuilder.OffloadInfoManager.empty()) &&
"Target or declare target region expected.");
-if (HasRequiresUnifiedSharedMemory)
-  Flags = OMP_REQ_UNIFIED_SHARED_MEMORY;
 CGF.EmitRuntimeCall(OMPBuilder.getOrCreateRuntimeFunction(
 CGM.getModule(), OMPRTL___tgt_register_requires),
-llvm::ConstantInt::get(CGM.Int64Ty, Flags));
+llvm::ConstantInt::get(
+CGM.Int64Ty, 
OMPBuilder.Config.getRequiresFlags()));
 CGF.FinishFunction();
   }
   return RequiresRegFn;

diff  --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.c

[PATCH] D147217: [OpenMP][OMPIRBuilder] OpenMPIRBuilder support for requires directive

2023-09-14 Thread Sergio Afonso via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG094a63a20bf5: [OpenMP][OMPIRBuilder] OpenMPIRBuilder support 
for requires directive (authored by skatrak).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147217

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
  mlir/lib/Target/LLVMIR/ModuleTranslation.cpp

Index: mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
===
--- mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
+++ mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
@@ -1298,8 +1298,11 @@
 // TODO: set the flags when available
 llvm::OpenMPIRBuilderConfig config(
 isTargetDevice, isGPU,
-/* HasRequiresUnifiedSharedMemory */ false,
-/* OpenMPOffloadMandatory */ false);
+/* OpenMPOffloadMandatory = */ false,
+/* HasRequiresReverseOffload = */ false,
+/* HasRequiresUnifiedAddress = */ false,
+/* HasRequiresUnifiedSharedMemory = */ false,
+/* HasRequiresDynamicAllocators = */ false);
 ompBuilder->setConfig(config);
   }
   return ompBuilder.get();
Index: llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
===
--- llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
+++ llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -5128,7 +5128,7 @@
   using InsertPointTy = OpenMPIRBuilder::InsertPointTy;
   OpenMPIRBuilder OMPBuilder(*M);
   OMPBuilder.initialize();
-  OpenMPIRBuilderConfig Config(false, false, false, false);
+  OpenMPIRBuilderConfig Config(false, false, false, false, false, false, false);
   OMPBuilder.setConfig(Config);
   F->setName("func");
   IRBuilder<> Builder(BB);
@@ -5206,7 +5206,8 @@
 
 TEST_F(OpenMPIRBuilderTest, TargetRegionDevice) {
   OpenMPIRBuilder OMPBuilder(*M);
-  OMPBuilder.setConfig(OpenMPIRBuilderConfig(true, false, false, false));
+  OMPBuilder.setConfig(
+  OpenMPIRBuilderConfig(true, false, false, false, false, false, false));
   OMPBuilder.initialize();
 
   F->setName("func");
@@ -5896,7 +5897,8 @@
 
 TEST_F(OpenMPIRBuilderTest, OffloadEntriesInfoManager) {
   OpenMPIRBuilder OMPBuilder(*M);
-  OMPBuilder.setConfig(OpenMPIRBuilderConfig(true, false, false, false));
+  OMPBuilder.setConfig(
+  OpenMPIRBuilderConfig(true, false, false, false, false, false, false));
   OffloadEntriesInfoManager &InfoManager = OMPBuilder.OffloadInfoManager;
   TargetRegionEntryInfo EntryInfo("parent", 1, 2, 4, 0);
   InfoManager.initializeTargetRegionEntryInfo(EntryInfo, 0);
@@ -5919,7 +5921,7 @@
 TEST_F(OpenMPIRBuilderTest, registerTargetGlobalVariable) {
   OpenMPIRBuilder OMPBuilder(*M);
   OMPBuilder.initialize();
-  OpenMPIRBuilderConfig Config(false, false, false, false);
+  OpenMPIRBuilderConfig Config(false, false, false, false, false, false, false);
   OMPBuilder.setConfig(Config);
 
   std::vector TargetTriple;
@@ -5996,8 +5998,11 @@
   OMPBuilder.initialize();
   OpenMPIRBuilderConfig Config(/* IsTargetDevice = */ true,
/* IsGPU = */ true,
+   /* OpenMPOffloadMandatory = */ false,
+   /* HasRequiresReverseOffload = */ false,
+   /* HasRequiresUnifiedAddress = */ false,
/* HasRequiresUnifiedSharedMemory = */ false,
-   /* OpenMPOffloadMandatory = */ false);
+   /* HasRequiresDynamicAllocators = */ false);
   OMPBuilder.setConfig(Config);
 
   FunctionCallee FnTypeAndCallee =
@@ -6033,4 +6038,44 @@
   EXPECT_TRUE(Fn->hasFnAttribute(Attribute::MustProgress));
 }
 
+TEST_F(OpenMPIRBuilderTest, CreateRegisterRequires) {
+  OpenMPIRBuilder OMPBuilder(*M);
+  OMPBuilder.initialize();
+
+  OpenMPIRBuilderConfig Config(/* IsTargetDevice = */ false,
+   /* IsGPU = */ false,
+   /* OpenMPOffloadMandatory = */ false,
+   /* HasRequiresReverseOffload = */ true,
+   /* HasRequiresUnifiedAddress = */ false,
+   /* HasRequiresUnifiedSharedMemory = */ true,
+   /* HasRequiresDynamicAllocators = */ false);
+  OMPBuilder.setConfig(Config);
+
+  auto FName =
+  OMPBuilder.createPlatformSpecificName({"omp_offloading", "requires_reg"});
+  EXPECT_EQ(FName, ".omp_offloading.requires_reg");
+
+  Function *Fn = OMPBuilder.createRegisterRequires(FName);
+  EXPECT_NE(Fn, nullptr);
+  EXPECT_EQ(FName, Fn->getName());
+
+  EXPECT_EQ(Fn->getSection(), ".text.startup");
+  EXPECT_TRUE(Fn->hasInternalLinkage());
+  EXPECT_TRUE(Fn->hasFnAttribute(Att

[PATCH] D147218: [OpenMP][Flang][MLIR] Lowering of OpenMP requires directive from parse tree to MLIR

2023-09-14 Thread Sergio Afonso via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG29aa749087be: [OpenMP][Flang][MLIR] Lowering of OpenMP 
requires directive from parse tree to… (authored by skatrak).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147218

Files:
  flang/include/flang/Lower/OpenMP.h
  flang/lib/Lower/Bridge.cpp
  flang/lib/Lower/OpenMP.cpp
  flang/test/Lower/OpenMP/Todo/requires-unnamed-common.f90
  flang/test/Lower/OpenMP/requires-common.f90
  flang/test/Lower/OpenMP/requires-notarget.f90
  flang/test/Lower/OpenMP/requires.f90

Index: flang/test/Lower/OpenMP/requires.f90
===
--- /dev/null
+++ flang/test/Lower/OpenMP/requires.f90
@@ -0,0 +1,14 @@
+! RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | FileCheck %s
+! RUN: %flang_fc1 -emit-fir -fopenmp -fopenmp-is-target-device %s -o - | FileCheck %s
+! RUN: bbc -fopenmp -emit-fir %s -o - | FileCheck %s
+! RUN: bbc -fopenmp -fopenmp-is-target-device -emit-fir %s -o - | FileCheck %s
+
+! This test checks the lowering of requires into MLIR
+
+!CHECK:  module attributes {
+!CHECK-SAME: omp.requires = #omp
+program requires
+  !$omp requires unified_shared_memory reverse_offload atomic_default_mem_order(seq_cst)
+  !$omp target
+  !$omp end target
+end program requires
Index: flang/test/Lower/OpenMP/requires-notarget.f90
===
--- /dev/null
+++ flang/test/Lower/OpenMP/requires-notarget.f90
@@ -0,0 +1,14 @@
+! RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | FileCheck %s
+! RUN: %flang_fc1 -emit-fir -fopenmp -fopenmp-is-target-device %s -o - | FileCheck %s
+! RUN: bbc -fopenmp -emit-fir %s -o - | FileCheck %s
+! RUN: bbc -fopenmp -fopenmp-is-target-device -emit-fir %s -o - | FileCheck %s
+
+! This test checks that requires lowering into MLIR skips creating the
+! omp.requires attribute with target-related clauses if there are no device
+! functions in the compilation unit
+
+!CHECK:  module attributes {
+!CHECK-NOT:  omp.requires
+program requires
+  !$omp requires unified_shared_memory reverse_offload atomic_default_mem_order(seq_cst)
+end program requires
Index: flang/test/Lower/OpenMP/requires-common.f90
===
--- /dev/null
+++ flang/test/Lower/OpenMP/requires-common.f90
@@ -0,0 +1,19 @@
+! RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | FileCheck %s
+! RUN: %flang_fc1 -emit-fir -fopenmp -fopenmp-is-target-device %s -o - | FileCheck %s
+! RUN: bbc -fopenmp -emit-fir %s -o - | FileCheck %s
+! RUN: bbc -fopenmp -fopenmp-is-target-device -emit-fir %s -o - | FileCheck %s
+
+! This test checks the lowering of requires into MLIR
+
+!CHECK:  module attributes {
+!CHECK-SAME: omp.requires = #omp
+block data init
+  !$omp requires unified_shared_memory
+  integer :: x
+  common /block/ x
+  data x / 10 /
+end
+
+subroutine f
+  !$omp declare target
+end subroutine f
Index: flang/test/Lower/OpenMP/Todo/requires-unnamed-common.f90
===
--- /dev/null
+++ flang/test/Lower/OpenMP/Todo/requires-unnamed-common.f90
@@ -0,0 +1,23 @@
+! This test checks the lowering of REQUIRES inside of an unnamed BLOCK DATA.
+! The symbol of the `symTab` scope of the `BlockDataUnit` PFT node is null in
+! this case, resulting in the inability to store the REQUIRES flags gathered in
+! it.
+
+! RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | FileCheck %s
+! RUN: %flang_fc1 -emit-fir -fopenmp -fopenmp-is-target-device %s -o - | FileCheck %s
+! RUN: bbc -fopenmp -emit-fir %s -o - | FileCheck %s
+! RUN: bbc -fopenmp -fopenmp-is-target-device -emit-fir %s -o - | FileCheck %s
+! XFAIL: *
+
+!CHECK: module attributes {
+!CHECK-SAME:omp.requires = #omp
+block data
+  !$omp requires unified_shared_memory
+  integer :: x
+  common /block/ x
+  data x / 10 /
+end
+
+subroutine f
+  !$omp declare target
+end subroutine f
Index: flang/lib/Lower/OpenMP.cpp
===
--- flang/lib/Lower/OpenMP.cpp
+++ flang/lib/Lower/OpenMP.cpp
@@ -78,9 +78,7 @@
 static void gatherFuncAndVarSyms(
 const Fortran::parser::OmpObjectList &objList,
 mlir::omp::DeclareTargetCaptureClause clause,
-llvm::SmallVectorImpl>
-&symbolAndClause) {
+llvm::SmallVectorImpl &symbolAndClause) {
   for (const Fortran::parser::OmpObject &ompObject : objList.v) {
 Fortran::common::visit(
 Fortran::common::visitors{
@@ -2453,6 +2451,71 @@
  reductionDeclSymbols));
 }
 
+/// Extract the list of function and variable symbols affected by the given
+/// 'declare target' directive and return the intended device type for them.
+static mlir::omp::DeclareTargetDeviceType getDeclareTargetInfo(
+Fortran::lower::AbstractConverter &converter,
+Fortran::lower::pft::

[clang] [analyzer] First batch of patches for the Juliet benchmark for taint improvements (PR #66074)

2023-09-14 Thread via cfe-commits

https://github.com/DonatNagyE approved this pull request.

LGTM.

https://github.com/llvm/llvm-project/pull/66074
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 9058762 - [OpenMP][Flang][MLIR] Lowering of requires directive from MLIR to LLVM IR

2023-09-14 Thread Sergio Afonso via cfe-commits

Author: Sergio Afonso
Date: 2023-09-14T10:35:44+01:00
New Revision: 9058762789c0a83560c2b567a347b993e70b05ae

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

LOG: [OpenMP][Flang][MLIR] Lowering of requires directive from MLIR to LLVM IR

Default atomic ordering information is processed in the OpenMP dialect
to LLVM IR lowering stage at every spot where an operation can be
affected by it. The rest of clauses are stored globally in the
OpenMPIRBuilderConfig object before starting that lowering stage, so
that the OMPIRBuilder can conditionally modify code generation
depending on these. At the end of the process, the omp.requires
attribute is itself lowered into a global constructor that passes these
clauses as flags to the OpenMP runtime.

Depends on D147217, D147218 and D158278.

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

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
mlir/test/Target/LLVMIR/openmp-llvm.mlir

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 3b69305d050d769..92b7c8d4aa546f0 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -1039,9 +1039,10 @@ CGOpenMPRuntime::CGOpenMPRuntime(CodeGenModule &CGM)
   CGM.getLangOpts().OpenMPOffloadMandatory,
   /*HasRequiresReverseOffload*/ false, /*HasRequiresUnifiedAddress*/ false,
   hasRequiresUnifiedSharedMemory(), /*HasRequiresDynamicAllocators*/ 
false);
-  OMPBuilder.initialize(CGM.getLangOpts().OpenMPIsTargetDevice
-? CGM.getLangOpts().OMPHostIRFile
-: StringRef{});
+  OMPBuilder.initialize();
+  OMPBuilder.loadOffloadInfoMetadata(CGM.getLangOpts().OpenMPIsTargetDevice
+ ? CGM.getLangOpts().OMPHostIRFile
+ : StringRef{});
   OMPBuilder.setConfig(Config);
 }
 

diff  --git a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h 
b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
index a5977356da3e530..523a0718e1ffb53 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -154,6 +154,7 @@ class OpenMPIRBuilderConfig {
 
   void setIsTargetDevice(bool Value) { IsTargetDevice = Value; }
   void setIsGPU(bool Value) { IsGPU = Value; }
+  void setOpenMPOffloadMandatory(bool Value) { OpenMPOffloadMandatory = Value; 
}
   void setFirstSeparator(StringRef FS) { FirstSeparator = FS; }
   void setSeparator(StringRef S) { Separator = S; }
 
@@ -449,14 +450,9 @@ class OpenMPIRBuilder {
 
   /// Initialize the internal state, this will put structures types and
   /// potentially other helpers into the underlying module. Must be called
-  /// before any other method and only once! This internal state includes
-  /// Types used in the OpenMPIRBuilder generated from OMPKinds.def as well
-  /// as loading offload metadata for device from the OpenMP host IR file
-  /// passed in as the HostFilePath argument.
-  /// \param HostFilePath The path to the host IR file, used to load in
-  /// offload metadata for the device, allowing host and device to
-  /// maintain the same metadata mapping.
-  void initialize(StringRef HostFilePath = {});
+  /// before any other method and only once! This internal state includes types
+  /// used in the OpenMPIRBuilder generated from OMPKinds.def.
+  void initialize();
 
   void setConfig(OpenMPIRBuilderConfig C) { Config = C; }
 
@@ -2519,6 +2515,15 @@ class OpenMPIRBuilder {
   /// loaded from bitcode file, i.e, 
diff erent from OpenMPIRBuilder::M module.
   void loadOffloadInfoMetadata(Module &M);
 
+  /// Loads all the offload entries information from the host IR
+  /// metadata read from the file passed in as the HostFilePath argument. This
+  /// function is only meant to be used with device code generation.
+  ///
+  /// \param HostFilePath The path to the host IR file,
+  /// used to load in offload metadata for the device, allowing host and device
+  /// to maintain the same metadata mapping.
+  void loadOffloadInfoMetadata(StringRef HostFilePath);
+
   /// Gets (if variable with the given name already exist) or creates
   /// internal global variable with the specified Name. The created variable 
has
   /// linkage CommonLinkage by default and is initialized by null value.

diff  --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp 
b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index cc6054cb19d7806..9341c529c603e5d 100644
--- a/llvm/lib/Frontend/

[PATCH] D147219: [OpenMP][Flang][MLIR] Lowering of requires directive from MLIR to LLVM IR

2023-09-14 Thread Sergio Afonso via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9058762789c0: [OpenMP][Flang][MLIR] Lowering of requires 
directive from MLIR to LLVM IR (authored by skatrak).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147219

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
  mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
  mlir/test/Target/LLVMIR/openmp-llvm.mlir

Index: mlir/test/Target/LLVMIR/openmp-llvm.mlir
===
--- mlir/test/Target/LLVMIR/openmp-llvm.mlir
+++ mlir/test/Target/LLVMIR/openmp-llvm.mlir
@@ -2661,3 +2661,12 @@
 // CHECK: call void @foo_after()
 // CHECK: ret void
 
+// -
+
+// Check that OpenMP requires flags are registered by a global constructor.
+// CHECK: @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }]
+// CHECK-SAME: [{ i32, ptr, ptr } { i32 0, ptr @[[REG_FN:.*]], ptr null }]
+// CHECK: define {{.*}} @[[REG_FN]]({{.*}})
+// CHECK-NOT: }
+// CHECK:   call void @__tgt_register_requires(i64 10)
+module attributes {omp.requires = #omp} {}
Index: mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
===
--- mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
+++ mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
@@ -1278,32 +1278,18 @@
 llvm::OpenMPIRBuilder *ModuleTranslation::getOpenMPBuilder() {
   if (!ompBuilder) {
 ompBuilder = std::make_unique(*llvmModule);
+ompBuilder->initialize();
 
-bool isTargetDevice = false, isGPU = false;
-llvm::StringRef hostIRFilePath = "";
-
-if (auto deviceAttr =
-mlirModule->getAttrOfType("omp.is_target_device"))
-  isTargetDevice = deviceAttr.getValue();
-
-if (auto gpuAttr = mlirModule->getAttrOfType("omp.is_gpu"))
-  isGPU = gpuAttr.getValue();
-
-if (auto filepathAttr =
-mlirModule->getAttrOfType("omp.host_ir_filepath"))
-  hostIRFilePath = filepathAttr.getValue();
-
-ompBuilder->initialize(hostIRFilePath);
-
-// TODO: set the flags when available
-llvm::OpenMPIRBuilderConfig config(
-isTargetDevice, isGPU,
+// Flags represented as top-level OpenMP dialect attributes are set in
+// `OpenMPDialectLLVMIRTranslationInterface::amendOperation()`. Here we set
+// the default configuration.
+ompBuilder->setConfig(llvm::OpenMPIRBuilderConfig(
+/* IsTargetDevice = */ false, /* IsGPU = */ false,
 /* OpenMPOffloadMandatory = */ false,
 /* HasRequiresReverseOffload = */ false,
 /* HasRequiresUnifiedAddress = */ false,
 /* HasRequiresUnifiedSharedMemory = */ false,
-/* HasRequiresDynamicAllocators = */ false);
-ompBuilder->setConfig(config);
+/* HasRequiresDynamicAllocators = */ false));
   }
   return ompBuilder.get();
 }
Index: mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
===
--- mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
+++ mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
@@ -17,6 +17,7 @@
 #include "mlir/IR/IRMapping.h"
 #include "mlir/IR/Operation.h"
 #include "mlir/Support/LLVM.h"
+#include "mlir/Support/LogicalResult.h"
 #include "mlir/Target/LLVMIR/Dialect/OpenMPCommon.h"
 #include "mlir/Target/LLVMIR/ModuleTranslation.h"
 #include "mlir/Transforms/RegionUtils.h"
@@ -28,6 +29,8 @@
 #include "llvm/IR/DebugInfoMetadata.h"
 #include "llvm/IR/IRBuilder.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Transforms/Utils/ModuleUtils.h"
+#include 
 
 using namespace mlir;
 
@@ -1165,7 +1168,7 @@
 }
 
 /// Convert an Atomic Ordering attribute to llvm::AtomicOrdering.
-llvm::AtomicOrdering
+static llvm::AtomicOrdering
 convertAtomicOrdering(std::optional ao) {
   if (!ao)
 return llvm::AtomicOrdering::Monotonic; // Default Memory Ordering
@@ -1932,6 +1935,27 @@
   return success();
 }
 
+/// Converts the module-level set of OpenMP requires clauses into LLVM IR using
+/// OpenMPIRBuilder.
+static LogicalResult
+convertRequiresAttr(Operation &op, omp::ClauseRequiresAttr requiresAttr,
+LLVM::ModuleTranslation &moduleTranslation) {
+  auto *ompBuilder = moduleTranslation.getOpenMPBuilder();
+
+  // No need to read requiresAttr here, because it has already been done in
+  // translateModuleToLLVMIR(). There, flags are stored in the
+  // OpenMPIRBuilderConfig object, available to the OpenMPIRBuilder.
+  auto *regFn =
+  ompBuilder->createRegisterRequires(ompBuilder->createPlatformSpecificName(
+  {"omp_offloading", "requires_reg"}));
+
+  // Add registration function as global constructor
+  if (regFn)
+llvm::appendToGlobal

[clang] [AArch64] Remove copy instruction between uaddlv with v8i16 and dup (PR #66068)

2023-09-14 Thread David Green via cfe-commits


@@ -194,8 +194,23 @@ entry:
   ret <8 x i8> %vrshrn_n2
 }
 
-declare <8 x i8> @llvm.aarch64.neon.rshrn.v8i8(<8 x i16>, i32)
+define dso_local <8 x i16> @uaddlv_dup_v8i16(<8 x i16> %a) {
+; CHECK-LABEL: uaddlv_dup_v8i16:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:uaddlv s0, v0.8h
+; CHECK-NEXT:dup v1.8h, v0.h[0]
+; CHECK-NEXT:rshrn v0.4h, v1.4s, #3
+; CHECK-NEXT:rshrn2 v0.8h, v1.4s, #3
+; CHECK-NEXT:ret
+entry:
+  %vaddlv.i = tail call i32 @llvm.aarch64.neon.uaddlv.i32.v8i16(<8 x i16> %a)
+  %vecinit.i = insertelement <8 x i32> undef, i32 %vaddlv.i, i64 0
+  %vecinit7.i = shufflevector <8 x i32> %vecinit.i, <8 x i32> poison, <8 x 
i32> zeroinitializer
+  %vrshrn_n2 = tail call <8 x i16> @llvm.aarch64.neon.rshrn.v8i16(<8 x i32> 
%vecinit7.i, i32 3)

davemgreen wrote:

This isn't a valid neon intrinsic - they need to legal vector sizes for the 
inputs and outputs. I think it works in this case because it gets expanded to 
shifts and whatnot. Is there another instruction that could be used in it's 
place for the test? Maybe just a simple shift?

https://github.com/llvm/llvm-project/pull/66068
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [AArch64] Remove copy instruction between uaddlv with v8i16 and dup (PR #66068)

2023-09-14 Thread David Green via cfe-commits


@@ -194,8 +194,23 @@ entry:
   ret <8 x i8> %vrshrn_n2
 }
 
-declare <8 x i8> @llvm.aarch64.neon.rshrn.v8i8(<8 x i16>, i32)
+define dso_local <8 x i16> @uaddlv_dup_v8i16(<8 x i16> %a) {
+; CHECK-LABEL: uaddlv_dup_v8i16:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:uaddlv s0, v0.8h
+; CHECK-NEXT:dup v1.8h, v0.h[0]

davemgreen wrote:

I think the .8h might be incorrect here?

https://github.com/llvm/llvm-project/pull/66068
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [AArch64] Remove copy instruction between uaddlv with v8i16 and dup (PR #66068)

2023-09-14 Thread David Green via cfe-commits


@@ -6077,6 +6077,8 @@ defm : DUPWithTruncPats;
 defm : DUPWithTruncPats;
 defm : DUPWithTruncPats;
 
+defm : DUPWithTruncPats;

davemgreen wrote:

There isn't really an trunc going on here, If I'm understanding what is going 
on. Can we add a DAG combine for
```
  t38: i32 = extract_vector_elt t36, Constant:i64<0>
t35: v4i32 = AArch64ISD::DUP t38
```
We should be able to turn that into a AArch64ISD::DUPLANE, and it should be 
generally useful to do so I believe.

https://github.com/llvm/llvm-project/pull/66068
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [AArch64] Remove copy instruction between uaddlv with v8i16 and dup (PR #66068)

2023-09-14 Thread David Green via cfe-commits


@@ -194,8 +194,23 @@ entry:
   ret <8 x i8> %vrshrn_n2
 }
 
-declare <8 x i8> @llvm.aarch64.neon.rshrn.v8i8(<8 x i16>, i32)
+define dso_local <8 x i16> @uaddlv_dup_v8i16(<8 x i16> %a) {
+; CHECK-LABEL: uaddlv_dup_v8i16:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:uaddlv s0, v0.8h
+; CHECK-NEXT:dup v1.8h, v0.h[0]
+; CHECK-NEXT:rshrn v0.4h, v1.4s, #3
+; CHECK-NEXT:rshrn2 v0.8h, v1.4s, #3
+; CHECK-NEXT:ret
+entry:
+  %vaddlv.i = tail call i32 @llvm.aarch64.neon.uaddlv.i32.v8i16(<8 x i16> %a)
+  %vecinit.i = insertelement <8 x i32> undef, i32 %vaddlv.i, i64 0
+  %vecinit7.i = shufflevector <8 x i32> %vecinit.i, <8 x i32> poison, <8 x 
i32> zeroinitializer
+  %vrshrn_n2 = tail call <8 x i16> @llvm.aarch64.neon.rshrn.v8i16(<8 x i32> 
%vecinit7.i, i32 3)

davemgreen wrote:

This isn't a valid neon intrinsic - they need to legal vector sizes for the 
inputs and outputs. I think it works in this case because it gets expanded to 
shifts and whatnot. Is there another instruction that could be used in it's 
place for the test? Maybe just a simple shift?

https://github.com/llvm/llvm-project/pull/66068
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [AArch64] Remove copy instruction between uaddlv with v8i16 and dup (PR #66068)

2023-09-14 Thread David Green via cfe-commits


@@ -5329,7 +5329,8 @@ SDValue 
AArch64TargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op,
   case Intrinsic::aarch64_neon_uaddlv: {
 EVT OpVT = Op.getOperand(1).getValueType();
 EVT ResVT = Op.getValueType();
-if (ResVT == MVT::i32 && (OpVT == MVT::v8i8 || OpVT == MVT::v16i8)) {
+if (ResVT == MVT::i32 &&
+(OpVT == MVT::v8i8 || OpVT == MVT::v16i8 || OpVT == MVT::v8i16)) {

davemgreen wrote:

Should this add v4i16 too?

https://github.com/llvm/llvm-project/pull/66068
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [AArch64] Remove copy instruction between uaddlv with v8i16 and dup (PR #66068)

2023-09-14 Thread David Green via cfe-commits


@@ -194,8 +194,23 @@ entry:
   ret <8 x i8> %vrshrn_n2
 }
 
-declare <8 x i8> @llvm.aarch64.neon.rshrn.v8i8(<8 x i16>, i32)
+define dso_local <8 x i16> @uaddlv_dup_v8i16(<8 x i16> %a) {
+; CHECK-LABEL: uaddlv_dup_v8i16:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:uaddlv s0, v0.8h
+; CHECK-NEXT:dup v1.8h, v0.h[0]

davemgreen wrote:

I think the .8h might be incorrect here?

https://github.com/llvm/llvm-project/pull/66068
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 0b2778d - [analyzer] Fix StdLibraryFunctionsChecker crash on surprising sink node (#66109)

2023-09-14 Thread via cfe-commits

Author: DonatNagyE
Date: 2023-09-14T11:51:46+02:00
New Revision: 0b2778d5e59192331351e082a354843b0e9c1235

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

LOG: [analyzer] Fix StdLibraryFunctionsChecker crash on surprising sink node 
(#66109)

Recent changes in StdLibraryFunctionsChecker introduced a situation
where the checker sequentially performed two state transitions to add
two separate note tags.

In the unlikely case when the updated state (the variable `NewState`)
was posteriorly overconstrained, the engine marked the node after the
first state transition as a sink to stop the "natural" graph exploration
after that point.

However, in this particular case the checker tried to directly add a
second node, and this triggered an assertion in the `addPredecessor()`
method of `ExplodedNode`.

This commit introduces an explicit `isSink()` check to avoid this crash.
To avoid similar bugs in the future, perhaps it would be possible to
tweak `addTransition()` and ensure that it returns `nullptr` when it
would return a sink node (to unify the two possible error conditions).

This crash was observed in an analysis of the curl project (in a very
long and complex function), and there I validated that this is the root
cause, but I don't have a self-contained testcase that can trigger the
creation of a PosteriorlyOverconstrained node in this situation.

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
index f5f6e3a91237686..13bb9cef5e490ed 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -1387,8 +1387,8 @@ void StdLibraryFunctionsChecker::checkPostCall(const 
CallEvent &Call,
 if (!NewState)
   continue;
 
-// It is possible that NewState == State is true.
-// It can occur if another checker has applied the state before us.
+// Here it's possible that NewState == State, e.g. when other checkers
+// already applied the same constraints (or stricter ones).
 // Still add these note tags, the other checker should add only its
 // specialized note tags. These general note tags are handled always by
 // StdLibraryFunctionsChecker.
@@ -1427,7 +1427,12 @@ void StdLibraryFunctionsChecker::checkPostCall(const 
CallEvent &Call,
 });
 Pred = C.addTransition(NewState, Pred, Tag);
   }
-  if (!Pred)
+
+  // Pred may be:
+  //  - a nullpointer, if we reach an already existing node 
(theoretically);
+  //  - a sink, when NewState is posteriorly overconstrained.
+  // In these situations we cannot add the errno note tag.
+  if (!Pred || Pred->isSink())
 continue;
 }
 



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


[clang] [analyzer] Fix StdLibraryFunctionsChecker crash on surprising sink node (PR #66109)

2023-09-14 Thread via cfe-commits

https://github.com/DonatNagyE closed 
https://github.com/llvm/llvm-project/pull/66109
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 909c963 - [analyzer] Fix stdin declaration in C++ tests (#66074)

2023-09-14 Thread Balazs Benics via cfe-commits

Author: Balazs Benics
Date: 2023-09-14T11:55:10+02:00
New Revision: 909c9639994b5467e8c8424580063e29139d1def

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

LOG: [analyzer] Fix stdin declaration in C++ tests (#66074)

The `stdin` declaration should be within `extern "C" {...}`, in C++
mode. In addition, it should be also marked `extern` in both C and
C++ modes.

I tightened the check to ensure we only accept `stdin` if both of these
match. However, from the Juliet test suite's perspective, this commit
should not matter.

https://github.com/llvm/llvm-project/pull/66074

Added: 


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

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
index 3dcb45c0b110383..8138c8411fb2613 100644
--- a/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
@@ -104,8 +104,7 @@ bool isStdin(SVal Val, const ASTContext &ACtx) {
   // variable named stdin with the proper type.
   if (const auto *D = dyn_cast_or_null(DeclReg->getDecl())) {
 D = D->getCanonicalDecl();
-// FIXME: This should look for an exact match.
-if (D->getName().contains("stdin") && D->isExternC()) {
+if (D->getName() == "stdin" && D->hasExternalStorage() && D->isExternC()) {
   const QualType FILETy = ACtx.getFILEType().getCanonicalType();
   const QualType Ty = D->getType().getCanonicalType();
 

diff  --git a/clang/test/Analysis/taint-diagnostic-visitor.c 
b/clang/test/Analysis/taint-diagnostic-visitor.c
index 663836836d3db67..f1b9ceebdd9a6b8 100644
--- a/clang/test/Analysis/taint-diagnostic-visitor.c
+++ b/clang/test/Analysis/taint-diagnostic-visitor.c
@@ -13,7 +13,7 @@ size_t strlen( const char* str );
 void *malloc(size_t size );
 void free( void *ptr );
 char *fgets(char *str, int n, FILE *stream);
-FILE *stdin;
+extern FILE *stdin;
 
 void taintDiagnostic(void)
 {

diff  --git a/clang/test/Analysis/taint-generic.cpp 
b/clang/test/Analysis/taint-generic.cpp
index 09cd54471948e1a..c907c8f5eeb958b 100644
--- a/clang/test/Analysis/taint-generic.cpp
+++ b/clang/test/Analysis/taint-generic.cpp
@@ -7,6 +7,12 @@ int scanf(const char*, ...);
 int mySource1();
 int mySource3();
 
+typedef struct _FILE FILE;
+extern "C" {
+extern FILE *stdin;
+}
+int fscanf(FILE *stream, const char *format, ...);
+
 bool isOutOfRange2(const int*);
 
 void mySink2(int);
@@ -124,3 +130,9 @@ void testConfigurationMemberFunc() {
   foo.myMemberScanf("%d", &x);
   Buffer[x] = 1; // expected-warning {{Out of bound memory access }}
 }
+
+void testReadingFromStdin(char **p) {
+  int n;
+  fscanf(stdin, "%d", &n);
+  Buffer[n] = 1; // expected-warning {{Out of bound memory access (index is 
tainted)}}
+}



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


[clang] 8243bc4 - [analyzer] Make socket `accept()` propagate taint (#66074)

2023-09-14 Thread Balazs Benics via cfe-commits

Author: Balazs Benics
Date: 2023-09-14T11:55:10+02:00
New Revision: 8243bc40452bc90fa4f66a374d088907c1fe38cb

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

LOG: [analyzer] Make socket `accept()` propagate taint (#66074)

This allows to track taint on real code from `socket()`
to reading into a buffer using `recv()`.

https://github.com/llvm/llvm-project/pull/66074

Added: 


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

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
index 8138c8411fb2613..54c3f6dcdddaf59 100644
--- a/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
@@ -621,6 +621,7 @@ void GenericTaintChecker::initTaintRules(CheckerContext &C) 
const {
   {{{"getlogin_r"}}, TR::Source({{0}})},
 
   // Props
+  {{{"accept"}}, TR::Prop({{0}}, {{ReturnValueIndex}})},
   {{{"atoi"}}, TR::Prop({{0}}, {{ReturnValueIndex}})},
   {{{"atol"}}, TR::Prop({{0}}, {{ReturnValueIndex}})},
   {{{"atoll"}}, TR::Prop({{0}}, {{ReturnValueIndex}})},

diff  --git a/clang/test/Analysis/taint-generic.c 
b/clang/test/Analysis/taint-generic.c
index b7906d201e4fad3..e58b9c71a757821 100644
--- a/clang/test/Analysis/taint-generic.c
+++ b/clang/test/Analysis/taint-generic.c
@@ -544,6 +544,10 @@ void testFread(const char *fname, int *buffer, size_t 
size, size_t count) {
 }
 
 ssize_t recv(int sockfd, void *buf, size_t len, int flags);
+int accept(int fd, struct sockaddr *addr, socklen_t *addrlen);
+int bind(int fd, const struct sockaddr *addr, socklen_t addrlen);
+int listen(int fd, int backlog);
+
 void testRecv(int *buf, size_t len, int flags) {
   int fd;
   scanf("%d", &fd); // fake a tainted a file descriptor
@@ -1107,3 +,10 @@ void testProctitle2(char *real_argv[]) {
   setproctitle_init(1, argv, 0); // expected-warning {{Untrusted data 
is passed to a user-defined sink}}
   setproctitle_init(1, real_argv, argv); // expected-warning {{Untrusted data 
is passed to a user-defined sink}}
 }
+
+void testAcceptPropagates() {
+  int listenSocket = socket(2, 1, 6);
+  clang_analyzer_isTainted_int(listenSocket); // expected-warning {{YES}}
+  int acceptSocket = accept(listenSocket, 0, 0);
+  clang_analyzer_isTainted_int(acceptSocket); // expected-warning {{YES}}
+}



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


[clang] 61924da - [analyzer] Propagate taint for wchar variants of some APIs (#66074)

2023-09-14 Thread Balazs Benics via cfe-commits

Author: Balazs Benics
Date: 2023-09-14T11:55:10+02:00
New Revision: 61924da630532c91f00351b7e84548eb42e2e1e0

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

LOG: [analyzer] Propagate taint for wchar variants of some APIs (#66074)

Functions like `fgets`, `strlen`, `strcat` propagate taint.
However, their `wchar_t` variants don't. This patch fixes that.

Notice, that there could be many more APIs missing.
This patch intends to fix those that so far surfaced,
instead of exhaustively fixing this issue.

https://github.com/llvm/llvm-project/pull/66074

Added: 


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

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
index 54c3f6dcdddaf59..5da0f34b3d0464f 100644
--- a/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
@@ -628,6 +628,7 @@ void GenericTaintChecker::initTaintRules(CheckerContext &C) 
const {
   {{{"fgetc"}}, TR::Prop({{0}}, {{ReturnValueIndex}})},
   {{{"fgetln"}}, TR::Prop({{0}}, {{ReturnValueIndex}})},
   {{{"fgets"}}, TR::Prop({{2}}, {{0, ReturnValueIndex}})},
+  {{{"fgetws"}}, TR::Prop({{2}}, {{0, ReturnValueIndex}})},
   {{{"fscanf"}}, TR::Prop({{0}}, {{}, 2})},
   {{{"fscanf_s"}}, TR::Prop({{0}}, {{}, {2}})},
   {{{"sscanf"}}, TR::Prop({{0}}, {{}, 2})},
@@ -695,6 +696,7 @@ void GenericTaintChecker::initTaintRules(CheckerContext &C) 
const {
   {{{"strndup"}}, TR::Prop({{0}}, {{ReturnValueIndex}})},
   {{{"strndupa"}}, TR::Prop({{0}}, {{ReturnValueIndex}})},
   {{{"strlen"}}, TR::Prop({{0}}, {{ReturnValueIndex}})},
+  {{{"wcslen"}}, TR::Prop({{0}}, {{ReturnValueIndex}})},
   {{{"strnlen"}}, TR::Prop({{0}}, {{ReturnValueIndex}})},
   {{{"strtol"}}, TR::Prop({{0}}, {{1, ReturnValueIndex}})},
   {{{"strtoll"}}, TR::Prop({{0}}, {{1, ReturnValueIndex}})},
@@ -731,6 +733,8 @@ void GenericTaintChecker::initTaintRules(CheckerContext &C) 
const {
TR::Prop({{1}}, {{0, ReturnValueIndex}})},
   {{CDF_MaybeBuiltin, {{"strcat"}}},
TR::Prop({{1}}, {{0, ReturnValueIndex}})},
+  {{CDF_MaybeBuiltin, {{"wcsncat"}}},
+   TR::Prop({{1}}, {{0, ReturnValueIndex}})},
   {{CDF_MaybeBuiltin, {{"strdup"}}}, TR::Prop({{0}}, 
{{ReturnValueIndex}})},
   {{CDF_MaybeBuiltin, {{"strdupa"}}},
TR::Prop({{0}}, {{ReturnValueIndex}})},

diff  --git a/clang/test/Analysis/taint-generic.c 
b/clang/test/Analysis/taint-generic.c
index e58b9c71a757821..f08186fc8c4c1e5 100644
--- a/clang/test/Analysis/taint-generic.c
+++ b/clang/test/Analysis/taint-generic.c
@@ -56,7 +56,10 @@
 // CHECK-INVALID-ARG-SAME:rules greater or equal to -1
 
 typedef long long rsize_t;
+typedef typeof(sizeof(int)) size_t;
+typedef __WCHAR_TYPE__ wchar_t;
 void clang_analyzer_isTainted_char(char);
+void clang_analyzer_isTainted_wchar(wchar_t);
 void clang_analyzer_isTainted_charp(char*);
 void clang_analyzer_isTainted_int(int);
 
@@ -75,6 +78,17 @@ extern FILE *stdin;
 #define bool _Bool
 #define NULL (void*)0
 
+wchar_t *fgetws(wchar_t *ws, int n, FILE *stream);
+wchar_t *wmemset(wchar_t *wcs, wchar_t wc, unsigned long n);
+wchar_t *wmemcpy(wchar_t *dest, const wchar_t *src, size_t n);
+wchar_t *wmemmove(wchar_t *dest, const wchar_t *src, size_t n);
+size_t wcslen(const wchar_t *s);
+wchar_t *wcscpy(wchar_t * dest, const wchar_t * src);
+wchar_t *wcsncpy(wchar_t *dest, const wchar_t *src, size_t n);
+wchar_t *wcscat(wchar_t *dest, const wchar_t *src);
+wchar_t *wcsncat(wchar_t *dest,const wchar_t *src, size_t n);
+int swprintf(wchar_t *wcs, size_t maxlen, const wchar_t *format, ...);
+
 char *getenv(const char *name);
 
 FILE *fopen(const char *name, const char *mode);
@@ -430,6 +444,24 @@ int testSprintf_propagates_taint(char *buf, char *msg) {
   return 1 / x;// expected-warning {{Division by a tainted 
value, possibly zero}}
 }
 
+void test_wchar_apis_propagate(const char *path) {
+  FILE *f = fopen(path, "r");
+  clang_analyzer_isTainted_charp((char*)f);  // expected-warning {{YES}}
+  wchar_t wbuf[10];
+  fgetws(wbuf, sizeof(wbuf)/sizeof(*wbuf), f);
+  clang_analyzer_isTainted_wchar(*wbuf); // expected-warning {{YES}}
+  int n = wcslen(wbuf);
+  clang_analyzer_isTainted_int(n); // expected-warning {{YES}}
+
+  wchar_t dst[100] = L"ABC";
+  clang_analyzer_isTainted_wchar(*dst); // expected-warning {{NO}}
+  wcsncat(dst, wbuf, sizeof(wbuf)/sizeof(*wbuf));
+  clang_analyzer_isTainted_wchar(*dst); // expected-warning {{YES}}
+
+  int m = wcslen(dst);
+  clang_analyzer_isTainted_int(m); // expected-warning {{YES}}
+}
+
 int scanf_s(const

[clang] [analyzer] First batch of patches for the Juliet benchmark for taint improvements (PR #66074)

2023-09-14 Thread Balazs Benics via cfe-commits

steakhal wrote:

Merged manually, to allow landing these commits separately.

https://github.com/llvm/llvm-project/pull/66074
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer] First batch of patches for the Juliet benchmark for taint improvements (PR #66074)

2023-09-14 Thread Balazs Benics via cfe-commits

https://github.com/steakhal closed 
https://github.com/llvm/llvm-project/pull/66074
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 09ffb9e - [AArch64][Clang] Implement ACLE rintn intrinsics (#66112)

2023-09-14 Thread via cfe-commits

Author: M Iyengar
Date: 2023-09-14T11:00:49+01:00
New Revision: 09ffb9ee19a73d8369ce11502e991c190fdafe5c

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

LOG: [AArch64][Clang] Implement ACLE rintn intrinsics (#66112)

This patch adds support for two missing ACLE intrinsics for floating
point round with ties to even:

- rintn
- rintnf

These are specified in ACLE section 8.6:
[https://arm-software.github.io/acle/main/acle.html#floating-point-data-processing-intrinsics]

Added: 


Modified: 
clang/lib/Headers/arm_acle.h
clang/test/CodeGen/arm_acle.c

Removed: 




diff  --git a/clang/lib/Headers/arm_acle.h b/clang/lib/Headers/arm_acle.h
index c208512bab59829..61d80258d166a1d 100644
--- a/clang/lib/Headers/arm_acle.h
+++ b/clang/lib/Headers/arm_acle.h
@@ -592,6 +592,21 @@ __smusdx(int16x2_t __a, int16x2_t __b) {
 }
 #endif
 
+/* 8.6 Floating-point data-processing intrinsics */
+#if (defined(__ARM_FEATURE_DIRECTED_ROUNDING)&& \
+  (__ARM_FEATURE_DIRECTED_ROUNDING)) && \
+  (defined(__ARM_64BIT_STATE) && __ARM_64BIT_STATE)
+static __inline__ double __attribute__((__always_inline__, __nodebug__))
+__rintn(double __a) {
+  return __builtin_roundeven(__a);
+}
+
+static __inline__ float __attribute__((__always_inline__, __nodebug__))
+__rintnf(float __a) {
+  return __builtin_roundevenf(__a);
+}
+#endif
+
 /* 9.7 CRC32 intrinsics */
 #if (defined(__ARM_FEATURE_CRC32) && __ARM_FEATURE_CRC32) ||   
\
 (defined(__ARM_64BIT_STATE) && __ARM_64BIT_STATE)

diff  --git a/clang/test/CodeGen/arm_acle.c b/clang/test/CodeGen/arm_acle.c
index b1105a1d5aabb64..00afaf15fded392 100644
--- a/clang/test/CodeGen/arm_acle.c
+++ b/clang/test/CodeGen/arm_acle.c
@@ -1690,6 +1690,22 @@ int32_t test_jcvt(double v) {
 }
 #endif
 
+#if defined(__ARM_FEATURE_DIRECTED_ROUNDING) && defined(__ARM_64BIT_STATE)
+
+// AArch64-LABEL: @test_rintn(
+// AArch64-NEXT:  entry:
+// AArch64-NEXT:call double @llvm.roundeven.f64(double [[TMP0:%.*]])
+double test_rintn(double a) {
+  return __rintn(a);
+}
+
+// AArch64-LABEL: @test_rintnf(
+// AArch64-NEXT: entry:
+// AArch64-NEXT:  call float @llvm.roundeven.f32(float [[TMP0:%.*]])
+float test_rintnf(float b) {
+  return __rintnf(b);
+}
+#endif
 
 #if defined(__ARM_64BIT_STATE) && defined(__ARM_FEATURE_RNG)
 



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


[clang] [AArch64][Clang] Implement ACLE rintn intrinsics (PR #66112)

2023-09-14 Thread Victor Campos via cfe-commits

https://github.com/vhscampos closed 
https://github.com/llvm/llvm-project/pull/66112
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Fix a bug in ContinuationIndenter (PR #66354)

2023-09-14 Thread Owen Pan via cfe-commits

https://github.com/owenca created 
https://github.com/llvm/llvm-project/pull/66354:

See https://reviews.llvm.org/D136154#3890747 for context.

Fixes part of #58592.

>From 9a15ec3256e2d380d5eb70f0751ea1bb457895dd Mon Sep 17 00:00:00 2001
From: Owen Pan 
Date: Thu, 14 Sep 2023 02:59:43 -0700
Subject: [PATCH] [clang-format] Fix a bug in ContinuationIndenter

See https://reviews.llvm.org/D136154#3890747 for context.

Fixes part of #58592.
---
 clang/lib/Format/ContinuationIndenter.cpp |  5 +++--
 clang/unittests/Format/FormatTest.cpp | 23 +++
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index 75ab08de42ea0e8..8f14105751daefa 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -876,8 +876,9 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState 
&State, bool DryRun,
  FormatStyle::BCIS_AfterColon) {
 CurrentState.Indent = State.Column;
 CurrentState.LastSpace = State.Column;
-  } else if ((Previous.isOneOf(TT_BinaryOperator, TT_ConditionalExpr,
-   TT_CtorInitializerColon)) &&
+  } else if (Previous.isOneOf(TT_ConditionalExpr, TT_CtorInitializerColon)) {
+State.Stack.back().LastSpace = State.Column;
+  } else if (Previous.is(TT_BinaryOperator) &&
  ((Previous.getPrecedence() != prec::Assignment &&
(Previous.isNot(tok::lessless) || Previous.OperatorIndex != 0 ||
 Previous.NextOperator)) ||
diff --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 4f72166bdce2d73..0d0fbdb84e3271b 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -7108,6 +7108,29 @@ TEST_F(FormatTest, 
ExpressionIndentationBreakingBeforeOperators) {
"(someOtherLongishConditionPart1 || "
"someOtherEvenLongerNestedConditionPart2);",
Style);
+
+  Style = getLLVMStyleWithColumns(20);
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+  Style.BinPackParameters = false;
+  Style.BreakBeforeBinaryOperators = FormatStyle::BOS_NonAssignment;
+  Style.ContinuationIndentWidth = 2;
+  verifyFormat("struct Foo {\n"
+   "  Foo(\n"
+   "int arg1,\n"
+   "int arg2)\n"
+   "  : Base(\n"
+   "  arg1,\n"
+   "  arg2) {}\n"
+   "};",
+   Style);
+  verifyFormat("return abc\n"
+   " ? foo(\n"
+   " a,\n"
+   " b,\n"
+   " bar(\n"
+   "   abc))\n"
+   " : g(abc);",
+   Style);
 }
 
 TEST_F(FormatTest, ExpressionIndentationStrictAlign) {

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


[clang] [clang-format] Fix a bug in ContinuationIndenter (PR #66354)

2023-09-14 Thread via cfe-commits

https://github.com/llvmbot labeled 
https://github.com/llvm/llvm-project/pull/66354
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Fix a bug in ContinuationIndenter (PR #66354)

2023-09-14 Thread via cfe-commits

https://github.com/llvmbot labeled 
https://github.com/llvm/llvm-project/pull/66354
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Fix a bug in ContinuationIndenter (PR #66354)

2023-09-14 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang


Changes
See https://reviews.llvm.org/D136154#3890747 for context.

Fixes part of #58592.
--
Full diff: https://github.com/llvm/llvm-project/pull/66354.diff

2 Files Affected:

- (modified) clang/lib/Format/ContinuationIndenter.cpp (+3-2) 
- (modified) clang/unittests/Format/FormatTest.cpp (+23) 



diff --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index 75ab08de42ea0e8..8f14105751daefa 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -876,8 +876,9 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState 
&State, bool DryRun,
  FormatStyle::BCIS_AfterColon) {
 CurrentState.Indent = State.Column;
 CurrentState.LastSpace = State.Column;
-  } else if ((Previous.isOneOf(TT_BinaryOperator, TT_ConditionalExpr,
-   TT_CtorInitializerColon)) &&
+  } else if (Previous.isOneOf(TT_ConditionalExpr, TT_CtorInitializerColon)) {
+State.Stack.back().LastSpace = State.Column;
+  } else if (Previous.is(TT_BinaryOperator) &&
  ((Previous.getPrecedence() != prec::Assignment &&
(Previous.isNot(tok::lessless) || Previous.OperatorIndex != 0 ||
 Previous.NextOperator)) ||
diff --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 4f72166bdce2d73..0d0fbdb84e3271b 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -7108,6 +7108,29 @@ TEST_F(FormatTest, 
ExpressionIndentationBreakingBeforeOperators) {
"(someOtherLongishConditionPart1 || "
"someOtherEvenLongerNestedConditionPart2);",
Style);
+
+  Style = getLLVMStyleWithColumns(20);
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+  Style.BinPackParameters = false;
+  Style.BreakBeforeBinaryOperators = FormatStyle::BOS_NonAssignment;
+  Style.ContinuationIndentWidth = 2;
+  verifyFormat("struct Foo {\n"
+   "  Foo(\n"
+   "int arg1,\n"
+   "int arg2)\n"
+   "  : Base(\n"
+   "  arg1,\n"
+   "  arg2) {}\n"
+   "};",
+   Style);
+  verifyFormat("return abc\n"
+   " ? foo(\n"
+   " a,\n"
+   " b,\n"
+   " bar(\n"
+   "   abc))\n"
+   " : g(abc);",
+   Style);
 }
 
 TEST_F(FormatTest, ExpressionIndentationStrictAlign) {




https://github.com/llvm/llvm-project/pull/66354
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 2dee316 - Fixup "[analyzer] Propagate taint for wchar variants of some APIs"

2023-09-14 Thread Balazs Benics via cfe-commits

Author: Balazs Benics
Date: 2023-09-14T12:22:11+02:00
New Revision: 2dee316a04be3fa466944542ee05926f28aa9ce4

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

LOG: Fixup "[analyzer] Propagate taint for wchar variants of some APIs"

Fix build bot: https://lab.llvm.org/buildbot/#/builders/139/builds/49699

clang/test/Analysis/taint-generic.c:
```
Line 100: redefinition of typedef 'size_t' is a C11 feature
Line 59: previous definition is here
```

This commit fixups 61924da630532c91f00351b7e84548eb42e2e1e0
Committed in this PR: https://github.com/llvm/llvm-project/pull/66074

Added: 


Modified: 
clang/test/Analysis/taint-generic.c

Removed: 




diff  --git a/clang/test/Analysis/taint-generic.c 
b/clang/test/Analysis/taint-generic.c
index f08186fc8c4c1e5..c674a03cfaec6c8 100644
--- a/clang/test/Analysis/taint-generic.c
+++ b/clang/test/Analysis/taint-generic.c
@@ -56,7 +56,8 @@
 // CHECK-INVALID-ARG-SAME:rules greater or equal to -1
 
 typedef long long rsize_t;
-typedef typeof(sizeof(int)) size_t;
+typedef __typeof(sizeof(int)) size_t;
+typedef signed long long ssize_t;
 typedef __WCHAR_TYPE__ wchar_t;
 void clang_analyzer_isTainted_char(char);
 void clang_analyzer_isTainted_wchar(wchar_t);
@@ -97,8 +98,6 @@ int fscanf(FILE *restrict stream, const char *restrict 
format, ...);
 int sprintf(char *str, const char *format, ...);
 void setproctitle(const char *fmt, ...);
 void setproctitle_init(int argc, char *argv[], char *envp[]);
-typedef __typeof(sizeof(int)) size_t;
-typedef signed long long ssize_t;
 
 // Define string functions. Use builtin for some of them. They all default to
 // the processing in the taint checker.



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


[clang] [analyzer] Fix taint sink rules for exec-like functions (PR #66358)

2023-09-14 Thread Balazs Benics via cfe-commits

https://github.com/steakhal labeled 
https://github.com/llvm/llvm-project/pull/66358
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer] Fix taint sink rules for exec-like functions (PR #66358)

2023-09-14 Thread Balazs Benics via cfe-commits

https://github.com/steakhal created 
https://github.com/llvm/llvm-project/pull/66358:

Variadic arguments were not considered as taint sink arguments. I also decided 
to extend the list of exec-like functions.

(Juliet CWE78_OS_Command_Injection__char_connect_socket_execl)

---

This commit was split off from PR 
https://github.com/llvm/llvm-project/pull/66074 as requested.

>From 4b7a44c3f6267713375c43d9ccf25240d335ee53 Mon Sep 17 00:00:00 2001
From: Balazs Benics 
Date: Thu, 14 Sep 2023 11:55:10 +0200
Subject: [PATCH] [analyzer] Fix taint sink rules for exec-like functions

Variadic arguments were not considered as taint sink arguments.
I also decided to extend the list of exec-like functions.

(Juliet CWE78_OS_Command_Injection__char_connect_socket_execl)
---
 .../Checkers/GenericTaintChecker.cpp  |  14 +-
 clang/test/Analysis/taint-generic.c   | 161 +-
 2 files changed, 167 insertions(+), 8 deletions(-)

diff --git a/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
index 5da0f34b3d0464f..8ebedc1269dc1d1 100644
--- a/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
@@ -743,12 +743,14 @@ void GenericTaintChecker::initTaintRules(CheckerContext 
&C) const {
   // Sinks
   {{{"system"}}, TR::Sink({{0}}, MsgSanitizeSystemArgs)},
   {{{"popen"}}, TR::Sink({{0}}, MsgSanitizeSystemArgs)},
-  {{{"execl"}}, TR::Sink({{0}}, MsgSanitizeSystemArgs)},
-  {{{"execle"}}, TR::Sink({{0}}, MsgSanitizeSystemArgs)},
-  {{{"execlp"}}, TR::Sink({{0}}, MsgSanitizeSystemArgs)},
-  {{{"execvp"}}, TR::Sink({{0}}, MsgSanitizeSystemArgs)},
-  {{{"execvP"}}, TR::Sink({{0}}, MsgSanitizeSystemArgs)},
-  {{{"execve"}}, TR::Sink({{0}}, MsgSanitizeSystemArgs)},
+  {{{"execl"}}, TR::Sink({{}, {0}}, MsgSanitizeSystemArgs)},
+  {{{"execle"}}, TR::Sink({{}, {0}}, MsgSanitizeSystemArgs)},
+  {{{"execlp"}}, TR::Sink({{}, {0}}, MsgSanitizeSystemArgs)},
+  {{{"execv"}}, TR::Sink({{0, 1}}, MsgSanitizeSystemArgs)},
+  {{{"execve"}}, TR::Sink({{0, 1, 2}}, MsgSanitizeSystemArgs)},
+  {{{"fexecve"}}, TR::Sink({{0, 1, 2}}, MsgSanitizeSystemArgs)},
+  {{{"execvp"}}, TR::Sink({{0, 1}}, MsgSanitizeSystemArgs)},
+  {{{"execvpe"}}, TR::Sink({{0, 1, 2}}, MsgSanitizeSystemArgs)},
   {{{"dlopen"}}, TR::Sink({{0}}, MsgSanitizeSystemArgs)},
   {{CDF_MaybeBuiltin, {{"malloc"}}}, TR::Sink({{0}}, 
MsgTaintedBufferSize)},
   {{CDF_MaybeBuiltin, {{"calloc"}}}, TR::Sink({{0}}, 
MsgTaintedBufferSize)},
diff --git a/clang/test/Analysis/taint-generic.c 
b/clang/test/Analysis/taint-generic.c
index f08186fc8c4c1e5..dbe954d597054da 100644
--- a/clang/test/Analysis/taint-generic.c
+++ b/clang/test/Analysis/taint-generic.c
@@ -63,6 +63,8 @@ void clang_analyzer_isTainted_wchar(wchar_t);
 void clang_analyzer_isTainted_charp(char*);
 void clang_analyzer_isTainted_int(int);
 
+int coin();
+
 int scanf(const char *restrict format, ...);
 char *gets(char *str);
 char *gets_s(char *str, rsize_t n);
@@ -119,6 +121,41 @@ void *malloc(size_t);
 void *calloc(size_t nmemb, size_t size);
 void bcopy(void *s1, void *s2, size_t n);
 
+
+//function | pathname | filename | fd | arglist | argv[] | envp[]
+//===
+// 1  execl| X|  ||X||
+// 2  execle   | X|  ||X||   X
+// 3  execlp   |  | X||X||
+// 4  execv| X|  || |X   |
+// 5  execve   | X|  || |X   |   X
+// 6  execvp   |  | X|| |X   |
+// 7  execvpe  |  | X|| |X   |   X
+// 8  fexecve  |  |  |  X | |X   |   X
+//===
+//letter   |  | p|  f |l|v   |   e
+//
+// legend:
+//  - pathname: rel/abs path to the binary
+//  - filename: file name searched in PATH to execute the binary
+//  - fd:   accepts a file descriptor
+//  - arglist:  accepts variadic arguments
+//  - argv: accepts a pointer to array, denoting the new argv
+//  - envp: accepts a pointer to array, denoting the new envp
+
+int execl(const char *path, const char *arg, ...);
+int execle(const char *path, const char *arg, ...);
+int execlp(const char *file, const char *arg, ...);
+int execv(const char *path, char *const argv[]);
+int execve(const char *path, char *const argv[], char *const envp[]);
+int execvp(const char *file, char *const argv[]);
+int execvpe(const char *file, char *const argv[], char *const envp[]);
+int fexecve(int fd, char *const argv[], char *const envp[]);
+FILE *popen(const char *command, const char *type);
+int pclose(FILE *stream);
+int system(const char *command);

[clang] [analyzer] Fix taint sink rules for exec-like functions (PR #66358)

2023-09-14 Thread Balazs Benics via cfe-commits

https://github.com/steakhal review_requested 
https://github.com/llvm/llvm-project/pull/66358
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer] Fix taint sink rules for exec-like functions (PR #66358)

2023-09-14 Thread via cfe-commits

https://github.com/llvmbot labeled 
https://github.com/llvm/llvm-project/pull/66358
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer] Fix taint sink rules for exec-like functions (PR #66358)

2023-09-14 Thread via cfe-commits

https://github.com/llvmbot labeled 
https://github.com/llvm/llvm-project/pull/66358
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer] Fix taint sink rules for exec-like functions (PR #66358)

2023-09-14 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-static-analyzer-1


Changes
Variadic arguments were not considered as taint sink arguments. I also decided 
to extend the list of exec-like functions.

(Juliet CWE78_OS_Command_Injection__char_connect_socket_execl)

---

This commit was split off from PR 
https://github.com/llvm/llvm-project/pull/66074 as requested.
--
Full diff: https://github.com/llvm/llvm-project/pull/66358.diff

2 Files Affected:

- (modified) clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp (+8-6) 
- (modified) clang/test/Analysis/taint-generic.c (+159-2) 



diff --git a/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
index 5da0f34b3d0464f..8ebedc1269dc1d1 100644
--- a/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
@@ -743,12 +743,14 @@ void GenericTaintChecker::initTaintRules(CheckerContext 
&C) const {
   // Sinks
   {{{"system"}}, TR::Sink({{0}}, MsgSanitizeSystemArgs)},
   {{{"popen"}}, TR::Sink({{0}}, MsgSanitizeSystemArgs)},
-  {{{"execl"}}, TR::Sink({{0}}, MsgSanitizeSystemArgs)},
-  {{{"execle"}}, TR::Sink({{0}}, MsgSanitizeSystemArgs)},
-  {{{"execlp"}}, TR::Sink({{0}}, MsgSanitizeSystemArgs)},
-  {{{"execvp"}}, TR::Sink({{0}}, MsgSanitizeSystemArgs)},
-  {{{"execvP"}}, TR::Sink({{0}}, MsgSanitizeSystemArgs)},
-  {{{"execve"}}, TR::Sink({{0}}, MsgSanitizeSystemArgs)},
+  {{{"execl"}}, TR::Sink({{}, {0}}, 
MsgSanitizeSystemArgs)},
+  {{{"execle"}}, TR::Sink({{}, {0}}, 
MsgSanitizeSystemArgs)},
+  {{{"execlp"}}, TR::Sink({{}, {0}}, 
MsgSanitizeSystemArgs)},
+  {{{"execv"}}, TR::Sink({{0, 1}}, 
MsgSanitizeSystemArgs)},
+  {{{"execve"}}, TR::Sink({{0, 1, 2}}, 
MsgSanitizeSystemArgs)},
+  {{{"fexecve"}}, TR::Sink({{0, 1, 2}}, 
MsgSanitizeSystemArgs)},
+  {{{"execvp"}}, TR::Sink({{0, 1}}, 
MsgSanitizeSystemArgs)},
+  {{{"execvpe"}}, TR::Sink({{0, 1, 2}}, 
MsgSanitizeSystemArgs)},
   {{{"dlopen"}}, TR::Sink({{0}}, MsgSanitizeSystemArgs)},
   {{CDF_MaybeBuiltin, {{"malloc"}}}, TR::Sink({{0}}, 
MsgTaintedBufferSize)},
   {{CDF_MaybeBuiltin, {{"calloc"}}}, TR::Sink({{0}}, 
MsgTaintedBufferSize)},
diff --git a/clang/test/Analysis/taint-generic.c 
b/clang/test/Analysis/taint-generic.c
index f08186fc8c4c1e5..dbe954d597054da 100644
--- a/clang/test/Analysis/taint-generic.c
+++ b/clang/test/Analysis/taint-generic.c
@@ -63,6 +63,8 @@ void clang_analyzer_isTainted_wchar(wchar_t);
 void clang_analyzer_isTainted_charp(char*);
 void clang_analyzer_isTainted_int(int);
 
+int coin();
+
 int scanf(const char *restrict format, ...);
 char *gets(char *str);
 char *gets_s(char *str, rsize_t n);
@@ -119,6 +121,41 @@ void *malloc(size_t);
 void *calloc(size_t nmemb, size_t size);
 void bcopy(void *s1, void *s2, size_t n);
 
+
+//function | pathname | filename | fd | arglist | argv[] | envp[]
+//===
+// 1  execl| X|  ||X||
+// 2  execle   | X|  ||X||   X
+// 3  execlp   |  | X||X||
+// 4  execv| X|  || |X   |
+// 5  execve   | X|  || |X   |   X
+// 6  execvp   |  | X|| |X   |
+// 7  execvpe  |  | X|| |X   |   X
+// 8  fexecve  |  |  |  X | |X   |   X
+//===
+//letter   |  | p|  f |l|v   |   e
+//
+// legend:
+//  - pathname: rel/abs path to the binary
+//  - filename: file name searched in PATH to execute the binary
+//  - fd:   accepts a file descriptor
+//  - arglist:  accepts variadic arguments
+//  - argv: accepts a pointer to array, denoting the new argv
+//  - envp: accepts a pointer to array, denoting the new envp
+
+int execl(const char *path, const char *arg, ...);
+int execle(const char *path, const char *arg, ...);
+int execlp(const char *file, const char *arg, ...);
+int execv(const char *path, char *const argv[]);
+int execve(const char *path, char *const argv[], char *const envp[]);
+int execvp(const char *file, char *const argv[]);
+int execvpe(const char *file, char *const argv[], char *const envp[]);
+int fexecve(int fd, char *const argv[], char *const envp[]);
+FILE *popen(const char *command, const char *type);
+int pclose(FILE *stream);
+int system(const char *command);
+
+
 typedef size_t socklen_t;
 
 struct sockaddr {
@@ -225,7 +262,6 @@ void testUncontrolledFormatString(char **p) {
 
 }
 
-int system(const char 

[PATCH] D151834: Include math-errno with fast-math

2023-09-14 Thread Mikael Holmén via Phabricator via cfe-commits
uabelho added a comment.

What's the way forward here? Revert if it's unclear what to do?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151834

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


[clang] [clang][dataflow] Add a test for context-sensitive analysis on a self-referential class. (PR #66359)

2023-09-14 Thread via cfe-commits

https://github.com/martinboehme created 
https://github.com/llvm/llvm-project/pull/66359:

The test demonstrates that the `this` pointer seen in the constructor has the
same value as the address of the variable the object is constructed into.


>From c2219d46c4cdb5e82bf98d0249412c95c0781c97 Mon Sep 17 00:00:00 2001
From: Martin Braenne 
Date: Thu, 14 Sep 2023 11:06:24 +
Subject: [PATCH] [clang][dataflow] Add a test for context-sensitive analysis
 on a self-referential class.

The test demonstrates that the `this` pointer seen in the constructor has the
same value as the address of the variable the object is constructed into.
---
 .../Analysis/FlowSensitive/TransferTest.cpp   | 35 +++
 1 file changed, 35 insertions(+)

diff --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp 
b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
index 05ee5df0e95a433..e29dc86d7aaffb3 100644
--- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -5457,6 +5457,41 @@ TEST(TransferTest, ContextSensitiveConstructorDefault) {
   {BuiltinOptions{ContextSensitiveOptions{}}});
 }
 
+TEST(TransferTest, ContextSensitiveSelfReferentialClass) {
+  // Test that the `this` pointer seen in the constructor has the same value
+  // as the address of the variable the object is constructed into.
+  std::string Code = R"(
+class MyClass {
+public:
+  MyClass() : Self(this) {}
+  MyClass *Self;
+};
+
+void target() {
+  MyClass MyObj;
+  MyClass *SelfPtr = MyObj.Self;
+  // [[p]]
+}
+  )";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {
+ASSERT_THAT(Results.keys(), UnorderedElementsAre("p"));
+
+const ValueDecl *MyObjDecl = findValueDecl(ASTCtx, "MyObj");
+ASSERT_THAT(MyObjDecl, NotNull());
+
+const ValueDecl *SelfDecl = findValueDecl(ASTCtx, "SelfPtr");
+ASSERT_THAT(SelfDecl, NotNull());
+
+const Environment &Env = getEnvironmentAtAnnotation(Results, "p");
+auto &SelfVal = *cast(Env.getValue(*SelfDecl));
+EXPECT_EQ(Env.getStorageLocation(*MyObjDecl), 
&SelfVal.getPointeeLoc());
+  },
+  {BuiltinOptions{ContextSensitiveOptions{}}});
+}
+
 TEST(TransferTest, UnnamedBitfieldInitializer) {
   std::string Code = R"(
 struct B {};

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


[clang] [clang][dataflow] Add a test for context-sensitive analysis on a self-referential class. (PR #66359)

2023-09-14 Thread via cfe-commits

https://github.com/martinboehme review_requested 
https://github.com/llvm/llvm-project/pull/66359
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][dataflow] Add a test for context-sensitive analysis on a self-referential class. (PR #66359)

2023-09-14 Thread via cfe-commits

https://github.com/llvmbot labeled 
https://github.com/llvm/llvm-project/pull/66359
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][dataflow] Add a test for context-sensitive analysis on a self-referential class. (PR #66359)

2023-09-14 Thread via cfe-commits

https://github.com/llvmbot labeled 
https://github.com/llvm/llvm-project/pull/66359
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][dataflow] Add a test for context-sensitive analysis on a self-referential class. (PR #66359)

2023-09-14 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang


Changes
The test demonstrates that the `this` pointer seen in the constructor has the
same value as the address of the variable the object is constructed into.

--
Full diff: https://github.com/llvm/llvm-project/pull/66359.diff

1 Files Affected:

- (modified) clang/unittests/Analysis/FlowSensitive/TransferTest.cpp (+35) 



diff --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp 
b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
index 05ee5df0e95a433..e29dc86d7aaffb3 100644
--- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -5457,6 +5457,41 @@ TEST(TransferTest, ContextSensitiveConstructorDefault) {
   {BuiltinOptions{ContextSensitiveOptions{}}});
 }
 
+TEST(TransferTest, ContextSensitiveSelfReferentialClass) {
+  // Test that the `this` pointer seen in the constructor has the same value
+  // as the address of the variable the object is constructed into.
+  std::string Code = R"(
+class MyClass {
+public:
+  MyClass() : Self(this) {}
+  MyClass *Self;
+};
+
+void target() {
+  MyClass MyObj;
+  MyClass *SelfPtr = MyObj.Self;
+  // [[p]]
+}
+  )";
+  runDataflow(
+  Code,
+  [](const 
llvm::StringMap<DataflowAnalysisState<NoopLattice>> 
&Results,
+ ASTContext &ASTCtx) {
+ASSERT_THAT(Results.keys(), 
UnorderedElementsAre("p"));
+
+const ValueDecl *MyObjDecl = findValueDecl(ASTCtx, 
"MyObj");
+ASSERT_THAT(MyObjDecl, NotNull());
+
+const ValueDecl *SelfDecl = findValueDecl(ASTCtx, 
"SelfPtr");
+ASSERT_THAT(SelfDecl, NotNull());
+
+const Environment &Env = getEnvironmentAtAnnotation(Results, 
"p");
+auto &SelfVal = 
*cast<PointerValue>(Env.getValue(*SelfDecl));
+EXPECT_EQ(Env.getStorageLocation(*MyObjDecl), 
&SelfVal.getPointeeLoc());
+  },
+  {BuiltinOptions{ContextSensitiveOptions{}}});
+}
+
 TEST(TransferTest, UnnamedBitfieldInitializer) {
   std::string Code = R"(
 struct B {};




https://github.com/llvm/llvm-project/pull/66359
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 263fc4c - Turn off memory leaks in unit test

2023-09-14 Thread Benjamin Kramer via cfe-commits

Author: Benjamin Kramer
Date: 2023-09-14T13:16:22+02:00
New Revision: 263fc4c79a2b41a57dd1bf3a17873002c5d69265

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

LOG: Turn off memory leaks in unit test

Added: 


Modified: 
clang/unittests/Serialization/ForceCheckFileInputTest.cpp

Removed: 




diff  --git a/clang/unittests/Serialization/ForceCheckFileInputTest.cpp 
b/clang/unittests/Serialization/ForceCheckFileInputTest.cpp
index c1f6d40767751e4..ed0daa43436eb6d 100644
--- a/clang/unittests/Serialization/ForceCheckFileInputTest.cpp
+++ b/clang/unittests/Serialization/ForceCheckFileInputTest.cpp
@@ -75,6 +75,7 @@ export int aa = 43;
 std::shared_ptr Invocation =
 createInvocation(Args, CIOpts);
 EXPECT_TRUE(Invocation);
+Invocation->getFrontendOpts().DisableFree = false;
 
 auto Buf = CIOpts.VFS->getBufferForFile("a.cppm");
 EXPECT_TRUE(Buf);
@@ -113,6 +114,7 @@ export int aa = 43;
 std::shared_ptr Invocation =
 createInvocation(Args, CIOpts);
 EXPECT_TRUE(Invocation);
+Invocation->getFrontendOpts().DisableFree = false;
 
 CompilerInstance Clang;
 



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


  1   2   3   4   >