[PATCH] D137697: Move the isSelfContained function from clangd to libtooling.

2022-11-13 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

nit: isSelfContained/isSelfContainedHeader in commit message


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137697

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


[PATCH] D137897: Extend the number of case Sema::CheckForIntOverflow covers

2022-11-13 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

It looks like `conditional_callbacks.c` has been failing every once and while 
before this change. I can't seem to track down when it started yet.


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

https://reviews.llvm.org/D137897

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


[PATCH] D137531: [clang] Add the check of membership in decltype for the issue #58674

2022-11-13 Thread Liming Liu via Phabricator via cfe-commits
lime updated this revision to Diff 474987.
lime retitled this revision from "[clang] Add the check of decltype in derived 
templates for issue #58674" to "[clang] Add the check of membership in decltype 
for the issue #58674".
lime added a comment.
Herald added a subscriber: yaxunl.

Remove an if-statement.


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

https://reviews.llvm.org/D137531

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/decltype.cpp

Index: clang/test/SemaCXX/decltype.cpp
===
--- clang/test/SemaCXX/decltype.cpp
+++ clang/test/SemaCXX/decltype.cpp
@@ -101,6 +101,44 @@
   template void foo(decltype(T(LP1{ .p1 = g1, .p1.x[1] = 'x' }))) {}
 }
 
+namespace GH58674 {
+  struct Foo {
+float value_;
+struct nested {
+  float value_;
+};
+  };
+
+  template 
+  struct TemplateFoo {
+float value_;
+  };
+
+  float bar;
+
+  template 
+  struct Animal{};
+
+  template 
+  class Cat : Animal {
+using okay = decltype(Foo::value_);
+using also_okay = decltype(bar);
+using okay2 = decltype(Foo::nested::value_);
+using okay3 = decltype(TemplateFoo::value_);
+  public:
+void meow() {
+  using okay = decltype(Foo::value_);
+  using also_okay = decltype(bar);
+  using okay2 = decltype(Foo::nested::value_);
+  using okay3 = decltype(TemplateFoo::value_);
+}
+  };
+
+  void baz() {
+  Cat{}.meow();
+  }
+}
+
 template
 class conditional {
 };
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -2693,19 +2693,26 @@
   // spuriously dependent expression if we're inside a dependent
   // instance method.
   if (!R.empty() && (*R.begin())->isCXXClassMember()) {
-bool MightBeImplicitMember;
-if (!IsAddressOfOperand)
-  MightBeImplicitMember = true;
-else if (!SS.isEmpty())
-  MightBeImplicitMember = false;
-else if (R.isOverloadedResult())
-  MightBeImplicitMember = false;
-else if (R.isUnresolvableResult())
-  MightBeImplicitMember = true;
-else
-  MightBeImplicitMember = isa(R.getFoundDecl()) ||
-  isa(R.getFoundDecl()) ||
-  isa(R.getFoundDecl());
+bool MightBeImplicitMember = true, CheckField = true;
+if (IsAddressOfOperand) {
+  MightBeImplicitMember = SS.isEmpty() && !R.isOverloadedResult();
+  CheckField = !R.isUnresolvableResult();
+}
+if (MightBeImplicitMember && CheckField) {
+  if (R.isSingleResult() &&
+  isa(R.getFoundDecl())) {
+auto Class = cast((*R.begin())->getDeclContext());
+for (auto Curr = S->getLookupEntity(); Curr && !Curr->isFileContext();
+ Curr = Curr->getParent()) {
+  if (auto ThisClass = dyn_cast_if_present(Curr)) {
+if ((MightBeImplicitMember = ThisClass->Equals(Class) ||
+ ThisClass->isDerivedFrom(Class)))
+  break;
+  }
+}
+  } else if (IsAddressOfOperand)
+MightBeImplicitMember = false;
+}
 
 if (MightBeImplicitMember)
   return BuildPossibleImplicitMemberExpr(SS, TemplateKWLoc,
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -298,6 +298,9 @@
   and Clang 15 accidentally stopped predeclaring those functions in that
   language mode. Clang 16 now predeclares those functions again. This fixes
   `Issue 56607 `_.
+- Fix an issue about ``decltype`` in the members of class templates derived from
+  templates with related parameters.
+  `Issue 58674 `_
 
 Improvements to Clang's diagnostics
 ^^^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137181: [clang-format] Don't use 'PPIndentWidth' inside multi-line macros

2022-11-13 Thread Noah Goldstein via Phabricator via cfe-commits
goldstein.w.n added a comment.

In D137181#3923434 , @owenpan wrote:

> In D137181#3918715 , @goldstein.w.n 
> wrote:
>
>> In D137181#3918673 , @owenpan 
>> wrote:
>>
>>> Below is how I defined `PPLevel`:
>>>
>>>   $ git diff UnwrappedLineParser.h
>>>   diff --git a/clang/lib/Format/UnwrappedLineParser.h 
>>> b/clang/lib/Format/UnwrappedLineParser.h
>>>   index b9b106bcc89a..a234f6852e0c 100644
>>>   --- a/clang/lib/Format/UnwrappedLineParser.h
>>>   +++ b/clang/lib/Format/UnwrappedLineParser.h
>>>   @@ -43,6 +43,9 @@ struct UnwrappedLine {
>>>
>>>  /// The indent level of the \c UnwrappedLine.
>>>  unsigned Level;
>>>   +  /// The \c PPBranchLevel (adjusted for header guards) of the macro 
>>> definition
>>>   +  /// this line belongs to.
>>>   +  unsigned PPLevel;
>>>
>>>  /// Whether this \c UnwrappedLine is part of a preprocessor directive.
>>>  bool InPPDirective;
>>>   @@ -358,7 +361,7 @@ struct UnwrappedLineNode {
>>>};
>>>
>>>inline UnwrappedLine::UnwrappedLine()
>>>   -: Level(0), InPPDirective(false), InPragmaDirective(false),
>>>   +: Level(0), PPLevel(0), InPPDirective(false), 
>>> InPragmaDirective(false),
>>>  InMacroBody(false), MustBeDeclaration(false),
>>>  MatchingOpeningBlockLineIndex(kInvalidIndex) {}
>>>
>>>
>>> Conceptually, I think it's more accurate to make `PPLevel` to mean the PP 
>>> branching level of the `#define` line, not the first line of the macro 
>>> body. IMO it may simplify the changes you made to the formatter.
>>
>> Hmm? Not sure what you mean.
>
> Does the comments above `unsigned PPLevel;` in the above `git diff` output 
> help? Anyway, you already addressed my comment by decreasing `PPLevel` by 1, 
> so it's ok now.

Got it. Is the patch okay?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137181

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


[PATCH] D137205: [clang-tidy] Add performance-unnecessary-copy-on-last-use check

2022-11-13 Thread Fabian Keßler via Phabricator via cfe-commits
Febbe added a comment.

In D137205#3920016 , @firewave wrote:

> Getting this false positive:
>
>   #include 
>   
>   extern std::string str()
>   {
>   std::string ret;
>   return ret.empty() ? ret : ret.substr(1);
>   }
>
>
>
>   input.cpp:6:23: warning: Parameter 'ret' is copied on last use, consider 
> moving it instead. [performance-unnecessary-copy-on-last-use]
>   return ret.empty() ? ret : ret.substr(1);
>^
>std::move( )
>
> Appears to be caused by the ternary since I also have it inline with a 
> function parameter in another case.

As I know, the compilers can't copy elide always on ternary operators. 
Therefore, I have also a test, suggesting it on return.




Comment at: 
clang-tools-extra/docs/clang-tidy/checks/performance/unnecessary-copy-on-last-use.rst:50
+
+   A string specifying which include-style is used, `llvm` or `google`. Default
+   is `llvm`.

Eugene.Zelenko wrote:
> Could such option be shared between different checks? Or even rely on 
> `.clang-format`?
I just oriented myself at other similar checks, which introduced this. It uses 
both there:

```
UnnecessaryCopyOnLastUseCheck::UnnecessaryCopyOnLastUseCheck(
StringRef Name, ClangTidyContext *Context)
: ClangTidyCheck(Name, Context),
  Inserter(Options.getLocalOrGlobal("IncludeStyle",
utils::IncludeSorter::IS_LLVM),
```

Do you mean, that I can just remove the description of the option, because it 
is taken from global options?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137205

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


[PATCH] D137205: [clang-tidy] Add performance-unnecessary-copy-on-last-use check

2022-11-13 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/performance/unnecessary-copy-on-last-use.rst:50
+
+   A string specifying which include-style is used, `llvm` or `google`. Default
+   is `llvm`.

Febbe wrote:
> Eugene.Zelenko wrote:
> > Could such option be shared between different checks? Or even rely on 
> > `.clang-format`?
> I just oriented myself at other similar checks, which introduced this. It 
> uses both there:
> 
> ```
> UnnecessaryCopyOnLastUseCheck::UnnecessaryCopyOnLastUseCheck(
> StringRef Name, ClangTidyContext *Context)
> : ClangTidyCheck(Name, Context),
>   Inserter(Options.getLocalOrGlobal("IncludeStyle",
> utils::IncludeSorter::IS_LLVM),
> ```
> 
> Do you mean, that I can just remove the description of the option, because it 
> is taken from global options?
I'm personally of the idea that it should be removed. However that's out of the 
scope for this patch so for now thist should stick with the current convention.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137205

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


[PATCH] D137040: [clangd] Add heuristic for dropping snippet when completing member function pointer

2022-11-13 Thread Tom Praschan via Phabricator via cfe-commits
tom-anders updated this revision to Diff 474990.
tom-anders added a comment.

Clean up test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137040

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang/include/clang/Sema/CodeCompleteConsumer.h
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/unittests/Sema/CodeCompleteTest.cpp

Index: clang/unittests/Sema/CodeCompleteTest.cpp
===
--- clang/unittests/Sema/CodeCompleteTest.cpp
+++ clang/unittests/Sema/CodeCompleteTest.cpp
@@ -23,6 +23,8 @@
 
 using namespace clang;
 using namespace clang::tooling;
+using ::testing::AllOf;
+using ::testing::Contains;
 using ::testing::Each;
 using ::testing::UnorderedElementsAre;
 
@@ -36,6 +38,51 @@
   std::string PtrDiffType;
 };
 
+struct CompletedFunctionDecl {
+  std::string Name;
+  bool IsStatic;
+  bool CanBeCall;
+};
+MATCHER_P(named, name, "") { return arg.Name == name; }
+MATCHER_P(isStatic, value, "") { return arg.IsStatic == value; }
+MATCHER_P(canBeCall, value, "") { return arg.CanBeCall == value; }
+
+class SaveCompletedFunctions : public CodeCompleteConsumer {
+public:
+  SaveCompletedFunctions(std::vector &CompletedFuncDecls)
+  : CodeCompleteConsumer(/*CodeCompleteOpts=*/{}),
+CompletedFuncDecls(CompletedFuncDecls),
+CCTUInfo(std::make_shared()) {}
+
+  void ProcessCodeCompleteResults(Sema &S, CodeCompletionContext Context,
+  CodeCompletionResult *Results,
+  unsigned NumResults) override {
+for (unsigned I = 0; I < NumResults; ++I) {
+  auto R = Results[I];
+  if (R.Kind == CodeCompletionResult::RK_Declaration) {
+if (const auto *FD = llvm::dyn_cast(R.getDeclaration())) {
+  CompletedFunctionDecl D;
+  D.Name = FD->getNameAsString();
+  D.CanBeCall = R.FunctionCanBeCall;
+  D.IsStatic = FD->isStatic();
+  CompletedFuncDecls.emplace_back(std::move(D));
+}
+  }
+}
+  }
+
+private:
+  CodeCompletionAllocator &getAllocator() override {
+return CCTUInfo.getAllocator();
+  }
+
+  CodeCompletionTUInfo &getCodeCompletionTUInfo() override { return CCTUInfo; }
+
+  std::vector &CompletedFuncDecls;
+
+  CodeCompletionTUInfo CCTUInfo;
+};
+
 class VisitedContextFinder : public CodeCompleteConsumer {
 public:
   VisitedContextFinder(CompletionContext &ResultCtx)
@@ -74,19 +121,19 @@
 
 class CodeCompleteAction : public SyntaxOnlyAction {
 public:
-  CodeCompleteAction(ParsedSourceLocation P, CompletionContext &ResultCtx)
-  : CompletePosition(std::move(P)), ResultCtx(ResultCtx) {}
+  CodeCompleteAction(ParsedSourceLocation P, CodeCompleteConsumer *Consumer)
+  : CompletePosition(std::move(P)), Consumer(Consumer) {}
 
   bool BeginInvocation(CompilerInstance &CI) override {
 CI.getFrontendOpts().CodeCompletionAt = CompletePosition;
-CI.setCodeCompletionConsumer(new VisitedContextFinder(ResultCtx));
+CI.setCodeCompletionConsumer(Consumer);
 return true;
   }
 
 private:
   // 1-based code complete position ;
   ParsedSourceLocation CompletePosition;
-  CompletionContext &ResultCtx;
+  CodeCompleteConsumer *Consumer;
 };
 
 ParsedSourceLocation offsetToPosition(llvm::StringRef Code, size_t Offset) {
@@ -103,7 +150,7 @@
   CompletionContext ResultCtx;
   clang::tooling::runToolOnCodeWithArgs(
   std::make_unique(offsetToPosition(Code, Offset),
-   ResultCtx),
+   new VisitedContextFinder(ResultCtx)),
   Code, {"-std=c++11"}, TestCCName);
   return ResultCtx;
 }
@@ -129,6 +176,69 @@
   return Types;
 }
 
+std::vector
+CollectCompletedFunctions(StringRef Code, std::size_t Point) {
+  std::vector Result;
+  clang::tooling::runToolOnCodeWithArgs(
+  std::make_unique(offsetToPosition(Code, Point),
+   new SaveCompletedFunctions(Result)),
+  Code, {"-std=c++11"}, TestCCName);
+  return Result;
+}
+
+TEST(SemaCodeCompleteTest, FunctionCanBeCall) {
+  llvm::Annotations Code(R"cpp(
+struct Foo {
+  static int staticMethod();
+  int method() const;
+  Foo() {
+this->$canBeCall^
+$canBeCall^
+Foo::$canBeCall^
+  }
+};
+
+struct Derived : Foo {
+  Derived() {
+Foo::$canBeCall^
+  }
+};
+
+struct OtherClass {
+  OtherClass() {
+Foo f;
+f.$canBeCall^
+&Foo::$cannotBeCall^
+  }
+};
+
+int main() {
+  Foo f;
+  f.$canBeCall^
+  &Foo::$cannotBeCall^
+}
+)cpp");
+
+  for (const auto &P : Code.points("canBeCall")) {
+auto Results = CollectCompletedFunctions(Code.code(), P);
+EXPECT_THAT(Results, Contains(AllOf(named("method"), isStatic(false),
+   

[PATCH] D137787: [CodeGen] Relax assertion on generating destructor call

2022-11-13 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

In D137787#3921673 , @Hahnfeld wrote:

> I've trimmed the failing code down to
>
>   #include 
>   #include 
>   #include 
>   
>   template 
>   struct SO {
> void a() {
>   struct SI {
> std::vector v;
>   };
>   SI s;
>   SI m(std::move(s));
> }
>   
> void g() {
>   std::vector v{"a"};
> }
>   };
>
> in a header / module and
>
>   SO s;
>   s.a();
>   s.g();
>
> in the calling code. Sadly this works fine in standalone Clang...
>
> All of the above code seems to be important, starting from the outer 
> `template`, having two functions, moving a `std::vector` from a default 
> generated move constructor and then constructing a 
> `std::vector` with at least one element. If this rings a 
> bell for anybody or anybody has an idea where to go from here, please let me 
> know. I'm out of depth how to produce the exact failing conditions in a test. 
> I would argue that relaxing the `assert` is fine regardless because it still 
> tests that the `DtorDecl` belongs to this type, but I can't articulate why an 
> exact pointer comparison fails in very rare circumstances...

So the code look like:

  // foo.h
  #include 
  #include 
  #include 
  
  template 
  struct SO {
void a() {
  struct SI {
std::vector v;
  };
  SI s;
  SI m(std::move(s));
}
  
void g() {
  std::vector v{"a"};
}
  };
  
  // foo.cpp
  import "foo.h";
  void func() {
  SO s;
  s.a();
  s.g();
  }

Is it the reproducer? If it is, my suggestion would be:

- Preprocess `foo.h` into `foo.ii` then replace `import "foo.h";`
- Then reduce `foo.ii` step by step. There should be many things that can be 
removed.
- Then we found there is no things we can reduce, then it should be the test.

I know it sounds too hard at first. But I tried and it works although it would 
take one whole day. Here is an example for the reduced test case: 
https://github.com/llvm/llvm-project/commit/1aaba40dcbe8fdc93d825d1f4e22edaa3e9aa5b1,
 which is reduced from 2 system headers which contains 30,000+ lines of code.

> I would argue that relaxing the `assert` is fine regardless

Yes, I understood. But we hope it can land with a test case really. Otherwise, 
the same use case may be broken some time again without being noticed by any 
one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137787

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


Re: How can Autoconf help with the transition to stricter compilation defaults?

2022-11-13 Thread Paul Eggert via cfe-commits

On 2022-11-11 07:11, Aaron Ballman wrote:

We believe the runtime behavior is sufficiently dangerous to
warrant a conservative view that any call to a function will be a call
that gets executed at runtime, hence a definitive signature mismatch
is something we feel comfortable diagnosing (in some form) by default.


As long as these diagnostics by default do not cause the compiler to 
exit with nonzero status, we should be OK with Autoconf-generated 
'configure' scripts. Although there will be problems with people who run 
"./configure CFLAGS='-Werror'", that sort of usage has always been 
problematic and unsupported by Autoconf, so we can simply continue to 
tell people "don't do that".

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


Re: How can Autoconf help with the transition to stricter compilation defaults?

2022-11-13 Thread Paul Eggert via cfe-commits

On 2022-11-11 07:11, Aaron Ballman wrote:

Clang doesn't require such a linker (we work with various system linkers).


As long as the system linkers continue to work as they have 
traditionally worked, we're fine.



the frontend perspective, we can't tell the difference between
"trust me this is safe because it never gets executed" and "this is a
CVE"


If some system linker ever attempts to reject links with mismatched 
signatures, Autoconf-generated code will need to have a way to shut that 
off. I hope Clang maintainers can be cajoled into supporting that, if 
the time comes. Perhaps there can be a #pragma, or a compile-time 
option, to do that.

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


[PATCH] D137787: [CodeGen] Relax assertion on generating destructor call

2022-11-13 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

> Is it the reproducer?

No, as I wrote:

> Sadly this works fine in standalone Clang...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137787

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


[PATCH] D137762: [clang-format] avoid breaking )( with BlockIndent

2022-11-13 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:5006-5010
+return !((Previous && (Previous->is(tok::kw_for) || Previous->isIf())) ||
+ (Right.Next &&
+  (Right.Next->is(tok::l_paren) ||
+   (Right.Next->is(tok::r_paren) &&
+(Right.NestingLevel == 0 || Previous->is(tok::star));

gedare wrote:
> HazardyKnusperkeks wrote:
> > This is horrible to read.
> > 
> > Could you split this into multiple statements? Maybe with lambdas, I don't 
> > know.
> > 
> > But I have no intention to ever understand that condition.
> Sure. I was just following the prevailing style in this code base. I'll 
> refactor.
> Sure. I was just following the prevailing style in this code base. I'll 
> refactor.

No problem. We have some of this occurrences.



Comment at: clang/unittests/Format/FormatTest.cpp:7237-7243
+  EXPECT_EQ(StringRef("functionCall(\n"
+  "paramA, paramB, paramC\n"
+  ");\n"
+  "void functionDecl(\n"
+  "int A, int B, int C\n"
+  ");"),
+format(Input, Style));

I know you copy what is there, but could you use verifyFormat? You can port the 
other checks also, but are not obligated to.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137762

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


[PATCH] D137205: [clang-tidy] Add performance-unnecessary-copy-on-last-use check

2022-11-13 Thread Aaron Gokaslan via Phabricator via cfe-commits
Skylion007 added a comment.

The main false positive I also keep seeing is in pybind11 where it suggests 
call an std::move() for an implicit conversion, but the target of the implicit 
conversion does not have an rvalue. (In this case, we have a py::object which 
inherits from py::handle, and is just py::handle with ownership semantics. This 
allows implicit conversion to a reference at anytime, and therefore std::move 
has no effect here except to complicate the code a bit.




Comment at: 
clang-tools-extra/clang-tidy/performance/UnnecessaryCopyOnLastUseCheck.cpp:114-115
+static Usage definiteLastUse(ASTContext *Context, CFG *const TheCFG,
+ DeclRefExpr const *DeclRef) {
+  assert(TheCFG != nullptr);
+

This assertion is not valid. The crash I linked above is due to "TheCFG" 
sometimes being null unfortunately. Making it return Usage::Error stops the 
crash at least. Seems to happen when it cannot find an include . 




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137205

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


[PATCH] D137714: Do not merge traps in functions annotated optnone

2022-11-13 Thread Dan Liew via Phabricator via cfe-commits
delcypher added a comment.

Other than minor issue in the test this LGTM




Comment at: clang/test/CodeGen/ubsan-trap-debugloc.c:11
+void bar(volatile int a) __attribute__((optnone)) {
+  // CHECK: call void @llvm.ubsantrap(i8 0){{.*}} !dbg [[LOC2:![0-9]+]]
+  // CHECK: call void @llvm.ubsantrap(i8 0){{.*}} !dbg [[LOC3:![0-9]+]]

Could you add `CHECK-LABEL: @foo` and `CHECK-LABEL: @bar` to this test? This 
helps make it explicit which functions in the IR we are trying to match.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137714

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


[PATCH] D137375: [AIX][pg] Add Correct Search Paths for Profiled Libraries

2022-11-13 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 475005.
francii added a comment.

Add support for `--sysroot`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137375

Files:
  clang/lib/Driver/ToolChains/AIX.cpp


Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -243,6 +243,23 @@
   CmdArgs.push_back("-lm");
 
 CmdArgs.push_back("-lc");
+
+if (Args.hasArg(options::OPT_pg)) {
+  const char *libProfiled;
+  const char *usrLibProfiled;
+
+  if (!D.SysRoot.empty()) {
+libProfiled = Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+ "/lib/profiled");
+usrLibProfiled = Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+"/usr/lib/profiled");
+  } else {
+libProfiled = Args.MakeArgString(llvm::Twine("-L/lib/profiled"));
+usrLibProfiled = 
Args.MakeArgString(llvm::Twine("-L/usr/lib/profiled"));
+  }
+  CmdArgs.push_back(libProfiled);
+  CmdArgs.push_back(usrLibProfiled);
+}
   }
 
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());


Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -243,6 +243,23 @@
   CmdArgs.push_back("-lm");
 
 CmdArgs.push_back("-lc");
+
+if (Args.hasArg(options::OPT_pg)) {
+  const char *libProfiled;
+  const char *usrLibProfiled;
+
+  if (!D.SysRoot.empty()) {
+libProfiled = Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+ "/lib/profiled");
+usrLibProfiled = Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+"/usr/lib/profiled");
+  } else {
+libProfiled = Args.MakeArgString(llvm::Twine("-L/lib/profiled"));
+usrLibProfiled = Args.MakeArgString(llvm::Twine("-L/usr/lib/profiled"));
+  }
+  CmdArgs.push_back(libProfiled);
+  CmdArgs.push_back(usrLibProfiled);
+}
   }
 
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137375: [AIX][pg] Add Correct Search Paths for Profiled Libraries

2022-11-13 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 475006.
francii added a comment.

Removed unnecessary variables


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137375

Files:
  clang/lib/Driver/ToolChains/AIX.cpp


Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -245,20 +245,15 @@
 CmdArgs.push_back("-lc");
 
 if (Args.hasArg(options::OPT_pg)) {
-  const char *libProfiled;
-  const char *usrLibProfiled;
-
   if (!D.SysRoot.empty()) {
-libProfiled = Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
- "/lib/profiled");
-usrLibProfiled = Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
-"/usr/lib/profiled");
+CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+ "/lib/profiled"));
+CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+ "/usr/lib/profiled"));
   } else {
-libProfiled = Args.MakeArgString(llvm::Twine("-L/lib/profiled"));
-usrLibProfiled = 
Args.MakeArgString(llvm::Twine("-L/usr/lib/profiled"));
+CmdArgs.push_back("-L/lib/profiled");
+CmdArgs.push_back("-L/usr/lib/profiled");
   }
-  CmdArgs.push_back(libProfiled);
-  CmdArgs.push_back(usrLibProfiled);
 }
   }
 


Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -245,20 +245,15 @@
 CmdArgs.push_back("-lc");
 
 if (Args.hasArg(options::OPT_pg)) {
-  const char *libProfiled;
-  const char *usrLibProfiled;
-
   if (!D.SysRoot.empty()) {
-libProfiled = Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
- "/lib/profiled");
-usrLibProfiled = Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
-"/usr/lib/profiled");
+CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+ "/lib/profiled"));
+CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+ "/usr/lib/profiled"));
   } else {
-libProfiled = Args.MakeArgString(llvm::Twine("-L/lib/profiled"));
-usrLibProfiled = Args.MakeArgString(llvm::Twine("-L/usr/lib/profiled"));
+CmdArgs.push_back("-L/lib/profiled");
+CmdArgs.push_back("-L/usr/lib/profiled");
   }
-  CmdArgs.push_back(libProfiled);
-  CmdArgs.push_back(usrLibProfiled);
 }
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137375: [AIX][pg] Add Correct Search Paths for Profiled Libraries

2022-11-13 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 475007.
francii added a comment.

Soft reset


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137375

Files:
  clang/lib/Driver/ToolChains/AIX.cpp


Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -243,6 +243,18 @@
   CmdArgs.push_back("-lm");
 
 CmdArgs.push_back("-lc");
+
+if (Args.hasArg(options::OPT_pg)) {
+  if (!D.SysRoot.empty()) {
+CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+ "/lib/profiled"));
+CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+ "/usr/lib/profiled"));
+  } else {
+CmdArgs.push_back("-L/lib/profiled");
+CmdArgs.push_back("-L/usr/lib/profiled");
+  }
+}
   }
 
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());


Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -243,6 +243,18 @@
   CmdArgs.push_back("-lm");
 
 CmdArgs.push_back("-lc");
+
+if (Args.hasArg(options::OPT_pg)) {
+  if (!D.SysRoot.empty()) {
+CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+ "/lib/profiled"));
+CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+ "/usr/lib/profiled"));
+  } else {
+CmdArgs.push_back("-L/lib/profiled");
+CmdArgs.push_back("-L/usr/lib/profiled");
+  }
+}
   }
 
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137753: [Clang][GNU][AIX][p]Enable -p Functionality

2022-11-13 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 475009.
francii added a comment.

Updated Linux test case
Added profiled library search for AIX.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137753

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/linux-ld.c

Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -1572,6 +1572,13 @@
 // CHECK-CRTFASTMATH: usr/lib/gcc/x86_64-unknown-linux/10.2.0{{/|}}crtfastmath.o
 // CHECK-NOCRTFASTMATH-NOT: crtfastmath.o
 
+// Check that we link in gcrt1.o when compiling with -p
+// RUN: %clang -p --target=x86_64-unknown-linux -no-pie -### %s \
+// RUN:--gcc-toolchain="" \
+// RUN:--sysroot=%S/Inputs/basic_linux_tree 2>& 1 \
+// RUN:   | FileCheck --check-prefix=CHECK-P %s
+// CHECK-P: gcrt1.o
+
 // Check that we link in gcrt1.o when compiling with -pg
 // RUN: %clang -pg --target=x86_64-unknown-linux -no-pie -### %s \
 // RUN:--gcc-toolchain="" \
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -498,7 +498,7 @@
 if (!isAndroid && !IsIAMCU) {
   const char *crt1 = nullptr;
   if (!Args.hasArg(options::OPT_shared)) {
-if (Args.hasArg(options::OPT_pg))
+if (Args.hasArg(options::OPT_p, options::OPT_pg))
   crt1 = "gcrt1.o";
 else if (IsPIE)
   crt1 = "Scrt1.o";
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -521,7 +521,8 @@
 
 static bool useFramePointerForTargetByDefault(const ArgList &Args,
   const llvm::Triple &Triple) {
-  if (Args.hasArg(options::OPT_pg) && !Args.hasArg(options::OPT_mfentry))
+  if (Args.hasArg(options::OPT_p, options::OPT_pg) &&
+  !Args.hasArg(options::OPT_mfentry))
 return true;
 
   switch (Triple.getArch()) {
@@ -6268,6 +6269,7 @@
   Args.AddLastArg(CmdArgs, options::OPT_fms_hotpatch);
 
   if (TC.SupportsProfiling()) {
+Args.AddLastArg(CmdArgs, options::OPT_p);
 Args.AddLastArg(CmdArgs, options::OPT_pg);
 
 llvm::Triple::ArchType Arch = TC.getArch();
@@ -7388,7 +7390,7 @@
 C.getJobs().getJobs().back()->PrintInputFilenames = true;
   }
 
-  if (Arg *A = Args.getLastArg(options::OPT_pg))
+  if (Arg *A = Args.getLastArg(options::OPT_p, options::OPT_pg))
 if (FPKeepKind == CodeGenOptions::FramePointerKind::None &&
 !Args.hasArg(options::OPT_mfentry))
   D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer"
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -250,6 +250,18 @@
   CmdArgs.push_back("-lm");
 
 CmdArgs.push_back("-lc");
+
+if (Args.hasArg(options::OPT_p, options::OPT_pg)) {
+  if (!D.SysRoot.empty()) {
+CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+ "/lib/profiled"));
+CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
+ "/usr/lib/profiled"));
+  } else {
+CmdArgs.push_back("-L/lib/profiled");
+CmdArgs.push_back("-L/usr/lib/profiled");
+  }
+}
   }
 
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1043,7 +1043,8 @@
   // inlining, we just add an attribute to insert a mcount call in backend.
   // The attribute "counting-function" is set to mcount function name which is
   // architecture dependent.
-  if (CGM.getCodeGenOpts().InstrumentForProfiling) {
+  if (CGM.getCodeGenOpts().InstrumentForProfiling ||
+  CGM.getCodeGenOpts().InstrumentForProfilingGraph) {
 // Calls to fentry/mcount should not be generated if function has
 // the no_instrument_function attribute.
 if (!CurFuncDecl || !CurFuncDecl->hasAttr()) {
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -923,7 +923,8 @@
 if (CodeGenOpts.InstrumentFunctions ||
  

[PATCH] D133036: [InstCombine] Treat passing undef to noundef params as UB

2022-11-13 Thread Tim Neumann via Phabricator via cfe-commits
TimNN added a comment.

I'm sorry for the noise. Further investigation has shown that this happens when 
Rust is doing (thin) LTO, and I don't think this patch can be considered in any 
way "at fault" here, so this is the last you'll hear from me on the topic here.

I don't know whether the fault is with how Rust implements (thin) LTO or 
something on the LLVM side. Basically, after running the `FunctionImporter` on 
a module, we end up with a `define available_externally void outer` and a 
`declare void inner`, presumably coming from different modules. `outer` 
contains the call to `inner` with `poison`, but the parameter is `noundef` on 
the declaration on `inner`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133036

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


[PATCH] D137350: [RISCV] Implement assembler support for XVentanaCondOps

2022-11-13 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D137350

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


[PATCH] D137851: [OPENMP]Initial support for at clause

2022-11-13 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 updated this revision to Diff 475013.
jyu2 added a comment.

try fix format again


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137851

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/OpenMPKinds.def
  clang/include/clang/Basic/OpenMPKinds.h
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/OpenMP/error_ast_print.cpp
  clang/test/OpenMP/error_message.cpp
  clang/tools/libclang/CIndex.cpp
  flang/lib/Semantics/check-omp-structure.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -301,6 +301,9 @@
   let clangClass = "OMPAtomicDefaultMemOrderClause";
   let flangClass = "OmpAtomicDefaultMemOrderClause";
 }
+def OMPC_At : Clause<"at"> {
+  let clangClass = "OMPAtClause";
+}
 def OMPC_Allocate : Clause<"allocate"> {
   let clangClass = "OMPAllocateClause";
   let flangClass = "OmpAllocateClause";
@@ -527,7 +530,11 @@
 }
 def OMP_TaskYield : Directive<"taskyield"> {}
 def OMP_Barrier : Directive<"barrier"> {}
-def OMP_Error : Directive<"error"> {}
+def OMP_Error : Directive<"error"> {
+  let allowedClauses = [
+VersionedClause
+  ];
+}
 def OMP_TaskWait : Directive<"taskwait"> {
   let allowedClauses = [
 VersionedClause
Index: flang/lib/Semantics/check-omp-structure.cpp
===
--- flang/lib/Semantics/check-omp-structure.cpp
+++ flang/lib/Semantics/check-omp-structure.cpp
@@ -1868,6 +1868,7 @@
 CHECK_SIMPLE_CLAUSE(Use, OMPC_use)
 CHECK_SIMPLE_CLAUSE(Novariants, OMPC_novariants)
 CHECK_SIMPLE_CLAUSE(Nocontext, OMPC_nocontext)
+CHECK_SIMPLE_CLAUSE(At, OMPC_at)
 CHECK_SIMPLE_CLAUSE(Filter, OMPC_filter)
 CHECK_SIMPLE_CLAUSE(When, OMPC_when)
 CHECK_SIMPLE_CLAUSE(AdjustArgs, OMPC_adjust_args)
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2443,6 +2443,8 @@
 void OMPClauseEnqueue::VisitOMPAtomicDefaultMemOrderClause(
 const OMPAtomicDefaultMemOrderClause *) {}
 
+void OMPClauseEnqueue::VisitOMPAtClause(const OMPAtClause *) {}
+
 void OMPClauseEnqueue::VisitOMPDeviceClause(const OMPDeviceClause *C) {
   Visitor->AddStmt(C->getDevice());
 }
Index: clang/test/OpenMP/error_message.cpp
===
--- clang/test/OpenMP/error_message.cpp
+++ clang/test/OpenMP/error_message.cpp
@@ -7,19 +7,19 @@
   if (argc)
 #pragma omp error // expected-error {{'#pragma omp error' cannot be an immediate substatement}}
 if (argc) {
-#pragma omp error
+#pragma omp error // expected-error {{ERROR}}
 }
   while (argc)
 #pragma omp error // expected-error {{'#pragma omp error' cannot be an immediate substatement}}
 while (argc) {
-#pragma omp error
+#pragma omp error // expected-error {{ERROR}}
 }
   do
 #pragma omp error // expected-error {{'#pragma omp error' cannot be an immediate substatement}}
 while (argc)
   ;
   do {
-#pragma omp error
+#pragma omp error // expected-error {{ERROR}}
   } while (argc);
   switch (argc)
 #pragma omp error // expected-error {{'#pragma omp error' cannot be an immediate substatement}}
@@ -28,47 +28,75 @@
 #pragma omp error // expected-error {{'#pragma omp error' cannot be an immediate substatement}}
   switch (argc)
   case 1: {
-#pragma omp error
+#pragma omp error // expected-error {{ERROR}}
   }
   switch (argc) {
-#pragma omp error
+#pragma omp error // expected-error {{ERROR}}
   case 1:
-#pragma omp error
+#pragma omp error // expected-error {{ERROR}}
 break;
   default: {
-#pragma omp error
+#pragma omp error // expected-error {{ERROR}}
   } break;
   }
   for (;;)
 #pragma omp error // expected-error {{'#pragma omp error' cannot be an immediate substatement}}
 for (;;) {
-#pragma omp error
+#pragma omp error // expected-error {{ERROR}}
 }
 label:
-#pragma omp error
+#pragma omp error // expected-error {{ERROR}}
 label1 : {
-#pragma omp error
+#pragma omp error // expected-error {{ERROR}}
 }
 if (1)
   label2:
 #pragma omp error // expected-error {{'#pragma omp error' cannot be an immediate substatement}}
 
+// expected-error@+1 {{ERROR}}
+#pragma omp error at() // expected-error {{expected 'compilation' or 'execution' in OpenMP clause 'at'}}
+
+

[clang] e564f51 - [clang][test] Avoid UB in overload.cl

2022-11-13 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2022-11-13T14:02:24-08:00
New Revision: e564f5153f91ef40a406c7f907877ceafb6da39d

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

LOG: [clang][test] Avoid UB in overload.cl

Added: 


Modified: 
clang/test/CodeGenOpenCL/overload.cl

Removed: 




diff  --git a/clang/test/CodeGenOpenCL/overload.cl 
b/clang/test/CodeGenOpenCL/overload.cl
index f9e69c6d11540..62ed84c7ec972 100644
--- a/clang/test/CodeGenOpenCL/overload.cl
+++ b/clang/test/CodeGenOpenCL/overload.cl
@@ -14,25 +14,25 @@ void __attribute__((overloadable)) bar(generic int *generic 
*a, generic int *gen
 
 // Checking address space resolution
 void kernel test1() {
-  global int *a;
-  global int *b;
-  generic int *c;
-  local int *d;
-  generic int *generic *gengen;
-  generic int *local *genloc;
-  generic int *global *genglob;
-  // CHECK-DAG: call spir_func void @_Z3fooPU3AS1iS0_(i32 addrspace(1)* 
noundef undef, i32 addrspace(1)* noundef undef)
+  global int *a = 0;
+  global int *b = 0;
+  generic int *c = 0;
+  local int *d = 0;
+  generic int *generic *gengen = 0;
+  generic int *local *genloc = 0;
+  generic int *global *genglob = 0;
+  // CHECK-DAG: call spir_func void @_Z3fooPU3AS1iS0_(i32 addrspace(1)* 
noundef {{.*}}, i32 addrspace(1)* noundef {{.*}})
   foo(a, b);
-  // CHECK-DAG: call spir_func void @_Z3fooPU3AS4iS0_(i32 addrspace(4)* 
noundef undef, i32 addrspace(4)* noundef undef)
+  // CHECK-DAG: call spir_func void @_Z3fooPU3AS4iS0_(i32 addrspace(4)* 
noundef {{.*}}, i32 addrspace(4)* noundef {{.*}})
   foo(b, c);
-  // CHECK-DAG: call spir_func void @_Z3fooPU3AS4iS0_(i32 addrspace(4)* 
noundef undef, i32 addrspace(4)* noundef undef)
+  // CHECK-DAG: call spir_func void @_Z3fooPU3AS4iS0_(i32 addrspace(4)* 
noundef {{.*}}, i32 addrspace(4)* noundef {{.*}})
   foo(a, d);
 
-  // CHECK-DAG: call spir_func void @_Z3barPU3AS4PU3AS4iS2_(i32 addrspace(4)* 
addrspace(4)* noundef undef, i32 addrspace(4)* addrspace(4)* noundef undef)
+  // CHECK-DAG: call spir_func void @_Z3barPU3AS4PU3AS4iS2_(i32 addrspace(4)* 
addrspace(4)* noundef {{.*}}, i32 addrspace(4)* addrspace(4)* noundef {{.*}})
   bar(gengen, genloc);
-  // CHECK-DAG: call spir_func void @_Z3barPU3AS4PU3AS4iS2_(i32 addrspace(4)* 
addrspace(4)* noundef undef, i32 addrspace(4)* addrspace(4)* noundef undef)
+  // CHECK-DAG: call spir_func void @_Z3barPU3AS4PU3AS4iS2_(i32 addrspace(4)* 
addrspace(4)* noundef {{.*}}, i32 addrspace(4)* addrspace(4)* noundef {{.*}})
   bar(gengen, genglob);
-  // CHECK-DAG: call spir_func void @_Z3barPU3AS1PU3AS4iS2_(i32 addrspace(4)* 
addrspace(1)* noundef undef, i32 addrspace(4)* addrspace(1)* noundef undef)
+  // CHECK-DAG: call spir_func void @_Z3barPU3AS1PU3AS4iS2_(i32 addrspace(4)* 
addrspace(1)* noundef {{.*}}, i32 addrspace(4)* addrspace(1)* noundef {{.*}})
   bar(genglob, genglob);
 }
 
@@ -40,8 +40,8 @@ void kernel test1() {
 void kernel test2() {
   short4 e0=0;
 
-  // CHECK-DAG: call spir_func <4 x i16> @_Z5clampDv4_sss(<4 x i16> noundef 
zeroinitializer, i16 noundef signext 0, i16 noundef signext 255)
+  // CHECK-DAG: call spir_func <4 x i16> @_Z5clampDv4_sss(<4 x i16> noundef 
{{.*}}, i16 noundef signext 0, i16 noundef signext 255)
   clamp(e0, 0, 255);
-  // CHECK-DAG: call spir_func <4 x i16> @_Z5clampDv4_sS_S_(<4 x i16> noundef 
zeroinitializer, <4 x i16> noundef zeroinitializer, <4 x i16> noundef 
zeroinitializer)
+  // CHECK-DAG: call spir_func <4 x i16> @_Z5clampDv4_sS_S_(<4 x i16> noundef 
{{.*}}, <4 x i16> noundef {{.*}}, <4 x i16> noundef {{.*}})
   clamp(e0, e0, e0);
 }



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


[PATCH] D133036: [InstCombine] Treat passing undef to noundef params as UB

2022-11-13 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks updated this revision to Diff 475017.
aeubanks added a comment.

I somehow missed the previous comments

rebased on top of fixing UB in tests changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133036

Files:
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/test/Transforms/InstCombine/call-undef.ll
  llvm/test/Transforms/InstCombine/out-of-bounds-indexes.ll

Index: llvm/test/Transforms/InstCombine/out-of-bounds-indexes.ll
===
--- llvm/test/Transforms/InstCombine/out-of-bounds-indexes.ll
+++ llvm/test/Transforms/InstCombine/out-of-bounds-indexes.ll
@@ -6,7 +6,7 @@
 ; CHECK-LABEL: @test_out_of_bounds(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:[[AND1:%.*]] = and i32 [[A:%.*]], 3
-; CHECK-NEXT:tail call void @llvm.assume(i1 poison)
+; CHECK-NEXT:store i1 true, ptr poison, align 1
 ; CHECK-NEXT:ret i32 [[AND1]]
 ;
 entry:
@@ -20,7 +20,7 @@
 define i128 @test_non64bit(i128 %a) {
 ; CHECK-LABEL: @test_non64bit(
 ; CHECK-NEXT:[[AND1:%.*]] = and i128 [[A:%.*]], 3
-; CHECK-NEXT:tail call void @llvm.assume(i1 poison)
+; CHECK-NEXT:store i1 true, ptr poison, align 1
 ; CHECK-NEXT:ret i128 [[AND1]]
 ;
   %and1 = and i128 %a, 3
Index: llvm/test/Transforms/InstCombine/call-undef.ll
===
--- llvm/test/Transforms/InstCombine/call-undef.ll
+++ llvm/test/Transforms/InstCombine/call-undef.ll
@@ -1,5 +1,6 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: opt < %s -passes=instcombine -S | FileCheck %s
+; RUN: opt < %s -passes=instcombine -S -instcombine-disable-optimize-passing-undef-ub | FileCheck %s --check-prefix=DISABLE
 
 declare void @c(i32 noundef)
 declare void @d(ptr dereferenceable(1))
@@ -8,8 +9,12 @@
 
 define void @test1() {
 ; CHECK-LABEL: @test1(
-; CHECK-NEXT:call void @c(i32 undef)
+; CHECK-NEXT:store i1 true, ptr poison, align 1
 ; CHECK-NEXT:ret void
+;
+; DISABLE-LABEL: @test1(
+; DISABLE-NEXT:call void @c(i32 undef)
+; DISABLE-NEXT:ret void
 ;
   call void @c(i32 undef)
   ret void
@@ -17,8 +22,12 @@
 
 define void @test2() {
 ; CHECK-LABEL: @test2(
-; CHECK-NEXT:call void @c(i32 poison)
+; CHECK-NEXT:store i1 true, ptr poison, align 1
 ; CHECK-NEXT:ret void
+;
+; DISABLE-LABEL: @test2(
+; DISABLE-NEXT:call void @c(i32 poison)
+; DISABLE-NEXT:ret void
 ;
   call void @c(i32 poison)
   ret void
@@ -26,8 +35,12 @@
 
 define void @test3() {
 ; CHECK-LABEL: @test3(
-; CHECK-NEXT:call void @e(i32 noundef undef)
+; CHECK-NEXT:store i1 true, ptr poison, align 1
 ; CHECK-NEXT:ret void
+;
+; DISABLE-LABEL: @test3(
+; DISABLE-NEXT:call void @e(i32 noundef undef)
+; DISABLE-NEXT:ret void
 ;
   call void @e(i32 noundef undef)
   ret void
@@ -35,8 +48,12 @@
 
 define void @test4() {
 ; CHECK-LABEL: @test4(
-; CHECK-NEXT:call void @e(i32 noundef poison)
+; CHECK-NEXT:store i1 true, ptr poison, align 1
 ; CHECK-NEXT:ret void
+;
+; DISABLE-LABEL: @test4(
+; DISABLE-NEXT:call void @e(i32 noundef poison)
+; DISABLE-NEXT:ret void
 ;
   call void @e(i32 noundef poison)
   ret void
@@ -44,8 +61,12 @@
 
 define void @test5() {
 ; CHECK-LABEL: @test5(
-; CHECK-NEXT:call void @d(ptr undef)
+; CHECK-NEXT:store i1 true, ptr poison, align 1
 ; CHECK-NEXT:ret void
+;
+; DISABLE-LABEL: @test5(
+; DISABLE-NEXT:call void @d(ptr undef)
+; DISABLE-NEXT:ret void
 ;
   call void @d(ptr undef)
   ret void
@@ -53,8 +74,12 @@
 
 define void @test6() {
 ; CHECK-LABEL: @test6(
-; CHECK-NEXT:call void @d(ptr poison)
+; CHECK-NEXT:store i1 true, ptr poison, align 1
 ; CHECK-NEXT:ret void
+;
+; DISABLE-LABEL: @test6(
+; DISABLE-NEXT:call void @d(ptr poison)
+; DISABLE-NEXT:ret void
 ;
   call void @d(ptr poison)
   ret void
@@ -62,8 +87,12 @@
 
 define void @test7() {
 ; CHECK-LABEL: @test7(
-; CHECK-NEXT:call void @f(ptr dereferenceable(1) undef)
+; CHECK-NEXT:store i1 true, ptr poison, align 1
 ; CHECK-NEXT:ret void
+;
+; DISABLE-LABEL: @test7(
+; DISABLE-NEXT:call void @f(ptr dereferenceable(1) undef)
+; DISABLE-NEXT:ret void
 ;
   call void @f(ptr dereferenceable(1) undef)
   ret void
@@ -71,17 +100,38 @@
 
 define void @test8() {
 ; CHECK-LABEL: @test8(
-; CHECK-NEXT:call void @f(ptr dereferenceable(1) poison)
+; CHECK-NEXT:store i1 true, ptr poison, align 1
 ; CHECK-NEXT:ret void
+;
+; DISABLE-LABEL: @test8(
+; DISABLE-NEXT:call void @f(ptr dereferenceable(1) poison)
+; DISABLE-NEXT:ret void
 ;
   call void @f(ptr dereferenceable(1) poison)
   ret void
 }
 
+define void @test9() sanitize_memory {
+; CHECK-LABEL: @test9(
+; CHECK-NEXT:call void @c(i32 undef)
+; CHECK-NEXT:ret void
+;
+; DISABLE-LABEL: @test9(
+; DISABLE-NEXT:call void @c(i32 undef)
+; DISABLE-NEXT:ret void
+;

[PATCH] D131295: [clangd] Implement textDocument/codeLens

2022-11-13 Thread Trass3r via Phabricator via cfe-commits
Trass3r added inline comments.



Comment at: clang-tools-extra/clangd/tool/ClangdMain.cpp:348
+"code-lens", cat(Features), desc("Enable preview of CodeLens feature"),
+init(true),  Hidden,
+};

I guess we should rather make it opt-in and gather some feedback.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131295

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


[PATCH] D137917: [cmake] Fix _GNU_SOURCE being added unconditionally

2022-11-13 Thread Trass3r via Phabricator via cfe-commits
Trass3r created this revision.
Herald added a project: All.
Trass3r requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137917

Files:
  clang/CMakeLists.txt
  llvm/cmake/config-ix.cmake


Index: llvm/cmake/config-ix.cmake
===
--- llvm/cmake/config-ix.cmake
+++ llvm/cmake/config-ix.cmake
@@ -348,7 +348,7 @@
 
 check_symbol_exists(__GLIBC__ stdio.h LLVM_USING_GLIBC)
 if( LLVM_USING_GLIBC )
-  add_definitions( -D_GNU_SOURCE )
+  add_compile_definitions(_GNU_SOURCE)
   list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_GNU_SOURCE")
 endif()
 # This check requires _GNU_SOURCE
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -414,8 +414,6 @@
   endif()
 endif()
 
-add_definitions( -D_GNU_SOURCE )
-
 option(CLANG_BUILD_TOOLS
   "Build the Clang tools. If OFF, just generate build targets." ON)
 


Index: llvm/cmake/config-ix.cmake
===
--- llvm/cmake/config-ix.cmake
+++ llvm/cmake/config-ix.cmake
@@ -348,7 +348,7 @@
 
 check_symbol_exists(__GLIBC__ stdio.h LLVM_USING_GLIBC)
 if( LLVM_USING_GLIBC )
-  add_definitions( -D_GNU_SOURCE )
+  add_compile_definitions(_GNU_SOURCE)
   list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_GNU_SOURCE")
 endif()
 # This check requires _GNU_SOURCE
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -414,8 +414,6 @@
   endif()
 endif()
 
-add_definitions( -D_GNU_SOURCE )
-
 option(CLANG_BUILD_TOOLS
   "Build the Clang tools. If OFF, just generate build targets." ON)
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137919: [clangd] use fine-grained code action kinds

2022-11-13 Thread Trass3r via Phabricator via cfe-commits
Trass3r created this revision.
Herald added subscribers: kadircet, arphaman.
Herald added a project: All.
Trass3r requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137919

Files:
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/refactor/InsertionPoint.h
  clang-tools-extra/clangd/refactor/Tweak.h
  clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
  clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp
  clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
  clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
  clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp
  clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
  clang-tools-extra/clangd/refactor/tweaks/ExpandMacro.cpp
  clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
  clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
  clang-tools-extra/clangd/refactor/tweaks/MemberwiseConstructor.cpp
  clang-tools-extra/clangd/refactor/tweaks/ObjCLocalizeStringLiteral.cpp
  clang-tools-extra/clangd/refactor/tweaks/ObjCMemberwiseInitializer.cpp
  clang-tools-extra/clangd/refactor/tweaks/PopulateSwitch.cpp
  clang-tools-extra/clangd/refactor/tweaks/RawStringLiteral.cpp
  clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
  clang-tools-extra/clangd/refactor/tweaks/SpecialMembers.cpp
  clang-tools-extra/clangd/refactor/tweaks/SwapIfBranches.cpp

Index: clang-tools-extra/clangd/refactor/tweaks/SwapIfBranches.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/SwapIfBranches.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/SwapIfBranches.cpp
@@ -29,7 +29,7 @@
 ///   ^^^ 
 /// After:
 ///   if (foo) { continue; } else { return 10; }
-class SwapIfBranches : public Tweak {
+class SwapIfBranches final : public Tweak {
 public:
   const char *id() const final;
 
@@ -37,7 +37,7 @@
   Expected apply(const Selection &Inputs) override;
   std::string title() const override { return "Swap if branches"; }
   llvm::StringLiteral kind() const override {
-return CodeAction::REFACTOR_KIND;
+return CodeAction::REFACTOR_REWRITE_KIND;
   }
   bool hidden() const override { return true; }
 
Index: clang-tools-extra/clangd/refactor/tweaks/SpecialMembers.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/SpecialMembers.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/SpecialMembers.cpp
@@ -84,11 +84,11 @@
 //  - to understand the implicit behavior
 //  - to avoid relying on the implicit behavior
 //  - as a baseline for explicit modification
-class DeclareCopyMove : public Tweak {
+class DeclareCopyMove final : public Tweak {
 public:
   const char *id() const final;
   llvm::StringLiteral kind() const override {
-return CodeAction::REFACTOR_KIND;
+return CodeAction::REFACTOR_REWRITE_KIND;
   }
   std::string title() const override {
 return llvm::formatv("Declare implicit {0} members",
Index: clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
@@ -29,7 +29,7 @@
 /// Currently limited to using namespace directives inside global namespace to
 /// simplify implementation. Also the namespace must not contain using
 /// directives.
-class RemoveUsingNamespace : public Tweak {
+class RemoveUsingNamespace final : public Tweak {
 public:
   const char *id() const override;
 
@@ -39,7 +39,7 @@
 return "Remove using namespace, re-qualify names instead";
   }
   llvm::StringLiteral kind() const override {
-return CodeAction::REFACTOR_KIND;
+return CodeAction::REFACTOR_REWRITE_KIND;
   }
 
 private:
Index: clang-tools-extra/clangd/refactor/tweaks/RawStringLiteral.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/RawStringLiteral.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/RawStringLiteral.cpp
@@ -26,7 +26,7 @@
 /// After:
 ///   printf(R"("a"
 /// b)");
-class RawStringLiteral : public Tweak {
+class RawStringLiteral final : public Tweak {
 public:
   const char *id() const final;
 
@@ -34,7 +34,7 @@
   Expected apply(const Selection &Inputs) override;
   std::string title() const override { return "Convert to raw string"; }
   llvm::StringLiteral kind() const override {
-return CodeAction::REFACTOR_KIND;
+return CodeAction::REFACTOR_REWRITE_KIND;
   }
 
 private:
Index: clang-tools-extra/clangd/refactor/tweaks/PopulateSwitch.cpp
===
--- clang-tools-extra/clangd/refactor/tweak

[PATCH] D137919: [clangd] use fine-grained code action kinds

2022-11-13 Thread Trass3r via Phabricator via cfe-commits
Trass3r added a comment.

RFC. First described in https://github.com/clangd/clangd/issues/1326.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137919

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


[PATCH] D137920: [nfc] Mark classes final as reported by -Wsuggest-final-types

2022-11-13 Thread Trass3r via Phabricator via cfe-commits
Trass3r created this revision.
Herald added subscribers: steakhal, pmatos, asb, abrachet, frasercrmck, 
ThomasRaoux, martong, phosek, luismarques, apazos, sameer.abuasal, pengfei, 
s.egerton, Jim, mstorsjo, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, 
rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, 
rbar, kbarton, hiraditya, sbc100, nemanjai, dschuff, emaste.
Herald added a reviewer: NoQ.
Herald added a project: All.
Trass3r requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, pcwang-thead, MaskRay, 
aheejin.
Herald added projects: clang, LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137920

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/AST/DeclObjC.h
  clang/include/clang/AST/DeclTemplate.h
  clang/include/clang/Frontend/CompilerInstance.h
  clang/include/clang/Lex/Lexer.h
  clang/include/clang/Lex/Pragma.h
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/CodeCompleteConsumer.h
  clang/include/clang/Sema/SemaInternal.h
  clang/include/clang/Serialization/ASTReader.h
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugType.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
  clang/lib/Driver/ToolChains/AIX.h
  clang/lib/Driver/ToolChains/BareMetal.h
  clang/lib/Driver/ToolChains/CSKYToolChain.h
  clang/lib/Driver/ToolChains/CrossWindows.h
  clang/lib/Driver/ToolChains/Cuda.h
  clang/lib/Driver/ToolChains/Darwin.h
  clang/lib/Driver/ToolChains/Fuchsia.h
  clang/lib/Driver/ToolChains/Gnu.h
  clang/lib/Driver/ToolChains/Hexagon.h
  clang/lib/Driver/ToolChains/Hurd.h
  clang/lib/Driver/ToolChains/Lanai.h
  clang/lib/Driver/ToolChains/MSP430.h
  clang/lib/Driver/ToolChains/MSVC.h
  clang/lib/Driver/ToolChains/MinGW.h
  clang/lib/Driver/ToolChains/NaCl.h
  clang/lib/Driver/ToolChains/OpenBSD.h
  clang/lib/Driver/ToolChains/PPCFreeBSD.h
  clang/lib/Driver/ToolChains/RISCVToolchain.h
  clang/lib/Driver/ToolChains/SPIRV.h
  clang/lib/Driver/ToolChains/VEToolchain.h
  clang/lib/Frontend/MultiplexConsumer.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.h
  llvm/include/llvm/CodeGen/GlobalISel/GISelKnownBits.h
  llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h
  llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h
  llvm/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h
  llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLoc.h
  llvm/include/llvm/Object/COFF.h
  llvm/include/llvm/Object/MachO.h
  llvm/include/llvm/Object/Wasm.h
  llvm/include/llvm/Object/XCOFFObjectFile.h
  llvm/include/llvm/ProfileData/InstrProfReader.h
  llvm/include/llvm/Support/VirtualFileSystem.h
  llvm/include/llvm/TableGen/Record.h
  llvm/lib/Support/VirtualFileSystem.cpp
  llvm/lib/Target/AArch64/AArch64FrameLowering.h
  llvm/lib/Target/AArch64/AArch64ISelLowering.h
  llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.h
  llvm/lib/Target/ARM/ARMISelLowering.h
  llvm/lib/Target/ARM/ARMSubtarget.h
  llvm/lib/Target/ARM/MCTargetDesc/ARMInstPrinter.h
  llvm/lib/Target/X86/X86FrameLowering.h
  llvm/utils/TableGen/DAGISelMatcher.h
  llvm/utils/TableGen/GlobalISel/GIMatchDagPredicate.h
  llvm/utils/TableGen/GlobalISel/GIMatchTree.h

Index: llvm/utils/TableGen/GlobalISel/GIMatchTree.h
===
--- llvm/utils/TableGen/GlobalISel/GIMatchTree.h
+++ llvm/utils/TableGen/GlobalISel/GIMatchTree.h
@@ -553,7 +553,7 @@
 ///   result is that the cases that don't match the superset will match the
 ///   subset rule, while the ones that do match the superset will match either
 ///   (which one is algorithm dependent but will usually be the superset).
-class GIMatchTreeOpcodePartitioner : public GIMatchTreePartitioner {
+class GIMatchTreeOpcodePartitioner final : public GIMatchTreePartitioner {
   unsigned InstrID;
   DenseMap InstrToPartition;
   std::vector PartitionToInstr;
@@ -582,7 +582,7 @@
  StringRef Indent) const override;
 };
 
-class GIMatchTreeVRegDefPartitioner : public GIMatchTreePartitioner {
+class GIMatchTreeVRegDefPartitioner final : public GIMatchTreePartitioner {
   unsigned NewInstrID = -1;
   unsigned InstrID;
   unsigned OpIdx;
Index: llvm/utils/TableGen/GlobalISel/GIMatchDagPredicate.h
===
--- llvm/utils/TableGen/GlobalISel/GIMatchDagPredicate.h
+++ llvm/utils/TableGen/GlobalISel/GIMatchDagPredicate.h
@@ -80,7 +80,7 @@
 #endif // if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
 };
 
-class GIMatchDagOpcodePredicate : public GIMatchDagPredicate {
+c

[PATCH] D137920: [nfc] Mark classes final as reported by -Wsuggest-final-types

2022-11-13 Thread Trass3r via Phabricator via cfe-commits
Trass3r added a comment.

See https://github.com/llvm/llvm-project/issues/57525.
The change is focused on those cases reported by gcc, i.e. with actual 
devirtualization potential.
It needs to be carefully checked if some of those shouldn't be final (and could 
we somehow mark those as intended for subclassing, along the lines of `class F 
/*non-final*/ : ...`?).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137920

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


[PATCH] D137205: [clang-tidy] Add performance-unnecessary-copy-on-last-use check

2022-11-13 Thread Fabian Keßler via Phabricator via cfe-commits
Febbe updated this revision to Diff 475030.
Febbe marked 5 inline comments as done.
Febbe added a comment.

Fixed a lot of false positives:

- no move for no automatic storage duration
- no move for lambda captures


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137205

Files:
  clang-tools-extra/clang-tidy/performance/CMakeLists.txt
  clang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp
  clang-tools-extra/clang-tidy/performance/UnnecessaryCopyOnLastUseCheck.cpp
  clang-tools-extra/clang-tidy/performance/UnnecessaryCopyOnLastUseCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/docs/clang-tidy/checks/performance/unnecessary-copy-on-last-use.rst
  
clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-on-last-use.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-on-last-use.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-on-last-use.cpp
@@ -0,0 +1,247 @@
+// RUN: %check_clang_tidy %s -std=c++17 performance-unnecessary-copy-on-last-use %t
+// RUN: %check_clang_tidy %s -std=c++11 performance-unnecessary-copy-on-last-use %t
+// CHECK-FIXES: #include 
+
+struct Movable {
+  Movable() = default;
+  Movable(Movable const &) = default;
+  Movable(Movable &&) = default;
+  Movable &operator=(Movable const &) = default;
+  Movable &operator=(Movable &&) = default;
+  ~Movable();
+
+  void memberUse() {}
+};
+
+struct Copyable {
+  Copyable() = default;
+  Copyable(Copyable const &) = default;
+  Copyable(Copyable &&) = default;
+  Copyable &operator=(Copyable const &) = default;
+  Copyable &operator=(Copyable &&) = default;
+  ~Copyable() = default; 
+
+  void memberUse() {}
+};
+// static_assert(!std::is_trivially_copyable_v, "Movable must not be trivially copyable");
+
+void valueReceiver(Movable Mov);
+void constRefReceiver(Movable const &Mov);
+
+void valueTester() {
+  Movable Mov{};
+  valueReceiver(Mov);
+  valueReceiver(Mov);
+  // CHECK-MESSAGES: [[@LINE-1]]:17: warning: Parameter 'Mov' is copied on last use, consider moving it instead. [performance-unnecessary-copy-on-last-use]
+  // CHECK-FIXES: valueReceiver(std::move(Mov));
+  Mov = Movable{};
+  valueReceiver(Mov);
+  // CHECK-MESSAGES: [[@LINE-1]]:17: warning: Parameter 'Mov' is copied on last use, consider moving it instead. [performance-unnecessary-copy-on-last-use]
+  // CHECK-FIXES: valueReceiver(std::move(Mov));
+}
+
+void testUsageInBranch(bool Splitter) {
+  Movable Mov{};
+
+  valueReceiver(Mov);
+  if(Splitter){
+Mov.memberUse();
+  } else {
+Mov = Movable{};
+  }
+  valueReceiver(Mov);
+  // CHECK-MESSAGES: [[@LINE-1]]:17: warning: Parameter 'Mov' is copied on last use, consider moving it instead. [performance-unnecessary-copy-on-last-use]
+  // CHECK-FIXES: valueReceiver(std::move(Mov));
+
+  if(Splitter){
+Mov = Movable{};
+  } else {
+Mov = Movable{};
+  }
+  valueReceiver(Mov);
+  Mov.memberUse();
+}
+
+void testExplicitCopy() {
+  Movable Mov{};
+  constRefReceiver(Movable{Mov});
+  // CHECK-MESSAGES: [[@LINE-1]]:28: warning: Parameter 'Mov' is copied on last use, consider moving it instead. [performance-unnecessary-copy-on-last-use]
+  // CHECK-FIXES: constRefReceiver(Movable{std::move(Mov)});
+}
+
+Movable testReturn() {
+  Movable Mov{};
+  return Mov; // no warning, copy elision
+}
+
+Movable testReturn2(Movable && Mov, bool F) {
+  return F? Mov: Movable{}; 
+  // CHECK-MESSAGES: [[@LINE-1]]:13: warning: Parameter 'Mov' is copied on last use, consider moving it instead. [performance-unnecessary-copy-on-last-use] 
+  // CHECK-FIXES: return F? std::move(Mov): Movable{};
+}
+
+void rValReferenceTester(Movable&& Mov) {
+  valueReceiver(Mov);
+  valueReceiver(Mov);
+  // CHECK-MESSAGES: [[@LINE-1]]:17: warning: Parameter 'Mov' is copied on last use, consider moving it instead. [performance-unnecessary-copy-on-last-use]
+  // CHECK-FIXES: valueReceiver(std::move(Mov));
+  Mov = Movable{};
+  valueReceiver(Mov);
+  // CHECK-MESSAGES: [[@LINE-1]]:17: warning: Parameter 'Mov' is copied on last use, consider moving it instead. [performance-unnecessary-copy-on-last-use]
+  // CHECK-FIXES: valueReceiver(std::move(Mov));
+}
+
+void referenceTester(Movable& Mov) {
+  valueReceiver(Mov);
+  valueReceiver(Mov);
+  Mov = Movable{};
+  valueReceiver(Mov);
+}
+
+void pointerTester(Movable* Mov) {
+  valueReceiver(*Mov);
+  valueReceiver(*Mov);
+  *Mov = Movable{};
+  valueReceiver(*Mov);
+}
+
+template 
+struct RemoveRef{
+  using type = T;
+};
+
+template 
+struct RemoveRef{
+  using type = T;
+};
+
+template 
+struct RemoveRef{
+  using type = T;
+};
+
+template
+using RemoveRefT = typename RemoveRef::type;
+
+template 
+void initSomething(Movable&& Mov) {
+  valueReceiver(Mov);
+  valueReceiver(Mov

[PATCH] D137865: [clang-format][NFC] Improve documentation on ReflowComments

2022-11-13 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: clang/include/clang/Format/Format.h:3073-3076
+  /// If ``true``, clang-format will attempt to re-flow comments. That is it
+  /// will touch a comment and *reflow* long comments into new lines, trying to
+  /// obey the ``ColumnLimit``. ``/*`` comments will get a leading ``*`` on the
+  /// new lines.

Let's leave it as is because the new lines don't always get a leading `*`:
```
$ cat foo.cpp
/* The LLVM Project is a collection of modular and reusable compiler and 
toolchain
   technologies. */
$ clang-format -style='{ReflowComments: true}' foo.cpp
/* The LLVM Project is a collection of modular and reusable compiler and
   toolchain technologies. */
```



Comment at: clang/include/clang/Format/Format.h:3864
   /// \endcode
+  /// This option has only effect if ``ReflowComments`` is set to ``true``.
   /// \version 13

We need an empty line after `/// \endcode`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137865

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


[PATCH] D137865: [clang-format][NFC] Improve documentation on ReflowComments

2022-11-13 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: clang/include/clang/Format/Format.h:3864
   /// \endcode
+  /// This option has only effect if ``ReflowComments`` is set to ``true``.
   /// \version 13

owenpan wrote:
> We need an empty line after `/// \endcode`.
> We need an empty line after `/// \endcode`.

We need an empty `///` line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137865

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


[PATCH] D137787: [CodeGen] Relax assertion on generating destructor call

2022-11-13 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

In D137787#3923540 , @Hahnfeld wrote:

>> Is it the reproducer?
>
> No, as I wrote:
>
>> Sadly this works fine in standalone Clang...

Sorry, I don't understand well. Could you rewrite the reproducer in the style I 
wrote? And in what cases it works fine?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137787

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


[PATCH] D137901: [Clang] `nothrow`-implying attributes should actually manifest `nothrow` attribute (PR58798)

2022-11-13 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

I think improving diagnostic is useful but `-fsanitize=` is probably not a good 
place. Instrumenting call sites with `callq   
__ubsan_handle_exception_escape@PLT` wastes code size. The functionality is 
better handled somewhere in libc++abi personality related code with possible 
improvement to exception handling related LLVM IR.

  void bar(); void foo() { bar(); }

I wish that I capture the compiler and runtime behavior well in 
https://maskray.me/blog/2020-12-12-c++-exception-handling-abi#compiler-behavior.
 
https://discourse.llvm.org/t/catching-exceptions-while-unwinding-through-fno-exceptions-code/57151
 is a proposal to improve the diagnostics.

`clang++ -fno-exceptions -fsanitize=exception-escape -c b.cc` does not 
instrument the potentially-throwing-and-propagating `bar()` so an error cannot 
be caught.
However, for `-fno-exceptions` code, instrumenting every call site is going to 
greatly increase code size and suppress optimizations.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137901

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


[PATCH] D137381: [clang][compiler-rt] Exception escape out of an non-unwinding function is an undefined behaviour

2022-11-13 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

I think improving diagnostic is useful but `-fsanitize=` is probably not a good 
place. Instrumenting call sites with `callq   
__ubsan_handle_exception_escape@PLT` wastes code size. The functionality is 
better handled somewhere in libc++abi personality related code with possible 
improvement to exception handling related LLVM IR.

  void bar(); void foo() { bar(); }

`clang++ -fno-exceptions -fsanitize=exception-escape -c b.cc` does not 
instrument the potentially-throwing-and-propagating `bar()` so an error cannot 
be caught.
However, for `-fno-exceptions` code, instrumenting every call site is going to 
greatly increase code size and suppress optimizations.

I wish that I capture the compiler and runtime behavior well in 
https://maskray.me/blog/2020-12-12-c++-exception-handling-abi#compiler-behavior.
 
https://discourse.llvm.org/t/catching-exceptions-while-unwinding-through-fno-exceptions-code/57151
 is a proposal to improve the diagnostics.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137381

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


[PATCH] D137181: [clang-format] Don't use 'PPIndentWidth' inside multi-line macros

2022-11-13 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

I think we are close to the finishing line. Can you revisit the change to the 
formatter and clean it up? For example, casting `PPLevel` to `unsigned` is 
redundant now. IMO you can simply the change too.




Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:63
 skipLine(Line, /*UnknownIndent=*/true);
-if (Line.InPPDirective ||
-(Style.IndentPPDirectives == FormatStyle::PPDIS_BeforeHash &&
- Line.Type == LT_CommentAbovePPDirective)) {
-  unsigned IndentWidth =
+if (Style.IndentPPDirectives != FormatStyle::PPDIS_None &&
+(Line.InPPDirective ||

You don't need to add this condition.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137181

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


[PATCH] D137570: [Clang][Sema] Refactor category declaration under CheckForIncompatibleAttributes. NFC

2022-11-13 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 475043.
eopXD marked 3 inline comments as done.
eopXD added a comment.

Address comments from reviewers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137570

Files:
  clang/lib/Sema/SemaStmtAttr.cpp


Index: clang/lib/Sema/SemaStmtAttr.cpp
===
--- clang/lib/Sema/SemaStmtAttr.cpp
+++ clang/lib/Sema/SemaStmtAttr.cpp
@@ -306,21 +306,34 @@
   if (!DiagnoseMutualExclusions(S, Attrs))
 return;
 
-  // There are 6 categories of loop hints attributes: vectorize, interleave,
-  // unroll, unroll_and_jam, pipeline and distribute. Except for distribute 
they
-  // come in two variants: a state form and a numeric form.  The state form
-  // selectively defaults/enables/disables the transformation for the loop
-  // (for unroll, default indicates full unrolling rather than enabling the
-  // transformation). The numeric form form provides an integer hint (for
-  // example, unroll count) to the transformer. The following array accumulates
-  // the hints encountered while iterating through the attributes to check for
-  // compatibility.
+  enum CategoryType {
+// For the following categories, they come in two variants: a state form 
and
+// a numeric form. The state form may be one of default, enable, and
+// disable. The numeric form provides an integer hint (for example, unroll
+// count) to the transformer.
+Vectorize,
+Interleave,
+UnrollAndJam,
+Pipeline,
+// For unroll, default indicates full unrolling rather than enabling the
+// transformation.
+Unroll,
+// The loop distribution transformation only has a state form that is
+// exposed by
+// #pragma clang loop distribute (enable | disable).
+Distribute,
+// The vector predication only has a state form that is exposed by
+// #pragma clang loop vectorize_predicate (enable | disable).
+VectorizePredicate,
+// This serves as a indicator to how many category are listed in this enum.
+NumberOfCategories
+  };
+  // The following array accumulates the hints encountered while iterating
+  // through the attributes to check for compatibility.
   struct {
 const LoopHintAttr *StateAttr;
 const LoopHintAttr *NumericAttr;
-  } HintAttrs[] = {{nullptr, nullptr}, {nullptr, nullptr}, {nullptr, nullptr},
-   {nullptr, nullptr}, {nullptr, nullptr}, {nullptr, nullptr},
-   {nullptr, nullptr}};
+  } HintAttrs[CategoryType::NumberOfCategories] = {};
 
   for (const auto *I : Attrs) {
 const LoopHintAttr *LH = dyn_cast(I);
@@ -329,16 +342,8 @@
 if (!LH)
   continue;
 
+CategoryType Category = CategoryType::NumberOfCategories;
 LoopHintAttr::OptionType Option = LH->getOption();
-enum {
-  Vectorize,
-  Interleave,
-  Unroll,
-  UnrollAndJam,
-  Distribute,
-  Pipeline,
-  VectorizePredicate
-} Category;
 switch (Option) {
 case LoopHintAttr::Vectorize:
 case LoopHintAttr::VectorizeWidth:
@@ -369,7 +374,7 @@
   break;
 };
 
-assert(Category < sizeof(HintAttrs) / sizeof(HintAttrs[0]));
+assert(Category != NumberOfCategories && "Unhandled loop hint option");
 auto &CategoryState = HintAttrs[Category];
 const LoopHintAttr *PrevAttr;
 if (Option == LoopHintAttr::Vectorize ||


Index: clang/lib/Sema/SemaStmtAttr.cpp
===
--- clang/lib/Sema/SemaStmtAttr.cpp
+++ clang/lib/Sema/SemaStmtAttr.cpp
@@ -306,21 +306,34 @@
   if (!DiagnoseMutualExclusions(S, Attrs))
 return;
 
-  // There are 6 categories of loop hints attributes: vectorize, interleave,
-  // unroll, unroll_and_jam, pipeline and distribute. Except for distribute they
-  // come in two variants: a state form and a numeric form.  The state form
-  // selectively defaults/enables/disables the transformation for the loop
-  // (for unroll, default indicates full unrolling rather than enabling the
-  // transformation). The numeric form form provides an integer hint (for
-  // example, unroll count) to the transformer. The following array accumulates
-  // the hints encountered while iterating through the attributes to check for
-  // compatibility.
+  enum CategoryType {
+// For the following categories, they come in two variants: a state form and
+// a numeric form. The state form may be one of default, enable, and
+// disable. The numeric form provides an integer hint (for example, unroll
+// count) to the transformer.
+Vectorize,
+Interleave,
+UnrollAndJam,
+Pipeline,
+// For unroll, default indicates full unrolling rather than enabling the
+// transformation.
+Unroll,
+// The loop distribution transformation only has a state form that is
+// exposed by
+// #pragma clang loop distribute (enable | disable).
+  

[PATCH] D137570: [Clang][Sema] Refactor category declaration under CheckForIncompatibleAttributes. NFC

2022-11-13 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 475044.
eopXD added a comment.

Minor update in comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137570

Files:
  clang/lib/Sema/SemaStmtAttr.cpp


Index: clang/lib/Sema/SemaStmtAttr.cpp
===
--- clang/lib/Sema/SemaStmtAttr.cpp
+++ clang/lib/Sema/SemaStmtAttr.cpp
@@ -306,21 +306,33 @@
   if (!DiagnoseMutualExclusions(S, Attrs))
 return;
 
-  // There are 6 categories of loop hints attributes: vectorize, interleave,
-  // unroll, unroll_and_jam, pipeline and distribute. Except for distribute 
they
-  // come in two variants: a state form and a numeric form.  The state form
-  // selectively defaults/enables/disables the transformation for the loop
-  // (for unroll, default indicates full unrolling rather than enabling the
-  // transformation). The numeric form form provides an integer hint (for
-  // example, unroll count) to the transformer. The following array accumulates
-  // the hints encountered while iterating through the attributes to check for
-  // compatibility.
+  enum CategoryType {
+// For the following categories, they come in two variants: a state form 
and
+// a numeric form. The state form may be one of default, enable, and
+// disable. The numeric form provides an integer hint (for example, unroll
+// count) to the transformer.
+Vectorize,
+Interleave,
+UnrollAndJam,
+Pipeline,
+// For unroll, default indicates full unrolling rather than enabling the
+// transformation.
+Unroll,
+// The loop distribution transformation only has a state form that is
+// exposed by #pragma clang loop distribute (enable | disable).
+Distribute,
+// The vector predication only has a state form that is exposed by
+// #pragma clang loop vectorize_predicate (enable | disable).
+VectorizePredicate,
+// This serves as a indicator to how many category are listed in this enum.
+NumberOfCategories
+  };
+  // The following array accumulates the hints encountered while iterating
+  // through the attributes to check for compatibility.
   struct {
 const LoopHintAttr *StateAttr;
 const LoopHintAttr *NumericAttr;
-  } HintAttrs[] = {{nullptr, nullptr}, {nullptr, nullptr}, {nullptr, nullptr},
-   {nullptr, nullptr}, {nullptr, nullptr}, {nullptr, nullptr},
-   {nullptr, nullptr}};
+  } HintAttrs[CategoryType::NumberOfCategories] = {};
 
   for (const auto *I : Attrs) {
 const LoopHintAttr *LH = dyn_cast(I);
@@ -329,16 +341,8 @@
 if (!LH)
   continue;
 
+CategoryType Category = CategoryType::NumberOfCategories;
 LoopHintAttr::OptionType Option = LH->getOption();
-enum {
-  Vectorize,
-  Interleave,
-  Unroll,
-  UnrollAndJam,
-  Distribute,
-  Pipeline,
-  VectorizePredicate
-} Category;
 switch (Option) {
 case LoopHintAttr::Vectorize:
 case LoopHintAttr::VectorizeWidth:
@@ -369,7 +373,7 @@
   break;
 };
 
-assert(Category < sizeof(HintAttrs) / sizeof(HintAttrs[0]));
+assert(Category != NumberOfCategories && "Unhandled loop hint option");
 auto &CategoryState = HintAttrs[Category];
 const LoopHintAttr *PrevAttr;
 if (Option == LoopHintAttr::Vectorize ||


Index: clang/lib/Sema/SemaStmtAttr.cpp
===
--- clang/lib/Sema/SemaStmtAttr.cpp
+++ clang/lib/Sema/SemaStmtAttr.cpp
@@ -306,21 +306,33 @@
   if (!DiagnoseMutualExclusions(S, Attrs))
 return;
 
-  // There are 6 categories of loop hints attributes: vectorize, interleave,
-  // unroll, unroll_and_jam, pipeline and distribute. Except for distribute they
-  // come in two variants: a state form and a numeric form.  The state form
-  // selectively defaults/enables/disables the transformation for the loop
-  // (for unroll, default indicates full unrolling rather than enabling the
-  // transformation). The numeric form form provides an integer hint (for
-  // example, unroll count) to the transformer. The following array accumulates
-  // the hints encountered while iterating through the attributes to check for
-  // compatibility.
+  enum CategoryType {
+// For the following categories, they come in two variants: a state form and
+// a numeric form. The state form may be one of default, enable, and
+// disable. The numeric form provides an integer hint (for example, unroll
+// count) to the transformer.
+Vectorize,
+Interleave,
+UnrollAndJam,
+Pipeline,
+// For unroll, default indicates full unrolling rather than enabling the
+// transformation.
+Unroll,
+// The loop distribution transformation only has a state form that is
+// exposed by #pragma clang loop distribute (enable | disable).
+Distribute,
+// The vector predication only has a state f

[clang] 360c5fe - [C++20] [Modules] Emit Macro Definition in -module-file-info action

2022-11-13 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2022-11-14T13:28:26+08:00
New Revision: 360c5fe54c0758c73bf85453fd2913f371adc7d5

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

LOG: [C++20] [Modules] Emit Macro Definition in -module-file-info action

It is helpful to know whih macro definition is emitted in the module
file without openning it directly. And this is not easy to be tested
with the lit test. So this patch add the facility to emit macro
definitions in `-module-file-info` action. And this should be innnocent
for every other cases.

Added: 
clang/test/Modules/cxx20-module-file-info-macros.cpp

Modified: 
clang/lib/Frontend/FrontendActions.cpp

Removed: 




diff  --git a/clang/lib/Frontend/FrontendActions.cpp 
b/clang/lib/Frontend/FrontendActions.cpp
index be3c42e79802..b4ec3892a1b6 100644
--- a/clang/lib/Frontend/FrontendActions.cpp
+++ b/clang/lib/Frontend/FrontendActions.cpp
@@ -938,6 +938,20 @@ void DumpModuleInfoAction::ExecuteAction() {
 }
   }
 }
+
+// Emit the macro definitions in the module file so that we can know how
+// much definitions in the module file quickly.
+// TODO: Emit the macro definition bodies completely.
+if (auto FilteredMacros = llvm::make_filter_range(
+R->getPreprocessor().macros(),
+[](const auto &Macro) { return Macro.first->isFromAST(); });
+!FilteredMacros.empty()) {
+  Out << "   Macro Definitions:\n";
+  for (/* pair*/ const auto &Macro :
+   FilteredMacros)
+Out << " " << Macro.first->getName() << "\n";
+}
+
 // Now let's print out any modules we did not see as part of the Primary.
 for (auto SM : SubModMap) {
   if (!SM.second.Seen && SM.second.Mod) {

diff  --git a/clang/test/Modules/cxx20-module-file-info-macros.cpp 
b/clang/test/Modules/cxx20-module-file-info-macros.cpp
new file mode 100644
index ..422589702948
--- /dev/null
+++ b/clang/test/Modules/cxx20-module-file-info-macros.cpp
@@ -0,0 +1,74 @@
+// Test the output from -module-file-info about C++20 Modules
+// can reflect macros definitions correctly.
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header %t/foo.h -o 
%t/foo.pcm
+// RUN: %clang_cc1 -module-file-info %t/foo.pcm | FileCheck %t/foo.h
+//
+// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header 
%t/include_foo.h -o %t/include_foo.pcm
+// RUN: %clang_cc1 -module-file-info %t/include_foo.pcm | FileCheck 
%t/include_foo.h
+
+// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header 
-fmodule-file=%t/foo.pcm \
+// RUN: %t/import_foo.h -o %t/import_foo.pcm
+// RUN: %clang_cc1 -module-file-info %t/import_foo.pcm | FileCheck 
%t/import_foo.h
+//
+// RUN: %clang_cc1 -std=c++20 %t/named_module.cppm -emit-module-interface -o 
%t/M.pcm
+// RUN: %clang_cc1 -module-file-info %t/M.pcm | FileCheck %t/named_module.cppm
+
+//--- foo.h
+#pragma once
+#define FOO
+#define CONSTANT 43
+#define FUNC_Macro(X) (X+1)
+#define TO_BE_UNDEF
+#undef TO_BE_UNDEF
+
+#ifndef FOO
+#define CONDITIONAL_DEF
+#endif
+
+#define REDEFINE
+#define REDEFINE
+
+// CHECK: Macro Definitions:
+// CHECK-DAG: REDEFINE
+// CHECK-DAG: FUNC_Macro
+// CHECK-DAG: CONSTANT
+// CHECK-DAG: FOO
+// CHECK-NEXT: ===
+
+//--- include_foo.h
+#include "foo.h"
+#undef REDEFINE
+// CHECK: Macro Definitions:
+// CHECK-DAG: CONSTANT
+// CHECK-DAG: FUNC_Macro
+// CHECK-DAG: FOO
+// CHECK-NEXT: ===
+
+//--- import_foo.h
+import "foo.h";
+#undef REDEFINE
+// CHECK: Macro Definitions:
+// CHECK-DAG: CONSTANT
+// CHECK-DAG: FUNC_Macro
+// CHECK-DAG: FOO
+// CHECK-NEXT: ===
+
+//--- named_module.cppm
+module;
+#include "foo.h"
+export module M;
+#define M_Module 43
+// FIXME: It is meaningless for named modules to emit macro definitions.
+// It wastes the time and spaces completely.
+// CHECK: Macro Definitions:
+// CHECK-DAG: M_Module
+// CHECK-DAG: REDEFINE
+// CHECK-DAG: FUNC_Macro
+// CHECK-DAG: TO_BE_UNDEF
+// CHECK-DAG: FOO
+// CHECK-DAG: CONSTANT
+// CHECK-NEXT: ===



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


[PATCH] D137181: [clang-format] Don't use 'PPIndentWidth' inside multi-line macros

2022-11-13 Thread Noah Goldstein via Phabricator via cfe-commits
goldstein.w.n updated this revision to Diff 475050.
goldstein.w.n added a comment.



1. Updating D137181 : [clang-format] Don't 
use 'PPIndentWidth' inside multi-line macros #
2. Enter a brief description of the changes included in this update.
3. The first line is used as subject, next lines as comment. #
4. If you intended to create a new revision, use:
5. $ arc diff --create

Cleanup logic in Formatter


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137181

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -5040,6 +5040,348 @@
"  int y = 0;\n"
"}",
style);
+
+  style.IndentPPDirectives = FormatStyle::PPDIS_None;
+  verifyFormat("#ifdef X\n"
+   "#define Y  \\\n"
+   "switch (Y) {   \\\n"
+   "case 0:\\\n"
+   "break; \\\n"
+   "case 1:\\\n"
+   "break; \\\n"
+   "}  \\\n"
+   "Z();\n"
+   "#endif",
+   style);
+  verifyFormat("#ifdef foo\n"
+   "#define bar() \\\n"
+   "if (A) {  \\\n"
+   "B();  \\\n"
+   "} \\\n"
+   "C();\n"
+   "#endif",
+   style);
+  verifyFormat("if (emacs) {\n"
+   "#ifdef is\n"
+   "#define lit   \\\n"
+   "if (af) { \\\n"
+   "return duh(); \\\n"
+   "}\n"
+   "#endif\n"
+   "}",
+   style);
+  verifyFormat("#if abc\n"
+   "#ifdef foo\n"
+   "#define bar()\\\n"
+   "if (A) { \\\n"
+   "if (B) { \\\n"
+   "C(); \\\n"
+   "}\\\n"
+   "}\\\n"
+   "D();\n"
+   "#endif\n"
+   "#endif",
+   style);
+  verifyFormat("#ifndef foo\n"
+   "#define foo\n"
+   "if (emacs) {\n"
+   "#ifdef is\n"
+   "#define lit   \\\n"
+   "if (af) { \\\n"
+   "return duh(); \\\n"
+   "}\n"
+   "#endif\n"
+   "}\n"
+   "#endif",
+   style);
+  verifyFormat("#if 1\n"
+   "#define X  \\\n"
+   "{  \\\n"
+   "x; \\\n"
+   "x; \\\n"
+   "}\n"
+   "#endif",
+   style);
+  verifyFormat("#define X  \\\n"
+   "{  \\\n"
+   "x; \\\n"
+   "x; \\\n"
+   "}\n",
+   style);
+
+  style.PPIndentWidth = 2;
+  verifyFormat("#ifdef foo\n"
+   "#define bar() \\\n"
+   "if (A) {  \\\n"
+   "B();  \\\n"
+   "} \\\n"
+   "C();\n"
+   "#endif",
+   style);
+  style.IndentWidth = 8;
+  verifyFormat("#ifdef foo\n"
+   "#define bar()\\\n"
+   "if (A) { \\\n"
+   "B(); \\\n"
+   "}\\\n"
+   "C();\n"
+   "#endif",
+   style);
+
+  style.IndentWidth = 1;
+  style.PPIndentWidth = 4;
+  verifyFormat("#if 1\n"
+   "#define X \\\n"
+   " {\\\n"
+   "  x;  \\\n"
+   "  x;  \\\n"
+   " }\n"
+   "#endif",
+   style);
+  verifyFormat("#define X \\\n"
+   " {\\\n"
+   "  x;  \\\n"
+   "  x;  \\\n"
+   " }\n",
+   style);
+
+  style.IndentWidth = 4;
+  style.PPIndentWidth = 1;
+
+  style.IndentPPDirectives = FormatStyle::PPDIS_AfterHash;
+  verifyFormat("#ifdef X\n"
+   "# define Y  \\\n"
+   " switch (Y) {   \\\n"
+   " case 0:\\\n"
+   " break; \\\n"
+   " case 1:\\\n"
+   " break; \\\n"
+   " }  \\\n"
+   " Z();\n"
+   "#endif",
+   style);
+  verifyFormat("#ifdef foo\n"
+   "# define bar() \\\n"
+ 

[PATCH] D137181: [clang-format] Don't use 'PPIndentWidth' inside multi-line macros

2022-11-13 Thread Noah Goldstein via Phabricator via cfe-commits
goldstein.w.n added a comment.

In D137181#3923921 , @owenpan wrote:

> I think we are close to the finishing line. Can you revisit the change to the 
> formatter and clean it up? For example, casting `PPLevel` to `unsigned` is 
> redundant now. IMO you can simply the change too.

Cleaned up the logic a bit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137181

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


[PATCH] D137181: [clang-format] Don't use 'PPIndentWidth' inside multi-line macros

2022-11-13 Thread Noah Goldstein via Phabricator via cfe-commits
goldstein.w.n marked 2 inline comments as done.
goldstein.w.n added inline comments.



Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:69
   (Style.PPIndentWidth >= 0) ? Style.PPIndentWidth : Style.IndentWidth;
-  Indent = Line.Level * IndentWidth + AdditionalIndent;
+  if (Line.InMacroBody && Line.PPLevel != 0 &&
+  static_cast(Line.PPLevel) < Line.Level) {

sstwcw wrote:
> What is this test for?
> 
> ```
> clang-format -style='{IndentPPDirective: BeforeHash, PPIndentWidth: 2, 
> IndentWidth: 4, ColumnLimit: 40}'
> 
> actual:
> #define X  \
>   {\
> x; \
> x; \
>   }
> 
> expected:
> #define X  \
> {  \
> x; \
> x; \
> }
> ```
You're right, unneeded. Fixed and added test for it.



Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:73
+Indent += (Line.Level - Line.PPLevel - 1) * Style.IndentWidth;
+if (PPIndentWidth < Style.IndentWidth)
+  Indent += Style.IndentWidth - PPIndentWidth;

sstwcw wrote:
> What is this for?
> 
> ```
> clang-format -style='{IndentPPDirective: BeforeHash, PPIndentWidth: 4, 
> IndentWidth: 1, ColumnLimit: 40}'
> 
> actual:
> #if X
> #define X  \
> {  \
>  x;\
>  x;\
> }
> #endif
> 
> expected:
> #if X
> #define X  \
>  { \
>   x;   \
>   x;   \
>  }
> #endif
> ```
You're right, unneeded. Fixed and added test for it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137181

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


[PATCH] D133289: [C2X] N3007 Type inference for object definitions

2022-11-13 Thread Guillot Tony via Phabricator via cfe-commits
to268 marked 7 inline comments as done.
to268 added a comment.

This is a status update of the patch.




Comment at: clang/lib/Parse/ParseExpr.cpp:1526
+// This is a temporary fix while we don't support C2x 6.5.2.5p4
+if (getLangOpts().C2x && GetLookAheadToken(2).getKind() == tok::l_brace) {
+  Diag(Tok, diag::err_c2x_auto_compound_literal_not_allowed);

aaron.ballman wrote:
> I don't think this is quite right; I suspect we're going to need more 
> complicated logic here. Consider a case like: `(auto const){ 12 }` or `(auto 
> *){ nullptr }` where two tokens ahead is `)` and not `{`. (Note, these type 
> specifications can be pretty arbitrarily complex.)
> 
> Given that this is a temporary workaround for a lack of support for storage 
> class specifiers in compound literals, perhaps another approach is to not try 
> to catch uses in compound literals. Instead, we could add tests with FIXME 
> comments to demonstrate the behavior we get with compound literals now, and 
> when we do that storage class specifier work, we will (hopefully) break those 
> tests and come back to make them correct.
I think it's better to make a test of the actual behavior than trying to 
correct this case. 



Comment at: clang/lib/Parse/ParseExpr.cpp:1530-1531
+}
+  }
+[[fallthrough]];
+

aaron.ballman wrote:
> This looks a bit less visually jarring to me (the indentation differences 
> were distracting). WDYT?
That's better but i remember that `clang-format` has failed on that.



Comment at: clang/test/C/C2x/n3007.c:13
+  int* pc = &c; // expected-warning {{incompatible pointer types initializing 
'int *' with an expression of type 'unsigned long *'}}
+
+  const int ci = 12;

aaron.ballman wrote:
> I'd also like a test for:
> ```
> _Atomic auto i = 12;
> _Atomic(auto) j = 12;
> 
> _Atomic(int) foo(void);
> auto k = foo(); // Do we get _Atomic(int) or just int?
> ```
The _Atomic qualifier is dropped so the type of k is an `int`



Comment at: clang/test/C/C2x/n3007.c:40-41
+void test_arrary(void) {
+  auto a[4];  // expected-error {{'a' declared as array of 'auto'}}
+  auto b[] = {1, 2};  // expected-error {{'b' declared as array of 'auto'}}
+}

aaron.ballman wrote:
> I think other array cases we want to test are:
> ```
> auto a = { 1 , 2 }; // Error
> auto b = { 1, }; // OK
> auto c = (int [3]){ 1, 2, 3 }; // OK
> ```
These statements are not working:
```
auto b = { 1, }; // Not valid
auto d = { 1 };  // Not valid
```
I think it's related to the compound literal.




Comment at: clang/test/C/C2x/n3007.c:56
+
+  _Static_assert(_Generic(test_char_ptr, const char * : 1, char * : 2) == 2, 
"C is weird");
+}

aaron.ballman wrote:
> I'd also like to ensure we reject:
> ```
> typedef auto (*fp)(void);
> typedef void (*fp)(auto);
> 
> _Generic(0, auto : 1);
> ```
> and we should ensure we properly get integer promotions:
> ```
> short s;
> auto a = s;
> _Generic(a, int : 1);
> ```
> and a test for use of an explicit pointer declarator (which is UB that we can 
> define if we want to):
> ```
> int a;
> auto *ptr = &a; // Okay?
> auto *ptr = a; // Error
> ```
```
> and we should ensure we properly get integer promotions:
> ```
> short s;
> auto a = s;
> _Generic(a, int : 1);
> ```
I got the error `controlling expression type 'short' not compatible with any 
generic association type` so we don't promote from `short` to `int`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133289

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


[PATCH] D137712: Correctly handle Substitution failure in concept specialization.

2022-11-13 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 updated this revision to Diff 475054.
usaxena95 marked 3 inline comments as done.
usaxena95 added a comment.

Addressed commented. Added Release notes.
Removed infrastructure changes and deferred them to a future patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137712

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ExprConcepts.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/ComputeDependence.cpp
  clang/lib/AST/ExprConcepts.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/Sema/SemaConcept.cpp
  clang/lib/Sema/TreeTransform.h
  clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp

Index: clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp
===
--- clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp
+++ clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp
@@ -51,3 +51,80 @@
   X.next();
 };
 
+
+namespace SubstitutionFailureNestedRequires {
+template  concept True = true;
+
+struct S { double value; };
+
+template 
+concept Pipes = requires (T x) {
+   requires True || True;
+   requires True || True;
+};
+
+template 
+concept Amps1 = requires (T x) {
+   requires True && True;
+   // expected-note@-1{{because 'member reference base type 'int' is not a structure or union'}}
+};
+template 
+concept Amps2 = requires (T x) {
+   requires True && True;
+};
+
+static_assert(Pipes);
+static_assert(Pipes);
+
+static_assert(Amps1);
+static_assert(!Amps1);
+
+static_assert(Amps2);
+static_assert(!Amps2);
+
+template
+void foo1() requires requires (T x) { // expected-note {{candidate template ignored: constraints not satisfied [with T = int]}}
+  requires
+  True // expected-note {{because 'member reference base type 'int' is not a structure or union'}}
+  && True;
+} {}
+template void fooPipes() requires Pipes {}
+template void fooAmps1() requires Amps1 {}
+// expected-note@-1 {{candidate template ignored: constraints not satisfied [with T = int]}} \
+// expected-note@-1 {{because 'int' does not satisfy 'Amps1'}}
+
+void foo() {
+  foo1();
+  foo1(); // expected-error {{no matching function for call to 'foo1'}}
+  fooPipes();
+  fooPipes();
+  fooAmps1();
+  fooAmps1(); // expected-error {{no matching function for call to 'fooAmps1'}}
+}
+
+template
+concept HasNoValue = requires (T x) {
+  requires !True && True;
+};
+static_assert(HasNoValue);
+static_assert(!HasNoValue);
+
+template constexpr bool NotAConceptTrue = true;
+template 
+concept SFinNestedRequires = requires (T x) {
+// Only SF in a concept specialisation should be evaluated to false. 
+// Rest is still a SF.
+   requires NotAConceptTrue || NotAConceptTrue;
+   // expected-note@-1 {{because 'NotAConceptTrue || NotAConceptTrue' would be invalid: member reference base type 'int' is not a structure or union}}
+};
+static_assert(!SFinNestedRequires); // Unsatisfied but not a hard error.
+static_assert(SFinNestedRequires);
+template 
+void foo() requires SFinNestedRequires {} 
+// expected-note@-1 {{candidate template ignored: constraints not satisfied [with T = int]}}
+// expected-note@-2 {{because 'int' does not satisfy 'SFinNestedRequires'}}
+void bar() { 
+  foo(); // expected-error {{no matching function for call to 'foo'}}
+  foo();
+}
+}
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -15,6 +15,7 @@
 
 #include "CoroutineStmtBuilder.h"
 #include "TypeLocBuilder.h"
+#include "clang/AST/ASTConcept.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/DeclTemplate.h"
@@ -37,6 +38,7 @@
 #include "clang/Sema/ScopeInfo.h"
 #include "clang/Sema/SemaDiagnostic.h"
 #include "clang/Sema/SemaInternal.h"
+#include "clang/Sema/TemplateDeduction.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/Support/ErrorHandling.h"
 #include 
@@ -3477,6 +3479,23 @@
 return Result;
   }
 
+  ExprResult RebuildConceptSpecializationSubstitutionFailure(
+  ConceptSpecializationExpr *E,
+  ConstraintSatisfaction::SubstitutionDiagnostic *SubstDiags) {
+ConstraintSatisfaction Satisfaction;
+Satisfaction.IsSatisfied = false;
+Satisfaction.ContainsErrors = false;
+Satisfaction.Details.emplace_back(E, SubstDiags);
+CXXScopeSpec SS;
+SS.Adopt(E->getNestedNameSpecifierLoc());
+return ConceptSpecializationExpr::CreateSubstitutionFailure(
+SemaRef.Context,
+SS.isSet() ? SS.getWithLocInContext(SemaRef.Context)
+   : NestedNameSpecifierLoc{},
+E->getTemplateKWLoc(), E->getConceptNameInfo(), E->getFoundDecl(),
+E->getNamedConcept(), &Satisfaction);
+  }
+
   /// \brief Build a new requires expression.
   ///
   /// By default, performs semantic analysis to build the new expression.
@

[PATCH] D137712: Correctly handle Substitution failure in concept specialization.

2022-11-13 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 added inline comments.



Comment at: clang/include/clang/AST/ExprConcepts.h:103
 
+  bool hasSubstitutionFailureInArgs() const {
+return ArgsHasSubstitutionFailure;

erichkeane wrote:
> Does this really belong here instead of as a part of the 
> ConceptSpecializationDecl?
I am not aware of the original goals for this. For example, 
`ASTTemplateArgumentListInfo` is part of `ConceptReference` while 
`TemplateArgument` is part of `ImplicitConceptSpecializationDecl`. Both of them 
are invalid in such a case.
I am open to suggestion to where to place this.



Comment at: clang/include/clang/AST/ExprConcepts.h:159
+  // todo: add doc ?
+struct SubstitutionDiagnostic {
+  StringRef SubstitutedEntity;

erichkeane wrote:
> I had a previous patch at something else where I was moving toward doing this 
> change, so I think this is probably something inevitable.  
> 
> However, I'm having a tough time splitting this patch mentally between the 
> 'fix' and the infrastructure changes needed.  A part of me thinks we should 
> split this patch a bit in that direction.
I agree. This is a larger change which probably belongs to a separate change. 
Until then I think it is fine to not provide diagnostic of the exact expression 
of the SubstitutedEntity for which SF occurred.



Comment at: clang/lib/AST/ExprConcepts.cpp:112-113
+  return ConceptSpecializationExpr::Create(
+  C, NNS, TemplateKWLoc, ConceptNameInfo, FoundDecl, NamedConcept, nullptr,
+  nullptr, Satisfaction);
+}

shafik wrote:
> I think I got the parameter names correct.
Could you please elaborate what is your suggestion here ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137712

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


[PATCH] D137040: [clangd] Add heuristic for dropping snippet when completing member function pointer

2022-11-13 Thread Nathan Ridge via Phabricator via cfe-commits
nridge accepted this revision.
nridge added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137040

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