[PATCH] D98214: [clang-format] Fix aligning with linebreaks

2021-03-09 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius requested changes to this revision.
curdeius added a comment.
This revision now requires changes to proceed.

This looks really good. Just a few rather minor remarks.




Comment at: clang/lib/Format/WhitespaceManager.cpp:280-281
   // In the above example, we need to take special care to ensure that
-  // 'double z' is indented along with it's owning function 'b'.
+  // 'double z' is indented along with it's owning function 'b'. The same holds
+  // for calling a function:
+  //   double a = foo(x);

Nit: I'd break the line before the new phrase.



Comment at: clang/lib/Format/WhitespaceManager.cpp:332-340
   if (Changes[ScopeStart - 1].Tok->is(TT_FunctionDeclarationName) ||
   (ScopeStart > Start + 1 &&
Changes[ScopeStart - 2].Tok->is(TT_FunctionDeclarationName)) ||
+  (ScopeStart > Start + 1 &&
+   Changes[ScopeStart - 2].Tok->is(tok::identifier) &&
+   Changes[ScopeStart - 1].Tok->is(tok::l_paren)) ||
   Changes[i].Tok->is(TT_ConditionalExpr) ||

Would it be possible to break up this condition and name it (or name its 
parts)? It's getting hard to follow.
Suggestion according to my understanding, which might be wrong.



Comment at: clang/unittests/Format/FormatTest.cpp:14305-14311
+  verifyFormat("void foo() {\n"
+   "  int myVar = 5;\n"
+   "  double x = 3.14;\n"
+   "  auto str = \"Hello \"\n"
+   " \"World\";\n"
+   "}",
+   Style);

Nice tests. I'd like to see however the behaviour when there's another 
assignment/declaration after a multi-line string, maybe even mixing multi-line 
strings and multi-line function calls. You already do test multiple multi-line 
function calls (with `newEntry` and `newEntry2`).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98214

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


[clang] 587859d - clang-format: use `pb` as a canonical raw string delimiter for google style

2021-03-09 Thread Krasimir Georgiev via cfe-commits

Author: Krasimir Georgiev
Date: 2021-03-09T09:07:14+01:00
New Revision: 587859d977e88648bee1888dce5175ef827f212e

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

LOG: clang-format: use `pb` as a canonical raw string delimiter for google style

This updates the canonical text proto raw string delimiter to `pb` for Google 
style, moving codebases towards a simpler and more consistent style.

Also updates a behavior where the canonical delimiter was not applied for raw 
strings with empty delimiters detected via well-known enclosing functions that 
expect a text proto, effectively making the canonical delimiter more viral. 
This feature is not widely used so this should be safe and more in line with 
promoting the canonicity of the canonical delimiter.

Reviewed By: sammccall

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

Added: 


Modified: 
clang/lib/Format/ContinuationIndenter.cpp
clang/lib/Format/Format.cpp
clang/unittests/Format/FormatTestRawStrings.cpp

Removed: 




diff  --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index ffb328f7de13..cbf016f4b166 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -1651,7 +1651,7 @@ unsigned ContinuationIndenter::reformatRawStringLiteral(
   StringRef OldDelimiter = *getRawStringDelimiter(Current.TokenText);
   StringRef NewDelimiter =
   getCanonicalRawStringDelimiter(Style, RawStringStyle.Language);
-  if (NewDelimiter.empty() || OldDelimiter.empty())
+  if (NewDelimiter.empty())
 NewDelimiter = OldDelimiter;
   // The text of a raw string is between the leading 'R"delimiter(' and the
   // trailing 'delimiter)"'.

diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 674f3e1220f7..120202caa3cd 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1137,7 +1137,7 @@ FormatStyle getGoogleStyle(FormatStyle::LanguageKind 
Language) {
   "ParseTestProto",
   "ParsePartialTestProto",
   },
-  /*CanonicalDelimiter=*/"",
+  /*CanonicalDelimiter=*/"pb",
   /*BasedOnStyle=*/"google",
   },
   };

diff  --git a/clang/unittests/Format/FormatTestRawStrings.cpp 
b/clang/unittests/Format/FormatTestRawStrings.cpp
index 6310fe510fd3..6f9a0d650ba2 100644
--- a/clang/unittests/Format/FormatTestRawStrings.cpp
+++ b/clang/unittests/Format/FormatTestRawStrings.cpp
@@ -782,11 +782,16 @@ a = ParseTextProto(R"(key:value)");)test",
 }
 
 TEST_F(FormatTestRawStrings, UpdatesToCanonicalDelimiters) {
-  FormatStyle Style = getRawStringPbStyleWithColumns(25);
+  FormatStyle Style = getRawStringPbStyleWithColumns(35);
   Style.RawStringFormats[0].CanonicalDelimiter = "proto";
+  Style.RawStringFormats[0].EnclosingFunctions.push_back("PARSE_TEXT_PROTO");
+
   expect_eq(R"test(a = R"proto(key: value)proto";)test",
 format(R"test(a = R"pb(key:value)pb";)test", Style));
 
+  expect_eq(R"test(PARSE_TEXT_PROTO(R"proto(key: value)proto");)test",
+format(R"test(PARSE_TEXT_PROTO(R"(key:value)");)test", Style));
+
   // Don't update to canonical delimiter if it occurs as a raw string suffix in
   // the raw string content.
   expect_eq(R"test(a = R"pb(key: ")proto")pb";)test",



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


[PATCH] D97688: clang-format: use `pb` as a canonical raw string delimiter for google style

2021-03-09 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG587859d977e8: clang-format: use `pb` as a canonical raw 
string delimiter for google style (authored by krasimir).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97688

Files:
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/Format.cpp
  clang/unittests/Format/FormatTestRawStrings.cpp


Index: clang/unittests/Format/FormatTestRawStrings.cpp
===
--- clang/unittests/Format/FormatTestRawStrings.cpp
+++ clang/unittests/Format/FormatTestRawStrings.cpp
@@ -782,11 +782,16 @@
 }
 
 TEST_F(FormatTestRawStrings, UpdatesToCanonicalDelimiters) {
-  FormatStyle Style = getRawStringPbStyleWithColumns(25);
+  FormatStyle Style = getRawStringPbStyleWithColumns(35);
   Style.RawStringFormats[0].CanonicalDelimiter = "proto";
+  Style.RawStringFormats[0].EnclosingFunctions.push_back("PARSE_TEXT_PROTO");
+
   expect_eq(R"test(a = R"proto(key: value)proto";)test",
 format(R"test(a = R"pb(key:value)pb";)test", Style));
 
+  expect_eq(R"test(PARSE_TEXT_PROTO(R"proto(key: value)proto");)test",
+format(R"test(PARSE_TEXT_PROTO(R"(key:value)");)test", Style));
+
   // Don't update to canonical delimiter if it occurs as a raw string suffix in
   // the raw string content.
   expect_eq(R"test(a = R"pb(key: ")proto")pb";)test",
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -1137,7 +1137,7 @@
   "ParseTestProto",
   "ParsePartialTestProto",
   },
-  /*CanonicalDelimiter=*/"",
+  /*CanonicalDelimiter=*/"pb",
   /*BasedOnStyle=*/"google",
   },
   };
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -1651,7 +1651,7 @@
   StringRef OldDelimiter = *getRawStringDelimiter(Current.TokenText);
   StringRef NewDelimiter =
   getCanonicalRawStringDelimiter(Style, RawStringStyle.Language);
-  if (NewDelimiter.empty() || OldDelimiter.empty())
+  if (NewDelimiter.empty())
 NewDelimiter = OldDelimiter;
   // The text of a raw string is between the leading 'R"delimiter(' and the
   // trailing 'delimiter)"'.


Index: clang/unittests/Format/FormatTestRawStrings.cpp
===
--- clang/unittests/Format/FormatTestRawStrings.cpp
+++ clang/unittests/Format/FormatTestRawStrings.cpp
@@ -782,11 +782,16 @@
 }
 
 TEST_F(FormatTestRawStrings, UpdatesToCanonicalDelimiters) {
-  FormatStyle Style = getRawStringPbStyleWithColumns(25);
+  FormatStyle Style = getRawStringPbStyleWithColumns(35);
   Style.RawStringFormats[0].CanonicalDelimiter = "proto";
+  Style.RawStringFormats[0].EnclosingFunctions.push_back("PARSE_TEXT_PROTO");
+
   expect_eq(R"test(a = R"proto(key: value)proto";)test",
 format(R"test(a = R"pb(key:value)pb";)test", Style));
 
+  expect_eq(R"test(PARSE_TEXT_PROTO(R"proto(key: value)proto");)test",
+format(R"test(PARSE_TEXT_PROTO(R"(key:value)");)test", Style));
+
   // Don't update to canonical delimiter if it occurs as a raw string suffix in
   // the raw string content.
   expect_eq(R"test(a = R"pb(key: ")proto")pb";)test",
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -1137,7 +1137,7 @@
   "ParseTestProto",
   "ParsePartialTestProto",
   },
-  /*CanonicalDelimiter=*/"",
+  /*CanonicalDelimiter=*/"pb",
   /*BasedOnStyle=*/"google",
   },
   };
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -1651,7 +1651,7 @@
   StringRef OldDelimiter = *getRawStringDelimiter(Current.TokenText);
   StringRef NewDelimiter =
   getCanonicalRawStringDelimiter(Style, RawStringStyle.Language);
-  if (NewDelimiter.empty() || OldDelimiter.empty())
+  if (NewDelimiter.empty())
 NewDelimiter = OldDelimiter;
   // The text of a raw string is between the leading 'R"delimiter(' and the
   // trailing 'delimiter)"'.
___
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-03-09 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD added a comment.

In D97183#2598806 , @NoQ wrote:

> We could, for instance, teach it to mark //exploded nodes// as interesting 
> when it changes tracking mode.

@NoQ, what is tracking mode for an `ExplodedNode`?


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] D89942: Disable LTO and LLD for bootstrap builds on systems unsupported by LLD

2021-03-09 Thread serge via Phabricator via cfe-commits
serge-sans-paille accepted this revision.
serge-sans-paille added a comment.
This revision is now accepted and ready to land.

@tbaeder sorry for the delay. I don't see any reason why we should keep that 
one in review any longer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89942

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


[PATCH] D95043: [clangd] Use Dirty Filesystem for cross file rename.

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

This looks pretty good, great cleanup!




Comment at: clang-tools-extra/clangd/ClangdServer.cpp:408
+clangd::rename({Pos, NewName.getValueOr("__clangd_rename_dummy"),
+InpAST->AST, File, TFS.view(llvm::None),
+/*Index=*/nullptr, RenameOpts});

we shouldn't need to pass a nontrivial FS in here, right?



Comment at: clang-tools-extra/clangd/refactor/Rename.h:40
 
+  // The filesystem to query when performing cross file renames.
+  llvm::IntrusiveRefCntPtr FS;

Index + FS are both only used for cross-file renames at this point.

(We used to support a single-file rename mode where the index was used to 
validate that the symbol wasn't used elsewhere, but that's gone now)

I think we should document this, and assert that they're either both set 
(cross-file) or neither is.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95043

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


[PATCH] D97850: Fix PCM read from ModuleCache for ext4 filesystem

2021-03-09 Thread Robert Widmann via Phabricator via cfe-commits
CodaFi added a comment.

I believe removing inode numbers is the correct fix, yes. The workaround I 
applied, and the one here, are both insufficient in the general case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97850

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


[PATCH] D96033: [clang-repl] Land initial infrastructure for incremental parsing

2021-03-09 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev updated this revision to Diff 329234.
v.g.vassilev added a comment.

- Do not rely on process exit code for `--host-supports-jit` but parse the 
true/false flag.

- Move the `IncrementalProcessingTest` unittest from unittests/CodeGen to 
unittests/Interpreter.


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

https://reviews.llvm.org/D96033

Files:
  clang/include/clang/CodeGen/CodeGenAction.h
  clang/include/clang/Frontend/FrontendAction.h
  clang/include/clang/Interpreter/Interpreter.h
  clang/include/clang/Interpreter/Transaction.h
  clang/lib/CMakeLists.txt
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/Frontend/FrontendAction.cpp
  clang/lib/Interpreter/CMakeLists.txt
  clang/lib/Interpreter/IncrementalExecutor.cpp
  clang/lib/Interpreter/IncrementalExecutor.h
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/lib/Interpreter/IncrementalParser.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/test/CMakeLists.txt
  clang/test/Interpreter/execute.c
  clang/test/Interpreter/sanity.c
  clang/test/lit.cfg.py
  clang/tools/CMakeLists.txt
  clang/tools/clang-repl/CMakeLists.txt
  clang/tools/clang-repl/ClangRepl.cpp
  clang/unittests/CMakeLists.txt
  clang/unittests/CodeGen/CMakeLists.txt
  clang/unittests/CodeGen/IncrementalProcessingTest.cpp
  clang/unittests/Interpreter/CMakeLists.txt
  clang/unittests/Interpreter/IncrementalProcessingTest.cpp
  clang/unittests/Interpreter/InterpreterTest.cpp

Index: clang/unittests/Interpreter/InterpreterTest.cpp
===
--- /dev/null
+++ clang/unittests/Interpreter/InterpreterTest.cpp
@@ -0,0 +1,92 @@
+//===- unittests/Interpreter/InterpreterTest.cpp --- Interpreter tests ===//
+//
+// 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
+//
+//===--===//
+//
+// Unit tests for Clang's Interpreter library.
+//
+//===--===//
+
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclGroup.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Interpreter/Interpreter.h"
+
+#include "llvm/ADT/ArrayRef.h"
+
+#include "gtest/gtest.h"
+
+using namespace clang;
+
+namespace {
+
+static std::unique_ptr createInterpreter() {
+  std::vector ClangArgs = {"-Xclang", "-emit-llvm-only"};
+  auto CI = cantFail(clang::IncrementalCompilerBuilder::create(ClangArgs));
+  return cantFail(clang::Interpreter::create(std::move(CI)));
+}
+
+TEST(InterpreterTest, Sanity) {
+  std::unique_ptr Interp = createInterpreter();
+  Transaction &R1(cantFail(Interp->Parse("void g(); void g() {}")));
+  EXPECT_EQ(2U, R1.Decls.size());
+
+  Transaction &R2(cantFail(Interp->Parse("int i;")));
+  EXPECT_EQ(1U, R2.Decls.size());
+}
+
+static std::string DeclToString(DeclGroupRef DGR) {
+  return llvm::cast(DGR.getSingleDecl())->getQualifiedNameAsString();
+}
+
+TEST(InterpreterTest, IncrementalInputTopLevelDecls) {
+  std::unique_ptr Interp = createInterpreter();
+  auto R1OrErr = Interp->Parse("int var1 = 42; int f() { return var1; }");
+  // gtest doesn't expand into explicit bool conversions.
+  EXPECT_TRUE(!!R1OrErr);
+  auto R1 = R1OrErr->Decls;
+  EXPECT_EQ(2U, R1.size());
+  EXPECT_EQ("var1", DeclToString(R1[0]));
+  EXPECT_EQ("f", DeclToString(R1[1]));
+
+  auto R2OrErr = Interp->Parse("int var2 = f();");
+  EXPECT_TRUE(!!R2OrErr);
+  auto R2 = R2OrErr->Decls;
+  EXPECT_EQ(1U, R2.size());
+  EXPECT_EQ("var2", DeclToString(R2[0]));
+}
+
+
+TEST(InterpreterTest, Errors) {
+  std::unique_ptr Interp = createInterpreter();
+  auto Err = Interp->Parse("intentional_error v1 = 42; ").takeError();
+  EXPECT_EQ("Parsing failed.", llvm::toString(std::move(Err)));
+
+  EXPECT_DEATH((void)Interp->Parse("int var1 = 42;"), "");
+}
+
+// Here we test whether the user can mix declarations and statements. The
+// interpreter should be smart enough to recognize the declarations from the
+// statements and wrap the latter into a declaration, producing valid code.
+TEST(InterpreterTest, DeclsAndStatements) {
+  std::unique_ptr Interp = createInterpreter();
+  auto R1OrErr = Interp->Parse(
+  "int var1 = 42; extern \"C\" int printf(const char*, ...);");
+  // gtest doesn't expand into explicit bool conversions.
+  EXPECT_TRUE(!!R1OrErr);
+
+  auto R1 = R1OrErr->Decls;
+  EXPECT_EQ(2U, R1.size());
+
+  // FIXME: Add support for wrapping and running statements.
+  auto R2OrErr =
+Interp->Parse("var1++; printf(\"var1 value is %d\\n\", var1);");
+  EXPECT_FALSE(!!R2OrErr);
+  auto Err = R2OrErr.takeError();
+  EXPECT_EQ("Parsing failed.", llvm::toString(std::move(Err)));
+}
+
+} // end anonymous namespace
Index: clang/unittests/Interpreter/IncrementalProcessingTest.cpp
==

[PATCH] D97388: [analyzer] Replace StoreManager::evalIntegralCast with SValBuilder::evalCast

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

All reports and crashes are preserved at this point of the patch stack - with 
or without z3 crosscheck on multiple projects - even on llvm.


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

https://reviews.llvm.org/D97388

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


[PATCH] D97388: [analyzer] Replace StoreManager::evalIntegralCast with SValBuilder::evalCast

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

If @NoQ doesn't have any objections I'm ok with this change.


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

https://reviews.llvm.org/D97388

___
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-03-09 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 329242.
serge-sans-paille added a comment.

Patch rebased on main.


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

https://reviews.llvm.org/D93095

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Decl.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/Sema/reserved-identifier.c
  clang/test/Sema/reserved-identifier.cpp

Index: clang/test/Sema/reserved-identifier.cpp
===
--- /dev/null
+++ clang/test/Sema/reserved-identifier.cpp
@@ -0,0 +1,82 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++20 -verify -Wreserved-identifier %s
+
+int foo__bar() { return 0; }// expected-warning {{'foo__bar' is a reserved identifier}}
+static int _bar() { return 0; } // expected-warning {{'_bar' is a reserved identifier}}
+static int _Bar() { return 0; } // expected-warning {{'_Bar' is a reserved identifier}}
+int _barbouille() { return 0; } // expected-warning {{'_barbouille' is a reserved identifier}}
+
+void foo(unsigned int _Reserved) { // expected-warning {{'_Reserved' is a reserved identifier}}
+  unsigned int __1 =   // expected-warning {{'__1' is a reserved identifier}}
+  _Reserved;   // no-warning
+}
+
+// This one is explicitly skipped by -Wreserved-identifier
+void *_; // no-warning
+
+template  constexpr bool __toucan = true; // expected-warning {{'__toucan' is a reserved identifier}}
+
+template 
+concept _Barbotine = __toucan; // expected-warning {{'_Barbotine' is a reserved identifier}}
+
+template  // expected-warning {{'__' is a reserved identifier}}
+struct BarbeNoire {};
+
+template  // expected-warning {{'__' is a reserved identifier}}
+void BarbeRousse() {}
+
+namespace _Barbidur { // expected-warning {{'_Barbidur' is a reserved identifier}}
+
+struct __barbidou {}; // expected-warning {{'__barbidou' is a reserved identifier}}
+struct _barbidou {};  // no-warning
+
+int __barbouille; // expected-warning {{'__barbouille' is a reserved identifier}}
+int _barbouille;  // no-warning
+
+int __babar() { return 0; } // expected-warning {{'__babar' is a reserved identifier}}
+int _babar() { return 0; }  // no-warning
+
+} // namespace _Barbidur
+
+class __barbapapa { // expected-warning {{'__barbapapa' is a reserved identifier}}
+  void _barbabelle() {} // no-warning
+  int _Barbalala;   // expected-warning {{'_Barbalala' is a reserved identifier}}
+};
+
+enum class __menu { // expected-warning {{'__menu' is a reserved identifier}}
+  __some,   // expected-warning {{'__some' is a reserved identifier}}
+  _Other,   // expected-warning {{'_Other' is a reserved identifier}}
+  _other// no-warning
+};
+
+enum _Menu { // expected-warning {{'_Menu' is a reserved identifier}}
+  _OtheR_,   // expected-warning {{'_OtheR_' is a reserved identifier}}
+  _other_// expected-warning {{'_other_' is a reserved identifier}}
+};
+
+enum {
+  __some, // expected-warning {{'__some' is a reserved identifier}}
+  _Other, // expected-warning {{'_Other' is a reserved identifier}}
+  _other  // expected-warning {{'_other' is a reserved identifier}}
+};
+
+static union {
+  int _barbeFleurie; // no-warning
+};
+
+using _Barbamama = __barbapapa; // expected-warning {{'_Barbamama' is a reserved identifier}}
+
+int foobar() {
+  return foo__bar(); // no-warning
+}
+
+namespace {
+int _barbatruc; // no-warning
+}
+
+long double operator"" _BarbeBleue(long double) // no-warning
+{
+  return 0.;
+}
+
+struct _BarbeRouge {} p; // expected-warning {{'_BarbeRouge' is a reserved identifier}}
+struct _BarbeNoire {}* q; // expected-warning {{'_BarbeNoire' is a reserved identifier}}
Index: clang/test/Sema/reserved-identifier.c
===
--- /dev/null
+++ clang/test/Sema/reserved-identifier.c
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wreserved-identifier -Wno-visibility %s
+
+#define __oof foo__ // expected-warning {{macro name is a reserved identifier}}
+
+int foo__bar() { return 0; }// no-warning
+static int _bar() { return 0; } // expected-warning {{'_bar' is a reserved identifier}}
+static int _Bar() { return 0; } // expected-warning {{'_Bar' is a reserved identifier}}
+int _foo() { return 0; }// expected-warning {{'_foo' is a reserved identifier}}
+
+// This one is explicitly skipped by -Wreserved-identifier
+void *_; // no-warning
+
+void foo(unsigned int _Reserved) { // expected-warning {{'_Reserved' is a reserved identifier}}
+  unsigned int __1 =   // expected-warning {{'__1' is a reserved identifier}}
+  _Reserved;   // no-warning
+  goto __reserved;
+__reserved: // expected-warning {{'__reserve

[PATCH] D97563: [clang-tidy] Enable modernize-concat-nested-namespaces also on headers

2021-03-09 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin added a comment.

@aaron.ballman @alexfh @njames93 - friendly ping, please take a look!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97563

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


[PATCH] D95799: [analyzer] Symbolicate float values with integral casting

2021-03-09 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

@NoQ wrote:

> IIUC this is roughly the first time ever when `SValBuilder` starts emitting 
> symbols of float type. This is a huge change with an almost unlimited scope 
> of unexpected side effects and very rigorous testing is required to 
> understand the actual effect of this patch on programs that use floats. I 
> think that generally some symbols are always better than no symbols, even if 
> the constraint manager is completely unable to handle them. But we have to 
> make sure that the entirety of `SValBuilder` and the entirety of 
> `RegionStore` (and possibly the entirety of `ExprEngine`) are ready to deal 
> with completely new kinds of values that they've never seen before.

I kind of abandoned this patch. I realized that too much circumstances appeared 
that I am not an expert in. It is more like an experimental patch which serves 
to make clear some information, start discussion of what another people know 
about handling floats. Thank you for your sharing. Now I see what potential 
problems could be. I'm going to proceed as soon as I'm feel more confident 
answering this questions.




Comment at: clang/test/Analysis/svalbuilder-float-cast.c:11
   *p += 1;
-  // This should NOT be (float)$x + 1. Symbol $x was never casted to float.
-  // FIXME: Ideally, this should be $x + 1.

NoQ wrote:
> You silently ignored and removed this comment. The author of the original 
> code was pretty certain that your solution is incorrect and most likely added 
> this comment there specifically to make sure your solution doesn't get 
> implemented.
> 
> If you see potential problems with your patch, please don't try to sweep them 
> under the rug. If you're sure your solution is correct, please explain why. 
> If not, please ask about it in the summary or in the comments.
> 
> Generally, every commit should be obvious. If there are obvious questions 
> that remain unanswered then the commit is not obvious and needs improvement.
Very good objection! Sorry, honestly I somehow missed that it `should NOT`. Of 
course we should have strong arguments introducing the opposite effect. This is 
my mistake.


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

https://reviews.llvm.org/D95799

___
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-03-09 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD added a comment.

I am trying to use scan-build on a file to see what sort of errors are reported:
`./llvm-project/release/bin/scan-build -o . -enable-checker 
alpha.cplusplus.SmartPtr -analyzer-config 
alpha.cplusplus.SmartPtrModelling:ModelSmartPtrDereference=true  clang++ -c 
uniq_deref.cpp`.
@NoQ, @vsavchenko why does this not work?


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] D95043: [clangd] Use Dirty Filesystem for cross file rename.

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



Comment at: clang-tools-extra/clangd/refactor/Rename.h:40
 
+  // The filesystem to query when performing cross file renames.
+  llvm::IntrusiveRefCntPtr FS;

sammccall wrote:
> Index + FS are both only used for cross-file renames at this point.
> 
> (We used to support a single-file rename mode where the index was used to 
> validate that the symbol wasn't used elsewhere, but that's gone now)
> 
> I think we should document this, and assert that they're either both set 
> (cross-file) or neither is.
I wasn't sure the best way to approach this, but i agree, this is probably the 
safest. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95043

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


[PATCH] D98241: [clangd] Move logging out of LSPTest base class into a separate one.

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

This was causing TSan failures due to a race on vptr during destruction,
see
https://lab.llvm.org/buildbot/#/builders/131/builds/6579/steps/6/logs/FAIL__Clangd_Unit_Tests__LSPTest_FeatureModulesThr.

The story is, during the execution of a destructor all the virtual
dispatches should resolve to implementations in the class being
destroyed, not the derived ones. And LSPTests will log some stuff during
destruction (we send shutdown/exit requests, which are logged), which is
a virtual dispatch when LSPTest is derived from clang::clangd::Logger.

It is a benign race in our case, as gtests that derive from LSPTest
doesn't override the `log` method. But still during destruction, we
might try to update vtable ptr (due to being done with destruction of
test and starting destruction of LSPTest) and read from it to dispatch a
log message at the same time.

This patch fixes that race by moving `log` out of the vtable of
`LSPTest`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98241

Files:
  clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp


Index: clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
@@ -35,9 +35,9 @@
   return false;
 }
 
-class LSPTest : public ::testing::Test, private clangd::Logger {
+class LSPTest : public ::testing::Test {
 protected:
-  LSPTest() : LogSession(*this) {
+  LSPTest() : LogSession(L) {
 ClangdServer::Options &Base = Opts;
 Base = ClangdServer::optsForTest();
 // This is needed to we can test index-based operations like call 
hierarchy.
@@ -73,26 +73,29 @@
   FeatureModuleSet FeatureModules;
 
 private:
-  // Color logs so we can distinguish them from test output.
-  void log(Level L, const char *Fmt,
-   const llvm::formatv_object_base &Message) override {
-raw_ostream::Colors Color;
-switch (L) {
-case Level::Verbose:
-  Color = raw_ostream::BLUE;
-  break;
-case Level::Error:
-  Color = raw_ostream::RED;
-  break;
-default:
-  Color = raw_ostream::YELLOW;
-  break;
+  class Logger : public clang::clangd::Logger {
+// Color logs so we can distinguish them from test output.
+void log(Level L, const char *Fmt,
+ const llvm::formatv_object_base &Message) override {
+  raw_ostream::Colors Color;
+  switch (L) {
+  case Level::Verbose:
+Color = raw_ostream::BLUE;
+break;
+  case Level::Error:
+Color = raw_ostream::RED;
+break;
+  default:
+Color = raw_ostream::YELLOW;
+break;
+  }
+  std::lock_guard Lock(LogMu);
+  (llvm::outs().changeColor(Color) << Message << "\n").resetColor();
 }
-std::lock_guard Lock(LogMu);
-(llvm::outs().changeColor(Color) << Message << "\n").resetColor();
-  }
-  std::mutex LogMu;
+std::mutex LogMu;
+  };
 
+  Logger L;
   LoggingSession LogSession;
   llvm::Optional Server;
   llvm::Optional ServerThread;


Index: clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
@@ -35,9 +35,9 @@
   return false;
 }
 
-class LSPTest : public ::testing::Test, private clangd::Logger {
+class LSPTest : public ::testing::Test {
 protected:
-  LSPTest() : LogSession(*this) {
+  LSPTest() : LogSession(L) {
 ClangdServer::Options &Base = Opts;
 Base = ClangdServer::optsForTest();
 // This is needed to we can test index-based operations like call hierarchy.
@@ -73,26 +73,29 @@
   FeatureModuleSet FeatureModules;
 
 private:
-  // Color logs so we can distinguish them from test output.
-  void log(Level L, const char *Fmt,
-   const llvm::formatv_object_base &Message) override {
-raw_ostream::Colors Color;
-switch (L) {
-case Level::Verbose:
-  Color = raw_ostream::BLUE;
-  break;
-case Level::Error:
-  Color = raw_ostream::RED;
-  break;
-default:
-  Color = raw_ostream::YELLOW;
-  break;
+  class Logger : public clang::clangd::Logger {
+// Color logs so we can distinguish them from test output.
+void log(Level L, const char *Fmt,
+ const llvm::formatv_object_base &Message) override {
+  raw_ostream::Colors Color;
+  switch (L) {
+  case Level::Verbose:
+Color = raw_ostream::BLUE;
+break;
+  case Level::Error:
+Color = raw_ostream::RED;
+break;
+  default:
+Color = raw_ostream::YEL

[PATCH] D95244: [clang][AST] Handle overload callee type in CallExpr::getCallReturnType.

2021-03-09 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

> This causes a crash if the function is called in such case.

Is the crash caused by the below assertion?

  QualType Expr::findBoundMemberType(const Expr *expr) {
assert(expr->hasPlaceholderType(BuiltinType::BoundMember));




Comment at: clang/lib/AST/Expr.cpp:1403
+if (CalleeType.isNull())
+  return CreateDependentType();
+

balazske wrote:
> I am not sure if dependent type is here (and later) the correct value to 
> return. But only a null type is another possibility.
Perhaps we should handle this similarly as the type of `UnresolvedMemberExpr` 
or `OverloadExpr`? Which I assume is a null type.




Comment at: clang/unittests/Tooling/SourceCodeTest.cpp:642-644
+f_overload(p);
+A a;
+a.f(p);

Do we have the crash with both `f_overload` and with `a.f(p)` calls?
If yes, then please create two separate test cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95244

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


[PATCH] D95244: [clang][AST] Handle overload callee type in CallExpr::getCallReturnType.

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



Comment at: clang/lib/AST/Expr.cpp:1406
+  } else if (CalleeType->isDependentType() ||
+ CalleeType->isSpecificPlaceholderType(BuiltinType::Overload)) {
+return CreateDependentType();

Can't we create a built in place holder type here? Or could we simply just 
return `CalleeType`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95244

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


[PATCH] D98242: [clangd] Store system relative includes as verbatim

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

This makes our index more portable between different systems, e.g. we
can index a codebase with a --sysroot and make use of it on a system
that has a different abs path for those includes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98242

Files:
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp


Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -1446,6 +1446,20 @@
   UnorderedElementsAre(IncludeHeaderWithRef(TestHeaderURI, 1u)));
 }
 
+TEST_F(SymbolCollectorTest, IncludeHeaderFromSystemIsVerbatim) {
+  llvm::StringRef HeaderName = "header.h";
+  TestHeaderName = testPath(HeaderName);
+  TestHeaderURI = URI::create(TestHeaderName).toString();
+  CollectorOpts.CollectIncludePath = true;
+  runSymbolCollector("#pragma once\nclass Foo {};", /*Main=*/"",
+ {"-isystem", testRoot()});
+  EXPECT_THAT(Symbols, UnorderedElementsAre(
+   AllOf(QName("Foo"), DeclURI(TestHeaderURI;
+  EXPECT_THAT(Symbols.begin()->IncludeHeaders,
+  UnorderedElementsAre(
+  IncludeHeaderWithRef("<" + HeaderName.str() + ">", 1u)));
+}
+
 TEST_F(SymbolCollectorTest, CanonicalSTLHeader) {
   CollectorOpts.CollectIncludePath = true;
   CanonicalIncludes Includes;
Index: clang-tools-extra/clangd/index/SymbolCollector.cpp
===
--- clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -789,6 +789,16 @@
 // Conservatively refuse to insert #includes to files without guards.
 return llvm::None;
   }
+  // Store system includes as verbatim. This enables making use of the same
+  // index in different environments, e.g. a system header like 
+  // might resolve to different absolute paths, but the path relative to 
sysroot
+  // will be the same.
+  bool IsSystem = false;
+  auto ShorterInclude =
+  PP->getHeaderSearchInfo().suggestPathToFileForDiagnostics(FE, "",
+&IsSystem);
+  if (IsSystem)
+return "<" + ShorterInclude + ">";
   // Standard case: just insert the file itself.
   return toURI(SM, Filename, Opts);
 }


Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -1446,6 +1446,20 @@
   UnorderedElementsAre(IncludeHeaderWithRef(TestHeaderURI, 1u)));
 }
 
+TEST_F(SymbolCollectorTest, IncludeHeaderFromSystemIsVerbatim) {
+  llvm::StringRef HeaderName = "header.h";
+  TestHeaderName = testPath(HeaderName);
+  TestHeaderURI = URI::create(TestHeaderName).toString();
+  CollectorOpts.CollectIncludePath = true;
+  runSymbolCollector("#pragma once\nclass Foo {};", /*Main=*/"",
+ {"-isystem", testRoot()});
+  EXPECT_THAT(Symbols, UnorderedElementsAre(
+   AllOf(QName("Foo"), DeclURI(TestHeaderURI;
+  EXPECT_THAT(Symbols.begin()->IncludeHeaders,
+  UnorderedElementsAre(
+  IncludeHeaderWithRef("<" + HeaderName.str() + ">", 1u)));
+}
+
 TEST_F(SymbolCollectorTest, CanonicalSTLHeader) {
   CollectorOpts.CollectIncludePath = true;
   CanonicalIncludes Includes;
Index: clang-tools-extra/clangd/index/SymbolCollector.cpp
===
--- clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -789,6 +789,16 @@
 // Conservatively refuse to insert #includes to files without guards.
 return llvm::None;
   }
+  // Store system includes as verbatim. This enables making use of the same
+  // index in different environments, e.g. a system header like 
+  // might resolve to different absolute paths, but the path relative to sysroot
+  // will be the same.
+  bool IsSystem = false;
+  auto ShorterInclude =
+  PP->getHeaderSearchInfo().suggestPathToFileForDiagnostics(FE, "",
+&IsSystem);
+  if (IsSystem)
+return "<" + ShorterInclude + ">";
   // Standard case: just insert the file itself.
   return toURI(SM, Filename, Opts);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bi

[PATCH] D94554: [clangd] Add a Filesystem that overlays Dirty files.

2021-03-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/DraftStore.cpp:287
+for (const auto &KV : DS.Drafts) {
+  // Query the base filesystem for file uniqueids.
+  auto BaseStatus = BaseView->status(KV.getKey());

njames93 wrote:
> njames93 wrote:
> > sammccall wrote:
> > > njames93 wrote:
> > > > sammccall wrote:
> > > > > doing IO in view() doesn't seem obviously OK.
> > > > > 
> > > > > what's the practical consequence of the overlay's inodes not matching 
> > > > > that of the underlying FS? (It seems reasonable to say that the files 
> > > > > always have different identity, and may/may not have the same content)
> > > > It's probably not necessary, but I know preambles use the UniqueID. It 
> > > > may just be safer to create a uniqueID for each item in the DraftStore 
> > > > and leave it at that.
> > > The biggest risks I can see with this approach:
> > >  - in build-preamble-from-dirty-FS mode, would opening a draft cause the 
> > > preamble to be considered invalid and needing rebuilding? My read of 
> > > PrecompiledPreamble::CanReuse is no (UniqueIDs are not stored)
> > >  - when parsing, if the file can be read through the overlay *and* 
> > > underlying via different paths (e.g. hardlinks), these won't be 
> > > deduplicated. However giving them the same inode only changes the nature 
> > > of the bug: the file would get whichever content was read first.
> > > 
> > > So I think it's as good as we can expect.
> > Unfortunately in the current implementation, opening a draft will 
> > invalidate and preambles that use the underlying file. 
> > This is due to the last modification times not matching. 
> > This could be addressed by querying the TFS on the textDocument/didOpen 
> > request to get the actual last modification time, but we shouldn't really 
> > be doing any kind of IO on that thread.
> @sammccall Any further comments with regard to this. Is calling IO to get 
> modification time in didOpen ok, or just accept opening a file would 
> invalidate a preamble if the DirtyFS was used for preambles.
There's no urgency in resolving this:
 - preambles-from-dirty-fs doesn't exist in this patch
 - even once it does, we can introduce the problem first (in this experimental 
mode) and then solve it

That said, my suspicion is that having ClangdLSPServer stat the file, 
conditional on being in preambles-from-dirty-fs mode, would be OK.
(If the filesize matches I think it's safe to say the content does, and copy 
the timestamp. If the filesize mismatches... well, there are a number of 
scenarios involving encodings, and it's hard to say which will matter in 
practice, so we'd probably want to log and wait for the bug reports)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94554

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


[PATCH] D95043: [clangd] Use Dirty Filesystem for cross file rename.

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



Comment at: clang-tools-extra/clangd/ClangdServer.cpp:408
+clangd::rename({Pos, NewName.getValueOr("__clangd_rename_dummy"),
+InpAST->AST, File, TFS.view(llvm::None),
+/*Index=*/nullptr, RenameOpts});

sammccall wrote:
> we shouldn't need to pass a nontrivial FS in here, right?
i think this makes sense, as the idea is try to keep it fast by shying away 
from copying over all the dirty buffers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95043

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


[PATCH] D98241: [clangd] Move logging out of LSPTest base class into a separate one.

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

Thanks for working this out!

And sorry for the stupid private inheritance tricks :-(


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98241

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


[PATCH] D97277: [analyzer] Eliminate dispatchCast, evalCastFromNonLoc and evalCastFromLoc functions from SValBuilder

2021-03-09 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko accepted this revision.
vsavchenko added a comment.
This revision is now accepted and ready to land.

Looks great, thanks for cleaning up!


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

https://reviews.llvm.org/D97277

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


[clang-tools-extra] d1531b0 - [clangd] Move logging out of LSPTest base class into a separate one.

2021-03-09 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2021-03-09T11:57:05+01:00
New Revision: d1531b08c3d1bd46829a91313e7d6eb24d04c0d0

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

LOG: [clangd] Move logging out of LSPTest base class into a separate one.

This was causing TSan failures due to a race on vptr during destruction,
see
https://lab.llvm.org/buildbot/#/builders/131/builds/6579/steps/6/logs/FAIL__Clangd_Unit_Tests__LSPTest_FeatureModulesThr.

The story is, during the execution of a destructor all the virtual
dispatches should resolve to implementations in the class being
destroyed, not the derived ones. And LSPTests will log some stuff during
destruction (we send shutdown/exit requests, which are logged), which is
a virtual dispatch when LSPTest is derived from clang::clangd::Logger.

It is a benign race in our case, as gtests that derive from LSPTest
doesn't override the `log` method. But still during destruction, we
might try to update vtable ptr (due to being done with destruction of
test and starting destruction of LSPTest) and read from it to dispatch a
log message at the same time.

This patch fixes that race by moving `log` out of the vtable of
`LSPTest`.

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

Added: 


Modified: 
clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp 
b/clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
index c01a1d2ebc88..f596f94bd6cd 100644
--- a/clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
+++ b/clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
@@ -35,9 +35,9 @@ MATCHER_P(DiagMessage, M, "") {
   return false;
 }
 
-class LSPTest : public ::testing::Test, private clangd::Logger {
+class LSPTest : public ::testing::Test {
 protected:
-  LSPTest() : LogSession(*this) {
+  LSPTest() : LogSession(L) {
 ClangdServer::Options &Base = Opts;
 Base = ClangdServer::optsForTest();
 // This is needed to we can test index-based operations like call 
hierarchy.
@@ -73,26 +73,29 @@ class LSPTest : public ::testing::Test, private 
clangd::Logger {
   FeatureModuleSet FeatureModules;
 
 private:
-  // Color logs so we can distinguish them from test output.
-  void log(Level L, const char *Fmt,
-   const llvm::formatv_object_base &Message) override {
-raw_ostream::Colors Color;
-switch (L) {
-case Level::Verbose:
-  Color = raw_ostream::BLUE;
-  break;
-case Level::Error:
-  Color = raw_ostream::RED;
-  break;
-default:
-  Color = raw_ostream::YELLOW;
-  break;
+  class Logger : public clang::clangd::Logger {
+// Color logs so we can distinguish them from test output.
+void log(Level L, const char *Fmt,
+ const llvm::formatv_object_base &Message) override {
+  raw_ostream::Colors Color;
+  switch (L) {
+  case Level::Verbose:
+Color = raw_ostream::BLUE;
+break;
+  case Level::Error:
+Color = raw_ostream::RED;
+break;
+  default:
+Color = raw_ostream::YELLOW;
+break;
+  }
+  std::lock_guard Lock(LogMu);
+  (llvm::outs().changeColor(Color) << Message << "\n").resetColor();
 }
-std::lock_guard Lock(LogMu);
-(llvm::outs().changeColor(Color) << Message << "\n").resetColor();
-  }
-  std::mutex LogMu;
+std::mutex LogMu;
+  };
 
+  Logger L;
   LoggingSession LogSession;
   llvm::Optional Server;
   llvm::Optional ServerThread;



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


[PATCH] D98244: [analyzer] Fix StdLibraryFunctionsChecker performance issue

2021-03-09 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko created this revision.
vsavchenko added reviewers: NoQ, martong, steakhal, xazax.hun.
Herald added subscribers: ASDenysPetrov, Charusso, dkrupp, donat.nagy, 
Szelethus, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware.
vsavchenko requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

`initFunctionSummaries` lazily initializes a data structure with
function summaries for standard library functions.  It is called for
every pre-, post-, and eval-call events, i.e. 3 times for each call on
the path.  If the initialization doesn't find any standard library
functions in the translation unit, it will get re-tried (with the same
effect) many times even for small translation units.

For projects not using standard libraries, the speed-up can reach 50%
after this patch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98244

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


Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -508,6 +508,7 @@
   mutable FunctionSummaryMapType FunctionSummaryMap;
 
   mutable std::unique_ptr BT_InvalidArg;
+  mutable bool SummariesInitialized = false;
 
   static SVal getArgSVal(const CallEvent &Call, ArgNo ArgN) {
 return ArgN == Ret ? Call.getReturnValue() : Call.getArgSVal(ArgN);
@@ -823,7 +824,7 @@
 
 void StdLibraryFunctionsChecker::initFunctionSummaries(
 CheckerContext &C) const {
-  if (!FunctionSummaryMap.empty())
+  if (SummariesInitialized)
 return;
 
   SValBuilder &SVB = C.getSValBuilder();
@@ -2485,6 +2486,8 @@
 Signature(ArgTypes{VoidPtrRestrictTy}, RetType{VoidTy}),
 Summary(EvalCallAsPure));
   }
+
+  SummariesInitialized = true;
 }
 
 void ento::registerStdCLibraryFunctionsChecker(CheckerManager &mgr) {


Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -508,6 +508,7 @@
   mutable FunctionSummaryMapType FunctionSummaryMap;
 
   mutable std::unique_ptr BT_InvalidArg;
+  mutable bool SummariesInitialized = false;
 
   static SVal getArgSVal(const CallEvent &Call, ArgNo ArgN) {
 return ArgN == Ret ? Call.getReturnValue() : Call.getArgSVal(ArgN);
@@ -823,7 +824,7 @@
 
 void StdLibraryFunctionsChecker::initFunctionSummaries(
 CheckerContext &C) const {
-  if (!FunctionSummaryMap.empty())
+  if (SummariesInitialized)
 return;
 
   SValBuilder &SVB = C.getSValBuilder();
@@ -2485,6 +2486,8 @@
 Signature(ArgTypes{VoidPtrRestrictTy}, RetType{VoidTy}),
 Summary(EvalCallAsPure));
   }
+
+  SummariesInitialized = true;
 }
 
 void ento::registerStdCLibraryFunctionsChecker(CheckerManager &mgr) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98241: [clangd] Move logging out of LSPTest base class into a separate one.

2021-03-09 Thread Kadir Cetinkaya 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 rGd1531b08c3d1: [clangd] Move logging out of LSPTest base 
class into a separate one. (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98241

Files:
  clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp


Index: clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
@@ -35,9 +35,9 @@
   return false;
 }
 
-class LSPTest : public ::testing::Test, private clangd::Logger {
+class LSPTest : public ::testing::Test {
 protected:
-  LSPTest() : LogSession(*this) {
+  LSPTest() : LogSession(L) {
 ClangdServer::Options &Base = Opts;
 Base = ClangdServer::optsForTest();
 // This is needed to we can test index-based operations like call 
hierarchy.
@@ -73,26 +73,29 @@
   FeatureModuleSet FeatureModules;
 
 private:
-  // Color logs so we can distinguish them from test output.
-  void log(Level L, const char *Fmt,
-   const llvm::formatv_object_base &Message) override {
-raw_ostream::Colors Color;
-switch (L) {
-case Level::Verbose:
-  Color = raw_ostream::BLUE;
-  break;
-case Level::Error:
-  Color = raw_ostream::RED;
-  break;
-default:
-  Color = raw_ostream::YELLOW;
-  break;
+  class Logger : public clang::clangd::Logger {
+// Color logs so we can distinguish them from test output.
+void log(Level L, const char *Fmt,
+ const llvm::formatv_object_base &Message) override {
+  raw_ostream::Colors Color;
+  switch (L) {
+  case Level::Verbose:
+Color = raw_ostream::BLUE;
+break;
+  case Level::Error:
+Color = raw_ostream::RED;
+break;
+  default:
+Color = raw_ostream::YELLOW;
+break;
+  }
+  std::lock_guard Lock(LogMu);
+  (llvm::outs().changeColor(Color) << Message << "\n").resetColor();
 }
-std::lock_guard Lock(LogMu);
-(llvm::outs().changeColor(Color) << Message << "\n").resetColor();
-  }
-  std::mutex LogMu;
+std::mutex LogMu;
+  };
 
+  Logger L;
   LoggingSession LogSession;
   llvm::Optional Server;
   llvm::Optional ServerThread;


Index: clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
@@ -35,9 +35,9 @@
   return false;
 }
 
-class LSPTest : public ::testing::Test, private clangd::Logger {
+class LSPTest : public ::testing::Test {
 protected:
-  LSPTest() : LogSession(*this) {
+  LSPTest() : LogSession(L) {
 ClangdServer::Options &Base = Opts;
 Base = ClangdServer::optsForTest();
 // This is needed to we can test index-based operations like call hierarchy.
@@ -73,26 +73,29 @@
   FeatureModuleSet FeatureModules;
 
 private:
-  // Color logs so we can distinguish them from test output.
-  void log(Level L, const char *Fmt,
-   const llvm::formatv_object_base &Message) override {
-raw_ostream::Colors Color;
-switch (L) {
-case Level::Verbose:
-  Color = raw_ostream::BLUE;
-  break;
-case Level::Error:
-  Color = raw_ostream::RED;
-  break;
-default:
-  Color = raw_ostream::YELLOW;
-  break;
+  class Logger : public clang::clangd::Logger {
+// Color logs so we can distinguish them from test output.
+void log(Level L, const char *Fmt,
+ const llvm::formatv_object_base &Message) override {
+  raw_ostream::Colors Color;
+  switch (L) {
+  case Level::Verbose:
+Color = raw_ostream::BLUE;
+break;
+  case Level::Error:
+Color = raw_ostream::RED;
+break;
+  default:
+Color = raw_ostream::YELLOW;
+break;
+  }
+  std::lock_guard Lock(LogMu);
+  (llvm::outs().changeColor(Color) << Message << "\n").resetColor();
 }
-std::lock_guard Lock(LogMu);
-(llvm::outs().changeColor(Color) << Message << "\n").resetColor();
-  }
-  std::mutex LogMu;
+std::mutex LogMu;
+  };
 
+  Logger L;
   LoggingSession LogSession;
   llvm::Optional Server;
   llvm::Optional ServerThread;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97411: [DebugInfo] Add an attribute to force type info to be emitted for types that are required to be complete.

2021-03-09 Thread Carlos Alberto Enciso via Phabricator via cfe-commits
CarlosAlbertoEnciso added a comment.

In D97411#2611142 , @probinson wrote:

> In D97411#2598625 , @akhuang wrote:
>
>> I started looking into some diffs of debug info in libc++ tests, but it's 
>> pretty hard to tell what's different - as far as I can see, there are just a 
>> bunch of `__hash_value_type`s and `__value_type`s.
>
> This is a job for llvm-dva!  See the preliminary patch at D88661 
> , although it's getting a bit old and might 
> not apply/build cleanly.
>
> (llvm-dva is undergoing an internal review at the moment, we hope to have a 
> proper reviewable patch series up soon-ish.)

Uploaded an updated `llvm-dva` single patch the builds with the TOT.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97411

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


[PATCH] D98242: [clangd] Store system relative includes as verbatim

2021-03-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:801
+  if (IsSystem)
+return "<" + ShorterInclude + ">";
   // Standard case: just insert the file itself.

This is a great heuristic, now I'm thinking of all the ways it can go wrong...

---

It could be slow: it's doing a string comparison for every include path entry 
(not just the -isystems) and that can be a long list for big codebases. We're 
calling this for most symbols we encounter, so in principle this looks 
quadratic in codebase size when indexing a preamble.

It's tempting to throw a cache on it but actually... the callsite looks like:
```
foreach header:
  foreach symbol:
adjust(getIncludeHeader(symbol, header));
```

getIncludeHeader() is entirely dependent on the header almost ignores the 
symbol, so hoisting it out of the loop would be as good as caching it.

The wrinkle is the std::move hack, but we can move *that* part alone inside the 
loop instead.

---

It could fail to translate properly between paths, being inserted where the 
-isystem wasn't available. Often this means the *library* isn't available in 
this part of the codebase, so really the problem is offering the symbol at all 
(though using verbatim headers may make this harder to fix). Dynamic indexes 
spanning multiple projects are another case, but I think a marginal one. I 
don't think we need to address this.

---

It may give inconsistent results between TUs for the same symbol.
When a definition is indexed, it should win, so the problematic cases are:
 - header-only symbols (or no definition indexed) with inconsistent -isystem. 
This is not terribly important, as above I think.
 - definition is missing -isystem, because *within* the library headers are not 
considered "system". This seems likely to be common, and I'm not sure how to 
address it (other than giving verbatim headers priority always, which seems 
dubious). It's not a regression though (just the bug doesn't get fixed for 
these symbols.)
 - definition has -isystem (library impl considers its own headers as system) 
but other files don't. Also not sure how to solve this but it seems less likely 
to be common to me.

One design around these problems would be to store *both* a preferred spelling 
and a filename, and to use the spelling if it can be resolved. But this is 
invasive, means doing stat()s, doesn't work well with genfiles... I'm not 
really sure of a clean solution here.

Maybe we just move ahead as-is and see if we hit problems...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98242

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


[PATCH] D89986: [AIX] do not emit visibility attribute into IR when there is -mignore-xcoff-visibility

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

In D89986#2612021 , @DiggerLin wrote:

> Gentle ping . @jansvoboda11 .  Do you have any comment on it the last update 
> on  "added -round-trip-args functionality for the lang opt 
> "-mignore-xcoff-visibility" ?

I'd slightly prefer the code for `OPT_mignore_xcoff_visibility` argument 
generation to be in a similar place the parsing code is (between 
`OPT_fgnuc_version_EQ ` and `OPT_ftrapv`), but otherwise this change looks good 
to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89986

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


[PATCH] D98246: [clangd] Add basic monitoring info request for remote index server

2021-03-09 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev created this revision.
kbobyrev added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman.
kbobyrev requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98246

Files:
  clang-tools-extra/clangd/index/remote/Client.cpp
  clang-tools-extra/clangd/index/remote/Service.proto
  clang-tools-extra/clangd/index/remote/server/Server.cpp


Index: clang-tools-extra/clangd/index/remote/server/Server.cpp
===
--- clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -90,7 +90,7 @@
 class RemoteIndexServer final : public v1::SymbolIndex::Service {
 public:
   RemoteIndexServer(clangd::SymbolIndex &Index, llvm::StringRef IndexRoot)
-  : Index(Index) {
+  : Index(Index), ServiceStartTime(std::chrono::system_clock::now()) {
 llvm::SmallString<256> NativePath = IndexRoot;
 llvm::sys::path::native(NativePath);
 ProtobufMarshaller = std::unique_ptr(new Marshaller(
@@ -279,8 +279,20 @@
 Millis);
   }
 
+  grpc::Status MonitoringInfo(grpc::ServerContext *Context,
+  const google::protobuf::Empty *Request,
+  v1::MonitoringInfoReply *Reply) override {
+Reply->set_info(
+llvm::formatv("Service started at {0}. Uptime: {1}", ServiceStartTime,
+  ServiceStartTime - std::chrono::system_clock::now()));
+logRequest(*Request);
+logResponse(*Reply);
+return grpc::Status::OK;
+  }
+
   std::unique_ptr ProtobufMarshaller;
   clangd::SymbolIndex &Index;
+  llvm::sys::TimePoint<> ServiceStartTime;
 };
 
 // Detect changes in \p IndexPath file and load new versions of the index
Index: clang-tools-extra/clangd/index/remote/Service.proto
===
--- clang-tools-extra/clangd/index/remote/Service.proto
+++ clang-tools-extra/clangd/index/remote/Service.proto
@@ -10,8 +10,11 @@
 
 package clang.clangd.remote.v1;
 
+import "google/protobuf/empty.proto";
 import "Index.proto";
 
+message MonitoringInfoReply { optional string info = 1; }
+
 // Semantics of SymbolIndex match clangd::SymbolIndex with all required
 // structures corresponding to their clangd::* counterparts.
 service SymbolIndex {
@@ -22,5 +25,7 @@
   rpc Refs(RefsRequest) returns (stream RefsReply) {}
 
   rpc Relations(RelationsRequest) returns (stream RelationsReply) {}
+
+  rpc MonitoringInfo(google.protobuf.Empty) returns (MonitoringInfoReply) {}
 }
 
Index: clang-tools-extra/clangd/index/remote/Client.cpp
===
--- clang-tools-extra/clangd/index/remote/Client.cpp
+++ clang-tools-extra/clangd/index/remote/Client.cpp
@@ -17,6 +17,7 @@
 #include "clang/Basic/Version.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Chrono.h"
 #include "llvm/Support/Error.h"
 
 #include 
@@ -70,8 +71,7 @@
 SPAN_ATTACH(Tracer, "Request", RPCRequest.DebugString());
 grpc::ClientContext Context;
 Context.AddMetadata("version", clang::getClangToolFullVersion("clangd"));
-std::chrono::system_clock::time_point StartTime =
-std::chrono::system_clock::now();
+llvm::sys::TimePoint<> StartTime = std::chrono::system_clock::now();
 auto Deadline = StartTime + DeadlineWaitingTime;
 Context.set_deadline(Deadline);
 auto Reader = (Stub.get()->*RPCCall)(&Context, RPCRequest);


Index: clang-tools-extra/clangd/index/remote/server/Server.cpp
===
--- clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -90,7 +90,7 @@
 class RemoteIndexServer final : public v1::SymbolIndex::Service {
 public:
   RemoteIndexServer(clangd::SymbolIndex &Index, llvm::StringRef IndexRoot)
-  : Index(Index) {
+  : Index(Index), ServiceStartTime(std::chrono::system_clock::now()) {
 llvm::SmallString<256> NativePath = IndexRoot;
 llvm::sys::path::native(NativePath);
 ProtobufMarshaller = std::unique_ptr(new Marshaller(
@@ -279,8 +279,20 @@
 Millis);
   }
 
+  grpc::Status MonitoringInfo(grpc::ServerContext *Context,
+  const google::protobuf::Empty *Request,
+  v1::MonitoringInfoReply *Reply) override {
+Reply->set_info(
+llvm::formatv("Service started at {0}. Uptime: {1}", ServiceStartTime,
+  ServiceStartTime - std::chrono::system_clock::now()));
+logRequest(*Request);
+logResponse(*Reply);
+return grpc::Status::OK;
+  }
+
   std::unique_ptr ProtobufMarshaller;
   clangd::SymbolIndex &Index;
+  llvm::sys::TimePoint<> ServiceStartTime;
 };
 
 // Detect changes in \p IndexPat

[PATCH] D94554: [clangd] Add a Filesystem that overlays Dirty files.

2021-03-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.

Still LG btw!




Comment at: clang-tools-extra/clangd/ClangdServer.h:342
 
-  llvm::Optional getDraft(PathRef File) const;
+  std::shared_ptr getDraft(PathRef File) const;
 

Maybe add an explicit comment that this returns nullptr if the file is not open.
(When the type was Optional this was fairly self-explanatory)



Comment at: clang-tools-extra/clangd/ClangdServer.h:389
+
+  const std::unique_ptr DirtyFS;
 };

nit: we don't use const on pointer members, just on the pointee where 
appropriate.
Maybe not the best style in a vacuum but it's fairly consistent and diverging 
from it is a bit confusing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94554

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


[clang] 13c77f2 - [OpenCL] Fix builtins that require multiple extensions

2021-03-09 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2021-03-09T11:37:26Z
New Revision: 13c77f204671f403a30d29ec1c9145c556302f66

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

LOG: [OpenCL] Fix builtins that require multiple extensions

Builtins that require multiple extensions, such as certain
`write_imagef` forms, were not exposed because of the Sema check not
splitting the extension string.

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

Added: 


Modified: 
clang/lib/Sema/SemaLookup.cpp
clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl

Removed: 




diff  --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index 404f24d8ce0a..4da81bb44d5b 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -815,9 +815,20 @@ static void InsertOCLBuiltinDeclarationsFromTable(Sema &S, 
LookupResult &LR,
 // Ignore this builtin function if it carries an extension macro that is
 // not defined. This indicates that the extension is not supported by the
 // target, so the builtin function should not be available.
-StringRef Ext = FunctionExtensionTable[OpenCLBuiltin.Extension];
-if (!Ext.empty() && !S.getPreprocessor().isMacroDefined(Ext))
-  continue;
+StringRef Extensions = FunctionExtensionTable[OpenCLBuiltin.Extension];
+if (!Extensions.empty()) {
+  SmallVector ExtVec;
+  Extensions.split(ExtVec, " ");
+  bool AllExtensionsDefined = true;
+  for (StringRef Ext : ExtVec) {
+if (!S.getPreprocessor().isMacroDefined(Ext)) {
+  AllExtensionsDefined = false;
+  break;
+}
+  }
+  if (!AllExtensionsDefined)
+continue;
+}
 
 SmallVector RetTypes;
 SmallVector, 5> ArgTypes;

diff  --git a/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl 
b/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
index 9a5ed77b1635..825dd3a935d0 100644
--- a/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
+++ b/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
@@ -17,6 +17,10 @@
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
 #endif
 
+#if __OPENCL_C_VERSION__ <= CL_VERSION_1_2
+#pragma OPENCL EXTENSION cl_khr_3d_image_writes : enable
+#endif
+
 // First, test that Clang gracefully handles missing types.
 #ifdef NO_HEADER
 void test_without_header() {
@@ -169,13 +173,20 @@ kernel void basic_image_readwrite(read_write image3d_t 
image_read_write_image3d)
 }
 #endif // __OPENCL_C_VERSION__ >= CL_VERSION_2_0
 
-kernel void basic_image_writeonly(write_only image1d_buffer_t 
image_write_only_image1d_buffer) {
+kernel void basic_image_writeonly(write_only image1d_buffer_t 
image_write_only_image1d_buffer, write_only image3d_t image3dwo) {
   half4 h4;
   float4 f4;
   int i;
 
   write_imagef(image_write_only_image1d_buffer, i, f4);
   write_imageh(image_write_only_image1d_buffer, i, h4);
+
+  int4 i4;
+  write_imagef(image3dwo, i4, i, f4);
+#if __OPENCL_C_VERSION__ <= CL_VERSION_1_2 && !defined(__OPENCL_CPP_VERSION__)
+  // expected-error@-2{{no matching function for call to 'write_imagef'}}
+  // expected-note@-3 + {{candidate function not viable}}
+#endif
 }
 
 kernel void basic_subgroup(global uint *out) {



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


[PATCH] D97930: [OpenCL] Fix builtins that require multiple extensions

2021-03-09 Thread Sven van Haastregt via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG13c77f204671: [OpenCL] Fix builtins that require multiple 
extensions (authored by svenvh).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97930

Files:
  clang/lib/Sema/SemaLookup.cpp
  clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl


Index: clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
===
--- clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
+++ clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
@@ -17,6 +17,10 @@
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
 #endif
 
+#if __OPENCL_C_VERSION__ <= CL_VERSION_1_2
+#pragma OPENCL EXTENSION cl_khr_3d_image_writes : enable
+#endif
+
 // First, test that Clang gracefully handles missing types.
 #ifdef NO_HEADER
 void test_without_header() {
@@ -169,13 +173,20 @@
 }
 #endif // __OPENCL_C_VERSION__ >= CL_VERSION_2_0
 
-kernel void basic_image_writeonly(write_only image1d_buffer_t 
image_write_only_image1d_buffer) {
+kernel void basic_image_writeonly(write_only image1d_buffer_t 
image_write_only_image1d_buffer, write_only image3d_t image3dwo) {
   half4 h4;
   float4 f4;
   int i;
 
   write_imagef(image_write_only_image1d_buffer, i, f4);
   write_imageh(image_write_only_image1d_buffer, i, h4);
+
+  int4 i4;
+  write_imagef(image3dwo, i4, i, f4);
+#if __OPENCL_C_VERSION__ <= CL_VERSION_1_2 && !defined(__OPENCL_CPP_VERSION__)
+  // expected-error@-2{{no matching function for call to 'write_imagef'}}
+  // expected-note@-3 + {{candidate function not viable}}
+#endif
 }
 
 kernel void basic_subgroup(global uint *out) {
Index: clang/lib/Sema/SemaLookup.cpp
===
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -815,9 +815,20 @@
 // Ignore this builtin function if it carries an extension macro that is
 // not defined. This indicates that the extension is not supported by the
 // target, so the builtin function should not be available.
-StringRef Ext = FunctionExtensionTable[OpenCLBuiltin.Extension];
-if (!Ext.empty() && !S.getPreprocessor().isMacroDefined(Ext))
-  continue;
+StringRef Extensions = FunctionExtensionTable[OpenCLBuiltin.Extension];
+if (!Extensions.empty()) {
+  SmallVector ExtVec;
+  Extensions.split(ExtVec, " ");
+  bool AllExtensionsDefined = true;
+  for (StringRef Ext : ExtVec) {
+if (!S.getPreprocessor().isMacroDefined(Ext)) {
+  AllExtensionsDefined = false;
+  break;
+}
+  }
+  if (!AllExtensionsDefined)
+continue;
+}
 
 SmallVector RetTypes;
 SmallVector, 5> ArgTypes;


Index: clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
===
--- clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
+++ clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
@@ -17,6 +17,10 @@
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
 #endif
 
+#if __OPENCL_C_VERSION__ <= CL_VERSION_1_2
+#pragma OPENCL EXTENSION cl_khr_3d_image_writes : enable
+#endif
+
 // First, test that Clang gracefully handles missing types.
 #ifdef NO_HEADER
 void test_without_header() {
@@ -169,13 +173,20 @@
 }
 #endif // __OPENCL_C_VERSION__ >= CL_VERSION_2_0
 
-kernel void basic_image_writeonly(write_only image1d_buffer_t image_write_only_image1d_buffer) {
+kernel void basic_image_writeonly(write_only image1d_buffer_t image_write_only_image1d_buffer, write_only image3d_t image3dwo) {
   half4 h4;
   float4 f4;
   int i;
 
   write_imagef(image_write_only_image1d_buffer, i, f4);
   write_imageh(image_write_only_image1d_buffer, i, h4);
+
+  int4 i4;
+  write_imagef(image3dwo, i4, i, f4);
+#if __OPENCL_C_VERSION__ <= CL_VERSION_1_2 && !defined(__OPENCL_CPP_VERSION__)
+  // expected-error@-2{{no matching function for call to 'write_imagef'}}
+  // expected-note@-3 + {{candidate function not viable}}
+#endif
 }
 
 kernel void basic_subgroup(global uint *out) {
Index: clang/lib/Sema/SemaLookup.cpp
===
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -815,9 +815,20 @@
 // Ignore this builtin function if it carries an extension macro that is
 // not defined. This indicates that the extension is not supported by the
 // target, so the builtin function should not be available.
-StringRef Ext = FunctionExtensionTable[OpenCLBuiltin.Extension];
-if (!Ext.empty() && !S.getPreprocessor().isMacroDefined(Ext))
-  continue;
+StringRef Extensions = FunctionExtensionTable[OpenCLBuiltin.Extension];
+if (!Extensions.empty()) {
+  SmallVector ExtVec;
+  Extensions.split(ExtVec, " ");
+  bool AllExtensionsDefined = true;
+  for (StringRef Ext : ExtVec) {
+if (!S.getPreprocessor().isMacroDef

[PATCH] D97874: [analyzer] Improve SVal cast from integer to bool using known RangeSet

2021-03-09 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 329282.
ASDenysPetrov added a comment.

Updated due to discussion.


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

https://reviews.llvm.org/D97874

Files:
  clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
  clang/test/Analysis/cast_symbolic_ints_to_bool.cpp


Index: clang/test/Analysis/cast_symbolic_ints_to_bool.cpp
===
--- /dev/null
+++ clang/test/Analysis/cast_symbolic_ints_to_bool.cpp
@@ -0,0 +1,67 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify 
%s
+
+template 
+void clang_analyzer_dump(T);
+
+void test_int_to_bool(bool b, int x) {
+  clang_analyzer_dump(b); // expected-warning{{reg_$0<_Bool b>}}
+  b = x;
+  clang_analyzer_dump(b); // expected-warning{{reg_$1}}
+  if (x < 0) {
+b = x;
+clang_analyzer_dump(b); // expected-warning{{1 U1b}}
+  } else if (x > 0) {
+b = x;
+clang_analyzer_dump(b); // expected-warning{{1 U1b}}
+  } else {
+b = x;
+clang_analyzer_dump(b); // expected-warning{{0 U1b}}
+  }
+}
+
+void test_char_to_bool(char x) {
+  bool b = x;
+  clang_analyzer_dump(b); // expected-warning{{reg_$0}}
+  if (x < 0) {
+bool b = x;
+clang_analyzer_dump(b); // expected-warning{{1 U1b}}
+  } else if (x > 0) {
+bool b = x;
+clang_analyzer_dump(b); // expected-warning{{1 U1b}}
+  } else {
+bool b = x;
+clang_analyzer_dump(b); // expected-warning{{0 U1b}}
+  }
+}
+
+void test_unsigned_to_bool(bool b, unsigned x) {
+  clang_analyzer_dump(b); // expected-warning{{reg_$0<_Bool b>}}
+  b = x;
+  clang_analyzer_dump(b); // expected-warning{{reg_$1}}
+  if (x) {
+b = x;
+clang_analyzer_dump(b); // expected-warning{{1 U1b}}
+  } else {
+b = x;
+clang_analyzer_dump(b); // expected-warning{{0 U1b}}
+  }
+}
+
+void test_unsigned_to_bool(unsigned char x) {
+  bool b = x;
+  clang_analyzer_dump(b); // expected-warning{{reg_$0}}
+  if (x < 42) {
+b = x;
+clang_analyzer_dump(b); // expected-warning{{reg_$0}}
+if (x) {
+  b = x;
+  clang_analyzer_dump(b); // expected-warning{{1 U1b}}
+} else {
+  b = x;
+  clang_analyzer_dump(b); // expected-warning{{0 U1b}}
+}
+  } else {
+b = x;
+clang_analyzer_dump(b); // expected-warning{{1 U1b}}
+  }
+}
Index: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -871,12 +871,16 @@
 
   // Symbol to bool.
   if (!OriginalTy.isNull() && CastTy->isBooleanType()) {
-// Non-float to bool.
-if (Loc::isLocType(OriginalTy) ||
-OriginalTy->isIntegralOrEnumerationType() ||
-OriginalTy->isMemberPointerType()) {
-  BasicValueFactory &BVF = getBasicValueFactory();
-  return makeNonLoc(SE, BO_NE, BVF.getValue(0, SE->getType()), CastTy);
+// Symbolic integer to bool.
+if (OriginalTy->isIntegralOrEnumerationType()) {
+
+  // Integer is known to be non-zero or zero only.
+  auto truth = State->isNonNull(V);
+  if (truth.isConstrained())
+return makeTruthVal(truth.isConstrainedTrue(), CastTy);
+
+  // Unconstrained integer to bool.
+  return V;
 }
   } else {
 // Symbol to integer.


Index: clang/test/Analysis/cast_symbolic_ints_to_bool.cpp
===
--- /dev/null
+++ clang/test/Analysis/cast_symbolic_ints_to_bool.cpp
@@ -0,0 +1,67 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s
+
+template 
+void clang_analyzer_dump(T);
+
+void test_int_to_bool(bool b, int x) {
+  clang_analyzer_dump(b); // expected-warning{{reg_$0<_Bool b>}}
+  b = x;
+  clang_analyzer_dump(b); // expected-warning{{reg_$1}}
+  if (x < 0) {
+b = x;
+clang_analyzer_dump(b); // expected-warning{{1 U1b}}
+  } else if (x > 0) {
+b = x;
+clang_analyzer_dump(b); // expected-warning{{1 U1b}}
+  } else {
+b = x;
+clang_analyzer_dump(b); // expected-warning{{0 U1b}}
+  }
+}
+
+void test_char_to_bool(char x) {
+  bool b = x;
+  clang_analyzer_dump(b); // expected-warning{{reg_$0}}
+  if (x < 0) {
+bool b = x;
+clang_analyzer_dump(b); // expected-warning{{1 U1b}}
+  } else if (x > 0) {
+bool b = x;
+clang_analyzer_dump(b); // expected-warning{{1 U1b}}
+  } else {
+bool b = x;
+clang_analyzer_dump(b); // expected-warning{{0 U1b}}
+  }
+}
+
+void test_unsigned_to_bool(bool b, unsigned x) {
+  clang_analyzer_dump(b); // expected-warning{{reg_$0<_Bool b>}}
+  b = x;
+  clang_analyzer_dump(b); // expected-warning{{reg_$1}}
+  if (x) {
+b = x;
+clang_analyzer_dump(b); // expected-warning{{1 U1b}}
+  } else {
+b = x;
+clang_analyzer_dump(b); // expected-warning{{0 U1b}}
+  }
+}
+
+void test_unsigned_to_bool(unsigned char x) {
+  bool b = x;
+  clang_analyzer_dump(b); // expected-warning{{re

[PATCH] D97196: [clang-tidy] Add new check 'bugprone-unhandled-exception-at-new'.

2021-03-09 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97196

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


[PATCH] D98076: [OpenCL][Docs] Release 12.0 notes

2021-03-09 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:208
+- Added ``-cl-std=CL3.0`` and predefined version macro for OpenCL 3.0.
+- Added ``-cl-std=CL1.0`` and mapped to the existing  OpenCL 1.0 functionality.
+- Improved OpenCL extension handling per target.





Comment at: clang/docs/ReleaseNotes.rst:211
+- Added clang extension for function pointers ``__cl_clang_function_pointers``
+  and  variadic functions ``__cl_clang_variadic_functions``.
+- Improve diagnostics for nested pointers, unevaluated ``vec_step`` expression.





Comment at: clang/docs/ReleaseNotes.rst:214
+- Added ``global_device`` and ``global_host`` address spaces for USM
+  allocations.
+

Perhaps one more point to mention:
```
 - Allow pointer-to-pointer kernel arguments beyond OpenCL 1.2.
```
(related commit is 523775f96742 ("[OpenCL] Allow pointer-to-pointer kernel args 
beyond CL 1.2", 2020-12-01)).



Comment at: clang/docs/ReleaseNotes.rst:222
+  constructors.
+- Remove warning for variadic macro use.
 

Nitpick: you're mixing past and present tense ("added" vs "fix").  It would be 
nicer for consistency to use the same tense everywhere.


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

https://reviews.llvm.org/D98076

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


[PATCH] D97990: [clang] Improve diagnostics on implicitly deleted defaulted comparisons

2021-03-09 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 329289.
mizvekov added a comment.

Change to simpler way to do it:
For CompleteObject Kind, just fill in the declaration for the complete object.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97990

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
  clang/test/CXX/class/class.compare/class.compare.default/p2.cpp
  clang/test/CXX/class/class.compare/class.compare.default/p4.cpp
  clang/test/CXX/class/class.compare/class.eq/p2.cpp
  clang/test/CXX/class/class.compare/class.spaceship/p1.cpp
  clang/test/CXX/class/class.compare/class.spaceship/p2.cpp

Index: clang/test/CXX/class/class.compare/class.spaceship/p2.cpp
===
--- clang/test/CXX/class/class.compare/class.spaceship/p2.cpp
+++ clang/test/CXX/class/class.compare/class.spaceship/p2.cpp
@@ -52,7 +52,7 @@
 bool operator<(const A&) const;
   };
   struct B {
-A a; // expected-note {{no viable comparison function for member 'a'}}
+A a; // expected-note {{no viable three-way comparison function for member 'a'}}
 auto operator<=>(const B&) const = default; // expected-warning {{implicitly deleted}}
   };
 }
@@ -159,16 +159,16 @@
 namespace PR48856 {
   struct A {
 auto operator<=>(const A &) const = default; // expected-warning {{implicitly deleted}}
-void (*x)(); // expected-note {{because there is no viable comparison function for member 'x'}}
+void (*x)(); // expected-note {{because there is no viable three-way comparison function for member 'x'}}
   };
 
   struct B {
 auto operator<=>(const B &) const = default; // expected-warning {{implicitly deleted}}
-void (B::*x)();  // expected-note {{because there is no viable comparison function for member 'x'}}
+void (B::*x)();  // expected-note {{because there is no viable three-way comparison function for member 'x'}}
   };
 
   struct C {
 auto operator<=>(const C &) const = default; // expected-warning {{implicitly deleted}}
-int C::*x;   // expected-note {{because there is no viable comparison function for member 'x'}}
+int C::*x;   // expected-note {{because there is no viable three-way comparison function for member 'x'}}
   };
 }
Index: clang/test/CXX/class/class.compare/class.spaceship/p1.cpp
===
--- clang/test/CXX/class/class.compare/class.spaceship/p1.cpp
+++ clang/test/CXX/class/class.compare/class.spaceship/p1.cpp
@@ -78,9 +78,9 @@
   };
 
   // expected-note@#base {{deleted comparison function for base class 'C'}}
-  // expected-note@#base {{no viable comparison function for base class 'D1'}}
+  // expected-note@#base {{no viable three-way comparison function for base class 'D1'}}
   // expected-note@#base {{three-way comparison cannot be synthesized because there is no viable function for '<' comparison}}
-  // expected-note@#base {{no viable comparison function for base class 'D2'}}
+  // expected-note@#base {{no viable three-way comparison function for base class 'D2'}}
   // expected-note@#base {{three-way comparison cannot be synthesized because there is no viable function for '==' comparison}}
   // expected-note@#base {{deleted comparison function for base class 'E'}}
   // expected-note@#base {{implied comparison for base class 'F' is ambiguous}}
@@ -110,9 +110,9 @@
   }
 
   // expected-note@#arr {{deleted comparison function for member 'arr'}}
-  // expected-note@#arr {{no viable comparison function for member 'arr'}}
+  // expected-note@#arr {{no viable three-way comparison function for member 'arr'}}
   // expected-note@#arr {{three-way comparison cannot be synthesized because there is no viable function for '<' comparison}}
-  // expected-note@#arr {{no viable comparison function for member 'arr'}}
+  // expected-note@#arr {{no viable three-way comparison function for member 'arr'}}
   // expected-note@#arr {{three-way comparison cannot be synthesized because there is no viable function for '==' comparison}}
   // expected-note@#arr {{deleted comparison function for member 'arr'}}
   // expected-note@#arr {{implied comparison for member 'arr' is ambiguous}}
Index: clang/test/CXX/class/class.compare/class.eq/p2.cpp
===
--- clang/test/CXX/class/class.compare/class.eq/p2.cpp
+++ clang/test/CXX/class/class.compare/class.eq/p2.cpp
@@ -18,26 +18,26 @@
 struct H1 {
   bool operator==(const H1 &) const = default;
   bool operator<(const H1 &) const = default; // expected-warning {{implicitly deleted}}
-  // expected-note@-1 {{because there is no 

[PATCH] D97080: [flang][driver] Add -fintrinsic-modules-path option

2021-03-09 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

In D97080#2586289 , @arnamoy10 wrote:

> Also, not sure what to set as the default directory, as gfortran uses a 
> specific installation location.

We probably should use a location relative to the `flang-new` binary, i.e. 
`/../tools/flang/include/flang/`.

**Question**: What are the semantics for this flag in `gfortran`? Is the path 
specified with `-fintrinsics-module-path` _prepended_ or _appended_ to the 
default search path?


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

https://reviews.llvm.org/D97080

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


[PATCH] D97743: Define __GCC_HAVE_DWARF2_CFI_ASM if applicable

2021-03-09 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.

Could the logic be implemented in the driver?

LGTM regardless.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97743

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


[PATCH] D95016: [Clang][RISCV] Add custom TableGen backend for riscv-vector intrinsics.

2021-03-09 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

LGTM. @jrtc27 are you ok with this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95016

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


[PATCH] D97552: [clang][cli] Fix generation of '-fvisibility' with regards to '-mignore-xcoff-visibility'

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

In D97552#2607842 , @DiggerLin wrote:

> 1. in your summary , it looks  clang will emit "-fvisibility default"  to cc1 
> even if there is no -fvisibility in the clang command ?  I compiled the clang 
> with your patch, it looks do not always emit "-fvisibility default"  to cc1.  
> I understand wrong on your summary ?
> 2. If clang will emit "-fvisibility default"  to cc1 when there is no 
> -fvisibility in the clang command, it is a new functionality , there should 
> be a test case for it?



1. `-fvisibility default` will be generated by 
`CompilerInvocation::generateCC1CommandLine`, which will be used during Clang 
modules build. Not by the Clang driver when constructing `-cc1` invocation on 
normal (non-modular) build.
2. This code is tested by a round-trip mechanism when 
`-DCLANG_ROUND_TRIP_CC1_ARGS` is turned on: 
https://lists.llvm.org/pipermail/cfe-dev/2021-February/067714.html


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97552

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


[PATCH] D98055: [ExtVectorType] Support conditional select operator for C++.

2021-03-09 Thread Florian Hahn via Phabricator via cfe-commits
fhahn marked an inline comment as done.
fhahn added inline comments.



Comment at: clang/lib/Sema/SemaExprCXX.cpp:6172-6174
+  if (IsVectorConditional) {
+return CheckVectorConditionalTypes(Cond, LHS, RHS, QuestionLoc);
+  }

aaron.ballman wrote:
> 
I'll fix that before committing, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98055

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


[PATCH] D98251: [-Wcompletion-handler] Extend list of detected conventions

2021-03-09 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko created this revision.
vsavchenko added a reviewer: NoQ.
Herald added a subscriber: Charusso.
vsavchenko requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Update convention detection to accomodate changes from:
https://github.com/DougGregor/swift-evolution/blob/concurrency-objc/proposals/-concurrency-objc.md#asynchronous-completion-handler-methods


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98251

Files:
  clang/lib/Analysis/CalledOnceCheck.cpp
  clang/test/SemaObjC/warn-called-once.m


Index: clang/test/SemaObjC/warn-called-once.m
===
--- clang/test/SemaObjC/warn-called-once.m
+++ clang/test/SemaObjC/warn-called-once.m
@@ -1036,6 +1036,20 @@
   }
 }
 
+- (void)test:(int)cond fooWithReplyTo:(void (^)(void))handler {
+  if (cond) {
+// expected-warning@-1{{completion handler is never called when taking 
false branch}}
+handler();
+  }
+}
+
+- (void)test:(int)cond with:(void (^)(void))fooWithCompletionBlock {
+  if (cond) {
+// expected-warning@-1{{completion handler is never called when taking 
false branch}}
+fooWithCompletionBlock();
+  }
+}
+
 - (void)completion_handler_wrong_type:(int (^)(void))completionHandler {
   // We don't want to consider completion handlers with non-void return types.
   if ([self condition]) {
Index: clang/lib/Analysis/CalledOnceCheck.cpp
===
--- clang/lib/Analysis/CalledOnceCheck.cpp
+++ clang/lib/Analysis/CalledOnceCheck.cpp
@@ -48,9 +48,12 @@
 template 
 using CFGSizedVector = llvm::SmallVector;
 constexpr llvm::StringLiteral CONVENTIONAL_NAMES[] = {
-"completionHandler", "completion", "withCompletionHandler"};
+"completionHandler", "completion",  "withCompletionHandler",
+"withCompletion","completionBlock", "withCompletionBlock",
+"replyTo",   "reply",   "withReplyTo"};
 constexpr llvm::StringLiteral CONVENTIONAL_SUFFIXES[] = {
-"WithCompletionHandler", "WithCompletion"};
+"WithCompletionHandler", "WithCompletion", "WithCompletionBlock",
+"WithReplyTo", "WithReply"};
 constexpr llvm::StringLiteral CONVENTIONAL_CONDITIONS[] = {
 "error", "cancel", "shouldCall", "done", "OK", "success"};
 
@@ -994,13 +997,15 @@
   return hasConventionalSuffix(MethodSelector.getNameForSlot(0));
 }
 
-return isConventional(MethodSelector.getNameForSlot(PieceIndex));
+llvm::StringRef PieceName = MethodSelector.getNameForSlot(PieceIndex);
+return isConventional(PieceName) || hasConventionalSuffix(PieceName);
   }
 
   bool shouldBeCalledOnce(const ParmVarDecl *Parameter) const {
 return isExplicitlyMarked(Parameter) ||
(CheckConventionalParameters &&
-isConventional(Parameter->getName()) &&
+(isConventional(Parameter->getName()) ||
+ hasConventionalSuffix(Parameter->getName())) &&
 isConventional(Parameter->getType()));
   }
 


Index: clang/test/SemaObjC/warn-called-once.m
===
--- clang/test/SemaObjC/warn-called-once.m
+++ clang/test/SemaObjC/warn-called-once.m
@@ -1036,6 +1036,20 @@
   }
 }
 
+- (void)test:(int)cond fooWithReplyTo:(void (^)(void))handler {
+  if (cond) {
+// expected-warning@-1{{completion handler is never called when taking false branch}}
+handler();
+  }
+}
+
+- (void)test:(int)cond with:(void (^)(void))fooWithCompletionBlock {
+  if (cond) {
+// expected-warning@-1{{completion handler is never called when taking false branch}}
+fooWithCompletionBlock();
+  }
+}
+
 - (void)completion_handler_wrong_type:(int (^)(void))completionHandler {
   // We don't want to consider completion handlers with non-void return types.
   if ([self condition]) {
Index: clang/lib/Analysis/CalledOnceCheck.cpp
===
--- clang/lib/Analysis/CalledOnceCheck.cpp
+++ clang/lib/Analysis/CalledOnceCheck.cpp
@@ -48,9 +48,12 @@
 template 
 using CFGSizedVector = llvm::SmallVector;
 constexpr llvm::StringLiteral CONVENTIONAL_NAMES[] = {
-"completionHandler", "completion", "withCompletionHandler"};
+"completionHandler", "completion",  "withCompletionHandler",
+"withCompletion","completionBlock", "withCompletionBlock",
+"replyTo",   "reply",   "withReplyTo"};
 constexpr llvm::StringLiteral CONVENTIONAL_SUFFIXES[] = {
-"WithCompletionHandler", "WithCompletion"};
+"WithCompletionHandler", "WithCompletion", "WithCompletionBlock",
+"WithReplyTo", "WithReply"};
 constexpr llvm::StringLiteral CONVENTIONAL_CONDITIONS[] = {
 "error", "cancel", "shouldCall", "done", "OK", "success"};
 
@@ -994,13 +997,15 @@
   return hasConventionalSuffix(MethodSelector.getNameForSlot(0));
 }
 
-return isConventional(MethodSelector.getNameForSlot(PieceIndex))

[PATCH] D97785: [SystemZ][z/OS] Distinguish between text and binary files on z/OS

2021-03-09 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.

If there are no concerns about setting OF_None flag for all ToolOutputFiles on 
Windows only, I would also like to get your reviews for this patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97785

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


[clang] fc8d376 - [ExtVectorType] Support conditional select operator for C++.

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

Author: Florian Hahn
Date: 2021-03-09T13:08:52Z
New Revision: fc8d3766d721ebc075e16814e48adf48034ea858

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

LOG: [ExtVectorType] Support conditional select operator for C++.

This patch implements the conditional select operator for
ext_vector_types in C++. It does so by using the same semantics as for
C.

D71463 added support for the conditional select operator for VectorType
in C++. Unfortunately the semantics between ext_vector_type in C are
different to VectorType in C++. Select for ext_vector_type is based on
the MSB of the condition vector, whereas for VectorType it is `!= 0`.

This unfortunately means that the behavior is inconsistent between
ExtVectorType and VectorType, but I think using the C semantics for
ExtVectorType in C++ as well should be less surprising for users.

Reviewed By: erichkeane, aaron.ballman

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

Added: 
clang/test/CodeGenCXX/ext-vector-type-conditional.cpp
clang/test/CodeGenCXX/vector-size-conditional.cpp
clang/test/SemaCXX/ext-vector-type-conditional.cpp
clang/test/SemaCXX/vector-size-conditional.cpp

Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaExprCXX.cpp

Removed: 
clang/test/CodeGenCXX/vector-conditional.cpp
clang/test/SemaCXX/vector-conditional.cpp



diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 79eeed869ba6..7076274dcb6b 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7423,9 +7423,10 @@ def err_conditional_vector_element_size : Error<
 def err_conditional_vector_has_void : Error<
   "GNU vector conditional operand cannot be %select{void|a throw 
expression}0">;
 def err_conditional_vector_operand_type
-: Error<"%select{enumeration|extended vector}0 type %1 is not allowed in a 
"
-"vector conditional">;
-def err_conditional_vector_mismatched_vectors
+: Error<"enumeration type %0 is not allowed in a vector conditional">;
+def err_conditional_vector_cond_result_mismatch
+: Error<"cannot mix vectors and extended vectors in a vector conditional">;
+def err_conditional_vector_mismatched
 : Error<"vector operands to the vector conditional must be the same type "
 "%
diff {($ and $)|}0,1}">;
 

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index e561aaaca7bb..a919740aa662 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -11557,9 +11557,9 @@ class Sema final {
   QualType CXXCheckConditionalOperands( // C++ 5.16
 ExprResult &cond, ExprResult &lhs, ExprResult &rhs,
 ExprValueKind &VK, ExprObjectKind &OK, SourceLocation questionLoc);
-  QualType CheckGNUVectorConditionalTypes(ExprResult &Cond, ExprResult &LHS,
-  ExprResult &RHS,
-  SourceLocation QuestionLoc);
+  QualType CheckVectorConditionalTypes(ExprResult &Cond, ExprResult &LHS,
+   ExprResult &RHS,
+   SourceLocation QuestionLoc);
   QualType FindCompositePointerType(SourceLocation Loc, Expr *&E1, Expr *&E2,
 bool ConvertArgs = true);
   QualType FindCompositePointerType(SourceLocation Loc,

diff  --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 8da913035c8f..6a79d621f5de 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -5970,19 +5970,18 @@ static bool ConvertForConditional(Sema &Self, 
ExprResult &E, QualType T) {
 // extension.
 static bool isValidVectorForConditionalCondition(ASTContext &Ctx,
  QualType CondTy) {
-  if (!CondTy->isVectorType() || CondTy->isExtVectorType())
+  if (!CondTy->isVectorType() && !CondTy->isExtVectorType())
 return false;
   const QualType EltTy =
   cast(CondTy.getCanonicalType())->getElementType();
-
   assert(!EltTy->isBooleanType() && !EltTy->isEnumeralType() &&
  "Vectors cant be boolean or enum types");
   return EltTy->isIntegralType(Ctx);
 }
 
-QualType Sema::CheckGNUVectorConditionalTypes(ExprResult &Cond, ExprResult 
&LHS,
-  ExprResult &RHS,
-  SourceLocation QuestionLoc) {
+QualType Sema::CheckVectorConditionalTypes(ExprResult &Cond, ExprResult &LHS,
+   ExprResult &RHS,
+   SourceLocation QuestionLoc) {
   LHS = DefaultFunctionArray

[PATCH] D98055: [ExtVectorType] Support conditional select operator for C++.

2021-03-09 Thread Florian Hahn via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
fhahn marked an inline comment as done.
Closed by commit rGfc8d3766d721: [ExtVectorType] Support conditional select 
operator for C++. (authored by fhahn).

Changed prior to commit:
  https://reviews.llvm.org/D98055?vs=328815&id=329300#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98055

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/CodeGenCXX/ext-vector-type-conditional.cpp
  clang/test/CodeGenCXX/vector-conditional.cpp
  clang/test/CodeGenCXX/vector-size-conditional.cpp
  clang/test/SemaCXX/ext-vector-type-conditional.cpp
  clang/test/SemaCXX/vector-conditional.cpp
  clang/test/SemaCXX/vector-size-conditional.cpp

Index: clang/test/SemaCXX/ext-vector-type-conditional.cpp
===
--- clang/test/SemaCXX/ext-vector-type-conditional.cpp
+++ clang/test/SemaCXX/ext-vector-type-conditional.cpp
@@ -2,17 +2,17 @@
 // Note that this test depends on the size of long-long to be different from
 // int, so it specifies a triple.
 
-using FourShorts = short __attribute__((__vector_size__(8)));
-using TwoInts = int __attribute__((__vector_size__(8)));
-using TwoUInts = unsigned __attribute__((__vector_size__(8)));
-using FourInts = int __attribute__((__vector_size__(16)));
-using FourUInts = unsigned __attribute__((__vector_size__(16)));
-using TwoLongLong = long long __attribute__((__vector_size__(16)));
-using FourLongLong = long long __attribute__((__vector_size__(32)));
-using TwoFloats = float __attribute__((__vector_size__(8)));
-using FourFloats = float __attribute__((__vector_size__(16)));
-using TwoDoubles = double __attribute__((__vector_size__(16)));
-using FourDoubles = double __attribute__((__vector_size__(32)));
+using FourShorts = short __attribute__((ext_vector_type(4)));
+using TwoInts = int __attribute__((ext_vector_type(2)));
+using TwoUInts = unsigned __attribute__((ext_vector_type(2)));
+using FourInts = int __attribute__((ext_vector_type(4)));
+using FourUInts = unsigned __attribute__((ext_vector_type(4)));
+using TwoLongLong = long long __attribute__((ext_vector_type(2)));
+using FourLongLong = long long __attribute__((ext_vector_type(4)));
+using TwoFloats = float __attribute__((ext_vector_type(2)));
+using FourFloats = float __attribute__((ext_vector_type(4)));
+using TwoDoubles = double __attribute__((ext_vector_type(2)));
+using FourDoubles = double __attribute__((ext_vector_type(4)));
 
 FourShorts four_shorts;
 TwoInts two_ints;
@@ -55,9 +55,9 @@
   (void)(four_ints ?: four_doubles);   // expected-error {{vector operands to the vector conditional must be the same type ('FourInts' (vector of 4 'int' values) and 'FourDoubles' (vector of 4 'double' values)}}
 
   // Scalars are promoted, but must be the same element size.
-  (void)(four_ints ? 3.0f : 3.0); // expected-error {{vector condition type 'FourInts' (vector of 4 'int' values) and result type '__attribute__((__vector_size__(4 * sizeof(double double' (vector of 4 'double' values) do not have elements of the same size}}
-  (void)(four_ints ? 5ll : 5);// expected-error {{vector condition type 'FourInts' (vector of 4 'int' values) and result type '__attribute__((__vector_size__(4 * sizeof(long long long long' (vector of 4 'long long' values) do not have elements of the same size}}
-  (void)(four_ints ?: 3.0);   // expected-error {{cannot convert between scalar type 'double' and vector type 'FourInts' (vector of 4 'int' values) as implicit conversion would cause truncation}}
+  (void)(four_ints ? 3.0f : 3.0); // expected-error {{vector condition type 'FourInts' (vector of 4 'int' values) and result type 'double __attribute__((ext_vector_type(4)))' (vector of 4 'double' values) do not have elements of the same size}}
+  (void)(four_ints ? 5ll : 5);// expected-error {{vector condition type 'FourInts' (vector of 4 'int' values) and result type 'long long __attribute__((ext_vector_type(4)))' (vector of 4 'long long' values) do not have elements of the same size}}
+  (void)(four_ints ?: 3.0);   // expected-error {{annot convert between vector values of different size ('FourInts' (vector of 4 'int' values) and 'double')}}
   (void)(four_ints ?: 5ll);   // We allow this despite GCc not allowing this since we support integral->vector-integral conversions despite integer rank.
 
   // This one would be allowed in GCC, but we don't allow vectors of enum. Also,
@@ -66,7 +66,7 @@
   // the other side causes.
   (void)(four_ints ? e : e);  // expected-error {{enumeration type 'E' is not allowed in a vector conditional}}
   (void)(four_ints ? se : se);// expected-error {{enumeration type 'SE' is not allowed in a vector conditional}}
-  (void)(four_shorts ? (s

[PATCH] D98253: [clang][ARM] Refactor computeLLVMTriple code for ARM

2021-03-09 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett created this revision.
Herald added subscribers: danielkiss, kristof.beyls.
DavidSpickett requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This moves code that sets the architecture name
and Float ABI into two new functions in
ToolChains/Arch/ARM.cpp. Greatly simplifying computeLLVMTriple.

Some light refactoring in setArchNameInTriple to
move local variables closer to their first use.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98253

Files:
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/lib/Driver/ToolChains/Arch/ARM.h

Index: clang/lib/Driver/ToolChains/Arch/ARM.h
===
--- clang/lib/Driver/ToolChains/Arch/ARM.h
+++ clang/lib/Driver/ToolChains/Arch/ARM.h
@@ -51,7 +51,11 @@
 FloatABI getARMFloatABI(const ToolChain &TC, const llvm::opt::ArgList &Args);
 FloatABI getARMFloatABI(const Driver &D, const llvm::Triple &Triple,
 const llvm::opt::ArgList &Args);
+void setFloatABIInTriple(const Driver &D, const llvm::opt::ArgList &Args,
+ llvm::Triple &triple);
 ReadTPMode getReadTPMode(const Driver &D, const llvm::opt::ArgList &Args);
+void setArchNameInTriple(const Driver &D, const llvm::opt::ArgList &Args,
+ types::ID InputType, llvm::Triple &Triple);
 
 bool useAAPCSForMachO(const llvm::Triple &T);
 void getARMArchCPUFromArgs(const llvm::opt::ArgList &Args,
Index: clang/lib/Driver/ToolChains/Arch/ARM.cpp
===
--- clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -166,6 +166,132 @@
   return ReadTPMode::Soft;
 }
 
+void arm::setArchNameInTriple(const Driver &D, const ArgList &Args,
+  types::ID InputType, llvm::Triple &Triple) {
+  StringRef MCPU, MArch;
+  if (const Arg *A = Args.getLastArg(options::OPT_mcpu_EQ))
+MCPU = A->getValue();
+  if (const Arg *A = Args.getLastArg(options::OPT_march_EQ))
+MArch = A->getValue();
+
+  std::string CPU = Triple.isOSBinFormatMachO()
+? tools::arm::getARMCPUForMArch(MArch, Triple).str()
+: tools::arm::getARMTargetCPU(MCPU, MArch, Triple);
+  StringRef Suffix = tools::arm::getLLVMArchSuffixForARM(CPU, MArch, Triple);
+
+  bool IsBigEndian = Triple.getArch() == llvm::Triple::armeb ||
+ Triple.getArch() == llvm::Triple::thumbeb;
+  // Handle pseudo-target flags '-mlittle-endian'/'-EL' and
+  // '-mbig-endian'/'-EB'.
+  if (Arg *A = Args.getLastArg(options::OPT_mlittle_endian,
+   options::OPT_mbig_endian)) {
+IsBigEndian = !A->getOption().matches(options::OPT_mlittle_endian);
+  }
+  std::string ArchName = IsBigEndian ? "armeb" : "arm";
+
+  // FIXME: Thumb should just be another -target-feaure, not in the triple.
+  bool IsMProfile =
+  llvm::ARM::parseArchProfile(Suffix) == llvm::ARM::ProfileKind::M;
+  bool ThumbDefault = IsMProfile ||
+  // Thumb2 is the default for V7 on Darwin.
+  (llvm::ARM::parseArchVersion(Suffix) == 7 &&
+   Triple.isOSBinFormatMachO()) ||
+  // FIXME: this is invalid for WindowsCE
+  Triple.isOSWindows();
+
+  // Check if ARM ISA was explicitly selected (using -mno-thumb or -marm) for
+  // M-Class CPUs/architecture variants, which is not supported.
+  bool ARMModeRequested =
+  !Args.hasFlag(options::OPT_mthumb, options::OPT_mno_thumb, ThumbDefault);
+  if (IsMProfile && ARMModeRequested) {
+if (MCPU.size())
+  D.Diag(diag::err_cpu_unsupported_isa) << CPU << "ARM";
+else
+  D.Diag(diag::err_arch_unsupported_isa)
+  << tools::arm::getARMArch(MArch, Triple) << "ARM";
+  }
+
+  // Check to see if an explicit choice to use thumb has been made via
+  // -mthumb. For assembler files we must check for -mthumb in the options
+  // passed to the assembler via -Wa or -Xassembler.
+  bool IsThumb = false;
+  if (InputType != types::TY_PP_Asm)
+IsThumb =
+Args.hasFlag(options::OPT_mthumb, options::OPT_mno_thumb, ThumbDefault);
+  else {
+// Ideally we would check for these flags in
+// CollectArgsForIntegratedAssembler but we can't change the ArchName at
+// that point.
+llvm::StringRef WaMArch, WaMCPU;
+for (const auto *A :
+ Args.filtered(options::OPT_Wa_COMMA, options::OPT_Xassembler)) {
+  for (StringRef Value : A->getValues()) {
+// There is no assembler equivalent of -mno-thumb, -marm, or -mno-arm.
+if (Value == "-mthumb")
+  IsThumb = true;
+else if (Value.startswith("-march="))
+  WaMArch = Value.substr(7);
+else if (Value.startswith("-mcpu="))
+  WaMCPU = Value.substr(6);
+  }
+}
+
+if (WaMCPU.size() || WaMArch.size()

[PATCH] D98253: [clang][ARM] Refactor computeLLVMTriple code for ARM

2021-03-09 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett added a reviewer: ostannard.
DavidSpickett added a comment.

Besides the usual motivations this is prep for fixing 
https://bugs.llvm.org/show_bug.cgi?id=48894 for AArch64. Which will need a 
similar (but simpler) set of calls.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98253

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


[PATCH] D98254: Fix typo in two files in Clang

2021-03-09 Thread FusionBolt via Phabricator via cfe-commits
FusionBolt created this revision.
FusionBolt added reviewers: 01alchemist, 0b01.
FusionBolt requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98254

Files:
  clang/lib/AST/Interp/Context.h
  clang/lib/AST/Interp/Interp.h


Index: clang/lib/AST/Interp/Interp.h
===
--- clang/lib/AST/Interp/Interp.h
+++ clang/lib/AST/Interp/Interp.h
@@ -37,7 +37,7 @@
 using APInt = llvm::APInt;
 using APSInt = llvm::APSInt;
 
-/// Convers a value to an APValue.
+/// Convert a value to an APValue.
 template  bool ReturnValue(const T &V, APValue &R) {
   R = V.toAPValue();
   return true;
@@ -49,7 +49,7 @@
 /// Checks if the array is offsetable.
 bool CheckArray(InterpState &S, CodePtr OpPC, const Pointer &Ptr);
 
-/// Checks if a pointer is live and accesible.
+/// Checks if a pointer is live and accessible.
 bool CheckLive(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
AccessKinds AK);
 /// Checks if a pointer is null.
Index: clang/lib/AST/Interp/Context.h
===
--- clang/lib/AST/Interp/Context.h
+++ clang/lib/AST/Interp/Context.h
@@ -68,7 +68,7 @@
   /// Runs a function.
   bool Run(State &Parent, Function *Func, APValue &Result);
 
-  /// Checks a result fromt the interpreter.
+  /// Checks a result from the interpreter.
   bool Check(State &Parent, llvm::Expected &&R);
 
 private:


Index: clang/lib/AST/Interp/Interp.h
===
--- clang/lib/AST/Interp/Interp.h
+++ clang/lib/AST/Interp/Interp.h
@@ -37,7 +37,7 @@
 using APInt = llvm::APInt;
 using APSInt = llvm::APSInt;
 
-/// Convers a value to an APValue.
+/// Convert a value to an APValue.
 template  bool ReturnValue(const T &V, APValue &R) {
   R = V.toAPValue();
   return true;
@@ -49,7 +49,7 @@
 /// Checks if the array is offsetable.
 bool CheckArray(InterpState &S, CodePtr OpPC, const Pointer &Ptr);
 
-/// Checks if a pointer is live and accesible.
+/// Checks if a pointer is live and accessible.
 bool CheckLive(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
AccessKinds AK);
 /// Checks if a pointer is null.
Index: clang/lib/AST/Interp/Context.h
===
--- clang/lib/AST/Interp/Context.h
+++ clang/lib/AST/Interp/Context.h
@@ -68,7 +68,7 @@
   /// Runs a function.
   bool Run(State &Parent, Function *Func, APValue &Result);
 
-  /// Checks a result fromt the interpreter.
+  /// Checks a result from the interpreter.
   bool Check(State &Parent, llvm::Expected &&R);
 
 private:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98255: [release][docs] List all cores Arm has added support for in LLVM 12.

2021-03-09 Thread Amilendra Kodithuwakku via Phabricator via cfe-commits
amilendra created this revision.
amilendra added reviewers: willlovett, kristof.beyls, jgreenhalgh.
amilendra added a project: clang.
amilendra requested review of this revision.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98255

Files:
  clang/docs/ReleaseNotes.rst


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -130,6 +130,15 @@
   This behavior matches newer GCC.
   (`D91760 `_)
   (`D92054 `_)
+- Support has been added for the following processors (command-line identifiers
+  in parentheses):
+  - Arm Cortex-A78C (cortex-a78c).
+  - Arm Cortex-R82 (cortex-r82).
+  - Arm Neoverse V1 (neoverse-v1).
+  - Arm Neoverse N2 (neoverse-n2).
+  - Fujitsu A64FX (a64fx).
+  For example, to select architecture support and tuning for Neoverse-V1 based
+  systems, use ``-mcpu=neoverse-v1``.
 
 Removed Compiler Flags
 -


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -130,6 +130,15 @@
   This behavior matches newer GCC.
   (`D91760 `_)
   (`D92054 `_)
+- Support has been added for the following processors (command-line identifiers
+  in parentheses):
+  - Arm Cortex-A78C (cortex-a78c).
+  - Arm Cortex-R82 (cortex-r82).
+  - Arm Neoverse V1 (neoverse-v1).
+  - Arm Neoverse N2 (neoverse-n2).
+  - Fujitsu A64FX (a64fx).
+  For example, to select architecture support and tuning for Neoverse-V1 based
+  systems, use ``-mcpu=neoverse-v1``.
 
 Removed Compiler Flags
 -
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97951: [Sema] Fix diagnostics for one-byte length modifier

2021-03-09 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!


Repository:
  rC Clang

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

https://reviews.llvm.org/D97951

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


[PATCH] D89942: Disable LTO and LLD for bootstrap builds on systems unsupported by LLD

2021-03-09 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 329309.
tbaeder added a comment.

Just re-tested this on a SystemZ machine and found that the `set()` in 
`clang/CMakeLists.txt` were not actually being applied. I also made it disable 
LLD on SystemZ as well, as you suggested. And I added a warning when 
`BOOTSTRAP_LLVM_ENABLE_LLD` is `TRUE` but lld is not in `LLVM_ENABLE_PROJECTS`


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

https://reviews.llvm.org/D89942

Files:
  clang/CMakeLists.txt
  clang/cmake/caches/3-stage-base.cmake


Index: clang/cmake/caches/3-stage-base.cmake
===
--- clang/cmake/caches/3-stage-base.cmake
+++ clang/cmake/caches/3-stage-base.cmake
@@ -1,16 +1,6 @@
 set(CMAKE_BUILD_TYPE RELEASE CACHE STRING "")
 set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
 set(LLVM_BUILD_EXTERNAL_COMPILER_RT ON CACHE BOOL "")
-set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
-
-# Use LLD do have less requirements on system linker, unless we're on an apple
-# platform where the system compiler is to be prefered.
-if(APPLE)
-set(BOOTSTRAP_LLVM_ENABLE_LLD OFF CACHE BOOL "")
-else()
-set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
-endif()
-
 
 set(CLANG_BOOTSTRAP_TARGETS
   clang
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -635,7 +635,29 @@
   set(STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-stamps/)
   set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-bins/)
 
+  # We want LLD for LTO, but LLD does not support SystemZ, so disable
+  # LTO here and use the installed system linker
+  if ("${LLVM_NATIVE_ARCH}" MATCHES "SystemZ")
+message(STATUS "Disabling LTO and LLD for stage3 builds since LLD does not 
support ${LLVM_NATIVE_ARCH}")
+set(BOOTSTRAP_LLVM_ENABLE_LLD OFF CACHE BOOL "" FORCE)
+set(BOOTSTRAP_LLVM_ENABLE_LTO OFF CACHE BOOL "" FORCE)
+  elseif(APPLE)
+# Use LLD to have fewer requirements on system linker, unless we're on an 
apple
+# platform where the system compiler is to be preferred
+message(STATUS "Using system linker for stage3 builds on Apple")
+set(BOOTSTRAP_LLVM_ENABLE_LLD OFF CACHE BOOL "" FORCE)
+  else()
+set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "" FORCE)
+set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "" FORCE)
+  endif()
+  message(STATUS "Stage3 builds: LLD: ${BOOTSTRAP_LLVM_ENABLE_LLD}. LTO: 
${BOOTSTRAP_LLVM_ENABLE_LTO}")
+
   if(BOOTSTRAP_LLVM_ENABLE_LLD)
+# adding lld to clang-bootstrap-deps without having it enabled in
+# LLVM_ENABLE_PROJECTS just generates a cryptic error message.
+if (NOT "lld" IN_LIST LLVM_ENABLE_PROJECTS)
+  message(FATAL_ERROR "LLD is enabled in the boostrap build, but lld is 
not in LLVM_ENABLE_PROJECTS")
+endif()
 add_dependencies(clang-bootstrap-deps lld)
   endif()
 


Index: clang/cmake/caches/3-stage-base.cmake
===
--- clang/cmake/caches/3-stage-base.cmake
+++ clang/cmake/caches/3-stage-base.cmake
@@ -1,16 +1,6 @@
 set(CMAKE_BUILD_TYPE RELEASE CACHE STRING "")
 set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
 set(LLVM_BUILD_EXTERNAL_COMPILER_RT ON CACHE BOOL "")
-set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
-
-# Use LLD do have less requirements on system linker, unless we're on an apple
-# platform where the system compiler is to be prefered.
-if(APPLE)
-set(BOOTSTRAP_LLVM_ENABLE_LLD OFF CACHE BOOL "")
-else()
-set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
-endif()
-
 
 set(CLANG_BOOTSTRAP_TARGETS
   clang
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -635,7 +635,29 @@
   set(STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-stamps/)
   set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-bins/)
 
+  # We want LLD for LTO, but LLD does not support SystemZ, so disable
+  # LTO here and use the installed system linker
+  if ("${LLVM_NATIVE_ARCH}" MATCHES "SystemZ")
+message(STATUS "Disabling LTO and LLD for stage3 builds since LLD does not support ${LLVM_NATIVE_ARCH}")
+set(BOOTSTRAP_LLVM_ENABLE_LLD OFF CACHE BOOL "" FORCE)
+set(BOOTSTRAP_LLVM_ENABLE_LTO OFF CACHE BOOL "" FORCE)
+  elseif(APPLE)
+# Use LLD to have fewer requirements on system linker, unless we're on an apple
+# platform where the system compiler is to be preferred
+message(STATUS "Using system linker for stage3 builds on Apple")
+set(BOOTSTRAP_LLVM_ENABLE_LLD OFF CACHE BOOL "" FORCE)
+  else()
+set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "" FORCE)
+set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "" FORCE)
+  endif()
+  message(STATUS "Stage3 builds: LLD: ${BOOTSTRAP_LLVM_ENABLE_LLD}. LTO: ${BOOTSTRAP_LLVM_ENABLE_LTO}")
+
   if(BOOTSTRAP_LLVM_ENABLE_LLD)
+# adding lld to clang-bootstrap-deps without 

[PATCH] D98246: [clangd] Add basic monitoring info request for remote index server

2021-03-09 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 329312.
kbobyrev added a comment.
Herald added subscribers: llvm-commits, mgorny.
Herald added a project: LLVM.

Use reflection, improve message format.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98246

Files:
  clang-tools-extra/clangd/index/remote/Service.proto
  clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/server/Server.cpp
  llvm/cmake/modules/FindGRPC.cmake

Index: llvm/cmake/modules/FindGRPC.cmake
===
--- llvm/cmake/modules/FindGRPC.cmake
+++ llvm/cmake/modules/FindGRPC.cmake
@@ -22,6 +22,8 @@
   add_library(protobuf ALIAS protobuf::libprotobuf)
   set_target_properties(gRPC::grpc++ PROPERTIES IMPORTED_GLOBAL TRUE)
   add_library(grpc++ ALIAS gRPC::grpc++)
+  set_target_properties(gRPC::grpc++_reflection PROPERTIES IMPORTED_GLOBAL TRUE)
+  add_library(grpc++_reflection ALIAS gRPC::grpc++_reflection)
 
   set(GRPC_CPP_PLUGIN $)
   set(PROTOC ${Protobuf_PROTOC_EXECUTABLE})
@@ -71,6 +73,9 @@
   add_library(grpc++ UNKNOWN IMPORTED GLOBAL)
   message(STATUS "Using grpc++: " ${GRPC_LIBRARY})
   set_target_properties(grpc++ PROPERTIES IMPORTED_LOCATION ${GRPC_LIBRARY})
+  find_library(GRPC_REFLECTION_LIBRARY grpc++_reflection $GRPC_OPTS REQUIRED)
+  add_library(grpc++_reflection UNKNOWN IMPORTED GLOBAL)
+  set_target_properties(grpc++_reflection PROPERTIES IMPORTED_LOCATION ${GRPC_REFLECTION_LIBRARY})
   find_library(PROTOBUF_LIBRARY protobuf $PROTOBUF_OPTS REQUIRED)
   message(STATUS "Using protobuf: " ${PROTOBUF_LIBRARY})
   add_library(protobuf UNKNOWN IMPORTED GLOBAL)
Index: clang-tools-extra/clangd/index/remote/server/Server.cpp
===
--- clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -30,6 +30,7 @@
 #include "llvm/Support/VirtualFileSystem.h"
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -90,7 +91,7 @@
 class RemoteIndexServer final : public v1::SymbolIndex::Service {
 public:
   RemoteIndexServer(clangd::SymbolIndex &Index, llvm::StringRef IndexRoot)
-  : Index(Index) {
+  : Index(Index), ServiceStartTime(std::chrono::system_clock::now()) {
 llvm::SmallString<256> NativePath = IndexRoot;
 llvm::sys::path::native(NativePath);
 ProtobufMarshaller = std::unique_ptr(new Marshaller(
@@ -279,8 +280,23 @@
 Millis);
   }
 
+  grpc::Status MonitoringInfo(grpc::ServerContext *Context,
+  const google::protobuf::Empty *Request,
+  v1::MonitoringInfoReply *Reply) override {
+auto Uptime = std::chrono::duration_cast(
+  std::chrono::system_clock::now() - ServiceStartTime)
+  .count();
+Reply->set_info(llvm::formatv(
+"Service started at {0:%Y-%m-%d %H:%M:%S}. Uptime: {1} h {2} m.",
+ServiceStartTime, Uptime / 60, Uptime % 60));
+logRequest(*Request);
+logResponse(*Reply);
+return grpc::Status::OK;
+  }
+
   std::unique_ptr ProtobufMarshaller;
   clangd::SymbolIndex &Index;
+  llvm::sys::TimePoint<> ServiceStartTime;
 };
 
 // Detect changes in \p IndexPath file and load new versions of the index
@@ -313,6 +329,7 @@
   RemoteIndexServer Service(Index, IndexRoot);
 
   grpc::EnableDefaultHealthCheckService(true);
+  grpc::reflection::InitProtoReflectionServerBuilderPlugin();
   grpc::ServerBuilder Builder;
   Builder.AddListeningPort(ServerAddress.str(),
grpc::InsecureServerCredentials());
Index: clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
===
--- clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
+++ clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
@@ -17,4 +17,6 @@
   RemoteIndexProto
   RemoteIndexServiceProto
   clangdRemoteMarshalling
+
+  grpc++_reflection
   )
Index: clang-tools-extra/clangd/index/remote/Service.proto
===
--- clang-tools-extra/clangd/index/remote/Service.proto
+++ clang-tools-extra/clangd/index/remote/Service.proto
@@ -10,8 +10,11 @@
 
 package clang.clangd.remote.v1;
 
+import "google/protobuf/empty.proto";
 import "Index.proto";
 
+message MonitoringInfoReply { optional string info = 1; }
+
 // Semantics of SymbolIndex match clangd::SymbolIndex with all required
 // structures corresponding to their clangd::* counterparts.
 service SymbolIndex {
@@ -22,5 +25,7 @@
   rpc Refs(RefsRequest) returns (stream RefsReply) {}
 
   rpc Relations(RelationsRequest) returns (stream RelationsReply) {}
+
+  rpc MonitoringInfo(google.protobuf.Empty) returns (MonitoringInfoReply) {}
 }
 
___
cfe-commits mailing list
cfe-commits@l

[PATCH] D93095: Introduce -Wreserved-identifier

2021-03-09 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 329318.
serge-sans-paille added a comment.

Updated error message to report the reason why an identifier is reserved.


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

https://reviews.llvm.org/D93095

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Decl.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/Sema/reserved-identifier.c
  clang/test/Sema/reserved-identifier.cpp

Index: clang/test/Sema/reserved-identifier.cpp
===
--- /dev/null
+++ clang/test/Sema/reserved-identifier.cpp
@@ -0,0 +1,82 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++20 -verify -Wreserved-identifier %s
+
+int foo__bar() { return 0; }// expected-warning {{'foo__bar' is a reserved identifier}}
+static int _bar() { return 0; } // expected-warning {{'_bar' is a reserved identifier}}
+static int _Bar() { return 0; } // expected-warning {{'_Bar' is a reserved identifier}}
+int _barbouille() { return 0; } // expected-warning {{'_barbouille' is a reserved identifier}}
+
+void foo(unsigned int _Reserved) { // expected-warning {{'_Reserved' is a reserved identifier}}
+  unsigned int __1 =   // expected-warning {{'__1' is a reserved identifier}}
+  _Reserved;   // no-warning
+}
+
+// This one is explicitly skipped by -Wreserved-identifier
+void *_; // no-warning
+
+template  constexpr bool __toucan = true; // expected-warning {{'__toucan' is a reserved identifier}}
+
+template 
+concept _Barbotine = __toucan; // expected-warning {{'_Barbotine' is a reserved identifier}}
+
+template  // expected-warning {{'__' is a reserved identifier}}
+struct BarbeNoire {};
+
+template  // expected-warning {{'__' is a reserved identifier}}
+void BarbeRousse() {}
+
+namespace _Barbidur { // expected-warning {{'_Barbidur' is a reserved identifier}}
+
+struct __barbidou {}; // expected-warning {{'__barbidou' is a reserved identifier}}
+struct _barbidou {};  // no-warning
+
+int __barbouille; // expected-warning {{'__barbouille' is a reserved identifier}}
+int _barbouille;  // no-warning
+
+int __babar() { return 0; } // expected-warning {{'__babar' is a reserved identifier}}
+int _babar() { return 0; }  // no-warning
+
+} // namespace _Barbidur
+
+class __barbapapa { // expected-warning {{'__barbapapa' is a reserved identifier}}
+  void _barbabelle() {} // no-warning
+  int _Barbalala;   // expected-warning {{'_Barbalala' is a reserved identifier}}
+};
+
+enum class __menu { // expected-warning {{'__menu' is a reserved identifier}}
+  __some,   // expected-warning {{'__some' is a reserved identifier}}
+  _Other,   // expected-warning {{'_Other' is a reserved identifier}}
+  _other// no-warning
+};
+
+enum _Menu { // expected-warning {{'_Menu' is a reserved identifier}}
+  _OtheR_,   // expected-warning {{'_OtheR_' is a reserved identifier}}
+  _other_// expected-warning {{'_other_' is a reserved identifier}}
+};
+
+enum {
+  __some, // expected-warning {{'__some' is a reserved identifier}}
+  _Other, // expected-warning {{'_Other' is a reserved identifier}}
+  _other  // expected-warning {{'_other' is a reserved identifier}}
+};
+
+static union {
+  int _barbeFleurie; // no-warning
+};
+
+using _Barbamama = __barbapapa; // expected-warning {{'_Barbamama' is a reserved identifier}}
+
+int foobar() {
+  return foo__bar(); // no-warning
+}
+
+namespace {
+int _barbatruc; // no-warning
+}
+
+long double operator"" _BarbeBleue(long double) // no-warning
+{
+  return 0.;
+}
+
+struct _BarbeRouge {} p; // expected-warning {{'_BarbeRouge' is a reserved identifier}}
+struct _BarbeNoire {}* q; // expected-warning {{'_BarbeNoire' is a reserved identifier}}
Index: clang/test/Sema/reserved-identifier.c
===
--- /dev/null
+++ clang/test/Sema/reserved-identifier.c
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wreserved-identifier -Wno-visibility %s
+
+#define __oof foo__ // expected-warning {{macro name is a reserved identifier}}
+
+int foo__bar() { return 0; }// no-warning
+static int _bar() { return 0; } // expected-warning {{'_bar' is a reserved identifier}}
+static int _Bar() { return 0; } // expected-warning {{'_Bar' is a reserved identifier}}
+int _foo() { return 0; }// expected-warning {{'_foo' is a reserved identifier}}
+
+// This one is explicitly skipped by -Wreserved-identifier
+void *_; // no-warning
+
+void foo(unsigned int _Reserved) { // expected-warning {{'_Reserved' is a reserved identifier}}
+  unsigned int __1 =   // expected-warning {{'__1' is a reserved identifier}}
+  _Reserved;   // no-warning
+  goto __rese

[clang-tools-extra] 0250b05 - [clangd] Add a Filesystem that overlays Dirty files.

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

Author: Nathan James
Date: 2021-03-09T14:35:21Z
New Revision: 0250b053b5aa7fc16408e6c037e5e71db5e9b012

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

LOG: [clangd] Add a Filesystem that overlays Dirty files.

Create a `ThreadsafeFS` in the `DraftStore` that overlays the dirty file 
contents over another `ThreadsafeFS`.
This provides a nice thread-safe interface for using dirty file contents 
throughout the codebase, for example cross file refactoring.
Creating a Filesystem view will overlay a snapshot of the current contents, so 
if the draft store is updated while the view is being used, it will contain 
stale contents.

Reviewed By: sammccall

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

Added: 


Modified: 
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/ClangdServer.h
clang-tools-extra/clangd/DraftStore.cpp
clang-tools-extra/clangd/DraftStore.h
clang-tools-extra/clangd/unittests/DraftStoreTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp 
b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index df5377d77f2b..8875f85c8b70 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -666,8 +666,9 @@ void ClangdLSPServer::onDocumentDidChange(
 log("Trying to incrementally change non-added document: {0}", File);
 return;
   }
+  std::string NewCode(*Code);
   for (const auto &Change : Params.contentChanges) {
-if (auto Err = applyChange(*Code, Change)) {
+if (auto Err = applyChange(NewCode, Change)) {
   // If this fails, we are most likely going to be not in sync anymore with
   // the client.  It is better to remove the draft and let further
   // operations fail rather than giving wrong results.
@@ -676,7 +677,7 @@ void ClangdLSPServer::onDocumentDidChange(
   return;
 }
   }
-  Server->addDocument(File, *Code, encodeVersion(Params.textDocument.version),
+  Server->addDocument(File, NewCode, 
encodeVersion(Params.textDocument.version),
   WantDiags, Params.forceRebuild);
 }
 

diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index cbd9677f340c..9a5f4bce2e21 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -106,6 +106,23 @@ struct UpdateIndexCallbacks : public ParsingCallbacks {
   ClangdServer::Callbacks *ServerCallbacks;
 };
 
+class DraftStoreFS : public ThreadsafeFS {
+public:
+  DraftStoreFS(const ThreadsafeFS &Base, const DraftStore &Drafts)
+  : Base(Base), DirtyFiles(Drafts) {}
+
+private:
+  llvm::IntrusiveRefCntPtr viewImpl() const override {
+auto OFS = llvm::makeIntrusiveRefCnt(
+Base.view(llvm::None));
+OFS->pushOverlay(DirtyFiles.asVFS());
+return OFS;
+  }
+
+  const ThreadsafeFS &Base;
+  const DraftStore &DirtyFiles;
+};
+
 } // namespace
 
 ClangdServer::Options ClangdServer::optsForTest() {
@@ -132,7 +149,8 @@ ClangdServer::ClangdServer(const GlobalCompilationDatabase 
&CDB,
 : FeatureModules(Opts.FeatureModules), CDB(CDB), TFS(TFS),
   DynamicIdx(Opts.BuildDynamicSymbolIndex ? new FileIndex() : nullptr),
   ClangTidyProvider(Opts.ClangTidyProvider),
-  WorkspaceRoot(Opts.WorkspaceRoot) {
+  WorkspaceRoot(Opts.WorkspaceRoot),
+  DirtyFS(std::make_unique(TFS, DraftMgr)) {
   // Pass a callback into `WorkScheduler` to extract symbols from a newly
   // parsed file and rebuild the file index synchronously each time an AST
   // is parsed.
@@ -220,14 +238,14 @@ void ClangdServer::reparseOpenFilesIfNeeded(
   for (const Path &FilePath : DraftMgr.getActiveFiles())
 if (Filter(FilePath))
   if (auto Draft = DraftMgr.getDraft(FilePath)) // else disappeared in 
race?
-addDocument(FilePath, std::move(Draft->Contents), Draft->Version,
+addDocument(FilePath, *Draft->Contents, Draft->Version,
 WantDiagnostics::Auto);
 }
 
-llvm::Optional ClangdServer::getDraft(PathRef File) const {
+std::shared_ptr ClangdServer::getDraft(PathRef File) const {
   auto Draft = DraftMgr.getDraft(File);
   if (!Draft)
-return llvm::None;
+return nullptr;
   return std::move(Draft->Contents);
 }
 

diff  --git a/clang-tools-extra/clangd/ClangdServer.h 
b/clang-tools-extra/clangd/ClangdServer.h
index 5254bfe78b71..152aa5a49e8b 100644
--- a/clang-tools-extra/clangd/ClangdServer.h
+++ b/clang-tools-extra/clangd/ClangdServer.h
@@ -348,7 +348,9 @@ class ClangdServer {
   /// FIXME: those metrics might be useful too, we should add them.
   llvm::StringMap fileStats() const;
 
-  llvm::Optional getDraft(PathRef File) const;
+  /// Gets the contents of a currently

[PATCH] D94554: [clangd] Add a Filesystem that overlays Dirty files.

2021-03-09 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0250b053b5aa: [clangd] Add a Filesystem that overlays Dirty 
files. (authored by njames93).

Changed prior to commit:
  https://reviews.llvm.org/D94554?vs=329070&id=329319#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94554

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/DraftStore.cpp
  clang-tools-extra/clangd/DraftStore.h
  clang-tools-extra/clangd/unittests/DraftStoreTests.cpp

Index: clang-tools-extra/clangd/unittests/DraftStoreTests.cpp
===
--- clang-tools-extra/clangd/unittests/DraftStoreTests.cpp
+++ clang-tools-extra/clangd/unittests/DraftStoreTests.cpp
@@ -24,20 +24,20 @@
 
   EXPECT_EQ("25", DS.addDraft(File, "25", ""));
   EXPECT_EQ("25", DS.getDraft(File)->Version);
-  EXPECT_EQ("", DS.getDraft(File)->Contents);
+  EXPECT_EQ("", *DS.getDraft(File)->Contents);
 
   EXPECT_EQ("26", DS.addDraft(File, "", "x"));
   EXPECT_EQ("26", DS.getDraft(File)->Version);
-  EXPECT_EQ("x", DS.getDraft(File)->Contents);
+  EXPECT_EQ("x", *DS.getDraft(File)->Contents);
 
   EXPECT_EQ("27", DS.addDraft(File, "", "x")) << "no-op change";
   EXPECT_EQ("27", DS.getDraft(File)->Version);
-  EXPECT_EQ("x", DS.getDraft(File)->Contents);
+  EXPECT_EQ("x", *DS.getDraft(File)->Contents);
 
   // We allow versions to go backwards.
   EXPECT_EQ("7", DS.addDraft(File, "7", "y"));
   EXPECT_EQ("7", DS.getDraft(File)->Version);
-  EXPECT_EQ("y", DS.getDraft(File)->Contents);
+  EXPECT_EQ("y", *DS.getDraft(File)->Contents);
 }
 
 } // namespace
Index: clang-tools-extra/clangd/DraftStore.h
===
--- clang-tools-extra/clangd/DraftStore.h
+++ clang-tools-extra/clangd/DraftStore.h
@@ -13,6 +13,7 @@
 #include "support/Path.h"
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/StringMap.h"
+#include "llvm/Support/VirtualFileSystem.h"
 #include 
 #include 
 #include 
@@ -27,7 +28,7 @@
 class DraftStore {
 public:
   struct Draft {
-std::string Contents;
+std::shared_ptr Contents;
 std::string Version;
   };
 
@@ -47,9 +48,15 @@
   /// Remove the draft from the store.
   void removeDraft(PathRef File);
 
+  llvm::IntrusiveRefCntPtr asVFS() const;
+
 private:
+  struct DraftAndTime {
+Draft Draft;
+std::time_t MTime;
+  };
   mutable std::mutex Mutex;
-  llvm::StringMap Drafts;
+  llvm::StringMap Drafts;
 };
 
 } // namespace clangd
Index: clang-tools-extra/clangd/DraftStore.cpp
===
--- clang-tools-extra/clangd/DraftStore.cpp
+++ clang-tools-extra/clangd/DraftStore.cpp
@@ -11,6 +11,8 @@
 #include "support/Logger.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/Errc.h"
+#include "llvm/Support/VirtualFileSystem.h"
+#include 
 
 namespace clang {
 namespace clangd {
@@ -22,7 +24,7 @@
   if (It == Drafts.end())
 return None;
 
-  return It->second;
+  return It->second.Draft;
 }
 
 std::vector DraftStore::getActiveFiles() const {
@@ -75,10 +77,11 @@
  llvm::StringRef Contents) {
   std::lock_guard Lock(Mutex);
 
-  Draft &D = Drafts[File];
-  updateVersion(D, Version);
-  D.Contents = Contents.str();
-  return D.Version;
+  auto &D = Drafts[File];
+  updateVersion(D.Draft, Version);
+  std::time(&D.MTime);
+  D.Draft.Contents = std::make_shared(Contents);
+  return D.Draft.Version;
 }
 
 void DraftStore::removeDraft(PathRef File) {
@@ -87,5 +90,39 @@
   Drafts.erase(File);
 }
 
+namespace {
+
+/// A read only MemoryBuffer shares ownership of a ref counted string. The
+/// shared string object must not be modified while an owned by this buffer.
+class SharedStringBuffer : public llvm::MemoryBuffer {
+  const std::shared_ptr BufferContents;
+  const std::string Name;
+
+public:
+  BufferKind getBufferKind() const override {
+return MemoryBuffer::MemoryBuffer_Malloc;
+  }
+
+  StringRef getBufferIdentifier() const override { return Name; }
+
+  SharedStringBuffer(std::shared_ptr Data, StringRef Name)
+  : BufferContents(std::move(Data)), Name(Name) {
+assert(BufferContents && "Can't create from empty shared_ptr");
+MemoryBuffer::init(BufferContents->c_str(),
+   BufferContents->c_str() + BufferContents->size(),
+   /*RequiresNullTerminator=*/true);
+  }
+};
+} // namespace
+
+llvm::IntrusiveRefCntPtr DraftStore::asVFS() const {
+  auto MemFS = llvm::makeIntrusiveRefCnt();
+  std::lock_guard Guard(Mutex);
+  for (const auto &Draft : Drafts)
+MemFS->addFile(Draft.getKey(), Draft.getValue().MTime,
+   std::make_unique(
+   Draft.getValue().Draft.Contents, Draft.getKey()));
+  return MemFS;
+}
 } // n

[PATCH] D89986: [AIX] do not emit visibility attribute into IR when there is -mignore-xcoff-visibility

2021-03-09 Thread Digger Lin via Phabricator via cfe-commits
DiggerLin updated this revision to Diff 329316.
DiggerLin added a comment.

slight change , move to

  if (Opts.IgnoreXCOFFVisibility)
GenerateArg(Args, OPT_mignore_xcoff_visibility, SA);

to position as comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89986

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/LangOptions.def
  clang/lib/AST/Decl.cpp
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/aix-ignore-xcoff-visibility.cpp
  clang/test/CodeGen/aix-visibility-inlines-hidden.cpp

Index: clang/test/CodeGen/aix-visibility-inlines-hidden.cpp
===
--- /dev/null
+++ clang/test/CodeGen/aix-visibility-inlines-hidden.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -mcmodel=large -emit-llvm -o - -x c++ %s  | \
+// RUN: FileCheck -check-prefix=NOVISIBILITY-IR %s
+
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -mcmodel=large \
+// RUN:-fvisibility-inlines-hidden -emit-llvm -o - -x c++ %s  | \
+// RUN: FileCheck -check-prefix=NOVISIBILITY-IR %s
+
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -mcmodel=large -fvisibility-inlines-hidden \
+// RUN:-fvisibility default -emit-llvm -o - -x c++ %s  | \
+// RUN: FileCheck -check-prefix=VISIBILITY-IR %s
+
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -mcmodel=large -mignore-xcoff-visibility -emit-llvm \
+// RUN:-fvisibility-inlines-hidden -fvisibility default -o - -x c++ %s  | \
+// RUN: FileCheck -check-prefix=NOVISIBILITY-IR %s
+
+int x = 66;
+__attribute__((__noinline__)) inline void f() {
+  x = 55;
+}
+
+#pragma GCC visibility push(hidden)
+__attribute__((__noinline__)) inline void foo() {
+  x = 55;
+}
+#pragma GCC visibility pop
+
+int bar() {
+  f();
+  foo();
+  return x;
+}
+
+// VISIBILITY-IR: define linkonce_odr hidden void @_Z1fv()
+// NOVISIBILITY-IR:   define linkonce_odr void @_Z1fv()
+
+// VISIBILITY-IR: define linkonce_odr hidden void @_Z3foov()
+// NOVISIBILITY-IR:   define linkonce_odr void @_Z3foov()
Index: clang/test/CodeGen/aix-ignore-xcoff-visibility.cpp
===
--- clang/test/CodeGen/aix-ignore-xcoff-visibility.cpp
+++ clang/test/CodeGen/aix-ignore-xcoff-visibility.cpp
@@ -1,26 +1,19 @@
-// REQUIRES: powerpc-registered-target
-// RUN: %clang_cc1 -triple powerpc-unknown-aix -o - -x c++ -S  %s  |\
-// RUN:   FileCheck --check-prefix=IGNOREVISIBILITY-ASM %s
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -emit-llvm -o - -x c++ %s  | \
+// RUN: FileCheck -check-prefix=NOVISIBILITY-IR %s
 
-// RUN: %clang_cc1 -triple powerpc-unknown-aix -mignore-xcoff-visibility -o - -x c++ -S %s  | \
-// RUN: FileCheck -check-prefix=IGNOREVISIBILITY-ASM %s
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -emit-llvm -round-trip-args -o - -x c++ %s  | \
+// RUN: FileCheck -check-prefix=NOVISIBILITY-IR %s
 
-// RUN: %clang_cc1 -triple powerpc-unknown-aix -mignore-xcoff-visibility -fvisibility default -o - -x c++ -S %s  | \
-// RUN: FileCheck -check-prefix=IGNOREVISIBILITY-ASM %s
-
-// RUN: %clang_cc1 -triple powerpc-unknown-aix -fvisibility default -o - -x c++ -S %s  | \
-// RUN: FileCheck -check-prefix=VISIBILITY-ASM %s
-
-// RUN: %clang_cc1 -triple powerpc-unknown-aix -mignore-xcoff-visibility -fvisibility default -o - -x c++ -S %s  | \
-// RUN: FileCheck -check-prefix=IGNOREVISIBILITY-ASM %s
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -mignore-xcoff-visibility -fvisibility default -emit-llvm -o - -x c++ %s  | \
+// RUN: FileCheck -check-prefix=NOVISIBILITY-IR %s
 
-// RUN: %clang_cc1 -triple powerpc-unknown-aix -fvisibility default -o - -x c++ -S %s  | \
-// RUN: FileCheck -check-prefix=VISIBILITY-ASM %s
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -mignore-xcoff-visibility -fvisibility default -emit-llvm -round-trip-args -o - -x c++ %s  | \
+// RUN: FileCheck -check-prefix=NOVISIBILITY-IR %s
 
-// RUN: %clang_cc1 -triple powerpc-unknown-aix -mignore-xcoff-visibility -fvisibility default -emit-llvm -o - -x c++ %s  | \
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -fvisibility default -emit-llvm -o - -x c++ %s  | \
 // RUN: FileCheck -check-prefix=VISIBILITY-IR %s
 
-// RUN: %clang_cc1 -triple powerpc-unknown-aix -fvisibility default -emit-llvm -o - -x c++ %s  | \
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -fvisibility default -round-trip-args -emit-llvm -o - -x c++ %s  | \
 // RUN: FileCheck -check-prefix=VISIBILITY-IR %s
 
 __attribute__((visibility("hidden"))) void foo_h(int *p) {
@@ -70,28 +63,11 @@
 // VISIBILITY-IR:define weak_odr protected i32 @_ZN5basicIiE7getdataEv(%class.basic* {{[^,]*}} %this)
 // VISIBILITY-IR:define hidden void @_Z7prambarv()
 
-// VISIBILITY-ASM: .globl  _Z5foo_hPi[DS],hidden
-// VISIBILITY-ASM: .globl  ._Z5foo_hPi,hidden
-// VISIBILITY-ASM: .globl  _Z3

[clang-tools-extra] 574663f - [clangd][NFC] Silence some buildbot warnings after 0250b053

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

Author: Nathan James
Date: 2021-03-09T14:55:55Z
New Revision: 574663f9d522420be7a67d9c55728af8330e1dd3

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

LOG: [clangd][NFC] Silence some buildbot warnings after 0250b053

https://reviews.llvm.org/D94554 introduced code which wont compile with some 
build flags due to a field having the same identifier as a type.

clang-tools-extra/clangd/DraftStore.h:55:11: error: declaration of 
‘clang::clangd::DraftStore::Draft 
clang::clangd::DraftStore::DraftAndTime::Draft’ changes meaning of ‘Draft’ 
[-fpermissive]
   55 | Draft Draft;
  |   ^
clang-tools-extra/clangd/DraftStore.h:30:10: note: ‘Draft’ declared here as 
‘struct clang::clangd::DraftStore::Draft’
   30 |   struct Draft {
 |  ^

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/DraftStore.cpp 
b/clang-tools-extra/clangd/DraftStore.cpp
index b640f88f5773..e040d1ee93d6 100644
--- a/clang-tools-extra/clangd/DraftStore.cpp
+++ b/clang-tools-extra/clangd/DraftStore.cpp
@@ -24,7 +24,7 @@ llvm::Optional 
DraftStore::getDraft(PathRef File) const {
   if (It == Drafts.end())
 return None;
 
-  return It->second.Draft;
+  return It->second.D;
 }
 
 std::vector DraftStore::getActiveFiles() const {
@@ -78,10 +78,10 @@ std::string DraftStore::addDraft(PathRef File, 
llvm::StringRef Version,
   std::lock_guard Lock(Mutex);
 
   auto &D = Drafts[File];
-  updateVersion(D.Draft, Version);
+  updateVersion(D.D, Version);
   std::time(&D.MTime);
-  D.Draft.Contents = std::make_shared(Contents);
-  return D.Draft.Version;
+  D.D.Contents = std::make_shared(Contents);
+  return D.D.Version;
 }
 
 void DraftStore::removeDraft(PathRef File) {
@@ -121,7 +121,7 @@ llvm::IntrusiveRefCntPtr 
DraftStore::asVFS() const {
   for (const auto &Draft : Drafts)
 MemFS->addFile(Draft.getKey(), Draft.getValue().MTime,
std::make_unique(
-   Draft.getValue().Draft.Contents, Draft.getKey()));
+   Draft.getValue().D.Contents, Draft.getKey()));
   return MemFS;
 }
 } // namespace clangd

diff  --git a/clang-tools-extra/clangd/DraftStore.h 
b/clang-tools-extra/clangd/DraftStore.h
index ff3056e41c29..6b50b23995a0 100644
--- a/clang-tools-extra/clangd/DraftStore.h
+++ b/clang-tools-extra/clangd/DraftStore.h
@@ -52,7 +52,7 @@ class DraftStore {
 
 private:
   struct DraftAndTime {
-Draft Draft;
+Draft D;
 std::time_t MTime;
   };
   mutable std::mutex Mutex;



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


[clang] 272bcd0 - [clang][sema][NFC] Remove a superfluous semicolon

2021-03-09 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2021-03-09T16:14:07+01:00
New Revision: 272bcd0eeff5297eea5a25223d169dcd44b06ba6

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

LOG: [clang][sema][NFC] Remove a superfluous semicolon

Silences a GCC warning:

clang/lib/Sema/SemaChecking.cpp:4506:2: warning: extra ‘;’ [-Wpedantic]
 };
  ^

Added: 


Modified: 
clang/lib/Sema/SemaChecking.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 92f8d11d54fe..fef6a9306eaf 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -4503,7 +4503,7 @@ void Sema::CheckArgAlignment(SourceLocation Loc, 
NamedDecl *FDecl,
 Diag(Loc, diag::warn_param_mismatched_alignment)
 << (int)ArgAlign.getQuantity() << (int)ParamAlign.getQuantity()
 << ParamName << FDecl;
-};
+}
 
 /// Handles the checks for format strings, non-POD arguments to vararg
 /// functions, NULL arguments passed to non-NULL parameters, and diagnose_if



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


[PATCH] D93769: [clang] Add support for option -ffp-eval-method and extend #pragma float_control similarly

2021-03-09 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:2884
+  }
+  Opts.setFPEvalMethod(FEM);
+

Can you please use the marshalling infrastructure for this? 
https://clang.llvm.org/docs/InternalsManual.html#adding-new-command-line-option 
(`MarshallingInfoEnum`)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93769

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


[clang] 46d4d1f - [AIX] do not emit visibility attribute into IR when there is -mignore-xcoff-visibility

2021-03-09 Thread via cfe-commits

Author: diggerlin
Date: 2021-03-09T10:38:00-05:00
New Revision: 46d4d1fea401de1d22fe746077a4ca4dd7e137b4

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

LOG: [AIX] do not emit visibility attribute into IR when there is 
-mignore-xcoff-visibility

SUMMARY:

n the patch https://reviews.llvm.org/D87451 "add new option 
-mignore-xcoff-visibility"
we did as "The option -mignore-xcoff-visibility has no effect on visibility 
attribute when compile with -emit-llvm option to generated LLVM IR."

in these patch we let -mignore-xcoff-visibility effect on generating IR too. 
the new feature only work on AIX OS

Reviewer: Jason Liu,

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

Added: 
clang/test/CodeGen/aix-visibility-inlines-hidden.cpp

Modified: 
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Basic/LangOptions.def
clang/lib/AST/Decl.cpp
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CodeGen/aix-ignore-xcoff-visibility.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index a1db1b101620..bbda74044a1c 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -39,7 +39,6 @@ CODEGENOPT(AssumeSaneOperatorNew , 1, 1) ///< implicit 
__attribute__((malloc)) o
 CODEGENOPT(Autolink  , 1, 1) ///< -fno-autolink
 CODEGENOPT(ObjCAutoRefCountExceptions , 1, 0) ///< Whether ARC should be 
EH-safe.
 CODEGENOPT(Backchain , 1, 0) ///< -mbackchain
-CODEGENOPT(IgnoreXCOFFVisibility , 1, 0) ///< -mignore-xcoff-visibility
 CODEGENOPT(ControlFlowGuardNoChecks  , 1, 0) ///< -cfguard-no-checks
 CODEGENOPT(ControlFlowGuard  , 1, 0) ///< -cfguard
 CODEGENOPT(EHContGuard   , 1, 0) ///< -ehcontguard

diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 346638549719..620b0899507a 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -267,6 +267,7 @@ BENIGN_LANGOPT(DumpRecordLayoutsSimple , 1, 0, "dumping the 
layout of IRgen'd re
 BENIGN_LANGOPT(DumpVTableLayouts , 1, 0, "dumping the layouts of emitted 
vtables")
 LANGOPT(NoConstantCFStrings , 1, 0, "no constant CoreFoundation strings")
 BENIGN_LANGOPT(InlineVisibilityHidden , 1, 0, "hidden visibility for inline 
C++ methods")
+BENIGN_LANGOPT(IgnoreXCOFFVisibility, 1, 0, "All the visibility attributes 
that are specified in the source code are ignored in aix XCOFF.")
 BENIGN_LANGOPT(VisibilityInlinesHiddenStaticLocalVar, 1, 0,
"hidden visibility for static local variables in inline C++ "
"methods when -fvisibility-inlines hidden is enabled")

diff  --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 8c986df3e175..cae092ac369d 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -1487,10 +1487,13 @@ LinkageInfo LinkageComputer::getLVForDecl(const 
NamedDecl *D,
 }
 
 LinkageInfo LinkageComputer::getDeclLinkageAndVisibility(const NamedDecl *D) {
-  return getLVForDecl(D,
-  LVComputationKind(usesTypeVisibility(D)
-? NamedDecl::VisibilityForType
-: NamedDecl::VisibilityForValue));
+  NamedDecl::ExplicitVisibilityKind EK = usesTypeVisibility(D)
+ ? NamedDecl::VisibilityForType
+ : NamedDecl::VisibilityForValue;
+  LVComputationKind CK(EK);
+  return getLVForDecl(D, D->getASTContext().getLangOpts().IgnoreXCOFFVisibility
+ ? CK.forLinkageOnly()
+ : CK);
 }
 
 Module *Decl::getOwningModuleForLinkage(bool IgnoreLinkage) const {

diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 36b6588e773f..37f9067e0b2e 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -549,7 +549,7 @@ static bool initTargetOptions(DiagnosticsEngine &Diags,
   Options.EnableMachineFunctionSplitter = CodeGenOpts.SplitMachineFunctions;
   Options.FunctionSections = CodeGenOpts.FunctionSections;
   Options.DataSections = CodeGenOpts.DataSections;
-  Options.IgnoreXCOFFVisibility = CodeGenOpts.IgnoreXCOFFVisibility;
+  Options.IgnoreXCOFFVisibility = LangOpts.IgnoreXCOFFVisibility;
   Options.UniqueSectionNames = CodeGenOpts.UniqueSectionNames;
   Options.UniqueBasicBlockSectionNames =
   CodeGenOpts.UniqueBasicBlockSectionNames;

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 89e485a29384..2606e9f1b185 100644
--- a/cl

[PATCH] D89986: [AIX] do not emit visibility attribute into IR when there is -mignore-xcoff-visibility

2021-03-09 Thread Digger Lin 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 rG46d4d1fea401: [AIX] do not emit visibility attribute into IR 
when there is -mignore-xcoff… (authored by DiggerLin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89986

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/LangOptions.def
  clang/lib/AST/Decl.cpp
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/aix-ignore-xcoff-visibility.cpp
  clang/test/CodeGen/aix-visibility-inlines-hidden.cpp

Index: clang/test/CodeGen/aix-visibility-inlines-hidden.cpp
===
--- /dev/null
+++ clang/test/CodeGen/aix-visibility-inlines-hidden.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -mcmodel=large -emit-llvm -o - -x c++ %s  | \
+// RUN: FileCheck -check-prefix=NOVISIBILITY-IR %s
+
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -mcmodel=large \
+// RUN:-fvisibility-inlines-hidden -emit-llvm -o - -x c++ %s  | \
+// RUN: FileCheck -check-prefix=NOVISIBILITY-IR %s
+
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -mcmodel=large -fvisibility-inlines-hidden \
+// RUN:-fvisibility default -emit-llvm -o - -x c++ %s  | \
+// RUN: FileCheck -check-prefix=VISIBILITY-IR %s
+
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -mcmodel=large -mignore-xcoff-visibility -emit-llvm \
+// RUN:-fvisibility-inlines-hidden -fvisibility default -o - -x c++ %s  | \
+// RUN: FileCheck -check-prefix=NOVISIBILITY-IR %s
+
+int x = 66;
+__attribute__((__noinline__)) inline void f() {
+  x = 55;
+}
+
+#pragma GCC visibility push(hidden)
+__attribute__((__noinline__)) inline void foo() {
+  x = 55;
+}
+#pragma GCC visibility pop
+
+int bar() {
+  f();
+  foo();
+  return x;
+}
+
+// VISIBILITY-IR: define linkonce_odr hidden void @_Z1fv()
+// NOVISIBILITY-IR:   define linkonce_odr void @_Z1fv()
+
+// VISIBILITY-IR: define linkonce_odr hidden void @_Z3foov()
+// NOVISIBILITY-IR:   define linkonce_odr void @_Z3foov()
Index: clang/test/CodeGen/aix-ignore-xcoff-visibility.cpp
===
--- clang/test/CodeGen/aix-ignore-xcoff-visibility.cpp
+++ clang/test/CodeGen/aix-ignore-xcoff-visibility.cpp
@@ -1,26 +1,19 @@
-// REQUIRES: powerpc-registered-target
-// RUN: %clang_cc1 -triple powerpc-unknown-aix -o - -x c++ -S  %s  |\
-// RUN:   FileCheck --check-prefix=IGNOREVISIBILITY-ASM %s
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -emit-llvm -o - -x c++ %s  | \
+// RUN: FileCheck -check-prefix=NOVISIBILITY-IR %s
 
-// RUN: %clang_cc1 -triple powerpc-unknown-aix -mignore-xcoff-visibility -o - -x c++ -S %s  | \
-// RUN: FileCheck -check-prefix=IGNOREVISIBILITY-ASM %s
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -emit-llvm -round-trip-args -o - -x c++ %s  | \
+// RUN: FileCheck -check-prefix=NOVISIBILITY-IR %s
 
-// RUN: %clang_cc1 -triple powerpc-unknown-aix -mignore-xcoff-visibility -fvisibility default -o - -x c++ -S %s  | \
-// RUN: FileCheck -check-prefix=IGNOREVISIBILITY-ASM %s
-
-// RUN: %clang_cc1 -triple powerpc-unknown-aix -fvisibility default -o - -x c++ -S %s  | \
-// RUN: FileCheck -check-prefix=VISIBILITY-ASM %s
-
-// RUN: %clang_cc1 -triple powerpc-unknown-aix -mignore-xcoff-visibility -fvisibility default -o - -x c++ -S %s  | \
-// RUN: FileCheck -check-prefix=IGNOREVISIBILITY-ASM %s
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -mignore-xcoff-visibility -fvisibility default -emit-llvm -o - -x c++ %s  | \
+// RUN: FileCheck -check-prefix=NOVISIBILITY-IR %s
 
-// RUN: %clang_cc1 -triple powerpc-unknown-aix -fvisibility default -o - -x c++ -S %s  | \
-// RUN: FileCheck -check-prefix=VISIBILITY-ASM %s
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -mignore-xcoff-visibility -fvisibility default -emit-llvm -round-trip-args -o - -x c++ %s  | \
+// RUN: FileCheck -check-prefix=NOVISIBILITY-IR %s
 
-// RUN: %clang_cc1 -triple powerpc-unknown-aix -mignore-xcoff-visibility -fvisibility default -emit-llvm -o - -x c++ %s  | \
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -fvisibility default -emit-llvm -o - -x c++ %s  | \
 // RUN: FileCheck -check-prefix=VISIBILITY-IR %s
 
-// RUN: %clang_cc1 -triple powerpc-unknown-aix -fvisibility default -emit-llvm -o - -x c++ %s  | \
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -fvisibility default -round-trip-args -emit-llvm -o - -x c++ %s  | \
 // RUN: FileCheck -check-prefix=VISIBILITY-IR %s
 
 __attribute__((visibility("hidden"))) void foo_h(int *p) {
@@ -70,28 +63,11 @@
 // VISIBILITY-IR:define weak_odr protected i32 @_ZN5basicIiE7getdataEv(%class.basic* {{[^,]*}} %this)
 // VISIBILITY-IR:define hidden void @_Z7prambarv()
 
-// VISIBILITY-ASM: .globl  _Z5foo_hPi[DS],hidden
-// VISIBILITY-ASM: .globl  ._

[PATCH] D97965: [clang] Fix crash when creating deduction guide.

2021-03-09 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz updated this revision to Diff 329346.
adamcz added a comment.

expanded a comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97965

Files:
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp


Index: clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
===
--- clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
+++ clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
@@ -416,6 +416,17 @@
 
 }
 
+namespace no_crash_on_default_arg {
+class A {
+  template  class B {
+B(int c = 1);
+  };
+  // This used to crash due to unparsed default arg above. The diagnostic could
+  // be improved, but the point of this test is to simply check we do not 
crash.
+  B(); // expected-error {{deduction guide declaration without trailing return 
type}}
+};
+} // namespace no_crash_on_default_arg
+
 #pragma clang diagnostic push
 #pragma clang diagnostic warning "-Wctad-maybe-unsupported"
 namespace test_implicit_ctad_warning {
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -2494,6 +2494,12 @@
 if (!CD || (!FTD && CD->isFunctionTemplateSpecialization()))
   continue;
 
+// Cannot make a deduction guide when unparsed arguments are present.
+if (std::any_of(CD->param_begin(), CD->param_end(), [](ParmVarDecl *P) {
+  return !P || P->hasUnparsedDefaultArg();
+}))
+  continue;
+
 Transform.transformConstructor(FTD, CD);
 AddedAny = true;
   }


Index: clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
===
--- clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
+++ clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
@@ -416,6 +416,17 @@
 
 }
 
+namespace no_crash_on_default_arg {
+class A {
+  template  class B {
+B(int c = 1);
+  };
+  // This used to crash due to unparsed default arg above. The diagnostic could
+  // be improved, but the point of this test is to simply check we do not crash.
+  B(); // expected-error {{deduction guide declaration without trailing return type}}
+};
+} // namespace no_crash_on_default_arg
+
 #pragma clang diagnostic push
 #pragma clang diagnostic warning "-Wctad-maybe-unsupported"
 namespace test_implicit_ctad_warning {
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -2494,6 +2494,12 @@
 if (!CD || (!FTD && CD->isFunctionTemplateSpecialization()))
   continue;
 
+// Cannot make a deduction guide when unparsed arguments are present.
+if (std::any_of(CD->param_begin(), CD->param_end(), [](ParmVarDecl *P) {
+  return !P || P->hasUnparsedDefaultArg();
+}))
+  continue;
+
 Transform.transformConstructor(FTD, CD);
 AddedAny = true;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97965: [clang] Fix crash when creating deduction guide.

2021-03-09 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz added inline comments.



Comment at: clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp:425
+  // This used to crash due to unparsed default arg above.
+  B(); // expected-error {{deduction guide declaration without trailing return 
type}}
+};

hokein wrote:
> The diagnostic seems bogus, but I think it is at least better than crashing, 
> I'd add add a FIXME to fix this bogus diagnostic here?.
I added a line about improving the diagnostic. I'm a bit hesitant to leave a 
FIXME, since it doesn't seem like something actually worth spending time on. 
Just a weird corner case on broken code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97965

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


[clang] 4f8e299 - [Sema] Fix diagnostics for one-byte length modifier

2021-03-09 Thread Anton Bikineev via cfe-commits

Author: Anton Bikineev
Date: 2021-03-09T16:56:20+01:00
New Revision: 4f8e299785e860cf974d696d7ca83b70a94977fe

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

LOG: [Sema] Fix diagnostics for one-byte length modifier

In case a char-literal of type int (C/ObjectiveC) corresponds to a
format specifier with the %hh length modifier, don't treat the literal
as of type char for issuing diagnostics, as otherwise this results in:

printf("%hhd", 'e');
warning: format specifies type 'char' but the argument has type 'char'.

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

Added: 


Modified: 
clang/lib/Sema/SemaChecking.cpp
clang/test/FixIt/format.m

Removed: 




diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index fef6a9306eaf..e390159a8f64 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -8730,8 +8730,11 @@ CheckPrintfHandler::checkFormatExpr(const 
analyze_printf::PrintfSpecifier &FS,
   } else if (const CharacterLiteral *CL = dyn_cast(E)) {
 // Special case for 'a', which has type 'int' in C.
 // Note, however, that we do /not/ want to treat multibyte constants like
-// 'MooV' as characters! This form is deprecated but still exists.
-if (ExprTy == S.Context.IntTy)
+// 'MooV' as characters! This form is deprecated but still exists. In
+// addition, don't treat expressions as of type 'char' if one byte length
+// modifier is provided.
+if (ExprTy == S.Context.IntTy &&
+FS.getLengthModifier().getKind() != LengthModifier::AsChar)
   if (llvm::isUIntN(S.Context.getCharWidth(), CL->getValue()))
 ExprTy = S.Context.CharTy;
   }

diff  --git a/clang/test/FixIt/format.m b/clang/test/FixIt/format.m
index ef27b1bac353..0d173846d0ad 100644
--- a/clang/test/FixIt/format.m
+++ b/clang/test/FixIt/format.m
@@ -169,6 +169,12 @@ void test_char(char c, signed char s, unsigned char u, 
uint8_t n) {
 
   NSLog(@"%@", 'abcd'); // expected-warning{{format specifies type 'id' but 
the argument has type 'int'}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:13}:"%d"
+
+  NSLog(@"%hhd", 'a'); // expected-warning{{format specifies type 'char' but 
the argument has type 'int'}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:15}:"%d"
+
+  NSLog(@"%hhu", 'a'); // expected-warning{{format specifies type 'unsigned 
char' but the argument has type 'int'}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:15}:"%d"
 }
 
 void multichar_constants_false_negative() {



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


[PATCH] D97951: [Sema] Fix diagnostics for one-byte length modifier

2021-03-09 Thread Anton Bikineev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4f8e299785e8: [Sema] Fix diagnostics for one-byte length 
modifier (authored by AntonBikineev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97951

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/FixIt/format.m


Index: clang/test/FixIt/format.m
===
--- clang/test/FixIt/format.m
+++ clang/test/FixIt/format.m
@@ -169,6 +169,12 @@
 
   NSLog(@"%@", 'abcd'); // expected-warning{{format specifies type 'id' but 
the argument has type 'int'}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:13}:"%d"
+
+  NSLog(@"%hhd", 'a'); // expected-warning{{format specifies type 'char' but 
the argument has type 'int'}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:15}:"%d"
+
+  NSLog(@"%hhu", 'a'); // expected-warning{{format specifies type 'unsigned 
char' but the argument has type 'int'}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:15}:"%d"
 }
 
 void multichar_constants_false_negative() {
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -8730,8 +8730,11 @@
   } else if (const CharacterLiteral *CL = dyn_cast(E)) {
 // Special case for 'a', which has type 'int' in C.
 // Note, however, that we do /not/ want to treat multibyte constants like
-// 'MooV' as characters! This form is deprecated but still exists.
-if (ExprTy == S.Context.IntTy)
+// 'MooV' as characters! This form is deprecated but still exists. In
+// addition, don't treat expressions as of type 'char' if one byte length
+// modifier is provided.
+if (ExprTy == S.Context.IntTy &&
+FS.getLengthModifier().getKind() != LengthModifier::AsChar)
   if (llvm::isUIntN(S.Context.getCharWidth(), CL->getValue()))
 ExprTy = S.Context.CharTy;
   }


Index: clang/test/FixIt/format.m
===
--- clang/test/FixIt/format.m
+++ clang/test/FixIt/format.m
@@ -169,6 +169,12 @@
 
   NSLog(@"%@", 'abcd'); // expected-warning{{format specifies type 'id' but the argument has type 'int'}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:13}:"%d"
+
+  NSLog(@"%hhd", 'a'); // expected-warning{{format specifies type 'char' but the argument has type 'int'}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:15}:"%d"
+
+  NSLog(@"%hhu", 'a'); // expected-warning{{format specifies type 'unsigned char' but the argument has type 'int'}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:15}:"%d"
 }
 
 void multichar_constants_false_negative() {
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -8730,8 +8730,11 @@
   } else if (const CharacterLiteral *CL = dyn_cast(E)) {
 // Special case for 'a', which has type 'int' in C.
 // Note, however, that we do /not/ want to treat multibyte constants like
-// 'MooV' as characters! This form is deprecated but still exists.
-if (ExprTy == S.Context.IntTy)
+// 'MooV' as characters! This form is deprecated but still exists. In
+// addition, don't treat expressions as of type 'char' if one byte length
+// modifier is provided.
+if (ExprTy == S.Context.IntTy &&
+FS.getLengthModifier().getKind() != LengthModifier::AsChar)
   if (llvm::isUIntN(S.Context.getCharWidth(), CL->getValue()))
 ExprTy = S.Context.CharTy;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97951: [Sema] Fix diagnostics for one-byte length modifier

2021-03-09 Thread Anton Bikineev via Phabricator via cfe-commits
AntonBikineev added a comment.

Thanks Aaron for taking a look!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97951

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


[PATCH] D98264: [AArch64] Implement __rndr, __rndrrs intrinsics

2021-03-09 Thread Stelios Ioannou via Phabricator via cfe-commits
stelios-arm created this revision.
stelios-arm added reviewers: dmgreen, SjoerdMeijer, fhahn, simon_tatham, 
ostannard, c-rhodes.
stelios-arm added a project: LLVM.
Herald added subscribers: danielkiss, hiraditya, kristof.beyls.
stelios-arm requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch implements the  `__rndr` and `__rndrrs` intrinsics to provide access 
to the random number instructions introduced in Armv8.5-A. They are only 
defined for the AArch64 execution state and are available when 
`__ARM_FEATURE_RNG` is defined.

These intrinsics store the random number in their pointer argument and return a 
status code if the generation succeeded. The difference between `__rndr` and 
`__rndrrs`, is that the latter intrinsic reseeds the random number generator.

The instructions write the NZCV flags indicating the success of the operation 
that we can then read with a CSET.

[1] https://developer.arm.com/docs/101028/latest/data-processing-intrinsics
[2] https://bugs.llvm.org/show_bug.cgi?id=47838


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98264

Files:
  clang/include/clang/Basic/BuiltinsAArch64.def
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/arm_acle.h
  clang/test/CodeGen/arm_acle.c
  clang/test/CodeGen/builtins-arm64.c
  clang/test/Preprocessor/init-aarch64.c
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.h
  llvm/lib/Target/AArch64/AArch64InstrFormats.td
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/test/CodeGen/AArch64/rand.ll
  llvm/test/CodeGen/AArch64/stp-opt-with-renaming.mir

Index: llvm/test/CodeGen/AArch64/stp-opt-with-renaming.mir
===
--- llvm/test/CodeGen/AArch64/stp-opt-with-renaming.mir
+++ llvm/test/CodeGen/AArch64/stp-opt-with-renaming.mir
@@ -100,11 +100,11 @@
   bb.0:
 liveins: $x0
 
-renamable $x8 = MRS 58880
+renamable $x8 = MRS 58880, implicit-def $nzcv
 renamable $x8 = MOVZXi 15309, 0
 renamable $x8 = MOVKXi renamable $x8, 26239, 16
 STRXui renamable $x8, renamable $x0, 0, implicit killed $x8 :: (store 8)
-renamable $x8 = MRS 55840
+renamable $x8 = MRS 55840, implicit-def $nzcv
 STRXui killed renamable  $x8, renamable killed $x0, 1, implicit killed $x8 :: (store 8)
 RET undef $lr
 
@@ -134,9 +134,9 @@
   bb.0:
 liveins: $x0, $x1
 
-renamable $x8 = MRS 58880
+renamable $x8 = MRS 58880, implicit-def $nzcv
 STRXui renamable $x8, renamable $x0, 0, implicit killed $x8 :: (store 4)
-renamable $x8 = MRS 55840
+renamable $x8 = MRS 55840, implicit-def $nzcv
 STRXui killed renamable  $x8, renamable killed $x0, 1, implicit killed $x8 :: (store 4)
 RET undef $lr
 
@@ -166,9 +166,9 @@
   bb.0:
 liveins: $x0, $x1
 
-renamable $x8 = MRS 58880
+renamable $x8 = MRS 58880, implicit-def $nzcv
 STRWui renamable $w8, renamable $x0, 0, implicit killed $x8 :: (store 4)
-renamable $x8 = MRS 55840
+renamable $x8 = MRS 55840, implicit-def $nzcv
 STRWui killed renamable $w8, renamable killed $x0, 1, implicit killed $x8 :: (store 4)
 RET undef $lr
 
@@ -275,10 +275,10 @@
   bb.0:
 liveins: $x0, $x1
 
-renamable $x8 = MRS 58880
+renamable $x8 = MRS 58880, implicit-def $nzcv
 renamable $w8 = ORRWrs $wzr, killed renamable $w8, 0, implicit-def $x8
 STRWui renamable $w8, renamable $x0, 0, implicit killed $x8 :: (store 4)
-renamable $x8 = MRS 55840
+renamable $x8 = MRS 55840, implicit-def $nzcv
 STRWui killed renamable $w8, renamable killed $x0, 1, implicit killed $x8 :: (store 4)
 RET undef $lr
 
Index: llvm/test/CodeGen/AArch64/rand.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/rand.ll
@@ -0,0 +1,37 @@
+; RUN: llc -mtriple=aarch64 -mcpu=neoverse-v1 -mattr=+rand %s -o - | FileCheck %s
+
+define  i32 @rndr(i64* %__addr) {
+; CHECK-LABEL: rndr:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:mrs x8, RNDR
+; CHECK-NEXT:cset w9, ne
+; CHECK-NEXT:str x8, [x0]
+; CHECK-NEXT:and w0, w9, #0x1
+; CHECK-NEXT:ret
+  %1 = tail call { i64, i1 } @llvm.aarch64.rndr()
+  %2 = extractvalue { i64, i1 } %1, 0
+  %3 = extractvalue { i64, i1 } %1, 1
+  store i64 %2, i64* %__addr, align 8
+  %4 = zext i1 %3 to i32
+  ret i32 %4
+}
+
+
+define  i32 @rndrrs(i64*  %__addr) {
+; CHECK-LABEL: rndrrs:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:mrs x8, RNDRRS
+; CHECK-NEXT:cset w9, ne
+; CHECK-NEXT:str x8, [x0]
+; CHECK-NEXT:and w0, w9, #0x1
+; CHECK-NEXT:ret
+  %1 = tail call { i64, i1 } @llvm.aarch64.rndrrs()
+  %2 = extractvalue { i64, i1 } %1, 0
+  %3 = extractvalue { i64, i1 } %1, 1
+  store i64 %2, i64* %__addr, align 8
+  %4 = zext i1 %3 to i32
+  ret i32 %4
+}
+
+declare 

[clang] 4e1c487 - [clang] Fix crash when creating deduction guide.

2021-03-09 Thread Adam Czachorowski via cfe-commits

Author: Adam Czachorowski
Date: 2021-03-09T16:57:56+01:00
New Revision: 4e1c487004a29ec9bc56fd47fc30336d033c57dd

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

LOG: [clang] Fix crash when creating deduction guide.

We used to trigger assertion when transforming c-tor with unparsed
default argument. Now we ignore such constructors for this purpose.

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

Added: 


Modified: 
clang/lib/Sema/SemaTemplate.cpp
clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 12880b95b9c6..7a65c2a6fe2c 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -2494,6 +2494,12 @@ void Sema::DeclareImplicitDeductionGuides(TemplateDecl 
*Template,
 if (!CD || (!FTD && CD->isFunctionTemplateSpecialization()))
   continue;
 
+// Cannot make a deduction guide when unparsed arguments are present.
+if (std::any_of(CD->param_begin(), CD->param_end(), [](ParmVarDecl *P) {
+  return !P || P->hasUnparsedDefaultArg();
+}))
+  continue;
+
 Transform.transformConstructor(FTD, CD);
 AddedAny = true;
   }

diff  --git a/clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp 
b/clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
index 305cc3e976b0..161944f9e64f 100644
--- a/clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
+++ b/clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
@@ -416,6 +416,17 @@ B b(0, {});
 
 }
 
+namespace no_crash_on_default_arg {
+class A {
+  template  class B {
+B(int c = 1);
+  };
+  // This used to crash due to unparsed default arg above. The diagnostic could
+  // be improved, but the point of this test is to simply check we do not 
crash.
+  B(); // expected-error {{deduction guide declaration without trailing return 
type}}
+};
+} // namespace no_crash_on_default_arg
+
 #pragma clang diagnostic push
 #pragma clang diagnostic warning "-Wctad-maybe-unsupported"
 namespace test_implicit_ctad_warning {



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


[PATCH] D97965: [clang] Fix crash when creating deduction guide.

2021-03-09 Thread Adam Czachorowski 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 rG4e1c487004a2: [clang] Fix crash when creating deduction 
guide. (authored by adamcz).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97965

Files:
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp


Index: clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
===
--- clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
+++ clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
@@ -416,6 +416,17 @@
 
 }
 
+namespace no_crash_on_default_arg {
+class A {
+  template  class B {
+B(int c = 1);
+  };
+  // This used to crash due to unparsed default arg above. The diagnostic could
+  // be improved, but the point of this test is to simply check we do not 
crash.
+  B(); // expected-error {{deduction guide declaration without trailing return 
type}}
+};
+} // namespace no_crash_on_default_arg
+
 #pragma clang diagnostic push
 #pragma clang diagnostic warning "-Wctad-maybe-unsupported"
 namespace test_implicit_ctad_warning {
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -2494,6 +2494,12 @@
 if (!CD || (!FTD && CD->isFunctionTemplateSpecialization()))
   continue;
 
+// Cannot make a deduction guide when unparsed arguments are present.
+if (std::any_of(CD->param_begin(), CD->param_end(), [](ParmVarDecl *P) {
+  return !P || P->hasUnparsedDefaultArg();
+}))
+  continue;
+
 Transform.transformConstructor(FTD, CD);
 AddedAny = true;
   }


Index: clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
===
--- clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
+++ clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
@@ -416,6 +416,17 @@
 
 }
 
+namespace no_crash_on_default_arg {
+class A {
+  template  class B {
+B(int c = 1);
+  };
+  // This used to crash due to unparsed default arg above. The diagnostic could
+  // be improved, but the point of this test is to simply check we do not crash.
+  B(); // expected-error {{deduction guide declaration without trailing return type}}
+};
+} // namespace no_crash_on_default_arg
+
 #pragma clang diagnostic push
 #pragma clang diagnostic warning "-Wctad-maybe-unsupported"
 namespace test_implicit_ctad_warning {
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -2494,6 +2494,12 @@
 if (!CD || (!FTD && CD->isFunctionTemplateSpecialization()))
   continue;
 
+// Cannot make a deduction guide when unparsed arguments are present.
+if (std::any_of(CD->param_begin(), CD->param_end(), [](ParmVarDecl *P) {
+  return !P || P->hasUnparsedDefaultArg();
+}))
+  continue;
+
 Transform.transformConstructor(FTD, CD);
 AddedAny = true;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98264: [AArch64] Implement __rndr, __rndrrs intrinsics

2021-03-09 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added inline comments.



Comment at: clang/lib/Basic/Targets/AArch64.cpp:363
 
+  if (HasRandGen)
+Builder.defineMacro("__ARM_FEATURE_RNG", "1");

Where/when is `HasRandGen` set?



Comment at: clang/test/Preprocessor/init-aarch64.c:28
 // AARCH64-NEXT: #define __ARM_FEATURE_NUMERIC_MAXMIN 1
+// AARCH64-NEXT: #define  __ARM_FEATURE_RNG 1
 // AARCH64-NEXT: #define __ARM_FEATURE_UNALIGNED 1

Why are we expecting this here? Are we not only expecting this for v8.5?

We also need a negative test and CHECK-NOT of this where we don't expect this.



Comment at: llvm/lib/Target/AArch64/AArch64InstrFormats.td:1495
   let DecoderNamespace = "Fallback";
+  let Defs = [NZCV];
 }

Do all MRS instructions do this?



Comment at: llvm/lib/Target/AArch64/AArch64InstrInfo.td:1274
+def : Pat<(AArch64mrs imm:$id),
+  (MRS imm:$id)>;
+

Nit: can be on the same line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98264

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


[PATCH] D98265: [NFC] Use llvm::SmallVector to workaround XL compiler problem on AIX

2021-03-09 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L created this revision.
Xiangling_L added reviewers: daltenty, hubert.reinterpretcast, cebowleratibm, 
jsji, Whitney.
Xiangling_L requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

LLVM is recommending to use SmallVector (that is, omitting the N), in the 
absence of a well-motivated choice for the number of inlined elements N.

However, this doesn't work well with XL compiler on AIX since some header(s) 
aren't properly picked up with it. We need to take a further look into the real 
issue underneath and fix it in a later patch.

But currently we'd like to use this patch to unblock the build compiler issue 
first.

Note:
The first build failure was spot here: 
http://lab.llvm.org:8014/#/builders/126/builds/71


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98265

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp


Index: clang/lib/CodeGen/CGStmtOpenMP.cpp
===
--- clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -1913,7 +1913,7 @@
 emitCapturedStmtCall(CodeGenFunction &ParentCGF, EmittedClosureTy Cap,
  llvm::ArrayRef Args) {
   // Append the closure context to the argument.
-  SmallVector EffectiveArgs;
+  llvm::SmallVector EffectiveArgs;
   EffectiveArgs.reserve(Args.size() + 1);
   llvm::append_range(EffectiveArgs, Args);
   EffectiveArgs.push_back(Cap.second);


Index: clang/lib/CodeGen/CGStmtOpenMP.cpp
===
--- clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -1913,7 +1913,7 @@
 emitCapturedStmtCall(CodeGenFunction &ParentCGF, EmittedClosureTy Cap,
  llvm::ArrayRef Args) {
   // Append the closure context to the argument.
-  SmallVector EffectiveArgs;
+  llvm::SmallVector EffectiveArgs;
   EffectiveArgs.reserve(Args.size() + 1);
   llvm::append_range(EffectiveArgs, Args);
   EffectiveArgs.push_back(Cap.second);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D95043: [clangd] Use Dirty Filesystem for cross file rename.

2021-03-09 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 329354.
njames93 added a comment.

Update to assert that either Index and FS are both set, or neither set.
Document this behaviour.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95043

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/refactor/Rename.h
  clang-tools-extra/clangd/unittests/RenameTests.cpp

Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -33,6 +33,19 @@
 using testing::UnorderedElementsAre;
 using testing::UnorderedElementsAreArray;
 
+llvm::IntrusiveRefCntPtr
+createOverlay(llvm::IntrusiveRefCntPtr Base,
+  llvm::IntrusiveRefCntPtr Overlay) {
+  auto OFS =
+  llvm::makeIntrusiveRefCnt(std::move(Base));
+  OFS->pushOverlay(std::move(Overlay));
+  return OFS;
+}
+
+llvm::IntrusiveRefCntPtr getVFSFromAST(ParsedAST &AST) {
+  return &AST.getSourceManager().getFileManager().getVirtualFileSystem();
+}
+
 // Convert a Range to a Ref.
 Ref refWithRange(const clangd::Range &Range, const std::string &URI) {
   Ref Result;
@@ -815,7 +828,8 @@
 auto Index = TU.index();
 for (const auto &RenamePos : Code.points()) {
   auto RenameResult =
-  rename({RenamePos, NewName, AST, testPath(TU.Filename), Index.get()});
+  rename({RenamePos, NewName, AST, testPath(TU.Filename),
+  getVFSFromAST(AST), Index.get()});
   ASSERT_TRUE(bool(RenameResult)) << RenameResult.takeError();
   ASSERT_EQ(1u, RenameResult->GlobalChanges.size());
   EXPECT_EQ(
@@ -1101,13 +1115,21 @@
   auto AST = TU.build();
 
   auto Main = testPath("main.cc");
+  auto InMemFS = llvm::makeIntrusiveRefCnt();
+  InMemFS->addFile(testPath("main.cc"), 0,
+   llvm::MemoryBuffer::getMemBuffer(Code.code()));
+  InMemFS->addFile(testPath("other.cc"), 0,
+   llvm::MemoryBuffer::getMemBuffer(Code.code()));
 
   auto Rename = [&](const SymbolIndex *Idx) {
-auto GetDirtyBuffer = [&](PathRef Path) -> llvm::Optional {
-  return Code.code().str(); // Every file has the same content.
-};
-RenameInputs Inputs{Code.point(), "xPrime",AST,   Main,
-Idx,  RenameOptions(), GetDirtyBuffer};
+RenameInputs Inputs{Code.point(),
+"xPrime",
+AST,
+Main,
+Idx ? createOverlay(getVFSFromAST(AST), InMemFS)
+: nullptr,
+Idx,
+RenameOptions()};
 auto Results = rename(Inputs);
 EXPECT_TRUE(bool(Results)) << llvm::toString(Results.takeError());
 return std::move(*Results);
@@ -1237,25 +1259,19 @@
 
   Annotations MainCode("class  [[Fo^o]] {};");
   auto MainFilePath = testPath("main.cc");
-  // Dirty buffer for foo.cc.
-  auto GetDirtyBuffer = [&](PathRef Path) -> llvm::Optional {
-if (Path == FooPath)
-  return FooDirtyBuffer.code().str();
-return llvm::None;
-  };
+  llvm::IntrusiveRefCntPtr InMemFS =
+  new llvm::vfs::InMemoryFileSystem;
+  InMemFS->addFile(FooPath, 0,
+   llvm::MemoryBuffer::getMemBuffer(FooDirtyBuffer.code()));
 
   // Run rename on Foo, there is a dirty buffer for foo.cc, rename should
   // respect the dirty buffer.
   TestTU TU = TestTU::withCode(MainCode.code());
   auto AST = TU.build();
   llvm::StringRef NewName = "newName";
-  auto Results = rename({MainCode.point(),
- NewName,
- AST,
- MainFilePath,
- Index.get(),
- {},
- GetDirtyBuffer});
+  auto Results =
+  rename({MainCode.point(), NewName, AST, MainFilePath,
+  createOverlay(getVFSFromAST(AST), InMemFS), Index.get()});
   ASSERT_TRUE(bool(Results)) << Results.takeError();
   EXPECT_THAT(
   applyEdits(std::move(Results->GlobalChanges)),
@@ -1270,13 +1286,8 @@
   // Set a file "bar.cc" on disk.
   TU.AdditionalFiles["bar.cc"] = std::string(BarCode.code());
   AST = TU.build();
-  Results = rename({MainCode.point(),
-NewName,
-AST,
-MainFilePath,
-Index.get(),
-{},
-GetDirtyBuffer});
+  Results = rename({MainCode.point(), NewName, AST, MainFilePath,
+createOverlay(getVFSFromAST(AST), InMemFS), Index.get()});
   ASSERT_TRUE(bool(Results)) << Results.takeError();
   EXPECT_THAT(
   applyEdits(std::move(Res

[PATCH] D98264: [AArch64] Implement __rndr, __rndrrs intrinsics

2021-03-09 Thread Dave Green via Phabricator via cfe-commits
dmgreen added inline comments.



Comment at: llvm/lib/Target/AArch64/AArch64InstrFormats.td:1495
   let DecoderNamespace = "Fallback";
+  let Defs = [NZCV];
 }

SjoerdMeijer wrote:
> Do all MRS instructions do this?
No, but some do and it's not obvious which ones do and don't. I think it should 
be reasonable to always def NZCV here, even if they are just dead. It should be 
very rare that it would be beneficial for NZCV to be live across a MRS 
instruction.



Comment at: llvm/lib/Target/AArch64/AArch64InstrInfo.td:1270
+// MRS from CodeGen.
+def AArch64mrs  : SDNode<"AArch64ISD::MRS",
+ SDTypeProfile<1, 1, [SDTCisVT<0, i64>, 
SDTCisVT<1, i32>]>,

These are usually put somewhere else in the aarch64 backend, and it might be 
worth keeping it with the others.



Comment at: llvm/lib/Target/AArch64/AArch64InstrInfo.td:1274
+def : Pat<(AArch64mrs imm:$id),
+  (MRS imm:$id)>;
+

SjoerdMeijer wrote:
> Nit: can be on the same line.
I always prefer Pat's to have input and output lines separate, for what it's 
worth. It makes them more easily readable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98264

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


[PATCH] D95016: [Clang][RISCV] Add custom TableGen backend for riscv-vector intrinsics.

2021-03-09 Thread Zakk Chen via Phabricator via cfe-commits
khchen added a comment.

@jrtc27, please advise if there is anything more should to be changed, thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95016

___
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-03-09 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 329361.
serge-sans-paille added a comment.

Fix some formatting
Support literal operator


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

https://reviews.llvm.org/D93095

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Decl.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/Sema/reserved-identifier.c
  clang/test/Sema/reserved-identifier.cpp

Index: clang/test/Sema/reserved-identifier.cpp
===
--- /dev/null
+++ clang/test/Sema/reserved-identifier.cpp
@@ -0,0 +1,84 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++20 -verify -Wreserved-identifier %s
+
+int foo__bar() { return 0; }// expected-warning {{identifier 'foo__bar' is reserved because it contains '__'}}
+static int _bar() { return 0; } // expected-warning {{identifier '_bar' is reserved because it starts with '_' at global scope}}
+static int _Bar() { return 0; } // expected-warning {{identifier '_Bar' is reserved because it starts with '_' at global scope}}
+int _barbouille() { return 0; } // expected-warning {{identifier '_barbouille' is reserved because it starts with '_' at global scope}}
+
+void foo(unsigned int _Reserved) { // expected-warning {{identifier '_Reserved' is reserved because it starts with '_' at global scope}}
+  unsigned int __1 =   // expected-warning {{identifier '__1' is reserved because it starts with '__'}}
+  _Reserved;   // no-warning
+}
+
+// This one is explicitly skipped by -Wreserved-identifier
+void *_; // no-warning
+
+template  constexpr bool __toucan = true; // expected-warning {{identifier '__toucan' is reserved because it starts with '_' at global scope}}
+
+template 
+concept _Barbotine = __toucan; // expected-warning {{identifier '_Barbotine' is reserved because it starts with '_' at global scope}}
+
+template  // expected-warning {{'__' is reserved because it starts with '_' at global scope}}
+struct BarbeNoire {};
+
+template  // expected-warning {{'__' is reserved because it starts with '_' at global scope}}
+void BarbeRousse() {}
+
+namespace _Barbidur { // expected-warning {{identifier '_Barbidur' is reserved because it starts with '_' at global scope}}
+
+struct __barbidou {}; // expected-warning {{identifier '__barbidou' is reserved because it starts with '__'}}
+struct _barbidou {};  // no-warning
+
+int __barbouille; // expected-warning {{identifier '__barbouille' is reserved because it starts with '__'}}
+int _barbouille;  // no-warning
+
+int __babar() { return 0; } // expected-warning {{identifier '__babar' is reserved because it starts with '__'}}
+int _babar() { return 0; }  // no-warning
+
+} // namespace _Barbidur
+
+class __barbapapa { // expected-warning {{identifier '__barbapapa' is reserved because it starts with '_' at global scope}}
+  void _barbabelle() {} // no-warning
+  int _Barbalala;   // expected-warning {{identifier '_Barbalala' is reserved because it starts with '_' followed by a capital letter}}
+};
+
+enum class __menu { // expected-warning {{identifier '__menu' is reserved because it starts with '_' at global scope}}
+  __some,   // expected-warning {{identifier '__some' is reserved because it starts with '__'}}
+  _Other,   // expected-warning {{identifier '_Other' is reserved because it starts with '_' followed by a capital letter}}
+  _other// no-warning
+};
+
+enum _Menu { // expected-warning {{identifier '_Menu' is reserved because it starts with '_' at global scope}}
+  _OtheR_,   // expected-warning {{identifier '_OtheR_' is reserved because it starts with '_' at global scope}}
+  _other_// expected-warning {{identifier '_other_' is reserved because it starts with '_' at global scope}}
+};
+
+enum {
+  __some, // expected-warning {{identifier '__some' is reserved because it starts with '_' at global scope}}
+  _Other, // expected-warning {{identifier '_Other' is reserved because it starts with '_' at global scope}}
+  _other  // expected-warning {{identifier '_other' is reserved because it starts with '_' at global scope}}
+};
+
+static union {
+  int _barbeFleurie; // no-warning
+};
+
+using _Barbamama = __barbapapa; // expected-warning {{identifier '_Barbamama' is reserved because it starts with '_' at global scope}}
+
+int foobar() {
+  return foo__bar(); // no-warning
+}
+
+namespace {
+int _barbatruc; // no-warning
+}
+
+long double operator"" _BarbeBleue(long double) // expected-warning {{identifier 'operator""_BarbeBleue' is reserved because it starts with '_' at global scope}}
+{
+  return 0.;
+}
+
+struct _BarbeRouge { // expected-warning {{identifier '_BarbeRouge' is reserved because it starts with '_' at global scope}}
+} p;
+struct

[PATCH] D98264: [AArch64] Implement __rndr, __rndrrs intrinsics

2021-03-09 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added inline comments.



Comment at: llvm/lib/Target/AArch64/AArch64InstrFormats.td:1495
   let DecoderNamespace = "Fallback";
+  let Defs = [NZCV];
 }

dmgreen wrote:
> SjoerdMeijer wrote:
> > Do all MRS instructions do this?
> No, but some do and it's not obvious which ones do and don't. I think it 
> should be reasonable to always def NZCV here, even if they are just dead. It 
> should be very rare that it would be beneficial for NZCV to be live across a 
> MRS instruction.
True, but since creating another definition is cheap, what would the cons be of:

  class MRS_NZCV : MRSI {
..
let Defs = [NZCV];
  }

The way I look at it is that the description would be more accurate?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98264

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


[PATCH] D98244: [analyzer] Fix StdLibraryFunctionsChecker performance issue

2021-03-09 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a comment.
This revision is now accepted and ready to land.

Good catch! Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98244

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


[PATCH] D98265: [NFC] Use llvm::SmallVector to workaround XL compiler problem on AIX

2021-03-09 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Maybe this needs to be addressed in the forward declaration in 
clang/include/clang/Basic/LLVM.h ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98265

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


[PATCH] D98244: [analyzer] Fix StdLibraryFunctionsChecker performance issue

2021-03-09 Thread Balázs Benics via Phabricator via cfe-commits
steakhal accepted this revision.
steakhal added a comment.

> For projects not using standard libraries, the speed-up can reach 50% after 
> this patch.

Uh, that's something serious!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98244

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


[PATCH] D97277: [analyzer] Eliminate dispatchCast, evalCastFromNonLoc and evalCastFromLoc functions from SValBuilder

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

Please, @ASDenysPetrov, mention `NFC` in the commit message when you commit 
this change.
The same applies to all of your NFC changes.


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

https://reviews.llvm.org/D97277

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


[PATCH] D98265: [NFC] Use llvm::SmallVector to workaround XL compiler problem on AIX

2021-03-09 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L added a comment.

In D98265#2614245 , @craig.topper 
wrote:

> Maybe this needs to be addressed in the forward declaration in 
> clang/include/clang/Basic/LLVM.h ?

Yeah, adding an additional llvm namespace is a certain another way to 
workaround this issue. But I think the fix we apply is also a quick way to 
workaround the build issue.  And as I mentioned, we would expect a real fix in 
a later patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98265

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


[clang] b8b7a9d - [clang] unbreak Index/preamble-reparse-changed-module.m with LLVM_APPEND_VC_REV=NO after 46d4d1fea401

2021-03-09 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2021-03-09T12:29:43-05:00
New Revision: b8b7a9dcdcbcd7427119f92b9a276ac0122ca8c6

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

LOG: [clang] unbreak Index/preamble-reparse-changed-module.m with 
LLVM_APPEND_VC_REV=NO after 46d4d1fea401

See discussion starting at https://reviews.llvm.org/D96816#2572431 .
The same thing is happening with 46d4d1fea401.

Added: 


Modified: 
clang/include/clang/Serialization/ASTBitCodes.h

Removed: 




diff  --git a/clang/include/clang/Serialization/ASTBitCodes.h 
b/clang/include/clang/Serialization/ASTBitCodes.h
index 03ec8da289de..2c4356a738f9 100644
--- a/clang/include/clang/Serialization/ASTBitCodes.h
+++ b/clang/include/clang/Serialization/ASTBitCodes.h
@@ -41,7 +41,7 @@ namespace serialization {
 /// Version 4 of AST files also requires that the version control branch and
 /// revision match exactly, since there is no backward compatibility of
 /// AST files at this time.
-const unsigned VERSION_MAJOR = 12;
+const unsigned VERSION_MAJOR = 13;
 
 /// AST file minor version number supported by this version of
 /// Clang.



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


[PATCH] D98265: [NFC] Use llvm::SmallVector to workaround XL compiler problem on AIX

2021-03-09 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast accepted this revision.
hubert.reinterpretcast added a comment.
This revision is now accepted and ready to land.

LGTM; thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98265

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


[PATCH] D46443: [libc++] Add missing cstdalign header

2021-03-09 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added inline comments.



Comment at: libcxx/include/cstdalign:24
+#include <__config>
+#include 
+

hubert.reinterpretcast wrote:
> sbc100 wrote:
> > hubert.reinterpretcast wrote:
> > > This seems to be assuming that the underlying C library's `stdalign.h` is 
> > > C++ friendly. A C11 `stdalign.h` //does// define `alignof` and `alignas` 
> > > as macros.
> > Should I just remove this `#include` then?
> The idea would be to //add// a `stdalign.h` alongside this header that 
> doesn't `#include_next` the underlying C library's `stdalign.h`.
I'm not sure if that should be the solution. At least gcc's libstdc++ assumes 
that `stdalign.h` is C++-compatbile (cf. 
https://github.com/gcc-mirror/gcc/blob/16e2427f50c208dfe07d07f18009969502c25dc8/libstdc%2B%2B-v3/include/c_global/cstdalign).

Clang provides a compatible header: 
https://github.com/llvm/llvm-project/commit/8acb4044d83ecc9df81b1c9f327d5bd4325e1756.
Gcc too of course: 
https://github.com/gcc-mirror/gcc/blob/16e2427f50c208dfe07d07f18009969502c25dc8/gcc/ginclude/stdalign.h.

MSVC's STL on the other hand, doesn't include `` 
(https://github.com/microsoft/STL/blob/main/stl/inc/cstdalign).

@hubert.reinterpretcast, are you aware of an environment which has non-friendly 
`stdalign.h`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D46443

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


[PATCH] D46443: [libc++] Add missing cstdalign header

2021-03-09 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added inline comments.



Comment at: libcxx/include/cstdalign:24
+#include <__config>
+#include 
+

curdeius wrote:
> hubert.reinterpretcast wrote:
> > sbc100 wrote:
> > > hubert.reinterpretcast wrote:
> > > > This seems to be assuming that the underlying C library's `stdalign.h` 
> > > > is C++ friendly. A C11 `stdalign.h` //does// define `alignof` and 
> > > > `alignas` as macros.
> > > Should I just remove this `#include` then?
> > The idea would be to //add// a `stdalign.h` alongside this header that 
> > doesn't `#include_next` the underlying C library's `stdalign.h`.
> I'm not sure if that should be the solution. At least gcc's libstdc++ assumes 
> that `stdalign.h` is C++-compatbile (cf. 
> https://github.com/gcc-mirror/gcc/blob/16e2427f50c208dfe07d07f18009969502c25dc8/libstdc%2B%2B-v3/include/c_global/cstdalign).
> 
> Clang provides a compatible header: 
> https://github.com/llvm/llvm-project/commit/8acb4044d83ecc9df81b1c9f327d5bd4325e1756.
> Gcc too of course: 
> https://github.com/gcc-mirror/gcc/blob/16e2427f50c208dfe07d07f18009969502c25dc8/gcc/ginclude/stdalign.h.
> 
> MSVC's STL on the other hand, doesn't include `` 
> (https://github.com/microsoft/STL/blob/main/stl/inc/cstdalign).
> 
> @hubert.reinterpretcast, are you aware of an environment which has 
> non-friendly `stdalign.h`?
FYI, musl is also C++ friendly: 
https://git.musl-libc.org/cgit/musl/tree/include/stdalign.h.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D46443

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


[PATCH] D98264: [AArch64] Implement __rndr, __rndrrs intrinsics

2021-03-09 Thread Dave Green via Phabricator via cfe-commits
dmgreen added inline comments.



Comment at: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp:15993
+  DAG.getConstant(0, dl, MVT::i32),
+  DAG.getConstant(AArch64CC::EQ, dl, MVT::i32), A.getValue(1));
+  return DAG.getMergeValues(

Can you make sure EQ is correct here? I think it might be backwards.



Comment at: llvm/lib/Target/AArch64/AArch64InstrFormats.td:1495
   let DecoderNamespace = "Fallback";
+  let Defs = [NZCV];
 }

SjoerdMeijer wrote:
> dmgreen wrote:
> > SjoerdMeijer wrote:
> > > Do all MRS instructions do this?
> > No, but some do and it's not obvious which ones do and don't. I think it 
> > should be reasonable to always def NZCV here, even if they are just dead. 
> > It should be very rare that it would be beneficial for NZCV to be live 
> > across a MRS instruction.
> True, but since creating another definition is cheap, what would the cons be 
> of:
> 
>   class MRS_NZCV : MRSI {
> ..
> let Defs = [NZCV];
>   }
> 
> The way I look at it is that the description would be more accurate?
I believe that would have an over-lapping definition with the existing MRS 
instruction?

It would need to be a pseudo I think, which would eventually be turned into a 
MSR proper late enough on the pipeline for it to be valid (or the other way 
around, the no-nzcv version gets turned into a the nzcv version to keep the 
verifier happy).

It could also be a optional def, but those are only used in the arm backend and 
I would not recommend using them anywhere else.  I would probably suggest just 
setting MRS as a NZCV setting instruction, unless we find a reason to need to 
implement it differently.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98264

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


[clang] 561fb7f - [NFC] Use llvm::SmallVector to workaround XL compiler problem on AIX

2021-03-09 Thread Xiangling Liao via cfe-commits

Author: Xiangling Liao
Date: 2021-03-09T13:03:52-05:00
New Revision: 561fb7f60ab631e712c3fb6bbeb47061222c6818

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

LOG: [NFC] Use llvm::SmallVector to workaround XL compiler problem on AIX

LLVM is recommending to use SmallVector (that is, omitting the N), in the
absence of a well-motivated choice for the number of inlined elements N.

However, this doesn't work well with XL compiler on AIX since some header(s)
aren't properly picked up with it. We need to take a further look into the real
issue underneath and fix it in a later patch.

But currently we'd like to use this patch to unblock the build compiler issue
first.

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

Added: 


Modified: 
clang/lib/CodeGen/CGStmtOpenMP.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 2eaa481cd911..575d1143caab 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -1913,7 +1913,7 @@ static llvm::CallInst *
 emitCapturedStmtCall(CodeGenFunction &ParentCGF, EmittedClosureTy Cap,
  llvm::ArrayRef Args) {
   // Append the closure context to the argument.
-  SmallVector EffectiveArgs;
+  llvm::SmallVector EffectiveArgs;
   EffectiveArgs.reserve(Args.size() + 1);
   llvm::append_range(EffectiveArgs, Args);
   EffectiveArgs.push_back(Cap.second);



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


[PATCH] D98265: [NFC] Use llvm::SmallVector to workaround XL compiler problem on AIX

2021-03-09 Thread Xiangling Liao 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 rG561fb7f60ab6: [NFC] Use llvm::SmallVector to workaround XL 
compiler problem on AIX (authored by Xiangling_L).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98265

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp


Index: clang/lib/CodeGen/CGStmtOpenMP.cpp
===
--- clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -1913,7 +1913,7 @@
 emitCapturedStmtCall(CodeGenFunction &ParentCGF, EmittedClosureTy Cap,
  llvm::ArrayRef Args) {
   // Append the closure context to the argument.
-  SmallVector EffectiveArgs;
+  llvm::SmallVector EffectiveArgs;
   EffectiveArgs.reserve(Args.size() + 1);
   llvm::append_range(EffectiveArgs, Args);
   EffectiveArgs.push_back(Cap.second);


Index: clang/lib/CodeGen/CGStmtOpenMP.cpp
===
--- clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -1913,7 +1913,7 @@
 emitCapturedStmtCall(CodeGenFunction &ParentCGF, EmittedClosureTy Cap,
  llvm::ArrayRef Args) {
   // Append the closure context to the argument.
-  SmallVector EffectiveArgs;
+  llvm::SmallVector EffectiveArgs;
   EffectiveArgs.reserve(Args.size() + 1);
   llvm::append_range(EffectiveArgs, Args);
   EffectiveArgs.push_back(Cap.second);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98255: [release][docs] List all cores Arm has added support for in LLVM 12.

2021-03-09 Thread Amilendra Kodithuwakku via Phabricator via cfe-commits
amilendra updated this revision to Diff 329380.
amilendra added a comment.
Herald added subscribers: llvm-commits, libcxx-commits, openmp-commits, 
lldb-commits, Sanitizers, jansvoboda11, frasercrmck, dexonsmith, ecnelises, 
wenlei, dang, jdoerfert, sstefan1, omjavaid, jvesely, phosek, kerbowa, 
luismarques, apazos, sameer.abuasal, usaxena95, pengfei, s.egerton, Jim, 
asbirlea, ormris, mstorsjo, kadircet, jocewei, rupprecht, PkmX, jfb, arphaman, 
the_o, brucehoult, MartinMosbeck, rogfer01, steven_wu, mgrang, edward-jones, 
george.burgess.iv, zzheng, MaskRay, jrtc27, martong, niosHD, sabuasal, 
simoncook, johnrusso, rbar, asb, kbarton, aheejin, hiraditya, fedor.sergeev, 
eraman, arichardson, sbc100, mgorny, nhaehnle, nemanjai, emaste, arsenm, MatzeB.
Herald added a reviewer: deadalnix.
Herald added a reviewer: shafik.
Herald added a reviewer: jdoerfert.
Herald added a reviewer: jhenderson.
Herald added a reviewer: MaskRay.
Herald added projects: Sanitizers, LLDB, libc++, OpenMP, libc++abi, libunwind, 
LLVM.
Herald added a reviewer: libc++.
Herald added a reviewer: libc++abi.
Herald added a reviewer: libunwind.

- Fix test failures after a92ceea91116e7b95d23eff634507fa2cff86ef2 

- [libc++] Fix extern template test failing on Windows
- [libc++] Fix extern-templates.sh.cpp test on Linux
- [release][docs] List all cores Arm has added support for in LLVM 12.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98255

Files:
  .github/workflows/clang-tests.yml
  .github/workflows/libclang-abi-tests.yml
  .github/workflows/libclc-tests.yml
  .github/workflows/lld-tests.yml
  .github/workflows/lldb-tests.yml
  .github/workflows/llvm-tests.yml
  .github/workflows/main-branch-sync.yml
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.h
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/Config.h
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/ConfigFragment.h
  clang-tools-extra/clangd/ConfigYAML.cpp
  clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/TidyProvider.cpp
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/support/CMakeLists.txt
  clang-tools-extra/clangd/support/Function.h
  clang-tools-extra/clangd/support/Path.cpp
  clang-tools-extra/clangd/support/Path.h
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
  clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp
  clang-tools-extra/clangd/unittests/TidyProviderTests.cpp
  clang-tools-extra/clangd/unittests/support/PathTests.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-prefer-member-initializer.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer-modernize-use-default-member-init-assignment.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer-modernize-use-default-member-init.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer.cpp
  clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/AST/Mangle.h
  clang/include/clang/AST/MangleNumberingContext.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Lex/VariadicMacroSupport.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/CXXABI.h
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ItaniumCXXABI.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftCXXABI.cpp
  clang/lib/ASTMatchers/ASTMatchFinder.cpp
  clang/lib/ASTMatchers/ASTMatchersInternal.cpp
  clang/lib/Basic/ProfileList.cpp
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGCUDANV.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/lib/Driver/ToolChain

[PATCH] D98255: [release][docs] List all cores Arm has added support for in LLVM 12.

2021-03-09 Thread Amilendra Kodithuwakku via Phabricator via cfe-commits
amilendra abandoned this revision.
amilendra added a comment.
Herald added a subscriber: JDevlieghere.

Abandoning this revision because I think I messed up something when using 
arcanist to fix pre-merge errors. 
https://buildkite.com/llvm-project/diff-checks/builds/32719
I'll submit a new review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98255

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


[PATCH] D97743: Define __GCC_HAVE_DWARF2_CFI_ASM if applicable

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

In D97743#2613629 , @jansvoboda11 
wrote:

> Could the logic be implemented in the driver?
>
> LGTM regardless.

No. `Res` is a `clang::CompilerInvocation` object. `CompilerInvocation` is not 
in the driver...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97743

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


[PATCH] D98264: [AArch64] Implement __rndr, __rndrrs intrinsics

2021-03-09 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added inline comments.



Comment at: llvm/lib/Target/AArch64/AArch64InstrFormats.td:1495
   let DecoderNamespace = "Fallback";
+  let Defs = [NZCV];
 }

dmgreen wrote:
> SjoerdMeijer wrote:
> > dmgreen wrote:
> > > SjoerdMeijer wrote:
> > > > Do all MRS instructions do this?
> > > No, but some do and it's not obvious which ones do and don't. I think it 
> > > should be reasonable to always def NZCV here, even if they are just dead. 
> > > It should be very rare that it would be beneficial for NZCV to be live 
> > > across a MRS instruction.
> > True, but since creating another definition is cheap, what would the cons 
> > be of:
> > 
> >   class MRS_NZCV : MRSI {
> > ..
> > let Defs = [NZCV];
> >   }
> > 
> > The way I look at it is that the description would be more accurate?
> I believe that would have an over-lapping definition with the existing MRS 
> instruction?
> 
> It would need to be a pseudo I think, which would eventually be turned into a 
> MSR proper late enough on the pipeline for it to be valid (or the other way 
> around, the no-nzcv version gets turned into a the nzcv version to keep the 
> verifier happy).
> 
> It could also be a optional def, but those are only used in the arm backend 
> and I would not recommend using them anywhere else.  I would probably suggest 
> just setting MRS as a NZCV setting instruction, unless we find a reason to 
> need to implement it differently.
> I believe that would have an over-lapping definition with the existing MRS 
> instruction?

Ah yeah, that might be true.

> It would need to be a pseudo I think

How much work is adding a pseudo for this case? My first reaction would be just 
trying to model this correctly, then we potentially don't have to worry again 
later about this. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98264

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


[clang] c11ff4b - Define __GCC_HAVE_DWARF2_CFI_ASM if applicable

2021-03-09 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2021-03-09T10:52:26-08:00
New Revision: c11ff4bbada3b5127a1f010e0a97a1e6e46fb61a

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

LOG: Define __GCC_HAVE_DWARF2_CFI_ASM if applicable

In -fno-exceptions -fno-asynchronous-unwind-tables -g0 mode,
GCC does not emit `.cfi_*` directives.

```
% diff <(gcc -fno-asynchronous-unwind-tables -dM -E a.c) <(gcc -dM -E a.c)
130a131
> #define __GCC_HAVE_DWARF2_CFI_ASM 1
```

This macro is useful because code can decide whether inline asm should include 
`.cfi_*` directives.
`.cfi_*` directives without `.cfi_startproc` can cause assembler errors
(integrated assembler: `this directive must appear between .cfi_startproc and 
.cfi_endproc directives`).

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

Added: 
clang/test/Preprocessor/unwind-tables.c

Modified: 
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 2606e9f1b185..bd0240870706 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -4355,6 +4355,11 @@ bool CompilerInvocation::CreateFromArgsImpl(
   Res.getCodeGenOpts().Argv0 = Argv0;
   Res.getCodeGenOpts().CommandLineArgs = CommandLineArgs;
 
+  if ((T.isOSBinFormatELF() || T.isOSBinFormatMachO()) &&
+  (Res.getLangOpts()->Exceptions || Res.getCodeGenOpts().UnwindTables ||
+   Res.getCodeGenOpts().getDebugInfo() != codegenoptions::NoDebugInfo))
+Res.getPreprocessorOpts().addMacroDef("__GCC_HAVE_DWARF2_CFI_ASM=1");
+
   Success &= FixupInvocation(Res, Diags, Args, DashX);
 
   return Success;

diff  --git a/clang/test/Preprocessor/unwind-tables.c 
b/clang/test/Preprocessor/unwind-tables.c
new file mode 100644
index ..2f769761b6c6
--- /dev/null
+++ b/clang/test/Preprocessor/unwind-tables.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 %s -verify -munwind-tables -triple x86_64-windows
+// RUN: %clang_cc1 %s -verify -triple x86_64-unknown-elf
+
+// RUN: %clang_cc1 %s -verify -munwind-tables -DCFI_ASM -triple 
x86_64-unknown-elf
+// RUN: %clang_cc1 %s -verify -munwind-tables -DCFI_ASM -triple 
aarch64-apple-darwin
+// RUN: %clang_cc1 %s -verify -debug-info-kind=line-tables-only -DCFI_ASM 
-triple x86_64-unknown-elf
+// RUN: %clang_cc1 %s -verify -fexceptions -DCFI_ASM -triple x86_64-unknown-elf
+
+// expected-no-diagnostics
+
+#ifdef CFI_ASM
+  #if __GCC_HAVE_DWARF2_CFI_ASM != 1
+  #error "__GCC_HAVE_DWARF2_CFI_ASM not defined"
+  #endif
+#else
+  #ifdef __GCC_HAVE_DWARF2_CFI_ASM
+  #error "__GCC_HAVE_DWARF2_CFI_ASM defined"
+  #endif
+#endif



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


[PATCH] D97743: Define __GCC_HAVE_DWARF2_CFI_ASM if applicable

2021-03-09 Thread Fangrui Song 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 rGc11ff4bbada3: Define __GCC_HAVE_DWARF2_CFI_ASM if applicable 
(authored by MaskRay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97743

Files:
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Preprocessor/unwind-tables.c


Index: clang/test/Preprocessor/unwind-tables.c
===
--- /dev/null
+++ clang/test/Preprocessor/unwind-tables.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 %s -verify -munwind-tables -triple x86_64-windows
+// RUN: %clang_cc1 %s -verify -triple x86_64-unknown-elf
+
+// RUN: %clang_cc1 %s -verify -munwind-tables -DCFI_ASM -triple 
x86_64-unknown-elf
+// RUN: %clang_cc1 %s -verify -munwind-tables -DCFI_ASM -triple 
aarch64-apple-darwin
+// RUN: %clang_cc1 %s -verify -debug-info-kind=line-tables-only -DCFI_ASM 
-triple x86_64-unknown-elf
+// RUN: %clang_cc1 %s -verify -fexceptions -DCFI_ASM -triple x86_64-unknown-elf
+
+// expected-no-diagnostics
+
+#ifdef CFI_ASM
+  #if __GCC_HAVE_DWARF2_CFI_ASM != 1
+  #error "__GCC_HAVE_DWARF2_CFI_ASM not defined"
+  #endif
+#else
+  #ifdef __GCC_HAVE_DWARF2_CFI_ASM
+  #error "__GCC_HAVE_DWARF2_CFI_ASM defined"
+  #endif
+#endif
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -4355,6 +4355,11 @@
   Res.getCodeGenOpts().Argv0 = Argv0;
   Res.getCodeGenOpts().CommandLineArgs = CommandLineArgs;
 
+  if ((T.isOSBinFormatELF() || T.isOSBinFormatMachO()) &&
+  (Res.getLangOpts()->Exceptions || Res.getCodeGenOpts().UnwindTables ||
+   Res.getCodeGenOpts().getDebugInfo() != codegenoptions::NoDebugInfo))
+Res.getPreprocessorOpts().addMacroDef("__GCC_HAVE_DWARF2_CFI_ASM=1");
+
   Success &= FixupInvocation(Res, Diags, Args, DashX);
 
   return Success;


Index: clang/test/Preprocessor/unwind-tables.c
===
--- /dev/null
+++ clang/test/Preprocessor/unwind-tables.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 %s -verify -munwind-tables -triple x86_64-windows
+// RUN: %clang_cc1 %s -verify -triple x86_64-unknown-elf
+
+// RUN: %clang_cc1 %s -verify -munwind-tables -DCFI_ASM -triple x86_64-unknown-elf
+// RUN: %clang_cc1 %s -verify -munwind-tables -DCFI_ASM -triple aarch64-apple-darwin
+// RUN: %clang_cc1 %s -verify -debug-info-kind=line-tables-only -DCFI_ASM -triple x86_64-unknown-elf
+// RUN: %clang_cc1 %s -verify -fexceptions -DCFI_ASM -triple x86_64-unknown-elf
+
+// expected-no-diagnostics
+
+#ifdef CFI_ASM
+  #if __GCC_HAVE_DWARF2_CFI_ASM != 1
+  #error "__GCC_HAVE_DWARF2_CFI_ASM not defined"
+  #endif
+#else
+  #ifdef __GCC_HAVE_DWARF2_CFI_ASM
+  #error "__GCC_HAVE_DWARF2_CFI_ASM defined"
+  #endif
+#endif
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -4355,6 +4355,11 @@
   Res.getCodeGenOpts().Argv0 = Argv0;
   Res.getCodeGenOpts().CommandLineArgs = CommandLineArgs;
 
+  if ((T.isOSBinFormatELF() || T.isOSBinFormatMachO()) &&
+  (Res.getLangOpts()->Exceptions || Res.getCodeGenOpts().UnwindTables ||
+   Res.getCodeGenOpts().getDebugInfo() != codegenoptions::NoDebugInfo))
+Res.getPreprocessorOpts().addMacroDef("__GCC_HAVE_DWARF2_CFI_ASM=1");
+
   Success &= FixupInvocation(Res, Diags, Args, DashX);
 
   return Success;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98274: [clangd][NFC] Use std::string::replace in SourceCode:applyChange.

2021-03-09 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: sammccall, kadircet.
Herald added subscribers: usaxena95, arphaman.
njames93 requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang.

Just looks nicer and easier to read.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98274

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


Index: clang-tools-extra/clangd/SourceCode.cpp
===
--- clang-tools-extra/clangd/SourceCode.cpp
+++ clang-tools-extra/clangd/SourceCode.cpp
@@ -1091,15 +1091,8 @@
  "computed range length ({1}).",
  *Change.rangeLength, ComputedRangeLength);
 
-  std::string NewContents;
-  NewContents.reserve(*StartIndex + Change.text.length() +
-  (Contents.length() - *EndIndex));
+  Contents.replace(*StartIndex, *EndIndex - *StartIndex, Change.text);
 
-  NewContents = Contents.substr(0, *StartIndex);
-  NewContents += Change.text;
-  NewContents += Contents.substr(*EndIndex);
-
-  std::swap(Contents, NewContents);
   return llvm::Error::success();
 }
 


Index: clang-tools-extra/clangd/SourceCode.cpp
===
--- clang-tools-extra/clangd/SourceCode.cpp
+++ clang-tools-extra/clangd/SourceCode.cpp
@@ -1091,15 +1091,8 @@
  "computed range length ({1}).",
  *Change.rangeLength, ComputedRangeLength);
 
-  std::string NewContents;
-  NewContents.reserve(*StartIndex + Change.text.length() +
-  (Contents.length() - *EndIndex));
+  Contents.replace(*StartIndex, *EndIndex - *StartIndex, Change.text);
 
-  NewContents = Contents.substr(0, *StartIndex);
-  NewContents += Change.text;
-  NewContents += Contents.substr(*EndIndex);
-
-  std::swap(Contents, NewContents);
   return llvm::Error::success();
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98275: [clang-tidy] Fix mpi checks when running multiple TUs per clang-tidy process

2021-03-09 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: alexfh, aaron.ballman.
Herald added a subscriber: xazax.hun.
njames93 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Both the mpi-type-mismatch and mpi-buffer-deref check make use of a static 
MPIFunctionClassifier object.
This causes issue as the classifier is initialized with the first ASTContext 
that produces a match.
If the check is enabled on multiple translation units in a single clang-tidy 
process, this classifier won't be reinitialized for each TU. I'm not an expert 
in the MPIFunctionClassifier but I'd imagine this is a source of UB.
It is suspected that this bug may result in the crash caused here: 
https://bugs.llvm.org/show_bug.cgi?id=48985. However even if not the case, this 
should still be addressed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98275

Files:
  clang-tools-extra/clang-tidy/mpi/BufferDerefCheck.cpp
  clang-tools-extra/clang-tidy/mpi/BufferDerefCheck.h
  clang-tools-extra/clang-tidy/mpi/TypeMismatchCheck.cpp
  clang-tools-extra/clang-tidy/mpi/TypeMismatchCheck.h

Index: clang-tools-extra/clang-tidy/mpi/TypeMismatchCheck.h
===
--- clang-tools-extra/clang-tidy/mpi/TypeMismatchCheck.h
+++ clang-tools-extra/clang-tidy/mpi/TypeMismatchCheck.h
@@ -11,6 +11,7 @@
 
 #include "../ClangTidyCheck.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/StaticAnalyzer/Checkers/MPIFunctionClassifier.h"
 
 namespace clang {
 namespace tidy {
@@ -31,6 +32,8 @@
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
 
+  void onEndOfTranslationUnit() override;
+
 private:
   /// Check if the buffer type MPI datatype pairs match.
   ///
@@ -41,6 +44,8 @@
   void checkArguments(ArrayRef BufferTypes,
   ArrayRef BufferExprs,
   ArrayRef MPIDatatypes, const LangOptions &LO);
+
+  Optional FuncClassifier;
 };
 
 } // namespace mpi
Index: clang-tools-extra/clang-tidy/mpi/TypeMismatchCheck.cpp
===
--- clang-tools-extra/clang-tidy/mpi/TypeMismatchCheck.cpp
+++ clang-tools-extra/clang-tidy/mpi/TypeMismatchCheck.cpp
@@ -8,7 +8,6 @@
 
 #include "TypeMismatchCheck.h"
 #include "clang/Lex/Lexer.h"
-#include "clang/StaticAnalyzer/Checkers/MPIFunctionClassifier.h"
 #include "clang/Tooling/FixIt.h"
 #include 
 #include 
@@ -241,13 +240,15 @@
 }
 
 void TypeMismatchCheck::check(const MatchFinder::MatchResult &Result) {
-  static ento::mpi::MPIFunctionClassifier FuncClassifier(*Result.Context);
   const auto *const CE = Result.Nodes.getNodeAs("CE");
   if (!CE->getDirectCallee())
 return;
 
+  if (!FuncClassifier)
+FuncClassifier.emplace(*Result.Context);
+
   const IdentifierInfo *Identifier = CE->getDirectCallee()->getIdentifier();
-  if (!Identifier || !FuncClassifier.isMPIType(Identifier))
+  if (!Identifier || !FuncClassifier->isMPIType(Identifier))
 return;
 
   // These containers are used, to capture buffer, MPI datatype pairs.
@@ -281,18 +282,18 @@
   };
 
   // Collect all buffer, MPI datatype pairs for the inspected call expression.
-  if (FuncClassifier.isPointToPointType(Identifier)) {
+  if (FuncClassifier->isPointToPointType(Identifier)) {
 AddPair(0, 2);
-  } else if (FuncClassifier.isCollectiveType(Identifier)) {
-if (FuncClassifier.isReduceType(Identifier)) {
+  } else if (FuncClassifier->isCollectiveType(Identifier)) {
+if (FuncClassifier->isReduceType(Identifier)) {
   AddPair(0, 3);
   AddPair(1, 3);
-} else if (FuncClassifier.isScatterType(Identifier) ||
-   FuncClassifier.isGatherType(Identifier) ||
-   FuncClassifier.isAlltoallType(Identifier)) {
+} else if (FuncClassifier->isScatterType(Identifier) ||
+   FuncClassifier->isGatherType(Identifier) ||
+   FuncClassifier->isAlltoallType(Identifier)) {
   AddPair(0, 2);
   AddPair(3, 5);
-} else if (FuncClassifier.isBcastType(Identifier)) {
+} else if (FuncClassifier->isBcastType(Identifier)) {
   AddPair(0, 2);
 }
   }
@@ -331,6 +332,7 @@
   }
 }
 
+void TypeMismatchCheck::onEndOfTranslationUnit() { FuncClassifier.reset(); }
 } // namespace mpi
 } // namespace tidy
 } // namespace clang
Index: clang-tools-extra/clang-tidy/mpi/BufferDerefCheck.h
===
--- clang-tools-extra/clang-tidy/mpi/BufferDerefCheck.h
+++ clang-tools-extra/clang-tidy/mpi/BufferDerefCheck.h
@@ -10,6 +10,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MPI_BUFFER_DEREF_H
 
 #include "../ClangTidyCheck.h"
+#include "clang/StaticAnalyzer/Checkers/MPIFunctionClassifier.h"
 
 namespace clang {
 namespace tidy {
@@ -30,6 +31,7 @@
   : ClangTidyCheck(Name, Context) {}
   void registerMatchers(ast_mat

[PATCH] D98277: [release][docs] List all cores Arm has added support for in LLVM 12.

2021-03-09 Thread Amilendra Kodithuwakku via Phabricator via cfe-commits
amilendra created this revision.
amilendra added reviewers: willlovett, kristof.beyls, jgreenhalgh.
amilendra requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98277

Files:
  clang/docs/ReleaseNotes.rst


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -130,6 +130,15 @@
   This behavior matches newer GCC.
   (`D91760 `_)
   (`D92054 `_)
+- Support has been added for the following processors (command-line identifiers
+  in parentheses):
+  - Arm Cortex-A78C (cortex-a78c).
+  - Arm Cortex-R82 (cortex-r82).
+  - Arm Neoverse V1 (neoverse-v1).
+  - Arm Neoverse N2 (neoverse-n2).
+  - Fujitsu A64FX (a64fx).
+  For example, to select architecture support and tuning for Neoverse-V1 based
+  systems, use ``-mcpu=neoverse-v1``.
 
 Removed Compiler Flags
 -


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -130,6 +130,15 @@
   This behavior matches newer GCC.
   (`D91760 `_)
   (`D92054 `_)
+- Support has been added for the following processors (command-line identifiers
+  in parentheses):
+  - Arm Cortex-A78C (cortex-a78c).
+  - Arm Cortex-R82 (cortex-r82).
+  - Arm Neoverse V1 (neoverse-v1).
+  - Arm Neoverse N2 (neoverse-n2).
+  - Fujitsu A64FX (a64fx).
+  For example, to select architecture support and tuning for Neoverse-V1 based
+  systems, use ``-mcpu=neoverse-v1``.
 
 Removed Compiler Flags
 -
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97743: Define __GCC_HAVE_DWARF2_CFI_ASM if applicable

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

This seems to break tests everywhere: http://45.33.8.238/linux/41275/step_7.txt


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97743

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


[clang] 8bb8d65 - Move some attribute diagnostic helper functions; NFC.

2021-03-09 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2021-03-09T14:57:00-05:00
New Revision: 8bb8d65e167dceb659211468fd44df5da17e0785

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

LOG: Move some attribute diagnostic helper functions; NFC.

These functions were local to SemaDeclAttr.cpp, but these functions are
useful in general (for instance, for statement or type attribute
processing). This refactoring is in advance of beginning to tablegen
diagnostic checks for statement attributes the way we already do for
declaration attributes.

There is one functional change in here as a drive-by. The
external_source_symbol attribute had one of its diagnostic checks
inside of an assert, which was corrected.

Added: 


Modified: 
clang/include/clang/Sema/ParsedAttr.h
clang/lib/Sema/ParsedAttr.cpp
clang/lib/Sema/SemaDeclAttr.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/ParsedAttr.h 
b/clang/include/clang/Sema/ParsedAttr.h
index 43c21faaece9..0d731d9150a8 100644
--- a/clang/include/clang/Sema/ParsedAttr.h
+++ b/clang/include/clang/Sema/ParsedAttr.h
@@ -573,6 +573,16 @@ class ParsedAttr final
 return MacroExpansionLoc;
   }
 
+  /// Check if the attribute has exactly as many args as Num. May output an
+  /// error. Returns false if a diagnostic is produced.
+  bool checkExactlyNumArgs(class Sema &S, unsigned Num) const;
+  /// Check if the attribute has at least as many args as Num. May output an
+  /// error. Returns false if a diagnostic is produced.
+  bool checkAtLeastNumArgs(class Sema &S, unsigned Num) const;
+  /// Check if the attribute has at most as many args as Num. May output an
+  /// error. Returns false if a diagnostic is produced.
+  bool checkAtMostNumArgs(class Sema &S, unsigned Num) const;
+
   bool isTargetSpecificAttr() const;
   bool isTypeAttr() const;
   bool isStmtAttr() const;

diff  --git a/clang/lib/Sema/ParsedAttr.cpp b/clang/lib/Sema/ParsedAttr.cpp
index 3ef8498baffd..c6a3d7c4342c 100644
--- a/clang/lib/Sema/ParsedAttr.cpp
+++ b/clang/lib/Sema/ParsedAttr.cpp
@@ -204,3 +204,35 @@ bool ParsedAttr::hasVariadicArg() const {
   // whether it's truly variadic or not.
   return getInfo().OptArgs == 15;
 }
+
+static unsigned getNumAttributeArgs(const ParsedAttr &AL) {
+  // FIXME: Include the type in the argument list.
+  return AL.getNumArgs() + AL.hasParsedType();
+}
+
+template 
+static bool checkAttributeNumArgsImpl(Sema &S, const ParsedAttr &AL,
+  unsigned Num, unsigned Diag,
+  Compare Comp) {
+  if (Comp(getNumAttributeArgs(AL), Num)) {
+S.Diag(AL.getLoc(), Diag) << AL << Num;
+return false;
+  }
+  return true;
+}
+
+bool ParsedAttr::checkExactlyNumArgs(Sema &S, unsigned Num) const {
+  return checkAttributeNumArgsImpl(S, *this, Num,
+   diag::err_attribute_wrong_number_arguments,
+   std::not_equal_to());
+}
+bool ParsedAttr::checkAtLeastNumArgs(Sema &S, unsigned Num) const {
+  return checkAttributeNumArgsImpl(S, *this, Num,
+   diag::err_attribute_too_few_arguments,
+   std::less());
+}
+bool ParsedAttr::checkAtMostNumArgs(Sema &S, unsigned Num) const {
+  return checkAttributeNumArgsImpl(S, *this, Num,
+   diag::err_attribute_too_many_arguments,
+   std::greater());
+}

diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 4376342185fb..5b9acda6738e 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -191,44 +191,6 @@ static unsigned getNumAttributeArgs(const ParsedAttr &AL) {
   return AL.getNumArgs() + AL.hasParsedType();
 }
 
-template 
-static bool checkAttributeNumArgsImpl(Sema &S, const ParsedAttr &AL,
-  unsigned Num, unsigned Diag,
-  Compare Comp) {
-  if (Comp(getNumAttributeArgs(AL), Num)) {
-S.Diag(AL.getLoc(), Diag) << AL << Num;
-return false;
-  }
-
-  return true;
-}
-
-/// Check if the attribute has exactly as many args as Num. May
-/// output an error.
-static bool checkAttributeNumArgs(Sema &S, const ParsedAttr &AL, unsigned Num) 
{
-  return checkAttributeNumArgsImpl(S, AL, Num,
-   diag::err_attribute_wrong_number_arguments,
-   std::not_equal_to());
-}
-
-/// Check if the attribute has at least as many args as Num. May
-/// output an error.
-static bool checkAttributeAtLeastNumArgs(Sema &S, const ParsedAttr &AL,
- unsigned Num) {
-  return checkAttributeNumArgsImpl(S, AL, Num,
-   diag::er

  1   2   >