[PATCH] D101743: [clangd] Fix hover crash on broken code

2021-05-03 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: hokein.
Herald added subscribers: usaxena95, arphaman.
kadircet requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101743

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -2438,6 +2438,20 @@
   }
 }
 
+TEST(Hover, NoCrash) {
+  Annotations T(R"cpp(
+/* error-ok */
+template T foo(T);
+
+// Setter variable heuristic might fail if the callexpr is broken.
+struct X { int Y; void [[^setY]](float) { Y = foo(x); } };)cpp");
+
+  TestTU TU = TestTU::withCode(T.code());
+  auto AST = TU.build();
+  for (const auto &P : T.points())
+getHover(AST, P, format::getLLVMStyle(), nullptr);
+}
+
 TEST(Hover, DocsFromMostSpecial) {
   Annotations T(R"cpp(
   // doc1
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -505,7 +505,7 @@
   if (auto *CE = llvm::dyn_cast(RHS->IgnoreCasts())) {
 if (CE->getNumArgs() != 1)
   return llvm::None;
-auto *ND = llvm::dyn_cast(CE->getCalleeDecl());
+auto *ND = llvm::dyn_cast_or_null(CE->getCalleeDecl());
 if (!ND || !ND->getIdentifier() || ND->getName() != "move" ||
 !ND->isInStdNamespace())
   return llvm::None;


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -2438,6 +2438,20 @@
   }
 }
 
+TEST(Hover, NoCrash) {
+  Annotations T(R"cpp(
+/* error-ok */
+template T foo(T);
+
+// Setter variable heuristic might fail if the callexpr is broken.
+struct X { int Y; void [[^setY]](float) { Y = foo(x); } };)cpp");
+
+  TestTU TU = TestTU::withCode(T.code());
+  auto AST = TU.build();
+  for (const auto &P : T.points())
+getHover(AST, P, format::getLLVMStyle(), nullptr);
+}
+
 TEST(Hover, DocsFromMostSpecial) {
   Annotations T(R"cpp(
   // doc1
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -505,7 +505,7 @@
   if (auto *CE = llvm::dyn_cast(RHS->IgnoreCasts())) {
 if (CE->getNumArgs() != 1)
   return llvm::None;
-auto *ND = llvm::dyn_cast(CE->getCalleeDecl());
+auto *ND = llvm::dyn_cast_or_null(CE->getCalleeDecl());
 if (!ND || !ND->getIdentifier() || ND->getName() != "move" ||
 !ND->isInStdNamespace())
   return llvm::None;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101616: [clangd] Fix data type of WorkDoneProgressReport::percentage

2021-05-03 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler added a comment.

Would you mind pushing this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101616

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


[PATCH] D101236: [ASTImporter] Import definitions required for layout of [[no_unique_address]] from LLDB

2021-05-03 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: clang/unittests/AST/ASTImporterTest.cpp:6408
+  // Import the definition of the created class.
+  llvm::Error Err = findFromTU(FromC)->Importer->ImportDefinition(ToC);
+  EXPECT_FALSE((bool)Err);

I suppose that the problem is you try to import the definition of a class that 
is in the destination context (`ToC`). That class is not imported properly yet, 
and I guess that is why its source location is not yet imported also (basically 
that's the reason of the sloc assertion).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101236

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


[PATCH] D101635: [analyzer] Fix assertion in SVals.h

2021-05-03 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In D101635#2731210 , @steakhal wrote:

> Does anyone have an idea how to prevent such a silly mistake from happening 
> again?

Maybe use more optionals? I.e., `castRegion` may fail, so let's change it to 
return `Optional` where the pointer is always non-null when 
present? In many cases it's probably unnecessary but when a function can return 
null //for poorly predictable reasons// (eg., like in this case, the region 
turning out to have symbolic offset after a potentially unlimited number of 
unwraps) it's probably worth it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101635

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


[PATCH] D97183: [analyzer] Add NoteTag for smart-ptr get()

2021-05-03 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD added a comment.

@NoQ ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97183

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


[PATCH] D101516: Introduce clangd-server-monitor tool

2021-05-03 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/test/remote-index/pipeline_helper.py:77
+  index_server_monitor_process.wait()
+  for line in index_server_monitor_process.stderr:
+args.server_log.write(line)

logs for index-server and monitor gets intertwined (as we put logs from 
index-server until `initialization` above). so can we output monitoring logs 
after we've dumped all the logs from index-server?



Comment at: clang-tools-extra/clangd/test/remote-index/pipeline_helper.py:98
 
+  monitor_info = index_server_monitor_process.stdout.read()
+  if not monitor_info:

can we just dump the stdout to main process (as we do with other subprocesses) 
and check for the output in the lit tests instead? that way we can check for 
particular values without complicating the helper instead


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101516

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


[PATCH] D101554: [clangd] Add support for the `defaultLibrary` semantic token modifier

2021-05-03 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

LG from my side.




Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:470
+  if (auto *OT = dyn_cast(T))
+return scopeModifier(OT->getInterface());
   return llvm::None;

is this guaranteed to be non-null ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101554

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


[PATCH] D101672: Modules: Simplify how DisableGeneratingGlobalModuleIndex is set, likely NFC

2021-05-03 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 accepted this revision.
jansvoboda11 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/D101672/new/

https://reviews.llvm.org/D101672

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


[PATCH] D101670: Modules: Rename ModuleBuildFailed => DisableGeneratingGlobalModuleIndex, NFC

2021-05-03 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 accepted this revision.
jansvoboda11 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/D101670/new/

https://reviews.llvm.org/D101670

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


[PATCH] D101696: [Matrix] Implement C-style explicit type conversions in CXX for matrix types

2021-05-03 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

Thanks for the update! Technically the fix in 
`clang/lib/CodeGen/CGExprScalar.cpp` is unrelated to C++ support. It would be 
great if you could put up a separate patch, so we can land this independently.

The whole patch basically LGTM. It would be great if you could add a test 
casting from unsigned to float/double (looks like no test generates `uitofp`) 
and a test for casting between signed & unsigned integers of the same size 
(unless there are already tests for that I missed)




Comment at: clang/lib/CodeGen/CGExprScalar.cpp:1209
-// Allow bitcast between matrixes of the same size.
-if (SrcTy->getPrimitiveSizeInBits() == DstTy->getPrimitiveSizeInBits())
-  return Builder.CreateBitCast(Src, DstTy, "conv");

Could you s



Comment at: clang/test/CodeGenCXX/matrix-casts.cpp:4
+template 
+
+using matrix_4_4 = X __attribute__((matrix_type(4, 4)));

nit: drop the newline here and before `using matrix_5_5...`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101696

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


[PATCH] D100727: [clang-format] Add options to AllowShortIfStatementsOnASingleLine to apply to "else if" and "else".

2021-05-03 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius updated this revision to Diff 342338.
curdeius added a comment.

- Fix format.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100727

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -461,6 +461,69 @@
"  }\n"
"g();");
 
+  verifyFormat("if (a)\n"
+   "  g();");
+  verifyFormat("if (a) {\n"
+   "  g()\n"
+   "};");
+  verifyFormat("if (a)\n"
+   "  g();\n"
+   "else\n"
+   "  g();");
+  verifyFormat("if (a) {\n"
+   "  g();\n"
+   "} else\n"
+   "  g();");
+  verifyFormat("if (a)\n"
+   "  g();\n"
+   "else {\n"
+   "  g();\n"
+   "}");
+  verifyFormat("if (a) {\n"
+   "  g();\n"
+   "} else {\n"
+   "  g();\n"
+   "}");
+  verifyFormat("if (a)\n"
+   "  g();\n"
+   "else if (b)\n"
+   "  g();\n"
+   "else\n"
+   "  g();");
+  verifyFormat("if (a) {\n"
+   "  g();\n"
+   "} else if (b)\n"
+   "  g();\n"
+   "else\n"
+   "  g();");
+  verifyFormat("if (a)\n"
+   "  g();\n"
+   "else if (b) {\n"
+   "  g();\n"
+   "} else\n"
+   "  g();");
+  verifyFormat("if (a)\n"
+   "  g();\n"
+   "else if (b)\n"
+   "  g();\n"
+   "else {\n"
+   "  g();\n"
+   "}");
+  verifyFormat("if (a)\n"
+   "  g();\n"
+   "else if (b) {\n"
+   "  g();\n"
+   "} else {\n"
+   "  g();\n"
+   "}");
+  verifyFormat("if (a) {\n"
+   "  g();\n"
+   "} else if (b) {\n"
+   "  g();\n"
+   "} else {\n"
+   "  g();\n"
+   "}");
+
   FormatStyle AllowsMergedIf = getLLVMStyle();
   AllowsMergedIf.AlignEscapedNewlines = FormatStyle::ENAS_Left;
   AllowsMergedIf.AllowShortIfStatementsOnASingleLine =
@@ -510,6 +573,59 @@
 
   AllowsMergedIf.ColumnLimit = 13;
   verifyFormat("if (a)\n  return;", AllowsMergedIf);
+
+  FormatStyle AllowsMergedIfElse = getLLVMStyle();
+  AllowsMergedIfElse.AllowShortIfStatementsOnASingleLine =
+  FormatStyle::SIS_AllIfsAndElse;
+  verifyFormat("if (a)\n"
+   "  // comment\n"
+   "  f();\n"
+   "else\n"
+   "  // comment\n"
+   "  f();",
+   AllowsMergedIfElse);
+  verifyFormat("{\n"
+   "  if (a)\n"
+   "  label:\n"
+   "f();\n"
+   "  else\n"
+   "  label:\n"
+   "f();\n"
+   "}",
+   AllowsMergedIfElse);
+  verifyFormat("if (a)\n"
+   "  ;\n"
+   "else\n"
+   "  ;",
+   AllowsMergedIfElse);
+  verifyFormat("if (a) {\n"
+   "} else {\n"
+   "}",
+   AllowsMergedIfElse);
+  verifyFormat("if (a) return;\n"
+   "else if (b) return;\n"
+   "else return;",
+   AllowsMergedIfElse);
+  verifyFormat("if (a) {\n"
+   "} else return;",
+   AllowsMergedIfElse);
+  verifyFormat("if (a) {\n"
+   "} else if (b) return;\n"
+   "else return;",
+   AllowsMergedIfElse);
+  verifyFormat("if (a) return;\n"
+   "else if (b) {\n"
+   "} else return;",
+   AllowsMergedIfElse);
+  verifyFormat("if (a)\n"
+   "  if (b) return;\n"
+   "  else return;",
+   AllowsMergedIfElse);
+  verifyFormat("if constexpr (a)\n"
+   "  if constexpr (b) return;\n"
+   "  else if constexpr (c) return;\n"
+   "  else return;",
+   AllowsMergedIfElse);
 }
 
 TEST_F(FormatTest, FormatIfWithoutCompoundStatementButElseWith) {
@@ -529,7 +645,166 @@
"  g();\n",
AllowsMergedIf);
 
-  AllowsMergedIf.AllowShortIfStatementsOnASingleLine = FormatStyle::SIS_Always;
+  verifyFormat("if (a) g();", AllowsMergedIf);
+  verifyFormat("if (a) {\n"
+   "  g()\n"
+   "};",
+   AllowsMergedIf);
+  verifyFormat("if (a)\n"
+   "  g();\n"
+   "else\n"
+   "  g();",
+   AllowsMergedIf);
+  verifyFormat("if (a) {\n"
+   "  g();\n"
+   "} else\n"
+   

[PATCH] D101526: [analyzer][StdLibraryFunctionsChecker] Add NoteTags for applied arg constraints

2021-05-03 Thread Gabor Marton via Phabricator via cfe-commits
martong marked 4 inline comments as done.
martong added inline comments.



Comment at: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:836-837
+  NewState, NewNode,
+  C.getNoteTag([Msg](PathSensitiveBugReport &BR,
+ llvm::raw_ostream &OS) { OS << Msg; }));
 }

NoQ wrote:
> martong wrote:
> > steakhal wrote:
> > > This way each and every applied constraint will be displayed even if the 
> > > given argument does not constitute to the bug condition.
> > > I recommend you branching within the lambda, on the interestingness of 
> > > the given argument constraint.
> > Okay, good point, thanks for the feedback! I am planning to change to this 
> > direction.
> Excellent catch @steakhal!
> 
> I think you can always emit the note but only mark it as //unprunable// when 
> the argument is interesting. This way it'd work identically to our normal 
> "Assuming..." notes.
> I think you can always emit the note but only mark it as unprunable when the 
> argument is interesting. This way it'd work identically to our normal 
> "Assuming..." notes.

`IsPrunable` is a `const` member in `NoteTag`. So, we have to decide about 
prunability when we call `getNoteTag`. To follow your suggestion, we should 
decide the prunability dynamically in `TagVisitor::VisitNode`. This would 
require some infrastructural changes in `NoteTag`. We could add e.g. another 
Callback member that would be able to decide the prunability with the help of a 
`BugReport&`. I am okay to go into that direction, but it should definitely be 
separated from this patch (follow-up). I am not sure if  it is an absolutely 
needed dependency for this change, is it? (If yes then I am going to create the 
dependent patch first).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101526

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


[PATCH] D101526: [analyzer][StdLibraryFunctionsChecker] Add NoteTags for applied arg constraints

2021-05-03 Thread Gabor Marton via Phabricator via cfe-commits
martong marked 2 inline comments as done.
martong added inline comments.



Comment at: 
clang/test/Analysis/std-c-library-functions-arg-constraints-note-tags.cpp:16
+int test_note(int x, int y) {
+__single_val_1(x);  // expected-note{{Applied constraint: The 1st arg 
should be within the range [1, 1]}}
+return y / (1 - x); // expected-warning{{Division by zero}} \

NoQ wrote:
> martong wrote:
> > NoQ wrote:
> > > This has to be a user-friendly message.
> > > * "Constraints" is compiler jargon.
> > > * We cannot afford shortening "argument" to "arg".
> > > * Generally, the less machine-generated it looks the better (":" is 
> > > definitely robotic).
> > Okay, thanks for your comment. I can make it to be more similar to the 
> > other notes we already have. What about this?
> > ```
> > Assuming the 1st argument is within the range [1, 1]
> > ```
> > 
> > > We cannot afford shortening "argument" to "arg".
> > I'd like to address this in another following patch if you don't mind.
> This sounds good for a generic message. I still think that most of the time 
> these messages should be part of the summary. Eg., 
> ```
> Assuming the 1st argument is within range [33, 47] U [58, 64] U [91, 96] U 
> [123, 125]
> ```
> ideally should be rephrased as
> ```
> Assuming the argument is a punctuation character
> ```
> in the summary of `ispunct()`.
Yes, absolutely, good idea. It makes sense to provide another member for the 
`Summary` that could specifically describe the function specific assumptions 
(or violations). However, before we would be able to go through all functions 
manually to create these specific messages we need a generic solution to have 
something that is more descriptive than the current solution.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101526

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


[PATCH] D70401: [WIP][RISCV] Implement ilp32e ABI

2021-05-03 Thread Zakk Chen via Phabricator via cfe-commits
khchen added a comment.
Herald added a subscriber: vkmr.

Hi, I would like to add ilp32e ABI support in llvm
Is there anyone working on this?
It seem the one thing missed is ilp32e ABI should disallow D ISA extension.
Is there anything else?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70401

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


[PATCH] D101640: [clang][patch] Add support for option -fextend-arguments-64: widen integer arguments to int64 in unprototyped function calls

2021-05-03 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

Usually, Clang has two flags to control a feature: one to turn it on and the 
other to turn it off. The last one on the command-line wins.

Accepting both `-fextend-arguments=64` and `-fextend-arguments=32` would be 
more consistent with the rest of the command-line options IMO.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101640

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


[PATCH] D101526: [analyzer][StdLibraryFunctionsChecker] Add NoteTags for applied arg constraints

2021-05-03 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 342342.
martong marked an inline comment as done.
martong added a comment.

- Add the description to the note tag only if the SVal is interesting
- Use 'Assuming the nth arg is in ...' form for the descriptions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101526

Files:
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/test/Analysis/std-c-library-functions-arg-constraints-note-tags.cpp
  clang/test/Analysis/std-c-library-functions-arg-constraints.c

Index: clang/test/Analysis/std-c-library-functions-arg-constraints.c
===
--- clang/test/Analysis/std-c-library-functions-arg-constraints.c
+++ clang/test/Analysis/std-c-library-functions-arg-constraints.c
@@ -238,6 +238,7 @@
   // State split should not happen here. I.e. x == 1 should not be evaluated
   // FALSE.
   __two_constrained_args(x, y);
+  //NOTE! Because of the second `clang_analyzer_eval` call we have two bug
   clang_analyzer_eval(x == 1); // \
   // report-warning{{TRUE}} \
   // bugpath-warning{{TRUE}} \
@@ -251,7 +252,6 @@
 int __arg_constrained_twice(int);
 void test_multiple_constraints_on_same_arg(int x) {
   __arg_constrained_twice(x);
-  // Check that both constraints are applied and only one branch is there.
   clang_analyzer_eval(x < 1 || x > 2); // \
   // report-warning{{TRUE}} \
   // bugpath-warning{{TRUE}} \
Index: clang/test/Analysis/std-c-library-functions-arg-constraints-note-tags.cpp
===
--- /dev/null
+++ clang/test/Analysis/std-c-library-functions-arg-constraints-note-tags.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-checker=alpha.unix.StdCLibraryFunctionArgs \
+// RUN:   -analyzer-checker=debug.StdCLibraryFunctionsTester \
+// RUN:   -analyzer-config apiModeling.StdCLibraryFunctions:DisplayLoadedSummaries=true \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false \
+// RUN:   -triple i686-unknown-linux \
+// RUN:   -analyzer-output=text \
+// RUN:   -verify
+
+int __single_val_0(int);  // [0, 0]
+
+int test_note(int x, int y) {
+__single_val_0(x);  // expected-note{{Assuming the 1st arg is within the range [0, 0]}}
+return y / x;   // expected-warning{{Division by zero}} \
+// expected-note{{Division by zero}}
+}
Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -142,9 +142,18 @@
 
 virtual StringRef getName() const = 0;
 
+// Represents that in which context do we require a description of the
+// constraint.
+enum class DescritptionKind {
+  // The constraint is violated.
+  Violation,
+  // We assume that the constraint is satisfied.
+  Assumption
+};
+
 // Give a description that explains the constraint to the user. Used when
 // the bug is reported.
-virtual std::string describe(ProgramStateRef State,
+virtual std::string describe(DescritptionKind DK, ProgramStateRef State,
  const Summary &Summary) const {
   // There are some descendant classes that are not used as argument
   // constraints, e.g. ComparisonConstraint. In that case we can safely
@@ -182,7 +191,7 @@
 RangeConstraint(ArgNo ArgN, RangeKind Kind, const IntRangeVector &Ranges)
 : ValueConstraint(ArgN), Kind(Kind), Ranges(Ranges) {}
 
-std::string describe(ProgramStateRef State,
+std::string describe(DescritptionKind DK, ProgramStateRef State,
  const Summary &Summary) const override;
 
 const IntRangeVector &getRanges() const { return Ranges; }
@@ -252,7 +261,7 @@
 bool CannotBeNull = true;
 
   public:
-std::string describe(ProgramStateRef State,
+std::string describe(DescritptionKind DK, ProgramStateRef State,
  const Summary &Summary) const override;
 StringRef getName() const override { return "NonNull"; }
 ProgramStateRef apply(ProgramStateRef State, const CallEvent &Call,
@@ -324,7 +333,7 @@
   return Result;
 }
 
-std::string describe(ProgramStateRef State,
+std::string describe(DescritptionKind DK, ProgramStateRef State,
  const Summary &Summary) const override;
 
 ProgramStateRef apply(ProgramStateRef State, const CallEvent &Call,
@@ -598,9 +607,12 @@
 // Highlight the range of the argument that was violated.
 R->addRange(Call.getArgSourceRange(VC->getArgNo()));
 
-// Describe the argument constraint

[PATCH] D99646: [clang-tidy] misc-avoid-std-io-outside-main: a new check

2021-05-03 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: clang-tools-extra/clang-tidy/misc/AvoidStdIoOutsideMainCheck.cpp:22
+  Finder->addMatcher(
+  declRefExpr(to(varDecl(hasAnyName("cin", "wcin", "cout", "wcout", "cerr",
+"wcerr"),

mgartmann wrote:
> Would there be a way to extract these names (`cin`, `cout`, ...) into a 
> separate variable? In my opinion, this would make the AST matchers cleaner 
> and easier to read.
> 
> E.g., I was not able to find an overload of `hasAnyName()` which takes a 
> `std:.vector` as argument.
> 
> Looking forward to hearing from you.
> Thanks for any feedback in advance.
`hasAnyName` can take an `ArrayRef` So If you have a 
`std::vector` that would work. If you have 
`std::vector` you can still sort of use it
```lang=c++
  auto StringClassMatcher = cxxRecordDecl(hasAnyName(SmallVector(
  StringLikeClasses.begin(), StringLikeClasses.end(;```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99646

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


[clang-tools-extra] 53df522 - [clang-tidy][NFC] Short circuit getting enum options suggestions.

2021-05-03 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2021-05-03T11:20:27+01:00
New Revision: 53df522a0c536d32a60c0ed571097a78ce2541a7

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

LOG: [clang-tidy][NFC] Short circuit getting enum options suggestions.

Use the MaxEditDistance to skip checking candidates we know we'll skip.

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidyCheck.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
index 46b69ed538cb2..6f7f6611c8d20 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
@@ -147,7 +147,7 @@ llvm::Optional 
ClangTidyCheck::OptionsView::getEnumInt(
 
   StringRef Value = Iter->getValue().Value;
   StringRef Closest;
-  unsigned EditDistance = -1;
+  unsigned EditDistance = 3;
   for (const auto &NameAndEnum : Mapping) {
 if (IgnoreCase) {
   if (Value.equals_lower(NameAndEnum.second))
@@ -159,7 +159,8 @@ llvm::Optional 
ClangTidyCheck::OptionsView::getEnumInt(
   EditDistance = 0;
   continue;
 }
-unsigned Distance = Value.edit_distance(NameAndEnum.second);
+unsigned Distance =
+Value.edit_distance(NameAndEnum.second, true, EditDistance);
 if (Distance < EditDistance) {
   EditDistance = Distance;
   Closest = NameAndEnum.second;



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


[PATCH] D100934: [clang][modules] Build inferred modules

2021-05-03 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

@dexonsmith ping




Comment at: clang/lib/Serialization/ASTReader.cpp:5621
+  // FIXME: NameAsWritten
+  ModMap.setUmbrellaHeader(CurrentModule, *Umbrella, Blob, "");
 else if (CurrentModule->getUmbrellaHeader().Entry != *Umbrella) {

jansvoboda11 wrote:
> Not sure what's the best way to write/read the two strings (`NameAsWritten`, 
> `PathRelativeToRootModuleDirectory`). Can we put them into a single blob and 
> separate them with `\0`?
I think we can store them in whatever format we want and separating them by 
`'\0'` should be fine.

However, I'm not convinced we need to do so in this patch. Deserialized 
`NameAsWritten` isn't being used anyway, meaning we have no interesting test 
case for serialization that would ensure it works as expected.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100934

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


[PATCH] D101462: Make it possible for targets to define their own MCObjectFileInfo

2021-05-03 Thread Philipp Krones via Phabricator via cfe-commits
flip1995 updated this revision to Diff 342345.
flip1995 added a comment.

[MC] Untangle MCContext and MCObjectFileInfo

This untangles the MCContext and the MCObjectFileInfo. There is a circular
dependency between MCContext and MCObjectFileInfo. Currently this dependency
also exists during construction: You can't contruct a MOFI without a MCContext
without constructing the MCContext with a dummy version of that MOFI first.
This removes this dependency during construction. In a perfect world,
MCObjectFileInfo wouldn't depend on MCContext at all, but only be stored in the
MCContext, like other MC information. This is future work.

This also shifts/adds more information to the MCContext making it more
available to the different targets. Namely:

- TargetTriple
- ObjectFileType
- SubtargetInfo

Included Commits:

- [MC] Add MCSubtargetInfo to MCContext
- [MC] Untangle MCContext and MCObjectFileInfo
- [MC] Move TargetTriple information from MCObjectFileInfo to MCContext


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101462

Files:
  clang/lib/Parse/ParseStmtAsm.cpp
  clang/tools/driver/cc1as_main.cpp
  lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
  lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
  lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp
  llvm/include/llvm/MC/MCContext.h
  llvm/include/llvm/MC/MCObjectFileInfo.h
  llvm/lib/CodeGen/MachineModuleInfo.cpp
  llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
  llvm/lib/DWARFLinker/DWARFStreamer.cpp
  llvm/lib/MC/MCAsmStreamer.cpp
  llvm/lib/MC/MCContext.cpp
  llvm/lib/MC/MCDisassembler/Disassembler.cpp
  llvm/lib/MC/MCMachOStreamer.cpp
  llvm/lib/MC/MCObjectFileInfo.cpp
  llvm/lib/MC/MCParser/AsmParser.cpp
  llvm/lib/MC/MCParser/COFFAsmParser.cpp
  llvm/lib/MC/MCParser/DarwinAsmParser.cpp
  llvm/lib/MC/MCParser/MasmParser.cpp
  llvm/lib/MC/MCStreamer.cpp
  llvm/lib/MC/MCWinCOFFStreamer.cpp
  llvm/lib/Object/ModuleSymbolTable.cpp
  llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
  llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
  llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.cpp
  llvm/lib/Target/TargetLoweringObjectFile.cpp
  llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp
  llvm/tools/llvm-dwp/llvm-dwp.cpp
  llvm/tools/llvm-exegesis/lib/Analysis.cpp
  llvm/tools/llvm-exegesis/lib/LlvmState.cpp
  llvm/tools/llvm-exegesis/lib/SnippetFile.cpp
  llvm/tools/llvm-jitlink/llvm-jitlink.cpp
  llvm/tools/llvm-mc-assemble-fuzzer/llvm-mc-assemble-fuzzer.cpp
  llvm/tools/llvm-mc/llvm-mc.cpp
  llvm/tools/llvm-mca/llvm-mca.cpp
  llvm/tools/llvm-ml/Disassembler.cpp
  llvm/tools/llvm-ml/llvm-ml.cpp
  llvm/tools/llvm-objdump/MachODump.cpp
  llvm/tools/llvm-objdump/llvm-objdump.cpp
  llvm/tools/llvm-profgen/ProfiledBinary.cpp
  llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
  llvm/tools/sancov/sancov.cpp
  llvm/unittests/CodeGen/MachineInstrTest.cpp
  llvm/unittests/CodeGen/MachineOperandTest.cpp
  llvm/unittests/CodeGen/TestAsmPrinter.cpp
  llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp
  llvm/unittests/MC/DwarfLineTables.cpp
  llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp

Index: llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
===
--- llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
+++ llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
@@ -57,6 +57,7 @@
   std::unique_ptr MRI;
   std::unique_ptr MUPMAI;
   std::unique_ptr MII;
+  std::unique_ptr MSTI;
   std::unique_ptr Str;
   std::unique_ptr Parser;
   std::unique_ptr Ctx;
@@ -86,6 +87,11 @@
 MAI.reset(TheTarget->createMCAsmInfo(*MRI, TripleName, MCOptions));
 EXPECT_NE(MAI, nullptr);
 
+std::unique_ptr MSTI;
+MSTI.reset(TheTarget->createMCSubtargetInfo(TripleName, /*CPU=*/"",
+/*Features=*/""));
+EXPECT_NE(MSTI, nullptr);
+
 // Now we cast to our mocked up version of MCAsmInfo.
 MUPMAI.reset(static_cast(MAI.release()));
 // MUPMAI should "hold" MAI.
@@ -99,9 +105,9 @@
 SrcMgr.AddNewSourceBuffer(std::move(Buffer), SMLoc());
 EXPECT_EQ(Buffer, nullptr);
 
-Ctx.reset(
-new MCContext(MUPMAI.get(), MRI.get(), &MOFI, &SrcMgr, &MCOptions));
-MOFI.InitMCObjectFileInfo(Triple, false, *Ctx, false);
+Ctx.reset(new MCContext(Triple, MUPMAI.get(), MRI.get(), &MOFI, MSTI.get(),
+&SrcMgr, &MCOptions));
+MOFI.InitMCObjectFileInfo(/*PIC=*/false, *Ctx, /*LargeCodeModel=*/false);
 
 Str.reset(TheTarget->createNullStreamer(*Ctx));
 
Index: llvm/unittests/MC/DwarfLineTables.cpp
===
--- llvm/unittests/MC/DwarfLineTables.cpp
+++ llvm/unittests/MC/DwarfLineTables.cpp
@@ -21,7 +21,7 @@
 
 namespace {
 struct Context {
-  const char *Triple = "x86_64-pc-linux";
+  const char *TripleName = "x86_64-pc-linux";
   std::unique_ptr 

[PATCH] D101750: [clangd] Find implementors only when index is present.

2021-05-03 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 created this revision.
usaxena95 added a reviewer: sammccall.
Herald added subscribers: kadircet, arphaman.
usaxena95 requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101750

Files:
  clang-tools-extra/clangd/XRefs.cpp


Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -299,7 +299,7 @@
 RelationKind Predicate,
 const SymbolIndex *Index,
 llvm::StringRef MainFilePath) {
-  if (IDs.empty())
+  if (IDs.empty() || !Index)
 return {};
   static constexpr trace::Metric FindImplementorsMetric(
   "find_implementors", trace::Metric::Counter, "case");


Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -299,7 +299,7 @@
 RelationKind Predicate,
 const SymbolIndex *Index,
 llvm::StringRef MainFilePath) {
-  if (IDs.empty())
+  if (IDs.empty() || !Index)
 return {};
   static constexpr trace::Metric FindImplementorsMetric(
   "find_implementors", trace::Metric::Counter, "case");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101721: [clang-tidy][NFC] Update tests and Default options to use boolean value

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

LGTM! One thing I'd like to be sure of though -- do we still have at least one 
test that's showing you can use false/0 and true/1/nonzero interchangeably? If 
not, we should probably have one that shows which "alternate forms" are 
accepted.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101721

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


[clang] fe4c9b3 - [clang] Remove libstdc++ friend template hack

2021-05-03 Thread Nathan Sidwell via cfe-commits

Author: Nathan Sidwell
Date: 2021-05-03T04:19:30-07:00
New Revision: fe4c9b3cb0c3c0cac6b63de3b47a86e31559bb6d

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

LOG: [clang] Remove libstdc++ friend template hack

this hack is for a now-unsupported version of libstdc++

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

Added: 


Modified: 
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/test/SemaCXX/libstdcxx_map_base_hack.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index cd0f13b9e32ed..1d572054e5fb7 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -1518,48 +1518,18 @@ Decl 
*TemplateDeclInstantiator::VisitClassTemplateDecl(ClassTemplateDecl *D) {
   return nullptr;
 }
 
-bool AdoptedPreviousTemplateParams = false;
 if (PrevClassTemplate) {
-  bool Complain = true;
-
-  // HACK: libstdc++ 4.2.1 contains an ill-formed friend class
-  // template for struct std::tr1::__detail::_Map_base, where the
-  // template parameters of the friend declaration don't match the
-  // template parameters of the original declaration. In this one
-  // case, we don't complain about the ill-formed friend
-  // declaration.
-  if (isFriend && Pattern->getIdentifier() &&
-  Pattern->getIdentifier()->isStr("_Map_base") &&
-  DC->isNamespace() &&
-  cast(DC)->getIdentifier() &&
-  cast(DC)->getIdentifier()->isStr("__detail")) {
-DeclContext *DCParent = DC->getParent();
-if (DCParent->isNamespace() &&
-cast(DCParent)->getIdentifier() &&
-cast(DCParent)->getIdentifier()->isStr("tr1")) {
-  if (cast(DCParent)->isInStdNamespace())
-Complain = false;
-}
-  }
-
   TemplateParameterList *PrevParams
 = PrevClassTemplate->getMostRecentDecl()->getTemplateParameters();
 
   // Make sure the parameter lists match.
-  if (!SemaRef.TemplateParameterListsAreEqual(InstParams, PrevParams,
-  Complain,
-  Sema::TPL_TemplateMatch)) {
-if (Complain)
-  return nullptr;
-
-AdoptedPreviousTemplateParams = true;
-InstParams = PrevParams;
-  }
+  if (!SemaRef.TemplateParameterListsAreEqual(InstParams, PrevParams, true,
+  Sema::TPL_TemplateMatch))
+return nullptr;
 
   // Do some additional validation, then merge default arguments
   // from the existing declarations.
-  if (!AdoptedPreviousTemplateParams &&
-  SemaRef.CheckTemplateParameterList(InstParams, PrevParams,
+  if (SemaRef.CheckTemplateParameterList(InstParams, PrevParams,
  Sema::TPC_ClassTemplate))
 return nullptr;
 }

diff  --git a/clang/test/SemaCXX/libstdcxx_map_base_hack.cpp 
b/clang/test/SemaCXX/libstdcxx_map_base_hack.cpp
index a556281fc0f86..3662f667c0009 100644
--- a/clang/test/SemaCXX/libstdcxx_map_base_hack.cpp
+++ b/clang/test/SemaCXX/libstdcxx_map_base_hack.cpp
@@ -1,25 +1,27 @@
-// RUN: %clang_cc1 -fsyntax-only %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
 
 // libstdc++ 4.2.x contains a bug where a friend struct template
 // declaration for std::tr1::__detail::_Map base has 
diff erent
-// template arguments than the real declaration. Clang has an
-// egregious hack to work around this problem, since we can't modify
-// all of the world's libstdc++'s.
+// template arguments than the real declaration.
 
-namespace std { namespace tr1 { namespace __detail {
-  template
-struct _Map_base { };
+// We no longer contain the hack to workaround the problem.  Verify that
+// std::tr1::__detail::Map_base is not a unique and special snowflake.
 
+namespace std { namespace tr1 { namespace __detail {
+template 
+struct _Map_base {};
 } } } 
 
 namespace std { namespace tr1 {
   template
   struct X1 {
-template
+template 
+// expected-error@-1{{too few template parameters}}
 friend struct __detail::_Map_base;
   };
 
 } }
 
-std::tr1::X1 x1i;
+std::tr1::X1 x1i; // expected-note{{in instantiation}}



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


[PATCH] D101392: Remove libstdc++ friend template hack

2021-05-03 Thread Nathan Sidwell via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfe4c9b3cb0c3: [clang] Remove libstdc++ friend template hack 
(authored by urnathan).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101392

Files:
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/SemaCXX/libstdcxx_map_base_hack.cpp


Index: clang/test/SemaCXX/libstdcxx_map_base_hack.cpp
===
--- clang/test/SemaCXX/libstdcxx_map_base_hack.cpp
+++ clang/test/SemaCXX/libstdcxx_map_base_hack.cpp
@@ -1,25 +1,27 @@
-// RUN: %clang_cc1 -fsyntax-only %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
 
 // libstdc++ 4.2.x contains a bug where a friend struct template
 // declaration for std::tr1::__detail::_Map base has different
-// template arguments than the real declaration. Clang has an
-// egregious hack to work around this problem, since we can't modify
-// all of the world's libstdc++'s.
+// template arguments than the real declaration.
 
-namespace std { namespace tr1 { namespace __detail {
-  template
-struct _Map_base { };
+// We no longer contain the hack to workaround the problem.  Verify that
+// std::tr1::__detail::Map_base is not a unique and special snowflake.
 
+namespace std { namespace tr1 { namespace __detail {
+template 
+struct _Map_base {};
 } } } 
 
 namespace std { namespace tr1 {
   template
   struct X1 {
-template
+template 
+// expected-error@-1{{too few template parameters}}
 friend struct __detail::_Map_base;
   };
 
 } }
 
-std::tr1::X1 x1i;
+std::tr1::X1 x1i; // expected-note{{in instantiation}}
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -1518,48 +1518,18 @@
   return nullptr;
 }
 
-bool AdoptedPreviousTemplateParams = false;
 if (PrevClassTemplate) {
-  bool Complain = true;
-
-  // HACK: libstdc++ 4.2.1 contains an ill-formed friend class
-  // template for struct std::tr1::__detail::_Map_base, where the
-  // template parameters of the friend declaration don't match the
-  // template parameters of the original declaration. In this one
-  // case, we don't complain about the ill-formed friend
-  // declaration.
-  if (isFriend && Pattern->getIdentifier() &&
-  Pattern->getIdentifier()->isStr("_Map_base") &&
-  DC->isNamespace() &&
-  cast(DC)->getIdentifier() &&
-  cast(DC)->getIdentifier()->isStr("__detail")) {
-DeclContext *DCParent = DC->getParent();
-if (DCParent->isNamespace() &&
-cast(DCParent)->getIdentifier() &&
-cast(DCParent)->getIdentifier()->isStr("tr1")) {
-  if (cast(DCParent)->isInStdNamespace())
-Complain = false;
-}
-  }
-
   TemplateParameterList *PrevParams
 = PrevClassTemplate->getMostRecentDecl()->getTemplateParameters();
 
   // Make sure the parameter lists match.
-  if (!SemaRef.TemplateParameterListsAreEqual(InstParams, PrevParams,
-  Complain,
-  Sema::TPL_TemplateMatch)) {
-if (Complain)
-  return nullptr;
-
-AdoptedPreviousTemplateParams = true;
-InstParams = PrevParams;
-  }
+  if (!SemaRef.TemplateParameterListsAreEqual(InstParams, PrevParams, true,
+  Sema::TPL_TemplateMatch))
+return nullptr;
 
   // Do some additional validation, then merge default arguments
   // from the existing declarations.
-  if (!AdoptedPreviousTemplateParams &&
-  SemaRef.CheckTemplateParameterList(InstParams, PrevParams,
+  if (SemaRef.CheckTemplateParameterList(InstParams, PrevParams,
  Sema::TPC_ClassTemplate))
 return nullptr;
 }


Index: clang/test/SemaCXX/libstdcxx_map_base_hack.cpp
===
--- clang/test/SemaCXX/libstdcxx_map_base_hack.cpp
+++ clang/test/SemaCXX/libstdcxx_map_base_hack.cpp
@@ -1,25 +1,27 @@
-// RUN: %clang_cc1 -fsyntax-only %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
 
 // libstdc++ 4.2.x contains a bug where a friend struct template
 // declaration for std::tr1::__detail::_Map base has different
-// template arguments than the real declaration. Clang has an
-// egregious hack to work around this problem, since we can't modify
-// all of the world's libstdc++'s.
+// template arguments than the real declaration.
 
-namespace std { namespace tr1 { namespace __detail {
-  template
-struct _Map_base { };
+// We no longer contain the

[PATCH] D92024: [clang] Implement P0692R1 from C++20 (access checking on specializations and instantiations)

2021-05-03 Thread Kristina Bessonova via Phabricator via cfe-commits
krisb added inline comments.



Comment at: clang/lib/Parse/ParseDecl.cpp:3080
+// For instance this marked as unavailable:
+//class __attribute((unavailable)) UnavailableClass;`
+auto RemoveAccessCheckingDiagnostics = [&TemplateInfo, this]() {

aorlov wrote:
> krisb wrote:
> > Basically, if `__attribute((unavailable))` should trigger the error for any 
> > use of an unavailable class, we have it already broken.
> > For example, for this code clang-12 doesn't produce any diagnostics:
> > ```
> > class __attribute((unavailable)) X {
> >   template  class __attribute((unavailable)) Y {};
> > };
> > class __attribute((unavailable)) A { 
> > class __attribute((unavailable)) C {}; 
> > };
> > template <> class X::Y {};
> > ```
> > So, I don't see much sense in inventing something new to workaround only 
> > the cases that come with this patch. It's better to either fix it globally 
> > or leave it broken atm with the corresponding FIXME.
> Anyway, I tried to remove the access diagnostics only. Who knows which 
> diagnostics may be needed. Or you strongly prefer using 
> `SuppressAccessChecks` instead?
Basically, I'd prefer consistency. Having two different ways of doing (almost) 
the same things doesn't look good to me. But I'm not sure about 
`SuppressAccessChecks` as turns all kinds of diagnostics off. Did you consider 
a possibility to improve `SuppressAccessChecks` to disable only a particular 
(specified) type of diagnostics? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92024

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


[PATCH] D101526: [analyzer][StdLibraryFunctionsChecker] Add NoteTags for applied arg constraints

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



Comment at: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:688-703
 std::string StdLibraryFunctionsChecker::BufferSizeConstraint::describe(
-ProgramStateRef State, const Summary &Summary) const {
+DescritptionKind DK, ProgramStateRef State, const Summary &Summary) const {
   SmallString<96> Result;
-  Result += "The size of the ";
+  const auto Violation = ValueConstraint::DescritptionKind::Violation;
+  Result += "the size of the ";
   Result += getArgDesc(ArgN);
+  Result += DK == Violation ? " should be " : " is ";

I don't know. Report message construction always seemed clunky.
Clang's or ClangTidy's approach seems superior in this regard.

Do we have anything better for this @NoQ?
Maybe `llvm::format()` could be an option.

Regarding this patch: It's fine. Better than it was before!



Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:854
+  NewState, NewNode,
+  C.getNoteTag([Msg, ArgSVal](PathSensitiveBugReport &BR,
+  llvm::raw_ostream &OS) {





Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:857
+if (BR.isInteresting(ArgSVal))
+  OS << Msg;
+  }));

Ah, there is a slight issue.
You should mark some stuff interesting here, to make this interestingness 
propagate back transitively.

Let's say `ArgSVal` is `x + y` which is considered to be out of range 
`[42,52]`. We should mark both `x` and `y` interesting because they themselves 
could have been constrained by the StdLibChecker previously. So, they must be 
interesting as well.

On the same token, IMO `PathSensitiveBugReport::markInteresting(symbol)` should 
be //transitive//. So that all `SymbolData` in that symbolic expression tree 
are considered interesting. What do you think @NoQ?
If we were doing this, @martong  - you could simply acquire the assumption you 
constructed for the given `ValueConstraint`, and mark that interesting. Then 
all `SymbolData`s on both sides of the logic operator would become implicitly 
interesting.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101526

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


[PATCH] D101721: [clang-tidy][NFC] Update tests and Default options to use boolean value

2021-05-03 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

In D101721#2733125 , @aaron.ballman 
wrote:

> LGTM! One thing I'd like to be sure of though -- do we still have at least 
> one test that's showing you can use false/0 and true/1/nonzero 
> interchangeably? If not, we should probably have one that shows which 
> "alternate forms" are accepted.

`clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp::CheckOptionsValidation::ValidIntOptions`
 contains a test which supports 0 and 1. 
However in a few years once we can be confident most users are using 
clang-tidy-11 or newer, it may be wise to drop support for 0 and 1 in order to 
be inline with yaml completely.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101721

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


[PATCH] D101566: Let -Wweak-template-vtables warn on implicit instantiations

2021-05-03 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

In D101566#2730746 , @dblaikie wrote:

> Out of curiosity - have you tried it & measured any significant 
> improvement/value in build times/sizes/etc?

No, I fear that would take too much time. (Not so much the benchmarking, but 
making a number of fixes that can be expected to make a dent.)

> This doesn't sound especially compelling for a warning (& still seems pretty 
> much not what the original weak-vtables warning was intending to do for 
> templates - and an inversion of the weak-template-vtables (& so I think, if 
> we are going to have this new thing as a warning, it should have a different 
> name and the existing name should be removed)).
>
> I still really think the best thing is to delete the existing 
> weak-template-vtables warning entirely.

I still don't understand the difference. You can of course argue that explicit 
instantiations are still weak, but I'd be curious why anyone would care about 
that. What is the reason behind `-Wweak-vtables` if not compile time or build 
size reductions? I can just guess, because the original bug 6116 
 doesn't state a reason.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101566

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


[PATCH] D101721: [clang-tidy][NFC] Update tests and Default options to use boolean value

2021-05-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D101721#2733169 , @njames93 wrote:

> In D101721#2733125 , @aaron.ballman 
> wrote:
>
>> LGTM! One thing I'd like to be sure of though -- do we still have at least 
>> one test that's showing you can use false/0 and true/1/nonzero 
>> interchangeably? If not, we should probably have one that shows which 
>> "alternate forms" are accepted.
>
> `clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp::CheckOptionsValidation::ValidIntOptions`
>  contains a test which supports 0 and 1.

Awesome, thank you for verifying!

> However in a few years once we can be confident most users are using 
> clang-tidy-11 or newer, it may be wise to drop support for 0 and 1 in order 
> to be inline with yaml completely.

I think if we want to go that route (which seems sensible to me), we should 
start warning on using anything but true/false as being deprecated. WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101721

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


[PATCH] D101439: [clang-cl] Add parsing support for a bunch of new flags

2021-05-03 Thread Hans Wennborg via Phabricator via cfe-commits
hans marked 2 inline comments as done.
hans added inline comments.



Comment at: clang/include/clang/Driver/Options.td:6117
 def _SLASH_favor : CLJoined<"favor">;
+def _SLASH_fsanitize_address_use_after_return : 
CLJoined<"fsanitize-address-use-after-return">;
+def _SLASH_fno_sanitize_address_vcasan_lib : 
CLJoined<"fno-sanitize-address-vcasan-lib">;

thakis wrote:
> Can we ask (or check) how this one is implemented? Does it inject a custom 
> __asan_default_options that returns `detect_stack_use_after_return=1` or is 
> it more involved?
They have docs here:
https://docs.microsoft.com/en-us/cpp/sanitizers/asan-building?view=msvc-160#fsanitize-address-use-after-return-compiler-option-experimental

It sounds like unlike Clang, MSVC doesn't turn on the necessary instrumentation 
for this by default for performance reasons. The flag enables the 
instrumentation, but the user also needs to set ASAN_OPTIONS to enable it at 
run-time.



Comment at: clang/include/clang/Driver/Options.td:6118
+def _SLASH_fsanitize_address_use_after_return : 
CLJoined<"fsanitize-address-use-after-return">;
+def _SLASH_fno_sanitize_address_vcasan_lib : 
CLJoined<"fno-sanitize-address-vcasan-lib">;
 def _SLASH_F : CLJoinedOrSeparate<"F">;

thakis wrote:
> I guess this one controls library search paths and they have vc libs built 
> with and without asan?
There are some docs here: 
https://docs.microsoft.com/en-us/cpp/sanitizers/asan-building?view=msvc-160#fno-sanitize-address-vcasan-lib-compiler-option

It's an extra library that implements __asan_set_error_report_callback for a 
better debugging experience and integration with the IDE, it sounds like.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101439

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


[clang] 876bf51 - [clang-cl] Add parsing support for a bunch of new flags

2021-05-03 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2021-05-03T13:51:27+02:00
New Revision: 876bf516e7d4bba615da6cf791372fb36fc8f947

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

LOG: [clang-cl] Add parsing support for a bunch of new flags

MSVC has added some new flags. Although they're not supported, this adds
parsing support for them so clang-cl doesn't treat them as filenames.

Except for /fsanitize=address which we do support. (clang-cl already
exposes the -fsanitize= option, but this allows using the
MSVC-spelling with a slash.)

Differential revision: https://reviews.llvm.org/D101439

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/test/Driver/cl-options.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index ea1c861f4ac35..56e8b76def504 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5767,6 +5767,9 @@ def _SLASH_fp_fast : CLFlag<"fp:fast">, HelpText<"">, 
Alias;
 def _SLASH_fp_precise : CLFlag<"fp:precise">,
   HelpText<"">, Alias;
 def _SLASH_fp_strict : CLFlag<"fp:strict">, HelpText<"">, Alias;
+def _SLASH_fsanitize_EQ_address : CLFlag<"fsanitize=address">,
+  HelpText<"Enable AddressSanitizer">,
+  Alias, AliasArgs<["address"]>;
 def _SLASH_GA : CLFlag<"GA">, Alias, AliasArgs<["local-exec"]>,
   HelpText<"Assume thread-local variables are defined in the executable">;
 def _SLASH_GR : CLFlag<"GR">, HelpText<"Emit RTTI data (default)">;
@@ -6121,8 +6124,12 @@ def _SLASH_Bt_plus : CLFlag<"Bt+">;
 def _SLASH_clr : CLJoined<"clr">;
 def _SLASH_d2 : CLJoined<"d2">;
 def _SLASH_doc : CLJoined<"doc">;
+def _SLASH_experimental : CLJoined<"experimental:">;
+def _SLASH_exportHeader : CLFlag<"exportHeader">;
 def _SLASH_FA_joined : CLJoined<"FA">;
 def _SLASH_favor : CLJoined<"favor">;
+def _SLASH_fsanitize_address_use_after_return : 
CLJoined<"fsanitize-address-use-after-return">;
+def _SLASH_fno_sanitize_address_vcasan_lib : 
CLJoined<"fno-sanitize-address-vcasan-lib">;
 def _SLASH_F : CLJoinedOrSeparate<"F">;
 def _SLASH_Fm : CLJoined<"Fm">;
 def _SLASH_Fr : CLJoined<"Fr">;
@@ -6141,6 +6148,10 @@ def _SLASH_Gm_ : CLFlag<"Gm-">;
 def _SLASH_GT : CLFlag<"GT">;
 def _SLASH_GZ : CLFlag<"GZ">;
 def _SLASH_H : CLFlag<"H">;
+def _SLASH_headername : CLJoined<"headerName:">;
+def _SLASH_headerUnit : CLJoinedOrSeparate<"headerUnit">;
+def _SLASH_headerUnitAngle : CLJoinedOrSeparate<"headerUnit:angle">;
+def _SLASH_headerUnitQuote : CLJoinedOrSeparate<"headerUnit:quote">;
 def _SLASH_homeparams : CLFlag<"homeparams">;
 def _SLASH_hotpatch : CLFlag<"hotpatch">;
 def _SLASH_kernel : CLFlag<"kernel">;
@@ -6156,6 +6167,10 @@ def _SLASH_Qspectre : CLFlag<"Qspectre">;
 def _SLASH_Qspectre_load : CLFlag<"Qspectre-load">;
 def _SLASH_Qspectre_load_cf : CLFlag<"Qspectre-load-cf">;
 def _SLASH_Qvec_report : CLJoined<"Qvec-report">;
+def _SLASH_reference : CLJoinedOrSeparate<"reference">;
+def _SLASH_sourceDependencies : CLJoinedOrSeparate<"sourceDependencies">;
+def _SLASH_sourceDependenciesDirectives : 
CLJoinedOrSeparate<"sourceDependencies:directives">;
+def _SLASH_translateInclude : CLFlag<"translateInclude">;
 def _SLASH_u : CLFlag<"u">;
 def _SLASH_V : CLFlag<"V">;
 def _SLASH_WL : CLFlag<"WL">;

diff  --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c
index c74a6de1e6256..270eaa33b0d92 100644
--- a/clang/test/Driver/cl-options.c
+++ b/clang/test/Driver/cl-options.c
@@ -56,6 +56,9 @@
 // fpstrict-NOT: -menable-unsafe-fp-math
 // fpstrict-NOT: -ffast-math
 
+// RUN: %clang_cl /fsanitize=address -### -- %s 2>&1 | FileCheck 
-check-prefix=fsanitize_address %s
+// fsanitize_address: -fsanitize=address
+
 // RUN: %clang_cl -### /FA -fprofile-instr-generate -- %s 2>&1 | FileCheck 
-check-prefix=CHECK-PROFILE-INSTR-GENERATE %s
 // RUN: %clang_cl -### /FA -fprofile-instr-generate=/tmp/somefile.profraw -- 
%s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-INSTR-GENERATE-FILE %s
 // CHECK-PROFILE-INSTR-GENERATE: "-fprofile-instrument=clang" 
"--dependent-lib=clang_rt.profile{{[^"]*}}.lib"
@@ -425,6 +428,10 @@
 // RUN: /clr:pure \
 // RUN: /d2FH4 \
 // RUN: /docname \
+// RUN: /experimental:module \
+// RUN: /experimental:preprocessor \
+// RUN: /exportHeader /headerName:foo \
+// RUN: /headerUnit foo.h=foo.ifc /headerUnit:quote foo.h=foo.ifc 
/headerUnit:angle foo.h=foo.ifc \
 // RUN: /EHsc \
 // RUN: /F 42 \
 // RUN: /FA \
@@ -433,6 +440,8 @@
 // RUN: /FAs \
 // RUN: /FAu \
 // RUN: /favor:blend \
+// RUN: /fsanitize-address-use-after-return \
+// RUN: /fno-sanitize-address-vcasan-lib \
 // RUN: /Fifoo \
 // RUN: /Fmfoo \
 // RUN: /FpDebug\main.pch \
@@ -479,6 +488,10 @@
 // RUN: /Qspectre-load \

[PATCH] D101439: [clang-cl] Add parsing support for a bunch of new flags

2021-05-03 Thread Hans Wennborg via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
hans marked 2 inline comments as done.
Closed by commit rG876bf516e7d4: [clang-cl] Add parsing support for a bunch of 
new flags (authored by hans).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101439

Files:
  clang/include/clang/Driver/Options.td
  clang/test/Driver/cl-options.c


Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -56,6 +56,9 @@
 // fpstrict-NOT: -menable-unsafe-fp-math
 // fpstrict-NOT: -ffast-math
 
+// RUN: %clang_cl /fsanitize=address -### -- %s 2>&1 | FileCheck 
-check-prefix=fsanitize_address %s
+// fsanitize_address: -fsanitize=address
+
 // RUN: %clang_cl -### /FA -fprofile-instr-generate -- %s 2>&1 | FileCheck 
-check-prefix=CHECK-PROFILE-INSTR-GENERATE %s
 // RUN: %clang_cl -### /FA -fprofile-instr-generate=/tmp/somefile.profraw -- 
%s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-INSTR-GENERATE-FILE %s
 // CHECK-PROFILE-INSTR-GENERATE: "-fprofile-instrument=clang" 
"--dependent-lib=clang_rt.profile{{[^"]*}}.lib"
@@ -425,6 +428,10 @@
 // RUN: /clr:pure \
 // RUN: /d2FH4 \
 // RUN: /docname \
+// RUN: /experimental:module \
+// RUN: /experimental:preprocessor \
+// RUN: /exportHeader /headerName:foo \
+// RUN: /headerUnit foo.h=foo.ifc /headerUnit:quote foo.h=foo.ifc 
/headerUnit:angle foo.h=foo.ifc \
 // RUN: /EHsc \
 // RUN: /F 42 \
 // RUN: /FA \
@@ -433,6 +440,8 @@
 // RUN: /FAs \
 // RUN: /FAu \
 // RUN: /favor:blend \
+// RUN: /fsanitize-address-use-after-return \
+// RUN: /fno-sanitize-address-vcasan-lib \
 // RUN: /Fifoo \
 // RUN: /Fmfoo \
 // RUN: /FpDebug\main.pch \
@@ -479,6 +488,10 @@
 // RUN: /Qspectre-load \
 // RUN: /Qspectre-load-cf \
 // RUN: /Qvec-report:2 \
+// RUN: /reference foo=foo.ifc /reference foo.ifc \
+// RUN: /sourceDependencies foo.json \
+// RUN: /sourceDependencies:directives foo.json \
+// RUN: /translateInclude \
 // RUN: /u \
 // RUN: /V \
 // RUN: /volatile:ms \
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -5767,6 +5767,9 @@
 def _SLASH_fp_precise : CLFlag<"fp:precise">,
   HelpText<"">, Alias;
 def _SLASH_fp_strict : CLFlag<"fp:strict">, HelpText<"">, Alias;
+def _SLASH_fsanitize_EQ_address : CLFlag<"fsanitize=address">,
+  HelpText<"Enable AddressSanitizer">,
+  Alias, AliasArgs<["address"]>;
 def _SLASH_GA : CLFlag<"GA">, Alias, AliasArgs<["local-exec"]>,
   HelpText<"Assume thread-local variables are defined in the executable">;
 def _SLASH_GR : CLFlag<"GR">, HelpText<"Emit RTTI data (default)">;
@@ -6121,8 +6124,12 @@
 def _SLASH_clr : CLJoined<"clr">;
 def _SLASH_d2 : CLJoined<"d2">;
 def _SLASH_doc : CLJoined<"doc">;
+def _SLASH_experimental : CLJoined<"experimental:">;
+def _SLASH_exportHeader : CLFlag<"exportHeader">;
 def _SLASH_FA_joined : CLJoined<"FA">;
 def _SLASH_favor : CLJoined<"favor">;
+def _SLASH_fsanitize_address_use_after_return : 
CLJoined<"fsanitize-address-use-after-return">;
+def _SLASH_fno_sanitize_address_vcasan_lib : 
CLJoined<"fno-sanitize-address-vcasan-lib">;
 def _SLASH_F : CLJoinedOrSeparate<"F">;
 def _SLASH_Fm : CLJoined<"Fm">;
 def _SLASH_Fr : CLJoined<"Fr">;
@@ -6141,6 +6148,10 @@
 def _SLASH_GT : CLFlag<"GT">;
 def _SLASH_GZ : CLFlag<"GZ">;
 def _SLASH_H : CLFlag<"H">;
+def _SLASH_headername : CLJoined<"headerName:">;
+def _SLASH_headerUnit : CLJoinedOrSeparate<"headerUnit">;
+def _SLASH_headerUnitAngle : CLJoinedOrSeparate<"headerUnit:angle">;
+def _SLASH_headerUnitQuote : CLJoinedOrSeparate<"headerUnit:quote">;
 def _SLASH_homeparams : CLFlag<"homeparams">;
 def _SLASH_hotpatch : CLFlag<"hotpatch">;
 def _SLASH_kernel : CLFlag<"kernel">;
@@ -6156,6 +6167,10 @@
 def _SLASH_Qspectre_load : CLFlag<"Qspectre-load">;
 def _SLASH_Qspectre_load_cf : CLFlag<"Qspectre-load-cf">;
 def _SLASH_Qvec_report : CLJoined<"Qvec-report">;
+def _SLASH_reference : CLJoinedOrSeparate<"reference">;
+def _SLASH_sourceDependencies : CLJoinedOrSeparate<"sourceDependencies">;
+def _SLASH_sourceDependenciesDirectives : 
CLJoinedOrSeparate<"sourceDependencies:directives">;
+def _SLASH_translateInclude : CLFlag<"translateInclude">;
 def _SLASH_u : CLFlag<"u">;
 def _SLASH_V : CLFlag<"V">;
 def _SLASH_WL : CLFlag<"WL">;


Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -56,6 +56,9 @@
 // fpstrict-NOT: -menable-unsafe-fp-math
 // fpstrict-NOT: -ffast-math
 
+// RUN: %clang_cl /fsanitize=address -### -- %s 2>&1 | FileCheck -check-prefix=fsanitize_address %s
+// 

[clang] 530e074 - Thread safety analysis: Replace flags in FactEntry by SourceKind (NFC)

2021-05-03 Thread Aaron Puchert via cfe-commits

Author: Aaron Puchert
Date: 2021-05-03T14:03:17+02:00
New Revision: 530e074faafe995a560e80815f5af8306670ea7b

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

LOG: Thread safety analysis: Replace flags in FactEntry by SourceKind (NFC)

The motivation here is to make it available in the base class whether a
fact is managed or not. That would have meant three flags on the base
class, so I had a look whether we really have 8 possible combinations.

It turns out we don't: asserted and declared are obviously mutually
exclusive. Managed facts are only created when we acquire a capability
through a scoped capability. Adopting an asserted or declared lock will
not (in fact can not, because Facts are immutable) make them managed.

We probably don't want to allow adopting an asserted lock (because then
the function should probably have a release attribute, and then the
assertion is pointless), but we might at some point decide to replace a
declared fact on adoption.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang/lib/Analysis/ThreadSafety.cpp

Removed: 




diff  --git a/clang/lib/Analysis/ThreadSafety.cpp 
b/clang/lib/Analysis/ThreadSafety.cpp
index cbb992f40c32b..bb3a4f1616fca 100644
--- a/clang/lib/Analysis/ThreadSafety.cpp
+++ b/clang/lib/Analysis/ThreadSafety.cpp
@@ -105,32 +105,37 @@ class FactSet;
 ///
 /// FIXME: this analysis does not currently support re-entrant locking.
 class FactEntry : public CapabilityExpr {
+public:
+  /// Where a fact comes from.
+  enum SourceKind {
+Acquired, ///< The fact has been directly acquired.
+Asserted, ///< The fact has been asserted to be held.
+Declared, ///< The fact is assumed to be held by callers.
+Managed,  ///< The fact has been acquired through a scoped capability.
+  };
+
 private:
   /// Exclusive or shared.
-  LockKind LKind;
+  LockKind LKind : 8;
+
+  // How it was acquired.
+  SourceKind Source : 8;
 
   /// Where it was acquired.
   SourceLocation AcquireLoc;
 
-  /// True if the lock was asserted.
-  bool Asserted;
-
-  /// True if the lock was declared.
-  bool Declared;
-
 public:
   FactEntry(const CapabilityExpr &CE, LockKind LK, SourceLocation Loc,
-bool Asrt, bool Declrd = false)
-  : CapabilityExpr(CE), LKind(LK), AcquireLoc(Loc), Asserted(Asrt),
-Declared(Declrd) {}
+SourceKind Src)
+  : CapabilityExpr(CE), LKind(LK), Source(Src), AcquireLoc(Loc) {}
   virtual ~FactEntry() = default;
 
   LockKind kind() const { return LKind;  }
   SourceLocation loc() const { return AcquireLoc; }
-  bool asserted() const { return Asserted; }
-  bool declared() const { return Declared; }
 
-  void setDeclared(bool D) { Declared = D; }
+  bool asserted() const { return Source == Asserted; }
+  bool declared() const { return Source == Declared; }
+  bool managed() const { return Source == Managed; }
 
   virtual void
   handleRemovalFromIntersection(const FactSet &FSet, FactManager &FactMan,
@@ -851,20 +856,16 @@ static void findBlockLocations(CFG *CFGraph,
 namespace {
 
 class LockableFactEntry : public FactEntry {
-private:
-  /// managed by ScopedLockable object
-  bool Managed;
-
 public:
   LockableFactEntry(const CapabilityExpr &CE, LockKind LK, SourceLocation Loc,
-bool Mng = false, bool Asrt = false)
-  : FactEntry(CE, LK, Loc, Asrt), Managed(Mng) {}
+SourceKind Src = Acquired)
+  : FactEntry(CE, LK, Loc, Src) {}
 
   void
   handleRemovalFromIntersection(const FactSet &FSet, FactManager &FactMan,
 SourceLocation JoinLoc, LockErrorKind LEK,
 ThreadSafetyHandler &Handler) const override {
-if (!Managed && !asserted() && !negative() && !isUniversal()) {
+if (!managed() && !asserted() && !negative() && !isUniversal()) {
   Handler.handleMutexHeldEndOfScope("mutex", toString(), loc(), JoinLoc,
 LEK);
 }
@@ -903,7 +904,7 @@ class ScopedLockableFactEntry : public FactEntry {
 
 public:
   ScopedLockableFactEntry(const CapabilityExpr &CE, SourceLocation Loc)
-  : FactEntry(CE, LK_Exclusive, Loc, false) {}
+  : FactEntry(CE, LK_Exclusive, Loc, Acquired) {}
 
   void addLock(const CapabilityExpr &M) {
 UnderlyingMutexes.emplace_back(M.sexpr(), UCK_Acquired);
@@ -983,7 +984,7 @@ class ScopedLockableFactEntry : public FactEntry {
 } else {
   FSet.removeLock(FactMan, !Cp);
   FSet.addLock(FactMan,
-   std::make_unique(Cp, kind, loc, true));
+   std::make_unique(Cp, kind, loc, 
Managed));
 }
   }
 
@@ -1854,10 +1855,11 @@ void BuildLockset::handleCall(const Expr *Exp, const 
NamedDecl *D,
 

[clang] daca6ed - Thread safety analysis: Fix false negative on break

2021-05-03 Thread Aaron Puchert via cfe-commits

Author: Aaron Puchert
Date: 2021-05-03T14:03:17+02:00
New Revision: daca6edb31efae048a420595fae9750aaa91c733

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

LOG: Thread safety analysis: Fix false negative on break

We weren't modifying the lock set when intersecting with one coming
from a break-terminated block. This is inconsistent, since break isn't a
back edge, and it leads to false negatives with scoped locks. We usually
don't warn for those when joining locksets aren't the same, we just
silently remove locks that are not in the intersection. But not warning
and not removing them isn't right.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang/lib/Analysis/ThreadSafety.cpp
clang/test/PCH/thread-safety-attrs.cpp
clang/test/SemaCXX/warn-thread-safety-analysis.cpp

Removed: 




diff  --git a/clang/lib/Analysis/ThreadSafety.cpp 
b/clang/lib/Analysis/ThreadSafety.cpp
index bb3a4f1616fca..4377fc58a1d55 100644
--- a/clang/lib/Analysis/ThreadSafety.cpp
+++ b/clang/lib/Analysis/ThreadSafety.cpp
@@ -2467,11 +2467,10 @@ void 
ThreadSafetyAnalyzer::runAnalysis(AnalysisDeclContext &AC) {
PrevBlock, CurrBlock);
 
 // Do not update EntrySet.
-intersectAndWarn(CurrBlockInfo->EntrySet, PrevLockset,
- PrevBlockInfo->ExitLoc,
- IsLoop ? LEK_LockedSomeLoopIterations
-: LEK_LockedSomePredecessors,
- false);
+intersectAndWarn(
+CurrBlockInfo->EntrySet, PrevLockset, PrevBlockInfo->ExitLoc,
+IsLoop ? LEK_LockedSomeLoopIterations : LEK_LockedSomePredecessors,
+!IsLoop);
   }
 }
 

diff  --git a/clang/test/PCH/thread-safety-attrs.cpp 
b/clang/test/PCH/thread-safety-attrs.cpp
index ae2a413af31c8..3e0c081f134f9 100644
--- a/clang/test/PCH/thread-safety-attrs.cpp
+++ b/clang/test/PCH/thread-safety-attrs.cpp
@@ -311,7 +311,8 @@ void sls_fun_bad_12() {
 }
 sls_mu.Lock();
   }
-  sls_mu.Unlock();
+  sls_mu.Unlock(); // \
+// expected-warning{{releasing mutex 'sls_mu' that was not held}}
 }
 
 #endif

diff  --git a/clang/test/SemaCXX/warn-thread-safety-analysis.cpp 
b/clang/test/SemaCXX/warn-thread-safety-analysis.cpp
index b837206138a67..369952eb397a2 100644
--- a/clang/test/SemaCXX/warn-thread-safety-analysis.cpp
+++ b/clang/test/SemaCXX/warn-thread-safety-analysis.cpp
@@ -337,7 +337,8 @@ void sls_fun_bad_12() {
 }
 sls_mu.Lock();
   }
-  sls_mu.Unlock();
+  sls_mu.Unlock(); // \
+// expected-warning{{releasing mutex 'sls_mu' that was not held}}
 }
 
 //-//
@@ -2582,6 +2583,7 @@ class Foo {
   void test3();
   void test4();
   void test5();
+  void test6();
 };
 
 
@@ -2620,6 +2622,18 @@ void Foo::test5() {
   rlock.Release();  // expected-warning {{releasing mutex 'mu_' that was not 
held}}
 }
 
+void Foo::test6() {
+  ReleasableMutexLock rlock(&mu_);
+  do {
+if (c) {
+  rlock.Release();
+  break;
+}
+  } while (c);
+  // No warning on join point because the lock will be released by the scope 
object anyway
+  a = 1; // expected-warning {{writing variable 'a' requires holding mutex 
'mu_' exclusively}}
+}
+
 
 } // end namespace ReleasableScopedLock
 



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


[PATCH] D100801: Thread safety analysis: Replace flags in FactEntry by SourceKind [NFC]

2021-05-03 Thread Aaron Puchert via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
aaronpuchert marked an inline comment as done.
Closed by commit rG530e074faafe: Thread safety analysis: Replace flags in 
FactEntry by SourceKind (NFC) (authored by aaronpuchert).

Changed prior to commit:
  https://reviews.llvm.org/D100801?vs=338656&id=342361#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100801

Files:
  clang/lib/Analysis/ThreadSafety.cpp

Index: clang/lib/Analysis/ThreadSafety.cpp
===
--- clang/lib/Analysis/ThreadSafety.cpp
+++ clang/lib/Analysis/ThreadSafety.cpp
@@ -105,32 +105,37 @@
 ///
 /// FIXME: this analysis does not currently support re-entrant locking.
 class FactEntry : public CapabilityExpr {
+public:
+  /// Where a fact comes from.
+  enum SourceKind {
+Acquired, ///< The fact has been directly acquired.
+Asserted, ///< The fact has been asserted to be held.
+Declared, ///< The fact is assumed to be held by callers.
+Managed,  ///< The fact has been acquired through a scoped capability.
+  };
+
 private:
   /// Exclusive or shared.
-  LockKind LKind;
+  LockKind LKind : 8;
+
+  // How it was acquired.
+  SourceKind Source : 8;
 
   /// Where it was acquired.
   SourceLocation AcquireLoc;
 
-  /// True if the lock was asserted.
-  bool Asserted;
-
-  /// True if the lock was declared.
-  bool Declared;
-
 public:
   FactEntry(const CapabilityExpr &CE, LockKind LK, SourceLocation Loc,
-bool Asrt, bool Declrd = false)
-  : CapabilityExpr(CE), LKind(LK), AcquireLoc(Loc), Asserted(Asrt),
-Declared(Declrd) {}
+SourceKind Src)
+  : CapabilityExpr(CE), LKind(LK), Source(Src), AcquireLoc(Loc) {}
   virtual ~FactEntry() = default;
 
   LockKind kind() const { return LKind;  }
   SourceLocation loc() const { return AcquireLoc; }
-  bool asserted() const { return Asserted; }
-  bool declared() const { return Declared; }
 
-  void setDeclared(bool D) { Declared = D; }
+  bool asserted() const { return Source == Asserted; }
+  bool declared() const { return Source == Declared; }
+  bool managed() const { return Source == Managed; }
 
   virtual void
   handleRemovalFromIntersection(const FactSet &FSet, FactManager &FactMan,
@@ -851,20 +856,16 @@
 namespace {
 
 class LockableFactEntry : public FactEntry {
-private:
-  /// managed by ScopedLockable object
-  bool Managed;
-
 public:
   LockableFactEntry(const CapabilityExpr &CE, LockKind LK, SourceLocation Loc,
-bool Mng = false, bool Asrt = false)
-  : FactEntry(CE, LK, Loc, Asrt), Managed(Mng) {}
+SourceKind Src = Acquired)
+  : FactEntry(CE, LK, Loc, Src) {}
 
   void
   handleRemovalFromIntersection(const FactSet &FSet, FactManager &FactMan,
 SourceLocation JoinLoc, LockErrorKind LEK,
 ThreadSafetyHandler &Handler) const override {
-if (!Managed && !asserted() && !negative() && !isUniversal()) {
+if (!managed() && !asserted() && !negative() && !isUniversal()) {
   Handler.handleMutexHeldEndOfScope("mutex", toString(), loc(), JoinLoc,
 LEK);
 }
@@ -903,7 +904,7 @@
 
 public:
   ScopedLockableFactEntry(const CapabilityExpr &CE, SourceLocation Loc)
-  : FactEntry(CE, LK_Exclusive, Loc, false) {}
+  : FactEntry(CE, LK_Exclusive, Loc, Acquired) {}
 
   void addLock(const CapabilityExpr &M) {
 UnderlyingMutexes.emplace_back(M.sexpr(), UCK_Acquired);
@@ -983,7 +984,7 @@
 } else {
   FSet.removeLock(FactMan, !Cp);
   FSet.addLock(FactMan,
-   std::make_unique(Cp, kind, loc, true));
+   std::make_unique(Cp, kind, loc, Managed));
 }
   }
 
@@ -1854,10 +1855,11 @@
 CapExprSet AssertLocks;
 Analyzer->getMutexIDs(AssertLocks, A, Exp, D, VD);
 for (const auto &AssertLock : AssertLocks)
-  Analyzer->addLock(FSet,
-std::make_unique(
-AssertLock, LK_Exclusive, Loc, false, true),
-ClassifyDiagnostic(A));
+  Analyzer->addLock(
+  FSet,
+  std::make_unique(AssertLock, LK_Exclusive, Loc,
+  FactEntry::Asserted),
+  ClassifyDiagnostic(A));
 break;
   }
   case attr::AssertSharedLock: {
@@ -1866,10 +1868,11 @@
 CapExprSet AssertLocks;
 Analyzer->getMutexIDs(AssertLocks, A, Exp, D, VD);
 for (const auto &AssertLock : AssertLocks)
-  Analyzer->addLock(FSet,
-std::make_unique(
-AssertLock, LK_Shared, Loc, false, true),
-ClassifyDiagnostic(A));
+  Ana

[PATCH] D101754: [Matrix] Remove bitcast when casting between matrices of the same size

2021-05-03 Thread Saurabh Jha via Phabricator via cfe-commits
SaurabhJha created this revision.
Herald added a subscriber: tschuett.
SaurabhJha requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

In matrix type casts, we were doing bitcast when the matrices had the same 
size. This was incorrect and this patch fixes that.
Also added some new CodeGen tests for signed <-> usigned conversions


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101754

Files:
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/test/CodeGen/matrix-cast.c


Index: clang/test/CodeGen/matrix-cast.c
===
--- clang/test/CodeGen/matrix-cast.c
+++ clang/test/CodeGen/matrix-cast.c
@@ -52,13 +52,23 @@
 void cast_int_matrix_to_float(ix5x5 i, fx5x5 f) {
   // CHECK-LABEL: define{{.*}} void @cast_int_matrix_to_float(<25 x i32> %i, 
<25 x float> %f)
   // CHECK:   [[I:%.*]] = load <25 x i32>, <25 x i32>* {{.*}}, align 4
-  // CHECK-NEXT:  [[CONV:%.*]] = bitcast <25 x i32> [[I]] to <25 x float>
+  // CHECK-NEXT:  [[CONV:%.*]] = sitofp <25 x i32> [[I]] to <25 x float>
   // CHECK-NEXT:  store <25 x float> [[CONV]], <25 x float>* {{.*}}, align 4
   // CHECK-NEXT:  ret void
 
   f = (fx5x5)i;
 }
 
+void cast_unsigned_int_matrix_to_float(unsigned_short_int_5x5 u, fx5x5 f) {
+  // CHECK-LABEL: define{{.*}} void @cast_unsigned_int_matrix_to_float(<25 x 
i16> %u, <25 x float> %f)
+  // CHECK:   [[U:%.*]] = load <25 x i16>, <25 x i16>* {{.*}}, align 2
+  // CHECK-NEXT:  [[CONV:%.*]] = uitofp <25 x i16> [[U]] to <25 x float>
+  // CHECK-NEXT:  store <25 x float> [[CONV]], <25 x float>* {{.*}}, align 4
+  // CHECK-NEXT:  ret void
+
+  f = (fx5x5)u;
+}
+
 void cast_double_matrix_to_int(dx5x5 d, ix5x5 i) {
   // CHECK-LABEL: define{{.*}} void @cast_double_matrix_to_int(<25 x double> 
%d, <25 x i32> %i)
   // CHECK:   [[D:%.*]] = load <25 x double>, <25 x double>* {{.*}}, align 
8
@@ -108,3 +118,23 @@
 
   s = (unsigned_short_int_5x5)l;
 }
+
+void cast_unsigned_short_int_to_int(unsigned_short_int_5x5 u, ix5x5 i) {
+  // CHECK-LABEL: define{{.*}} void @cast_unsigned_short_int_to_int(<25 x i16> 
%u, <25 x i32> %i)
+  // CHECK:   [[U:%.*]] = load <25 x i16>, <25 x i16>* %0, align 2
+  // CHECK-NEXT:  [[CONV:%.*]] = zext <25 x i16> [[U]] to <25 x i32>
+  // CHECK-NEXT:  store <25 x i32> [[CONV]], <25 x i32>* {{.*}}, align 4
+  // CHECK-NEXT:  ret void
+
+  i = (ix5x5)u;
+}
+
+void cast_int_to_unsigned_long_int(ix5x5 i, unsigned_long_int_5x5 u) {
+  // CHECK-LABEL: define{{.*}} void @cast_int_to_unsigned_long_int(<25 x i32> 
%i, <25 x i64> %u)
+  // CHECK:   [[I:%.*]] = load <25 x i32>, <25 x i32>* %0, align 4
+  // CHECK-NEXT:  [[CONV:%.*]] = sext <25 x i32> [[I]] to <25 x i64>
+  // CHECK-NEXT:  store <25 x i64> [[CONV]], <25 x i64>* {{.*}}, align 8
+  // CHECK-NEXT:  ret void
+
+  u = (unsigned_long_int_5x5)i;
+}
Index: clang/lib/CodeGen/CGExprScalar.cpp
===
--- clang/lib/CodeGen/CGExprScalar.cpp
+++ clang/lib/CodeGen/CGExprScalar.cpp
@@ -1205,10 +1205,6 @@
   QualType SrcElementType;
   QualType DstElementType;
   if (SrcType->isMatrixType() && DstType->isMatrixType()) {
-// Allow bitcast between matrixes of the same size.
-if (SrcTy->getPrimitiveSizeInBits() == DstTy->getPrimitiveSizeInBits())
-  return Builder.CreateBitCast(Src, DstTy, "conv");
-
 SrcElementTy = cast(SrcTy)->getElementType();
 DstElementTy = cast(DstTy)->getElementType();
 SrcElementType = SrcType->castAs()->getElementType();


Index: clang/test/CodeGen/matrix-cast.c
===
--- clang/test/CodeGen/matrix-cast.c
+++ clang/test/CodeGen/matrix-cast.c
@@ -52,13 +52,23 @@
 void cast_int_matrix_to_float(ix5x5 i, fx5x5 f) {
   // CHECK-LABEL: define{{.*}} void @cast_int_matrix_to_float(<25 x i32> %i, <25 x float> %f)
   // CHECK:   [[I:%.*]] = load <25 x i32>, <25 x i32>* {{.*}}, align 4
-  // CHECK-NEXT:  [[CONV:%.*]] = bitcast <25 x i32> [[I]] to <25 x float>
+  // CHECK-NEXT:  [[CONV:%.*]] = sitofp <25 x i32> [[I]] to <25 x float>
   // CHECK-NEXT:  store <25 x float> [[CONV]], <25 x float>* {{.*}}, align 4
   // CHECK-NEXT:  ret void
 
   f = (fx5x5)i;
 }
 
+void cast_unsigned_int_matrix_to_float(unsigned_short_int_5x5 u, fx5x5 f) {
+  // CHECK-LABEL: define{{.*}} void @cast_unsigned_int_matrix_to_float(<25 x i16> %u, <25 x float> %f)
+  // CHECK:   [[U:%.*]] = load <25 x i16>, <25 x i16>* {{.*}}, align 2
+  // CHECK-NEXT:  [[CONV:%.*]] = uitofp <25 x i16> [[U]] to <25 x float>
+  // CHECK-NEXT:  store <25 x float> [[CONV]], <25 x float>* {{.*}}, align 4
+  // CHECK-NEXT:  ret void
+
+  f = (fx5x5)u;
+}
+
 void cast_double_matrix_to_int(dx5x5 d, ix5x5 i) {
   // CHECK-LABEL: define{{.*}} void @cast_double_matrix_to_int(<25 x double> %d, <25 x i32> %i)
   // CHECK:   [[D:%.*]] = load <25 x double>, <25 x double>* {{.*}}, align 8
@@ -108,3 +118,23 @@
 

[PATCH] D101202: Thread safety analysis: Fix false negative on break

2021-05-03 Thread Aaron Puchert 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 rGdaca6edb31ef: Thread safety analysis: Fix false negative on 
break (authored by aaronpuchert).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101202

Files:
  clang/lib/Analysis/ThreadSafety.cpp
  clang/test/PCH/thread-safety-attrs.cpp
  clang/test/SemaCXX/warn-thread-safety-analysis.cpp


Index: clang/test/SemaCXX/warn-thread-safety-analysis.cpp
===
--- clang/test/SemaCXX/warn-thread-safety-analysis.cpp
+++ clang/test/SemaCXX/warn-thread-safety-analysis.cpp
@@ -337,7 +337,8 @@
 }
 sls_mu.Lock();
   }
-  sls_mu.Unlock();
+  sls_mu.Unlock(); // \
+// expected-warning{{releasing mutex 'sls_mu' that was not held}}
 }
 
 //-//
@@ -2582,6 +2583,7 @@
   void test3();
   void test4();
   void test5();
+  void test6();
 };
 
 
@@ -2620,6 +2622,18 @@
   rlock.Release();  // expected-warning {{releasing mutex 'mu_' that was not 
held}}
 }
 
+void Foo::test6() {
+  ReleasableMutexLock rlock(&mu_);
+  do {
+if (c) {
+  rlock.Release();
+  break;
+}
+  } while (c);
+  // No warning on join point because the lock will be released by the scope 
object anyway
+  a = 1; // expected-warning {{writing variable 'a' requires holding mutex 
'mu_' exclusively}}
+}
+
 
 } // end namespace ReleasableScopedLock
 
Index: clang/test/PCH/thread-safety-attrs.cpp
===
--- clang/test/PCH/thread-safety-attrs.cpp
+++ clang/test/PCH/thread-safety-attrs.cpp
@@ -311,7 +311,8 @@
 }
 sls_mu.Lock();
   }
-  sls_mu.Unlock();
+  sls_mu.Unlock(); // \
+// expected-warning{{releasing mutex 'sls_mu' that was not held}}
 }
 
 #endif
Index: clang/lib/Analysis/ThreadSafety.cpp
===
--- clang/lib/Analysis/ThreadSafety.cpp
+++ clang/lib/Analysis/ThreadSafety.cpp
@@ -2467,11 +2467,10 @@
PrevBlock, CurrBlock);
 
 // Do not update EntrySet.
-intersectAndWarn(CurrBlockInfo->EntrySet, PrevLockset,
- PrevBlockInfo->ExitLoc,
- IsLoop ? LEK_LockedSomeLoopIterations
-: LEK_LockedSomePredecessors,
- false);
+intersectAndWarn(
+CurrBlockInfo->EntrySet, PrevLockset, PrevBlockInfo->ExitLoc,
+IsLoop ? LEK_LockedSomeLoopIterations : LEK_LockedSomePredecessors,
+!IsLoop);
   }
 }
 


Index: clang/test/SemaCXX/warn-thread-safety-analysis.cpp
===
--- clang/test/SemaCXX/warn-thread-safety-analysis.cpp
+++ clang/test/SemaCXX/warn-thread-safety-analysis.cpp
@@ -337,7 +337,8 @@
 }
 sls_mu.Lock();
   }
-  sls_mu.Unlock();
+  sls_mu.Unlock(); // \
+// expected-warning{{releasing mutex 'sls_mu' that was not held}}
 }
 
 //-//
@@ -2582,6 +2583,7 @@
   void test3();
   void test4();
   void test5();
+  void test6();
 };
 
 
@@ -2620,6 +2622,18 @@
   rlock.Release();  // expected-warning {{releasing mutex 'mu_' that was not held}}
 }
 
+void Foo::test6() {
+  ReleasableMutexLock rlock(&mu_);
+  do {
+if (c) {
+  rlock.Release();
+  break;
+}
+  } while (c);
+  // No warning on join point because the lock will be released by the scope object anyway
+  a = 1; // expected-warning {{writing variable 'a' requires holding mutex 'mu_' exclusively}}
+}
+
 
 } // end namespace ReleasableScopedLock
 
Index: clang/test/PCH/thread-safety-attrs.cpp
===
--- clang/test/PCH/thread-safety-attrs.cpp
+++ clang/test/PCH/thread-safety-attrs.cpp
@@ -311,7 +311,8 @@
 }
 sls_mu.Lock();
   }
-  sls_mu.Unlock();
+  sls_mu.Unlock(); // \
+// expected-warning{{releasing mutex 'sls_mu' that was not held}}
 }
 
 #endif
Index: clang/lib/Analysis/ThreadSafety.cpp
===
--- clang/lib/Analysis/ThreadSafety.cpp
+++ clang/lib/Analysis/ThreadSafety.cpp
@@ -2467,11 +2467,10 @@
PrevBlock, CurrBlock);
 
 // Do not update EntrySet.
-intersectAndWarn(CurrBlockInfo->EntrySet, PrevLockset,
- PrevBlockInfo->ExitLoc,
- IsLoop ? LEK_LockedSomeLoopIterations
-: LEK_LockedSomePredecessors,
- false);
+intersectAndWarn(
+CurrBlockInfo->EntrySet, PrevLockset, PrevBlockInfo->ExitLoc,
+IsLoop ? LEK_LockedSomeLoopIterations : LEK_LockedSomePredecessors,
+!IsLoop);
   }
 }
 
__

[PATCH] D101755: Thread safety analysis: Eliminate parameter from intersectAndWarn (NFC)

2021-05-03 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert created this revision.
aaronpuchert added reviewers: aaron.ballman, delesley.
aaronpuchert requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

We were modifying precisely when intersecting the lock sets of multiple
predecessors without back edge. That's no coincidence: we can't modify
on back edges, it doesn't make sense to modify at the end of a function,
and otherwise we always want to intersect on forward edges, because we
can build a new lock set for those.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101755

Files:
  clang/lib/Analysis/ThreadSafety.cpp


Index: clang/lib/Analysis/ThreadSafety.cpp
===
--- clang/lib/Analysis/ThreadSafety.cpp
+++ clang/lib/Analysis/ThreadSafety.cpp
@@ -1051,14 +1051,12 @@
   const CFGBlock *CurrBlock);
 
   void intersectAndWarn(FactSet &FSet1, const FactSet &FSet2,
-SourceLocation JoinLoc,
-LockErrorKind LEK1, LockErrorKind LEK2,
-bool Modify=true);
+SourceLocation JoinLoc, LockErrorKind LEK1,
+LockErrorKind LEK2);
 
   void intersectAndWarn(FactSet &FSet1, const FactSet &FSet2,
-SourceLocation JoinLoc, LockErrorKind LEK1,
-bool Modify=true) {
-intersectAndWarn(FSet1, FSet2, JoinLoc, LEK1, LEK1, Modify);
+SourceLocation JoinLoc, LockErrorKind LEK1) {
+intersectAndWarn(FSet1, FSet2, JoinLoc, LEK1, LEK1);
   }
 
   void runAnalysis(AnalysisDeclContext &AC);
@@ -2206,8 +2204,7 @@
 const FactSet &FSet2,
 SourceLocation JoinLoc,
 LockErrorKind LEK1,
-LockErrorKind LEK2,
-bool Modify) {
+LockErrorKind LEK2) {
   FactSet FSet1Orig = FSet1;
 
   // Find locks in FSet2 that conflict or are not in FSet1, and warn.
@@ -2220,11 +2217,13 @@
   if (LDat1.kind() != LDat2.kind()) {
 Handler.handleExclusiveAndShared("mutex", LDat2.toString(), 
LDat2.loc(),
  LDat1.loc());
-if (Modify && LDat1.kind() != LK_Exclusive) {
+if (LEK1 == LEK_LockedSomePredecessors &&
+LDat1.kind() != LK_Exclusive) {
   // Take the exclusive lock, which is the one in FSet2.
   *Iter1 = Fact;
 }
-  } else if (Modify && LDat1.asserted() && !LDat2.asserted()) {
+  } else if (LEK1 == LEK_LockedSomePredecessors && LDat1.asserted() &&
+ !LDat2.asserted()) {
 // The non-asserted lock in FSet2 is the one we want to track.
 *Iter1 = Fact;
   }
@@ -2242,7 +2241,7 @@
 if (!LDat2) {
   LDat1->handleRemovalFromIntersection(FSet1Orig, FactMan, JoinLoc, LEK2,
Handler);
-  if (Modify)
+  if (LEK2 == LEK_LockedSomePredecessors)
 FSet1.removeLock(FactMan, *LDat1);
 }
   }
@@ -2469,8 +2468,7 @@
 // Do not update EntrySet.
 intersectAndWarn(
 CurrBlockInfo->EntrySet, PrevLockset, PrevBlockInfo->ExitLoc,
-IsLoop ? LEK_LockedSomeLoopIterations : LEK_LockedSomePredecessors,
-!IsLoop);
+IsLoop ? LEK_LockedSomeLoopIterations : 
LEK_LockedSomePredecessors);
   }
 }
 
@@ -2518,10 +2516,8 @@
   CFGBlock *FirstLoopBlock = *SI;
   CFGBlockInfo *PreLoop = &BlockInfo[FirstLoopBlock->getBlockID()];
   CFGBlockInfo *LoopEnd = &BlockInfo[CurrBlockID];
-  intersectAndWarn(LoopEnd->ExitSet, PreLoop->EntrySet,
-   PreLoop->EntryLoc,
-   LEK_LockedSomeLoopIterations,
-   false);
+  intersectAndWarn(LoopEnd->ExitSet, PreLoop->EntrySet, PreLoop->EntryLoc,
+   LEK_LockedSomeLoopIterations);
 }
   }
 
@@ -2549,11 +2545,8 @@
 ExpectedExitSet.removeLock(FactMan, Lock);
 
   // FIXME: Should we call this function for all blocks which exit the 
function?
-  intersectAndWarn(ExpectedExitSet, Final->ExitSet,
-   Final->ExitLoc,
-   LEK_LockedAtEndOfFunction,
-   LEK_NotLockedAtEndOfFunction,
-   false);
+  intersectAndWarn(ExpectedExitSet, Final->ExitSet, Final->ExitLoc,
+   LEK_LockedAtEndOfFunction, LEK_NotLockedAtEndOfFunction);
 
   Handler.leaveFunction(CurrentFunction);
 }


Index: clang/lib/Analysis/ThreadSafety.cpp
===
--- clang/lib/Analysis/ThreadSafety.cpp
+++ clang/lib/Analysis/ThreadSafety.cpp
@@ -1051,14 +1051,12 @@
   const CFGBlock *CurrBlock);
 
   void intersectAn

[PATCH] D101696: [Matrix] Implement C-style explicit type conversions in CXX for matrix types

2021-05-03 Thread Saurabh Jha via Phabricator via cfe-commits
SaurabhJha added a comment.

In D101696#2732983 , @fhahn wrote:

> Thanks for the update! Technically the fix in 
> `clang/lib/CodeGen/CGExprScalar.cpp` is unrelated to C++ support. It would be 
> great if you could put up a separate patch, so we can land this independently.
>
> The whole patch basically LGTM. It would be great if you could add a test 
> casting from unsigned to float/double (looks like no test generates `uitofp`) 
> and a test for casting between signed & unsigned integers of the same size 
> (unless there are already tests for that I missed)

Sure thing. I have created a new patch here https://reviews.llvm.org/D101754. 
Once that's merged, I will rebase this one with the new main.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101696

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


[PATCH] D101702: [clang-format] Add more support for C# 8 nullables

2021-05-03 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

Thank you for the patch




Comment at: clang/lib/Format/TokenAnnotator.cpp:3197
+Right.is(TT_CSharpNullCoalescingAssignment))
+  return true;
+

should this honour SpaceBeforeAssignmentOperators ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101702

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


[PATCH] D101628: [Format] Don't sort includes if DisableFormat is true

2021-05-03 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.
This revision is now accepted and ready to land.

I've seen this asked for multiple time, I think this is fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101628

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


[PATCH] D101753: clang: Fix variable spelling

2021-05-03 Thread Nathan Sidwell 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 rGab7316f1c64c: [clang] Spell correct variable (authored by 
urnathan).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101753

Files:
  clang/include/clang/AST/DeclCXX.h
  clang/lib/AST/DeclCXX.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/SemaCXX/cxx2a-explicit-bool.cpp


Index: clang/test/SemaCXX/cxx2a-explicit-bool.cpp
===
--- clang/test/SemaCXX/cxx2a-explicit-bool.cpp
+++ clang/test/SemaCXX/cxx2a-explicit-bool.cpp
@@ -84,7 +84,7 @@
 
 }
 
-namespace trailling_object {
+namespace trailing_object {
 
 template
 struct B {
Index: clang/lib/Serialization/ASTWriterDecl.cpp
===
--- clang/lib/Serialization/ASTWriterDecl.cpp
+++ clang/lib/Serialization/ASTWriterDecl.cpp
@@ -1389,7 +1389,7 @@
 }
 
 void ASTDeclWriter::VisitCXXConstructorDecl(CXXConstructorDecl *D) {
-  Record.push_back(D->getTraillingAllocKind());
+  Record.push_back(D->getTrailingAllocKind());
   addExplicitSpecifier(D->getExplicitSpecifier(), Record);
   if (auto Inherited = D->getInheritedConstructor()) {
 Record.AddDeclRef(Inherited.getShadowDecl());
Index: clang/lib/AST/DeclCXX.cpp
===
--- clang/lib/AST/DeclCXX.cpp
+++ clang/lib/AST/DeclCXX.cpp
@@ -2600,19 +2600,19 @@
 CXXConstructorDecl *CXXConstructorDecl::CreateDeserialized(ASTContext &C,
unsigned ID,
uint64_t AllocKind) 
{
-  bool hasTraillingExplicit = static_cast(AllocKind & 
TAKHasTailExplicit);
+  bool hasTrailingExplicit = static_cast(AllocKind & TAKHasTailExplicit);
   bool isInheritingConstructor =
   static_cast(AllocKind & TAKInheritsConstructor);
   unsigned Extra =
   additionalSizeToAlloc(
-  isInheritingConstructor, hasTraillingExplicit);
+  isInheritingConstructor, hasTrailingExplicit);
   auto *Result = new (C, ID, Extra) CXXConstructorDecl(
   C, nullptr, SourceLocation(), DeclarationNameInfo(), QualType(), nullptr,
   ExplicitSpecifier(), false, false, ConstexprSpecKind::Unspecified,
   InheritedConstructor(), nullptr);
   Result->setInheritingConstructor(isInheritingConstructor);
   Result->CXXConstructorDeclBits.HasTrailingExplicitSpecifier =
-  hasTraillingExplicit;
+  hasTrailingExplicit;
   Result->setExplicitSpecifier(ExplicitSpecifier());
   return Result;
 }
Index: clang/include/clang/AST/DeclCXX.h
===
--- clang/include/clang/AST/DeclCXX.h
+++ clang/include/clang/AST/DeclCXX.h
@@ -2425,12 +2425,12 @@
  : ExplicitSpecKind::ResolvedFalse);
   }
 
-  enum TraillingAllocKind {
+  enum TrailingAllocKind {
 TAKInheritsConstructor = 1,
 TAKHasTailExplicit = 1 << 1,
   };
 
-  uint64_t getTraillingAllocKind() const {
+  uint64_t getTrailingAllocKind() const {
 return numTrailingObjects(OverloadToken()) |
(numTrailingObjects(OverloadToken()) << 1);
   }


Index: clang/test/SemaCXX/cxx2a-explicit-bool.cpp
===
--- clang/test/SemaCXX/cxx2a-explicit-bool.cpp
+++ clang/test/SemaCXX/cxx2a-explicit-bool.cpp
@@ -84,7 +84,7 @@
 
 }
 
-namespace trailling_object {
+namespace trailing_object {
 
 template
 struct B {
Index: clang/lib/Serialization/ASTWriterDecl.cpp
===
--- clang/lib/Serialization/ASTWriterDecl.cpp
+++ clang/lib/Serialization/ASTWriterDecl.cpp
@@ -1389,7 +1389,7 @@
 }
 
 void ASTDeclWriter::VisitCXXConstructorDecl(CXXConstructorDecl *D) {
-  Record.push_back(D->getTraillingAllocKind());
+  Record.push_back(D->getTrailingAllocKind());
   addExplicitSpecifier(D->getExplicitSpecifier(), Record);
   if (auto Inherited = D->getInheritedConstructor()) {
 Record.AddDeclRef(Inherited.getShadowDecl());
Index: clang/lib/AST/DeclCXX.cpp
===
--- clang/lib/AST/DeclCXX.cpp
+++ clang/lib/AST/DeclCXX.cpp
@@ -2600,19 +2600,19 @@
 CXXConstructorDecl *CXXConstructorDecl::CreateDeserialized(ASTContext &C,
unsigned ID,
uint64_t AllocKind) {
-  bool hasTraillingExplicit = static_cast(AllocKind & TAKHasTailExplicit);
+  bool hasTrailingExplicit = static_cast(AllocKind & TAKHasTailExplicit);
   bool isInheritingConstructor =
   static_cast(AllocKind & TAKInheritsConstructor);
   unsigned Extra =
   

[clang] ab7316f - [clang] Spell correct variable

2021-05-03 Thread Nathan Sidwell via cfe-commits

Author: Nathan Sidwell
Date: 2021-05-03T05:33:47-07:00
New Revision: ab7316f1c64c3530a6eca2e449c2dd734e83498e

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

LOG: [clang] Spell correct variable

fix Trailling -> Trailing (two ll-> one l)

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

Added: 


Modified: 
clang/include/clang/AST/DeclCXX.h
clang/lib/AST/DeclCXX.cpp
clang/lib/Serialization/ASTWriterDecl.cpp
clang/test/SemaCXX/cxx2a-explicit-bool.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index bbf7ecf6712a3..d90732b1d0ca9 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -2425,12 +2425,12 @@ class CXXConstructorDecl final
  : ExplicitSpecKind::ResolvedFalse);
   }
 
-  enum TraillingAllocKind {
+  enum TrailingAllocKind {
 TAKInheritsConstructor = 1,
 TAKHasTailExplicit = 1 << 1,
   };
 
-  uint64_t getTraillingAllocKind() const {
+  uint64_t getTrailingAllocKind() const {
 return numTrailingObjects(OverloadToken()) |
(numTrailingObjects(OverloadToken()) << 1);
   }

diff  --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index f22e599225b60..081c9ebf8622d 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -2600,19 +2600,19 @@ void CXXConstructorDecl::anchor() {}
 CXXConstructorDecl *CXXConstructorDecl::CreateDeserialized(ASTContext &C,
unsigned ID,
uint64_t AllocKind) 
{
-  bool hasTraillingExplicit = static_cast(AllocKind & 
TAKHasTailExplicit);
+  bool hasTrailingExplicit = static_cast(AllocKind & TAKHasTailExplicit);
   bool isInheritingConstructor =
   static_cast(AllocKind & TAKInheritsConstructor);
   unsigned Extra =
   additionalSizeToAlloc(
-  isInheritingConstructor, hasTraillingExplicit);
+  isInheritingConstructor, hasTrailingExplicit);
   auto *Result = new (C, ID, Extra) CXXConstructorDecl(
   C, nullptr, SourceLocation(), DeclarationNameInfo(), QualType(), nullptr,
   ExplicitSpecifier(), false, false, ConstexprSpecKind::Unspecified,
   InheritedConstructor(), nullptr);
   Result->setInheritingConstructor(isInheritingConstructor);
   Result->CXXConstructorDeclBits.HasTrailingExplicitSpecifier =
-  hasTraillingExplicit;
+  hasTrailingExplicit;
   Result->setExplicitSpecifier(ExplicitSpecifier());
   return Result;
 }

diff  --git a/clang/lib/Serialization/ASTWriterDecl.cpp 
b/clang/lib/Serialization/ASTWriterDecl.cpp
index 2b8278090b058..0a5a846bd05c2 100644
--- a/clang/lib/Serialization/ASTWriterDecl.cpp
+++ b/clang/lib/Serialization/ASTWriterDecl.cpp
@@ -1389,7 +1389,7 @@ void ASTDeclWriter::VisitCXXMethodDecl(CXXMethodDecl *D) {
 }
 
 void ASTDeclWriter::VisitCXXConstructorDecl(CXXConstructorDecl *D) {
-  Record.push_back(D->getTraillingAllocKind());
+  Record.push_back(D->getTrailingAllocKind());
   addExplicitSpecifier(D->getExplicitSpecifier(), Record);
   if (auto Inherited = D->getInheritedConstructor()) {
 Record.AddDeclRef(Inherited.getShadowDecl());

diff  --git a/clang/test/SemaCXX/cxx2a-explicit-bool.cpp 
b/clang/test/SemaCXX/cxx2a-explicit-bool.cpp
index c9e960f2d3db7..5a9ff0e442dae 100644
--- a/clang/test/SemaCXX/cxx2a-explicit-bool.cpp
+++ b/clang/test/SemaCXX/cxx2a-explicit-bool.cpp
@@ -84,7 +84,7 @@ E e = 1;
 
 }
 
-namespace trailling_object {
+namespace trailing_object {
 
 template
 struct B {



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


[PATCH] D101721: [clang-tidy][NFC] Update tests and Default options to use boolean value

2021-05-03 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

In D101721#2733173 , @aaron.ballman 
wrote:

> In D101721#2733169 , @njames93 
> wrote:
>
>> However in a few years once we can be confident most users are using 
>> clang-tidy-11 or newer, it may be wise to drop support for 0 and 1 in order 
>> to be inline with yaml completely.
>
> I think if we want to go that route (which seems sensible to me), we should 
> start warning on using anything but true/false as being deprecated. WDYT?

That's sort of the plan, however we shouldn't make that change right away as 
there's no point in issuing warnings at this time. As configurations are 
checked in there is likely to be people still using 10 and previous, which 
don't support the new spelling. This means the config can't be updated and 
users with newer clang-tidy versions will get a warning they can't silence.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101721

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


[PATCH] D100727: [clang-format] Add options to AllowShortIfStatementsOnASingleLine to apply to "else if" and "else".

2021-05-03 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

Still looks good to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100727

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


[PATCH] D93095: Introduce -Wreserved-identifier

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

Aside from the formatting nit and the question about the diagnostic, I think 
this LGTM!




Comment at: clang/include/clang/Basic/DiagnosticGroups.td:637
 def KeywordAsMacro : DiagGroup<"keyword-macro">;
-def ReservedIdAsMacro : DiagGroup<"reserved-id-macro">;
 

Do we want to keep this old name around as an alias to the new name (this makes 
upgrades easier on users who mention the diagnostic by name in their build 
script or within diagnostic pragmas)?



Comment at: clang/lib/AST/Decl.cpp:1084
+  const IdentifierInfo *II = getIdentifier();
+  if(!II)
+if (const auto *FD = dyn_cast(this))

The formatting issue is worth fixing.


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

https://reviews.llvm.org/D93095

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


[PATCH] D101754: [Matrix] Remove bitcast when casting between matrices of the same size

2021-05-03 Thread Florian Hahn via Phabricator via cfe-commits
fhahn accepted this revision.
fhahn added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!

I can commit this change on your behalf in a bit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101754

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


[PATCH] D101721: [clang-tidy][NFC] Update tests and Default options to use boolean value

2021-05-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D101721#2733260 , @njames93 wrote:

> In D101721#2733173 , @aaron.ballman 
> wrote:
>
>> In D101721#2733169 , @njames93 
>> wrote:
>>
>>> However in a few years once we can be confident most users are using 
>>> clang-tidy-11 or newer, it may be wise to drop support for 0 and 1 in order 
>>> to be inline with yaml completely.
>>
>> I think if we want to go that route (which seems sensible to me), we should 
>> start warning on using anything but true/false as being deprecated. WDYT?
>
> That's sort of the plan, however we shouldn't make that change right away as 
> there's no point in issuing warnings at this time. As configurations are 
> checked in there is likely to be people still using 10 and previous, which 
> don't support the new spelling. This means the config can't be updated and 
> users with newer clang-tidy versions will get a warning they can't silence.

That makes sense to me. Should we file a bug to suggest adding the deprecation 
warning in Clang 14(?) and planned removal in Clang 16(?) so that we don't lose 
track of this? (I have no firm opinion about which versions we decide to start 
deprecating and remove so long as they're not disruptive.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101721

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


[PATCH] D70094: [clang-tidy] new altera ID dependent backward branch check

2021-05-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/altera/IdDependentBackwardBranchCheck.h:32
+: VariableDeclaration(Declaration), Location(Location),
+  Message(Message) {}
+IdDependencyRecord(const FieldDecl *Declaration, SourceLocation Location,

aaron.ballman wrote:
> 
Ah, it looks like some changes conflicted with my suggestion -- when the 
function was taking a std::string, the move was needed, but now with a Twine, 
the move is an issue. You should remove the std::move.



Comment at: 
clang-tools-extra/clang-tidy/altera/IdDependentBackwardBranchCheck.h:35
+   std::string Message)
+: FieldDeclaration(Declaration), Location(Location), Message(Message) 
{}
+IdDependencyRecord() = default;

aaron.ballman wrote:
> 
Same here.


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

https://reviews.llvm.org/D70094

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


[PATCH] D101479: [Driver] Support libc++ in MSVC

2021-05-03 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

How does this interact with `/MT` / `/MD`? Does this link the static or the 
dynamic libc++? If the former, does that do the right thing for DLLs? If the 
latter, are users expected to manually copy libc++.dll? (Sorry, not super up to 
speed on the static/shared lib status of libc++ on windows.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101479

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


[PATCH] D101739: [OpenMP] Fix non-determinism in clang task codegen

2021-05-03 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101739

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


[PATCH] D101754: [Matrix] Remove bitcast when casting between matrices of the same size

2021-05-03 Thread Saurabh Jha via Phabricator via cfe-commits
SaurabhJha added a comment.

In D101754#2733273 , @fhahn wrote:

> LGTM, thanks!
>
> I can commit this change on your behalf in a bit

Cheers Florian!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101754

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


[PATCH] D101479: [Driver] Support libc++ in MSVC

2021-05-03 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added subscribers: smeenai, mstorsjo.
mstorsjo added a comment.

In D101479#2733303 , @thakis wrote:

> How does this interact with `/MT` / `/MD`? Does this link the static or the 
> dynamic libc++? If the former, does that do the right thing for DLLs? If the 
> latter, are users expected to manually copy libc++.dll? (Sorry, not super up 
> to speed on the static/shared lib status of libc++ on windows.)

Right now, libc++ headers mark everything dllimport by default, unless 
`_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS` is defined. If you build a static-only 
libc++, libc++'s `__config_site` predefines 
`_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS`.

Not sure if we want the desicion between static and shared libc++ be coupled 
with `/MT` and `/MD`, as one can quite plausibly want to use e.g. a static 
libc++ with `/MD`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101479

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


[PATCH] D101139: Create install targets for scan-build-py.

2021-05-03 Thread Anders Waldenborg via Phabricator via cfe-commits
wanders added inline comments.



Comment at: clang/tools/scan-build-py/CMakeLists.txt:8
+ "bin/intercept-cc"
+ "bin/scan-build")
+

This overwrites the "bin/scan-build" that was installed from the scan-build (no 
-py) subdirectory.

So with this  "scan-build" will suddenly mean the python variant instead of the 
per variant. That might be fine (?), but can't be a good idea to have that done 
by first installing the perl scan-build and then overwriting it with the python 
scan-build.  Also the man-page that the perl variant installs is not 
overwritten so "man scan-build" will show manual page for the perl variant.


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

https://reviews.llvm.org/D101139

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


[PATCH] D101758: [clang][modules] Add -cc1 option to backup PCM files

2021-05-03 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith.
Herald added a subscriber: dang.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

During a highly parallel build with `-fimplicit-modules`, multiple translation 
units may generate a PCM file for the same module at the same filesystem path 
in a short sequence.

When the first Clang instance tries to verify signature of the module on 
import, it discovers the new version of the PCM file (produced by latter Clang 
instance) that may have a different signature, leading to a mismatch and failed 
build.

To be able to debug such mismatch, it's invaluable to be able to compare the 
latter PCM (on disk) with the first one (overwritten).

This patch adds new -cc1 option `-fbackup-module` that tells Clang to store 
each PCM to the normal location **and** also to a path with an unique suffix 
(the PID of the Clang instance).

This is mostly additional change, but `PCHContainerGenerator` now doesn't 
unconditionally destroy the given `PCHBuffer` anymore and instead just 
decreases its reference count.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101758

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/FrontendOptions.h
  clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Serialization/PCHContainerOperations.cpp
  clang/test/Modules/backup-module.c
  clang/test/Modules/backup-module.h

Index: clang/test/Modules/backup-module.h
===
--- /dev/null
+++ clang/test/Modules/backup-module.h
@@ -0,0 +1 @@
+int function(void);
Index: clang/test/Modules/backup-module.c
===
--- /dev/null
+++ clang/test/Modules/backup-module.c
@@ -0,0 +1,10 @@
+// RUN: rm -rf %t && mkdir %t
+// RUN: %clang_cc1 %S/backup-module.h -emit-pch -o %t/backup-module.pch
+// RUN: find %t -name 'backup-module.pch.*' | not grep backup-module
+//
+// RUN: %clang_cc1 %S/backup-module.h -emit-pch -o %t/backup-module.pch -fbackup-module
+// RUN: find %t -name 'backup-module.pch.*' | grep backup-module
+// RUN: find %t -name 'backup-module.pch.*' | xargs diff %t/backup-module.pch
+
+// The purpose of this test is to make sure that the module file backup has
+// the same contents as the original.
Index: clang/lib/Serialization/PCHContainerOperations.cpp
===
--- clang/lib/Serialization/PCHContainerOperations.cpp
+++ clang/lib/Serialization/PCHContainerOperations.cpp
@@ -37,14 +37,14 @@
   ~RawPCHContainerGenerator() override = default;
 
   void HandleTranslationUnit(ASTContext &Ctx) override {
+// Decrease the reference count on function exit.
+std::shared_ptr Buffer = std::move(this->Buffer);
+
 if (Buffer->IsComplete) {
   // Make sure it hits disk now.
   *OS << Buffer->Data;
   OS->flush();
 }
-// Free the space of the temporary buffer.
-llvm::SmallVector Empty;
-Buffer->Data = std::move(Empty);
   }
 };
 
Index: clang/lib/Frontend/FrontendActions.cpp
===
--- clang/lib/Frontend/FrontendActions.cpp
+++ clang/lib/Frontend/FrontendActions.cpp
@@ -9,8 +9,8 @@
 #include "clang/Frontend/FrontendActions.h"
 #include "clang/AST/ASTConsumer.h"
 #include "clang/Basic/FileManager.h"
-#include "clang/Basic/TargetInfo.h"
 #include "clang/Basic/LangStandard.h"
+#include "clang/Basic/TargetInfo.h"
 #include "clang/Frontend/ASTConsumers.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
@@ -26,6 +26,7 @@
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/Process.h"
 #include "llvm/Support/YAMLTraits.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
@@ -48,6 +49,26 @@
 CI.createSema(Action.getTranslationUnitKind(),
   GetCodeCompletionConsumer(CI));
 }
+
+static void
+AddBackupPCHWriter(std::vector> &Consumers,
+   CompilerInstance &CI, StringRef InFile,
+   const std::string &OutFile,
+   std::shared_ptr &Buffer) {
+  std::string BackupOutFile =
+  OutFile + "." + std::to_string(llvm::sys::Process::getProcessId());
+
+  std::error_code EC;
+  auto OS = std::make_unique(BackupOutFile, EC);
+  if (EC) {
+CI.getDiagnostics().Report(diag::err_fe_error_opening)
+<< BackupOutFile << EC.message();
+return;
+  }
+
+  Consumers.push_back(CI.getPCHContainerWriter().CreatePCHContainerGenerator(
+  CI, std::string(InFile), BackupOutFile, std::move(OS), Buffer));
+}
 } // namespace
 
 //===--===//
@@ -118,6 +139,8 @@
   FrontendOpts.IncludeTime

[PATCH] D101503: [OpenMPIRBuilder] Add createOffloadMaptypes and createOffloadMapnames functions

2021-05-03 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur accepted this revision.
Meinersbur added a comment.
This revision is now accepted and ready to land.

LGTM, thank you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101503

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


[clang] 696becb - [Matrix] Remove bitcast when casting between matrices of the same size

2021-05-03 Thread Florian Hahn via cfe-commits

Author: Saurabh Jha
Date: 2021-05-03T15:31:43+01:00
New Revision: 696becbd139e4bbbe304ce2231de0fb50f307b68

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

LOG: [Matrix] Remove bitcast when casting between matrices of the same size

In matrix type casts, we were doing bitcast when the matrices had the same 
size. This was incorrect and this patch fixes that.
Also added some new CodeGen tests for signed <-> usigned conversions

Reviewed By: fhahn

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

Added: 


Modified: 
clang/lib/CodeGen/CGExprScalar.cpp
clang/test/CodeGen/matrix-cast.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index b469a4454f158..89ab9abc7dadb 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -1205,10 +1205,6 @@ Value *ScalarExprEmitter::EmitScalarCast(Value *Src, 
QualType SrcType,
   QualType SrcElementType;
   QualType DstElementType;
   if (SrcType->isMatrixType() && DstType->isMatrixType()) {
-// Allow bitcast between matrixes of the same size.
-if (SrcTy->getPrimitiveSizeInBits() == DstTy->getPrimitiveSizeInBits())
-  return Builder.CreateBitCast(Src, DstTy, "conv");
-
 SrcElementTy = cast(SrcTy)->getElementType();
 DstElementTy = cast(DstTy)->getElementType();
 SrcElementType = SrcType->castAs()->getElementType();

diff  --git a/clang/test/CodeGen/matrix-cast.c 
b/clang/test/CodeGen/matrix-cast.c
index 8871232f76b11..ad8f67acacdfb 100644
--- a/clang/test/CodeGen/matrix-cast.c
+++ b/clang/test/CodeGen/matrix-cast.c
@@ -52,13 +52,23 @@ void cast_int_matrix_to_short(ix5x5 i, sx5x5 s) {
 void cast_int_matrix_to_float(ix5x5 i, fx5x5 f) {
   // CHECK-LABEL: define{{.*}} void @cast_int_matrix_to_float(<25 x i32> %i, 
<25 x float> %f)
   // CHECK:   [[I:%.*]] = load <25 x i32>, <25 x i32>* {{.*}}, align 4
-  // CHECK-NEXT:  [[CONV:%.*]] = bitcast <25 x i32> [[I]] to <25 x float>
+  // CHECK-NEXT:  [[CONV:%.*]] = sitofp <25 x i32> [[I]] to <25 x float>
   // CHECK-NEXT:  store <25 x float> [[CONV]], <25 x float>* {{.*}}, align 4
   // CHECK-NEXT:  ret void
 
   f = (fx5x5)i;
 }
 
+void cast_unsigned_int_matrix_to_float(unsigned_short_int_5x5 u, fx5x5 f) {
+  // CHECK-LABEL: define{{.*}} void @cast_unsigned_int_matrix_to_float(<25 x 
i16> %u, <25 x float> %f)
+  // CHECK:   [[U:%.*]] = load <25 x i16>, <25 x i16>* {{.*}}, align 2
+  // CHECK-NEXT:  [[CONV:%.*]] = uitofp <25 x i16> [[U]] to <25 x float>
+  // CHECK-NEXT:  store <25 x float> [[CONV]], <25 x float>* {{.*}}, align 4
+  // CHECK-NEXT:  ret void
+
+  f = (fx5x5)u;
+}
+
 void cast_double_matrix_to_int(dx5x5 d, ix5x5 i) {
   // CHECK-LABEL: define{{.*}} void @cast_double_matrix_to_int(<25 x double> 
%d, <25 x i32> %i)
   // CHECK:   [[D:%.*]] = load <25 x double>, <25 x double>* {{.*}}, align 
8
@@ -108,3 +118,23 @@ void 
cast_unsigned_long_int_to_unsigned_short_int(unsigned_long_int_5x5 l, unsig
 
   s = (unsigned_short_int_5x5)l;
 }
+
+void cast_unsigned_short_int_to_int(unsigned_short_int_5x5 u, ix5x5 i) {
+  // CHECK-LABEL: define{{.*}} void @cast_unsigned_short_int_to_int(<25 x i16> 
%u, <25 x i32> %i)
+  // CHECK:   [[U:%.*]] = load <25 x i16>, <25 x i16>* %0, align 2
+  // CHECK-NEXT:  [[CONV:%.*]] = zext <25 x i16> [[U]] to <25 x i32>
+  // CHECK-NEXT:  store <25 x i32> [[CONV]], <25 x i32>* {{.*}}, align 4
+  // CHECK-NEXT:  ret void
+
+  i = (ix5x5)u;
+}
+
+void cast_int_to_unsigned_long_int(ix5x5 i, unsigned_long_int_5x5 u) {
+  // CHECK-LABEL: define{{.*}} void @cast_int_to_unsigned_long_int(<25 x i32> 
%i, <25 x i64> %u)
+  // CHECK:   [[I:%.*]] = load <25 x i32>, <25 x i32>* %0, align 4
+  // CHECK-NEXT:  [[CONV:%.*]] = sext <25 x i32> [[I]] to <25 x i64>
+  // CHECK-NEXT:  store <25 x i64> [[CONV]], <25 x i64>* {{.*}}, align 8
+  // CHECK-NEXT:  ret void
+
+  u = (unsigned_long_int_5x5)i;
+}



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


[PATCH] D101754: [Matrix] Remove bitcast when casting between matrices of the same size

2021-05-03 Thread Florian Hahn via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG696becbd139e: [Matrix] Remove bitcast when casting between 
matrices of the same size (authored by SaurabhJha, committed by fhahn).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101754

Files:
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/test/CodeGen/matrix-cast.c


Index: clang/test/CodeGen/matrix-cast.c
===
--- clang/test/CodeGen/matrix-cast.c
+++ clang/test/CodeGen/matrix-cast.c
@@ -52,13 +52,23 @@
 void cast_int_matrix_to_float(ix5x5 i, fx5x5 f) {
   // CHECK-LABEL: define{{.*}} void @cast_int_matrix_to_float(<25 x i32> %i, 
<25 x float> %f)
   // CHECK:   [[I:%.*]] = load <25 x i32>, <25 x i32>* {{.*}}, align 4
-  // CHECK-NEXT:  [[CONV:%.*]] = bitcast <25 x i32> [[I]] to <25 x float>
+  // CHECK-NEXT:  [[CONV:%.*]] = sitofp <25 x i32> [[I]] to <25 x float>
   // CHECK-NEXT:  store <25 x float> [[CONV]], <25 x float>* {{.*}}, align 4
   // CHECK-NEXT:  ret void
 
   f = (fx5x5)i;
 }
 
+void cast_unsigned_int_matrix_to_float(unsigned_short_int_5x5 u, fx5x5 f) {
+  // CHECK-LABEL: define{{.*}} void @cast_unsigned_int_matrix_to_float(<25 x 
i16> %u, <25 x float> %f)
+  // CHECK:   [[U:%.*]] = load <25 x i16>, <25 x i16>* {{.*}}, align 2
+  // CHECK-NEXT:  [[CONV:%.*]] = uitofp <25 x i16> [[U]] to <25 x float>
+  // CHECK-NEXT:  store <25 x float> [[CONV]], <25 x float>* {{.*}}, align 4
+  // CHECK-NEXT:  ret void
+
+  f = (fx5x5)u;
+}
+
 void cast_double_matrix_to_int(dx5x5 d, ix5x5 i) {
   // CHECK-LABEL: define{{.*}} void @cast_double_matrix_to_int(<25 x double> 
%d, <25 x i32> %i)
   // CHECK:   [[D:%.*]] = load <25 x double>, <25 x double>* {{.*}}, align 
8
@@ -108,3 +118,23 @@
 
   s = (unsigned_short_int_5x5)l;
 }
+
+void cast_unsigned_short_int_to_int(unsigned_short_int_5x5 u, ix5x5 i) {
+  // CHECK-LABEL: define{{.*}} void @cast_unsigned_short_int_to_int(<25 x i16> 
%u, <25 x i32> %i)
+  // CHECK:   [[U:%.*]] = load <25 x i16>, <25 x i16>* %0, align 2
+  // CHECK-NEXT:  [[CONV:%.*]] = zext <25 x i16> [[U]] to <25 x i32>
+  // CHECK-NEXT:  store <25 x i32> [[CONV]], <25 x i32>* {{.*}}, align 4
+  // CHECK-NEXT:  ret void
+
+  i = (ix5x5)u;
+}
+
+void cast_int_to_unsigned_long_int(ix5x5 i, unsigned_long_int_5x5 u) {
+  // CHECK-LABEL: define{{.*}} void @cast_int_to_unsigned_long_int(<25 x i32> 
%i, <25 x i64> %u)
+  // CHECK:   [[I:%.*]] = load <25 x i32>, <25 x i32>* %0, align 4
+  // CHECK-NEXT:  [[CONV:%.*]] = sext <25 x i32> [[I]] to <25 x i64>
+  // CHECK-NEXT:  store <25 x i64> [[CONV]], <25 x i64>* {{.*}}, align 8
+  // CHECK-NEXT:  ret void
+
+  u = (unsigned_long_int_5x5)i;
+}
Index: clang/lib/CodeGen/CGExprScalar.cpp
===
--- clang/lib/CodeGen/CGExprScalar.cpp
+++ clang/lib/CodeGen/CGExprScalar.cpp
@@ -1205,10 +1205,6 @@
   QualType SrcElementType;
   QualType DstElementType;
   if (SrcType->isMatrixType() && DstType->isMatrixType()) {
-// Allow bitcast between matrixes of the same size.
-if (SrcTy->getPrimitiveSizeInBits() == DstTy->getPrimitiveSizeInBits())
-  return Builder.CreateBitCast(Src, DstTy, "conv");
-
 SrcElementTy = cast(SrcTy)->getElementType();
 DstElementTy = cast(DstTy)->getElementType();
 SrcElementType = SrcType->castAs()->getElementType();


Index: clang/test/CodeGen/matrix-cast.c
===
--- clang/test/CodeGen/matrix-cast.c
+++ clang/test/CodeGen/matrix-cast.c
@@ -52,13 +52,23 @@
 void cast_int_matrix_to_float(ix5x5 i, fx5x5 f) {
   // CHECK-LABEL: define{{.*}} void @cast_int_matrix_to_float(<25 x i32> %i, <25 x float> %f)
   // CHECK:   [[I:%.*]] = load <25 x i32>, <25 x i32>* {{.*}}, align 4
-  // CHECK-NEXT:  [[CONV:%.*]] = bitcast <25 x i32> [[I]] to <25 x float>
+  // CHECK-NEXT:  [[CONV:%.*]] = sitofp <25 x i32> [[I]] to <25 x float>
   // CHECK-NEXT:  store <25 x float> [[CONV]], <25 x float>* {{.*}}, align 4
   // CHECK-NEXT:  ret void
 
   f = (fx5x5)i;
 }
 
+void cast_unsigned_int_matrix_to_float(unsigned_short_int_5x5 u, fx5x5 f) {
+  // CHECK-LABEL: define{{.*}} void @cast_unsigned_int_matrix_to_float(<25 x i16> %u, <25 x float> %f)
+  // CHECK:   [[U:%.*]] = load <25 x i16>, <25 x i16>* {{.*}}, align 2
+  // CHECK-NEXT:  [[CONV:%.*]] = uitofp <25 x i16> [[U]] to <25 x float>
+  // CHECK-NEXT:  store <25 x float> [[CONV]], <25 x float>* {{.*}}, align 4
+  // CHECK-NEXT:  ret void
+
+  f = (fx5x5)u;
+}
+
 void cast_double_matrix_to_int(dx5x5 d, ix5x5 i) {
   // CHECK-LABEL: define{{.*}} void @cast_double_matrix_to_int(<25 x double> %d, <25 x i32> %i)
   // CHECK:   [[D:%.*]] = load <25 x double>, <25 x double>* {{.*}}, align 8
@@ -108,3 +118,23 @@
 
   s = (unsigned_short_int_5x5)l;
 }
+
+void cast_unsigned_short_int_to_int(unsigned_short_int

[PATCH] D101479: [Driver] Support libc++ in MSVC

2021-05-03 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

In D101479#2733354 , @mstorsjo wrote:

> Not sure if we want the desicion between static and shared libc++ be coupled 
> with `/MT` and `/MD`, as one can quite plausibly want to use e.g. a static 
> libc++ with `/MD`.

Right, I meant more "how do users pick if they want a statically or dynamically 
linked libc++". Sounds like you get a dynamic libc++ by default. Since Windows 
doesn't have rpaths afaik, using `-stdlib=libc++` means you'll get an 
executable that won't start, unless you know to copy the libc++ dll next to 
your executable with this patch as-is, yes?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101479

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


[PATCH] D101554: [clangd] Add support for the `defaultLibrary` semantic token modifier

2021-05-03 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 342391.
dgoldman added a comment.

Remove unnecessary scope modifier


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101554

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/test/initialize-params.test
  clang-tools-extra/clangd/test/semantic-tokens.test
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -69,13 +69,16 @@
 std::vector>
 AdditionalFiles = {},
-uint32_t ModifierMask = -1) {
+uint32_t ModifierMask = -1,
+std::vector AdditionalArgs = {}) {
   Annotations Test(Code);
   TestTU TU;
   TU.Code = std::string(Test.code());
 
   TU.ExtraArgs.push_back("-std=c++20");
   TU.ExtraArgs.push_back("-xobjective-c++");
+  TU.ExtraArgs.insert(std::end(TU.ExtraArgs), std::begin(AdditionalArgs),
+  std::end(AdditionalArgs));
 
   for (auto File : AdditionalFiles)
 TU.AdditionalFiles.insert({File.first, std::string(File.second)});
@@ -731,6 +734,24 @@
 #define DEFINE_Y DEFINE(Y)
   )cpp"}},
  ~ScopeModifierMask);
+
+  checkHighlightings(R"cpp(
+#include "SYSObject.h"
+@interface $Class_defaultLibrary[[SYSObject]] ($Namespace_decl[[UserCategory]])
+@property(nonatomic, readonly) int $Field_decl_readonly[[user_property]];
+@end
+int $Function_decl[[somethingUsingSystemSymbols]]() {
+  $Class_defaultLibrary[[SYSObject]] *$LocalVariable_decl[[obj]] = [$Class_defaultLibrary[[SYSObject]] $StaticMethod_static_defaultLibrary[[new]]];
+  return $LocalVariable[[obj]].$Field_defaultLibrary[[value]] + $LocalVariable[[obj]].$Field_readonly[[user_property]];
+}
+  )cpp",
+ {{"SystemSDK/SYSObject.h", R"cpp(
+@interface SYSObject
+@property(nonatomic, assign) int value;
++ (instancetype)new;
+@end
+  )cpp"}},
+ ~ScopeModifierMask, {"-isystemSystemSDK/"});
 }
 
 TEST(SemanticHighlighting, ScopeModifiers) {
Index: clang-tools-extra/clangd/test/semantic-tokens.test
===
--- clang-tools-extra/clangd/test/semantic-tokens.test
+++ clang-tools-extra/clangd/test/semantic-tokens.test
@@ -23,7 +23,7 @@
 # CHECK-NEXT:  4,
 # CHECK-NEXT:  1,
 # CHECK-NEXT:  0,
-# CHECK-NEXT:  1025
+# CHECK-NEXT:  2049
 # CHECK-NEXT:],
 # CHECK-NEXT:"resultId": "1"
 # CHECK-NEXT:  }
@@ -49,7 +49,7 @@
 # CHECK-NEXT:  4,
 # CHECK-NEXT:  1,
 # CHECK-NEXT:  0,
-# CHECK-NEXT:  1025
+# CHECK-NEXT:  2049
 # CHECK-NEXT:],
 #Inserted at position 1
 # CHECK-NEXT:"deleteCount": 0,
@@ -72,12 +72,12 @@
 # CHECK-NEXT:  4,
 # CHECK-NEXT:  1,
 # CHECK-NEXT:  0,
-# CHECK-NEXT:  1025,
+# CHECK-NEXT:  2049,
 # CHECK-NEXT:  1,
 # CHECK-NEXT:  4,
 # CHECK-NEXT:  1,
 # CHECK-NEXT:  0,
-# CHECK-NEXT:  1025
+# CHECK-NEXT:  2049
 # CHECK-NEXT:],
 # CHECK-NEXT:"resultId": "3"
 # CHECK-NEXT:  }
Index: clang-tools-extra/clangd/test/initialize-params.test
===
--- clang-tools-extra/clangd/test/initialize-params.test
+++ clang-tools-extra/clangd/test/initialize-params.test
@@ -90,6 +90,7 @@
 # CHECK-NEXT:"static",
 # CHECK-NEXT:"abstract",
 # CHECK-NEXT:"dependentName",
+# CHECK-NEXT:"defaultLibrary",
 # CHECK-NEXT:"functionScope",
 # CHECK-NEXT:"classScope",
 # CHECK-NEXT:"fileScope",
Index: clang-tools-extra/clangd/SemanticHighlighting.h
===
--- clang-tools-extra/clangd/SemanticHighlighting.h
+++ clang-tools-extra/clangd/SemanticHighlighting.h
@@ -67,6 +67,7 @@
   Static,
   Abstract,
   DependentName,
+  DefaultLibrary,
 
   FunctionScope,
   ClassScope,
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -245,6 +245,16 @@
   return false;
 }
 
+/// Returns true if `Decl` is considered to be from a default/system library.
+/// This currently checks the systemness of the file by include type, although
+/// different heuristics may be used in the future (e.g. sysroot paths).
+bool isDefaultLibrary(const Decl *D) {
+  SourceLocat

[PATCH] D101554: [clangd] Add support for the `defaultLibrary` semantic token modifier

2021-05-03 Thread David Goldman via Phabricator via cfe-commits
dgoldman marked 2 inline comments as done.
dgoldman added inline comments.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:470
+  if (auto *OT = dyn_cast(T))
+return scopeModifier(OT->getInterface());
   return llvm::None;

kadircet wrote:
> is this guaranteed to be non-null ?
Went ahead and removed it, it's unnecessary now


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101554

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


[PATCH] D101462: [MC] Untangle MCContext and MCObjectFileInfo

2021-05-03 Thread Philipp Krones via Phabricator via cfe-commits
flip1995 updated this revision to Diff 342352.
flip1995 marked 3 inline comments as done.
flip1995 edited the summary of this revision.
flip1995 added a comment.
Herald added subscribers: dcaballe, cota, teijeong, rdzhabarov, tatianashp, 
msifontes, jurahul, Kayjukh, grosul1, Joonsoo, stephenneuendorffer, liufengdb, 
aartbik, lucyrfox, mgester, arpith-jacob, csigg, nicolasvasilache, antiagainst, 
shauheen, rriddle, mehdi_amini.
Herald added a reviewer: herhut.
Herald added a project: MLIR.

Rename InitMCObjectFileInfo and reorder arguments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101462

Files:
  clang/lib/Parse/ParseStmtAsm.cpp
  clang/tools/driver/cc1as_main.cpp
  llvm/include/llvm/MC/MCObjectFileInfo.h
  llvm/lib/DWARFLinker/DWARFStreamer.cpp
  llvm/lib/MC/MCObjectFileInfo.cpp
  llvm/lib/Object/ModuleSymbolTable.cpp
  llvm/lib/Target/TargetLoweringObjectFile.cpp
  llvm/tools/llvm-dwp/llvm-dwp.cpp
  llvm/tools/llvm-exegesis/lib/SnippetFile.cpp
  llvm/tools/llvm-mc-assemble-fuzzer/llvm-mc-assemble-fuzzer.cpp
  llvm/tools/llvm-mc/llvm-mc.cpp
  llvm/tools/llvm-mca/llvm-mca.cpp
  llvm/tools/llvm-ml/llvm-ml.cpp
  llvm/tools/llvm-objdump/llvm-objdump.cpp
  llvm/tools/llvm-profgen/ProfiledBinary.cpp
  llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
  mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp

Index: mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
===
--- mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
+++ mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
@@ -169,8 +169,8 @@
   mai->setRelaxELFRelocations(true);
 
   llvm::MCObjectFileInfo mofi;
-  llvm::MCContext ctx(mai.get(), mri.get(), &mofi, &srcMgr, &mcOptions);
-  mofi.InitMCObjectFileInfo(triple, false, ctx, false);
+  llvm::MCContext ctx(triple, mai.get(), mri.get(), &mofi, &srcMgr, &mcOptions);
+  mofi.initMCObjectFileInfo(ctx, /*PIC=*/false, /*LargeCodeModel=*/false);
 
   SmallString<128> cwd;
   if (!llvm::sys::fs::current_path(cwd))
Index: llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
===
--- llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
+++ llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
@@ -107,7 +107,7 @@
 
 Ctx.reset(new MCContext(Triple, MUPMAI.get(), MRI.get(), &MOFI, MSTI.get(),
 &SrcMgr, &MCOptions));
-MOFI.InitMCObjectFileInfo(/*PIC=*/false, *Ctx, /*LargeCodeModel=*/false);
+MOFI.initMCObjectFileInfo(*Ctx, /*PIC=*/false, /*LargeCodeModel=*/false);
 
 Str.reset(TheTarget->createNullStreamer(*Ctx));
 
Index: llvm/tools/llvm-profgen/ProfiledBinary.cpp
===
--- llvm/tools/llvm-profgen/ProfiledBinary.cpp
+++ llvm/tools/llvm-profgen/ProfiledBinary.cpp
@@ -334,7 +334,7 @@
 
   MCObjectFileInfo MOFI;
   MCContext Ctx(Triple(TripleName), AsmInfo.get(), MRI.get(), &MOFI, STI.get());
-  MOFI.InitMCObjectFileInfo(/*PIC=*/false, Ctx);
+  MOFI.initMCObjectFileInfo(Ctx, /*PIC=*/false);
   DisAsm.reset(TheTarget->createMCDisassembler(*STI, Ctx));
   if (!DisAsm)
 exitWithError("no disassembler for target " + TripleName, FileName);
Index: llvm/tools/llvm-objdump/llvm-objdump.cpp
===
--- llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -1579,7 +1579,7 @@
   MCObjectFileInfo MOFI;
   MCContext Ctx(Triple(TripleName), AsmInfo.get(), MRI.get(), &MOFI, STI.get());
   // FIXME: for now initialize MCObjectFileInfo with default values
-  MOFI.InitMCObjectFileInfo(/*PIC=*/false, Ctx);
+  MOFI.initMCObjectFileInfo(Ctx, /*PIC=*/false);
 
   std::unique_ptr DisAsm(
   TheTarget->createMCDisassembler(*STI, Ctx));
Index: llvm/tools/llvm-ml/llvm-ml.cpp
===
--- llvm/tools/llvm-ml/llvm-ml.cpp
+++ llvm/tools/llvm-ml/llvm-ml.cpp
@@ -283,7 +283,7 @@
   // MCObjectFileInfo needs a MCContext reference in order to initialize itself.
   MCObjectFileInfo MOFI;
   MCContext Ctx(TheTriple, MAI.get(), MRI.get(), &MOFI, STI.get(), &SrcMgr);
-  MOFI.InitMCObjectFileInfo(/*PIC=*/false, Ctx,
+  MOFI.initMCObjectFileInfo(Ctx, /*PIC=*/false,
 /*LargeCodeModel=*/true);
 
   if (InputArgs.hasArg(OPT_save_temp_labels))
Index: llvm/tools/llvm-mca/llvm-mca.cpp
===
--- llvm/tools/llvm-mca/llvm-mca.cpp
+++ llvm/tools/llvm-mca/llvm-mca.cpp
@@ -379,7 +379,7 @@
 
   MCContext Ctx(TheTriple, MAI.get(), MRI.get(), &MOFI, STI.get(), &SrcMgr);
 
-  MOFI.InitMCObjectFileInfo(/*PIC=*/false, Ctx);
+  MOFI.initMCObjectFileInfo(Ctx, /*PIC=*/false);
 
   std::unique_ptr BOS;
 
Index: llvm/tools/llvm-mc/llvm-mc.cpp
===
--- llvm

[PATCH] D101462: [MC] Untangle MCContext and MCObjectFileInfo

2021-05-03 Thread Philipp Krones via Phabricator via cfe-commits
flip1995 updated this revision to Diff 342354.
flip1995 added a comment.

Fix arc mistake...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101462

Files:
  clang/lib/Parse/ParseStmtAsm.cpp
  clang/tools/driver/cc1as_main.cpp
  lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
  lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
  lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp
  llvm/include/llvm/MC/MCContext.h
  llvm/include/llvm/MC/MCObjectFileInfo.h
  llvm/lib/CodeGen/MachineModuleInfo.cpp
  llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
  llvm/lib/DWARFLinker/DWARFStreamer.cpp
  llvm/lib/MC/MCAsmStreamer.cpp
  llvm/lib/MC/MCContext.cpp
  llvm/lib/MC/MCDisassembler/Disassembler.cpp
  llvm/lib/MC/MCMachOStreamer.cpp
  llvm/lib/MC/MCObjectFileInfo.cpp
  llvm/lib/MC/MCParser/AsmParser.cpp
  llvm/lib/MC/MCParser/COFFAsmParser.cpp
  llvm/lib/MC/MCParser/DarwinAsmParser.cpp
  llvm/lib/MC/MCParser/MasmParser.cpp
  llvm/lib/MC/MCStreamer.cpp
  llvm/lib/MC/MCWinCOFFStreamer.cpp
  llvm/lib/Object/ModuleSymbolTable.cpp
  llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
  llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
  llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.cpp
  llvm/lib/Target/TargetLoweringObjectFile.cpp
  llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp
  llvm/tools/llvm-dwp/llvm-dwp.cpp
  llvm/tools/llvm-exegesis/lib/Analysis.cpp
  llvm/tools/llvm-exegesis/lib/LlvmState.cpp
  llvm/tools/llvm-exegesis/lib/SnippetFile.cpp
  llvm/tools/llvm-jitlink/llvm-jitlink.cpp
  llvm/tools/llvm-mc-assemble-fuzzer/llvm-mc-assemble-fuzzer.cpp
  llvm/tools/llvm-mc/llvm-mc.cpp
  llvm/tools/llvm-mca/llvm-mca.cpp
  llvm/tools/llvm-ml/Disassembler.cpp
  llvm/tools/llvm-ml/llvm-ml.cpp
  llvm/tools/llvm-objdump/MachODump.cpp
  llvm/tools/llvm-objdump/llvm-objdump.cpp
  llvm/tools/llvm-profgen/ProfiledBinary.cpp
  llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
  llvm/tools/sancov/sancov.cpp
  llvm/unittests/CodeGen/MachineInstrTest.cpp
  llvm/unittests/CodeGen/MachineOperandTest.cpp
  llvm/unittests/CodeGen/TestAsmPrinter.cpp
  llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp
  llvm/unittests/MC/DwarfLineTables.cpp
  llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
  mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp

Index: mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
===
--- mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
+++ mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp
@@ -169,8 +169,8 @@
   mai->setRelaxELFRelocations(true);
 
   llvm::MCObjectFileInfo mofi;
-  llvm::MCContext ctx(mai.get(), mri.get(), &mofi, &srcMgr, &mcOptions);
-  mofi.InitMCObjectFileInfo(triple, false, ctx, false);
+  llvm::MCContext ctx(triple, mai.get(), mri.get(), &mofi, &srcMgr, &mcOptions);
+  mofi.initMCObjectFileInfo(ctx, /*PIC=*/false, /*LargeCodeModel=*/false);
 
   SmallString<128> cwd;
   if (!llvm::sys::fs::current_path(cwd))
Index: llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
===
--- llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
+++ llvm/unittests/MC/SystemZ/SystemZAsmLexerTest.cpp
@@ -57,6 +57,7 @@
   std::unique_ptr MRI;
   std::unique_ptr MUPMAI;
   std::unique_ptr MII;
+  std::unique_ptr MSTI;
   std::unique_ptr Str;
   std::unique_ptr Parser;
   std::unique_ptr Ctx;
@@ -86,6 +87,11 @@
 MAI.reset(TheTarget->createMCAsmInfo(*MRI, TripleName, MCOptions));
 EXPECT_NE(MAI, nullptr);
 
+std::unique_ptr MSTI;
+MSTI.reset(TheTarget->createMCSubtargetInfo(TripleName, /*CPU=*/"",
+/*Features=*/""));
+EXPECT_NE(MSTI, nullptr);
+
 // Now we cast to our mocked up version of MCAsmInfo.
 MUPMAI.reset(static_cast(MAI.release()));
 // MUPMAI should "hold" MAI.
@@ -99,9 +105,9 @@
 SrcMgr.AddNewSourceBuffer(std::move(Buffer), SMLoc());
 EXPECT_EQ(Buffer, nullptr);
 
-Ctx.reset(
-new MCContext(MUPMAI.get(), MRI.get(), &MOFI, &SrcMgr, &MCOptions));
-MOFI.InitMCObjectFileInfo(Triple, false, *Ctx, false);
+Ctx.reset(new MCContext(Triple, MUPMAI.get(), MRI.get(), &MOFI, MSTI.get(),
+&SrcMgr, &MCOptions));
+MOFI.initMCObjectFileInfo(*Ctx, /*PIC=*/false, /*LargeCodeModel=*/false);
 
 Str.reset(TheTarget->createNullStreamer(*Ctx));
 
Index: llvm/unittests/MC/DwarfLineTables.cpp
===
--- llvm/unittests/MC/DwarfLineTables.cpp
+++ llvm/unittests/MC/DwarfLineTables.cpp
@@ -21,7 +21,7 @@
 
 namespace {
 struct Context {
-  const char *Triple = "x86_64-pc-linux";
+  const char *TripleName = "x86_64-pc-linux";
   std::unique_ptr MRI;
   std::unique_ptr MAI;
   std::unique_ptr Ctx;
@@ -33,14 +33,15 @@
 
 // If we didn't build x86, do not run the test.
 std::st

[clang-tools-extra] c3d5f30 - [clangd] Find implementors only when index is present.

2021-05-03 Thread Utkarsh Saxena via cfe-commits

Author: Utkarsh Saxena
Date: 2021-05-03T17:16:33+02:00
New Revision: c3d5f306e910788fcc4db8da9c9e819a0869264b

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

LOG: [clangd] Find implementors only when index is present.

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

Added: 


Modified: 
clang-tools-extra/clangd/XRefs.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/XRefs.cpp 
b/clang-tools-extra/clangd/XRefs.cpp
index bb51b4a48d09..c21d3c3074ce 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -299,7 +299,7 @@ std::vector 
findImplementors(llvm::DenseSet IDs,
 RelationKind Predicate,
 const SymbolIndex *Index,
 llvm::StringRef MainFilePath) {
-  if (IDs.empty())
+  if (IDs.empty() || !Index)
 return {};
   static constexpr trace::Metric FindImplementorsMetric(
   "find_implementors", trace::Metric::Counter, "case");



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


[PATCH] D101750: [clangd] Find implementors only when index is present.

2021-05-03 Thread Utkarsh Saxena via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc3d5f306e910: [clangd] Find implementors only when index is 
present. (authored by usaxena95).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101750

Files:
  clang-tools-extra/clangd/XRefs.cpp


Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -299,7 +299,7 @@
 RelationKind Predicate,
 const SymbolIndex *Index,
 llvm::StringRef MainFilePath) {
-  if (IDs.empty())
+  if (IDs.empty() || !Index)
 return {};
   static constexpr trace::Metric FindImplementorsMetric(
   "find_implementors", trace::Metric::Counter, "case");


Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -299,7 +299,7 @@
 RelationKind Predicate,
 const SymbolIndex *Index,
 llvm::StringRef MainFilePath) {
-  if (IDs.empty())
+  if (IDs.empty() || !Index)
 return {};
   static constexpr trace::Metric FindImplementorsMetric(
   "find_implementors", trace::Metric::Counter, "case");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100621: [OpenMP] Ensure the DefaultMapperId has a location

2021-05-03 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield accepted this revision.
JonChesterfield added a comment.
This revision is now accepted and ready to land.

Not ideal to have unreproducible failures but the fix looks safe regardless


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100621

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


[PATCH] D99543: [clang-tidy] Allow opt-in or out of some commonly occuring patterns in NarrowingConversionsCheck.

2021-05-03 Thread Stephen Concannon via Phabricator via cfe-commits
Stephen updated this revision to Diff 342409.
Stephen marked 2 inline comments as done.
Stephen added a comment.

Within clang-tidy's NarrowingConversionsCheck.

- Allow opt-out of some common occurring patterns, such as:
  - Implicit casts between types of equivalent bit widths.
  - Implicit casts occurring from the return of a ::size() method.
  - Implicit casts on size_type and difference_type.
- Allow opt-in of errors within template instantiations.

This will help projects adopt these guidelines iteratively.
Developed in conjunction with Yitzhak Mandelbaum (ymandel).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99543

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.h
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-narrowing-conversions.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions-equivalentbitwidth-option.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions-ignoreconversionfromtypes-option.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions-intemplates-option.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions-intemplates-option.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions-intemplates-option.cpp
@@ -0,0 +1,35 @@
+// RUN: %check_clang_tidy -check-suffix=DEFAULT %s \
+// RUN: cppcoreguidelines-narrowing-conversions %t -- \
+// RUN: -config='{CheckOptions: [ \
+// RUN: ]}'
+
+// RUN: %check_clang_tidy -check-suffix=WARN %s \
+// RUN: cppcoreguidelines-narrowing-conversions %t -- \
+// RUN: -config='{CheckOptions: [ \
+// RUN:   {key: cppcoreguidelines-narrowing-conversions.WarnWithinTemplateInstantiation, value: 1} \
+// RUN: ]}'
+
+template 
+void assign_in_template(OrigType jj) {
+  int ii;
+  ii = jj;
+  // DEFAULT: Warning disabled because WarnWithinTemplateInstantiation=0.
+  // CHECK-MESSAGES-WARN: :[[@LINE-2]]:8: warning: narrowing conversion from 'long long' to signed type 'int' is implementation-defined [cppcoreguidelines-narrowing-conversions]
+}
+
+void narrow_inside_template_not_ok() {
+  long long j = 123;
+  assign_in_template(j);
+}
+
+void assign_outside_template(long long jj) {
+  int ii;
+  ii = jj;
+  // CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:8: warning: narrowing conversion from 'long long' to signed type 'int' is implementation-defined [cppcoreguidelines-narrowing-conversions]
+  // CHECK-MESSAGES-WARN: :[[@LINE-2]]:8: warning: narrowing conversion from 'long long' to signed type 'int' is implementation-defined [cppcoreguidelines-narrowing-conversions]
+}
+
+void narrow_outside_template_not_ok() {
+  long long j = 123;
+  assign_outside_template(j);
+}
Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions-ignoreconversionfromtypes-option.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions-ignoreconversionfromtypes-option.cpp
@@ -0,0 +1,84 @@
+// RUN: %check_clang_tidy -check-suffix=DEFAULT %s \
+// RUN: cppcoreguidelines-narrowing-conversions %t -- \
+// RUN: -config='{CheckOptions: [ \
+// RUN: ]}'
+
+// RUN: %check_clang_tidy -check-suffix=IGNORED %s \
+// RUN: cppcoreguidelines-narrowing-conversions %t -- \
+// RUN: -config='{CheckOptions: [ \
+// RUN:   {key: cppcoreguidelines-narrowing-conversions.IgnoreConversionFromTypes, value: "size_t;ptrdiff_t;size_type;difference_type"} \
+// RUN: ]}'
+
+typedef long long size_t;
+
+struct vector {
+  typedef long long size_type;
+  typedef long long difference_type;
+
+  size_t size() const { return 0; }
+};
+
+void narrowing_size_t() {
+  int i;
+  size_t j;
+  i = j;
+  // CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:7: warning: narrowing conversion from 'size_t' (aka 'long long') to signed type 'int' is implementation-defined [cppcoreguidelines-narrowing-conversions]
+  // IGNORED: Warning is disabled with IgnoreConversionFromTypes=size_t.
+}
+
+void narrowing_size_type() {
+  int i;
+  vector::size_type j;
+  i = j;
+  // CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:7: warning: narrowing conversion from 'vector::size_type' (aka 'long long') to signed type 'int' is implementation-defined [cppcoreguidelines-narrowing-conversions]
+  // IGNORED: Warning is disabled with IgnoreConversionFromTypes=size_type.
+}
+
+void narrowing_difference_type() {
+  int i;
+  vector::difference_type j;
+  i = j;
+  // CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:7: warning: narrowing conversion from 'vector::difference_type' (aka 'long long') to signed type 'int' is implementation-defined [cppcoreguidelines-narrowing-conversions]

[PATCH] D99543: [clang-tidy] Allow opt-in or out of some commonly occuring patterns in NarrowingConversionsCheck.

2021-05-03 Thread Stephen Concannon via Phabricator via cfe-commits
Stephen requested review of this revision.
Stephen added a comment.

Thanks, ymandel!

Anything else, aaron.ballman or hokein?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99543

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


[PATCH] D101696: [Matrix] Implement C-style explicit type conversions in CXX for matrix types

2021-05-03 Thread Saurabh Jha via Phabricator via cfe-commits
SaurabhJha updated this revision to Diff 342413.
SaurabhJha added a comment.

Rebase with main and add new tests for uitofp, unsigned int to int, and int to 
unsigned int


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101696

Files:
  clang/lib/Sema/SemaCast.cpp
  clang/test/CodeGenCXX/matrix-casts.cpp
  clang/test/SemaCXX/matrix-casts.cpp

Index: clang/test/SemaCXX/matrix-casts.cpp
===
--- clang/test/SemaCXX/matrix-casts.cpp
+++ clang/test/SemaCXX/matrix-casts.cpp
@@ -14,7 +14,6 @@
 typedef int vec __attribute__((vector_size(4)));
 
 void f1() {
-  // TODO: Update this test once the support of C-style casts for C++ is implemented.
   matrix_4_4 m1;
   matrix_4_4 m2;
   matrix_4_4 m3;
@@ -23,45 +22,46 @@
   vec v;
   test_struct *s;
 
-  (matrix_4_4)m1;   // expected-error {{C-style cast from 'matrix_4_4' (aka 'char __attribute__((matrix_type(4, \
-4)))') to 'matrix_4_4' (aka 'int __attribute__((matrix_type(4, 4)))') is not allowed}}
-  (matrix_4_4)m2; // expected-error {{C-style cast from 'matrix_4_4' (aka 'int __attribute__((matrix_type(4, \
-4)))') to 'matrix_4_4' (aka 'short __attribute__((matrix_type(4, 4)))') is not allowed}}
-  (matrix_5_5)m3;   // expected-error {{C-style cast from 'matrix_4_4' (aka 'short __attribute__((matrix_type(4, \
-4)))') to 'matrix_5_5' (aka 'int __attribute__((matrix_type(5, 5)))') is not allowed}}
+  m2 = (matrix_4_4)m1;
+  m2 = m1; // expected-error {{assigning to 'matrix_4_4' from incompatible type 'matrix_4_4'}}
+  m3 = (matrix_4_4)m2;
+  (matrix_5_5)m3; // expected-error {{conversion between matrix types 'matrix_5_5' (aka 'int __attribute__\
+((matrix_type(5, 5)))') and 'matrix_4_4' (aka 'short __attribute__((matrix_type(4, 4)))') of different size is not\
+ allowed}}
 
-  (int)m3;// expected-error {{C-style cast from 'matrix_4_4' (aka 'short __attribute__((matrix_type(4, \
-4)))') to 'int'}}
-  (matrix_4_4)i; // expected-error {{C-style cast from 'int' to 'matrix_4_4' (aka 'int __attribute__((\
-matrix_type(4, 4)))') is not allowed}}
+  (int)m3;// expected-error {{conversion between matrix type 'matrix_4_4' (aka 'short __attribute__\
+((matrix_type(4, 4)))') and incompatible type 'int' is not allowed}}
+  (matrix_4_4)i; // expected-error {{conversion between matrix type 'matrix_4_4' (aka 'int __attribute__\
+((matrix_type(4, 4)))') and incompatible type 'int' is not allowed}}
 
-  (vec) m2;// expected-error {{C-style cast from 'matrix_4_4' (aka 'int __attribute__((matrix_type(4, 4)))') \
-to 'vec' (vector of 1 'int' value) is not allowed}}
-  (matrix_4_4)v; // expected-error {{C-style cast from 'vec' (vector of 1 'int' value) to 'matrix_4_4' \
-(aka 'char __attribute__((matrix_type(4, 4)))') is not allowed}}
+  (vec) m2;// expected-error {{conversion between matrix type 'matrix_4_4' (aka 'int __attribute__\
+((matrix_type(4, 4)))') and incompatible type 'vec' (vector of 1 'int' value) is not allowed}}
+  (matrix_4_4)v; // expected-error {{conversion between matrix type 'matrix_4_4' (aka 'char __attribute__\
+((matrix_type(4, 4)))') and incompatible type 'vec' (vector of 1 'int' value) is not allowed}}
 
-  (test_struct *)m1;// expected-error {{cannot cast from type 'matrix_4_4' (aka 'char __attribute__\
-((matrix_type(4, 4)))') to pointer type 'test_struct *}}'
-  (matrix_5_5)s; // expected-error {{C-style cast from 'test_struct *' to 'matrix_5_5' (aka 'float __attribute__\
-((matrix_type(5, 5)))') is not allowed}}'
+  (test_struct *)m1;// expected-error {{conversion between matrix type 'matrix_4_4' (aka 'char __attribute__\
+((matrix_type(4, 4)))') and incompatible type 'test_struct *' is not allowed}}'
+  (matrix_5_5)s; // expected-error {{conversion between matrix type 'matrix_5_5' (aka 'float __attribute__\
+((matrix_type(5, 5)))') and incompatible type 'test_struct *' is not allowed}}'
 }
 
 void f2() {
-  // TODO: Update this test once the support of C-style casts for C++ is implemented.
   matrix_4_4 m1;
-  matrix_5_5 m2;
-  matrix_5_5 m3;
-  matrix_4_4 m4;
+  matrix_4_4 m2;
+  matrix_5_5 m3;
+  matrix_5_5 m4;
+  matrix_4_4 m5;
+  matrix_5_5 m6;
   float f;
 
-  (matrix_4_4)m1;   // expected-error {{C-style cast from 'matrix_4_4' (aka 'float __attribute__\
-((matrix_type(4, 4)))') to 'matrix_4_4' (aka 'double __attribute__((matrix_type(4, 4)))') is not allowed}}
-  (matrix_5_5)m2;// expected-error {{C-style cast from 'matrix_5_5' (aka 'double __attribute__\
-((matrix_type(5, 5)))') to 'matrix_5_5' (aka 'float __attribute__((matrix_type(5, 5)))') is not allowed}}
-  (matrix_5_5)m3; // expected-error {{C-style cast from 'matrix_5_5' (aka 'int __attribute__\
-((matrix_type(5, 5)))') to 'matrix_5_5' (aka 'unsigned int __attribute__((matrix_type(5, 5)))') \
-is not allowed}}
-  (matrix_4_4)m4;  // expected-error {{C-style cast from 'matrix_4_

[PATCH] D101763: [analyzer][ctu] Avoid parsing invocation list again and again during on-demand parsing of CTU

2021-05-03 Thread Ella Ma via Phabricator via cfe-commits
OikawaKirie created this revision.
OikawaKirie added reviewers: gamesh411, balazske, martong, xazax.hun.
OikawaKirie added a project: clang.
Herald added subscribers: steakhal, ASDenysPetrov, dkrupp, donat.nagy, 
Szelethus, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware.
OikawaKirie requested review of this revision.
Herald added a subscriber: cfe-commits.

During CTU, the *on-demand parsing* will read and parse the invocation list to 
know how to compile the file being imported. However, it seems that the 
invocation list will be parsed again if a previous parsing has failed. Then, 
parse again and fail again. This patch tries to overcome the problem by storing 
the error code during the first parsing, and re-create the stored error during 
the later parsings.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101763

Files:
  clang/include/clang/CrossTU/CrossTranslationUnit.h
  clang/lib/CrossTU/CrossTranslationUnit.cpp


Index: clang/lib/CrossTU/CrossTranslationUnit.cpp
===
--- clang/lib/CrossTU/CrossTranslationUnit.cpp
+++ clang/lib/CrossTU/CrossTranslationUnit.cpp
@@ -667,12 +667,16 @@
   /// Lazily initialize the invocation list member used for on-demand parsing.
   if (InvocationList)
 return llvm::Error::success();
+  else if (index_error_code::no_error != InvocationListParsingError)
+return llvm::make_error(InvocationListParsingError);
 
   llvm::ErrorOr> FileContent =
   llvm::MemoryBuffer::getFile(InvocationListFilePath);
-  if (!FileContent)
-return llvm::make_error(
-index_error_code::invocation_list_file_not_found);
+  if (!FileContent) {
+InvocationListParsingError =
+index_error_code::invocation_list_file_not_found;
+return llvm::make_error(InvocationListParsingError);
+  }
   std::unique_ptr ContentBuffer = std::move(*FileContent);
   assert(ContentBuffer && "If no error was produced after loading, the pointer 
"
   "should not be nullptr.");
@@ -680,8 +684,13 @@
   llvm::Expected ExpectedInvocationList =
   parseInvocationList(ContentBuffer->getBuffer(), PathStyle);
 
-  if (!ExpectedInvocationList)
-return ExpectedInvocationList.takeError();
+  // Handle the error to store the code for next call to this function.
+  if (!ExpectedInvocationList) {
+llvm::handleAllErrors(
+ExpectedInvocationList.takeError(),
+[&](IndexError &E) { InvocationListParsingError = E.getCode(); });
+return llvm::make_error(InvocationListParsingError);
+  }
 
   InvocationList = *ExpectedInvocationList;
 
Index: clang/include/clang/CrossTU/CrossTranslationUnit.h
===
--- clang/include/clang/CrossTU/CrossTranslationUnit.h
+++ clang/include/clang/CrossTU/CrossTranslationUnit.h
@@ -38,6 +38,7 @@
 namespace cross_tu {
 
 enum class index_error_code {
+  no_error = 0,
   unspecified = 1,
   missing_index_file,
   invalid_index_format,
@@ -253,6 +254,7 @@
 /// In case of on-demand parsing, the invocations for parsing the source
 /// files is stored.
 llvm::Optional InvocationList;
+index_error_code InvocationListParsingError = index_error_code::no_error;
   };
 
   /// Maintain number of AST loads and check for reaching the load limit.


Index: clang/lib/CrossTU/CrossTranslationUnit.cpp
===
--- clang/lib/CrossTU/CrossTranslationUnit.cpp
+++ clang/lib/CrossTU/CrossTranslationUnit.cpp
@@ -667,12 +667,16 @@
   /// Lazily initialize the invocation list member used for on-demand parsing.
   if (InvocationList)
 return llvm::Error::success();
+  else if (index_error_code::no_error != InvocationListParsingError)
+return llvm::make_error(InvocationListParsingError);
 
   llvm::ErrorOr> FileContent =
   llvm::MemoryBuffer::getFile(InvocationListFilePath);
-  if (!FileContent)
-return llvm::make_error(
-index_error_code::invocation_list_file_not_found);
+  if (!FileContent) {
+InvocationListParsingError =
+index_error_code::invocation_list_file_not_found;
+return llvm::make_error(InvocationListParsingError);
+  }
   std::unique_ptr ContentBuffer = std::move(*FileContent);
   assert(ContentBuffer && "If no error was produced after loading, the pointer "
   "should not be nullptr.");
@@ -680,8 +684,13 @@
   llvm::Expected ExpectedInvocationList =
   parseInvocationList(ContentBuffer->getBuffer(), PathStyle);
 
-  if (!ExpectedInvocationList)
-return ExpectedInvocationList.takeError();
+  // Handle the error to store the code for next call to this function.
+  if (!ExpectedInvocationList) {
+llvm::handleAllErrors(
+ExpectedInvocationList.takeError(),
+[&](IndexError &E) { InvocationListParsingError = E.getCode(); });
+return llvm::make_error(InvocationListParsingError);
+  }
 
   InvocationList = *ExpectedIn

[clang] 8d93d7f - [clang-format] Add options to AllowShortIfStatementsOnASingleLine to apply to "else if" and "else".

2021-05-03 Thread Marek Kurdej via cfe-commits

Author: Marek Kurdej
Date: 2021-05-03T18:11:25+02:00
New Revision: 8d93d7ffedebc5f18dee22ba954d38a1d2d0affa

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

LOG: [clang-format] Add options to AllowShortIfStatementsOnASingleLine to apply 
to "else if" and "else".

This fixes the bug http://llvm.org/pr50019.

Reviewed By: MyDeveloperDay

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Format/Format.h
clang/lib/Format/Format.cpp
clang/lib/Format/UnwrappedLineFormatter.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index d178097ac8e67..fe3b3257c6e46 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1,4 +1,4 @@
-
+q
 Clang 13.0.0 (In-Progress) Release Notes
 
 
@@ -239,6 +239,10 @@ clang-format
 - Option ``SpacesInAngles`` has been improved, it now accepts ``Leave`` value
   that allows to keep spaces where they are already present.
 
+- Option ``AllowShortIfStatementsOnASingleLine`` has been improved, it now
+  accepts ``AllIfsAndElse`` value that allows to put "else if" and "else" short
+  statements on a single line. (Fixes https://llvm.org/PR50019.)
+
 libclang
 
 

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 6c49497a56996..d13c6ff4d9334 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -620,37 +620,74 @@ struct FormatStyle {
   /// single line.
   ShortFunctionStyle AllowShortFunctionsOnASingleLine;
 
-  /// Different styles for handling short if lines
+  /// Different styles for handling short if statements.
   enum ShortIfStyle : unsigned char {
 /// Never put short ifs on the same line.
 /// \code
 ///   if (a)
-/// return ;
+/// return;
+///
+///   if (b)
+/// return;
+///   else
+/// return;
+///
+///   if (c)
+/// return;
 ///   else {
 /// return;
 ///   }
 /// \endcode
 SIS_Never,
-/// Without else put short ifs on the same line only if
-/// the else is not a compound statement.
+/// Put short ifs on the same line only if there is no else statement.
 /// \code
 ///   if (a) return;
+///
+///   if (b)
+/// return;
 ///   else
 /// return;
+///
+///   if (c)
+/// return;
+///   else {
+/// return;
+///   }
 /// \endcode
 SIS_WithoutElse,
-/// Always put short ifs on the same line if
-/// the else is not a compound statement or not.
+/// Put short ifs, but not else ifs nor else statements, on the same line.
 /// \code
 ///   if (a) return;
+///
+///   if (b) return;
+///   else if (b)
+/// return;
+///   else
+/// return;
+///
+///   if (c) return;
+///   else {
+/// return;
+///   }
+/// \endcode
+SIS_OnlyFirstIf,
+/// Always put short ifs, else ifs and else statements on the same
+/// line.
+/// \code
+///   if (a) return;
+///
+///   if (b) return;
+///   else return;
+///
+///   if (c) return;
 ///   else {
 /// return;
 ///   }
 /// \endcode
-SIS_Always,
+SIS_AllIfsAndElse,
   };
 
-  /// If ``true``, ``if (a) return;`` can be put on a single line.
+  /// Dependent on the value, ``if (a) return;`` can be put on a single line.
   ShortIfStyle AllowShortIfStatementsOnASingleLine;
 
   /// Different styles for merging short lambdas containing at most one

diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 7a80af24ab48c..ba7b03de8b3d3 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -146,10 +146,12 @@ template <> struct 
ScalarEnumerationTraits {
 template <> struct ScalarEnumerationTraits {
   static void enumeration(IO &IO, FormatStyle::ShortIfStyle &Value) {
 IO.enumCase(Value, "Never", FormatStyle::SIS_Never);
-IO.enumCase(Value, "Always", FormatStyle::SIS_Always);
 IO.enumCase(Value, "WithoutElse", FormatStyle::SIS_WithoutElse);
+IO.enumCase(Value, "OnlyFirstIf", FormatStyle::SIS_OnlyFirstIf);
+IO.enumCase(Value, "AllIfsAndElse", FormatStyle::SIS_AllIfsAndElse);
 
 // For backward compatibility.
+IO.enumCase(Value, "Always", FormatStyle::SIS_OnlyFirstIf);
 IO.enumCase(Value, "false", FormatStyle::SIS_Never);
 IO.enumCase(Value, "true", FormatStyle::SIS_WithoutElse);
   }

diff  --git a/clang/lib/Format/UnwrappedLineFormatter.cpp 

[PATCH] D100727: [clang-format] Add options to AllowShortIfStatementsOnASingleLine to apply to "else if" and "else".

2021-05-03 Thread Marek Kurdej via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8d93d7ffedeb: [clang-format] Add options to 
AllowShortIfStatementsOnASingleLine to apply to… (authored by curdeius).

Changed prior to commit:
  https://reviews.llvm.org/D100727?vs=342338&id=342417#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100727

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -461,6 +461,69 @@
"  }\n"
"g();");
 
+  verifyFormat("if (a)\n"
+   "  g();");
+  verifyFormat("if (a) {\n"
+   "  g()\n"
+   "};");
+  verifyFormat("if (a)\n"
+   "  g();\n"
+   "else\n"
+   "  g();");
+  verifyFormat("if (a) {\n"
+   "  g();\n"
+   "} else\n"
+   "  g();");
+  verifyFormat("if (a)\n"
+   "  g();\n"
+   "else {\n"
+   "  g();\n"
+   "}");
+  verifyFormat("if (a) {\n"
+   "  g();\n"
+   "} else {\n"
+   "  g();\n"
+   "}");
+  verifyFormat("if (a)\n"
+   "  g();\n"
+   "else if (b)\n"
+   "  g();\n"
+   "else\n"
+   "  g();");
+  verifyFormat("if (a) {\n"
+   "  g();\n"
+   "} else if (b)\n"
+   "  g();\n"
+   "else\n"
+   "  g();");
+  verifyFormat("if (a)\n"
+   "  g();\n"
+   "else if (b) {\n"
+   "  g();\n"
+   "} else\n"
+   "  g();");
+  verifyFormat("if (a)\n"
+   "  g();\n"
+   "else if (b)\n"
+   "  g();\n"
+   "else {\n"
+   "  g();\n"
+   "}");
+  verifyFormat("if (a)\n"
+   "  g();\n"
+   "else if (b) {\n"
+   "  g();\n"
+   "} else {\n"
+   "  g();\n"
+   "}");
+  verifyFormat("if (a) {\n"
+   "  g();\n"
+   "} else if (b) {\n"
+   "  g();\n"
+   "} else {\n"
+   "  g();\n"
+   "}");
+
   FormatStyle AllowsMergedIf = getLLVMStyle();
   AllowsMergedIf.AlignEscapedNewlines = FormatStyle::ENAS_Left;
   AllowsMergedIf.AllowShortIfStatementsOnASingleLine =
@@ -510,6 +573,59 @@
 
   AllowsMergedIf.ColumnLimit = 13;
   verifyFormat("if (a)\n  return;", AllowsMergedIf);
+
+  FormatStyle AllowsMergedIfElse = getLLVMStyle();
+  AllowsMergedIfElse.AllowShortIfStatementsOnASingleLine =
+  FormatStyle::SIS_AllIfsAndElse;
+  verifyFormat("if (a)\n"
+   "  // comment\n"
+   "  f();\n"
+   "else\n"
+   "  // comment\n"
+   "  f();",
+   AllowsMergedIfElse);
+  verifyFormat("{\n"
+   "  if (a)\n"
+   "  label:\n"
+   "f();\n"
+   "  else\n"
+   "  label:\n"
+   "f();\n"
+   "}",
+   AllowsMergedIfElse);
+  verifyFormat("if (a)\n"
+   "  ;\n"
+   "else\n"
+   "  ;",
+   AllowsMergedIfElse);
+  verifyFormat("if (a) {\n"
+   "} else {\n"
+   "}",
+   AllowsMergedIfElse);
+  verifyFormat("if (a) return;\n"
+   "else if (b) return;\n"
+   "else return;",
+   AllowsMergedIfElse);
+  verifyFormat("if (a) {\n"
+   "} else return;",
+   AllowsMergedIfElse);
+  verifyFormat("if (a) {\n"
+   "} else if (b) return;\n"
+   "else return;",
+   AllowsMergedIfElse);
+  verifyFormat("if (a) return;\n"
+   "else if (b) {\n"
+   "} else return;",
+   AllowsMergedIfElse);
+  verifyFormat("if (a)\n"
+   "  if (b) return;\n"
+   "  else return;",
+   AllowsMergedIfElse);
+  verifyFormat("if constexpr (a)\n"
+   "  if constexpr (b) return;\n"
+   "  else if constexpr (c) return;\n"
+   "  else return;",
+   AllowsMergedIfElse);
 }
 
 TEST_F(FormatTest, FormatIfWithoutCompoundStatementButElseWith) {
@@ -529,7 +645,166 @@
"  g();\n",
AllowsMergedIf);
 
-  AllowsMergedIf.AllowShortIfStatementsOnASingleLine = FormatStyle::SIS_Always;
+  verifyFormat("if (a) g();", AllowsMergedIf);
+  verifyFormat("if (a) {\n"
+   "  g()\n"
+   "};",
+   AllowsMergedI

[PATCH] D101030: [OpenMP] Overhaul `declare target` handling

2021-05-03 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 342419.
jdoerfert added a comment.

Fix tests by not always emitting a definition for omp allocate


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101030

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/AttrImpl.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/allocate_codegen.cpp
  clang/test/OpenMP/declare_target_codegen.cpp
  clang/test/OpenMP/declare_target_codegen_globalization.cpp
  clang/test/OpenMP/declare_target_device_only_compilation.cpp
  clang/test/OpenMP/declare_target_messages.cpp
  clang/test/OpenMP/declare_target_only_one_side_compilation.cpp
  clang/test/OpenMP/nvptx_allocate_codegen.cpp
  clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp
  clang/test/OpenMP/nvptx_declare_variant_name_mangling.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -922,6 +922,13 @@
 VersionedClause
   ];
 }
+def OMP_BeginDeclareTarget : Directive<"begin declare target"> {
+  let allowedClauses = [
+VersionedClause,
+VersionedClause,
+VersionedClause,
+  ];
+}
 def OMP_DeclareTarget : Directive<"declare target"> {
   let allowedClauses = [
 VersionedClause,
Index: clang/test/OpenMP/nvptx_declare_variant_name_mangling.cpp
===
--- clang/test/OpenMP/nvptx_declare_variant_name_mangling.cpp
+++ clang/test/OpenMP/nvptx_declare_variant_name_mangling.cpp
@@ -6,8 +6,8 @@
 
 // CHECK-DAG: @_Z3barv
 // CHECK-DAG: @_Z3bazv
-// CHECK-DAG: @"_Z53bar$ompvariant$S2$s7$Pnvptx$Pnvptx64$S3$s9$Pmatch_anyv"
-// CHECK-DAG: @"_Z53baz$ompvariant$S2$s7$Pnvptx$Pnvptx64$S3$s9$Pmatch_anyv"
+// CHECK-DAG: define{{.*}}@"_Z53bar$ompvariant$S2$s7$Pnvptx$Pnvptx64$S3$s9$Pmatch_anyv"
+// CHECK-DAG: define{{.*}}@"_Z53baz$ompvariant$S2$s7$Pnvptx$Pnvptx64$S3$s9$Pmatch_anyv"
 // CHECK-DAG: call i32 @"_Z53bar$ompvariant$S2$s7$Pnvptx$Pnvptx64$S3$s9$Pmatch_anyv"()
 // CHECK-DAG: call i32 @"_Z53baz$ompvariant$S2$s7$Pnvptx$Pnvptx64$S3$s9$Pmatch_anyv"()
 
Index: clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp
===
--- clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp
+++ clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp
@@ -34,21 +34,16 @@
 #pragma omp declare target (bar)
 int caz() { return 0; }
 
-// DEVICE-DAG: define{{ hidden | }}i32 [[FOO:@.*foo.*]]()
 // DEVICE-DAG: define{{ hidden | }}i32 [[BAR:@.*bar.*]]()
-// DEVICE-DAG: define{{ hidden | }}i32 [[BAZ:@.*baz.*]]()
-// DEVICE-DAG: define{{ hidden | }}i32 [[DOO:@.*doo.*]]()
-// DEVICE-DAG: define{{ hidden | }}i32 [[CAR:@.*car.*]]()
-// DEVICE-DAG: define{{ hidden | }}i32 [[CAZ:@.*caz.*]]()
 
 static int c = foo() + bar() + baz();
 #pragma omp declare target (c)
-// HOST-DAG: @[[C_CTOR:__omp_offloading__.+_c_l44_ctor]] = private constant i8 0
-// DEVICE-DAG: define internal void [[C_CTOR:@__omp_offloading__.+_c_l44_ctor]]()
-// DEVICE-DAG: call i32 [[FOO]]()
-// DEVICE-DAG: call i32 [[BAR]]()
-// DEVICE-DAG: call i32 [[BAZ]]()
-// DEVICE-DAG: ret void
+// HOST-DAG: @[[C_CTOR:__omp_offloading__.+_c_l39_ctor]] = private constant i8 0
+
+// DEVICE-DAG: define internal void [[C_CTOR:@__omp_offloading__.+_c_l39_ctor]]()
+// DEVICE-DAG: define{{ hidden | }}i32 [[FOO:@.*foo.*]]()
+// DEVICE-DAG: define{{ hidden | }}i32 [[BAZ:@.*baz.*]]()
+// DEVICE-DAG: define{{ hidden | }}i32 [[DOO:@.*doo.*]]()
 
 struct S {
   int a;
@@ -60,17 +55,14 @@
 #pragma omp declare target
 S cd = doo() + car() + caz() + baz();
 #pragma omp end declare target
-// HOST-DAG: @[[CD_CTOR:__omp_offloading__.+_cd_l61_ctor]] = private constant i8 0
-// DEVICE-DAG: define internal void [[CD_CTOR:@__omp_offloading__.+_cd_l61_ctor]]()
-// DEVICE-DAG: call i32 [[DOO]]()
-// DEVICE-DAG: call i32 [[CAR]]()
-// DEVICE-DAG: call i32 [[CAZ]]()
-// DEVICE-DAG: ret void
-
-// HOST-DAG: @[[CD_DTOR:__omp_offloading__.+_cd_l61_dtor]] = private constant i8 0
-// DEVICE-DAG: define internal void [[CD_DTOR:@__omp_offloading__.+_cd_l61_dtor]]()
-// DEVICE-DAG: call void
-// DEVICE-DAG: ret void
+// HOST-DAG: @[[CD_CTOR:__omp_offloading__.+_cd_l56_ctor]] = private constant i8 0
+// DEVICE-DAG: define internal void [[CD_CTOR:@__omp_offloading__.+_cd_l56_ctor]]()
+
+// DEVICE-DAG: define{{ hidden | }}i32 [[CAR:@.*car.*]]()
+// DEVIC

[clang] d492532 - [docs] Fix syntax typo.

2021-05-03 Thread Marek Kurdej via cfe-commits

Author: Marek Kurdej
Date: 2021-05-03T18:28:54+02:00
New Revision: d492532b8c3a90502a452174c7f1d2677d054fda

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

LOG: [docs] Fix syntax typo.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index fe3b3257c6e4..62604a6e95eb 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1,4 +1,4 @@
-q
+=
 Clang 13.0.0 (In-Progress) Release Notes
 
 



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


[PATCH] D101479: [Driver] Support libc++ in MSVC

2021-05-03 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In D101479#2733434 , @thakis wrote:

> In D101479#2733354 , @mstorsjo 
> wrote:
>
>> Not sure if we want the desicion between static and shared libc++ be coupled 
>> with `/MT` and `/MD`, as one can quite plausibly want to use e.g. a static 
>> libc++ with `/MD`.
>
> Right, I meant more "how do users pick if they want a statically or 
> dynamically linked libc++". Sounds like you get a dynamic libc++ by default. 
> Since Windows doesn't have rpaths afaik, using `-stdlib=libc++` means you'll 
> get an executable that won't start, unless you know to copy the libc++ dll 
> next to your executable with this patch as-is, yes?

Yes, that sounds correct.

As for how people choose - I guess unless you resort to trickery - you use 
whichever is default in the libc++ build that is used.

However, the libc++ headers inject linker directives to pull in the right form 
of the lib, matching the linkage of the headers. So as long as that isn't 
disabled, the clang driver shouldn't need to specify any lib to link against at 
all.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101479

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


[clang] b2be167 - [docs] Fix title overline.

2021-05-03 Thread Marek Kurdej via cfe-commits

Author: Marek Kurdej
Date: 2021-05-03T18:32:36+02:00
New Revision: b2be167a49523b1caab78bfca0635b8439c157ee

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

LOG: [docs] Fix title overline.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 62604a6e95eb..36ceb1bc7cfb 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1,4 +1,4 @@
-=
+
 Clang 13.0.0 (In-Progress) Release Notes
 
 



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


[clang] 9d669e8 - [docs] Bump the trunk major version to 13 and update copyright year.

2021-05-03 Thread Marek Kurdej via cfe-commits

Author: Marek Kurdej
Date: 2021-05-03T18:44:47+02:00
New Revision: 9d669e859b8069bf154c6d9ec37cc6bc2304f4e9

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

LOG: [docs] Bump the trunk major version to 13 and update copyright year.

Added: 


Modified: 
clang/docs/conf.py
libcxx/docs/conf.py

Removed: 




diff  --git a/clang/docs/conf.py b/clang/docs/conf.py
index b63e829bfaf1..3af05bac2321 100644
--- a/clang/docs/conf.py
+++ b/clang/docs/conf.py
@@ -50,9 +50,9 @@
 # built documents.
 #
 # The short version.
-version = '12'
+version = '13'
 # The full version, including alpha/beta/rc tags.
-release = '12'
+release = '13'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.

diff  --git a/libcxx/docs/conf.py b/libcxx/docs/conf.py
index c58b1871c377..5516cdb2eeea 100644
--- a/libcxx/docs/conf.py
+++ b/libcxx/docs/conf.py
@@ -11,6 +11,7 @@
 # serve to show the default.
 
 import sys, os
+from datetime import date
 
 # If extensions (or modules to document with autodoc) are in another directory,
 # add these directories to sys.path here. If the directory is relative to the
@@ -40,7 +41,7 @@
 
 # General information about the project.
 project = u'libc++'
-copyright = u'2011-2020, LLVM Project'
+copyright = u'2011-2021, LLVM Project' % date.today().year
 
 # The version info for the project you're documenting, acts as replacement for
 # |version| and |release|, also used in various other places throughout the



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


[PATCH] D101030: [OpenMP] Overhaul `declare target` handling

2021-05-03 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/CodeGen/CGDecl.cpp:2618
+void CodeGenModule::EmitOMPAllocateDecl(const OMPAllocateDecl *D) {
+  for (Expr *E : const_cast(D)->varlists()) {
+auto *DE = cast(E);

Why need to remove constantness here?



Comment at: clang/lib/CodeGen/CGDecl.cpp:2622
+
+// Skipp all but globals.
+if (!VD->hasGlobalStorage())

`Skip`



Comment at: clang/lib/CodeGen/CGDecl.cpp:2623-2624
+// Skipp all but globals.
+if (!VD->hasGlobalStorage())
+  continue;
+

What about static locals, will it work?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101030

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


[PATCH] D101462: [MC] Untangle MCContext and MCObjectFileInfo

2021-05-03 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.

Looks great!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101462

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


[PATCH] D97915: [Coroutines] Handle overaligned frame allocation

2021-05-03 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D97915#2728377 , @ChuanqiXu wrote:

> This code snippets confused me before:
>
>   coro.alloc.align: ; preds = 
> %coro.check.align
> %mask = sub i64 %11, 1
> %intptr = ptrtoint i8* %call to i64
> %over_boundary = add i64 %intptr, %mask
> %inverted_mask = xor i64 %mask, -1
> %aligned_intptr = and i64 %over_boundary, %inverted_mask
> %diff = sub i64 %aligned_intptr, %intptr
> %aligned_result = getelementptr inbounds i8, i8* %call, i64 %diff
>
> This code implies that `%diff > 0`. Formally, given `Align = 2^m, m > 4` and 
> `Address=16n`, we need to prove that:
>
>   (Address + Align -16)&(~(Align-1)) >= Address
>
> `&(~Align-1)` would make the lowest `m` bit to 0. And `Align-16` equals to 
> `2^m - 16`, which is `16*(2^(m-4)-1)`. Then `Address + Align -16` could be 
> `16*(n+2^(m-4)-1)`.
> Then we call `X` for the value of the lowest `m` bit of  `Address + Align 
> -16`. 
> Because `X` has `m` bit, so `X <= 2^m - 1`. Noticed that `X` should be 16 
> aligned, so the lowest 4 bit should be zero.
> Now,
>
>   X <= 2^m - 1 -1 - 2 - 4 - 8 = 2^m - 16
>
> So the inequality we need prove now should be:
>
>   16*(n+2^(m-4)-1) - X >= 16n
>
> Given X has the largest value wouldn't affect the inequality, so:
>
>   16*(n+2^(m-4)-1) - 2^m + 16 >= 16n
>
> which is very easy now.
>
> The overall prove looks non-travel to me. I spent some time to figure it out. 
> I guess there must be some other people who can't get it immediately. I 
> strongly recommend to add comment and corresponding prove for this code.

The code is equivalent to

  (Address + Align -1)&(~(Align-1)) >= Address

which should be correct. It is implemented by 
`CodeGenFunction::EmitBuiltinAlignTo`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97915

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


[PATCH] D100620: [OpenMP] Make sure classes work on the device as they do on the host

2021-05-03 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 342433.
jdoerfert marked an inline comment as done.
jdoerfert added a comment.
Herald added a subscriber: mgorny.

Avoid including  by not wrapping 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100620

Files:
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/openmp_wrappers/__clang_openmp_device_functions.h
  clang/lib/Headers/openmp_wrappers/new
  clang/test/Headers/Inputs/include/new
  clang/test/Headers/Inputs/include/stdlib.h
  clang/test/Headers/target_include_new.cpp

Index: clang/test/Headers/target_include_new.cpp
===
--- /dev/null
+++ clang/test/Headers/target_include_new.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/Inputs/include -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64 -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/Inputs/include -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64 -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s
+// expected-no-diagnostics
+
+// Ensure we make `_ZdlPv`, aka. `operator delete(void*)` available without the need to `include `.
+
+// CHECK: define {{.*}}_ZdlPv
+
+#ifndef HEADER
+#define HEADER
+
+class Base {
+  public:
+virtual ~Base() = default;
+};
+
+class Derived : public Base {
+  public:
+#pragma omp declare target
+Derived();
+#pragma omp end declare target
+};
+
+Derived::Derived() { }
+
+int main(void) {
+  #pragma omp target
+  {
+  }
+  return 0;
+}
+#endif
Index: clang/test/Headers/Inputs/include/stdlib.h
===
--- clang/test/Headers/Inputs/include/stdlib.h
+++ clang/test/Headers/Inputs/include/stdlib.h
@@ -1,6 +1,9 @@
 #pragma once
 typedef __SIZE_TYPE__ size_t;
 
+void *malloc(size_t);
+void free(void*);
+
 #ifndef __cplusplus
 extern int abs(int __x) __attribute__((__const__));
 #endif
Index: clang/test/Headers/Inputs/include/new
===
--- /dev/null
+++ clang/test/Headers/Inputs/include/new
@@ -0,0 +1,7 @@
+
+namespace std
+{
+
+struct nothrow_t { explicit nothrow_t() = default; };
+
+}
Index: clang/lib/Headers/openmp_wrappers/new
===
--- clang/lib/Headers/openmp_wrappers/new
+++ /dev/null
@@ -1,70 +0,0 @@
-//===- new - OPENMP wrapper for  --===
-//
-// 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
-//
-//===---===
-
-#ifndef __CLANG_OPENMP_WRAPPERS_NEW
-#define __CLANG_OPENMP_WRAPPERS_NEW
-
-#include_next 
-
-#if defined(__NVPTX__) && defined(_OPENMP)
-
-#include 
-
-#pragma push_macro("OPENMP_NOEXCEPT")
-#if __cplusplus >= 201103L
-#define OPENMP_NOEXCEPT noexcept
-#else
-#define OPENMP_NOEXCEPT
-#endif
-
-// Device overrides for non-placement new and delete.
-inline void *operator new(__SIZE_TYPE__ size) {
-  if (size == 0)
-size = 1;
-  return ::malloc(size);
-}
-inline void *operator new(__SIZE_TYPE__ size,
-  const std::nothrow_t &) OPENMP_NOEXCEPT {
-  return ::operator new(size);
-}
-
-inline void *operator new[](__SIZE_TYPE__ size) { return ::operator new(size); }
-inline void *operator new[](__SIZE_TYPE__ size, const std::nothrow_t &) {
-  return ::operator new(size);
-}
-
-inline void operator delete(void *ptr)OPENMP_NOEXCEPT {
-  if (ptr)
-::free(ptr);
-}
-inline void operator delete(void *ptr, const std::nothrow_t &)OPENMP_NOEXCEPT {
-  ::operator delete(ptr);
-}
-
-inline void operator delete[](void *ptr) OPENMP_NOEXCEPT {
-  ::operator delete(ptr);
-}
-inline void operator delete[](void *ptr,
-  const std::nothrow_t &) OPENMP_NOEXCEPT {
-  ::operator delete(ptr);
-}
-
-// Sized delete, C++14 only.
-#if __cplusplus >= 201402L
-inline void operator delete(void *ptr, __SIZE_TYPE__ size)OPENMP_NOEXCEPT {
-  ::operator delete(ptr);
-}
-inline void operator delete[](void *ptr, __SIZE_TYPE__ size) OPENMP_NOEXCEPT {
-  ::operator delete(ptr);
-}
-#endif
-
-#pragma pop_macro("OPENMP_NOEXCEPT")
-#endif
-
-#endif // include guard
Index: clang/lib/Headers/openmp_wrappers/__clang_openmp_device_functions.h
===
--- clang/lib/Headers/openmp_wrappers/__clang_openmp_device_functions.h
+++ clang/lib/Headers/openmp_wrappers/__cl

[clang] 31751ce - [clang-format] Fix build on gcc < 7 introduced in rG8d93d7ff.

2021-05-03 Thread Marek Kurdej via cfe-commits

Author: Marek Kurdej
Date: 2021-05-03T18:52:41+02:00
New Revision: 31751ce1b9239d7aacac84864bf06c36ce888408

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

LOG: [clang-format] Fix build on gcc < 7 introduced in rG8d93d7ff.

This fixes another bogus build error on gcc, e.g. 
https://lab.llvm.org/buildbot/#/builders/118/builds/2504.

/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux-perf/llvm/clang/lib/Format/UnwrappedLineFormatter.cpp:424:42:
 error: binding ‘clang::format::FormatToken* const’ to reference of type 
‘clang::format::FormatToken*&’ discards qualifiers
 auto IsElseLine = [&First = TheLine->First]() -> bool {
  ^

Added: 


Modified: 
clang/lib/Format/UnwrappedLineFormatter.cpp

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineFormatter.cpp 
b/clang/lib/Format/UnwrappedLineFormatter.cpp
index 8d1694fe4b44..2b1b15de8bbf 100644
--- a/clang/lib/Format/UnwrappedLineFormatter.cpp
+++ b/clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -421,7 +421,8 @@ class LineJoiner {
   }
   return MergedLines;
 }
-auto IsElseLine = [&First = TheLine->First]() -> bool {
+auto IsElseLine = [&TheLine]() -> bool {
+  const FormatToken *First = TheLine->First;
   if (First->is(tok::kw_else))
 return true;
 



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


[PATCH] D100620: [OpenMP] Make sure classes work on the device as they do on the host

2021-05-03 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield accepted this revision.
JonChesterfield added a comment.
This revision is now accepted and ready to land.

cstdlib may not exist, probably in the same situations as new not existing, but 
that can probably be left until the problem arises. I think this looks 
reasonable, and it'll unblock some applications that don't presently build.




Comment at: 
clang/lib/Headers/openmp_wrappers/__clang_openmp_device_functions.h:74
+  if (ptr)
+::free(ptr);
+}

free(nullptr) is well formed, don't think we need the branch here


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100620

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


[PATCH] D101030: [OpenMP] Overhaul `declare target` handling

2021-05-03 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: clang/lib/CodeGen/CGDecl.cpp:2618
+void CodeGenModule::EmitOMPAllocateDecl(const OMPAllocateDecl *D) {
+  for (Expr *E : const_cast(D)->varlists()) {
+auto *DE = cast(E);

ABataev wrote:
> Why need to remove constantness here?
The problem is that the declaration, which might have been already generated in 
IR or not, had no address space attached before. Now we want to do that after 
the fact, potentially *way later*. To reuse the general codegen mechanism I 
modify the VarDecl (temporarily) by attaching the new address space and calling 
codegen again. If you have a better idea, I'm happy to change this.



Comment at: clang/lib/CodeGen/CGDecl.cpp:2623-2624
+// Skipp all but globals.
+if (!VD->hasGlobalStorage())
+  continue;
+

ABataev wrote:
> What about static locals, will it work?
need to check, will add a test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101030

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


[PATCH] D100620: [OpenMP] Make sure classes work on the device as they do on the host

2021-05-03 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

We might want a test that includes  along with this header, to check they 
don't conflict with one another


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100620

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


[PATCH] D100620: [OpenMP] Make sure classes work on the device as they do on the host

2021-05-03 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D100620#2733707 , @JonChesterfield 
wrote:

> We might want a test that includes  along with this header, to check 
> they don't conflict with one another

For that I need to replicate the potentially conflicting `` stuff in the 
test header mockups. I'll try it later on one system though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100620

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


[PATCH] D101766: [TableGen] [Clang] Clean up Options.td and add asserts

2021-05-03 Thread Paul C. Anagnostopoulos via Phabricator via cfe-commits
Paul-C-Anagnostopoulos created this revision.
Paul-C-Anagnostopoulos added reviewers: jansvoboda11, dblaikie, craig.topper.
Herald added a subscriber: dang.
Paul-C-Anagnostopoulos requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This revision does some cleanup to Options.td. It also adds three asserts that 
have been listed as TODOs for awhile.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101766

Files:
  clang/include/clang/Driver/Options.td

Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -274,10 +274,10 @@
 // Use this only when the option cannot be declared via BoolFOption.
 multiclass OptInFFlag flags=[]> {
-  def f#NAME : Flag<["-"], "f"#name>, Flags,
-   Group, HelpText;
+  def f#NAME : Flag<["-"], "f"#name>, Flags<[CC1Option] # flags>,
+   Group, HelpText;
   def fno_#NAME : Flag<["-"], "fno-"#name>, Flags,
-  Group, HelpText;
+  Group, HelpText;
 }
 
 // A boolean option which is opt-out in CC1. The negative option exists in CC1 and
@@ -286,9 +286,9 @@
 multiclass OptOutFFlag flags=[]> {
   def f#NAME : Flag<["-"], "f"#name>, Flags,
-   Group, HelpText;
-  def fno_#NAME : Flag<["-"], "fno-"#name>, Flags,
-  Group, HelpText;
+   Group, HelpText;
+  def fno_#NAME : Flag<["-"], "fno-"#name>, Flags<[CC1Option] # flags>,
+  Group, HelpText;
 }
 
 // Creates a positive and negative flags where both of them are prefixed with
@@ -297,9 +297,9 @@
 multiclass SimpleMFlag {
   def m#NAME : Flag<["-"], "m"#name>, Group,
-HelpText;
+HelpText;
   def mno_#NAME : Flag<["-"], "mno-"#name>, Group,
-HelpText;
+HelpText;
 }
 
 //===--===//
@@ -349,8 +349,8 @@
 class ApplySuffix {
   FlagDef Result
 = FlagDef;
+  flag.OptionFlags # suffix.OptionFlags,
+  flag.Help # suffix.Help, flag.ImpliedBy>;
 }
 
 // Definition of the command line flag with positive spelling, e.g. "-ffoo".
@@ -368,16 +368,16 @@
   : FlagDef {
   // Name of the TableGen record.
-  string RecordName = prefix#!cond(flag.Polarity : "", true : "no_")#name;
+  string RecordName = prefix # !if(flag.Polarity, "", "no_") # name;
 
   // Spelling of the flag.
-  string Spelling = prefix#!cond(flag.Polarity : "", true : "no-")#spelling;
+  string Spelling = prefix # !if(flag.Polarity, "", "no-") # spelling;
 
   // Can the flag be implied by another flag?
   bit CanBeImplied = !not(!empty(flag.ImpliedBy));
 
   // C++ code that will be assigned to the keypath when the flag is present.
-  code ValueAsCode = !cond(flag.Value : "true", true: "false");
+  code ValueAsCode = !if(flag.Value, "true", "false");
 }
 
 // TableGen record for a single marshalled flag.
@@ -404,11 +404,19 @@
   defvar flag2 = FlagDefExpanded.Result, prefix,
  NAME, spelling_base>;
 
-  // TODO: Assert that the flags have different polarity.
-  // TODO: Assert that the flags have different value.
-  // TODO: Assert that only one of the flags can be implied.
+  // The flags must have different polarity, different values, and only
+  // one can be implied.
+  assert !xor(flag1.Polarity, flag2.Polarity),
+ "the flags must have different polarity: flag1: " #
+ flag1.Polarity # ", flag2: " # flag2.Polarity;
+  assert !ne(flag1.Value, flag2.Value),
+ "the flags must have different values: flag1: " #
+ flag1.Value # ", flag2: " # flag2.Value;
+  assert !not(!and(flag1.CanBeImplied, flag2.CanBeImplied)),
+ "only one of the flags can be implied: flag1: " #
+ flag1.CanBeImplied # ", flag2: " # flag2.CanBeImplied;
 
-  defvar implied = !cond(flag1.CanBeImplied: flag1, true: flag2);
+  defvar implied = !if(flag1.CanBeImplied, flag1, flag2);
 
   def flag1.RecordName : MarshalledFlagRec;
   def flag2.RecordName : MarshalledFlagRec;
@@ -1077,7 +1085,8 @@
 def fasynchronous_unwind_tables : Flag<["-"], "fasynchronous-unwind-tables">, Group;
 
 defm double_square_bracket_attributes : BoolFOption<"double-square-bracket-attributes",
-  LangOpts<"DoubleSquareBracketAttributes">, Default,
+  LangOpts<"DoubleSquareBracketAttributes">,
+  Default,
   PosFlag, NegFlag,
   BothFlags<[NoXarchOption, CC1Option], " '[[]]' attributes in all C and C++ language modes">>;
 
@@ -1896,8 +1905,9 @@
 "LangOptions::LaxVectorConversionKind::Integer",
 "LangOptions::LaxVectorConversionKind::All"]>,
   MarshallingInfoEnum,
-  !strconcat(open_cl.KeyPath, " ? LangOptions::LaxVectorConversionKind::None"
-  " : LangOptions::LaxVectorConversionKind::All")>;
+  open_cl.

[PATCH] D101462: [MC] Untangle MCContext and MCObjectFileInfo

2021-05-03 Thread Philipp Krones via Phabricator via cfe-commits
flip1995 added a comment.

Not sure how the process from here on out is. I think it is important to note, 
that I don't have push rights and someone else will have to land this for me (I 
guess?).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101462

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


[PATCH] D101462: [MC] Untangle MCContext and MCObjectFileInfo

2021-05-03 Thread Philipp Krones via Phabricator via cfe-commits
flip1995 added a comment.

> I'll keep this open for a few days as it touches too many things.

Sounds good 👍

I used `arc diff`. The commits I made with `git` have my name and email 
attached. But it seems like `arc` doesn't use them? I'll figure it out 
tomorrow, can't be that hard, I hope.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101462

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


[PATCH] D101462: [MC] Untangle MCContext and MCObjectFileInfo

2021-05-03 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D101462#2733691 , @flip1995 wrote:

> Not sure how the process from here on out is. I think it is important to 
> note, that I don't have push rights and someone else will have to land this 
> for me (I guess?).

I'll keep this open for a few days as it touches too many things.
I can push it on your behalf afterwards but you'll need to provide your name 
and email 
https://llvm.org/docs/Phabricator.html#committing-someone-s-change-from-phabricator
(If you uploaded the diff with with `git format-patch -1` instead of `git diff` 
the information would have been available)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101462

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


[PATCH] D101630: [HIP] Fix device-only compilation

2021-05-03 Thread Artem Belevich via Phabricator via cfe-commits
tra added a subscriber: jdoerfert.
tra added a comment.

In D101630#2730273 , @yaxunl wrote:

> How about an option -fhip-bundle-device-output. If it is on, device output is 
> bundled no matter how many GPU arch there are. By default it is on.

+1 to the option, but I can't say I'm particularly happy about the default. I'd 
still prefer the default to be a no-bundling + an error in cases when we'd 
nominally produce multiple outputs.
We could use a third opinion here.

@jdoerfert : Do you have any thoughts on what would be a sensible default when 
a user uses `-S -o foo.s` for compilations that may produce multiple results? I 
think OpenMP may have to deal with similar issues.

On one hand it would be convenient for ccache to just work with the CUDA/HIP 
compilation out of the box. Compiler always produces one output file, 
regardless of what it does under the hood and ccache may not care what's in it.

On the other, this behavior breaks user expectations. I.e. `clang -S` is 
supposed to produce the assembly, not an opaque binary bundle blob.
Using an `-S` with multiple sub-compilations is also likely an error on the 
user's end and should be explicitly diagnosed and that's how it currently work.
Using `-fno-hip-bundle-device-output` to restore the expected behavior puts the 
burden on the wrong side, IMO.  I believe, it should be ccache which should be 
using `-fhip-bundle-device-output` to deal with the CUDA/HIP compilations.


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

https://reviews.llvm.org/D101630

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


[PATCH] D101735: [WebAssembly] Reenable end-to-end test in wasm-eh.cpp

2021-05-03 Thread Thomas Lively via Phabricator via cfe-commits
tlively accepted this revision.
tlively added a comment.
This revision is now accepted and ready to land.

This is hopefully less controversial because the test already exists and this 
is just re-enabling it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101735

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


[clang] a27ca15 - [OpenMP] Fix non-determinism in clang task codegen

2021-05-03 Thread Giorgis Georgakoudis via cfe-commits

Author: Giorgis Georgakoudis
Date: 2021-05-03T10:34:38-07:00
New Revision: a27ca15dd08342b199e2feb5ae896475fd90a518

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

LOG: [OpenMP] Fix non-determinism in clang task codegen

Reviewed By: jdoerfert

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

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGOpenMPRuntime.h
clang/lib/CodeGen/CGStmtOpenMP.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index fce6efe9fee0..1980c5c91af2 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -12107,8 +12107,8 @@ 
CGOpenMPRuntime::NontemporalDeclsRAII::~NontemporalDeclsRAII() {
 
 CGOpenMPRuntime::UntiedTaskLocalDeclsRAII::UntiedTaskLocalDeclsRAII(
 CodeGenFunction &CGF,
-const llvm::DenseMap,
- std::pair> &LocalVars)
+const llvm::MapVector,
+  std::pair> &LocalVars)
 : CGM(CGF.CGM), NeedToPush(!LocalVars.empty()) {
   if (!NeedToPush)
 return;

diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.h 
b/clang/lib/CodeGen/CGOpenMPRuntime.h
index 7be9c3b1da22..5155370f46cf 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.h
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.h
@@ -253,8 +253,8 @@ class CGOpenMPRuntime {
   public:
 UntiedTaskLocalDeclsRAII(
 CodeGenFunction &CGF,
-const llvm::DenseMap,
- std::pair> &LocalVars);
+const llvm::MapVector,
+  std::pair> &LocalVars);
 ~UntiedTaskLocalDeclsRAII();
   };
 
@@ -723,8 +723,8 @@ class CGOpenMPRuntime {
   llvm::SmallVector NontemporalDeclsStack;
 
   using UntiedLocalVarsAddressesMap =
-  llvm::DenseMap,
- std::pair>;
+  llvm::MapVector,
+  std::pair>;
   llvm::SmallVector UntiedLocalVarsStack;
 
   /// Stack for list of addresses of declarations in current context marked as

diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 83d3dd0fc813..e7ddc0aa4c8d 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -4339,7 +4339,8 @@ void CodeGenFunction::EmitOMPTaskBasedDirective(
   auto &&CodeGen = [&Data, &S, CS, &BodyGen, &LastprivateDstsOrigs,
 CapturedRegion](CodeGenFunction &CGF,
 PrePostActionTy &Action) {
-llvm::DenseMap, std::pair>
+llvm::MapVector,
+std::pair>
 UntiedLocalVars;
 // Set proper addresses for generated private copies.
 OMPPrivateScope Scope(CGF);
@@ -4392,7 +4393,12 @@ void CodeGenFunction::EmitOMPTaskBasedDirective(
   Ty = CGF.getContext().getPointerType(Ty);
 Address PrivatePtr = CGF.CreateMemTemp(
 CGF.getContext().getPointerType(Ty), ".local.ptr.addr");
-UntiedLocalVars.try_emplace(VD, PrivatePtr, Address::invalid());
+auto Result = UntiedLocalVars.insert(
+std::make_pair(VD, std::make_pair(PrivatePtr, 
Address::invalid(;
+// If key exists update in place.
+if (Result.second == false)
+  *Result.first = std::make_pair(
+  VD, std::make_pair(PrivatePtr, Address::invalid()));
 CallArgs.push_back(PrivatePtr.getPointer());
 ParamTypes.push_back(PrivatePtr.getType());
   }
@@ -4424,14 +4430,14 @@ void CodeGenFunction::EmitOMPTaskBasedDirective(
 if (isAllocatableDecl(Pair.first)) {
   llvm::Value *Ptr = CGF.Builder.CreateLoad(Pair.second.first);
   Address Replacement(Ptr, CGF.getPointerAlign());
-  Pair.getSecond().first = Replacement;
+  Pair.second.first = Replacement;
   Ptr = CGF.Builder.CreateLoad(Replacement);
   Replacement = Address(Ptr, 
CGF.getContext().getDeclAlign(Pair.first));
-  Pair.getSecond().second = Replacement;
+  Pair.second.second = Replacement;
 } else {
   llvm::Value *Ptr = CGF.Builder.CreateLoad(Pair.second.first);
   Address Replacement(Ptr, CGF.getContext().getDeclAlign(Pair.first));
-  Pair.getSecond().first = Replacement;
+  Pair.second.first = Replacement;
 }
   }
 }



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


[PATCH] D101739: [OpenMP] Fix non-determinism in clang task codegen

2021-05-03 Thread Giorgis Georgakoudis via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa27ca15dd083: [OpenMP] Fix non-determinism in clang task 
codegen (authored by ggeorgakoudis).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101739

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGStmtOpenMP.cpp


Index: clang/lib/CodeGen/CGStmtOpenMP.cpp
===
--- clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -4339,7 +4339,8 @@
   auto &&CodeGen = [&Data, &S, CS, &BodyGen, &LastprivateDstsOrigs,
 CapturedRegion](CodeGenFunction &CGF,
 PrePostActionTy &Action) {
-llvm::DenseMap, std::pair>
+llvm::MapVector,
+std::pair>
 UntiedLocalVars;
 // Set proper addresses for generated private copies.
 OMPPrivateScope Scope(CGF);
@@ -4392,7 +4393,12 @@
   Ty = CGF.getContext().getPointerType(Ty);
 Address PrivatePtr = CGF.CreateMemTemp(
 CGF.getContext().getPointerType(Ty), ".local.ptr.addr");
-UntiedLocalVars.try_emplace(VD, PrivatePtr, Address::invalid());
+auto Result = UntiedLocalVars.insert(
+std::make_pair(VD, std::make_pair(PrivatePtr, 
Address::invalid(;
+// If key exists update in place.
+if (Result.second == false)
+  *Result.first = std::make_pair(
+  VD, std::make_pair(PrivatePtr, Address::invalid()));
 CallArgs.push_back(PrivatePtr.getPointer());
 ParamTypes.push_back(PrivatePtr.getType());
   }
@@ -4424,14 +4430,14 @@
 if (isAllocatableDecl(Pair.first)) {
   llvm::Value *Ptr = CGF.Builder.CreateLoad(Pair.second.first);
   Address Replacement(Ptr, CGF.getPointerAlign());
-  Pair.getSecond().first = Replacement;
+  Pair.second.first = Replacement;
   Ptr = CGF.Builder.CreateLoad(Replacement);
   Replacement = Address(Ptr, 
CGF.getContext().getDeclAlign(Pair.first));
-  Pair.getSecond().second = Replacement;
+  Pair.second.second = Replacement;
 } else {
   llvm::Value *Ptr = CGF.Builder.CreateLoad(Pair.second.first);
   Address Replacement(Ptr, CGF.getContext().getDeclAlign(Pair.first));
-  Pair.getSecond().first = Replacement;
+  Pair.second.first = Replacement;
 }
   }
 }
Index: clang/lib/CodeGen/CGOpenMPRuntime.h
===
--- clang/lib/CodeGen/CGOpenMPRuntime.h
+++ clang/lib/CodeGen/CGOpenMPRuntime.h
@@ -253,8 +253,8 @@
   public:
 UntiedTaskLocalDeclsRAII(
 CodeGenFunction &CGF,
-const llvm::DenseMap,
- std::pair> &LocalVars);
+const llvm::MapVector,
+  std::pair> &LocalVars);
 ~UntiedTaskLocalDeclsRAII();
   };
 
@@ -723,8 +723,8 @@
   llvm::SmallVector NontemporalDeclsStack;
 
   using UntiedLocalVarsAddressesMap =
-  llvm::DenseMap,
- std::pair>;
+  llvm::MapVector,
+  std::pair>;
   llvm::SmallVector UntiedLocalVarsStack;
 
   /// Stack for list of addresses of declarations in current context marked as
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -12107,8 +12107,8 @@
 
 CGOpenMPRuntime::UntiedTaskLocalDeclsRAII::UntiedTaskLocalDeclsRAII(
 CodeGenFunction &CGF,
-const llvm::DenseMap,
- std::pair> &LocalVars)
+const llvm::MapVector,
+  std::pair> &LocalVars)
 : CGM(CGF.CGM), NeedToPush(!LocalVars.empty()) {
   if (!NeedToPush)
 return;


Index: clang/lib/CodeGen/CGStmtOpenMP.cpp
===
--- clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -4339,7 +4339,8 @@
   auto &&CodeGen = [&Data, &S, CS, &BodyGen, &LastprivateDstsOrigs,
 CapturedRegion](CodeGenFunction &CGF,
 PrePostActionTy &Action) {
-llvm::DenseMap, std::pair>
+llvm::MapVector,
+std::pair>
 UntiedLocalVars;
 // Set proper addresses for generated private copies.
 OMPPrivateScope Scope(CGF);
@@ -4392,7 +4393,12 @@
   Ty = CGF.getContext().getPointerType(Ty);
 Address PrivatePtr = CGF.CreateMemTemp(
 CGF.getContext().getPointerType(Ty), ".local.ptr.addr");
-UntiedLocalVars.try_emplace(VD, PrivatePtr, Address::invalid());
+auto Result = UntiedLocalVars.insert(
+std::make_pair(VD, std::make_pair(PrivatePtr, Address::invalid(;
+   

[PATCH] D100620: [OpenMP] Make sure classes work on the device as they do on the host

2021-05-03 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

In D100620#2733708 , @jdoerfert wrote:

> For that I need to replicate the potentially conflicting `` stuff in the 
> test header mockups. I'll try it later on one system though.

Yep, may not be able to check in something that pulls  out of the host 
system.

It seems inconvenient that clang doesn't automatically inject the new/delete 
forms that are intended to be available without including new.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100620

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


[PATCH] D100934: [clang][modules] Build inferred modules

2021-05-03 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

Given that there are four different things being done in this commit, it sounds 
naively like it should be four separate commits. If the logic is too 
intertwined to land each of the four pieces separately (certainly possible), 
can you quickly explain why, to motivate landing them together? (Or maybe 
there's an NFC refactoring that could be separated as a prep, to make the 
functional changes more isolated / easy to reason about?)

Either way, please split the testing between clang's ability to build inferred 
modules (clang/test/Modules) and clang-scan-deps ability to find them 
(clang/test/ClangScanDeps).




Comment at: clang/test/ClangScanDeps/modules-inferred-explicit-build.m:10-12
+// RUN: %S/module-deps-to-rsp.py %t.db --module-name=Inferred > %t.inferred.rsp
+// RUN: %S/module-deps-to-rsp.py %t.db --module-name=System > %t.system.rsp
+// RUN: %S/module-deps-to-rsp.py %t.db --tu-index=0 > %t.tu.rsp

I took me a while to figure out that `.rsp` and `-to-rsp` means "response 
file". Can we just use `response` (or even `response-file`?) in both cases, or 
is `.rsp` a well-known extension I'm just not aware of?

I'm also not sure we want to use this in a test (see my next comment). If it's 
a useful utility regardless perhaps it could have a home in clang/utils.



Comment at: clang/test/ClangScanDeps/modules-inferred-explicit-build.m:13-17
+// RUN: %clang @%t.inferred.rsp -pedantic -Werror
+// RUN: %clang @%t.system.rsp -pedantic -Werror
+// RUN: %clang -x objective-c -fsyntax-only %t.dir/modules_cdb_input.cpp \
+// RUN:   -F%S/Inputs/frameworks -fmodules -fimplicit-module-maps \
+// RUN:   -pedantic -Werror @%t.tu.rsp

I feel like the clang invocations that build/use modules should be in 
`clang/test/Modules`. Two independent things:
- Can clang build inferred modules explicitly? (tested in clang/test/Modules)
- Can clang-scan-deps generate deps for inferred modules? (tested in 
clang/test/ClangScanDeps)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100934

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


[PATCH] D101763: [analyzer][ctu] Avoid parsing invocation list again and again during on-demand parsing of CTU

2021-05-03 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

Awesome! Seems good to me. Though I've got limited experience on CTU stuff.
It would be nice to have tests, but it seems pretty hard to come up with one 
for this. Given that this is just a 'performance' issue, I'm fine with it.
Somehow try to check if this resolved your original concern.




Comment at: clang/include/clang/CrossTU/CrossTranslationUnit.h:41
 enum class index_error_code {
+  no_error = 0,
   unspecified = 1,

What about `success`?
That way it would resonate well with the return's `success()`;



Comment at: clang/lib/CrossTU/CrossTranslationUnit.cpp:691
+ExpectedInvocationList.takeError(),
+[&](IndexError &E) { InvocationListParsingError = E.getCode(); });
+return llvm::make_error(InvocationListParsingError);

Shouldn't be small enough to pass-by-value?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101763

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


[PATCH] D99543: [clang-tidy] Allow opt-in or out of some commonly occuring patterns in NarrowingConversionsCheck.

2021-05-03 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-narrowing-conversions-ignoreconversionfromtypes-option.cpp:12
+
+typedef long long size_t;
+

This is breaking tests on windows, It seems like its pre-defined to be 
`unsigned long long` on windows.
Simplest fix is to rename size_t to something else.
I guess changing the typedef to `unsigned long long` will change behaviour of 
tests.
Failing that an `// UNSUPPORTED: system-windows` directive at the top of the 
file would also work.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99543

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


[clang] 64a390c - Modules: Remove an extra early return, NFC

2021-05-03 Thread Duncan P. N. Exon Smith via cfe-commits

Author: Duncan P. N. Exon Smith
Date: 2021-05-03T10:50:09-07:00
New Revision: 64a390c1bc75eb55eeed3061df15dc581fd563e6

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

LOG: Modules: Remove an extra early return, NFC

Remove an early return from an `else` block that's immediately followed
by an equivalent early return after the `else` block.

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

Added: 


Modified: 
clang/lib/Frontend/CompilerInstance.cpp

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInstance.cpp 
b/clang/lib/Frontend/CompilerInstance.cpp
index 4a765b9203cc7..bcf9f9694f885 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -1890,8 +1890,6 @@ CompilerInstance::loadModule(SourceLocation ImportLoc,
   return Result;
 Module = Result;
 MM.cacheModuleLoad(*Path[0].first, Module);
-if (!Module)
-  return Module;
   }
 
   // If we never found the module, fail.  Otherwise, verify the module and link



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


[PATCH] D101645: [clang] RecursiveASTVisitor visits ObjCPropertyRefExpr's class receiver

2021-05-03 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir added a subscriber: akyrtzi.
benlangmuir added inline comments.



Comment at: clang/test/Index/Core/index-source.m:410
 // CHECK-NEXT: RelCont | classReceivers | c:@F@classReceivers
+// CHECK: [[@LINE-3]]:3 | class/ObjC | ClassReceivers | 
c:objc(cs)ClassReceivers | _OBJC_CLASS_$_ClassReceivers | Ref,RelCont | rel: 1
 // CHECK: [[@LINE-4]]:18 | class-method/acc-set/ObjC | setP1: | 
c:objc(cs)ClassReceivers(cm)setP1: | +[ClassReceivers setP1:] | 
Ref,Call,Impl,RelCall,RelCont | rel: 1

Is it okay that this is being visited out of source order now?  CC @akyrtzi


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101645

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


  1   2   3   >