[PATCH] D120992: [analyzer] ReverseNull: New checker to warn for pointer value conditions, if the pointer value is unconditionally non-null

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

In D120992#3368118 , @NoQ wrote:

> I guess there's the usual direction that I occasionally suggest: develop a 
> way to verify that all possible paths were explored during symbolic execution 
> (`CoreEngine::hasWorkRemaining()` on steroids), then do most of the work in 
> `checkEndAnalysis`.

I agree that having infrastructure for that would be useful. And I also agree 
that it might be overkill for this particular warning.

> In fact you already have one of the building blocks:

The dataflow analysis framework from google is also starting to shape up quite 
nicely. It already has a lightweight modeling of the memory that could be used 
to check if the pointer was changed between two program points.

> I actually don't know why dead stores checker isn't a compiler warning.

My guess would be simply no-one submitted a patch doing that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120992

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


[PATCH] D121176: [ASTStructuralEquivalence] Add support for comparing ObjCCategoryDecl.

2022-03-08 Thread Aleksei Sidorin via Phabricator via cfe-commits
a_sidorin added a comment.

Hi Volodymyr,
Unfortunately, I'm not familiar with Objective-C and its frontend but I have a 
question.




Comment at: clang/lib/AST/ASTStructuralEquivalence.cpp:1989
+   ++ParamT1, ++ParamT2) {
+if (!IsStructurallyEquivalent(Context, *ParamT1, *ParamT2))
+  return false;

Should we check if the parameter count is different?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121176

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


[PATCH] D121122: Set FLT_EVAL_METHOD to -1 when fast-math is enabled.

2022-03-08 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam updated this revision to Diff 413936.
zahiraam marked 3 inline comments as done.

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

https://reviews.llvm.org/D121122

Files:
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaAttr.cpp
  clang/test/CodeGen/eval-method-fast-math.c

Index: clang/test/CodeGen/eval-method-fast-math.c
===
--- /dev/null
+++ clang/test/CodeGen/eval-method-fast-math.c
@@ -0,0 +1,87 @@
+// RUN: %clang_cc1 -fexperimental-strict-floating-point  \
+// RUN: -triple x86_64-linux-gnu -emit-llvm -o - %s  \
+// RUN: | FileCheck %s -check-prefixes=CHECK
+
+// RUN: %clang_cc1 -triple i386--linux -emit-llvm -o - %s \
+// RUN: | FileCheck %s -check-prefixes=CHECK-EXT
+
+// RUN: %clang_cc1 -fexperimental-strict-floating-point  \
+// RUN: -mreassociate -freciprocal-math -ffp-contract=fast \
+// RUN: -ffast-math -triple x86_64-linux-gnu \
+// RUN: -emit-llvm -o - %s \
+// RUN: | FileCheck %s -check-prefixes=CHECK-FAST
+
+// RUN: %clang_cc1 -triple i386--linux -mreassociate -freciprocal-math \
+// RUN: -ffp-contract=fast -ffast-math -emit-llvm -o - %s \
+// RUN: | FileCheck %s -check-prefixes=CHECK-FAST
+
+float res;
+int add(float a, float b, float c) {
+  // CHECK: fadd float
+  // CHECK: load float, float*
+  // CHECK: fadd float
+  // CHECK: store float
+  // CHECK-FAST: fadd fast float
+  // CHECK-FAST: load float, float*
+  // CHECK-FAST: fadd fast float
+  // CHECK: ret i32 0
+  // CHECK-EXT: ret i32 2
+  // CHECK-FAST: ret i32 -1
+  res = a + b + c;
+  return __FLT_EVAL_METHOD__;
+}
+
+int add_precise(float a, float b, float c) {
+#pragma float_control(precise, on)
+  // CHECK: fadd float
+  // CHECK: load float, float*
+  // CHECK: fadd float
+  // CHECK: store float
+  // CHECK: ret i32 0
+  // CHECK-FAST: ret i32 -1
+  res = a + b + c;
+  return __FLT_EVAL_METHOD__;
+}
+
+#pragma float_control(push)
+#pragma float_control(precise, on)
+int add_precise_1(float a, float b, float c) {
+  // CHECK: fadd float
+  // CHECK: load float, float*
+  // CHECK: fadd float
+  // CHECK: store float
+  // CHECK: ret i32 0
+  // CHECK-FAST: ret i32 -1
+  res = a + b + c;
+  return __FLT_EVAL_METHOD__;
+}
+#pragma float_control(pop)
+
+int add_not_precise(float a, float b, float c) {
+  // Fast-math is enabled with this pragma.
+#pragma float_control(precise, off)
+  // CHECK-FAST: fadd fast float
+  // CHECK-FAST: load float, float*
+  // CHECK-FAST: fadd fast float
+  // CHECK-FAST: ret i32 -1
+  res = a + b + c;
+  return __FLT_EVAL_METHOD__;
+}
+
+#pragma float_control(push)
+// Fast-math is enabled with this pragma.
+#pragma float_control(precise, off)
+int add_not_precise_1(float a, float b, float c) {
+  // CHECK-FAST: fadd fast float
+  // CHECK-FAST: load float, float*
+  // CHECK-FAST: fadd fast float
+  // CHECK-FAST: ret i32 -1
+  res = a + b + c;
+  return __FLT_EVAL_METHOD__;
+}
+#pragma float_control(pop)
+
+int getFPEvalMethod() {
+  // CHECK: ret i32 0
+  return __FLT_EVAL_METHOD__;
+}
Index: clang/lib/Sema/SemaAttr.cpp
===
--- clang/lib/Sema/SemaAttr.cpp
+++ clang/lib/Sema/SemaAttr.cpp
@@ -517,6 +517,9 @@
 else
   NewFPFeatures.setFPPreciseEnabled(false);
 FpPragmaStack.Act(Loc, Action, StringRef(), NewFPFeatures);
+// Fast-math is enabled.
+PP.setCurrentFPEvalMethod(
+Loc, LangOptions::FPEvalMethodKind::FEM_Indeterminable);
 break;
   case PFC_Except:
 if (!isPreciseFPEnabled())
@@ -540,6 +543,8 @@
 }
 FpPragmaStack.Act(Loc, Action, StringRef(), NewFPFeatures);
 NewFPFeatures = FpPragmaStack.CurrentValue;
+PP.setCurrentFPEvalMethod(SourceLocation(),
+  CurFPFeatures.getFPEvalMethod());
 break;
   }
   CurFPFeatures = NewFPFeatures.applyOverrides(getLangOpts());
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -254,6 +254,10 @@
 PP.setCurrentFPEvalMethod(SourceLocation(),
   getLangOpts().getFPEvalMethod());
   CurFPFeatures.setFPEvalMethod(PP.getCurrentFPEvalMethod());
+  // Fast-math is enabled.
+  if (getLangOpts().AllowFPReassoc || getLangOpts().AllowRecip)
+PP.setCurrentFPEvalMethod(SourceLocation(),
+  LangOptions::FEM_Indeterminable);
 }
 
 // Anchor Sema's type info to this TU.
Index: clang/lib/Lex/PPMacroExpansion.cpp
===
--- clang/lib/Lex/PPMacroExpansion.cpp
+++ clang/lib/Lex/PPMacroExpansion.cpp
@@ -1577,14 +1577,35 @@
 Tok.setKind(tok::string_literal);
   } else if (II == Ident__FLT_EVAL_METHOD__) {
 // __FLT_EVAL_METHOD__ is set to the default value.
-OS << getTUFPEvalMethod();
-// __FLT_EVAL_METHOD__ expands to a simple numeric value.
-Tok.setKind(tok::num

[PATCH] D121122: Set FLT_EVAL_METHOD to -1 when fast-math is enabled.

2022-03-08 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam added inline comments.



Comment at: clang/lib/Lex/PPMacroExpansion.cpp:1600
+} else {
+  OS << getTUFPEvalMethod();
+  // __FLT_EVAL_METHOD__ expands to a simple numeric value.

andrew.w.kaylor wrote:
> It looks like you've got tabs in the code here.
No. I think that just means that the block of code was shifted  by a few spaces 
because it's in a condition now.



Comment at: clang/lib/Sema/SemaAttr.cpp:521
+// Fast-math is enabled.
+PP.setCurrentFPEvalMethod(
+Loc, LangOptions::FPEvalMethodKind::FEM_Indeterminable);

andrew.w.kaylor wrote:
> Why don't you need the reverse of this in the Precise and Pop cases? Also, 
> why is it necessary to call getCurrentFPEvalMethod() immediately after 
> setting it?
The call to getCurrentFPEvalMethod() was just left over debugging. Removed it.


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

https://reviews.llvm.org/D121122

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


[PATCH] D121078: Replace links to archived mailing lists by links to Discourse forums

2022-03-08 Thread Tanya Lattner via Phabricator via cfe-commits
tonic added a comment.

In D121078#3367950 , @aaron.ballman 
wrote:

> In D121078#3367289 , @tonic wrote:
>
>> In D121078#3366825 , 
>> @aaron.ballman wrote:
>>
>>> In D121078#3366025 , @tonic wrote:
>>>
 In D121078#3365542 , 
 @SimplyDanny wrote:

> In D121078#3363856 , 
> @aaron.ballman wrote:
>
>> I think we need to retain *some* references to the existing mailing list 
>> archives. The migration to Discourse worked fairly well, but there were 
>> still data migration issues.  For example:
>
> Do you have some prominent places in mind where the archives should be 
> mentioned? For me as someone who just started to get a bit more involved 
> into LLVM, the archives are not very helpful. There is no way to search 
> for threads as far as I know. That means it is very hard to find anything 
> specific. That is why I actually came up with this change in the first 
> place: Getting rid of references to the "old' mailing lists which are 
> just not helpful for beginners.
>>>
>>> Oh, I think these changes are *fantastic*, so I'm happy we're updating the 
>>> stale references to point to the more modern place to go. Thank you for 
>>> that!
>>>
>>> There are ways to search the archives (as Tanya mentioned, you can use a 
>>> google site search over them), but you have to know they exist to know to 
>>> do that, which is why I'd like to retain some mention of them until the 
>>> migration moves over *all* of the historical data. It's not super handy for 
>>> most folks, so I don't think we need a *prominent* place for this. But it 
>>> is handy for those of us who have to do a fair amount of historical digging 
>>> around to see how we came to the conclusions we came to (not a common 
>>> activity, but it is not uncommon for folks on standards committees to be 
>>> asked "why does your implementation do X?" and need to go looking).
>>
>> AFAIK, we have never had  link to the archives and instructed people to go 
>> search them aside from the link on the Mailman list info page.
>
> This patch removes the links to where the archives can be found. I have 
> instructed people to go search those archives on multiple occasions as part 
> of ISO standards work.
>
>> In addition, knowing they exist is also something that was not super obvious 
>> to many people who have not used Mailman. I want to avoid adding references 
>> to archives in all of these places because it defeats all the work to go and 
>> update the locations to have to go back and do it again.
>
> I know you want to avoid all mentions of mailman. I want to avoid losing 
> information that is still relevant for the foreseeable future. The places I 
> want to see updated already list mailman for the commits lists, so I don't 
> agree that my request adds a material burden for the future.
>
>> It is also confusing to newcomers to the project.
>
> This is why I suggested using a footnote to make it much more clear that this 
> is a secondary option. Not everyone in the project is a newcomer, but we 
> still need to support them. I'm not at all tied to this solution of using 
> footnotes if you have a suggestion for a less intrusive approach to 
> accomplish the same goal.
>
>>> I think the least distracting thing we could do would be to put a 
>>> superscript footnote after any link to a particular discourse forum which 
>>> goes to an anchor at the bottom of the page to a footnote saying something 
>>> like what I recommended below. This should keep the focus for most people 
>>> on going to Discourse, it shouldn't be overly distracting or confusing to 
>>> people new to the docs, but it still retains useful information that some 
>>> folks need.
>>>
 You do not need to worry about this.
>>>
>>> In your opinion, that may be true; in mine, this is still a concern.
>>
>> I don't think its fair to ask this person to be the one to add links to the 
>> archives and handle the situation. They are being put in the middle of an 
>> argument.
>
> The author changed a bunch of links in good ways but also did so in a way 
> that loses information in a few places that I don't wish to see lost. You 
> disagree. That's fine and is very normal part of patch review. It's not an 
> argument for reviewers to find consensus among themselves when there are 
> disagreements.
>
 Your change is updating the locations people are to ask for help.
>>>
>>> The change is also touching `Mailing List & Forums` content, which are not 
>>> specifically about asking for help (they can also be for reading instead of 
>>> writing).
>>
>> Again, we have never told people to search the archives. There isn't even a 
>> "Search" box on the archives.
>
> I ask folks to sear

[PATCH] D119479: [clang][extract-api] Add global record support

2022-03-08 Thread Zixu Wang via Phabricator via cfe-commits
zixuw updated this revision to Diff 413947.
zixuw added a comment.
Herald added a project: All.

Move ExtractAPIConsumer which references clangIndex USR generation methods out 
of clangFrontend to resolve a cycle between clangFrontend and clangIndex when 
building shared libs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119479

Files:
  clang/include/clang/AST/RawCommentList.h
  clang/include/clang/Frontend/FrontendActions.h
  clang/include/clang/SymbolGraph/API.h
  clang/include/clang/SymbolGraph/AvailabilityInfo.h
  clang/include/clang/SymbolGraph/DeclarationFragments.h
  clang/include/clang/SymbolGraph/Serialization.h
  clang/lib/AST/RawCommentList.cpp
  clang/lib/CMakeLists.txt
  clang/lib/Frontend/CMakeLists.txt
  clang/lib/Frontend/ExtractAPIConsumer.cpp
  clang/lib/SymbolGraph/API.cpp
  clang/lib/SymbolGraph/CMakeLists.txt
  clang/lib/SymbolGraph/DeclarationFragments.cpp
  clang/lib/SymbolGraph/ExtractAPIConsumer.cpp
  clang/lib/SymbolGraph/Serialization.cpp
  clang/test/Driver/extract-api.c
  clang/test/SymbolGraph/global_record.c

Index: clang/test/SymbolGraph/global_record.c
===
--- /dev/null
+++ clang/test/SymbolGraph/global_record.c
@@ -0,0 +1,363 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s@INPUT_DIR@%/t@g" %t/reference.output.json.in >> \
+// RUN: %t/reference.output.json
+// RUN: %clang -extract-api -target arm64-apple-macosx \
+// RUN: %t/input.c -o %t/output.json | FileCheck -allow-empty %s
+// RUN: diff %t/reference.output.json %t/output.json
+
+// CHECK-NOT: error:
+// CHECK-NOT: warning:
+
+//--- input.c
+int num;
+
+/**
+ * \brief Add two numbers.
+ * \param [in]  x   A number.
+ * \param [in]  y   Another number.
+ * \param [out] res The result of x + y.
+ */
+void add(const int x, const int y, int *res);
+
+//--- reference.output.json.in
+{
+  "metadata": {
+"formatVersion": {
+  "major": 0,
+  "minor": 5,
+  "patch": 3
+},
+"generator": "clang"
+  },
+  "module": {
+"name": "",
+"platform": {
+  "architecture": "arm64",
+  "operatingSystem": {
+"minimumVersion": {
+  "major": 11,
+  "minor": 0,
+  "patch": 0
+},
+"name": "macosx"
+  },
+  "vendor": "apple"
+}
+  },
+  "relationhips": [],
+  "symbols": [
+{
+  "declaration": [
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:I",
+  "spelling": "int"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "num"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "c",
+"precise": "c:@num"
+  },
+  "kind": {
+"displayName": "Variable",
+"identifier": "c.variable"
+  },
+  "location": {
+"character": 5,
+"line": 1,
+"uri": "file://INPUT_DIR/input.c"
+  },
+  "names": {
+"subHeading": [
+  {
+"kind": "identifier",
+"spelling": "num"
+  }
+],
+"title": "num"
+  }
+},
+{
+  "declaration": [
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:v",
+  "spelling": "void"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "add"
+},
+{
+  "kind": "text",
+  "spelling": "("
+},
+{
+  "kind": "keyword",
+  "spelling": "const"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:I",
+  "spelling": "int"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "internalParam",
+  "spelling": "x"
+},
+{
+  "kind": "text",
+  "spelling": ", "
+},
+{
+  "kind": "keyword",
+  "spelling": "const"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:I",
+  "spelling": "int"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "internalParam",
+  "spelling": "y"
+},
+{
+  "kind": "text",
+  "spelling": ", "
+},
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:I",
+  "spelling": "int"
+},
+{
+  "kind": "text",
+  "spelling": " *"
+},
+{
+  "kind": "internalParam",
+  "s

[PATCH] D119479: [clang][extract-api] Add global record support

2022-03-08 Thread Zixu Wang via Phabricator via cfe-commits
zixuw added a comment.

I've moved things around to resolve the cycle, but sadly it seems that shared 
lib builds are already broken and I could not test it:

  Linking CXX shared library lib/libLLVMTransformUtils.dylib
  FAILED: lib/libLLVMTransformUtils.dylib :
   
  Undefined symbols for architecture x86_64:
"(anonymous namespace)::MinCostMaxFlow::MinBaseDistance", referenced from:
(anonymous namespace)::FlowAdjuster::jumpDistance(llvm::FlowJump*) 
const in SampleProfileInference.cpp.o


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119479

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


[PATCH] D121259: [clang] Fix CodeGenAction for LLVM IR MemBuffers

2022-03-08 Thread Ryan Senanayake via Phabricator via cfe-commits
RSenApps created this revision.
RSenApps added reviewers: jlebar, mkuper, dcastagna, shangwuyao.
Herald added a project: All.
RSenApps requested review of this revision.
Herald added a project: clang.

Replaces use of getCurrentFile with getCurrentFileOrBufferName
in CodeGenAction. This avoids an assertion error or an incorrect
name chosen for the output file when assertions are disabled.
This error previously occurred when the FrontendInputFile was a
MemoryBuffer instead of a file.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121259

Files:
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/unittests/Frontend/CodeGenActionTest.cpp


Index: clang/unittests/Frontend/CodeGenActionTest.cpp
===
--- clang/unittests/Frontend/CodeGenActionTest.cpp
+++ clang/unittests/Frontend/CodeGenActionTest.cpp
@@ -59,4 +59,21 @@
   EXPECT_TRUE(Success);
 }
 
+TEST(CodeGenTest, CodeGenFromIRMemBuffer) {
+  auto Invocation = std::make_shared();
+  std::unique_ptr MemBuffer =
+  MemoryBuffer::getMemBuffer("", "test.ll");
+  Invocation->getFrontendOpts().Inputs.push_back(
+  FrontendInputFile(*MemBuffer, Language::LLVM_IR));
+  Invocation->getFrontendOpts().ProgramAction = frontend::EmitLLVMOnly;
+  Invocation->getTargetOpts().Triple = "i386-unknown-linux-gnu";
+  CompilerInstance Compiler;
+  Compiler.setInvocation(std::move(Invocation));
+  Compiler.createDiagnostics();
+  EXPECT_TRUE(Compiler.hasDiagnostics());
+
+  EmitLLVMOnlyAction Action;
+  bool Success = Compiler.ExecuteAction(Action);
+  EXPECT_TRUE(Success);
+}
 }
Index: clang/lib/CodeGen/CodeGenAction.cpp
===
--- clang/lib/CodeGen/CodeGenAction.cpp
+++ clang/lib/CodeGen/CodeGenAction.cpp
@@ -1113,7 +1113,7 @@
   auto &CodeGenOpts = CI.getCodeGenOpts();
   auto &Diagnostics = CI.getDiagnostics();
   std::unique_ptr OS =
-  GetOutputStream(CI, getCurrentFile(), BA);
+  GetOutputStream(CI, getCurrentFileOrBufferName(), BA);
   if (BA != Backend_EmitNothing && !OS)
 return;
 


Index: clang/unittests/Frontend/CodeGenActionTest.cpp
===
--- clang/unittests/Frontend/CodeGenActionTest.cpp
+++ clang/unittests/Frontend/CodeGenActionTest.cpp
@@ -59,4 +59,21 @@
   EXPECT_TRUE(Success);
 }
 
+TEST(CodeGenTest, CodeGenFromIRMemBuffer) {
+  auto Invocation = std::make_shared();
+  std::unique_ptr MemBuffer =
+  MemoryBuffer::getMemBuffer("", "test.ll");
+  Invocation->getFrontendOpts().Inputs.push_back(
+  FrontendInputFile(*MemBuffer, Language::LLVM_IR));
+  Invocation->getFrontendOpts().ProgramAction = frontend::EmitLLVMOnly;
+  Invocation->getTargetOpts().Triple = "i386-unknown-linux-gnu";
+  CompilerInstance Compiler;
+  Compiler.setInvocation(std::move(Invocation));
+  Compiler.createDiagnostics();
+  EXPECT_TRUE(Compiler.hasDiagnostics());
+
+  EmitLLVMOnlyAction Action;
+  bool Success = Compiler.ExecuteAction(Action);
+  EXPECT_TRUE(Success);
+}
 }
Index: clang/lib/CodeGen/CodeGenAction.cpp
===
--- clang/lib/CodeGen/CodeGenAction.cpp
+++ clang/lib/CodeGen/CodeGenAction.cpp
@@ -1113,7 +1113,7 @@
   auto &CodeGenOpts = CI.getCodeGenOpts();
   auto &Diagnostics = CI.getDiagnostics();
   std::unique_ptr OS =
-  GetOutputStream(CI, getCurrentFile(), BA);
+  GetOutputStream(CI, getCurrentFileOrBufferName(), BA);
   if (BA != Backend_EmitNothing && !OS)
 return;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D120936: [Sema][Windows] Don't special-case void* in __unaligned conversions.

2022-03-08 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I remember writing up feedback on this patch, but it's gone now, oh well.

I wasn't able to find any history for why `void*` was special here.

I see that MSVC doesn't warn when converting from `__unaligned int*` to `int*`, 
but that seems dangerous. Our team has an active feature request to tighten up 
clang warnings to make it harder to form unaligned pointers, so I'd like to 
insist that we warn when the `__unaligned` qualifier gets lost.




Comment at: clang/test/SemaCXX/MicrosoftExtensions.cpp:90
 
-  B_unaligned *p5 = p3; // expected-error {{cannot initialize a variable of 
type 'B_unaligned *' with an lvalue of type '__unaligned B_unaligned *'}}
+  B_unaligned *p5 = p3;
 

erichkeane wrote:
> MSVC is warning on this one, its a shame we don't have something similar.
I agree this is important, and I think it's a blocking issue. We don't want to 
allow new constructs, introduce a warning for them later, and then ask people 
to clean it up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120936

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


[PATCH] D121259: [clang] Fix CodeGenAction for LLVM IR MemBuffers

2022-03-08 Thread Justin Lebar via Phabricator via cfe-commits
jlebar accepted this revision.
jlebar added a comment.
This revision is now accepted and ready to land.

Congrats on your first patch!

Can Daniele or Shangwu land this for you, or do you need me to?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121259

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


[PATCH] D120949: [clang][AST matchers] adding attributedStmt AST matcher

2022-03-08 Thread Alister Johnson via Phabricator via cfe-commits
ajohnson-uoregon updated this revision to Diff 413962.
ajohnson-uoregon added a comment.

Figuring out git-clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120949

Files:
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/ASTMatchers/ASTMatchersInternal.cpp
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -2509,6 +2509,28 @@
   EXPECT_FALSE(Finder.addDynamicMatcher(hasName("x"), nullptr));
 }
 
+TEST(ASTMatchersTest, AttributedStmtBasic) {
+  StringRef Code = "int foo() { [[likely]] return 1; }";
+  EXPECT_TRUE(
+  matchesConditionally(Code, attributedStmt(), true, {"-std=c++20"}));
+}
+
+TEST(ASTMatchersTest, AttributedStmt_isAttr) {
+  StringRef Code = "int foo() { [[unlikely]] return 1; }";
+  EXPECT_TRUE(matchesConditionally(Code, attributedStmt(isAttr(attr::Unlikely)),
+   true, {"-std=c++20"}));
+  EXPECT_FALSE(matchesConditionally(Code, attributedStmt(isAttr(attr::Builtin)),
+true, {"-std=c++20"}));
+}
+
+TEST(ASTMatchersTest, AttributedStmt_hasSubStmt) {
+  StringRef Code = "int foo() { [[likely]] return 1; }";
+  EXPECT_TRUE(matchesConditionally(
+  Code, attributedStmt(hasSubStmt(returnStmt())), true, {"-std=c++20"}));
+  EXPECT_FALSE(matchesConditionally(Code, attributedStmt(hasSubStmt(ifStmt())),
+true, {"-std=c++20"}));
+}
+
 TEST(MatchFinderAPI, MatchesDynamic) {
   StringRef SourceCode = "struct A { void f() {} };";
   auto Matcher = functionDecl(isDefinition()).bind("method");
Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -142,6 +142,7 @@
   REGISTER_MATCHER(atomicExpr);
   REGISTER_MATCHER(atomicType);
   REGISTER_MATCHER(attr);
+  REGISTER_MATCHER(attributedStmt);
   REGISTER_MATCHER(autoType);
   REGISTER_MATCHER(autoreleasePoolStmt)
   REGISTER_MATCHER(binaryConditionalOperator);
@@ -355,6 +356,7 @@
   REGISTER_MATCHER(hasSpecializedTemplate);
   REGISTER_MATCHER(hasStaticStorageDuration);
   REGISTER_MATCHER(hasStructuredBlock);
+  REGISTER_MATCHER(hasSubStmt);
   REGISTER_MATCHER(hasSyntacticForm);
   REGISTER_MATCHER(hasTargetDecl);
   REGISTER_MATCHER(hasTemplateArgument);
@@ -395,6 +397,7 @@
   REGISTER_MATCHER(isArrow);
   REGISTER_MATCHER(isAssignmentOperator);
   REGISTER_MATCHER(isAtPosition);
+  REGISTER_MATCHER(isAttr);
   REGISTER_MATCHER(isBaseInitializer);
   REGISTER_MATCHER(isBitField);
   REGISTER_MATCHER(isCatchAll);
Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -981,6 +981,8 @@
 predefinedExpr;
 const internal::VariadicDynCastAllOfMatcher
 designatedInitExpr;
+const internal::VariadicDynCastAllOfMatcher
+attributedStmt;
 const internal::VariadicOperatorMatcherFunc<
 2, std::numeric_limits::max()>
 eachOf = {internal::DynTypedMatcher::VO_EachOf};
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -2699,6 +2699,60 @@
   return Node.size() == N;
 }
 
+/// Matches the attribute(s) attached to a Stmt
+///
+/// Given:
+/// \code
+///   constexpr double pow(double x, long long n) noexcept {
+/// if (n > 0) [[likely]]
+///  return x * pow(x, n - 1);
+/// else [[unlikely]]
+///  return 1;
+///   }
+/// \endcode
+/// attributedStmt() matches "[[likely]] return ...;" and
+/// "[[unlikely]] return 1;"
+extern const internal::VariadicDynCastAllOfMatcher
+attributedStmt;
+
+/// Matches the specified attribute.
+///
+/// Example:
+/// \code
+///   attributedStmt(isAttr(attr::Likely))
+/// \endcode
+/// would only match "[[likely]] return ...;" here:
+/// \code
+///   constexpr double pow(double x, long long n) noexcept {
+/// if (n > 0) [[likely]]
+///  return x * pow(x, n - 1);
+/// else [[unlikely]]
+///  return 1;
+///   }
+/// \endcode
+AST_MATCHER_P(AttributedStmt, isAttr, attr::Kind, AttrKind) {
+  return llvm::any_of(Node.getAttrs(),
+  [&](const Attr *A) { return A->getKind() == AttrKind; });
+}
+
+/// Matches the statement an attribute is attached to.
+///
+/// Example:
+/// \code
+///   attributedStmt(hasSubStmt(returnStmt()))
+/

[PATCH] D121259: [clang] Fix CodeGenAction for LLVM IR MemBuffers

2022-03-08 Thread Daniele Castagna via Phabricator via cfe-commits
dcastagna added a comment.

I'll land it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121259

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


[PATCH] D119479: [clang][extract-api] Add global record support

2022-03-08 Thread Zixu Wang via Phabricator via cfe-commits
zixuw added a comment.

Wait that's just a current linking issue on `main`, I suppose not specific to 
shared lib builds.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119479

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


[PATCH] D119479: [clang][extract-api] Add global record support

2022-03-08 Thread Zixu Wang via Phabricator via cfe-commits
zixuw updated this revision to Diff 413967.
zixuw added a comment.

Fix reference to vtable of ExtractAPIAction from 
clang/FrontendTools/ExecuteCompilerInstance


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119479

Files:
  clang/include/clang/AST/RawCommentList.h
  clang/include/clang/Frontend/FrontendActions.h
  clang/include/clang/SymbolGraph/API.h
  clang/include/clang/SymbolGraph/AvailabilityInfo.h
  clang/include/clang/SymbolGraph/DeclarationFragments.h
  clang/include/clang/SymbolGraph/FrontendActions.h
  clang/include/clang/SymbolGraph/Serialization.h
  clang/lib/AST/RawCommentList.cpp
  clang/lib/CMakeLists.txt
  clang/lib/Frontend/CMakeLists.txt
  clang/lib/Frontend/ExtractAPIConsumer.cpp
  clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  clang/lib/SymbolGraph/API.cpp
  clang/lib/SymbolGraph/CMakeLists.txt
  clang/lib/SymbolGraph/DeclarationFragments.cpp
  clang/lib/SymbolGraph/ExtractAPIConsumer.cpp
  clang/lib/SymbolGraph/Serialization.cpp
  clang/test/Driver/extract-api.c
  clang/test/SymbolGraph/global_record.c

Index: clang/test/SymbolGraph/global_record.c
===
--- /dev/null
+++ clang/test/SymbolGraph/global_record.c
@@ -0,0 +1,363 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s@INPUT_DIR@%/t@g" %t/reference.output.json.in >> \
+// RUN: %t/reference.output.json
+// RUN: %clang -extract-api -target arm64-apple-macosx \
+// RUN: %t/input.c -o %t/output.json | FileCheck -allow-empty %s
+// RUN: diff %t/reference.output.json %t/output.json
+
+// CHECK-NOT: error:
+// CHECK-NOT: warning:
+
+//--- input.c
+int num;
+
+/**
+ * \brief Add two numbers.
+ * \param [in]  x   A number.
+ * \param [in]  y   Another number.
+ * \param [out] res The result of x + y.
+ */
+void add(const int x, const int y, int *res);
+
+//--- reference.output.json.in
+{
+  "metadata": {
+"formatVersion": {
+  "major": 0,
+  "minor": 5,
+  "patch": 3
+},
+"generator": "clang"
+  },
+  "module": {
+"name": "",
+"platform": {
+  "architecture": "arm64",
+  "operatingSystem": {
+"minimumVersion": {
+  "major": 11,
+  "minor": 0,
+  "patch": 0
+},
+"name": "macosx"
+  },
+  "vendor": "apple"
+}
+  },
+  "relationhips": [],
+  "symbols": [
+{
+  "declaration": [
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:I",
+  "spelling": "int"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "num"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "c",
+"precise": "c:@num"
+  },
+  "kind": {
+"displayName": "Variable",
+"identifier": "c.variable"
+  },
+  "location": {
+"character": 5,
+"line": 1,
+"uri": "file://INPUT_DIR/input.c"
+  },
+  "names": {
+"subHeading": [
+  {
+"kind": "identifier",
+"spelling": "num"
+  }
+],
+"title": "num"
+  }
+},
+{
+  "declaration": [
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:v",
+  "spelling": "void"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "add"
+},
+{
+  "kind": "text",
+  "spelling": "("
+},
+{
+  "kind": "keyword",
+  "spelling": "const"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:I",
+  "spelling": "int"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "internalParam",
+  "spelling": "x"
+},
+{
+  "kind": "text",
+  "spelling": ", "
+},
+{
+  "kind": "keyword",
+  "spelling": "const"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:I",
+  "spelling": "int"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "internalParam",
+  "spelling": "y"
+},
+{
+  "kind": "text",
+  "spelling": ", "
+},
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:I",
+  "spelling": "int"
+},
+{
+  "kind": "text",
+  "spelling": " *"
+},
+{
+  "kind": "internalParam",
+  "spelling":

[PATCH] D121176: [ASTStructuralEquivalence] Add support for comparing ObjCCategoryDecl.

2022-03-08 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Thanks for the reviews! I'm going to address the comments, `check-lldb`, check 
tests failing on Debian.




Comment at: clang/lib/AST/ASTStructuralEquivalence.cpp:1971
+return false;
+  unsigned SlotsToCheck = NumArgs > 0 ? NumArgs : 1;
+  for (unsigned I = 0; I < SlotsToCheck; ++I) {

shafik wrote:
> I am curious what case are we catching here? Does `NumArgs` ever have the 
> value `1`?
Here I'm trying to handle the case with argument-less methods. For example, 
`-(void)test;` has 0 arguments but we still want to compare the first slot. At 
the moment I don't know how to clarify the code to make the intention clearer. 
Can add a comment explaining the intention (though there is a test that should 
catch breaking code accidentally).

And to answer your question, `NumArgs` can have value `1`.



Comment at: clang/lib/AST/ASTStructuralEquivalence.cpp:1989
+   ++ParamT1, ++ParamT2) {
+if (!IsStructurallyEquivalent(Context, *ParamT1, *ParamT2))
+  return false;

a_sidorin wrote:
> Should we check if the parameter count is different?
Mismatch in the number of parameters should be caught by `NumArgs != 
Selector2.getNumArgs()` earlier. But I think it makes sense to add an assertion 
verifying `param_size` is equal at this point.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121176

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


[clang] b3dae59 - [clang] Fix CodeGenAction for LLVM IR MemBuffers

2022-03-08 Thread Daniele Castagna via cfe-commits

Author: Ryan Senanayake
Date: 2022-03-09T00:39:48Z
New Revision: b3dae59b9dfb579d396bd97ca1b5a16529daac75

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

LOG: [clang] Fix CodeGenAction for LLVM IR MemBuffers

Replaces use of getCurrentFile with getCurrentFileOrBufferName
in CodeGenAction. This avoids an assertion error or an incorrect
name chosen for the output file when assertions are disabled.
This error previously occurred when the FrontendInputFile was a
MemoryBuffer instead of a file.

Reviewed By: jlebar

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

Added: 


Modified: 
clang/lib/CodeGen/CodeGenAction.cpp
clang/unittests/Frontend/CodeGenActionTest.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenAction.cpp 
b/clang/lib/CodeGen/CodeGenAction.cpp
index c2c508dedb097..807880fd4fd7a 100644
--- a/clang/lib/CodeGen/CodeGenAction.cpp
+++ b/clang/lib/CodeGen/CodeGenAction.cpp
@@ -1113,7 +1113,7 @@ void CodeGenAction::ExecuteAction() {
   auto &CodeGenOpts = CI.getCodeGenOpts();
   auto &Diagnostics = CI.getDiagnostics();
   std::unique_ptr OS =
-  GetOutputStream(CI, getCurrentFile(), BA);
+  GetOutputStream(CI, getCurrentFileOrBufferName(), BA);
   if (BA != Backend_EmitNothing && !OS)
 return;
 

diff  --git a/clang/unittests/Frontend/CodeGenActionTest.cpp 
b/clang/unittests/Frontend/CodeGenActionTest.cpp
index 455ec705f884d..f932be639191a 100644
--- a/clang/unittests/Frontend/CodeGenActionTest.cpp
+++ b/clang/unittests/Frontend/CodeGenActionTest.cpp
@@ -59,4 +59,21 @@ TEST(CodeGenTest, TestNullCodeGen) {
   EXPECT_TRUE(Success);
 }
 
+TEST(CodeGenTest, CodeGenFromIRMemBuffer) {
+  auto Invocation = std::make_shared();
+  std::unique_ptr MemBuffer =
+  MemoryBuffer::getMemBuffer("", "test.ll");
+  Invocation->getFrontendOpts().Inputs.push_back(
+  FrontendInputFile(*MemBuffer, Language::LLVM_IR));
+  Invocation->getFrontendOpts().ProgramAction = frontend::EmitLLVMOnly;
+  Invocation->getTargetOpts().Triple = "i386-unknown-linux-gnu";
+  CompilerInstance Compiler;
+  Compiler.setInvocation(std::move(Invocation));
+  Compiler.createDiagnostics();
+  EXPECT_TRUE(Compiler.hasDiagnostics());
+
+  EmitLLVMOnlyAction Action;
+  bool Success = Compiler.ExecuteAction(Action);
+  EXPECT_TRUE(Success);
+}
 }



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


[PATCH] D121259: [clang] Fix CodeGenAction for LLVM IR MemBuffers

2022-03-08 Thread Daniele Castagna via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb3dae59b9dfb: [clang] Fix CodeGenAction for LLVM IR 
MemBuffers (authored by RSenApps, committed by dcastagna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121259

Files:
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/unittests/Frontend/CodeGenActionTest.cpp


Index: clang/unittests/Frontend/CodeGenActionTest.cpp
===
--- clang/unittests/Frontend/CodeGenActionTest.cpp
+++ clang/unittests/Frontend/CodeGenActionTest.cpp
@@ -59,4 +59,21 @@
   EXPECT_TRUE(Success);
 }
 
+TEST(CodeGenTest, CodeGenFromIRMemBuffer) {
+  auto Invocation = std::make_shared();
+  std::unique_ptr MemBuffer =
+  MemoryBuffer::getMemBuffer("", "test.ll");
+  Invocation->getFrontendOpts().Inputs.push_back(
+  FrontendInputFile(*MemBuffer, Language::LLVM_IR));
+  Invocation->getFrontendOpts().ProgramAction = frontend::EmitLLVMOnly;
+  Invocation->getTargetOpts().Triple = "i386-unknown-linux-gnu";
+  CompilerInstance Compiler;
+  Compiler.setInvocation(std::move(Invocation));
+  Compiler.createDiagnostics();
+  EXPECT_TRUE(Compiler.hasDiagnostics());
+
+  EmitLLVMOnlyAction Action;
+  bool Success = Compiler.ExecuteAction(Action);
+  EXPECT_TRUE(Success);
+}
 }
Index: clang/lib/CodeGen/CodeGenAction.cpp
===
--- clang/lib/CodeGen/CodeGenAction.cpp
+++ clang/lib/CodeGen/CodeGenAction.cpp
@@ -1113,7 +1113,7 @@
   auto &CodeGenOpts = CI.getCodeGenOpts();
   auto &Diagnostics = CI.getDiagnostics();
   std::unique_ptr OS =
-  GetOutputStream(CI, getCurrentFile(), BA);
+  GetOutputStream(CI, getCurrentFileOrBufferName(), BA);
   if (BA != Backend_EmitNothing && !OS)
 return;
 


Index: clang/unittests/Frontend/CodeGenActionTest.cpp
===
--- clang/unittests/Frontend/CodeGenActionTest.cpp
+++ clang/unittests/Frontend/CodeGenActionTest.cpp
@@ -59,4 +59,21 @@
   EXPECT_TRUE(Success);
 }
 
+TEST(CodeGenTest, CodeGenFromIRMemBuffer) {
+  auto Invocation = std::make_shared();
+  std::unique_ptr MemBuffer =
+  MemoryBuffer::getMemBuffer("", "test.ll");
+  Invocation->getFrontendOpts().Inputs.push_back(
+  FrontendInputFile(*MemBuffer, Language::LLVM_IR));
+  Invocation->getFrontendOpts().ProgramAction = frontend::EmitLLVMOnly;
+  Invocation->getTargetOpts().Triple = "i386-unknown-linux-gnu";
+  CompilerInstance Compiler;
+  Compiler.setInvocation(std::move(Invocation));
+  Compiler.createDiagnostics();
+  EXPECT_TRUE(Compiler.hasDiagnostics());
+
+  EmitLLVMOnlyAction Action;
+  bool Success = Compiler.ExecuteAction(Action);
+  EXPECT_TRUE(Success);
+}
 }
Index: clang/lib/CodeGen/CodeGenAction.cpp
===
--- clang/lib/CodeGen/CodeGenAction.cpp
+++ clang/lib/CodeGen/CodeGenAction.cpp
@@ -1113,7 +1113,7 @@
   auto &CodeGenOpts = CI.getCodeGenOpts();
   auto &Diagnostics = CI.getDiagnostics();
   std::unique_ptr OS =
-  GetOutputStream(CI, getCurrentFile(), BA);
+  GetOutputStream(CI, getCurrentFileOrBufferName(), BA);
   if (BA != Backend_EmitNothing && !OS)
 return;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121197: [clang][dataflow] Add analysis that detects unsafe accesses to optionals

2022-03-08 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added inline comments.



Comment at: 
clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp:115
+  // optional::has_value
+  .CaseOf(isOptionalMemberCallWithName("has_value"),
+  transferOptionalHasValueCall)

One very important omission seems to be `optional::operator bool`. This is a 
widely used method and I'd love to see it supported.

Also would love to see FIXMEs for some of the most more frequently used 
functions/methods:
* make_optional makes a non-empty optional
* swap (free function and method)
* value_or returning its argument when the optional is known to be empty
* Model the value semantics:  Copy ctor, assignment operator
* Model the move semantics
* Default constructed optional is empty
* Invalidation: passing optional by non-const reference/pointer can invalidate 
its state




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121197

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


[PATCH] D119601: [analyzer] Refactor makeNull to makeNullWithWidth (NFC)

2022-03-08 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h:378
+type = type->isReferenceType()
+   ? Context.getPointerType(type->getPointeeType())
+   : type;

How do you discover the pointer width by looking only at the pointee type? Are 
objects of specific type always restricted to a specific address space? I.e., 
does every `int *` have the same width everywhere in the program? If not, how 
is this code supposed to work?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119601

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


[PATCH] D118311: [Clang][ModuleMap] Add conditional parsing via requires block declaration

2022-03-08 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese added inline comments.



Comment at: clang/lib/Lex/ModuleMap.cpp:2355
+parseModuleMembers();
+  }
+}

bruno wrote:
> Too many curly braces?
This is correct. It closes the block on line 2353.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118311

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


[PATCH] D115907: [misexpect] Re-implement MisExpect Diagnostics

2022-03-08 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added inline comments.
Herald added a project: All.



Comment at: clang/include/clang/Basic/CodeGenOptions.def:172
 CODEGENOPT(NoWarn, 1, 0) ///< Set when -Wa,--no-warn is enabled.
+CODEGENOPT(MisExpect , 1, 0) ///< Set -Wmisexpect is enabled
 CODEGENOPT(EnableSegmentedStacks , 1, 0) ///< Set when -fsplit-stack is 
enabled.

"Set when ..."



Comment at: clang/lib/CodeGen/CodeGenAction.cpp:1203
 
+  if (CodeGenOpts.MisExpect) {
+Ctx.setMisExpectWarningRequested(true);

Out of curiosity, since I am less familiar with clang than llvm, when is this 
path taken vs where this is done at line 336 in HandleTranslationUnit?

Also, it might be nice to have this code placed either consistently before or 
after the OptRecordFile handling in these two locations, so it is easier to 
compare.



Comment at: llvm/docs/MisExpect.rst:2
+===
+Misexpect
+===

I don't see a mention of -Wmisexpect in the document. Should there be 
user-facing clang documentation, this seems more specific to the LLVM 
implementation?



Comment at: llvm/docs/MisExpect.rst:22
+The MisExpect checks in the LLVM backend follow a simple procedure: if the
+profiling counter associated with an instruction using the ``llvm.expect``
+intrinsic was too low along the expected path, then it emits a diagnostic

Suggest using "profile weight" not profiling counter since we don't really have 
profile counters associated with instructions (rather with edges in the MST, at 
least in the IR PGO).

Also, doesn't the profile weight being too low only handle the LIKELY case? 
What about something being marked UNLIKELY with a hot/high profile weight? 
edit: After looking through the implementation, I think the comparison only 
being done in this direction is based on the way it is implemented, but it is 
unclear from this documentation here how the comparison is handling things 
being off in either direction.



Comment at: llvm/docs/MisExpect.rst:27
+The most natural place to perform the verification is just prior to when
+branch weights being assigned to the target instruction in the form of
+branch weight metadata.

grammatical issue "prior to when ... being assigned" - suggest "are assigned".



Comment at: llvm/docs/MisExpect.rst:39
+``-unlikely-branch-weight`` LLVM options. During verification, if the
+profile count is less than the calculated threshold, then we will emit a
+remark or warning detailing a potential performance regression. The

s/count/weight/

Also, similar to my earlier comment, what about an expect UNLIKELY branch with 
a high profile weight?



Comment at: llvm/docs/MisExpect.rst:48
+
+.. option:: -pass-remarks=misexpect
+

As noted in my comment at the top, it would be good to have user-facing clang 
documentation, in which case the clang version of this option is 
-Rpass=misexpect. 



Comment at: llvm/docs/MisExpect.rst:54
+
+.. option:: -pgo-warn-misexpect
+

Looking at the code, the -pgo-warn-misexpect seems to be useful for internal 
LLVM testing via 'opt', to mimic -Wmisexpect, so it probably should be 
documented as such.



Comment at: llvm/include/llvm/Transforms/Utils/MisExpect.h:39
+
+/// checkBackendInstrumentation - compares PGO counters to the thresholds used
+/// for llvm.expect and warns if the PGO counters are outside of the expected

Update function name.



Comment at: llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp:109
 
+  SI.setCondition(ArgValue);
+

Is there a reason why this line has changed ordering w.r.t. setMetadata?



Comment at: llvm/lib/Transforms/Utils/MisExpect.cpp:157
+  const uint64_t UnlikelyBranchWeight = ExpectedWeights[MinId];
+  const uint64_t ProfileCount = RealWeights[Index];
+  const uint64_t CaseTotal =

This is the only use of Index - can you just use MaxId directly? I guess the 
assumption is that the ExpectedWeights array has the same ordering as the 
RealWeights array, so we can check if the corresponding real weight from 
profile is colder than the most likely weight from the expect. Some comments to 
describe how the comparison is being done in this code more intuitively would 
help make it easier to understand.



Comment at: llvm/lib/Transforms/Utils/MisExpect.cpp:166
+
+  const llvm::BranchProbability LikelyThreshold(LikelyBranchWeight,
+TotalBranchWeight);

Why is this called a "Threshold" and not just a "Probability"?



Comment at: llvm/lib/Transforms/Utils/MisExpect.cpp:170
+
+  if (ProfileCount < ScaledThreshold)
+emitMisexpectDiagnostic(I, Ctx, ProfileCount, CaseTotal)

[PATCH] D118352: [clang][ABI] New c++20 modules mangling scheme

2022-03-08 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

We're also seeing this issue on our Mac bots, is it possible to revert it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118352

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


[clang] 845f0bb - Revert "[clang][ABI] New C++20 module mangling scheme"

2022-03-08 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2022-03-09T10:15:15+08:00
New Revision: 845f0bb5fac7479b27e5327c8787ac111e9ad610

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

LOG: Revert "[clang][ABI] New C++20 module mangling scheme"

This reverts commit 21e16ab6b8ddaccb70d2344bb35419e214a32ec9.

It looks like it would break builds in mac. See
https://reviews.llvm.org/D118352.

Added: 


Modified: 
clang/include/clang/AST/Mangle.h
clang/lib/AST/Decl.cpp
clang/lib/AST/ItaniumMangle.cpp
clang/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp
clang/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cppm
clang/test/CXX/modules-ts/basic/basic.def.odr/p4/user.cpp
clang/test/CXX/modules-ts/basic/basic.link/p3.cppm
clang/test/CXX/modules-ts/codegen-basics.cppm

Removed: 
clang/test/CodeGenCXX/Inputs/cxx20-module-impl-1a.cpp
clang/test/CodeGenCXX/Inputs/cxx20-module-std-subst-2a.cpp
clang/test/CodeGenCXX/cxx20-module-decomp-1.cpp
clang/test/CodeGenCXX/cxx20-module-extern-1.cppm
clang/test/CodeGenCXX/cxx20-module-impl-1a.cpp
clang/test/CodeGenCXX/cxx20-module-nested-1.cppm
clang/test/CodeGenCXX/cxx20-module-nested-2.cppm
clang/test/CodeGenCXX/cxx20-module-part-1a.cpp
clang/test/CodeGenCXX/cxx20-module-part-1b.cpp
clang/test/CodeGenCXX/cxx20-module-part-1c.cpp
clang/test/CodeGenCXX/cxx20-module-std-subst-1.cppm
clang/test/CodeGenCXX/cxx20-module-std-subst-2b.cpp
clang/test/CodeGenCXX/cxx20-module-std-subst-2c.cpp
clang/test/CodeGenCXX/cxx20-module-sub-1a.cppm
clang/test/CodeGenCXX/cxx20-module-sub-1b.cppm
clang/test/CodeGenCXX/cxx20-module-tmpl-1.cppm



diff  --git a/clang/include/clang/AST/Mangle.h 
b/clang/include/clang/AST/Mangle.h
index c594c9809fef6..7d02f08e0120c 100644
--- a/clang/include/clang/AST/Mangle.h
+++ b/clang/include/clang/AST/Mangle.h
@@ -194,8 +194,6 @@ class ItaniumMangleContext : public MangleContext {
 
   virtual void mangleDynamicStermFinalizer(const VarDecl *D, raw_ostream &) = 
0;
 
-  virtual void mangleModuleInitializer(const Module *Module, raw_ostream &) = 
0;
-
   // This has to live here, otherwise the CXXNameMangler won't have access to
   // it.
   virtual DiscriminatorOverrideTy getDiscriminatorOverride() const = 0;

diff  --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 9b8d0f6e288e7..82c4412296dbc 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -1540,11 +1540,6 @@ LinkageInfo 
LinkageComputer::getDeclLinkageAndVisibility(const NamedDecl *D) {
 }
 
 Module *Decl::getOwningModuleForLinkage(bool IgnoreLinkage) const {
-  if (isa(this))
-// Namespaces never have module linkage.  It is the entities within them
-// that [may] do.
-return nullptr;
-
   Module *M = getOwningModule();
   if (!M)
 return nullptr;

diff  --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index 1f78142044c8f..d1d7a7c40ceb9 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -130,8 +130,6 @@ class ItaniumMangleContextImpl : public 
ItaniumMangleContext {
 
   void mangleLambdaSig(const CXXRecordDecl *Lambda, raw_ostream &) override;
 
-  void mangleModuleInitializer(const Module *Module, raw_ostream &) override;
-
   bool getNextDiscriminator(const NamedDecl *ND, unsigned &disc) {
 // Lambda closure types are already numbered.
 if (isLambda(ND))
@@ -440,7 +438,6 @@ class CXXNameMangler {
   void mangleType(QualType T);
   void mangleNameOrStandardSubstitution(const NamedDecl *ND);
   void mangleLambdaSig(const CXXRecordDecl *Lambda);
-  void mangleModuleNamePrefix(StringRef Name, bool IsPartition = false);
 
 private:
 
@@ -476,21 +473,22 @@ class CXXNameMangler {
 
   void mangleNameWithAbiTags(GlobalDecl GD,
  const AbiTagList *AdditionalAbiTags);
-  void mangleModuleName(const NamedDecl *ND);
+  void mangleModuleName(const Module *M);
+  void mangleModuleNamePrefix(StringRef Name);
   void mangleTemplateName(const TemplateDecl *TD,
   const TemplateArgument *TemplateArgs,
   unsigned NumTemplateArgs);
-  void mangleUnqualifiedName(GlobalDecl GD, const DeclContext *DC,
+  void mangleUnqualifiedName(GlobalDecl GD,
  const AbiTagList *AdditionalAbiTags) {
-mangleUnqualifiedName(GD, cast(GD.getDecl())->getDeclName(), DC,
-  UnknownArity, AdditionalAbiTags);
+mangleUnqualifiedName(GD, cast(GD.getDecl())->getDeclName(), 
UnknownArity,
+  AdditionalAbiTags);
   }
   void mangleUnqualifiedName(GlobalDecl GD, DeclarationName Name,
- const DeclContext *DC, unsigned KnownArity,
+ unsigned Know

[PATCH] D118352: [clang][ABI] New c++20 modules mangling scheme

2022-03-08 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

In D118352#3368919 , @phosek wrote:

> We're also seeing this issue on our Mac bots, is it possible to revert it?

I've reverted it. Since this is the new feature, I think it wouldn't so hurry 
to land it. BTW, I think it would be helpful to provide more information to fix 
it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118352

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


[PATCH] D120936: [Sema][Windows] Don't special-case void* in __unaligned conversions.

2022-03-08 Thread Eli Friedman via Phabricator via cfe-commits
efriedma updated this revision to Diff 413989.
efriedma added a comment.

Added warning.  This roughly matches the corresponding MSVC warning, as far as 
I can tell.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120936

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/SemaCXX/MicrosoftExtensions.cpp

Index: clang/test/SemaCXX/MicrosoftExtensions.cpp
===
--- clang/test/SemaCXX/MicrosoftExtensions.cpp
+++ clang/test/SemaCXX/MicrosoftExtensions.cpp
@@ -85,18 +85,22 @@
   foo_unaligned(p2);
 
   __unaligned B_unaligned *p3 = 0;
-  int p4 = foo_unaligned(p3);
+  int p4 = foo_unaligned(p3); // expected-error {{cannot initialize a variable of type 'int' with an rvalue of type 'void *'}}
+  // expected-warning@-1 {{implicit cast from type '__unaligned B_unaligned *' to type 'B_unaligned *' drops __unaligned qualifier}}
 
-  B_unaligned *p5 = p3; // expected-error {{cannot initialize a variable of type 'B_unaligned *' with an lvalue of type '__unaligned B_unaligned *'}}
+  B_unaligned *p5 = p3;
+  // expected-warning@-1 {{implicit cast from type '__unaligned B_unaligned *' to type 'B_unaligned *' drops __unaligned qualifier}}
 
   __unaligned B_unaligned *p6 = p3;
 
   p1_aligned_type4 = p2_aligned_type4;
-  p2_aligned_type4 = p1_aligned_type4; // expected-error {{assigning to 'int aligned_type4::*' from incompatible type '__unaligned int aligned_type4::*'}}
+  p2_aligned_type4 = p1_aligned_type4;
+  // expected-warning@-1 {{implicit cast from type '__unaligned int aligned_type4::*' to type 'int aligned_type4::*' drops __unaligned qualifier}}
   p3_aligned_type4 = p1_aligned_type4;
 
   __unaligned int a[10];
-  int *b = a; // expected-error {{cannot initialize a variable of type 'int *' with an lvalue of type '__unaligned int[10]'}}
+  int *b = a;
+  // expected-warning@-1 {{implicit cast from type '__unaligned int[10]' to type 'int *' drops __unaligned qualifier}}
 }
 
 // Test from PR27367
@@ -115,13 +119,18 @@
 // We should accept type conversion of __unaligned to non-__unaligned references
 typedef struct in_addr {
 public:
-  in_addr(in_addr &a) {} // expected-note {{candidate constructor not viable: no known conversion from '__unaligned IN_ADDR *' (aka '__unaligned in_addr *') to 'in_addr &' for 1st argument; dereference the argument with *}}
-  in_addr(in_addr *a) {} // expected-note {{candidate constructor not viable: 1st argument ('__unaligned IN_ADDR *' (aka '__unaligned in_addr *')) would lose __unaligned qualifier}}
+  in_addr(in_addr &a) {} // expected-note {{candidate constructor not viable: expects an lvalue for 1st argument}}
+  in_addr(in_addr *a) {} // expected-note {{candidate constructor not viable: no known conversion from 'IN_ADDR' (aka 'in_addr') to 'in_addr *' for 1st argument}}
 } IN_ADDR;
 
 void f(IN_ADDR __unaligned *a) {
   IN_ADDR local_addr = *a;
-  IN_ADDR local_addr2 = a; // expected-error {{no viable conversion from '__unaligned IN_ADDR *' (aka '__unaligned in_addr *') to 'IN_ADDR' (aka 'in_addr')}}
+  // FIXME: MSVC accepts the following; not sure why clang tries to
+  // copy-construct an in_addr.
+  IN_ADDR local_addr2 = a; // expected-error {{no viable constructor copying variable of type 'IN_ADDR' (aka 'in_addr')}}
+  // expected-warning@-1 {{implicit cast from type '__unaligned IN_ADDR *' (aka '__unaligned in_addr *') to type 'in_addr *' drops __unaligned qualifier}}
+  IN_ADDR local_addr3(a);
+  // expected-warning@-1 {{implicit cast from type '__unaligned IN_ADDR *' (aka '__unaligned in_addr *') to type 'in_addr *' drops __unaligned qualifier}}
 }
 
 template void h1(T (__stdcall M::* const )()) { }
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -3195,9 +3195,8 @@
   Qualifiers FromQuals = FromType.getQualifiers();
   Qualifiers ToQuals = ToType.getQualifiers();
 
-  // Ignore __unaligned qualifier if this type is void.
-  if (ToType.getUnqualifiedType()->isVoidType())
-FromQuals.removeUnaligned();
+  // Ignore __unaligned qualifier.
+  FromQuals.removeUnaligned();
 
   // Objective-C ARC:
   //   Check Objective-C lifetime conversions.
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -4641,6 +4641,13 @@
 From->getType()->getPointeeType().getAddressSpace())
   CK = CK_AddressSpaceConversion;
 
+if (!isCast(CCK) &&
+!ToType->getPointeeType().getQualifiers().hasUnaligned() &&
+From->getType()->getPointeeType().getQualifiers().hasUnaligned()) {
+  Diag(From->getBeginLoc(), diag::warn_imp_cast_drops_unaligned)
+  << InitialFromTy

[PATCH] D121177: [modules] Merge equivalent extensions and diagnose ivar redeclarations for extensions loaded from different modules.

2022-03-08 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

I don't know about ObjC.  Comments on style/name only.




Comment at: clang/include/clang/Serialization/ASTReader.h:1110
+  template 
+  using DuplicateDecls = std::pair;
+

How about change the name to:
```
  template 
  using DuplicateObjDecls = std::pair;
```

to clarify it is only used for ObjC. So the developer of other languages would 
skip this when reading.



Comment at: clang/include/clang/Serialization/ASTReader.h:1112-1115
+  /// When resolving duplicate ivars from extensions we don't error out
+  /// immediately but check if can merge identical extensions. Not checking
+  /// extensions for equality immediately because ivar deserialization isn't
+  /// over yet at that point.

Similarly, I suggest to add words or change the name to clarify it is used in 
ObjC only.



Comment at: clang/include/clang/Serialization/ASTReader.h:1117
+  llvm::MapVector,
+  llvm::SmallVector, 4>>
+  PendingExtensionIvarRedeclarations;

It looks a little bit odd for me to use `Vector` for duplicate vars. 
Especially, the structure is `Vector>`. I feel it is better with 
`llvm::SmallSet`. If the order is important here, I think 
`llvm::SmallSetVector` might be an option.



Comment at: clang/lib/Serialization/ASTReaderDecl.cpp:1249-1251
+if (auto *ParentExt = dyn_cast(IVD->getDeclContext())) {
+  if (auto *PrevParentExt =
+  dyn_cast(PrevIvar->getDeclContext())) {

nit:
```
auto *ParentExt = dyn_cast(IVD->getDeclContext());
auto *PrevParentExt = dyn_cast(PrevIvar->getDeclContext());
if (ParentExt && PrevParentExt) {

}
```

We could reduce one identation in this way. Codes with less identation looks 
better.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121177

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


[PATCH] D120936: [Sema][Windows] Don't special-case void* in __unaligned conversions.

2022-03-08 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

In D120936#3368566 , @rnk wrote:

> I wasn't able to find any history for why `void*` was special here.

As far as I can tell, nobody ever thought `void*` was special.  The check was 
an attempt to restrict dubious conversions while still remaining compatible 
with existing code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120936

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


[PATCH] D119479: [clang][extract-api] Add global record support

2022-03-08 Thread Zixu Wang via Phabricator via cfe-commits
zixuw updated this revision to Diff 413992.
zixuw added a comment.

Plug clangSymbolGraph into clangFrontendTools


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119479

Files:
  clang/include/clang/AST/RawCommentList.h
  clang/include/clang/Frontend/FrontendActions.h
  clang/include/clang/SymbolGraph/API.h
  clang/include/clang/SymbolGraph/AvailabilityInfo.h
  clang/include/clang/SymbolGraph/DeclarationFragments.h
  clang/include/clang/SymbolGraph/FrontendActions.h
  clang/include/clang/SymbolGraph/Serialization.h
  clang/lib/AST/RawCommentList.cpp
  clang/lib/CMakeLists.txt
  clang/lib/Frontend/CMakeLists.txt
  clang/lib/Frontend/ExtractAPIConsumer.cpp
  clang/lib/FrontendTool/CMakeLists.txt
  clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  clang/lib/SymbolGraph/API.cpp
  clang/lib/SymbolGraph/CMakeLists.txt
  clang/lib/SymbolGraph/DeclarationFragments.cpp
  clang/lib/SymbolGraph/ExtractAPIConsumer.cpp
  clang/lib/SymbolGraph/Serialization.cpp
  clang/test/Driver/extract-api.c
  clang/test/SymbolGraph/global_record.c

Index: clang/test/SymbolGraph/global_record.c
===
--- /dev/null
+++ clang/test/SymbolGraph/global_record.c
@@ -0,0 +1,363 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s@INPUT_DIR@%/t@g" %t/reference.output.json.in >> \
+// RUN: %t/reference.output.json
+// RUN: %clang -extract-api -target arm64-apple-macosx \
+// RUN: %t/input.c -o %t/output.json | FileCheck -allow-empty %s
+// RUN: diff %t/reference.output.json %t/output.json
+
+// CHECK-NOT: error:
+// CHECK-NOT: warning:
+
+//--- input.c
+int num;
+
+/**
+ * \brief Add two numbers.
+ * \param [in]  x   A number.
+ * \param [in]  y   Another number.
+ * \param [out] res The result of x + y.
+ */
+void add(const int x, const int y, int *res);
+
+//--- reference.output.json.in
+{
+  "metadata": {
+"formatVersion": {
+  "major": 0,
+  "minor": 5,
+  "patch": 3
+},
+"generator": "clang"
+  },
+  "module": {
+"name": "",
+"platform": {
+  "architecture": "arm64",
+  "operatingSystem": {
+"minimumVersion": {
+  "major": 11,
+  "minor": 0,
+  "patch": 0
+},
+"name": "macosx"
+  },
+  "vendor": "apple"
+}
+  },
+  "relationhips": [],
+  "symbols": [
+{
+  "declaration": [
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:I",
+  "spelling": "int"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "num"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "c",
+"precise": "c:@num"
+  },
+  "kind": {
+"displayName": "Variable",
+"identifier": "c.variable"
+  },
+  "location": {
+"character": 5,
+"line": 1,
+"uri": "file://INPUT_DIR/input.c"
+  },
+  "names": {
+"subHeading": [
+  {
+"kind": "identifier",
+"spelling": "num"
+  }
+],
+"title": "num"
+  }
+},
+{
+  "declaration": [
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:v",
+  "spelling": "void"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "add"
+},
+{
+  "kind": "text",
+  "spelling": "("
+},
+{
+  "kind": "keyword",
+  "spelling": "const"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:I",
+  "spelling": "int"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "internalParam",
+  "spelling": "x"
+},
+{
+  "kind": "text",
+  "spelling": ", "
+},
+{
+  "kind": "keyword",
+  "spelling": "const"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:I",
+  "spelling": "int"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "internalParam",
+  "spelling": "y"
+},
+{
+  "kind": "text",
+  "spelling": ", "
+},
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:I",
+  "spelling": "int"
+},
+{
+  "kind": "text",
+  "spelling": " *"
+},
+{
+  "kind": "internalParam",
+  "spelling": "res"
+

[PATCH] D121269: [clang-format] Fix namepsace format when the name is after by a macro

2022-03-08 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu created this revision.
zequanwu added reviewers: thakis, MyDeveloperDay, owenpan, klimek, sammccall.
Herald added a project: All.
zequanwu requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Example:

  $ cat a.cpp
  namespace my_namespace::yeah API_AVAILABLE(macos(10.15)) {
  void test() {}
  }
  
  $ clang-format a.cpp
  namespace my_namespace::yeah API_AVAILABLE(macos(10.15)) {
  void test() {}
  }// namespace my_namespace::yeahAPI_AVAILABLE(macos(10.15))

After:

  $ clang-format a.cpp
  namespace my_namespace::yeah API_AVAILABLE(macos(10.15)) {
  void test() {}
  }// namespace my_namespace::yeah


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121269

Files:
  clang/lib/Format/NamespaceEndCommentsFixer.cpp
  clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp

Index: clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp
===
--- clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp
+++ clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp
@@ -189,6 +189,26 @@
 "int i;\n"
 "int j;\n"
 "}"));
+  EXPECT_EQ("#define M(x) x##x\n"
+"namespace A M(x) {\n"
+"int i;\n"
+"int j;\n"
+"}// namespace A M(x)",
+fixNamespaceEndComments("#define M(x) x##x\n"
+"namespace A M(x) {\n"
+"int i;\n"
+"int j;\n"
+"}"));
+  EXPECT_EQ("#define M(x) x##x\n"
+"namespace A::B M(x) {\n"
+"int i;\n"
+"int j;\n"
+"}// namespace A::B",
+fixNamespaceEndComments("#define M(x) x##x\n"
+"namespace A::B M(x) {\n"
+"int i;\n"
+"int j;\n"
+"}"));
   EXPECT_EQ("inline namespace A {\n"
 "int i;\n"
 "int j;\n"
Index: clang/lib/Format/NamespaceEndCommentsFixer.cpp
===
--- clang/lib/Format/NamespaceEndCommentsFixer.cpp
+++ clang/lib/Format/NamespaceEndCommentsFixer.cpp
@@ -55,30 +55,72 @@
 Tok = Tok->getNextNonComment();
 }
 
-// Use the string after `namespace` as a name candidate until `{` or `::` or
-// `(`. If the name is empty, use the candicate.
 std::string FirstNSName;
 // For `namespace [[foo]] A::B::inline C {` or
 // `namespace MACRO1 MACRO2 A::B::inline C {`, returns "A::B::inline C".
 // Peek for the first '::' (or '{' or '(')) and then return all tokens from
 // one token before that up until the '{'. A '(' might be a macro with
 // arguments.
-const FormatToken *FirstNSTok = Tok;
+const FormatToken *FirstNSTok = nullptr;
 while (Tok && !Tok->isOneOf(tok::l_brace, tok::coloncolon, tok::l_paren)) {
-  FirstNSName += FirstNSTok->TokenText;
+  if (FirstNSTok)
+FirstNSName += FirstNSTok->TokenText;
   FirstNSTok = Tok;
   Tok = Tok->getNextNonComment();
 }
 
-Tok = FirstNSTok;
-while (Tok && !Tok->is(tok::l_brace)) {
+bool IsPrevColoncolon = false;
+bool HasColoncolon = false;
+bool IsPrevInline = false;
+bool NameFinished = false;
+if (FirstNSTok)
+  Tok = FirstNSTok;
+FirstNSTok = nullptr;
+// Add everything from '(' to ')'.
+auto AddMacro = [&name](const FormatToken *Tok) {
+  if (!Tok->is(tok::l_paren))
+return Tok;
   name += Tok->TokenText;
-  if (Tok->is(tok::kw_inline))
-name += " ";
+  Tok = Tok->getNextNonComment();
+  for (int NestLevel = 1; Tok && NestLevel > 0;) {
+if (Tok->is(tok::l_paren))
+  ++NestLevel;
+else if (Tok->is(tok::r_paren))
+  --NestLevel;
+name += Tok->TokenText;
+Tok = Tok->getNextNonComment();
+  }
+  return Tok;
+};
+// If we found '::' in name, then it's the name. Otherwise, we can't tell
+// which one is name. For example, `namespace A B {`.
+while (Tok && !Tok->is(tok::l_brace)) {
+  if (FirstNSTok) {
+if (!IsPrevInline && HasColoncolon && !IsPrevColoncolon) {
+  if (FirstNSTok->is(tok::l_paren)) {
+FirstNSTok = Tok = AddMacro(FirstNSTok);
+continue;
+  }
+  if (!FirstNSTok->is(tok::coloncolon)) {
+NameFinished = true;
+break;
+  }
+}
+name += FirstNSTok->TokenText;
+IsPrevColoncolon = FirstNSTok->is(tok::coloncolon);
+HasColoncolon |= IsPrevColoncolon;
+if (FirstNSTok->is(tok::kw_inline)) {
+  name += " ";
+  IsPrevInline = true;
+}
+  }
+  FirstNSTok = Tok;
   Tok = Tok->getNextNonComment();
 }
-if (name

[PATCH] D121096: [C++20][Modules][HU 2/5] Support searching Header Units in user or system search paths.

2022-03-08 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added inline comments.



Comment at: clang/include/clang/Frontend/FrontendOptions.h:157
+  unsigned HeaderUnit : 3;
+  unsigned Header : 1;
 

I prefer `IsHeader`



Comment at: clang/include/clang/Frontend/FrontendOptions.h:252
+  bool isHeader() const { return Kind.isHeader(); }
+  InputKind::HeaderUnitKind getHeaderUnit() const {
+return Kind.getHeaderUnit();

How about `getHeaderUnitKind` ?



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:2788-2791
+  HUK =
+  XValue.consume_back("-header-unit") ? InputKind::HeaderUnit_Abs : 
HUK;
+  HUK = XValue.consume_back("-system") ? InputKind::HeaderUnit_System : 
HUK;
+  HUK = XValue.consume_back("-user") ? InputKind::HeaderUnit_User : HUK;

How do you think about the suggested changes? I feel it is less confusing.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:2796-2797
+// not intended to be a module map or header unit.
+IsHeaderFile = IsHeader && !Preprocessed && !ModuleMap &&
+   HUK == InputKind::HeaderUnit_None;
 

Oh, now I find `Header` and `HeaderUnit` might be a little bit confusing. It 
looks like `Header` should include `HeaderUnit` at the first sight. It is not 
true. But I don't have only suggestions...



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:2838-2839
   DashX = DashX.getPreprocessed();
+// A regular header is considered mutually exclusive with a header unit
+// one
+if (HUK != InputKind::HeaderUnit_None) {





Comment at: clang/lib/Frontend/CompilerInvocation.cpp:2855-2857
+  assert((DashX.getHeaderUnit() == InputKind::HeaderUnit_None ||
+  Inputs.size() == 1) &&
+ "Expected only one input file for header unit");

So the compiler would crash if there is multiple inputs for header unit? I feel 
it is not most friendly. How about emitting an error here?



Comment at: clang/lib/Frontend/FrontendAction.cpp:814-816
+  const DirectoryEntry *Dir = nullptr;
+  if (auto DirOrErr = CI.getFileManager().getDirectory("."))
+Dir = *DirOrErr;

Is it same as the suggested?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121096

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


[PATCH] D121096: [C++20][Modules][HU 2/5] Support searching Header Units in user or system search paths.

2022-03-08 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

BTW, all the tests uses ``clang_cc1`. How should the users do with `clang`? 
Could them use `-Xclang` only?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121096

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


[PATCH] D120296: [Attr] Fix a btf_type_tag AST generation bug

2022-03-08 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song updated this revision to Diff 413995.
yonghong-song added a comment.

- add a pch test to test serialization with btf_type_tag.
- simplify the code


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120296

Files:
  clang/include/clang-c/Index.h
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/ASTNodeTraverser.h
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeLoc.h
  clang/include/clang/AST/TypeProperties.td
  clang/include/clang/Basic/TypeNodes.td
  clang/include/clang/Serialization/ASTRecordWriter.h
  clang/include/clang/Serialization/TypeBitCodes.def
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CodeGen/attr-btf_type_tag-similar-type.c
  clang/test/PCH/btf_type_tag_attr.c
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXType.cpp

Index: clang/tools/libclang/CXType.cpp
===
--- clang/tools/libclang/CXType.cpp
+++ clang/tools/libclang/CXType.cpp
@@ -116,6 +116,7 @@
 TKCASE(Elaborated);
 TKCASE(Pipe);
 TKCASE(Attributed);
+TKCASE(BTFTagAttributed);
 TKCASE(Atomic);
 default:
   return CXType_Unexposed;
@@ -136,6 +137,10 @@
 return MakeCXType(ATT->getEquivalentType(), TU);
   }
 }
+if (auto *ATT = T->getAs()) {
+  if (!(TU->ParsingOptions & CXTranslationUnit_IncludeAttributedTypes))
+return MakeCXType(ATT->getWrappedType(), TU);
+}
 // Handle paren types as the original type
 if (auto *PTT = T->getAs()) {
   return MakeCXType(PTT->getInnerType(), TU);
@@ -610,6 +615,7 @@
 TKIND(Elaborated);
 TKIND(Pipe);
 TKIND(Attributed);
+TKIND(BTFTagAttributed);
 TKIND(BFloat16);
 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) TKIND(Id);
 #include "clang/Basic/OpenCLImageTypes.def"
@@ -1051,6 +1057,9 @@
   if (auto *ATT = T->getAs())
 return MakeCXType(ATT->getModifiedType(), GetTU(CT));
 
+  if (auto *ATT = T->getAs())
+return MakeCXType(ATT->getWrappedType(), GetTU(CT));
+
   return MakeCXType(QualType(), GetTU(CT));
 }
 
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1672,6 +1672,10 @@
   return Visit(TL.getModifiedLoc());
 }
 
+bool CursorVisitor::VisitBTFTagAttributedTypeLoc(BTFTagAttributedTypeLoc TL) {
+  return Visit(TL.getWrappedLoc());
+}
+
 bool CursorVisitor::VisitFunctionTypeLoc(FunctionTypeLoc TL,
  bool SkipResultType) {
   if (!SkipResultType && Visit(TL.getReturnLoc()))
Index: clang/test/PCH/btf_type_tag_attr.c
===
--- /dev/null
+++ clang/test/PCH/btf_type_tag_attr.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -include-pch %t \
+// RUN:   -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+
+int __attribute__((btf_type_tag("tag1"))) __attribute__((btf_type_tag("tag2"))) *p;
Index: clang/test/CodeGen/attr-btf_type_tag-similar-type.c
===
--- /dev/null
+++ clang/test/CodeGen/attr-btf_type_tag-similar-type.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple %itanium_abi_triple -debug-info-kind=limited -S -emit-llvm -o - %s | FileCheck %s
+
+struct map_value {
+int __attribute__((btf_type_tag("tag1"))) __attribute__((btf_type_tag("tag3"))) *a;
+int __attribute__((btf_type_tag("tag2"))) __attribute__((btf_type_tag("tag4"))) *b;
+};
+
+struct map_value *func(void);
+
+int test(struct map_value *arg)
+{
+return *arg->a;
+}
+
+// CHECK: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "map_value", file: ![[#]], line: [[#]], size: [[#]], elements: ![[L14:[0-9]+]]
+// CHECK: ![[L14]] = !{![[L15:[0-9]+]], ![[L20:[0-9]+]]}
+// CHECK: ![[L15]] = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: ![[#]], file: ![[#]], line: [[#]], baseType: ![[L16:[0-9]+]]
+// CHECK: ![[L16]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[#]], size: [[#]], annotations: ![[L17:[0-9]+]]
+// CHECK: ![[L17]] = !{![[L18:[0-9]+]], ![[L19:[0-9]+]]}
+// CHECK: ![[L18]] = !{!"btf_type_tag", !"tag1"}
+// CHECK: ![[L19]] = !{!"btf_type_tag", !"tag3"}
+// CHECK: ![[L20]] = !DIDerivedType(tag: DW_TAG_member, 

[PATCH] D121176: [ASTStructuralEquivalence] Add support for comparing ObjCCategoryDecl.

2022-03-08 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added inline comments.



Comment at: clang/lib/AST/ASTStructuralEquivalence.cpp:1240
- FieldDecl *Field1, FieldDecl *Field2) {
-  const auto *Owner2 = cast(Field2->getDeclContext());
 

By the way, the alternative to introducing parameter `Owner2Type` was to use 
`...Owner2 = cast(...)`. But that would work only for 
ObjCInterfaceDecl and would require making ObjCInterfaceDecl TypeDecl. 
Conceptually, it makes sense for ObjCInterfaceDecl to be TypeDecl as 
`@interface` does represent a type. But I've decided that such invasive change 
is not justified.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121176

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


[PATCH] D119609: [Clang][Sema] Prohibit expression statement in lambda default argument

2022-03-08 Thread Jun Zhang via Phabricator via cfe-commits
junaire updated this revision to Diff 413997.
junaire added a comment.

- Make sure Parser can diagnostic remaining error after the expr statement.
- Prohibit expression statement in template argument
- Add more tests
- Better diagnostic message


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119609

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseTemplate.cpp
  clang/test/Sema/err-expr-stmt-in-default-arg.cpp
  clang/test/SemaTemplate/dependent-expr.cpp

Index: clang/test/SemaTemplate/dependent-expr.cpp
===
--- clang/test/SemaTemplate/dependent-expr.cpp
+++ clang/test/SemaTemplate/dependent-expr.cpp
@@ -141,15 +141,7 @@
   using U = float; // expected-error {{different types ('float' vs 'decltype(g())' (aka 'void'))}}
 
   void h(auto a, decltype(g())*) {} // expected-note {{previous}}
-  void h(auto a, void*) {} // expected-error {{redefinition}}
-
-  void i(auto a) {
-[](auto a, int = ({decltype(a) i; i * 2;})){}(a); // expected-error {{invalid operands to binary expression ('decltype(a)' (aka 'void *') and 'int')}} expected-note {{in instantiation of}}
-  }
-  void use_i() {
-i(0);
-i((void*)0); // expected-note {{instantiation of}}
-  }
+  void h(auto a, void *) {} // expected-error {{redefinition}}
 }
 
 namespace BindingInStmtExpr {
Index: clang/test/Sema/err-expr-stmt-in-default-arg.cpp
===
--- /dev/null
+++ clang/test/Sema/err-expr-stmt-in-default-arg.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -std=c++20
+
+void foo() {
+  void fn(int i, int = ({ 1; })); // expected-error {{expression statement not permitted in default argument}}
+
+  auto a = [](int = ({ 1; })) {}; // expected-error {{expression statement not permitted in default argument}}
+
+  auto b = [](){}; // expected-error {{expression statement not permitted in default argument}}
+
+  void fn(int i, int j = ({{}, {}, {,}}), int k = ""); // expected-error {{expression statement not permitted in default argument}} expected-error {{cannot initialize a parameter of type 'int' with an lvalue of type 'const char[1]'}} expected-note {{passing argument to parameter 'k' here}}
+}
+
+template 
+int bar(Callable &&Call) {
+  return Call();
+}
+
+int baz() {
+  auto l = [](int a = ({ int x = 12; x; })) { // expected-error {{expression statement not permitted in default argument}}
+return 1;
+  };
+  return bar(l);
+}
Index: clang/lib/Parse/ParseTemplate.cpp
===
--- clang/lib/Parse/ParseTemplate.cpp
+++ clang/lib/Parse/ParseTemplate.cpp
@@ -19,6 +19,7 @@
 #include "clang/Sema/DeclSpec.h"
 #include "clang/Sema/ParsedTemplate.h"
 #include "clang/Sema/Scope.h"
+#include "clang/Sema/SemaDiagnostic.h"
 #include "llvm/Support/TimeProfiler.h"
 using namespace clang;
 
@@ -1007,18 +1008,23 @@
   SourceLocation EqualLoc;
   ExprResult DefaultArg;
   if (TryConsumeToken(tok::equal, EqualLoc)) {
-// C++ [temp.param]p15:
-//   When parsing a default template-argument for a non-type
-//   template-parameter, the first non-nested > is taken as the
-//   end of the template-parameter-list rather than a greater-than
-//   operator.
-GreaterThanIsOperatorScope G(GreaterThanIsOperator, false);
-EnterExpressionEvaluationContext ConstantEvaluated(
-Actions, Sema::ExpressionEvaluationContext::ConstantEvaluated);
-
-DefaultArg = Actions.CorrectDelayedTyposInExpr(ParseAssignmentExpression());
-if (DefaultArg.isInvalid())
+if (Tok.is(tok::l_paren) && NextToken().is(tok::l_brace)) {
+  Diag(Tok.getLocation(), diag::err_expr_statement_in_default_arg);
   SkipUntil(tok::comma, tok::greater, StopAtSemi | StopBeforeMatch);
+} else {
+  // C++ [temp.param]p15:
+  //   When parsing a default template-argument for a non-type
+  //   template-parameter, the first non-nested > is taken as the
+  //   end of the template-parameter-list rather than a greater-than
+  //   operator.
+  GreaterThanIsOperatorScope G(GreaterThanIsOperator, false);
+  EnterExpressionEvaluationContext ConstantEvaluated(
+  Actions, Sema::ExpressionEvaluationContext::ConstantEvaluated);
+  DefaultArg =
+  Actions.CorrectDelayedTyposInExpr(ParseAssignmentExpression());
+  if (DefaultArg.isInvalid())
+SkipUntil(tok::comma, tok::greater, StopAtSemi | StopBeforeMatch);
+}
   }
 
   // Create the parameter.
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -7085,8 +7085,16 @@
   if (getLangOpts().CPlusPlus11 && Tok.is(tok::l_brace)) {
 Diag(Tok, diag::warn_cxx98_compat_general

[PATCH] D119609: [Clang][Sema] Prohibit expression statement in lambda default argument

2022-03-08 Thread Jun Zhang via Phabricator via cfe-commits
junaire added a comment.

I just realized that something is not very clear here. Should we prohibit 
expression statements in all default arguments or just in lambda and templates? 
I wonder how gcc folks think about it as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119609

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


[PATCH] D120244: [clang][sema] Enable first-class bool support for C2x

2022-03-08 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder marked 3 inline comments as done.
tbaeder added a comment.

In D120244#3368216 , @aaron.ballman 
wrote:

> Precommit CI is failing:
>
> Failed Tests (1):
>
>   Clang :: Headers/stdbool.c

Heh, I guess I need to make a habit of running the tests also //after// 
clang-format :/




Comment at: clang/test/Headers/stdbool.c:2
+// RUN: %clang_cc1 -fgnuc-version=4.2.1 -std=c11 -E -dM %s 2>&1 | FileCheck 
--check-prefix=CHECK-C11 %s
+// RUN: %clang_cc1 -fgnuc-version=4.2.1 -std=c2x -E -dM %s 2>&1 | FileCheck 
--check-prefix=CHECK-C2X %s
+

aaron.ballman wrote:
> If you're playing along at home, `stdbool.cpp` tests the C++ behavior, so we 
> don't need an additional RUN line here for that.
> 
> However, I'd appreciate a RUN line that defines 
> `_CLANG_DISABLE_CRT_DEPRECATION_WARNINGS` to demonstrate we don't emit the 
> warning or the defines in that case.
I don't understand, both of the `RUN` lines are for C.


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

https://reviews.llvm.org/D120244

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


[PATCH] D120244: [clang][sema] Enable first-class bool support for C2x

2022-03-08 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 414005.

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

https://reviews.llvm.org/D120244

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Headers/stdbool.h
  clang/test/Headers/stdbool.c
  clang/test/Sema/c2x-bool.c

Index: clang/test/Sema/c2x-bool.c
===
--- /dev/null
+++ clang/test/Sema/c2x-bool.c
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -std=c2x -fsyntax-only -verify %s
+
+_Static_assert(_Generic(true, _Bool : 1, default: 0));
+_Static_assert(_Generic(false, _Bool : 1, default: 0));
+
+_Static_assert(_Generic(true, bool : 1, default: 0));
+_Static_assert(_Generic(false, bool : 1, default: 0));
+
+_Static_assert(_Generic(true, bool : true, default: false));
+_Static_assert(_Generic(false, bool : true, default: false));
+
+_Static_assert(true == (bool)+1);
+_Static_assert(false == (bool)+0);
+
+_Static_assert(_Generic(+true, bool : 0, unsigned int : 0, signed int : 1, default : 0));
+
+struct S {
+  bool b : 1;
+} s;
+_Static_assert(_Generic(+s.b, bool : 0, unsigned int : 0, signed int : 1, default : 0));
+
+static void *f = false; // expected-warning {{to null from a constant boolean expression}}
+static int one = true;
+static int zero = false;
+
+static void do_work() {
+  char *str = "Foo";
+  str[false] = 'f';
+  str[true] = 'f';
+
+  char c1[true];
+  char c2[false];
+}
+
+#if true != 1
+#error true should be 1 in the preprocessor
+#endif
+
+#if false != 0
+#error false should be 0 in the preprocessor
+#endif
Index: clang/test/Headers/stdbool.c
===
--- /dev/null
+++ clang/test/Headers/stdbool.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fgnuc-version=4.2.1 -std=c11 -E -dM %s 2>&1 | FileCheck --check-prefix=CHECK-C11 %s
+// RUN: %clang_cc1 -fgnuc-version=4.2.1 -std=c2x -E -dM %s 2>&1 | FileCheck --check-prefix=CHECK-C2X %s
+// RUN: %clang_cc1 -fgnuc-version=4.2.1 -std=c2x -E -dM -D_CLANG_DISABLE_CRT_DEPRECATION_WARNINGS %s 2>&1 | FileCheck --check-prefix=CHECK-C2X-CRT %s
+
+#include 
+
+// CHECK-C11: #define bool _Bool
+// CHECK-C11: #define false 0
+// CHECK-C11: #define true 1
+
+// CHECK-C2X: warning "the  header is deprecated
+// CHECK-C2X-NOT: #define bool
+// CHECK-C2X-NOT: #define true
+// CHECK-C2X-NOT: #define falsea
+
+// CHECK-C2X-CRT-NOT: warning "the  header is deprecated
+// CHECK-C2X-CRT-NOT: #define bool
+// CHECK-C2X-CRT-NOT: #define true
+// CHECK-C2X-CRT-NOT: #define false
Index: clang/lib/Headers/stdbool.h
===
--- clang/lib/Headers/stdbool.h
+++ clang/lib/Headers/stdbool.h
@@ -10,8 +10,13 @@
 #ifndef __STDBOOL_H
 #define __STDBOOL_H
 
-/* Don't define bool, true, and false in C++, except as a GNU extension. */
-#ifndef __cplusplus
+#define __bool_true_false_are_defined 1
+
+#if __STDC_VERSION__ > 201710L
+#if !defined(_CLANG_DISABLE_CRT_DEPRECATION_WARNINGS)
+#warning "the  header is deprecated in C2x"
+#endif /* !defined(_CLANG_DISABLE_CRT_DEPRECATION_WARNINGS) */
+#elif !defined(__cplusplus)
 #define bool _Bool
 #define true 1
 #define false 0
@@ -20,12 +25,10 @@
 #define _Bool bool
 #if __cplusplus < 201103L
 /* For C++98, define bool, false, true as a GNU extension. */
-#define bool  bool
+#define bool bool
 #define false false
-#define true  true
+#define true true
 #endif
 #endif
 
-#define __bool_true_false_are_defined 1
-
 #endif /* __STDBOOL_H */
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3249,8 +3249,8 @@
 
   Opts.RenderScript = IK.getLanguage() == Language::RenderScript;
 
-  // OpenCL and C++ both have bool, true, false keywords.
-  Opts.Bool = Opts.OpenCL || Opts.CPlusPlus;
+  // OpenCL, C++ and C2x have bool, true, false keywords.
+  Opts.Bool = Opts.OpenCL || Opts.CPlusPlus || Opts.C2x;
 
   // OpenCL has half keyword
   Opts.Half = Opts.OpenCL;
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -110,6 +110,7 @@
 ---
 
 - Implemented `WG14 N2674 The noreturn attribute `_.
+- Implemented `WG14 N2935 Make false and true first-class language features `_.
 
 C++ Language Changes in Clang
 -
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D118511: Add a warning for not packing non-POD members in packed structs

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

Hey @dblaikie, seems like this has never been pushed?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118511

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


[clang-tools-extra] 81f8df0 - [clangd] Make dexp command line options sticky

2022-03-08 Thread Yevgeny Rouban via cfe-commits

Author: Yevgeny Rouban
Date: 2022-03-09T12:59:49+07:00
New Revision: 81f8df0c83c6a4476f5bffa6947c0e78a94138a7

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

LOG: [clangd] Make dexp command line options sticky

Preparing for the cl::opt reset fix proposed on D115433 this
patch fixes the dexp tool to preserve its three command line
options (IndexLocation, ExecCommand, ProjectRoot) from reset
that is done before parsing query options.

Tags: #clang

Added: 


Modified: 
clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp 
b/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
index 2615d06bbd2b5..c6cefdf675ef5 100644
--- a/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
+++ b/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
@@ -413,6 +413,13 @@ int main(int argc, const char *argv[]) {
   using namespace clang::clangd;
 
   llvm::cl::ParseCommandLineOptions(argc, argv, Overview);
+
+  // Preserve global options when flag parser is reset, so commands can use
+  // them.
+  IndexLocation.setValue(IndexLocation, /*initial=*/ true);
+  ExecCommand.setValue(ExecCommand, /*initial=*/ true);
+  ProjectRoot.setValue(ProjectRoot, /*initial=*/ true);
+
   llvm::cl::ResetCommandLineParser(); // We reuse it for REPL commands.
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
 



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


[clang-tools-extra] c8a3572 - [clangd] Make dexp command line options sticky

2022-03-08 Thread Yevgeny Rouban via cfe-commits

Author: Yevgeny Rouban
Date: 2022-03-09T13:00:25+07:00
New Revision: c8a35727fe7cdb06bf2a081356c36a5159598e9f

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

LOG: [clangd] Make dexp command line options sticky

Preparing for the cl::opt reset fix proposed on D115433 this
patch fixes the dexp tool to preserve its three command line
options (IndexLocation, ExecCommand, ProjectRoot) from reset
that is done before parsing query options.

Tags: #clang

Added: 


Modified: 
clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp 
b/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
index c6cefdf675ef5..7bbcba3398335 100644
--- a/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
+++ b/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
@@ -416,9 +416,9 @@ int main(int argc, const char *argv[]) {
 
   // Preserve global options when flag parser is reset, so commands can use
   // them.
-  IndexLocation.setValue(IndexLocation, /*initial=*/ true);
-  ExecCommand.setValue(ExecCommand, /*initial=*/ true);
-  ProjectRoot.setValue(ProjectRoot, /*initial=*/ true);
+  IndexLocation.setValue(IndexLocation, /*initial=*/true);
+  ExecCommand.setValue(ExecCommand, /*initial=*/true);
+  ProjectRoot.setValue(ProjectRoot, /*initial=*/true);
 
   llvm::cl::ResetCommandLineParser(); // We reuse it for REPL commands.
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);



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


[PATCH] D120713: [clangd] Make dexp command line options sticky

2022-03-08 Thread Yevgeny Rouban via Phabricator via cfe-commits
yrouban closed this revision.
yrouban added a comment.

Closed by commit 
https://reviews.llvm.org/rG7fb39fb6d6665cd469557b43eb205cc32b0a7ac3.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120713

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


[PATCH] D121269: [clang-format] Fix namepsace format when the name is after by a macro

2022-03-08 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay requested changes to this revision.
MyDeveloperDay added inline comments.
This revision now requires changes to proceed.



Comment at: clang/lib/Format/NamespaceEndCommentsFixer.cpp:104
+  }
+  if (!FirstNSTok->is(tok::coloncolon)) {
+NameFinished = true;

Elide braces 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121269

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


[PATCH] D121269: [clang-format] Fix namepsace format when the name is after by a macro

2022-03-08 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Format/NamespaceEndCommentsFixer.cpp:104
+  }
+  if (!FirstNSTok->is(tok::coloncolon)) {
+NameFinished = true;

MyDeveloperDay wrote:
> Elide braces 
Ok ignore that



Comment at: clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp:192
 "}"));
+  EXPECT_EQ("#define M(x) x##x\n"
+"namespace A M(x) {\n"

Can you test the A B case? We can’t have a space right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121269

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


[PATCH] D121269: [clang-format] Fix namepsace format when the name is after by a macro

2022-03-08 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

Please wait for the other reviewers


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121269

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


[PATCH] D121096: [C++20][Modules][HU 2/5] Support searching Header Units in user or system search paths.

2022-03-08 Thread Iain Sandoe via Phabricator via cfe-commits
iains added a comment.

In D121096#3368996 , @ChuanqiXu wrote:

> BTW, all the tests uses ``clang_cc1`. How should the users do with `clang`? 
> Could them use `-Xclang` only?

The driver changes are in separate patches (they will make the same user-facing 
interface options as used by GCC).  I wanted to have the FE implementation 
available so that the driver has something to drive.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121096

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


[PATCH] D121096: [C++20][Modules][HU 2/5] Support searching Header Units in user or system search paths.

2022-03-08 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

In D121096#3369277 , @iains wrote:

> In D121096#3368996 , @ChuanqiXu 
> wrote:
>
>> BTW, all the tests uses ``clang_cc1`. How should the users do with `clang`? 
>> Could them use `-Xclang` only?
>
> The driver changes are in separate patches (they will make the same 
> user-facing interface options as used by GCC).  I wanted to have the FE 
> implementation available so that the driver has something to drive.

Makes sense to me. Thanks for the explanation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121096

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


[PATCH] D120992: [analyzer] ReverseNull: New checker to warn for pointer value conditions, if the pointer value is unconditionally non-null

2022-03-08 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/NullPtrInterferenceChecker.cpp:166
+/// child is a sink node.
+static bool unconditionallyLeadsHere(const ExplodedNode *N) {
+  size_t NonSinkNodeCount = llvm::count_if(

xazax.hun wrote:
> NoQ wrote:
> > xazax.hun wrote:
> > > Szelethus wrote:
> > > > xazax.hun wrote:
> > > > > xazax.hun wrote:
> > > > > > Consider the following code snippet:
> > > > > > ```
> > > > > > void f(int *p, bool b)
> > > > > > {
> > > > > >   if (b) {
> > > > > > *p = 4;
> > > > > >   }
> > > > > >   if (p) {
> > > > > >...
> > > > > >   }
> > > > > > }
> > > > > > ```
> > > > > > 
> > > > > > I suspect that we would get a warning for the code above. I think 
> > > > > > warning on the code above might be reasonable (the values of `b` 
> > > > > > and `p` might be correlated but in some cases the analyzer has no 
> > > > > > way to know this, probably some assertions could make the code 
> > > > > > clearer in that case).
> > > > > > 
> > > > > > My problem is with the wording of the error message.
> > > > > > The warning `Pointer is unconditionally non-null here` on the null 
> > > > > > check is not true for the code above.
> > > > > Also, if the check would warn for the code snippet above, the note 
> > > > > "suggest moving the condition here" would also be incorrect.
> > > > What if we demand that the the `CFGBlock` of the dereference must 
> > > > dominate the `CFGBlock` of the condition point?
> > > I think it makes sense to warn both when the dereference dominates the 
> > > null check, and when the null check post-dominates the dereference. We 
> > > just want to give different error messages in those cases. 
> > > What if we demand that the the CFGBlock of the dereference must dominate 
> > > the CFGBlock of the condition point?
> > 
> > ```lang=c
> >   *p = 4;
> >   if (b) {
> > p = bar();
> >   }
> >   if (p) {
> > ...
> >   }
> > ```
> > 
> Yup, this is a nice example. I cannot think of an easy way around this using 
> symbolic execution.
Ah, I see. However, empirically, the checker showed really promising results.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120992

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


[clang] f2b2490 - [Sema] Mark the referenced destructor during transformation of a `CXXBindTemporaryExpr`

2022-03-08 Thread Argyrios Kyrtzidis via cfe-commits

Author: Argyrios Kyrtzidis
Date: 2022-03-08T01:00:07-08:00
New Revision: f2b24905bfede6bd047a38f5cbae352e6b845428

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

LOG: [Sema] Mark the referenced destructor during transformation of a 
`CXXBindTemporaryExpr`

Otherwise we will fail to generate the definition of a defaulted destructor,
if the only reference was in a templated temporary.

rdar://89366678

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

Added: 
clang/test/SemaTemplate/defaulted-destructor-in-temporary.cpp

Modified: 
clang/lib/Sema/TreeTransform.h

Removed: 




diff  --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 0716689d4b626..6676bffb8a47a 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -12748,6 +12748,9 @@ ExprResult 
TreeTransform::TransformCXXInheritedCtorInitExpr(
 template
 ExprResult
 TreeTransform::TransformCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) 
{
+  if (auto *Dtor = E->getTemporary()->getDestructor())
+SemaRef.MarkFunctionReferenced(E->getBeginLoc(),
+   const_cast(Dtor));
   return getDerived().TransformExpr(E->getSubExpr());
 }
 

diff  --git a/clang/test/SemaTemplate/defaulted-destructor-in-temporary.cpp 
b/clang/test/SemaTemplate/defaulted-destructor-in-temporary.cpp
new file mode 100644
index 0..cbd4950c6af8e
--- /dev/null
+++ b/clang/test/SemaTemplate/defaulted-destructor-in-temporary.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -std=c++11 -triple=x86_64-apple-darwin %s -emit-llvm -o - | 
FileCheck %s
+
+// CHECK: define linkonce_odr {{.*}} @_ZN3StrD1Ev
+
+class A {
+public:
+  ~A();
+};
+class Str {
+  A d;
+
+public:
+  ~Str() = default;
+};
+class E {
+  Str s;
+  template 
+  void h() {
+s = {};
+  }
+  void f();
+};
+void E::f() {
+  h();
+}



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


[PATCH] D120426: [Sema] Mark the referenced destructor during transformation of a `CXXBindTemporaryExpr`

2022-03-08 Thread Argyrios Kyrtzidis via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf2b24905bfed: [Sema] Mark the referenced destructor during 
transformation of a… (authored by akyrtzi).
Herald added a project: All.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120426

Files:
  clang/lib/Sema/TreeTransform.h
  clang/test/SemaTemplate/defaulted-destructor-in-temporary.cpp


Index: clang/test/SemaTemplate/defaulted-destructor-in-temporary.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/defaulted-destructor-in-temporary.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -std=c++11 -triple=x86_64-apple-darwin %s -emit-llvm -o - | 
FileCheck %s
+
+// CHECK: define linkonce_odr {{.*}} @_ZN3StrD1Ev
+
+class A {
+public:
+  ~A();
+};
+class Str {
+  A d;
+
+public:
+  ~Str() = default;
+};
+class E {
+  Str s;
+  template 
+  void h() {
+s = {};
+  }
+  void f();
+};
+void E::f() {
+  h();
+}
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -12748,6 +12748,9 @@
 template
 ExprResult
 TreeTransform::TransformCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) 
{
+  if (auto *Dtor = E->getTemporary()->getDestructor())
+SemaRef.MarkFunctionReferenced(E->getBeginLoc(),
+   const_cast(Dtor));
   return getDerived().TransformExpr(E->getSubExpr());
 }
 


Index: clang/test/SemaTemplate/defaulted-destructor-in-temporary.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/defaulted-destructor-in-temporary.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -std=c++11 -triple=x86_64-apple-darwin %s -emit-llvm -o - | FileCheck %s
+
+// CHECK: define linkonce_odr {{.*}} @_ZN3StrD1Ev
+
+class A {
+public:
+  ~A();
+};
+class Str {
+  A d;
+
+public:
+  ~Str() = default;
+};
+class E {
+  Str s;
+  template 
+  void h() {
+s = {};
+  }
+  void f();
+};
+void E::f() {
+  h();
+}
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -12748,6 +12748,9 @@
 template
 ExprResult
 TreeTransform::TransformCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
+  if (auto *Dtor = E->getTemporary()->getDestructor())
+SemaRef.MarkFunctionReferenced(E->getBeginLoc(),
+   const_cast(Dtor));
   return getDerived().TransformExpr(E->getSubExpr());
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119842: [clangd] NFC: Cleanup IncludeCleaner API

2022-03-08 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.
Herald added a project: All.

Not sure how I missed this patch, sorry!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119842

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


[PATCH] D120713: [clangd] Make dexp command line options sticky

2022-03-08 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Thank you!




Comment at: clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp:417
+
+  // Protect IndexLocation, ExecCommand and ProjectRoot from being reset.
+  IndexLocation.setValue(IndexLocation, true /* initial */);

nit: comment echoes the code, say why instead?

Preserve global options when flag parser is reset, so commands can use them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120713

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


[PATCH] D121197: [clang][dataflow] Add analysis that detects unsafe accesses to optionals

2022-03-08 Thread Stanislav Gatev via Phabricator via cfe-commits
sgatev created this revision.
sgatev added reviewers: ymandel, xazax.hun, gribozavr2.
Herald added subscribers: tschuett, steakhal, rnkovacs, mgorny.
Herald added a project: All.
sgatev requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.
Herald added a project: clang.

Adds a dataflow analysis that detects unsafe accesses to values of type
`std::optional`, `absl::optional`, or `base::Optional`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121197

Files:
  
clang/include/clang/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.h
  clang/include/clang/Analysis/FlowSensitive/TestingSupport.h
  clang/lib/Analysis/FlowSensitive/CMakeLists.txt
  clang/lib/Analysis/FlowSensitive/Models/CMakeLists.txt
  clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
  clang/lib/Analysis/FlowSensitive/TestingSupport.cpp
  clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
  clang/unittests/Analysis/FlowSensitive/MatchSwitchTest.cpp
  clang/unittests/Analysis/FlowSensitive/Models/CMakeLists.txt
  
clang/unittests/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModelTest.cpp
  clang/unittests/Analysis/FlowSensitive/MultiVarConstantPropagationTest.cpp
  clang/unittests/Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp
  clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp
  clang/unittests/Analysis/FlowSensitive/TestingSupport.h
  clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp
  clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
  clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
@@ -7,7 +7,6 @@
 //===--===//
 
 #include "NoopAnalysis.h"
-#include "TestingSupport.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/ExprCXX.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
@@ -17,6 +16,7 @@
 #include "clang/Analysis/FlowSensitive/DataflowAnalysisContext.h"
 #include "clang/Analysis/FlowSensitive/DataflowEnvironment.h"
 #include "clang/Analysis/FlowSensitive/DataflowLattice.h"
+#include "clang/Analysis/FlowSensitive/TestingSupport.h"
 #include "clang/Analysis/FlowSensitive/Value.h"
 #include "clang/Analysis/FlowSensitive/WatchedLiteralsSolver.h"
 #include "clang/Tooling/Tooling.h"
Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -7,13 +7,13 @@
 //===--===//
 
 #include "NoopAnalysis.h"
-#include "TestingSupport.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Analysis/FlowSensitive/DataflowEnvironment.h"
 #include "clang/Analysis/FlowSensitive/StorageLocation.h"
+#include "clang/Analysis/FlowSensitive/TestingSupport.h"
 #include "clang/Analysis/FlowSensitive/Value.h"
 #include "clang/Basic/LangStandard.h"
 #include "llvm/ADT/ArrayRef.h"
Index: clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp
@@ -1,4 +1,4 @@
-#include "TestingSupport.h"
+#include "clang/Analysis/FlowSensitive/TestingSupport.h"
 #include "NoopAnalysis.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
Index: clang/unittests/Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp
@@ -12,7 +12,6 @@
 //
 //===--===//
 
-#include "TestingSupport.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/Expr.h"
@@ -22,6 +21,7 @@
 #include "clang/Analysis/FlowSensitive/DataflowAnalysis.h"
 #include "clang/Analysis/FlowSensitive/DataflowEnvironment.h"
 #include "clang/Analysis/FlowSensitive/DataflowLattice.h"
+#include "clang/Analysis/FlowSensitive/TestingSupport.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
Index: clang/unittests/Analysis/FlowSensitive/MultiVarConstantPropagationTest.cpp
===

[PATCH] D120992: [analyzer] ReverseNull: New checker to warn for pointer value conditions, if the pointer value is unconditionally non-null

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

In D120992#3364804 , @NoQ wrote:

> This check checks must-properties/all-paths properties. This has to be a data 
> flow / CFG-based warning. I don't think there's a way around.

Oof. I concede on that. Do you think there is any point in turning this into an 
optin checker? Or the philosophy should be that this is just way too wild?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120992

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


[PATCH] D121198: [flang][driver] Add support for `-debug-dump-pft`

2022-03-08 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski created this revision.
Herald added a reviewer: sscalpone.
Herald added a subscriber: dang.
Herald added projects: Flang, All.
awarzynski requested review of this revision.
Herald added subscribers: cfe-commits, jdoerfert.
Herald added a project: clang.

This patch adds support for dumping the pre-FIR tree in `flang-new
-fc1`. This flag is functionally identical to `-pft-test` in bbc.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121198

Files:
  clang/include/clang/Driver/Options.td
  flang/include/flang/Frontend/FrontendActions.h
  flang/include/flang/Frontend/FrontendOptions.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  flang/test/Driver/driver-help.f90
  flang/test/Driver/dump-pft.f90

Index: flang/test/Driver/dump-pft.f90
===
--- /dev/null
+++ flang/test/Driver/dump-pft.f90
@@ -0,0 +1,32 @@
+!-
+! RUN COMMANDS
+!-
+! RUN: %flang_fc1 -fdebug-dump-parse-tree %s 2>&1 | FileCheck %s --check-prefix=PARSE_TREE
+! RUN: %flang_fc1 -fdebug-dump-pft %s 2>&1 | FileCheck %s --check-prefix=PFT
+! RUN: bbc -pft-test %s 2>&1 | FileCheck %s --check-prefix=PFT
+
+!-
+! EXPECTEED OUTPUT
+!-
+! PFT: 1 Subroutine test_routine: subroutine test_routine(a, b, n)
+! PFT-NEXT:  1 EndSubroutineStmt: end subroutine
+! PRF-NEXT: End Subroutine test_routine
+! PFT-NO: Program -> ProgramUnit -> SubroutineSubprogram
+
+! PARSE_TREE: Program -> ProgramUnit -> SubroutineSubprogram
+! PARSE_TREE-NEXT: | SubroutineStmt
+! PARSE_TREE-NEXT: | | Name = 'test_routine'
+! PARSE_TREE-NEXT: | | DummyArg -> Name = 'a'
+! PARSE_TREE-NEXT: | | DummyArg -> Name = 'b'
+! PARSE_TREE-NEXT: | | DummyArg -> Name = 'n'
+! PARSE_TREE-NEXT: | SpecificationPart
+! PARSE_TREE-NEXT: | | ImplicitPart ->
+! PARSE_TREE-NEXT: | ExecutionPart -> Block
+! PARSE_TREE-NEXT: | EndSubroutineStmt ->
+! PARSE_TREE-NO: Subroutine test_routine: subroutine test_routine(a, b, n)
+
+!---
+! INPUT
+!---
+subroutine test_routine(a, b, n)
+end subroutine
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -82,6 +82,7 @@
 ! HELP-FC1-NEXT: -fdebug-dump-parse-tree Dump the parse tree
 ! HELP-FC1-NEXT: -fdebug-dump-parsing-log
 ! HELP-FC1-NEXT:   Run instrumented parse and dump the parsing log
+! HELP-FC1-NEXT: -fdebug-dump-pftDump the pre-fir parse tree
 ! HELP-FC1-NEXT: -fdebug-dump-provenance Dump provenance
 ! HELP-FC1-NEXT: -fdebug-dump-symbolsDump symbols after the semantic analysis
 ! HELP-FC1-NEXT: -fdebug-measure-parse-tree
Index: flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -49,6 +49,8 @@
 return std::make_unique();
   case DebugDumpParseTree:
 return std::make_unique();
+  case DebugDumpPFT:
+return std::make_unique();
   case DebugDumpParseTreeNoSema:
 return std::make_unique();
   case DebugDumpAll:
Index: flang/lib/Frontend/FrontendActions.cpp
===
--- flang/lib/Frontend/FrontendActions.cpp
+++ flang/lib/Frontend/FrontendActions.cpp
@@ -506,3 +506,17 @@
 }
 
 void PluginParseTreeAction::ExecuteAction() {}
+
+void DebugDumpPFTAction::ExecuteAction() {
+  CompilerInstance &ci = this->instance();
+
+  if (auto ast = Fortran::lower::createPFT(
+  *ci.parsing().parseTree(), ci.semantics().context())) {
+Fortran::lower::dumpPFT(llvm::outs(), *ast);
+return;
+  }
+
+  unsigned DiagID = ci.diagnostics().getCustomDiagID(
+  clang::DiagnosticsEngine::Error, "Pre FIR Tree is NULL.");
+  ci.diagnostics().Report(DiagID);
+}
Index: flang/lib/Frontend/CompilerInvocation.cpp
===
--- flang/lib/Frontend/CompilerInvocation.cpp
+++ flang/lib/Frontend/CompilerInvocation.cpp
@@ -168,6 +168,9 @@
 case clang::driver::options::OPT_fdebug_dump_parse_tree:
   opts.programAction = DebugDumpParseTree;
   break;
+case clang::driver::options::OPT_fdebug_dump_pft:
+  opts.programAction = DebugDumpPFT;
+  break;
 case clang::driver::options::OPT_fdebug_dump_all:
   opts.programAction = DebugDumpAll;
   break;
Index: flang/include/flang/Frontend/FrontendOptions.h
===
--- flang/include/flang/Frontend/FrontendOptions.h
+++ flang/include/flang/Frontend/FrontendOptions.h
@@ -57,6 +57,9 @@
   /// Parse, run semantics and then output the parse tree
   DebugDumpParseTree,
 
+  /// Parse, run semantics and then output the pre-fir parse tree
+  Deb

[PATCH] D121197: [clang][dataflow] Add analysis that detects unsafe accesses to optionals

2022-03-08 Thread Stanislav Gatev via Phabricator via cfe-commits
sgatev updated this revision to Diff 413743.
sgatev added a comment.

Mark functions as static and add TODOs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121197

Files:
  
clang/include/clang/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.h
  clang/include/clang/Analysis/FlowSensitive/TestingSupport.h
  clang/lib/Analysis/FlowSensitive/CMakeLists.txt
  clang/lib/Analysis/FlowSensitive/Models/CMakeLists.txt
  clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
  clang/lib/Analysis/FlowSensitive/TestingSupport.cpp
  clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
  clang/unittests/Analysis/FlowSensitive/MatchSwitchTest.cpp
  clang/unittests/Analysis/FlowSensitive/Models/CMakeLists.txt
  
clang/unittests/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModelTest.cpp
  clang/unittests/Analysis/FlowSensitive/MultiVarConstantPropagationTest.cpp
  clang/unittests/Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp
  clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp
  clang/unittests/Analysis/FlowSensitive/TestingSupport.h
  clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp
  clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
  clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
@@ -7,7 +7,6 @@
 //===--===//
 
 #include "NoopAnalysis.h"
-#include "TestingSupport.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/ExprCXX.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
@@ -17,6 +16,7 @@
 #include "clang/Analysis/FlowSensitive/DataflowAnalysisContext.h"
 #include "clang/Analysis/FlowSensitive/DataflowEnvironment.h"
 #include "clang/Analysis/FlowSensitive/DataflowLattice.h"
+#include "clang/Analysis/FlowSensitive/TestingSupport.h"
 #include "clang/Analysis/FlowSensitive/Value.h"
 #include "clang/Analysis/FlowSensitive/WatchedLiteralsSolver.h"
 #include "clang/Tooling/Tooling.h"
Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -7,13 +7,13 @@
 //===--===//
 
 #include "NoopAnalysis.h"
-#include "TestingSupport.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Analysis/FlowSensitive/DataflowEnvironment.h"
 #include "clang/Analysis/FlowSensitive/StorageLocation.h"
+#include "clang/Analysis/FlowSensitive/TestingSupport.h"
 #include "clang/Analysis/FlowSensitive/Value.h"
 #include "clang/Basic/LangStandard.h"
 #include "llvm/ADT/ArrayRef.h"
Index: clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp
@@ -1,4 +1,4 @@
-#include "TestingSupport.h"
+#include "clang/Analysis/FlowSensitive/TestingSupport.h"
 #include "NoopAnalysis.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
Index: clang/unittests/Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp
@@ -12,7 +12,6 @@
 //
 //===--===//
 
-#include "TestingSupport.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/Expr.h"
@@ -22,6 +21,7 @@
 #include "clang/Analysis/FlowSensitive/DataflowAnalysis.h"
 #include "clang/Analysis/FlowSensitive/DataflowEnvironment.h"
 #include "clang/Analysis/FlowSensitive/DataflowLattice.h"
+#include "clang/Analysis/FlowSensitive/TestingSupport.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
Index: clang/unittests/Analysis/FlowSensitive/MultiVarConstantPropagationTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/MultiVarConstantPropagationTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/MultiVarConstantPropagationTest.cpp
@@ -12,7 +12,6 @@
 //
 //===--

[PATCH] D121201: [clang] Merge the SourceRange into ParsedAttributes

2022-03-08 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added a reviewer: aaron.ballman.
Herald added subscribers: kbarton, nemanjai.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

I wasn't 100% whether to add the range to `ParsedAttributes` or even 
`ParsedAttributesView`.

There's still a `ParsedAttributesViewWithRange` which basically used //once// 
in `ParseDeclCXX.cpp`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121201

Files:
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/DeclSpec.h
  clang/include/clang/Sema/ParsedAttr.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Driver/ToolChains/PPCLinux.cpp
  clang/lib/Parse/ParseCXXInlineMethods.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Parse/ParseObjc.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/lib/Parse/ParseTemplate.cpp
  clang/lib/Parse/ParseTentative.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaStmtAttr.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaOpenCL/address-spaces.cl

Index: clang/test/SemaOpenCL/address-spaces.cl
===
--- clang/test/SemaOpenCL/address-spaces.cl
+++ clang/test/SemaOpenCL/address-spaces.cl
@@ -258,7 +258,7 @@
 
 void func_multiple_addr2(void) {
   typedef __private int private_int_t;
-  __private __attribute__((opencl_global)) int var1;   // expected-error {{multiple address spaces specified for type}} \
+  __attribute__((opencl_global)) __private int var1;   // expected-error {{multiple address spaces specified for type}} \
// expected-error {{function scope variable cannot be declared in global address space}}
   __private __attribute__((opencl_global)) int *var2;  // expected-error {{multiple address spaces specified for type}}
   __attribute__((opencl_global)) private_int_t var3;   // expected-error {{multiple address spaces specified for type}}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -362,7 +362,8 @@
 };
 
 static void processTypeAttrs(TypeProcessingState &state, QualType &type,
- TypeAttrLocation TAL, ParsedAttributesView &attrs);
+ TypeAttrLocation TAL,
+ const ParsedAttributesView &attrs);
 
 static bool handleFunctionTypeAttr(TypeProcessingState &state, ParsedAttr &attr,
QualType &type);
@@ -8123,7 +8124,12 @@
 
 static void processTypeAttrs(TypeProcessingState &state, QualType &type,
  TypeAttrLocation TAL,
- ParsedAttributesView &attrs) {
+ const ParsedAttributesView &attrs) {
+
+  state.setParsedNoDeref(false);
+  if (attrs.empty())
+return;
+
   // Scan through and apply attributes to this type where it makes sense.  Some
   // attributes (such as __address_space__, __vector_size__, etc) apply to the
   // type, but others can be present in the type specifiers even though they
@@ -8133,9 +8139,6 @@
   // sure we visit every element once. Copy the attributes list, and iterate
   // over that.
   ParsedAttributesView AttrsCopy{attrs};
-
-  state.setParsedNoDeref(false);
-
   for (ParsedAttr &attr : AttrsCopy) {
 
 // Skip attributes that were marked to be invalid.
Index: clang/lib/Sema/SemaStmtAttr.cpp
===
--- clang/lib/Sema/SemaStmtAttr.cpp
+++ clang/lib/Sema/SemaStmtAttr.cpp
@@ -468,8 +468,7 @@
   }
 }
 
-void Sema::ProcessStmtAttributes(Stmt *S,
- const ParsedAttributesWithRange &InAttrs,
+void Sema::ProcessStmtAttributes(Stmt *S, const ParsedAttributes &InAttrs,
  SmallVectorImpl &OutAttrs) {
   for (const ParsedAttr &AL : InAttrs) {
 if (const Attr *A = ProcessStmtAttribute(*this, S, AL, InAttrs.Range))
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -587,7 +587,7 @@
   return AttributedStmt::Create(Context, AttrsLoc, Attrs, SubStmt);
 }
 
-StmtResult Sema::ActOnAttributedStmt(const ParsedAttributesWithRange &Attrs,
+StmtResult Sema::ActOnAttributedStmt(const ParsedAttributes &Attrs,
  Stmt *SubStmt) {
   SmallVector SemanticAttrs;
   ProcessStmtAttributes(SubStmt, Attrs, SemanticAttrs);
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaD

[PATCH] D121201: [clang] Merge the SourceRange into ParsedAttributes

2022-03-08 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 413744.

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

https://reviews.llvm.org/D121201

Files:
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/DeclSpec.h
  clang/include/clang/Sema/ParsedAttr.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseCXXInlineMethods.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Parse/ParseObjc.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/lib/Parse/ParseTemplate.cpp
  clang/lib/Parse/ParseTentative.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaStmtAttr.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaOpenCL/address-spaces.cl

Index: clang/test/SemaOpenCL/address-spaces.cl
===
--- clang/test/SemaOpenCL/address-spaces.cl
+++ clang/test/SemaOpenCL/address-spaces.cl
@@ -258,7 +258,7 @@
 
 void func_multiple_addr2(void) {
   typedef __private int private_int_t;
-  __private __attribute__((opencl_global)) int var1;   // expected-error {{multiple address spaces specified for type}} \
+  __attribute__((opencl_global)) __private int var1;   // expected-error {{multiple address spaces specified for type}} \
// expected-error {{function scope variable cannot be declared in global address space}}
   __private __attribute__((opencl_global)) int *var2;  // expected-error {{multiple address spaces specified for type}}
   __attribute__((opencl_global)) private_int_t var3;   // expected-error {{multiple address spaces specified for type}}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -362,7 +362,8 @@
 };
 
 static void processTypeAttrs(TypeProcessingState &state, QualType &type,
- TypeAttrLocation TAL, ParsedAttributesView &attrs);
+ TypeAttrLocation TAL,
+ const ParsedAttributesView &attrs);
 
 static bool handleFunctionTypeAttr(TypeProcessingState &state, ParsedAttr &attr,
QualType &type);
@@ -8123,7 +8124,12 @@
 
 static void processTypeAttrs(TypeProcessingState &state, QualType &type,
  TypeAttrLocation TAL,
- ParsedAttributesView &attrs) {
+ const ParsedAttributesView &attrs) {
+
+  state.setParsedNoDeref(false);
+  if (attrs.empty())
+return;
+
   // Scan through and apply attributes to this type where it makes sense.  Some
   // attributes (such as __address_space__, __vector_size__, etc) apply to the
   // type, but others can be present in the type specifiers even though they
@@ -8133,9 +8139,6 @@
   // sure we visit every element once. Copy the attributes list, and iterate
   // over that.
   ParsedAttributesView AttrsCopy{attrs};
-
-  state.setParsedNoDeref(false);
-
   for (ParsedAttr &attr : AttrsCopy) {
 
 // Skip attributes that were marked to be invalid.
Index: clang/lib/Sema/SemaStmtAttr.cpp
===
--- clang/lib/Sema/SemaStmtAttr.cpp
+++ clang/lib/Sema/SemaStmtAttr.cpp
@@ -468,8 +468,7 @@
   }
 }
 
-void Sema::ProcessStmtAttributes(Stmt *S,
- const ParsedAttributesWithRange &InAttrs,
+void Sema::ProcessStmtAttributes(Stmt *S, const ParsedAttributes &InAttrs,
  SmallVectorImpl &OutAttrs) {
   for (const ParsedAttr &AL : InAttrs) {
 if (const Attr *A = ProcessStmtAttribute(*this, S, AL, InAttrs.Range))
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -587,7 +587,7 @@
   return AttributedStmt::Create(Context, AttrsLoc, Attrs, SubStmt);
 }
 
-StmtResult Sema::ActOnAttributedStmt(const ParsedAttributesWithRange &Attrs,
+StmtResult Sema::ActOnAttributedStmt(const ParsedAttributes &Attrs,
  Stmt *SubStmt) {
   SmallVector SemanticAttrs;
   ProcessStmtAttributes(SubStmt, Attrs, SemanticAttrs);
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -2615,12 +2615,11 @@
 /// example:
 ///class foo : public bar, virtual private baz {
 /// 'public bar' and 'virtual private baz' are each base-specifiers.
-BaseResult
-Sema::ActOnBaseSpecifier(Decl *classdecl, SourceRange SpecifierRange,
- ParsedAttributes &Attributes,
- bool Virtual, AccessSpecifier Access,
-

[PATCH] D121201: [clang] Merge the SourceRange into ParsedAttributes

2022-03-08 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added inline comments.



Comment at: clang/test/SemaOpenCL/address-spaces.cl:261
   typedef __private int private_int_t;
-  __private __attribute__((opencl_global)) int var1;   // expected-error 
{{multiple address spaces specified for type}} \
+  __attribute__((opencl_global)) __private int var1;   // expected-error 
{{multiple address spaces specified for type}} \
// expected-error 
{{function scope variable cannot be declared in global address space}}

This is a peculiar ordering problem...


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

https://reviews.llvm.org/D121201

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


[PATCH] D120221: [AST] Fix typos

2022-03-08 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.
Herald added a project: All.

LGTM!

In D120221#3334412 , @kuzkry wrote:

> Can I ask you to deliver this one for me? I don't have permissions. My name 
> and email in git format is "Krystian Kuzniarek "

Sure, thanks for the fix!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120221

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


[clang] 481f681 - [AST] Fix typo in assert messages

2022-03-08 Thread Anastasia Stulova via cfe-commits

Author: Krystian Kuzniarek
Date: 2022-03-08T11:06:50Z
New Revision: 481f6818670aa86e426e326975aa6ea6035d72b3

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

LOG: [AST] Fix typo in assert messages

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

Added: 


Modified: 
clang/lib/AST/ASTDiagnostic.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTDiagnostic.cpp b/clang/lib/AST/ASTDiagnostic.cpp
index 9f5e5ef1e96e6..0c27c0d14519d 100644
--- a/clang/lib/AST/ASTDiagnostic.cpp
+++ b/clang/lib/AST/ASTDiagnostic.cpp
@@ -372,7 +372,7 @@ void clang::FormatASTNodeDiagnosticArgument(
 default: llvm_unreachable("unknown ArgumentKind");
 case DiagnosticsEngine::ak_addrspace: {
   assert(Modifier.empty() && Argument.empty() &&
- "Invalid modifier for Qualfiers argument");
+ "Invalid modifier for Qualifiers argument");
 
   auto S = Qualifiers::getAddrSpaceAsString(static_cast(Val));
   if (S.empty()) {
@@ -387,7 +387,7 @@ void clang::FormatASTNodeDiagnosticArgument(
 }
 case DiagnosticsEngine::ak_qual: {
   assert(Modifier.empty() && Argument.empty() &&
- "Invalid modifier for Qualfiers argument");
+ "Invalid modifier for Qualifiers argument");
 
   Qualifiers Q(Qualifiers::fromOpaqueValue(Val));
   auto S = Q.getAsString();



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


[PATCH] D120221: [AST] Fix typos

2022-03-08 Thread Anastasia Stulova via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG481f6818670a: [AST] Fix typo in assert messages (authored by 
kuzkry, committed by Anastasia).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120221

Files:
  clang/lib/AST/ASTDiagnostic.cpp


Index: clang/lib/AST/ASTDiagnostic.cpp
===
--- clang/lib/AST/ASTDiagnostic.cpp
+++ clang/lib/AST/ASTDiagnostic.cpp
@@ -372,7 +372,7 @@
 default: llvm_unreachable("unknown ArgumentKind");
 case DiagnosticsEngine::ak_addrspace: {
   assert(Modifier.empty() && Argument.empty() &&
- "Invalid modifier for Qualfiers argument");
+ "Invalid modifier for Qualifiers argument");
 
   auto S = Qualifiers::getAddrSpaceAsString(static_cast(Val));
   if (S.empty()) {
@@ -387,7 +387,7 @@
 }
 case DiagnosticsEngine::ak_qual: {
   assert(Modifier.empty() && Argument.empty() &&
- "Invalid modifier for Qualfiers argument");
+ "Invalid modifier for Qualifiers argument");
 
   Qualifiers Q(Qualifiers::fromOpaqueValue(Val));
   auto S = Q.getAsString();


Index: clang/lib/AST/ASTDiagnostic.cpp
===
--- clang/lib/AST/ASTDiagnostic.cpp
+++ clang/lib/AST/ASTDiagnostic.cpp
@@ -372,7 +372,7 @@
 default: llvm_unreachable("unknown ArgumentKind");
 case DiagnosticsEngine::ak_addrspace: {
   assert(Modifier.empty() && Argument.empty() &&
- "Invalid modifier for Qualfiers argument");
+ "Invalid modifier for Qualifiers argument");
 
   auto S = Qualifiers::getAddrSpaceAsString(static_cast(Val));
   if (S.empty()) {
@@ -387,7 +387,7 @@
 }
 case DiagnosticsEngine::ak_qual: {
   assert(Modifier.empty() && Argument.empty() &&
- "Invalid modifier for Qualfiers argument");
+ "Invalid modifier for Qualifiers argument");
 
   Qualifiers Q(Qualifiers::fromOpaqueValue(Val));
   auto S = Q.getAsString();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121198: [flang][driver] Add support for `-debug-dump-pft`

2022-03-08 Thread Valentin Clement via Phabricator via cfe-commits
clementval added a comment.

I’m not sure this is a feature we want to expose in the main driver.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121198

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


[PATCH] D120713: [clangd] Make dexp command line options sticky

2022-03-08 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp:418
+  // Protect IndexLocation, ExecCommand and ProjectRoot from being reset.
+  IndexLocation.setValue(IndexLocation, true /* initial */);
+  ExecCommand.setValue(ExecCommand, true /* initial */);

also nit: `/*initial=*/ true`. same below


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120713

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


[clang] 75aca24 - [clang] Fix reference to file that was moved.

2022-03-08 Thread Adrian Kuegel via cfe-commits

Author: Adrian Kuegel
Date: 2022-03-08T12:26:02+01:00
New Revision: 75aca24d2f49a646df5a443c55bc020450fe04a7

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

LOG: [clang] Fix reference to file that was moved.

Added: 


Modified: 
clang/docs/tools/clang-formatted-files.txt

Removed: 




diff  --git a/clang/docs/tools/clang-formatted-files.txt 
b/clang/docs/tools/clang-formatted-files.txt
index ec18d87cca0e0..e0ce9b1c29228 100644
--- a/clang/docs/tools/clang-formatted-files.txt
+++ b/clang/docs/tools/clang-formatted-files.txt
@@ -7541,7 +7541,7 @@ mlir/examples/toy/Ch7/mlir/ToyCombine.cpp
 mlir/include/mlir/InitAllDialects.h
 mlir/include/mlir/InitAllPasses.h
 mlir/include/mlir/InitAllTranslations.h
-mlir/include/mlir/Parser.h
+mlir/include/mlir/Parser/Parser.h
 mlir/include/mlir/Translation.h
 mlir/include/mlir/Analysis/BufferViewFlowAnalysis.h
 mlir/include/mlir/Analysis/DataFlowAnalysis.h



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


[PATCH] D121198: [flang][driver] Add support for `-debug-dump-pft`

2022-03-08 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

In D121198#3366741 , @clementval 
wrote:

> I’m not sure this is a feature we want to expose in the main driver.

It's only available in `flang-new -fc1`, i.e. the frontend driver. We are not 
exposing it in `flang-new`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121198

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


[PATCH] D121206: [AARCH64] ssbs should be enabled by default for cortex-x1c

2022-03-08 Thread Ties Stuij via Phabricator via cfe-commits
stuij created this revision.
Herald added subscribers: hiraditya, kristof.beyls.
Herald added a project: All.
stuij 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/D121206

Files:
  clang/test/Driver/aarch64-ssbs.c
  clang/test/Preprocessor/aarch64-target-features.c
  llvm/lib/Support/AArch64TargetParser.cpp
  llvm/lib/Target/AArch64/AArch64.td


Index: llvm/lib/Target/AArch64/AArch64.td
===
--- llvm/lib/Target/AArch64/AArch64.td
+++ llvm/lib/Target/AArch64/AArch64.td
@@ -979,7 +979,7 @@
   list X1C  = [HasV8_2aOps, FeatureCrypto, FeatureFPARMv8,
  FeatureNEON, FeatureRCPC, FeaturePerfMon,
  FeatureSPE, FeatureFullFP16, FeatureDotProd,
- FeaturePAuth];
+ FeaturePAuth, FeatureSSBS];
   list X2   = [HasV9_0aOps, FeatureNEON, FeaturePerfMon,
  FeatureMatMulInt8, FeatureBF16, FeatureAM,
  FeatureMTE, FeatureETE, FeatureSVE2BitPerm,
Index: llvm/lib/Support/AArch64TargetParser.cpp
===
--- llvm/lib/Support/AArch64TargetParser.cpp
+++ llvm/lib/Support/AArch64TargetParser.cpp
@@ -120,6 +120,8 @@
 Features.push_back("+mops");
   if (Extensions & AArch64::AEK_PERFMON)
 Features.push_back("+perfmon");
+  if (Extensions & AArch64::AEK_SSBS)
+Features.push_back("+ssbs");
 
   return true;
 }
Index: clang/test/Preprocessor/aarch64-target-features.c
===
--- clang/test/Preprocessor/aarch64-target-features.c
+++ clang/test/Preprocessor/aarch64-target-features.c
@@ -285,7 +285,7 @@
 // CHECK-MCPU-A57: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+v8a" "-target-feature" "+fp-armv8" "-target-feature" "+neon" 
"-target-feature" "+crc" "-target-feature" "+crypto"
 // CHECK-MCPU-A72: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+v8a" "-target-feature" "+fp-armv8" "-target-feature" "+neon" 
"-target-feature" "+crc" "-target-feature" "+crypto"
 // CHECK-MCPU-CORTEX-A73: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" 
"-target-feature" "+v8a" "-target-feature" "+fp-armv8" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
-// CHECK-MCPU-CORTEX-R82: "-cc1"{{.*}} "-triple" "aarch64{{.*}}"  
"-target-feature" "+v8r" "-target-feature" "+fp-armv8" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+dotprod" "-target-feature" 
"+fp16fml" "-target-feature" "+ras" "-target-feature" "+lse" "-target-feature" 
"+rdm" "-target-feature" "+rcpc" "-target-feature" "+fullfp16"
+// CHECK-MCPU-CORTEX-R82: "-cc1"{{.*}} "-triple" "aarch64{{.*}}"  
"-target-feature" "+v8r" "-target-feature" "+fp-armv8" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+dotprod" "-target-feature" 
"+fp16fml" "-target-feature" "+ras" "-target-feature" "+lse" "-target-feature" 
"+rdm" "-target-feature" "+rcpc" "-target-feature" "+ssbs" "-target-feature" 
"+fullfp16"
 // CHECK-MCPU-M3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+v8a" "-target-feature" "+fp-armv8" "-target-feature" "+neon" 
"-target-feature" "+crc" "-target-feature" "+crypto"
 // CHECK-MCPU-M4: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" 
"+dotprod" "-target-feature" "+fullfp16"
 // CHECK-MCPU-KRYO: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+v8a" "-target-feature" "+fp-armv8" "-target-feature" "+neon" 
"-target-feature" "+crc" "-target-feature" "+crypto"
Index: clang/test/Driver/aarch64-ssbs.c
===
--- clang/test/Driver/aarch64-ssbs.c
+++ clang/test/Driver/aarch64-ssbs.c
@@ -1,7 +1,9 @@
 // RUN: %clang -### -target aarch64-none-none-eabi -march=armv8a+ssbs   %s 
2>&1 | FileCheck %s
+// RUN: %clang -### -target aarch64-none-none-eabi -mcpu=cortex-x1c %s 
2>&1 | FileCheck %s
 // CHECK: "-target-feature" "+ssbs"
 
 // RUN: %clang -### -target aarch64-none-none-eabi -march=armv8a+nossbs %s 
2>&1 | FileCheck %s --check-prefix=NOSSBS
+// RUN: %clang -### -target aarch64-none-none-eabi -mcpu=cortex-x1c+nossbs %s 
2>&1 | FileCheck %s --check-prefix=NOSSBS
 // NOSSBS: "-target-feature" "-ssbs"
 
 // RUN: %clang -### -target aarch64-none-none-eabi  %s 
2>&1 | FileCheck %s --check-prefix=ABSENTSSBS


Index: llvm/lib/Target/AArch64/AArch64.td
===
--- llvm/lib/Target/AArch64/AArch64.td
+++ llvm/lib/Target/AArch64/AArch64.td
@@ -979,7 +979,7 @@
   list X1C  = [HasV8_2aOps, FeatureCrypto, FeatureFPARMv8,

[PATCH] D118352: [clang][ABI] New c++20 modules mangling scheme

2022-03-08 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu accepted this revision.
ChuanqiXu added a comment.
This revision is now accepted and ready to land.

LGTM, then. BTW, I see there is already no dependency with D119833 
 in code. But it shows dependency still in 
phab.


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

https://reviews.llvm.org/D118352

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


[PATCH] D119609: [Clang][Sema] Don't act on ReturnStmt when parsing the lambda declarator.

2022-03-08 Thread Jun Zhang via Phabricator via cfe-commits
junaire added inline comments.



Comment at: clang/test/Sema/err-expr-stmt-in-default-arg.cpp:19
+  return bar(l);
+}

erichkeane wrote:
> For completeness, I'd like to see an 
> in-function-defined-struct-member-function test here as well.
> 
> As for the above question about the recovery, something like:
> 
> `void fn(int i, int j = ({ {},{},{,} }), int k = "");` I think checks all the 
> issues I can think of.  We want to make sure that 'k' still diagnoses its 
> error correctly (and that we have just skipped all of the expression 
> statement stuff).
Note that clang is already rejected the code: https://godbolt.org/z/57c4qaaPo



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119609

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


[PATCH] D121078: Replace links to archived mailing lists by links to Discourse forums

2022-03-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D121078#3366025 , @tonic wrote:

> In D121078#3365542 , @SimplyDanny 
> wrote:
>
>> In D121078#3363856 , 
>> @aaron.ballman wrote:
>>
>>> I think we need to retain *some* references to the existing mailing list 
>>> archives. The migration to Discourse worked fairly well, but there were 
>>> still data migration issues.  For example:
>>
>> Do you have some prominent places in mind where the archives should be 
>> mentioned? For me as someone who just started to get a bit more involved 
>> into LLVM, the archives are not very helpful. There is no way to search for 
>> threads as far as I know. That means it is very hard to find anything 
>> specific. That is why I actually came up with this change in the first 
>> place: Getting rid of references to the "old' mailing lists which are just 
>> not helpful for beginners.

Oh, I think these changes are *fantastic*, so I'm happy we're updating the 
stale references to point to the more modern place to go. Thank you for that!

There are ways to search the archives (as Tanya mentioned, you can use a google 
site search over them), but you have to know they exist to know to do that, 
which is why I'd like to retain some mention of them until the migration moves 
over *all* of the historical data. It's not super handy for most folks, so I 
don't think we need a *prominent* place for this. But it is handy for those of 
us who have to do a fair amount of historical digging around to see how we came 
to the conclusions we came to (not a common activity, but it is not uncommon 
for folks on standards committees to be asked "why does your implementation do 
X?" and need to go looking).

I think the least distracting thing we could do would be to put a superscript 
footnote after any link to a particular discourse forum which goes to an anchor 
at the bottom of the page to a footnote saying something like what I 
recommended below. This should keep the focus for most people on going to 
Discourse, it shouldn't be overly distracting or confusing to people new to the 
docs, but it still retains useful information that some folks need.

> You do not need to worry about this.

In your opinion, that may be true; in mine, this is still a concern.

> Your change is updating the locations people are to ask for help.

The change is also touching `Mailing List & Forums` content, which are not 
specifically about asking for help (they can also be for reading instead of 
writing).

> That has changed to Discourse and this is the proper change. This is separate 
> from the archive situation which we are actively working on and I have full 
> confidence will be sorted out. In addition, most people are not looking for 
> archives here, they will do a google search or search the archives (which is 
> effectively a google search since we have limited search on our website).

The migration *lost data* and I think it's important we retain some links for 
those of us who do code archeology a fair amount. Old timers will certainly 
remember that we used to have mailing lists, but that number is going to 
decrease as old timers leave the community and newcomers arrive. I see value in 
telling people who are new to the community where they can find the full, 
accurate history of conversations and so I still see the need to retain *some* 
link for quite some time. It's trivial to retain these links with some wording 
like `The canonical historical information from this mailing list can be found 
at .` And if we don't expect to retain that archive forever because we 
have full confidence we'll get all the data migrated eventually, we can add an 
additional sentence along the lines of `This archive is expected to be removed 
once the migration to Discourse has been verified to not lose data.` or 
something.

>> In D121078#3363856 , 
>> @aaron.ballman wrote:
>>
>>> Also, the commits mailing lists are still hosted by mailman and remain 
>>> relevant to the community for the foreseeable future.
>>
>> I tried to keep them in all places and just replaced the "-dev" lists by 
>> references to the forum(s). Have you found a link to a commits mailing list 
>> which I removed unintentionally?
>
> Do not worry about this as you have kept all the references to commits list.

Thanks, you're absolutely right about that -- I missed that we retained the 
existing links to the commits lists. Sorry for the noise there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121078

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


[clang] 7a54fce - [clang-format] Handle C# 9 `init` accessor specifier.

2022-03-08 Thread Marek Kurdej via cfe-commits

Author: Marek Kurdej
Date: 2022-03-08T13:33:36+01:00
New Revision: 7a54fceb256257e3f8c8bd16ffd55531d806c96e

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

LOG: [clang-format] Handle C# 9 `init` accessor specifier.

Before, the code:
```
int Value { get; } = 0;
int Value { init; } = 0;
```
was formatted incoherently:
```
int Value { get; } = 0;
int Value { init; }
= 0;
```
because `init` was not recognised as an accessor specifier.

Reviewed By: MyDeveloperDay, HazardyKnusperkeks

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

Added: 


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

Removed: 




diff  --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h
index b00b8ab7b927c..fa76da15a53d3 100644
--- a/clang/lib/Format/FormatToken.h
+++ b/clang/lib/Format/FormatToken.h
@@ -954,6 +954,7 @@ struct AdditionalKeywords {
 kw_event = &IdentTable.get("event");
 kw_fixed = &IdentTable.get("fixed");
 kw_foreach = &IdentTable.get("foreach");
+kw_init = &IdentTable.get("init");
 kw_implicit = &IdentTable.get("implicit");
 kw_internal = &IdentTable.get("internal");
 kw_lock = &IdentTable.get("lock");
@@ -986,11 +987,11 @@ struct AdditionalKeywords {
 
 CSharpExtraKeywords = std::unordered_set(
 {kw_base, kw_byte, kw_checked, kw_decimal, kw_delegate, kw_event,
- kw_fixed, kw_foreach, kw_implicit, kw_in, kw_interface, kw_internal,
- kw_is, kw_lock, kw_null, kw_object, kw_out, kw_override, kw_params,
- kw_readonly, kw_ref, kw_string, kw_stackalloc, kw_sbyte, kw_sealed,
- kw_uint, kw_ulong, kw_unchecked, kw_unsafe, kw_ushort, kw_when,
- kw_where,
+ kw_fixed, kw_foreach, kw_implicit, kw_in, kw_init, kw_interface,
+ kw_internal, kw_is, kw_lock, kw_null, kw_object, kw_out, kw_override,
+ kw_params, kw_readonly, kw_ref, kw_string, kw_stackalloc, kw_sbyte,
+ kw_sealed, kw_uint, kw_ulong, kw_unchecked, kw_unsafe, kw_ushort,
+ kw_when, kw_where,
  // Keywords from the JavaScript section.
  kw_as, kw_async, kw_await, kw_declare, kw_finally, kw_from,
  kw_function, kw_get, kw_import, kw_is, kw_let, kw_module, kw_readonly,
@@ -1078,6 +1079,7 @@ struct AdditionalKeywords {
   IdentifierInfo *kw_fixed;
   IdentifierInfo *kw_foreach;
   IdentifierInfo *kw_implicit;
+  IdentifierInfo *kw_init;
   IdentifierInfo *kw_internal;
 
   IdentifierInfo *kw_lock;

diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 3015cd2be8879..236e9a73b33a8 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -1652,7 +1652,7 @@ class AnnotatingParser {
 Current.Previous->isOneOf(
 tok::kw_namespace, tok::r_paren, tok::r_square, tok::r_brace,
 tok::kw_false, tok::kw_true, Keywords.kw_type, Keywords.kw_get,
-Keywords.kw_set) ||
+Keywords.kw_init, Keywords.kw_set) ||
 Current.Previous->Tok.isLiteral()) {
   Current.setType(TT_NonNullAssertion);
   return;

diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index a62aa5e649839..994b197347bc1 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -1837,16 +1837,16 @@ bool UnwrappedLineParser::tryToParsePropertyAccessor() {
   FormatToken *Tok = Tokens->getNextToken();
 
   // A trivial property accessor is of the form:
-  // { [ACCESS_SPECIFIER] [get]; [ACCESS_SPECIFIER] [set] }
+  // { [ACCESS_SPECIFIER] [get]; [ACCESS_SPECIFIER] [set|init] }
   // Track these as they do not require line breaks to be introduced.
-  bool HasGetOrSet = false;
+  bool HasSpecialAccessor = false;
   bool IsTrivialPropertyAccessor = true;
   while (!eof()) {
 if (Tok->isOneOf(tok::semi, tok::kw_public, tok::kw_private,
  tok::kw_protected, Keywords.kw_internal, Keywords.kw_get,
- Keywords.kw_set)) {
-  if (Tok->isOneOf(Keywords.kw_get, Keywords.kw_set))
-HasGetOrSet = true;
+ Keywords.kw_init, Keywords.kw_set)) {
+  if (Tok->isOneOf(Keywords.kw_get, Keywords.kw_init, Keywords.kw_set))
+HasSpecialAccessor = true;
   Tok = Tokens->getNextToken();
   continue;
 }
@@ -1855,7 +1855,7 @@ bool UnwrappedLineParser::tryToParsePropertyAccessor() {
 break;
   }
 
-  if (!HasGetOrSet) {
+  if (!HasSpecialAccessor) {
 Tokens->setPosition(StoredPosition);
 return false;
   }
@@ -1897,7 +1897,8 @@ bool UnwrappedLineParser::tryToParse

[PATCH] D121132: [clang-format] Handle C# 9 `init` accessor specifier.

2022-03-08 Thread Marek Kurdej via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7a54fceb2562: [clang-format] Handle C# 9 `init` accessor 
specifier. (authored by curdeius).

Changed prior to commit:
  https://reviews.llvm.org/D121132?vs=413539&id=413763#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121132

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

Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -960,9 +960,11 @@
   verifyFormat("int Value { get; } = 0", Style);
   verifyFormat("int Value { set }", Style);
   verifyFormat("int Value { set; }", Style);
+  verifyFormat("int Value { init; }", Style);
   verifyFormat("int Value { internal set; }", Style);
   verifyFormat("int Value { set; } = 0", Style);
   verifyFormat("int Value { get; set }", Style);
+  verifyFormat("int Value { get; init; }", Style);
   verifyFormat("int Value { set; get }", Style);
   verifyFormat("int Value { get; private set; }", Style);
   verifyFormat("int Value { get; set; }", Style);
@@ -974,6 +976,18 @@
 public string Name {
   get => _name;
   set => _name = value;
+})",
+   Style);
+  verifyFormat(R"(//
+public string Name {
+  init => _name = value;
+  get => _name;
+})",
+   Style);
+  verifyFormat(R"(//
+public string Name {
+  set => _name = value;
+  get => _name;
 })",
Style);
 
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1837,16 +1837,16 @@
   FormatToken *Tok = Tokens->getNextToken();
 
   // A trivial property accessor is of the form:
-  // { [ACCESS_SPECIFIER] [get]; [ACCESS_SPECIFIER] [set] }
+  // { [ACCESS_SPECIFIER] [get]; [ACCESS_SPECIFIER] [set|init] }
   // Track these as they do not require line breaks to be introduced.
-  bool HasGetOrSet = false;
+  bool HasSpecialAccessor = false;
   bool IsTrivialPropertyAccessor = true;
   while (!eof()) {
 if (Tok->isOneOf(tok::semi, tok::kw_public, tok::kw_private,
  tok::kw_protected, Keywords.kw_internal, Keywords.kw_get,
- Keywords.kw_set)) {
-  if (Tok->isOneOf(Keywords.kw_get, Keywords.kw_set))
-HasGetOrSet = true;
+ Keywords.kw_init, Keywords.kw_set)) {
+  if (Tok->isOneOf(Keywords.kw_get, Keywords.kw_init, Keywords.kw_set))
+HasSpecialAccessor = true;
   Tok = Tokens->getNextToken();
   continue;
 }
@@ -1855,7 +1855,7 @@
 break;
   }
 
-  if (!HasGetOrSet) {
+  if (!HasSpecialAccessor) {
 Tokens->setPosition(StoredPosition);
 return false;
   }
@@ -1897,7 +1897,8 @@
   nextToken();
   break;
 default:
-  if (FormatTok->isOneOf(Keywords.kw_get, Keywords.kw_set) &&
+  if (FormatTok->isOneOf(Keywords.kw_get, Keywords.kw_init,
+ Keywords.kw_set) &&
   !IsTrivialPropertyAccessor) {
 // Non-trivial get/set needs to be on its own line.
 addUnwrappedLine();
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1652,7 +1652,7 @@
 Current.Previous->isOneOf(
 tok::kw_namespace, tok::r_paren, tok::r_square, tok::r_brace,
 tok::kw_false, tok::kw_true, Keywords.kw_type, Keywords.kw_get,
-Keywords.kw_set) ||
+Keywords.kw_init, Keywords.kw_set) ||
 Current.Previous->Tok.isLiteral()) {
   Current.setType(TT_NonNullAssertion);
   return;
Index: clang/lib/Format/FormatToken.h
===
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -954,6 +954,7 @@
 kw_event = &IdentTable.get("event");
 kw_fixed = &IdentTable.get("fixed");
 kw_foreach = &IdentTable.get("foreach");
+kw_init = &IdentTable.get("init");
 kw_implicit = &IdentTable.get("implicit");
 kw_internal = &IdentTable.get("internal");
 kw_lock = &IdentTable.get("lock");
@@ -986,11 +987,11 @@
 
 CSharpExtraKeywords = std::unordered_set(
 {kw_base, kw_byte, kw_checked, kw_decimal, kw_delegate, kw_event,
- kw_fixed, kw_foreach, kw_implicit, kw_in, kw_interface, kw_internal,
- kw_is, kw_lock, kw_null, kw_object, kw_out, kw_override, kw_params,
- kw_readonly, kw_ref, kw_string, kw_stackalloc, kw_sbyte, kw_sealed,
- kw_uint, kw_ulong, kw_unchecked, kw_unsafe, kw_ushort, k

[PATCH] D121198: [flang][driver] Add support for `-debug-dump-pft`

2022-03-08 Thread Shraiysh via Phabricator via cfe-commits
shraiysh accepted this revision.
shraiysh added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121198

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


[clang] f537a40 - [clang-format] Correctly detect `!` as TT_NonNullAssertion after `default`.

2022-03-08 Thread Marek Kurdej via cfe-commits

Author: Marek Kurdej
Date: 2022-03-08T13:35:26+01:00
New Revision: f537a409160dc1e506445724c5256bb116c0d71a

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

LOG: [clang-format] Correctly detect `!` as TT_NonNullAssertion after `default`.

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

Depends on D121132.

Reviewed By: HazardyKnusperkeks, owenpan

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

Added: 


Modified: 
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTestCSharp.cpp

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 236e9a73b33a8..8f5f4e0f43362 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -1650,9 +1650,9 @@ class AnnotatingParser {
 : Current.Previous->is(tok::identifier);
 if (IsIdentifier ||
 Current.Previous->isOneOf(
-tok::kw_namespace, tok::r_paren, tok::r_square, tok::r_brace,
-tok::kw_false, tok::kw_true, Keywords.kw_type, Keywords.kw_get,
-Keywords.kw_init, Keywords.kw_set) ||
+tok::kw_default, tok::kw_namespace, tok::r_paren, 
tok::r_square,
+tok::r_brace, tok::kw_false, tok::kw_true, Keywords.kw_type,
+Keywords.kw_get, Keywords.kw_init, Keywords.kw_set) ||
 Current.Previous->Tok.isLiteral()) {
   Current.setType(TT_NonNullAssertion);
   return;

diff  --git a/clang/unittests/Format/FormatTestCSharp.cpp 
b/clang/unittests/Format/FormatTestCSharp.cpp
index 2a7642012a5f9..aa0304f73fed4 100644
--- a/clang/unittests/Format/FormatTestCSharp.cpp
+++ b/clang/unittests/Format/FormatTestCSharp.cpp
@@ -1078,6 +1078,26 @@ public class SaleItem
MicrosoftStyle);
 }
 
+TEST_F(FormatTestCSharp, DefaultLiteral) {
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
+
+  verifyFormat(
+  "T[] InitializeArray(int length, T initialValue = default) {}", 
Style);
+  verifyFormat("System.Numerics.Complex fillValue = default;", Style);
+  verifyFormat("int Value { get } = default;", Style);
+  verifyFormat("int Value { get } = default!;", Style);
+  verifyFormat(R"(//
+public record Person {
+  public string GetInit { get; init; } = default!;
+};)",
+   Style);
+  verifyFormat(R"(//
+public record Person {
+  public string GetSet { get; set; } = default!;
+};)",
+   Style);
+}
+
 TEST_F(FormatTestCSharp, CSharpSpaces) {
   FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
   Style.SpaceBeforeSquareBrackets = false;



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


[PATCH] D121136: [clang-format] Correctly detect `!` as TT_NonNullAssertion after `default`.

2022-03-08 Thread Marek Kurdej via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf537a409160d: [clang-format] Correctly detect `!` as 
TT_NonNullAssertion after `default`. (authored by curdeius).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121136

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTestCSharp.cpp


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -1078,6 +1078,26 @@
MicrosoftStyle);
 }
 
+TEST_F(FormatTestCSharp, DefaultLiteral) {
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
+
+  verifyFormat(
+  "T[] InitializeArray(int length, T initialValue = default) {}", 
Style);
+  verifyFormat("System.Numerics.Complex fillValue = default;", Style);
+  verifyFormat("int Value { get } = default;", Style);
+  verifyFormat("int Value { get } = default!;", Style);
+  verifyFormat(R"(//
+public record Person {
+  public string GetInit { get; init; } = default!;
+};)",
+   Style);
+  verifyFormat(R"(//
+public record Person {
+  public string GetSet { get; set; } = default!;
+};)",
+   Style);
+}
+
 TEST_F(FormatTestCSharp, CSharpSpaces) {
   FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
   Style.SpaceBeforeSquareBrackets = false;
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1650,9 +1650,9 @@
 : Current.Previous->is(tok::identifier);
 if (IsIdentifier ||
 Current.Previous->isOneOf(
-tok::kw_namespace, tok::r_paren, tok::r_square, tok::r_brace,
-tok::kw_false, tok::kw_true, Keywords.kw_type, Keywords.kw_get,
-Keywords.kw_init, Keywords.kw_set) ||
+tok::kw_default, tok::kw_namespace, tok::r_paren, 
tok::r_square,
+tok::r_brace, tok::kw_false, tok::kw_true, Keywords.kw_type,
+Keywords.kw_get, Keywords.kw_init, Keywords.kw_set) ||
 Current.Previous->Tok.isLiteral()) {
   Current.setType(TT_NonNullAssertion);
   return;


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -1078,6 +1078,26 @@
MicrosoftStyle);
 }
 
+TEST_F(FormatTestCSharp, DefaultLiteral) {
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
+
+  verifyFormat(
+  "T[] InitializeArray(int length, T initialValue = default) {}", Style);
+  verifyFormat("System.Numerics.Complex fillValue = default;", Style);
+  verifyFormat("int Value { get } = default;", Style);
+  verifyFormat("int Value { get } = default!;", Style);
+  verifyFormat(R"(//
+public record Person {
+  public string GetInit { get; init; } = default!;
+};)",
+   Style);
+  verifyFormat(R"(//
+public record Person {
+  public string GetSet { get; set; } = default!;
+};)",
+   Style);
+}
+
 TEST_F(FormatTestCSharp, CSharpSpaces) {
   FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
   Style.SpaceBeforeSquareBrackets = false;
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1650,9 +1650,9 @@
 : Current.Previous->is(tok::identifier);
 if (IsIdentifier ||
 Current.Previous->isOneOf(
-tok::kw_namespace, tok::r_paren, tok::r_square, tok::r_brace,
-tok::kw_false, tok::kw_true, Keywords.kw_type, Keywords.kw_get,
-Keywords.kw_init, Keywords.kw_set) ||
+tok::kw_default, tok::kw_namespace, tok::r_paren, tok::r_square,
+tok::r_brace, tok::kw_false, tok::kw_true, Keywords.kw_type,
+Keywords.kw_get, Keywords.kw_init, Keywords.kw_set) ||
 Current.Previous->Tok.isLiteral()) {
   Current.setType(TT_NonNullAssertion);
   return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] d5106c8 - [clangd] NFC: Cleanup IncludeCleaner API

2022-03-08 Thread Kirill Bobyrev via cfe-commits

Author: Kirill Bobyrev
Date: 2022-03-08T13:43:25+01:00
New Revision: d5106c8f973b76e49d64ac3d91236efafd771c7c

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

LOG: [clangd] NFC: Cleanup IncludeCleaner API

Make a further improvement to decrease verbosity of the API: ASTContext
provides SourceManager access.

Reviewed By: sammccall

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

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/IncludeCleaner.cpp 
b/clang-tools-extra/clangd/IncludeCleaner.cpp
index 90dfb2b4a3501..04dbf12410cf7 100644
--- a/clang-tools-extra/clangd/IncludeCleaner.cpp
+++ b/clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -286,11 +286,11 @@ FileID headerResponsible(FileID ID, const SourceManager 
&SM,
 
 } // namespace
 
-ReferencedLocations findReferencedLocations(const SourceManager &SM,
-ASTContext &Ctx, Preprocessor &PP,
+ReferencedLocations findReferencedLocations(ASTContext &Ctx, Preprocessor &PP,
 const syntax::TokenBuffer *Tokens) 
{
   trace::Span Tracer("IncludeCleaner::findReferencedLocations");
   ReferencedLocations Result;
+  const auto &SM = Ctx.getSourceManager();
   ReferencedLocationCrawler Crawler(Result, SM);
   Crawler.TraverseAST(Ctx);
   if (Tokens)
@@ -299,8 +299,8 @@ ReferencedLocations findReferencedLocations(const 
SourceManager &SM,
 }
 
 ReferencedLocations findReferencedLocations(ParsedAST &AST) {
-  return findReferencedLocations(AST.getSourceManager(), AST.getASTContext(),
- AST.getPreprocessor(), &AST.getTokens());
+  return findReferencedLocations(AST.getASTContext(), AST.getPreprocessor(),
+ &AST.getTokens());
 }
 
 ReferencedFiles

diff  --git a/clang-tools-extra/clangd/IncludeCleaner.h 
b/clang-tools-extra/clangd/IncludeCleaner.h
index ad34e3d6facdf..183f84f2f3bfe 100644
--- a/clang-tools-extra/clangd/IncludeCleaner.h
+++ b/clang-tools-extra/clangd/IncludeCleaner.h
@@ -51,8 +51,7 @@ struct ReferencedLocations {
 /// - don't attempt to describe where symbols were referenced from in
 ///   ambiguous cases (e.g. implicitly used symbols, multiple declarations)
 /// - err on the side of reporting all possible locations
-ReferencedLocations findReferencedLocations(const SourceManager &SM,
-ASTContext &Ctx, Preprocessor &PP,
+ReferencedLocations findReferencedLocations(ASTContext &Ctx, Preprocessor &PP,
 const syntax::TokenBuffer *Tokens);
 ReferencedLocations findReferencedLocations(ParsedAST &AST);
 



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


[PATCH] D119842: [clangd] NFC: Cleanup IncludeCleaner API

2022-03-08 Thread Kirill Bobyrev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd5106c8f973b: [clangd] NFC: Cleanup IncludeCleaner API 
(authored by kbobyrev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119842

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


Index: clang-tools-extra/clangd/IncludeCleaner.h
===
--- clang-tools-extra/clangd/IncludeCleaner.h
+++ clang-tools-extra/clangd/IncludeCleaner.h
@@ -51,8 +51,7 @@
 /// - don't attempt to describe where symbols were referenced from in
 ///   ambiguous cases (e.g. implicitly used symbols, multiple declarations)
 /// - err on the side of reporting all possible locations
-ReferencedLocations findReferencedLocations(const SourceManager &SM,
-ASTContext &Ctx, Preprocessor &PP,
+ReferencedLocations findReferencedLocations(ASTContext &Ctx, Preprocessor &PP,
 const syntax::TokenBuffer *Tokens);
 ReferencedLocations findReferencedLocations(ParsedAST &AST);
 
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -286,11 +286,11 @@
 
 } // namespace
 
-ReferencedLocations findReferencedLocations(const SourceManager &SM,
-ASTContext &Ctx, Preprocessor &PP,
+ReferencedLocations findReferencedLocations(ASTContext &Ctx, Preprocessor &PP,
 const syntax::TokenBuffer *Tokens) 
{
   trace::Span Tracer("IncludeCleaner::findReferencedLocations");
   ReferencedLocations Result;
+  const auto &SM = Ctx.getSourceManager();
   ReferencedLocationCrawler Crawler(Result, SM);
   Crawler.TraverseAST(Ctx);
   if (Tokens)
@@ -299,8 +299,8 @@
 }
 
 ReferencedLocations findReferencedLocations(ParsedAST &AST) {
-  return findReferencedLocations(AST.getSourceManager(), AST.getASTContext(),
- AST.getPreprocessor(), &AST.getTokens());
+  return findReferencedLocations(AST.getASTContext(), AST.getPreprocessor(),
+ &AST.getTokens());
 }
 
 ReferencedFiles


Index: clang-tools-extra/clangd/IncludeCleaner.h
===
--- clang-tools-extra/clangd/IncludeCleaner.h
+++ clang-tools-extra/clangd/IncludeCleaner.h
@@ -51,8 +51,7 @@
 /// - don't attempt to describe where symbols were referenced from in
 ///   ambiguous cases (e.g. implicitly used symbols, multiple declarations)
 /// - err on the side of reporting all possible locations
-ReferencedLocations findReferencedLocations(const SourceManager &SM,
-ASTContext &Ctx, Preprocessor &PP,
+ReferencedLocations findReferencedLocations(ASTContext &Ctx, Preprocessor &PP,
 const syntax::TokenBuffer *Tokens);
 ReferencedLocations findReferencedLocations(ParsedAST &AST);
 
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -286,11 +286,11 @@
 
 } // namespace
 
-ReferencedLocations findReferencedLocations(const SourceManager &SM,
-ASTContext &Ctx, Preprocessor &PP,
+ReferencedLocations findReferencedLocations(ASTContext &Ctx, Preprocessor &PP,
 const syntax::TokenBuffer *Tokens) {
   trace::Span Tracer("IncludeCleaner::findReferencedLocations");
   ReferencedLocations Result;
+  const auto &SM = Ctx.getSourceManager();
   ReferencedLocationCrawler Crawler(Result, SM);
   Crawler.TraverseAST(Ctx);
   if (Tokens)
@@ -299,8 +299,8 @@
 }
 
 ReferencedLocations findReferencedLocations(ParsedAST &AST) {
-  return findReferencedLocations(AST.getSourceManager(), AST.getASTContext(),
- AST.getPreprocessor(), &AST.getTokens());
+  return findReferencedLocations(AST.getASTContext(), AST.getPreprocessor(),
+ &AST.getTokens());
 }
 
 ReferencedFiles
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121206: [AARCH64] ssbs should be enabled by default for cortex-x1c

2022-03-08 Thread Dave Green via Phabricator via cfe-commits
dmgreen added inline comments.



Comment at: llvm/lib/Target/AArch64/AArch64.td:978
  FeatureNEON, FeatureRCPC, FeaturePerfMon,
  FeatureSPE, FeatureFullFP16, FeatureDotProd];
   list X1C  = [HasV8_2aOps, FeatureCrypto, FeatureFPARMv8,

X1 and A77 missing SSBS too. Should they be added at the same time?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121206

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


[PATCH] D112906: [PowerPC] Emit warning for ieeelongdouble on older GNU toolchain

2022-03-08 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.
Herald added a project: All.

Hi @qiucf,

I'm running into a problem with the testsuite that's caused by this patch. I 
think the comment from @jsji about newer glibc was never addressed.

When running the testsuite on ppc64le with a glibc newer than 2.34, the the 
warning mentioned in `ppc-float-abi-warning.cpp` is not emitted when using 
libstdc++.

In `PPCLinuxToolChain::SupportIEEEFloat128()`:

  bool HasUnsupportedCXXLib =
  ToolChain::GetCXXStdlibType(Args) == CST_Libcxx &&
  GCCInstallation.getVersion().isOlderThan(12, 1, 0);
  
  return GlibcSupportsFloat128(Linux::getDynamicLinker(Args)) &&
 !(D.CCCIsCXX() && HasUnsupportedCXXLib);

When using libstdc++, `HasUnsupportedCXXLib` will always be `false` since it's 
not `CST_Libcxx`...

I don't understand the `HasUnsupportedCXXLib` variable tbh, is there a typo in 
the stdlib check, or in a `&&`/`||` mixup?
Right now it is only `true` if we're using libc++ //and// the GCC installation 
is older than 12.1.0.

I will try one approach in the meantime, but your opinion would be appreciated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112906

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


[PATCH] D120244: [clang][sema] Enable first-class bool support for C2x

2022-03-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D120244#3362215 , @tbaeder wrote:

> Thanks for the links to the papers. What's the best way of updating 
> https://clang.llvm.org/c_status.html#c2x with the new papers?

I update that page from the WG14 editor's report (or the latest working draft) 
so that I can be sure we're tracking what actually made it into the standard. 
I'll try to get it right when I add these papers to the list, but you may want 
to keep your eyes peeled when I update the page to double-check just in case.

> I added the changes to `stdbool.h`, but I haven't been able to come up with a 
> good way of testing them...

I think stdbool.h should get a deprecation warning, and that will make it 
testable. e.g., 
https://github.com/llvm/llvm-project/blob/main/clang/lib/Headers/stdnoreturn.h#L16




Comment at: clang/lib/Headers/stdbool.h:13-14
 
+/* true, false and bool are first-class keywords in C2x */
+#if __STDC_VERSION__ < 202000L
 /* Don't define bool, true, and false in C++, except as a GNU extension. */

FWIW, I've been using `__STDC_VERSION__ > 201710L` for my C2x predicates. My 
plan was to switch them to use the C2x `__STDC_VERSION__` value once that's 
been finalized. Either approach works though.



Comment at: clang/lib/Headers/stdbool.h:16
 /* Don't define bool, true, and false in C++, except as a GNU extension. */
 #ifndef __cplusplus
 #define bool _Bool

We're inside an `#if __STDC_VERSION__` check here, so I think this will now 
always evaluate to true.



Comment at: clang/lib/Headers/stdbool.h:23-28
 #if __cplusplus < 201103L
 /* For C++98, define bool, false, true as a GNU extension. */
-#define bool  bool
+#define bool bool
 #define false false
-#define true  true
+#define true true
+#endif

This seems wrong now too.


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

https://reviews.llvm.org/D120244

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


[PATCH] D120639: [RISCV] Pass -mno-relax to assembler when -fno-integrated-as specified

2022-03-08 Thread luxufan via Phabricator via cfe-commits
StephenFan updated this revision to Diff 413774.
StephenFan added a comment.

Address @kito-cheng 's comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120639

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/riscv-gnutools.c


Index: clang/test/Driver/riscv-gnutools.c
===
--- clang/test/Driver/riscv-gnutools.c
+++ clang/test/Driver/riscv-gnutools.c
@@ -16,9 +16,14 @@
 // RUN: %clang -target riscv32 --gcc-toolchain=%S/Inputs/basic_riscv32_tree 
-fno-integrated-as %s -### -c -march=rv32g \
 // RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV32G-ILP32D %s
 
+// Check -mno-relax has passed when -fno-integrated-as specified
+// RUN: %clang -target riscv32 --gcc-toolchain=%S/Inputs/basic_riscv32_tree 
-mno-relax -fno-integrated-as %s -### -c \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV32-NO-RELAX %s
+
 // CHECK-RV32IMAC-ILP32: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32" "-march" 
"rv32imac"
 // CHECK-RV32IMAFDC-ILP32D: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32d" "-march" 
"rv32imafdc"
 // CHECK-RV32G-ILP32D: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32d" "-march" "rv32g"
+// CHECK-RV32-NO-RELAX: "{{.*}}as{{(.exe)?}}" "{{.*}}" "-mno-relax"
 
 
 // 64-bit checks
@@ -35,6 +40,11 @@
 // RUN: %clang -target riscv64 --gcc-toolchain=%S/Inputs/basic_riscv64_tree 
-fno-integrated-as %s -### -c -march=rv64g \
 // RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV64G-LP64D %s
 
+// Check -mno-relax has passed when -fno-integrated-as specified
+// RUN: %clang -target riscv64 --gcc-toolchain=%S/Inputs/basic_riscv64_tree 
-mno-relax -fno-integrated-as %s -### -c \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV64-NO-RELAX %s
+
 // CHECK-RV64IMAC-LP64: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64" "-march" 
"rv64imac"
 // CHECK-RV64IMAFDC-LP64D: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64d" "-march" 
"rv64imafdc"
 // CHECK-RV64G-LP64D: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64d" "-march" "rv64g"
+// CHECK-RV64-NO-RELAX: "{{.*}}as{{(.exe)?}}" "{{.*}}" "-mno-relax"
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -761,6 +761,8 @@
 StringRef MArchName = riscv::getRISCVArch(Args, 
getToolChain().getTriple());
 CmdArgs.push_back("-march");
 CmdArgs.push_back(MArchName.data());
+if (!Args.hasFlag(options::OPT_mrelax, options::OPT_mno_relax))
+  CmdArgs.push_back("-mno-relax");
 break;
   }
   case llvm::Triple::sparc:


Index: clang/test/Driver/riscv-gnutools.c
===
--- clang/test/Driver/riscv-gnutools.c
+++ clang/test/Driver/riscv-gnutools.c
@@ -16,9 +16,14 @@
 // RUN: %clang -target riscv32 --gcc-toolchain=%S/Inputs/basic_riscv32_tree -fno-integrated-as %s -### -c -march=rv32g \
 // RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV32G-ILP32D %s
 
+// Check -mno-relax has passed when -fno-integrated-as specified
+// RUN: %clang -target riscv32 --gcc-toolchain=%S/Inputs/basic_riscv32_tree -mno-relax -fno-integrated-as %s -### -c \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV32-NO-RELAX %s
+
 // CHECK-RV32IMAC-ILP32: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32" "-march" "rv32imac"
 // CHECK-RV32IMAFDC-ILP32D: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32d" "-march" "rv32imafdc"
 // CHECK-RV32G-ILP32D: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32d" "-march" "rv32g"
+// CHECK-RV32-NO-RELAX: "{{.*}}as{{(.exe)?}}" "{{.*}}" "-mno-relax"
 
 
 // 64-bit checks
@@ -35,6 +40,11 @@
 // RUN: %clang -target riscv64 --gcc-toolchain=%S/Inputs/basic_riscv64_tree -fno-integrated-as %s -### -c -march=rv64g \
 // RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV64G-LP64D %s
 
+// Check -mno-relax has passed when -fno-integrated-as specified
+// RUN: %clang -target riscv64 --gcc-toolchain=%S/Inputs/basic_riscv64_tree -mno-relax -fno-integrated-as %s -### -c \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV64-NO-RELAX %s
+
 // CHECK-RV64IMAC-LP64: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64" "-march" "rv64imac"
 // CHECK-RV64IMAFDC-LP64D: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64d" "-march" "rv64imafdc"
 // CHECK-RV64G-LP64D: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64d" "-march" "rv64g"
+// CHECK-RV64-NO-RELAX: "{{.*}}as{{(.exe)?}}" "{{.*}}" "-mno-relax"
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -761,6 +761,8 @@
 StringRef MArchName = riscv::getRISCVArch(Args, getToolChain().getTriple());
 CmdArgs.push_back("-march");
 CmdArgs.push_back(MArchName.data());
+if (!Args.hasFlag(options::OPT_mrelax, options::OPT_mno_relax))
+  CmdArgs.push_back("-mno-relax");
 break;
   }
   case llvm::Triple::sparc:
___
cfe-commits mailing list
cfe-commi

[PATCH] D121209: [clang][driver] Fix float128 diagnostics with glibc >= 2.32

2022-03-08 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: qiucf, jsji, kbarton.
Herald added a subscriber: nemanjai.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

As explained in https://reviews.llvm.org/D112906#3366874, the check here seems 
broken and the tests failed when run on a machine with a glibc >= 2.32 
installed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121209

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


Index: clang/lib/Driver/ToolChains/PPCLinux.cpp
===
--- clang/lib/Driver/ToolChains/PPCLinux.cpp
+++ clang/lib/Driver/ToolChains/PPCLinux.cpp
@@ -76,9 +76,11 @@
   if (Args.hasArg(options::OPT_nostdlib, options::OPT_nostdlibxx))
 return true;
 
+  CXXStdlibType StdLib = ToolChain::GetCXXStdlibType(Args);
   bool HasUnsupportedCXXLib =
-  ToolChain::GetCXXStdlibType(Args) == CST_Libcxx &&
-  GCCInstallation.getVersion().isOlderThan(12, 1, 0);
+  StdLib == CST_Libcxx ||
+  (StdLib == CST_Libstdcxx &&
+   GCCInstallation.getVersion().isOlderThan(12, 1, 0));
 
   return GlibcSupportsFloat128(Linux::getDynamicLinker(Args)) &&
  !(D.CCCIsCXX() && HasUnsupportedCXXLib);


Index: clang/lib/Driver/ToolChains/PPCLinux.cpp
===
--- clang/lib/Driver/ToolChains/PPCLinux.cpp
+++ clang/lib/Driver/ToolChains/PPCLinux.cpp
@@ -76,9 +76,11 @@
   if (Args.hasArg(options::OPT_nostdlib, options::OPT_nostdlibxx))
 return true;
 
+  CXXStdlibType StdLib = ToolChain::GetCXXStdlibType(Args);
   bool HasUnsupportedCXXLib =
-  ToolChain::GetCXXStdlibType(Args) == CST_Libcxx &&
-  GCCInstallation.getVersion().isOlderThan(12, 1, 0);
+  StdLib == CST_Libcxx ||
+  (StdLib == CST_Libstdcxx &&
+   GCCInstallation.getVersion().isOlderThan(12, 1, 0));
 
   return GlibcSupportsFloat128(Linux::getDynamicLinker(Args)) &&
  !(D.CCCIsCXX() && HasUnsupportedCXXLib);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121206: [AARCH64] ssbs should be enabled by default for cortex-x1c

2022-03-08 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett added inline comments.



Comment at: clang/test/Preprocessor/aarch64-target-features.c:288
 // CHECK-MCPU-CORTEX-A73: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" 
"-target-feature" "+v8a" "-target-feature" "+fp-armv8" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
-// CHECK-MCPU-CORTEX-R82: "-cc1"{{.*}} "-triple" "aarch64{{.*}}"  
"-target-feature" "+v8r" "-target-feature" "+fp-armv8" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+dotprod" "-target-feature" 
"+fp16fml" "-target-feature" "+ras" "-target-feature" "+lse" "-target-feature" 
"+rdm" "-target-feature" "+rcpc" "-target-feature" "+fullfp16"
+// CHECK-MCPU-CORTEX-R82: "-cc1"{{.*}} "-triple" "aarch64{{.*}}"  
"-target-feature" "+v8r" "-target-feature" "+fp-armv8" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+dotprod" "-target-feature" 
"+fp16fml" "-target-feature" "+ras" "-target-feature" "+lse" "-target-feature" 
"+rdm" "-target-feature" "+rcpc" "-target-feature" "+ssbs" "-target-feature" 
"+fullfp16"
 // CHECK-MCPU-M3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+v8a" "-target-feature" "+fp-armv8" "-target-feature" "+neon" 
"-target-feature" "+crc" "-target-feature" "+crypto"

Why did this change, was it just not correct before or is r82 some equivalent 
of the x1c?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121206

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


[PATCH] D119609: [Clang][Sema] Don't act on ReturnStmt when parsing the lambda declarator.

2022-03-08 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/test/Sema/err-expr-stmt-in-default-arg.cpp:19
+  return bar(l);
+}

junaire wrote:
> erichkeane wrote:
> > For completeness, I'd like to see an 
> > in-function-defined-struct-member-function test here as well.
> > 
> > As for the above question about the recovery, something like:
> > 
> > `void fn(int i, int j = ({ {},{},{,} }), int k = "");` I think checks all 
> > the issues I can think of.  We want to make sure that 'k' still diagnoses 
> > its error correctly (and that we have just skipped all of the expression 
> > statement stuff).
> Note that clang is already rejected the code: https://godbolt.org/z/57c4qaaPo
> 
I more mean an example like this one:
https://godbolt.org/z/nf7W1zznh

I see that we already reject it, however you are doing a 'skip until' here, and 
I want to make sure that the error on 'k' diagnoses correctly still. 

With your change, I would expect the 1st two errors there to go away and be 
replaced by your new error.  BUT the 'k' type would still be there.

The point of this is to make sure that your error doesn't leave the parser in a 
'bad' state.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119609

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


[PATCH] D119609: [Clang][Sema] Don't act on ReturnStmt when parsing the lambda declarator.

2022-03-08 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Also, please update the commit-message/title to better reflect the change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119609

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


[PATCH] D120244: [clang][sema] Enable first-class bool support for C2x

2022-03-08 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 413782.

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

https://reviews.llvm.org/D120244

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Headers/stdbool.h
  clang/test/Headers/stdbool.c
  clang/test/Sema/c2x-bool.c

Index: clang/test/Sema/c2x-bool.c
===
--- /dev/null
+++ clang/test/Sema/c2x-bool.c
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -std=c2x -fsyntax-only -verify %s
+
+_Static_assert(_Generic(true, _Bool : 1, default: 0));
+_Static_assert(_Generic(false, _Bool : 1, default: 0));
+
+_Static_assert(_Generic(true, bool : 1, default: 0));
+_Static_assert(_Generic(false, bool : 1, default: 0));
+
+_Static_assert(_Generic(true, bool : true, default: false));
+_Static_assert(_Generic(false, bool : true, default: false));
+
+_Static_assert(true == (bool)+1);
+_Static_assert(false == (bool)+0);
+
+_Static_assert(_Generic(+true, bool : 0, unsigned int : 0, signed int : 1, default : 0));
+
+struct S {
+  bool b : 1;
+} s;
+_Static_assert(_Generic(+s.b, bool : 0, unsigned int : 0, signed int : 1, default : 0));
+
+static void *f = false; // expected-warning {{to null from a constant boolean expression}}
+static int one = true;
+static int zero = false;
+
+static void do_work() {
+  char *str = "Foo";
+  str[false] = 'f';
+  str[true] = 'f';
+
+  char c1[true];
+  char c2[false];
+}
+
+#if true != 1
+#error true should be 1 in the preprocessor
+#endif
+
+#if false != 0
+#error false should be 0 in the preprocessor
+#endif
Index: clang/test/Headers/stdbool.c
===
--- /dev/null
+++ clang/test/Headers/stdbool.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fgnuc-version=4.2.1 -std=c11 -E -dM %s 2>&1 | FileCheck --check-prefix=CHECK-C11 %s
+// RUN: %clang_cc1 -fgnuc-version=4.2.1 -std=c2x -E -dM %s 2>&1 | FileCheck --check-prefix=CHECK-C2X %s
+
+#include 
+
+// CHECK-C11: #define bool _Bool
+// CHECK-C11: #define false 0
+// CHECK-C11: #define true 1
+
+// CHECK-C2X: warning "the  header is deprecated
+// CHECK-C2X-NOT: #define bool
+// CHECK-C2X-NOT: #define true
+// CHECK-C2X-NOT: #define false
Index: clang/lib/Headers/stdbool.h
===
--- clang/lib/Headers/stdbool.h
+++ clang/lib/Headers/stdbool.h
@@ -10,8 +10,13 @@
 #ifndef __STDBOOL_H
 #define __STDBOOL_H
 
-/* Don't define bool, true, and false in C++, except as a GNU extension. */
-#ifndef __cplusplus
+#define __bool_true_false_are_defined 1
+
+#if __STDC_VERSION__ > 201710L &&  \
+!defined(_CLANG_DISABLE_CRT_DEPRECATION_WARNINGS)
+#warning   \
+"the  header is deprecated in C2x. bool, true and false can be used without it."
+#elif !defined(__cplusplus)
 #define bool _Bool
 #define true 1
 #define false 0
@@ -20,12 +25,10 @@
 #define _Bool bool
 #if __cplusplus < 201103L
 /* For C++98, define bool, false, true as a GNU extension. */
-#define bool  bool
+#define bool bool
 #define false false
-#define true  true
+#define true true
 #endif
 #endif
 
-#define __bool_true_false_are_defined 1
-
 #endif /* __STDBOOL_H */
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3249,8 +3249,8 @@
 
   Opts.RenderScript = IK.getLanguage() == Language::RenderScript;
 
-  // OpenCL and C++ both have bool, true, false keywords.
-  Opts.Bool = Opts.OpenCL || Opts.CPlusPlus;
+  // OpenCL, C++ and C2x have bool, true, false keywords.
+  Opts.Bool = Opts.OpenCL || Opts.CPlusPlus || Opts.C2x;
 
   // OpenCL has half keyword
   Opts.Half = Opts.OpenCL;
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -110,6 +110,7 @@
 ---
 
 - Implemented `WG14 N2674 The noreturn attribute `_.
+- Implemented `WG14 N2935 Make false and true first-class language features `_.
 
 C++ Language Changes in Clang
 -
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D120244: [clang][sema] Enable first-class bool support for C2x

2022-03-08 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder marked 2 inline comments as done.
tbaeder added inline comments.



Comment at: clang/lib/Headers/stdbool.h:16
 /* Don't define bool, true, and false in C++, except as a GNU extension. */
 #ifndef __cplusplus
 #define bool _Bool

aaron.ballman wrote:
> We're inside an `#if __STDC_VERSION__` check here, so I think this will now 
> always evaluate to true.
Not being able to indent preprocessor directives at all makes this pretty hard 
to read, but it should work like this.


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

https://reviews.llvm.org/D120244

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


[PATCH] D121211: Properly diagnose constant evaluation issues at TU scope

2022-03-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman created this revision.
aaron.ballman added reviewers: cor3ntin, erichkeane, bruno, rsmith.
Herald added a project: All.
aaron.ballman requested review of this revision.
Herald added a project: clang.

We were not creating an evaluation context for the TU scope, so we never popped 
an evaluation context for it. Popping the evaluation context triggers a number 
of diagnostics, including warnings about immediate invocations that we were 
previously missing.

Note: I think we have an additional issue that we should solve, but not as part 
of this patch. I don't think Clang is properly modeling static initialization 
as happening before constant expression evaluation. I think structure members 
members are zero initialized per http://eel.is/c++draft/basic.start.static#1, 
https://eel.is/c++draft/basic.start.static#2.sentence-2, and 
http://eel.is/c++draft/dcl.init#general-6.2 and the new test case actually 
should be accepted. However, it's also worth noting that other compilers behave 
the way this patch makes Clang behave: https://godbolt.org/z/T7noqhdPr


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121211

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Parse/ParseAST.cpp
  clang/test/SemaCXX/cxx2a-consteval.cpp


Index: clang/test/SemaCXX/cxx2a-consteval.cpp
===
--- clang/test/SemaCXX/cxx2a-consteval.cpp
+++ clang/test/SemaCXX/cxx2a-consteval.cpp
@@ -689,3 +689,13 @@
   }
 };
 } // PR48235
+
+namespace NamespaceScopeConsteval {
+struct S {
+  int Val; // expected-note {{subobject declared here}}
+  consteval S() {}
+};
+
+S s; // expected-error {{call to consteval function 
'NamespaceScopeConsteval::S::S' is not a constant expression}} \
+expected-note {{subobject of type 'int' is not initialized}}
+} // namespace NamespaceScopeConsteval
Index: clang/lib/Parse/ParseAST.cpp
===
--- clang/lib/Parse/ParseAST.cpp
+++ clang/lib/Parse/ParseAST.cpp
@@ -155,6 +155,9 @@
 P.Initialize();
 Parser::DeclGroupPtrTy ADecl;
 Sema::ModuleImportState ImportState;
+EnterExpressionEvaluationContext PotentiallyEvaluated(
+S, Sema::ExpressionEvaluationContext::PotentiallyEvaluated);
+
 for (bool AtEOF = P.ParseFirstTopLevelDecl(ADecl, ImportState); !AtEOF;
  AtEOF = P.ParseTopLevelDecl(ADecl, ImportState)) {
   // If we got a null return and something *was* parsed, ignore it.  This
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -118,6 +118,8 @@
 
 C++20 Feature Support
 ^
+- Diagnose consteval and constexpr issues that happen at namespace scope. This
+  partially addresses `Issue 51593 
`_.
 
 C++2b Feature Support
 ^


Index: clang/test/SemaCXX/cxx2a-consteval.cpp
===
--- clang/test/SemaCXX/cxx2a-consteval.cpp
+++ clang/test/SemaCXX/cxx2a-consteval.cpp
@@ -689,3 +689,13 @@
   }
 };
 } // PR48235
+
+namespace NamespaceScopeConsteval {
+struct S {
+  int Val; // expected-note {{subobject declared here}}
+  consteval S() {}
+};
+
+S s; // expected-error {{call to consteval function 'NamespaceScopeConsteval::S::S' is not a constant expression}} \
+expected-note {{subobject of type 'int' is not initialized}}
+} // namespace NamespaceScopeConsteval
Index: clang/lib/Parse/ParseAST.cpp
===
--- clang/lib/Parse/ParseAST.cpp
+++ clang/lib/Parse/ParseAST.cpp
@@ -155,6 +155,9 @@
 P.Initialize();
 Parser::DeclGroupPtrTy ADecl;
 Sema::ModuleImportState ImportState;
+EnterExpressionEvaluationContext PotentiallyEvaluated(
+S, Sema::ExpressionEvaluationContext::PotentiallyEvaluated);
+
 for (bool AtEOF = P.ParseFirstTopLevelDecl(ADecl, ImportState); !AtEOF;
  AtEOF = P.ParseTopLevelDecl(ADecl, ImportState)) {
   // If we got a null return and something *was* parsed, ignore it.  This
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -118,6 +118,8 @@
 
 C++20 Feature Support
 ^
+- Diagnose consteval and constexpr issues that happen at namespace scope. This
+  partially addresses `Issue 51593 `_.
 
 C++2b Feature Support
 ^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121209: [clang][driver] Fix float128 diagnostics with glibc >= 2.32

2022-03-08 Thread Qiu Chaofan via Phabricator via cfe-commits
qiucf accepted this revision.
qiucf added a comment.
This revision is now accepted and ready to land.

LGTM, thanks for the catch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121209

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


[PATCH] D120770: [C2x] Implement literal suffixes for _BitInt

2022-03-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

If there aren't additional review comments, I plan to land this tomorrow. Any 
comments that come in after that are ones I'm happy to address post-commit.


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

https://reviews.llvm.org/D120770

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


[clang] 21e16ab - [clang][ABI] New C++20 module mangling scheme

2022-03-08 Thread Nathan Sidwell via cfe-commits

Author: Nathan Sidwell
Date: 2022-03-08T06:21:50-08:00
New Revision: 21e16ab6b8ddaccb70d2344bb35419e214a32ec9

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

LOG: [clang][ABI] New C++20 module mangling scheme

The existing module symbol mangling scheme turns out to be
undemangleable.  It is also desirable to switch to the
strong-ownership model as the hoped-for C++17 compatibility turns out
to be fragile, and we also now have a better way of controlling that.

The issue is captured on the ABI list at:
  https://github.com/itanium-cxx-abi/cxx-abi/issues/134

A document describing the issues and new mangling is at:
  https://drive.google.com/file/d/1qQjqptzOFT_lfXH8L6-iD9nCRi34wjft/view

This patch is the code-generation part.  I have a demangler too, but
that patch is based on some to-be-landed refactoring of the demangler.

The old mangling is unceremoniously dropped.  No backwards
compatibility, no deprectated old-mangling flag.  It was always
labelled experimental.  (Old and new manglings cannot be confused.)

Reviewed By: ChuanqiXu

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

Added: 
clang/test/CodeGenCXX/Inputs/cxx20-module-impl-1a.cpp
clang/test/CodeGenCXX/Inputs/cxx20-module-std-subst-2a.cpp
clang/test/CodeGenCXX/cxx20-module-decomp-1.cpp
clang/test/CodeGenCXX/cxx20-module-extern-1.cppm
clang/test/CodeGenCXX/cxx20-module-impl-1a.cpp
clang/test/CodeGenCXX/cxx20-module-nested-1.cppm
clang/test/CodeGenCXX/cxx20-module-nested-2.cppm
clang/test/CodeGenCXX/cxx20-module-part-1a.cpp
clang/test/CodeGenCXX/cxx20-module-part-1b.cpp
clang/test/CodeGenCXX/cxx20-module-part-1c.cpp
clang/test/CodeGenCXX/cxx20-module-std-subst-1.cppm
clang/test/CodeGenCXX/cxx20-module-std-subst-2b.cpp
clang/test/CodeGenCXX/cxx20-module-std-subst-2c.cpp
clang/test/CodeGenCXX/cxx20-module-sub-1a.cppm
clang/test/CodeGenCXX/cxx20-module-sub-1b.cppm
clang/test/CodeGenCXX/cxx20-module-tmpl-1.cppm

Modified: 
clang/include/clang/AST/Mangle.h
clang/lib/AST/Decl.cpp
clang/lib/AST/ItaniumMangle.cpp
clang/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp
clang/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cppm
clang/test/CXX/modules-ts/basic/basic.def.odr/p4/user.cpp
clang/test/CXX/modules-ts/basic/basic.link/p3.cppm
clang/test/CXX/modules-ts/codegen-basics.cppm

Removed: 




diff  --git a/clang/include/clang/AST/Mangle.h 
b/clang/include/clang/AST/Mangle.h
index 7d02f08e0120c..c594c9809fef6 100644
--- a/clang/include/clang/AST/Mangle.h
+++ b/clang/include/clang/AST/Mangle.h
@@ -194,6 +194,8 @@ class ItaniumMangleContext : public MangleContext {
 
   virtual void mangleDynamicStermFinalizer(const VarDecl *D, raw_ostream &) = 
0;
 
+  virtual void mangleModuleInitializer(const Module *Module, raw_ostream &) = 
0;
+
   // This has to live here, otherwise the CXXNameMangler won't have access to
   // it.
   virtual DiscriminatorOverrideTy getDiscriminatorOverride() const = 0;

diff  --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 82c4412296dbc..9b8d0f6e288e7 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -1540,6 +1540,11 @@ LinkageInfo 
LinkageComputer::getDeclLinkageAndVisibility(const NamedDecl *D) {
 }
 
 Module *Decl::getOwningModuleForLinkage(bool IgnoreLinkage) const {
+  if (isa(this))
+// Namespaces never have module linkage.  It is the entities within them
+// that [may] do.
+return nullptr;
+
   Module *M = getOwningModule();
   if (!M)
 return nullptr;

diff  --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index d1d7a7c40ceb9..1f78142044c8f 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -130,6 +130,8 @@ class ItaniumMangleContextImpl : public 
ItaniumMangleContext {
 
   void mangleLambdaSig(const CXXRecordDecl *Lambda, raw_ostream &) override;
 
+  void mangleModuleInitializer(const Module *Module, raw_ostream &) override;
+
   bool getNextDiscriminator(const NamedDecl *ND, unsigned &disc) {
 // Lambda closure types are already numbered.
 if (isLambda(ND))
@@ -438,6 +440,7 @@ class CXXNameMangler {
   void mangleType(QualType T);
   void mangleNameOrStandardSubstitution(const NamedDecl *ND);
   void mangleLambdaSig(const CXXRecordDecl *Lambda);
+  void mangleModuleNamePrefix(StringRef Name, bool IsPartition = false);
 
 private:
 
@@ -473,22 +476,21 @@ class CXXNameMangler {
 
   void mangleNameWithAbiTags(GlobalDecl GD,
  const AbiTagList *AdditionalAbiTags);
-  void mangleModuleName(const Module *M);
-  void mangleModuleNamePrefix(StringRef Name);
+  void mangleModuleName(const NamedDecl *ND);
   void mangleTemplateName(const TemplateDecl *TD,
 

[PATCH] D118352: [clang][ABI] New c++20 modules mangling scheme

2022-03-08 Thread Nathan Sidwell via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG21e16ab6b8dd: [clang][ABI] New C++20 module mangling scheme 
(authored by urnathan).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118352

Files:
  clang/include/clang/AST/Mangle.h
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp
  clang/test/CXX/modules-ts/basic/basic.def.odr/p4/module.cppm
  clang/test/CXX/modules-ts/basic/basic.def.odr/p4/user.cpp
  clang/test/CXX/modules-ts/basic/basic.link/p3.cppm
  clang/test/CXX/modules-ts/codegen-basics.cppm
  clang/test/CodeGenCXX/Inputs/cxx20-module-impl-1a.cpp
  clang/test/CodeGenCXX/Inputs/cxx20-module-std-subst-2a.cpp
  clang/test/CodeGenCXX/cxx20-module-decomp-1.cpp
  clang/test/CodeGenCXX/cxx20-module-extern-1.cppm
  clang/test/CodeGenCXX/cxx20-module-impl-1a.cpp
  clang/test/CodeGenCXX/cxx20-module-nested-1.cppm
  clang/test/CodeGenCXX/cxx20-module-nested-2.cppm
  clang/test/CodeGenCXX/cxx20-module-part-1a.cpp
  clang/test/CodeGenCXX/cxx20-module-part-1b.cpp
  clang/test/CodeGenCXX/cxx20-module-part-1c.cpp
  clang/test/CodeGenCXX/cxx20-module-std-subst-1.cppm
  clang/test/CodeGenCXX/cxx20-module-std-subst-2b.cpp
  clang/test/CodeGenCXX/cxx20-module-std-subst-2c.cpp
  clang/test/CodeGenCXX/cxx20-module-sub-1a.cppm
  clang/test/CodeGenCXX/cxx20-module-sub-1b.cppm
  clang/test/CodeGenCXX/cxx20-module-tmpl-1.cppm

Index: clang/test/CodeGenCXX/cxx20-module-tmpl-1.cppm
===
--- /dev/null
+++ clang/test/CodeGenCXX/cxx20-module-tmpl-1.cppm
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -std=c++20 %s -triple %itanium_abi_triple -emit-llvm -o - | FileCheck %s
+
+export module FOO;
+
+class One;
+class Two;
+
+export template struct TPL
+{
+void M (T *);
+template void N (T *, U*);
+};
+
+template
+void TPL::M (T *) {}
+
+template template void TPL::N (T *, U*) {}
+
+// CHECK-DAG: void @_ZNW3FOO3TPLIS_3OneE1MEPS1_(
+template void TPL::M (One *);
+// CHECK-DAG: void @_ZNW3FOO3TPLIS_3OneE1NIS_3TwoEEvPS1_PT_(
+template void TPL::N (One *, Two *);
+
+namespace NMS {
+class One;
+class Two;
+
+export template struct TPL
+{
+void M (T *);
+template void N (T *, U*);
+};
+
+template
+void TPL::M (T *) {}
+
+template template void TPL::N (T *, U*) {}
+
+// CHECK-DAG: void @_ZN3NMSW3FOO3TPLINS_S0_3OneEE1MEPS2_(
+template void TPL::M (One *);
+// CHECK-DAG: void @_ZN3NMSW3FOO3TPLINS_S0_3OneEE1NINS_S0_3TwoEEEvPS2_PT_
+template void TPL::N (One *, Two *);
+}
Index: clang/test/CodeGenCXX/cxx20-module-sub-1b.cppm
===
--- /dev/null
+++ clang/test/CodeGenCXX/cxx20-module-sub-1b.cppm
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -std=c++20 %S/cxx20-module-sub-1a.cppm -triple %itanium_abi_triple -emit-module-interface -o %t
+// RUN: %clang_cc1 -std=c++20 %s -triple %itanium_abi_triple -fmodule-file=%t -emit-llvm -o - | FileCheck %s
+
+export module FOO.BAZ;
+import FOO.BAR;
+
+namespace Bob {
+
+// CHECK-DAG: void @_ZN3BobW3FOOW3BAZ3FooEPS0_W3BAR1APNS_S2_1BE(
+void Foo (A *, B*) {
+}
+}
+
+// CHECK-DAG: void @_ZW3FOOW3BAZ3BarPS_W3BAR1APN3BobS1_1BE(
+void Bar (A *, Bob::B*) {
+}
Index: clang/test/CodeGenCXX/cxx20-module-sub-1a.cppm
===
--- /dev/null
+++ clang/test/CodeGenCXX/cxx20-module-sub-1a.cppm
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -std=c++20 %s -triple %itanium_abi_triple -emit-llvm -o - | FileCheck %s
+
+export module FOO.BAR;
+export class A;
+namespace Bob {
+export class B;
+
+// CHECK-DAG: void @_ZN3BobW3FOOW3BAR3BarEPS1_1APNS_S1_1BE(
+export void Bar (A *, B*) {
+}
+}
+
+// CHECK-DAG: void @_ZW3FOOW3BAR3FooPS0_1APN3BobS0_1BE(
+export void Foo (A *, Bob::B*) {
+}
Index: clang/test/CodeGenCXX/cxx20-module-std-subst-2c.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/cxx20-module-std-subst-2c.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -std=c++20 %S/Inputs/cxx20-module-std-subst-2a.cpp -triple %itanium_abi_triple -emit-module-interface -o %t
+// RUN: %clang_cc1 -std=c++20 %s -triple %itanium_abi_triple -fmodule-file=%t -emit-llvm -o - | FileCheck %s
+module;
+# 5 __FILE__ 1
+namespace std {
+template  struct char_traits {};
+} // namespace std
+# 9 "" 2
+export module Bar;
+import RenameString;
+
+// Use Ss as this is global-module std::char_traits
+// CHECK-DAG: void @_ZW3Bar1gRSs(
+void g(str> &s) {
+}
Index: clang/test/CodeGenCXX/cxx20-module-std-subst-2b.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/cxx20-module-std-subst-2b.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -std=c++20 %S/Inputs/cxx20-module-std-subst-2a.cpp -triple %itanium_abi_triple -emit-module-interface -o %t
+// RUN: %clang_cc1 -std=c++20 %s 

[PATCH] D121150: [pseudo][WIP] Implement a GLR parser.

2022-03-08 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 413788.
hokein added a comment.

fix a subtle bug where we might leave an unremoved node in the reduce path.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121150

Files:
  clang/include/clang/Tooling/Syntax/Pseudo/Forest.h
  clang/include/clang/Tooling/Syntax/Pseudo/GLRParser.h
  clang/lib/Tooling/Syntax/Pseudo/CMakeLists.txt
  clang/lib/Tooling/Syntax/Pseudo/Forest.cpp
  clang/lib/Tooling/Syntax/Pseudo/GLRParser.cpp
  clang/tools/clang-pseudo/ClangPseudo.cpp

Index: clang/tools/clang-pseudo/ClangPseudo.cpp
===
--- clang/tools/clang-pseudo/ClangPseudo.cpp
+++ clang/tools/clang-pseudo/ClangPseudo.cpp
@@ -8,6 +8,7 @@
 
 #include "clang/Basic/LangOptions.h"
 #include "clang/Tooling/Syntax/Pseudo/DirectiveMap.h"
+#include "clang/Tooling/Syntax/Pseudo/GLRParser.h"
 #include "clang/Tooling/Syntax/Pseudo/Grammar.h"
 #include "clang/Tooling/Syntax/Pseudo/LRGraph.h"
 #include "clang/Tooling/Syntax/Pseudo/LRTable.h"
@@ -29,6 +30,8 @@
 desc("Print the LR graph for the grammar"));
 static opt PrintTable("print-table",
 desc("Print the LR table for the grammar"));
+static opt ParseFile("parse", desc("Parse a C++ source file"),
+  init(""));
 static opt Source("source", desc("Source file"));
 static opt PrintSource("print-source", desc("Print token stream"));
 static opt PrintTokens("print-tokens", desc("Print detailed token info"));
@@ -69,6 +72,26 @@
 if (PrintTable)
   llvm::outs() << clang::syntax::pseudo::LRTable::buildSLR(*G).dumpForTests(
   *G);
+if (ParseFile.getNumOccurrences()) {
+  std::string Code = readOrDie(ParseFile);
+  const auto &T = clang::syntax::pseudo::LRTable::buildSLR(*G);
+  clang::LangOptions Opts;
+  Opts.CPlusPlus = 1;
+
+  auto RawTokens = clang::syntax::pseudo::lex(Code, Opts);
+  auto Tokens = clang::syntax::pseudo::stripComments(cook(RawTokens, Opts));
+  clang::syntax::pseudo::ForestArena Arena;
+  clang::syntax::pseudo::GLRParser Parser(T, *G, Arena);
+  const auto *Root = Parser.parse(Tokens);
+  if (Root) {
+llvm::outs() << "parsed successfully!\n";
+llvm::outs() << "Forest bytes: " << Arena.bytes()
+ << " nodes: " << Arena.nodeNum() << "\n";
+llvm::outs() << "GSS bytes: " << Parser.getGSS().bytes()
+ << " nodes: " << Parser.getGSS().nodeCount() << "\n";
+// llvm::outs() << Root->DumpRecursive(*G, true);
+  }
+}
 return 0;
   }
 
Index: clang/lib/Tooling/Syntax/Pseudo/GLRParser.cpp
===
--- /dev/null
+++ clang/lib/Tooling/Syntax/Pseudo/GLRParser.cpp
@@ -0,0 +1,334 @@
+//===--- GLRParser.cpp   -*- C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Tooling/Syntax/Pseudo/GLRParser.h"
+#include "clang/Basic/TokenKinds.h"
+#include "clang/Tooling/Syntax/Pseudo/Grammar.h"
+#include "clang/Tooling/Syntax/Pseudo/LRTable.h"
+#include "clang/Tooling/Syntax/Pseudo/Token.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/Support/Debug.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/FormatVariadic.h"
+#include 
+#include 
+
+#define DEBUG_TYPE "GLRParser.cpp"
+
+namespace clang {
+namespace syntax {
+namespace pseudo {
+
+using StateID = LRTable::StateID;
+
+const ForestNode *GLRParser::parse(const TokenStream &Code) {
+  ParsedForest.init(Code);
+  const Token *Lookahead = &Code.tokens().front();
+  addActions(GSS.addNode(/*StartState*/ 0, nullptr, {}), *Lookahead);
+
+  while (!ShiftList.empty() || !ReduceList.empty()) {
+LLVM_DEBUG(llvm::dbgs() << llvm::formatv(
+   "Lookahead token {0} (id: {1} text: '{2}')\n",
+   G.symbolName(tokenSymbol(Lookahead->Kind)),
+   tokenSymbol(Lookahead->Kind), Lookahead->text()));
+
+performReduction(*Lookahead);
+auto NewHeads = performShift(Code.index(*Lookahead));
+
+if (Lookahead->Kind != tok::eof)
+  ++Lookahead;
+for (const auto &AS : NewHeads)
+  addActions(AS, *Lookahead);
+  }
+
+  if (!AcceptLists.empty()) {
+// FIXME: supporting multiple accepted symbols. It should be fine now, as we
+// only have one production for the start symbol `_`. This would become a
+// problem when we support parsing any code snippet rather than the
+// translation unit.
+assert(AcceptLists.size() == 1);
+L

[PATCH] D121211: Properly diagnose constant evaluation issues at TU scope

2022-03-08 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin accepted this revision.
cor3ntin added a comment.
This revision is now accepted and ready to land.

There is already an evaluation context created in Sema but it's never popped 
back.
And because we rely heavily on there always being at least one evaluation 
context (`ExprEvalContexts.back()` is used all over the place for example), i 
think it make somewhat sense to have 2.

So this looks good to me. I wonder if we need a comment?




Comment at: clang/test/SemaCXX/cxx2a-consteval.cpp:699
+
+S s; // expected-error {{call to consteval function 
'NamespaceScopeConsteval::S::S' is not a constant expression}} \
+expected-note {{subobject of type 'int' is not initialized}}

I know there are more patches coming up and i don't remember what's broken or 
not, but if at all possible, can you add a test for a variable template 
instantiation too?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121211

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


[PATCH] D121197: [clang][dataflow] Add analysis that detects unsafe accesses to optionals

2022-03-08 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

Maybe add explanation to the patch description for move of `TestingSupport.h`?  
Also, mention that this just a core implementation, and fuller support is 
coming?




Comment at: 
clang/include/clang/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.h:20
+///
+/// FIXME: Consider separating the models from the unchecked access analysis.
+class UncheckedOptionalAccessModel

Delete?



Comment at: 
clang/include/clang/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.h:35-36
+private:
+  std::function &)>
+  TransferMatchSwitch;





Comment at: 
clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp:84
+auto *HasValueVal = getHasValue(OptionalVal);
+assert(HasValueVal != nullptr);
+

How are we confident that the `has_value` property is populated? Since we're 
only picking up on declr-refs and members, I think this won't hold otherwise.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121197

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


[PATCH] D118352: [clang][ABI] New c++20 modules mangling scheme

2022-03-08 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Looks like this breaks tests on macOS: http://45.33.8.238/macm1/29650/step_7.txt

Please take a look and revert for now if it takes a while to fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118352

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


[PATCH] D121211: Properly diagnose constant evaluation issues at TU scope

2022-03-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 413793.
aaron.ballman added a comment.

Added a comment and an additional test case.


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

https://reviews.llvm.org/D121211

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Parse/ParseAST.cpp
  clang/lib/Sema/Sema.cpp
  clang/test/SemaCXX/cxx2a-consteval.cpp


Index: clang/test/SemaCXX/cxx2a-consteval.cpp
===
--- clang/test/SemaCXX/cxx2a-consteval.cpp
+++ clang/test/SemaCXX/cxx2a-consteval.cpp
@@ -689,3 +689,23 @@
   }
 };
 } // PR48235
+
+namespace NamespaceScopeConsteval {
+struct S {
+  int Val; // expected-note {{subobject declared here}}
+  consteval S() {}
+};
+
+S s1; // expected-error {{call to consteval function 
'NamespaceScopeConsteval::S::S' is not a constant expression}} \
+ expected-note {{subobject of type 'int' is not initialized}}
+
+template 
+struct T {
+  Ty Val; // expected-note {{subobject declared here}}
+  consteval T() {}
+};
+
+T t; // expected-error {{call to consteval function 
'NamespaceScopeConsteval::T::T' is not a constant expression}} \
+ expected-note {{subobject of type 'int' is not initialized}}
+
+} // namespace NamespaceScopeConsteval
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -233,6 +233,9 @@
   // Tell diagnostics how to render things from the AST library.
   Diags.SetArgToStringFn(&FormatASTNodeDiagnosticArgument, &Context);
 
+  // This evaluation context exists to ensure that there's always at least one
+  // valid evaluation context available. It is never removed from the
+  // evaluation stack.
   ExprEvalContexts.emplace_back(
   ExpressionEvaluationContext::PotentiallyEvaluated, 0, CleanupInfo{},
   nullptr, ExpressionEvaluationContextRecord::EK_Other);
Index: clang/lib/Parse/ParseAST.cpp
===
--- clang/lib/Parse/ParseAST.cpp
+++ clang/lib/Parse/ParseAST.cpp
@@ -155,6 +155,9 @@
 P.Initialize();
 Parser::DeclGroupPtrTy ADecl;
 Sema::ModuleImportState ImportState;
+EnterExpressionEvaluationContext PotentiallyEvaluated(
+S, Sema::ExpressionEvaluationContext::PotentiallyEvaluated);
+
 for (bool AtEOF = P.ParseFirstTopLevelDecl(ADecl, ImportState); !AtEOF;
  AtEOF = P.ParseTopLevelDecl(ADecl, ImportState)) {
   // If we got a null return and something *was* parsed, ignore it.  This
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -118,6 +118,8 @@
 
 C++20 Feature Support
 ^
+- Diagnose consteval and constexpr issues that happen at namespace scope. This
+  partially addresses `Issue 51593 
`_.
 
 C++2b Feature Support
 ^


Index: clang/test/SemaCXX/cxx2a-consteval.cpp
===
--- clang/test/SemaCXX/cxx2a-consteval.cpp
+++ clang/test/SemaCXX/cxx2a-consteval.cpp
@@ -689,3 +689,23 @@
   }
 };
 } // PR48235
+
+namespace NamespaceScopeConsteval {
+struct S {
+  int Val; // expected-note {{subobject declared here}}
+  consteval S() {}
+};
+
+S s1; // expected-error {{call to consteval function 'NamespaceScopeConsteval::S::S' is not a constant expression}} \
+ expected-note {{subobject of type 'int' is not initialized}}
+
+template 
+struct T {
+  Ty Val; // expected-note {{subobject declared here}}
+  consteval T() {}
+};
+
+T t; // expected-error {{call to consteval function 'NamespaceScopeConsteval::T::T' is not a constant expression}} \
+ expected-note {{subobject of type 'int' is not initialized}}
+
+} // namespace NamespaceScopeConsteval
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -233,6 +233,9 @@
   // Tell diagnostics how to render things from the AST library.
   Diags.SetArgToStringFn(&FormatASTNodeDiagnosticArgument, &Context);
 
+  // This evaluation context exists to ensure that there's always at least one
+  // valid evaluation context available. It is never removed from the
+  // evaluation stack.
   ExprEvalContexts.emplace_back(
   ExpressionEvaluationContext::PotentiallyEvaluated, 0, CleanupInfo{},
   nullptr, ExpressionEvaluationContextRecord::EK_Other);
Index: clang/lib/Parse/ParseAST.cpp
===
--- clang/lib/Parse/ParseAST.cpp
+++ clang/lib/Parse/ParseAST.cpp
@@ -155,6 +155,9 @@
 P.Initialize();
 Parser::DeclGroupPtrTy ADecl;
 Sema::ModuleImportState ImportState;
+EnterExpressionEvaluationContext PotentiallyEvaluated(
+S, Sema::ExpressionEvaluationContex

[PATCH] D118352: [clang][ABI] New c++20 modules mangling scheme

2022-03-08 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

(also, please don't land unused code -- land those functions when you land 
their callers)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118352

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


[PATCH] D121214: [clang-tidy][docs][NFC] Add alias cert-mem51-cpp to bugprone-shared-ptr-array-mismatch

2022-03-08 Thread Balázs Benics via Phabricator via cfe-commits
steakhal created this revision.
steakhal added reviewers: whisperity, aaron.ballman.
Herald added subscribers: jeroen.dobbelaere, martong, rnkovacs, xazax.hun.
Herald added a project: All.
steakhal requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Document the connection between this checker and the corresponding CERT rule.


https://reviews.llvm.org/D121214

Files:
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-shared-ptr-array-mismatch.rst
  clang-tools-extra/docs/clang-tidy/checks/cert-mem51-cpp.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst


Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -350,6 +350,7 @@
`cert-exp42-c `_, `bugprone-suspicious-memory-comparison 
`_,
`cert-fio38-c `_, `misc-non-copyable-objects 
`_,
`cert-flp37-c `_, `bugprone-suspicious-memory-comparison 
`_,
+   `cert-mem51-cpp `_, 
`bugprone-shared-ptr-array-mismatch 
`_, "Yes"
`cert-msc30-c `_, `cert-msc50-cpp 
`_,
`cert-msc32-c `_, `cert-msc51-cpp 
`_,
`cert-oop11-cpp `_, `performance-move-constructor-init 
`_,
Index: clang-tools-extra/docs/clang-tidy/checks/cert-mem51-cpp.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/cert-mem51-cpp.rst
@@ -0,0 +1,12 @@
+.. title:: clang-tidy - cert-mem51-cpp
+.. meta::
+   :http-equiv=refresh: 5;URL=bugprone-shared-ptr-array-mismatch.html
+
+cert-mem51-cpp
+==
+
+The cert-mem51-cpp check is an alias, please see
+`bugprone-shared-ptr-array-mismatch `_
+for more information.
+
+Please note that the check only partially covers the corresponding CERT rule.
Index: 
clang-tools-extra/docs/clang-tidy/checks/bugprone-shared-ptr-array-mismatch.rst
===
--- 
clang-tools-extra/docs/clang-tidy/checks/bugprone-shared-ptr-array-mismatch.rst
+++ 
clang-tools-extra/docs/clang-tidy/checks/bugprone-shared-ptr-array-mismatch.rst
@@ -29,3 +29,8 @@
 std::shared_ptr x(new Foo[10]); // no replacement in this case
 // ^ warning: shared pointer to non-array is 
initialized with array [bugprone-shared-ptr-array-mismatch]
   };
+
+This check corresponds to the CERT C++ Coding Standard rule
+`MEM51-CPP. Properly deallocate dynamically allocated resources
+`_
+rule, but only partially implements it.


Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -350,6 +350,7 @@
`cert-exp42-c `_, `bugprone-suspicious-memory-comparison `_,
`cert-fio38-c `_, `misc-non-copyable-objects `_,
`cert-flp37-c `_, `bugprone-suspicious-memory-comparison `_,
+   `cert-mem51-cpp `_, `bugprone-shared-ptr-array-mismatch `_, "Yes"
`cert-msc30-c `_, `cert-msc50-cpp `_,
`cert-msc32-c `_, `cert-msc51-cpp `_,
`cert-oop11-cpp `_, `performance-move-constructor-init `_,
Index: clang-tools-extra/docs/clang-tidy/checks/cert-mem51-cpp.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/cert-mem51-cpp.rst
@@ -0,0 +1,12 @@
+.. title:: clang-tidy - cert-mem51-cpp
+.. meta::
+   :http-equiv=refresh: 5;URL=bugprone-shared-ptr-array-mismatch.html
+
+cert-mem51-cpp
+==
+
+The cert-mem51-cpp check is an alias, please see
+`bugprone-shared-ptr-array-mismatch `_
+for more information.
+
+Please note that the check only partially covers the corresponding CERT rule.
Index: clang-tools-extra/docs/clang-tidy/checks/bugprone-shared-ptr-array-mismatch.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/bugprone-shared-ptr-array-mismatch.rst
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone-shared-ptr-array-mismatch.rst
@@ -29,3 +29,8 @@
 std::shared_ptr x(new Foo[10]); // no replacement in this case
 // ^ warning: shared pointer to non-array is initialized with array [bugprone-shared-ptr-array-mismatch]
   };
+
+This check corresponds to the CERT C++ Coding Standard rule
+`MEM51-CPP. Properly deallocate dynamically allocated resources
+`_
+rule, but only partially implements it.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 5b7941a - [clang][driver] Fix float128 diagnostics with glibc >= 2.32

2022-03-08 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2022-03-08T15:49:01+01:00
New Revision: 5b7941ad7c893b4bb019e3c96b760b0f2670ccfc

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

LOG: [clang][driver] Fix float128 diagnostics with glibc >= 2.32

Fix checking for an unsupported stdlib++.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/PPCLinux.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/PPCLinux.cpp 
b/clang/lib/Driver/ToolChains/PPCLinux.cpp
index e480d8bd8703c..2fea262fd109c 100644
--- a/clang/lib/Driver/ToolChains/PPCLinux.cpp
+++ b/clang/lib/Driver/ToolChains/PPCLinux.cpp
@@ -76,9 +76,11 @@ bool PPCLinuxToolChain::SupportIEEEFloat128(
   if (Args.hasArg(options::OPT_nostdlib, options::OPT_nostdlibxx))
 return true;
 
+  CXXStdlibType StdLib = ToolChain::GetCXXStdlibType(Args);
   bool HasUnsupportedCXXLib =
-  ToolChain::GetCXXStdlibType(Args) == CST_Libcxx &&
-  GCCInstallation.getVersion().isOlderThan(12, 1, 0);
+  StdLib == CST_Libcxx ||
+  (StdLib == CST_Libstdcxx &&
+   GCCInstallation.getVersion().isOlderThan(12, 1, 0));
 
   return GlibcSupportsFloat128(Linux::getDynamicLinker(Args)) &&
  !(D.CCCIsCXX() && HasUnsupportedCXXLib);



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


[PATCH] D121209: [clang][driver] Fix float128 diagnostics with glibc >= 2.32

2022-03-08 Thread Timm Bäder via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5b7941ad7c89: [clang][driver] Fix float128 diagnostics with 
glibc >= 2.32 (authored by tbaeder).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121209

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


Index: clang/lib/Driver/ToolChains/PPCLinux.cpp
===
--- clang/lib/Driver/ToolChains/PPCLinux.cpp
+++ clang/lib/Driver/ToolChains/PPCLinux.cpp
@@ -76,9 +76,11 @@
   if (Args.hasArg(options::OPT_nostdlib, options::OPT_nostdlibxx))
 return true;
 
+  CXXStdlibType StdLib = ToolChain::GetCXXStdlibType(Args);
   bool HasUnsupportedCXXLib =
-  ToolChain::GetCXXStdlibType(Args) == CST_Libcxx &&
-  GCCInstallation.getVersion().isOlderThan(12, 1, 0);
+  StdLib == CST_Libcxx ||
+  (StdLib == CST_Libstdcxx &&
+   GCCInstallation.getVersion().isOlderThan(12, 1, 0));
 
   return GlibcSupportsFloat128(Linux::getDynamicLinker(Args)) &&
  !(D.CCCIsCXX() && HasUnsupportedCXXLib);


Index: clang/lib/Driver/ToolChains/PPCLinux.cpp
===
--- clang/lib/Driver/ToolChains/PPCLinux.cpp
+++ clang/lib/Driver/ToolChains/PPCLinux.cpp
@@ -76,9 +76,11 @@
   if (Args.hasArg(options::OPT_nostdlib, options::OPT_nostdlibxx))
 return true;
 
+  CXXStdlibType StdLib = ToolChain::GetCXXStdlibType(Args);
   bool HasUnsupportedCXXLib =
-  ToolChain::GetCXXStdlibType(Args) == CST_Libcxx &&
-  GCCInstallation.getVersion().isOlderThan(12, 1, 0);
+  StdLib == CST_Libcxx ||
+  (StdLib == CST_Libstdcxx &&
+   GCCInstallation.getVersion().isOlderThan(12, 1, 0));
 
   return GlibcSupportsFloat128(Linux::getDynamicLinker(Args)) &&
  !(D.CCCIsCXX() && HasUnsupportedCXXLib);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >